2
Copyright (c) 1994 - 2010, Lawrence Livermore National Security, LLC.
6
This file is part of Silo. For details, see silo.llnl.gov.
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions
12
* Redistributions of source code must retain the above copyright
13
notice, this list of conditions and the disclaimer below.
14
* Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the disclaimer (as noted
16
below) in the documentation and/or other materials provided with
18
* Neither the name of the LLNS/LLNL nor the names of its
19
contributors may be used to endorse or promote products derived
20
from this software without specific prior written permission.
22
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE
26
LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR
27
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
This work was produced at Lawrence Livermore National Laboratory under
36
Contract No. DE-AC52-07NA27344 with the DOE. Neither the United
37
States Government nor Lawrence Livermore National Security, LLC nor
38
any of their employees, makes any warranty, express or implied, or
39
assumes any liability or responsibility for the accuracy,
40
completeness, or usefulness of any information, apparatus, product, or
41
process disclosed, or represents that its use would not infringe
42
privately-owned rights. Any reference herein to any specific
43
commercial products, process, or services by trade name, trademark,
44
manufacturer or otherwise does not necessarily constitute or imply its
45
endorsement, recommendation, or favoring by the United States
46
Government or Lawrence Livermore National Security, LLC. The views and
47
opinions of authors expressed herein do not necessarily state or
48
reflect those of the United States Government or Lawrence Livermore
49
National Security, LLC, and shall not be used for advertising or
50
product endorsement purposes.
57
#ifndef WINDOWS_LEAN_AND_MEAN
58
#define WINDOWS_LEAN_AND_MEAN
63
#define CHECK_SYMBOL(A) if (!strncmp(str, #A, strlen(str))) return A
65
#define CHECK_SYMBOLN_INT(A) \
66
if (!strncmp(tok, #A, strlen(#A))) \
68
int n = sscanf(tok, #A"=%d", &driver_ints[driver_nints]);\
71
DBAddOption(opts, A, &driver_ints[driver_nints]);\
77
#define CHECK_SYMBOLN_STR(A) \
78
if (!strncmp(tok, #A, strlen(#A))) \
80
driver_strs[driver_nstrs] = strdup(&tok[strlen(#A)]+1);\
81
DBAddOption(opts, A, driver_strs[driver_nstrs]); \
86
#define CHECK_SYMBOLN_SYM(A) \
87
if (!strncmp(tok, #A, strlen(#A))) \
89
driver_ints[driver_nints] = StringToDriver(&tok[strlen(#A)]+1);\
90
DBAddOption(opts, A, &driver_ints[driver_nints]); \
96
static DBoptlist *driver_opts[] = {0,0,0,0,0,0,0,0,0,0};
97
static int driver_opts_ids[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
98
static int driver_ints[100];
99
static int driver_nints = 0;
100
static char *driver_strs[] = {0,0,0,0,0,0,0,0,0,0};
101
static int driver_nstrs = 0;
102
static const int driver_nopts = sizeof(driver_opts)/sizeof(driver_opts[0]);
104
static void CleanupDriverStuff()
107
for (i = 0; i < driver_nopts; i++)
109
if (driver_opts_ids[i] != -1) DBUnregisterFileOptionsSet(driver_opts_ids[i]);
110
if (driver_opts[i]) DBFreeOptlist(driver_opts[i]);
112
for (i = 0; i < sizeof(driver_strs)/sizeof(driver_strs[0]); i++)
113
if (driver_strs[i]) free(driver_strs[i]);
116
static void MakeDriverOpts(DBoptlist **_opts, int *opts_id)
118
DBoptlist *opts = DBMakeOptlist(30);
121
for (i = 0; i < driver_nopts; i++)
123
if (driver_opts[i] == 0)
125
driver_opts[i] = opts;
131
*opts_id = DBRegisterFileOptionsSet(opts);
132
driver_opts_ids[i] = *opts_id;
135
static int StringToDriver(const char *str)
140
CHECK_SYMBOL(DB_PDB);
141
CHECK_SYMBOL(DB_PDBP);
142
CHECK_SYMBOL(DB_HDF5);
143
CHECK_SYMBOL(DB_HDF5_SEC2);
144
CHECK_SYMBOL(DB_HDF5_STDIO);
145
CHECK_SYMBOL(DB_HDF5_CORE);
146
CHECK_SYMBOL(DB_HDF5_SPLIT);
147
CHECK_SYMBOL(DB_HDF5_MPIO);
148
CHECK_SYMBOL(DB_HDF5_MPIP);
149
CHECK_SYMBOL(DB_HDF5_LOG);
150
CHECK_SYMBOL(DB_HDF5_DIRECT);
151
CHECK_SYMBOL(DB_HDF5_FAMILY);
152
CHECK_SYMBOL(DB_HDF5_SILO);
154
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_DEFAULT);
155
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_SEC2);
156
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_STDIO);
157
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_CORE);
158
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_LOG);
159
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_SPLIT);
160
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_DIRECT);
161
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_FAMILY);
162
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_MPIP);
163
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_MPIO);
164
CHECK_SYMBOL(DB_FILE_OPTS_H5_DEFAULT_SILO);
166
CHECK_SYMBOL(DB_H5VFD_DEFAULT);
167
CHECK_SYMBOL(DB_H5VFD_SEC2);
168
CHECK_SYMBOL(DB_H5VFD_STDIO);
169
CHECK_SYMBOL(DB_H5VFD_CORE);
170
CHECK_SYMBOL(DB_H5VFD_LOG);
171
CHECK_SYMBOL(DB_H5VFD_SPLIT);
172
CHECK_SYMBOL(DB_H5VFD_DIRECT);
173
CHECK_SYMBOL(DB_H5VFD_FAMILY);
174
CHECK_SYMBOL(DB_H5VFD_MPIO);
175
CHECK_SYMBOL(DB_H5VFD_MPIP);
176
CHECK_SYMBOL(DB_H5VFD_SILO);
178
if (!strncmp(str, "DB_HDF5_OPTS(", 13))
182
MakeDriverOpts(&opts, &opts_id);
184
tmpstr = strdup(&str[13]);
186
tok = strtok(tmpstr, ",)");
192
CHECK_SYMBOLN_SYM(DBOPT_H5_VFD)
193
CHECK_SYMBOLN_SYM(DBOPT_H5_RAW_FILE_OPTS)
194
CHECK_SYMBOLN_STR(DBOPT_H5_RAW_EXTENSION)
195
CHECK_SYMBOLN_SYM(DBOPT_H5_META_FILE_OPTS)
196
CHECK_SYMBOLN_STR(DBOPT_H5_META_EXTENSION)
197
CHECK_SYMBOLN_INT(DBOPT_H5_CORE_ALLOC_INC)
198
CHECK_SYMBOLN_INT(DBOPT_H5_CORE_NO_BACK_STORE)
199
CHECK_SYMBOLN_INT(DBOPT_H5_META_BLOCK_SIZE)
200
CHECK_SYMBOLN_INT(DBOPT_H5_SMALL_RAW_SIZE)
201
CHECK_SYMBOLN_INT(DBOPT_H5_ALIGN_MIN)
202
CHECK_SYMBOLN_INT(DBOPT_H5_ALIGN_VAL)
203
CHECK_SYMBOLN_INT(DBOPT_H5_DIRECT_MEM_ALIGN)
204
CHECK_SYMBOLN_INT(DBOPT_H5_DIRECT_BLOCK_SIZE)
205
CHECK_SYMBOLN_INT(DBOPT_H5_DIRECT_BUF_SIZE)
206
CHECK_SYMBOLN_STR(DBOPT_H5_LOG_NAME)
207
CHECK_SYMBOLN_INT(DBOPT_H5_LOG_BUF_SIZE)
208
CHECK_SYMBOLN_INT(DBOPT_H5_SIEVE_BUF_SIZE)
209
CHECK_SYMBOLN_INT(DBOPT_H5_CACHE_NELMTS)
210
CHECK_SYMBOLN_INT(DBOPT_H5_CACHE_NBYTES)
211
CHECK_SYMBOLN_INT(DBOPT_H5_FAM_SIZE)
212
CHECK_SYMBOLN_SYM(DBOPT_H5_FAM_FILE_OPTS)
213
CHECK_SYMBOLN_INT(DBOPT_H5_SILO_BLOCK_SIZE)
214
CHECK_SYMBOLN_INT(DBOPT_H5_SILO_BLOCK_COUNT)
215
CHECK_SYMBOLN_INT(DBOPT_H5_SILO_LOG_STATS)
216
CHECK_SYMBOLN_INT(DBOPT_H5_SILO_USE_DIRECT)
217
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_DEFAULT)
218
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_SEC2)
219
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_STDIO)
220
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_CORE)
221
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_LOG)
222
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_SPLIT)
223
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_DIRECT)
224
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_FAMILY)
225
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_MPIP)
226
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_MPIO)
227
CHECK_SYMBOLN_STR(DB_FILE_OPTS_H5_DEFAULT_SILO)
231
fprintf(stderr, "Unable to determine driver from string \"%s\"\n", tok);
235
tok = strtok(0, ",)");
238
fprintf(stderr, "Unable to determine driver from string \"%s\"\n", tok);
245
return DB_HDF5_OPTS(opts_id);
248
fprintf(stderr, "Unable to determine driver from string \"%s\"\n", str);