OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
clo.h
Go to the documentation of this file.
1 #ifndef CLO_H
2 #define CLO_H
3 
4 #include <stdio.h>
5 #include <inttypes.h>
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 
69 #define CLO_CHUNK_SIZE 32
70 
72 #define CLO_ARRAY_DELIMITER " \t,:[]()\""
73 
88 };
89 
90 // forward reference for option structure
91 struct clo_option_t;
92 
98 typedef void (*clo_optionCallback_t)(struct clo_option_t *option);
99 
103 typedef struct clo_option_t {
104  char *key;
106  char *defaultVal;
107  char *desc;
108  char *valStr;
109  char *source;
111  void *cb_data;
112  int cb_flag;
113  char **strArray;
114  void *valArray;
115  int count;
116  char **aliases;
119  int position;
120 } clo_option_t;
121 
123 typedef struct clo_optionList_t {
132 
134 typedef struct clo_programMetadata_t {
135  char* tag;
136  char* value;
138 
145 
146 // global library settings
147 void clo_setIgnoreKeyCase(int val);
149 
150 void clo_setEnableDumpOptions(int val);
152 
155 
156 void clo_setVersion(const char *str);
157 void clo_setVersion2(const char* programName, const char* versionStr);
158 char* clo_getVersion();
159 
160 void clo_setHelpStr(const char *str);
161 char* clo_getHelpStr();
162 
163 void clo_setSelectOptionKeys(char *keys[]);
164 char **clo_getSelectOptionKeys();
165 
167 
168 clo_option_t* clo_createOption(const char *key, enum clo_dataType_t dataType,
169  const char *defaultVal, const char *desc);
170 void clo_addOptionAlias(clo_option_t *option, const char* alias);
171 void clo_addAlias(clo_optionList_t *list, const char *key, const char* alias);
174  enum clo_dataType_t dataType, const char *defaultVal,
175  const char* desc);
178 void clo_deleteOption(clo_option_t *option);
183 char* clo_getOptionRawString(clo_option_t *option);
184 
185 char* clo_getOptionString(clo_option_t *option);
186 int clo_getOptionBool(clo_option_t *option);
187 int clo_getOptionInt(clo_option_t *option);
188 int64_t clo_getOptionInt64(clo_option_t *option);
189 float clo_getOptionFloat(clo_option_t *option);
190 double clo_getOptionDouble(clo_option_t *option);
191 
192 char** clo_getOptionStrings(clo_option_t *option, int *count);
193 int* clo_getOptionBools(clo_option_t *option, int *count);
194 int* clo_getOptionInts(clo_option_t *option, int *count);
195 float* clo_getOptionFloats(clo_option_t *option, int *count);
196 double* clo_getOptionDoubles(clo_option_t *option, int *count);
197 
198 char* clo_getRawString(clo_optionList_t *list, const char *key);
199 char* clo_getString(clo_optionList_t *list, const char *key);
200 int clo_getBool(clo_optionList_t *list, const char *key);
201 int clo_getInt(clo_optionList_t *list, const char *key);
202 float clo_getFloat(clo_optionList_t *list, const char *key);
203 double clo_getDouble(clo_optionList_t *list, const char *key);
204 
205 char** clo_getStrings(clo_optionList_t *list, const char *key, int *count);
206 int* clo_getBools(clo_optionList_t *list, const char *key, int *count);
207 int* clo_getInts(clo_optionList_t *list, const char *key, int *count);
208 float* clo_getFloats(clo_optionList_t *list, const char *key, int *count);
209 double* clo_getDoubles(clo_optionList_t *list, const char *key, int *count);
210 
211 int clo_setOptionString(clo_option_t *option, const char *val, const char *source);
212 int clo_setString(clo_optionList_t *list, const char* key, const char *val, const char *source);
213 
214 // position option functions
220 
221 void clo_setEnableParOption(int val);
223 
224 void clo_printOptionVal(clo_option_t *option);
226 void clo_printOption(clo_option_t *option);
228 void clo_dumpOption(clo_option_t *option);
230 void clo_printVersion();
231 void clo_printHelpString();
233 
234 void clo_readString(clo_optionList_t *list, const char *str, const char *source);
235 void clo_readArgs(clo_optionList_t *list, int argc, char *argv[]);
236 void clo_readArgsPar(clo_optionList_t *list, int argc, char *argv[], int enableFileDescending);
238 void clo_readFile(clo_optionList_t *list, const char *fileName);
239 
240 int clo_isOptionSet(clo_option_t *option);
241 int clo_isSet(clo_optionList_t *list, const char *key);
242 
244 
245 void clo_addXmlProgramMetadata(const char* tag, const char* value);
247 
248 void clo_writeXmlStartTag(FILE *fout, int level, const char *tag);
249 void clo_writeXmlEndTag(FILE *fout, int level, const char *tag);
250 void clo_writeXmlTag(FILE *fout, int level, const char *tag, const char *value);
252 
253 void clo_trimDashes(char* str);
254 char* clo_trimDashesDup(const char* str);
255 
256 //void clo_resetFileRecursion();
257 
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif
float clo_getFloat(clo_optionList_t *list, const char *key)
Definition: clo.c:1429
void clo_printOptions(clo_optionList_t *list)
Definition: clo.c:1931
float * clo_getOptionFloats(clo_option_t *option, int *count)
Definition: clo.c:1295
void clo_setIgnoreKeyCase(int val)
Definition: clo.c:389
char ** clo_getStrings(clo_optionList_t *list, const char *key, int *count)
Definition: clo.c:1469
int32 value
Definition: Granule.c:1235
clo_option_t * clo_copyOption(clo_option_t *option)
Definition: clo.c:741
clo_optionList_t * clo_createList()
Definition: clo.c:532
char * defaultVal
Definition: clo.h:106
float * clo_getFloats(clo_optionList_t *list, const char *key, int *count)
Definition: clo.c:1538
void clo_setEnableParOption(int val)
Definition: clo.c:1738
int position
Definition: clo.h:119
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
Definition: CMakeLists.txt:7
void(* clo_optionCallback_t)(struct clo_option_t *option)
Definition: clo.h:98
int storageSize
Definition: clo.h:124
double clo_getDouble(clo_optionList_t *list, const char *key)
Definition: clo.c:1447
@ CLO_TYPE_POSITION
Definition: clo.h:87
double clo_getOptionDouble(clo_option_t *option)
Definition: clo.c:1195
void clo_deleteList(clo_optionList_t *list)
Definition: clo.c:875
int positionStorageSize
Definition: clo.h:128
clo_optionList_t * clo_copyList(clo_optionList_t *list)
Definition: clo.c:799
void clo_writeXmlTag(FILE *fout, int level, const char *tag, const char *value)
Definition: clo.c:2410
@ CLO_TYPE_DOUBLE
Definition: clo.h:82
char * key
Definition: clo.h:104
int * clo_getOptionBools(clo_option_t *option, int *count)
Definition: clo.c:1251
void clo_printUsage(clo_optionList_t *list)
Definition: clo.c:1988
void clo_printOptionVal(clo_option_t *option)
Definition: clo.c:1756
int clo_writeXmlFile(clo_optionList_t *list, const char *filename)
Definition: clo.c:2568
int * clo_getInts(clo_optionList_t *list, const char *key, int *count)
Definition: clo.c:1515
int numAliases
Definition: clo.h:117
void clo_clearXmlProgramMetadata()
Definition: clo.c:2361
float32 * pos
Definition: l1_czcs_hdf.c:35
char * clo_trimDashesDup(const char *str)
Definition: clo.c:954
int64_t clo_getOptionInt64(clo_option_t *option)
Definition: clo.c:1140
double * clo_getOptionDoubles(clo_option_t *option, int *count)
Definition: clo.c:1317
void clo_setVersion(const char *str)
Definition: clo.c:448
char * clo_getOptionRawString(clo_option_t *option)
Definition: clo.c:1030
@ CLO_TYPE_FLOAT
Definition: clo.h:81
clo_option_t * clo_createOption(const char *key, enum clo_dataType_t dataType, const char *defaultVal, const char *desc)
Definition: clo.c:585
int clo_isOptionSet(clo_option_t *option)
Definition: clo.c:2257
char ** aliases
Definition: clo.h:116
void clo_setSelectOptionKeys(char *keys[])
int aliasStorageSize
Definition: clo.h:118
clo_option_t * clo_findOption(clo_optionList_t *list, const char *key)
Definition: clo.c:967
void clo_readFile(clo_optionList_t *list, const char *fileName)
Definition: clo.c:2210
int * clo_getBools(clo_optionList_t *list, const char *key, int *count)
Definition: clo.c:1492
void clo_addAlias(clo_optionList_t *list, const char *key, const char *alias)
Definition: clo.c:646
void clo_trimDashes(char *str)
Definition: clo.c:918
char * clo_getRawString(clo_optionList_t *list, const char *key)
Definition: clo.c:1339
void clo_printVersion()
Definition: clo.c:1968
@ CLO_TYPE_BOOL
Definition: clo.h:78
char ** strArray
Definition: clo.h:113
void clo_readArgsPar(clo_optionList_t *list, int argc, char *argv[], int enableFileDescending)
Definition: clo.c:2119
void clo_dumpOptions(clo_optionList_t *list)
Definition: clo.c:1999
void clo_printHelpString()
Definition: clo.c:1978
char * clo_getString(clo_optionList_t *list, const char *key)
Definition: clo.c:1357
char * clo_getHelpStr()
Definition: clo.c:501
@ CLO_TYPE_INT64
Definition: clo.h:80
clo_programMetadata_t ** entries
Definition: clo.h:143
void clo_deleteOption(clo_option_t *option)
Definition: clo.c:823
int clo_getEnableParOption()
Definition: clo.c:1747
int clo_getEnableDumpOptions()
Definition: clo.c:419
clo_optionCallback_t cb
Definition: clo.h:110
int clo_getBool(clo_optionList_t *list, const char *key)
Definition: clo.c:1375
int clo_getInt(clo_optionList_t *list, const char *key)
Definition: clo.c:1393
void clo_readOptions(clo_optionList_t *list, clo_optionList_t *readList)
Definition: clo.c:2173
clo_option_t ** options
Definition: clo.h:126
char * valStr
Definition: clo.h:108
@ CLO_TYPE_INT
Definition: clo.h:79
char ** clo_getOptionStrings(clo_option_t *option, int *count)
Definition: clo.c:1226
void clo_dumpOption(clo_option_t *option)
Definition: clo.c:1896
void clo_setEnableDumpOptions(int val)
Definition: clo.c:410
@ CLO_TYPE_IFILE
Definition: clo.h:84
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
void clo_printVals(clo_optionList_t *list)
Definition: clo.c:1845
@ CLO_TYPE_OFILE
Definition: clo.h:85
char ** clo_getSelectOptionKeys()
Definition: clo.c:523
int clo_getEnableExtraOptions()
Definition: clo.c:439
char * clo_getOptionString(clo_option_t *option)
Definition: clo.c:1050
double * clo_getDoubles(clo_optionList_t *list, const char *key, int *count)
Definition: clo.c:1561
int * clo_getOptionInts(clo_option_t *option, int *count)
Definition: clo.c:1273
void clo_setVersion2(const char *programName, const char *versionStr)
Definition: clo.c:464
void clo_insertOption(clo_optionList_t *list, clo_option_t *option)
Definition: clo.c:666
int clo_getPositionNumOptions(clo_optionList_t *list)
Definition: clo.c:1704
int count
Definition: clo.h:115
@ CLO_TYPE_HELP
Definition: clo.h:86
level
Definition: mapgen.py:186
char * desc
Definition: clo.h:107
void clo_writeXmlEndTag(FILE *fout, int level, const char *tag)
Definition: clo.c:2395
void * valArray
Definition: clo.h:114
const char * str
Definition: l1c_msi.cpp:35
int clo_getNumOptions(clo_optionList_t *list)
Definition: clo.c:1017
int numOptions
Definition: clo.h:125
void clo_addXmlProgramMetadata(const char *tag, const char *value)
Definition: clo.c:2345
int cb_flag
Definition: clo.h:112
void clo_readString(clo_optionList_t *list, const char *str, const char *source)
Definition: clo.c:2019
void clo_setEnableExtraOptions(int val)
Definition: clo.c:429
int clo_setString(clo_optionList_t *list, const char *key, const char *val, const char *source)
Definition: clo.c:1667
int clo_writeParameterFile(clo_optionList_t *list, const char *filename)
Definition: clo.c:2287
int clo_getOptionBool(clo_option_t *option)
Definition: clo.c:1087
void clo_printOption(clo_option_t *option)
Definition: clo.c:1865
int clo_getEnablePositionOptions()
Definition: clo.c:1695
int positionNumOptions
Definition: clo.h:129
clo_option_t * clo_getOption(clo_optionList_t *list, int i)
Definition: clo.c:908
char * source
Definition: clo.h:109
void * cb_data
Definition: clo.h:111
char * clo_getPositionString(clo_optionList_t *list, int pos)
Definition: clo.c:1723
clo_option_t * clo_getPositionOption(clo_optionList_t *list, int i)
Definition: clo.c:1716
void clo_readArgs(clo_optionList_t *list, int argc, char *argv[])
Definition: clo.c:2103
clo_option_t * clo_addOption(clo_optionList_t *list, const char *key, enum clo_dataType_t dataType, const char *defaultVal, const char *desc)
Definition: clo.c:684
enum clo_dataType_t dataType
Definition: clo.h:105
clo_option_t ** positionOptions
Definition: clo.h:130
float clo_getOptionFloat(clo_option_t *option)
Definition: clo.c:1167
clo_dataType_t
Definition: clo.h:77
char * clo_getVersion()
Definition: clo.c:478
int i
Definition: decode_rs.h:71
msiBandIdx val
Definition: l1c_msi.cpp:34
int clo_isSet(clo_optionList_t *list, const char *key)
Definition: clo.c:2270
@ CLO_TYPE_STRING
Definition: clo.h:83
int clo_getIgnoreKeyCase()
Definition: clo.c:401
void clo_setEnablePositionOptions(int val)
Definition: clo.c:1685
int clo_getOptionInt(clo_option_t *option)
Definition: clo.c:1113
void clo_addOptionAlias(clo_option_t *option, const char *alias)
Definition: clo.c:632
int clo_setOptionString(clo_option_t *option, const char *val, const char *source)
Definition: clo.c:1579
void clo_writeXmlStartTag(FILE *fout, int level, const char *tag)
Definition: clo.c:2381
void clo_setHelpStr(const char *str)
Definition: clo.c:487
int count
Definition: decode_rs.h:79