1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  *
16  * Data and structure definitions for h5import
17  *
18  */
19 
20 #ifndef H5IMPORT_H__
21 #define H5IMPORT_H__
22 
23 /*
24  * state table tokens
25  */
26 #define FILNAME 0
27 /* filename */
28 #define OPT_o   1
29 /* output filename */
30 #define OPT_c   2   /* configuration filename */
31 #define OPT_h   3   /* request for explanation */
32 #define OPT_d   4   /* dimensions */
33 #define OPT_p   5   /* pathname */
34 #define OPT_t   6   /* data type */
35 #define OPT_s   7   /* data size */
36 #define ERR    20  /* invalid token */
37 
38 #define MAX_GROUPS_IN_PATH  20
39 #define MAX_PATH_NAME_LENGTH 255
40 #define NUM_KEYS 15
41 #define MIN_NUM_DIMENSION  1
42 #define MAX_NUM_DIMENSION  32
43 #define BASE_10 10
44 
45 #define PATH             0
46 #define INPUT_CLASS      1
47 #define INPUT_SIZE       2
48 #define RANK             3
49 #define DIM              4
50 #define OUTPUT_CLASS     5
51 #define OUTPUT_SIZE      6
52 #define OUTPUT_ARCH      7
53 #define OUTPUT_B_ORDER   8
54 #define CHUNK            9
55 #define COMPRESS         10
56 #define COMPRESS_PARAM   11
57 #define EXTERNALSTORE    12
58 #define EXTEND           13
59 #define INPUT_B_ORDER    14
60 
61 /* data types */
62 #define H5DT_INT8      signed char
63 #define H5DT_INT16     short
64 #define H5DT_INT32     int
65 #define H5DT_FLOAT32   float
66 #define H5DT_FLOAT64   double
67 #define VOIDP          void*
68 #define H5DT_UINT8     unsigned char
69 #define H5DT_UINT16    unsigned short
70 #define H5DT_UINT32    unsigned int
71 #define H5DT_INT64     long long
72 #define H5DT_UINT64    unsigned H5DT_INT64
73 
74 struct path_info
75 {
76     char group[MAX_GROUPS_IN_PATH][MAX_PATH_NAME_LENGTH];
77     int count;
78 };
79 
80 struct Input
81 {
82     int h5dumpInput;
83     struct path_info path;
84     int inputClass;
85     int inputSize;
86     int inputArchitecture;
87     int inputByteOrder;
88     int rank;
89     hsize_t* sizeOfDimension;
90     int outputClass;
91     int outputSize;
92     int outputArchitecture;
93     int outputByteOrder;
94     hsize_t* sizeOfChunk;
95     hsize_t* maxsizeOfDimension;
96     int compressionType;
97     int compressionParam;
98     char *externFilename;
99     VOIDP data;
100     int configOptionVector[NUM_KEYS];
101 };
102 
103 struct infilesformat
104 {
105     char datafile[MAX_PATH_NAME_LENGTH];
106     char configfile[MAX_PATH_NAME_LENGTH];
107     struct Input in;
108     int config; /* Configfile present? No - 0. Yes - 1 */
109 };
110 
111 struct Options
112 {
113     struct infilesformat  infiles[30];  /* structure to hold the list of input file names. Limited to 30*/
114     char   outfile[256];  /* output file name */
115     int    fcount;       /* number of input files */
116 };
117 
118 char keytable[NUM_KEYS][30] = {
119         "PATH",
120         "INPUT-CLASS",
121         "INPUT-SIZE",
122         "RANK",
123         "DIMENSION-SIZES",
124         "OUTPUT-CLASS",
125         "OUTPUT-SIZE",
126         "OUTPUT-ARCHITECTURE",
127         "OUTPUT-BYTE-ORDER",
128         "CHUNKED-DIMENSION-SIZES",
129         "COMPRESSION-TYPE",
130         "COMPRESSION-PARAM",
131         "EXTERNAL-STORAGE",
132         "MAXIMUM-DIMENSIONS",
133         "INPUT-BYTE-ORDER"
134 };
135 
136 static int  state_table[15][8] =
137 {
138     /* token ordering: FILNAME      OPT_o   OPT_c  OPT_h  OPT_d  OPT_p  OPT_t  OPT_s   */
139 
140     /* state 0: start */
141     {1, ERR, ERR, 6, ERR, ERR, ERR, ERR},
142 
143     /* state 1: input files */
144     {ERR, ERR, 2, ERR, 7, ERR, ERR, ERR},
145 
146     /* state 2: -c[onfigfile] */
147     {3, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
148 
149     /* state 3: configfile */
150     {1, 4, ERR, ERR, ERR, ERR, ERR, ERR},
151 
152     /* state 4: -o[utfile] */
153     {5, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
154 
155     /* state 5: outfile */
156     {ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
157 
158     /* state 6: -h[elp] */
159     {ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
160 
161     /* state 7: -d[ims] */
162     {8, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
163 
164     /* state 8: dimensions */
165     {1, 4, ERR, ERR, ERR, 9, 11, 13},
166 
167     /* state 9: -p[ath] */
168     {10, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
169 
170     /* state 10: path name */
171     {1, 4, ERR, ERR, ERR, ERR, 11, 13},
172 
173     /* state 11: -t[ype] */
174     {12, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
175 
176     /* state 12: data type */
177     {1, 4, ERR, ERR, ERR, ERR, ERR, 13},
178 
179     /* state 13: -s[ize] */
180     {14, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
181 
182     /* state 14: data size */
183     {1, 4, ERR, ERR, ERR, ERR, ERR, ERR}
184 
185 };
186 
187 /*
188  *
189  *  Function declarations for h5import
190  *
191  */
192 void  usage(char *);
193 void  setDefaultValues(struct Input *in, int count);
194 void  help(char *);
195 
196 hid_t       createOutputDataType(struct Input *in);
197 hid_t       createInputDataType(struct Input *in);
198 
199 #endif  /* H5IMPORT_H__ */
200 
201