OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
clo.h File Reference
#include <stdio.h>
#include <inttypes.h>
Include dependency graph for clo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  clo_option_t
 
struct  clo_optionList_t
 
struct  clo_programMetadata_t
 
struct  clo_programMetadataList_t
 

Macros

#define CLO_CHUNK_SIZE   32
 
#define CLO_ARRAY_DELIMITER   " \t,:[]()\""
 

Typedefs

typedef void(* clo_optionCallback_t) (struct clo_option_t *option)
 

Enumerations

enum  clo_dataType_t {
  CLO_TYPE_BOOL, CLO_TYPE_INT, CLO_TYPE_INT64, CLO_TYPE_FLOAT,
  CLO_TYPE_DOUBLE, CLO_TYPE_STRING, CLO_TYPE_IFILE, CLO_TYPE_OFILE,
  CLO_TYPE_HELP, CLO_TYPE_POSITION
}
 

Functions

void clo_setIgnoreKeyCase (int val)
 
int clo_getIgnoreKeyCase ()
 
void clo_setEnableDumpOptions (int val)
 
int clo_getEnableDumpOptions ()
 
void clo_setEnableExtraOptions (int val)
 
int clo_getEnableExtraOptions ()
 
void clo_setVersion (const char *str)
 
void clo_setVersion2 (const char *programName, const char *versionStr)
 
char * clo_getVersion ()
 
void clo_setHelpStr (const char *str)
 
char * clo_getHelpStr ()
 
void clo_setSelectOptionKeys (char *keys[])
 
char ** clo_getSelectOptionKeys ()
 
clo_optionList_tclo_createList ()
 
clo_option_tclo_createOption (const char *key, enum clo_dataType_t dataType, const char *defaultVal, const char *desc)
 
void clo_addOptionAlias (clo_option_t *option, const char *alias)
 
void clo_addAlias (clo_optionList_t *list, const char *key, const char *alias)
 
void clo_insertOption (clo_optionList_t *list, clo_option_t *option)
 
clo_option_tclo_addOption (clo_optionList_t *list, const char *key, enum clo_dataType_t dataType, const char *defaultVal, const char *desc)
 
clo_option_tclo_copyOption (clo_option_t *option)
 
clo_optionList_tclo_copyList (clo_optionList_t *list)
 
void clo_deleteOption (clo_option_t *option)
 
void clo_deleteList (clo_optionList_t *list)
 
clo_option_tclo_getOption (clo_optionList_t *list, int i)
 
clo_option_tclo_findOption (clo_optionList_t *list, const char *key)
 
int clo_getNumOptions (clo_optionList_t *list)
 
char * clo_getOptionRawString (clo_option_t *option)
 
char * clo_getOptionString (clo_option_t *option)
 
int clo_getOptionBool (clo_option_t *option)
 
int clo_getOptionInt (clo_option_t *option)
 
int64_t clo_getOptionInt64 (clo_option_t *option)
 
float clo_getOptionFloat (clo_option_t *option)
 
double clo_getOptionDouble (clo_option_t *option)
 
char ** clo_getOptionStrings (clo_option_t *option, int *count)
 
int * clo_getOptionBools (clo_option_t *option, int *count)
 
int * clo_getOptionInts (clo_option_t *option, int *count)
 
float * clo_getOptionFloats (clo_option_t *option, int *count)
 
double * clo_getOptionDoubles (clo_option_t *option, int *count)
 
char * clo_getRawString (clo_optionList_t *list, const char *key)
 
char * clo_getString (clo_optionList_t *list, const char *key)
 
int clo_getBool (clo_optionList_t *list, const char *key)
 
int clo_getInt (clo_optionList_t *list, const char *key)
 
float clo_getFloat (clo_optionList_t *list, const char *key)
 
double clo_getDouble (clo_optionList_t *list, const char *key)
 
char ** clo_getStrings (clo_optionList_t *list, const char *key, int *count)
 
int * clo_getBools (clo_optionList_t *list, const char *key, int *count)
 
int * clo_getInts (clo_optionList_t *list, const char *key, int *count)
 
float * clo_getFloats (clo_optionList_t *list, const char *key, int *count)
 
double * clo_getDoubles (clo_optionList_t *list, const char *key, int *count)
 
int clo_setOptionString (clo_option_t *option, const char *val, const char *source)
 
int clo_setString (clo_optionList_t *list, const char *key, const char *val, const char *source)
 
void clo_setEnablePositionOptions (int val)
 
int clo_getEnablePositionOptions ()
 
int clo_getPositionNumOptions (clo_optionList_t *list)
 
clo_option_tclo_getPositionOption (clo_optionList_t *list, int i)
 
char * clo_getPositionString (clo_optionList_t *list, int pos)
 
void clo_setEnableParOption (int val)
 
int clo_getEnableParOption ()
 
void clo_printOptionVal (clo_option_t *option)
 
void clo_printVals (clo_optionList_t *list)
 
void clo_printOption (clo_option_t *option)
 
void clo_printOptions (clo_optionList_t *list)
 
void clo_dumpOption (clo_option_t *option)
 
void clo_dumpOptions (clo_optionList_t *list)
 
void clo_printVersion ()
 
void clo_printHelpString ()
 
void clo_printUsage (clo_optionList_t *list)
 
void clo_readString (clo_optionList_t *list, const char *str, const char *source)
 
void clo_readArgs (clo_optionList_t *list, int argc, char *argv[])
 
void clo_readArgsPar (clo_optionList_t *list, int argc, char *argv[], int enableFileDescending)
 
void clo_readOptions (clo_optionList_t *list, clo_optionList_t *readList)
 
void clo_readFile (clo_optionList_t *list, const char *fileName)
 
int clo_isOptionSet (clo_option_t *option)
 
int clo_isSet (clo_optionList_t *list, const char *key)
 
int clo_writeParameterFile (clo_optionList_t *list, const char *filename)
 
void clo_addXmlProgramMetadata (const char *tag, const char *value)
 
void clo_clearXmlProgramMetadata ()
 
void clo_writeXmlStartTag (FILE *fout, int level, const char *tag)
 
void clo_writeXmlEndTag (FILE *fout, int level, const char *tag)
 
void clo_writeXmlTag (FILE *fout, int level, const char *tag, const char *value)
 
int clo_writeXmlFile (clo_optionList_t *list, const char *filename)
 
void clo_trimDashes (char *str)
 
char * clo_trimDashesDup (const char *str)
 

Detailed Description

Command Line Option (CLO) is a library for reading and documenting the command line options for a program. The library can also read parameter files.

First the program should set the version string using #clo_setVersionString() function. Then the option list is created using clo_createList(). The list is filled by defining options and assigning default values and descriptions using the clo_addOption() function.

Next the program should call clo_readArgs() which first reads the command line arguments into the options list and looks for pre-defined options like -help and -version.

The last occurrence of an option is the one used. Overwriting the previous option value.

Options on the command line are expressed as "key" or "key=val". Each option is separated by white space and multiple values are separated by commas, colons, or spaces.

progName key10 key=val key1=val1,val2,val3 key2="val1 val2 val3"

boolean
key=0,1,y,n,yes,no,on,off

int
key=1,2,548,9
key=[1,2,3,4]
key=(1,2,3,4)
key="[1,2,3,4]"
key=["1","2",3,4]
key=1:2

float
key=1,8.3,.6, 1.0 , 1

string
key=hello,dude
key="two words","other",what
key="val1,val2,val3"
key="val\,with comma, other"

There are a few key values that are inherently understood by the library. They are invoked when clo_readArgs() is called.

-version, –version will print out the version string
-h, -help, –help will print the usage
-dump_options will print out everything help does plus the current value of the option and where the value came from. -dump_options_paramfile will write a param file with all of the params and values -dump_options_xmlfile will write an xml file with all of the param information

Definition in file clo.h.

Macro Definition Documentation

◆ CLO_ARRAY_DELIMITER

#define CLO_ARRAY_DELIMITER   " \t,:[]()\""

characters that can separate array items

Definition at line 72 of file clo.h.

◆ CLO_CHUNK_SIZE

#define CLO_CHUNK_SIZE   32

how many pointers to allocate space for when adding to an array

Definition at line 69 of file clo.h.

Typedef Documentation

◆ clo_optionCallback_t

typedef void(* clo_optionCallback_t) (struct clo_option_t *option)

Option callback function definition. This function will get called right after this option is read.

Parameters
optionpointer to the option associated with the callback

Definition at line 98 of file clo.h.

Enumeration Type Documentation

◆ clo_dataType_t

Data types for the command line arguments.

Enumerator
CLO_TYPE_BOOL 
CLO_TYPE_INT 
CLO_TYPE_INT64 
CLO_TYPE_FLOAT 
CLO_TYPE_DOUBLE 
CLO_TYPE_STRING 
CLO_TYPE_IFILE 
CLO_TYPE_OFILE 
CLO_TYPE_HELP 
CLO_TYPE_POSITION 

Definition at line 77 of file clo.h.

Function Documentation

◆ clo_addAlias()

void clo_addAlias ( clo_optionList_t list,
const char *  key,
const char *  alias 
)

add and alias for key to the option

Parameters
listto add the alias to
keyin the list for the getting the option
aliasnew key alias for the option

Definition at line 646 of file clo.c.

◆ clo_addOption()

clo_option_t* clo_addOption ( clo_optionList_t list,
const char *  key,
enum clo_dataType_t  dataType,
const char *  defaultVal,
const char *  desc 
)

create a new option and add it to the list

Parameters
listlist to add the option to
keyname of the new option
dataTypedata type for this option
defaultValdefault value
desclong description of the option
Returns
the newly created option

Definition at line 684 of file clo.c.

◆ clo_addOptionAlias()

void clo_addOptionAlias ( clo_option_t option,
const char *  alias 
)

add and alias for key to the option

Parameters
optionoption to add the alias to
aliasnew key alias for the option

Definition at line 632 of file clo.c.

◆ clo_addXmlProgramMetadata()

void clo_addXmlProgramMetadata ( const char *  tag,
const char *  value 
)

add program metadata XML entries

Parameters
tagXML tag to add
valueXML value to add

Definition at line 2345 of file clo.c.

◆ clo_clearXmlProgramMetadata()

void clo_clearXmlProgramMetadata ( )

clear all of the program metadata XML entries

Definition at line 2361 of file clo.c.

◆ clo_copyList()

clo_optionList_t* clo_copyList ( clo_optionList_t list)

allocate a new list and make a deep copy of all of the options

Parameters
listlist to copy
Returns
newly allocated and copied list

Definition at line 799 of file clo.c.

◆ clo_copyOption()

clo_option_t* clo_copyOption ( clo_option_t option)

allocate a new option and make a deep copy of the given option

Parameters
optionoption to copy
Returns
newly allocated and initialized option

Definition at line 741 of file clo.c.

◆ clo_createList()

clo_optionList_t* clo_createList ( )

create an empty option list container

Returns
pointer to newly allocated and initialized structure

Definition at line 532 of file clo.c.

◆ clo_createOption()

clo_option_t* clo_createOption ( const char *  key,
enum clo_dataType_t  dataType,
const char *  defaultVal,
const char *  desc 
)

allocate and init an option structure

Parameters
keyname of the option
dataTypedata storage type for the option
defaultValinitial value
desclong description of this option
Returns
newly allocated and initialized option structure

Definition at line 585 of file clo.c.

◆ clo_deleteList()

void clo_deleteList ( clo_optionList_t list)

delete the list and all of its internal options

Parameters
listlist to delete

Definition at line 875 of file clo.c.

◆ clo_deleteOption()

void clo_deleteOption ( clo_option_t option)

delete the option and all of its internal storage

Parameters
optionoption to delete

Definition at line 823 of file clo.c.

◆ clo_dumpOption()

void clo_dumpOption ( clo_option_t option)

print the full description and value of an option

Parameters
optionoption to dump

Definition at line 1896 of file clo.c.

◆ clo_dumpOptions()

void clo_dumpOptions ( clo_optionList_t list)

print version string and dump all options in the list

Parameters
listoption list to print out

Definition at line 1999 of file clo.c.

◆ clo_findOption()

clo_option_t* clo_findOption ( clo_optionList_t list,
const char *  key 
)

search list for the option with the given key

Parameters
listlist to search
keykey to look for
Returns
option pointer or NULL if not found

Definition at line 967 of file clo.c.

◆ clo_getBool()

int clo_getBool ( clo_optionList_t list,
const char *  key 
)

Find the option "key" and return the first value. exit is called if "key" is not found. If the option has not been set the default value is returned.

Parameters
listlist of options to search
keyoption name to search for
Returns
internal pointer to the first boolean value

Definition at line 1375 of file clo.c.

◆ clo_getBools()

int* clo_getBools ( clo_optionList_t list,
const char *  key,
int *  count 
)

Find the option "key" and return the count and boolean array. exit is called if "key" is not found. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
listlist of options to search through
keyoption name to search for
count[out] number of items in the array
Returns
an array of booleans. This pointer is pointing to internal memory stored in the option structure.

Definition at line 1492 of file clo.c.

◆ clo_getDouble()

double clo_getDouble ( clo_optionList_t list,
const char *  key 
)

Find the option "key" and return the first value. exit is called if "key" is not found. If the option has not been set the default value is returned.

Parameters
listlist of options to search
keyoption name to search for
Returns
internal pointer to the first double value

Definition at line 1447 of file clo.c.

◆ clo_getDoubles()

double* clo_getDoubles ( clo_optionList_t list,
const char *  key,
int *  count 
)

Find the option "key" and return the count and float array. exit is called if "key" is not found. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
listlist of options to search through
keyoption name to search for
count[out] number of items in the array
Returns
an array of doubles. This pointer is pointing to internal memory stored in the option structure.

Definition at line 1561 of file clo.c.

◆ clo_getEnableDumpOptions()

int clo_getEnableDumpOptions ( )

is the library currently looking for the "-dump_options" key

Returns
1 = enable dump, 0 = disable

Definition at line 419 of file clo.c.

◆ clo_getEnableExtraOptions()

int clo_getEnableExtraOptions ( )

is the library set to automatically add options to the list when reading the command line or par file.

Returns
1 = enable adding, 0 = disable

Definition at line 439 of file clo.c.

◆ clo_getEnableParOption()

int clo_getEnableParOption ( )

is the library set to automatically add the par option

Returns
1 = enable, 0 = disable

Definition at line 1747 of file clo.c.

◆ clo_getEnablePositionOptions()

int clo_getEnablePositionOptions ( )

is the library set to automatically add options to the list when reading the command line or par file.

Returns
1 = enable adding, 0 = disable

Definition at line 1695 of file clo.c.

◆ clo_getFloat()

float clo_getFloat ( clo_optionList_t list,
const char *  key 
)

Find the option "key" and return the first value. exit is called if "key" is not found. If the option has not been set the default value is returned.

Parameters
listlist of options to search
keyoption name to search for
Returns
internal pointer to the first float value

Definition at line 1429 of file clo.c.

◆ clo_getFloats()

float* clo_getFloats ( clo_optionList_t list,
const char *  key,
int *  count 
)

Find the option "key" and return the count and float array. exit is called if "key" is not found. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
listlist of options to search through
keyoption name to search for
count[out] number of items in the array
Returns
an array of floats. This pointer is pointing to internal memory stored in the option structure.

Definition at line 1538 of file clo.c.

◆ clo_getHelpStr()

char* clo_getHelpStr ( )

get the help string for the program

Returns
the help string

Definition at line 501 of file clo.c.

◆ clo_getIgnoreKeyCase()

int clo_getIgnoreKeyCase ( )

get the state of option key case sensitivity

Returns
1 = case insensitive, 0 case sensitive

Definition at line 401 of file clo.c.

◆ clo_getInt()

int clo_getInt ( clo_optionList_t list,
const char *  key 
)

Find the option "key" and return the first value. exit is called if "key" is not found. If the option has not been set the default value is returned.

Parameters
listlist of options to search
keyoption name to search for
Returns
internal pointer to the first int value

Definition at line 1393 of file clo.c.

◆ clo_getInts()

int* clo_getInts ( clo_optionList_t list,
const char *  key,
int *  count 
)

Find the option "key" and return the count and int array. exit is called if "key" is not found. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
listlist of options to search through
keyoption name to search for
count[out] number of items in the array
Returns
an array of ints. This pointer is pointing to internal memory stored in the option structure.

Definition at line 1515 of file clo.c.

◆ clo_getNumOptions()

int clo_getNumOptions ( clo_optionList_t list)

get the number of options in the list

Parameters
listlist to get the count for
Returns
number of options

Definition at line 1017 of file clo.c.

◆ clo_getOption()

clo_option_t* clo_getOption ( clo_optionList_t list,
int  i 
)

get the option at index i

Parameters
listlist to search through
iindex into the list
Returns
option pointer at i, or NULL if not found

Definition at line 908 of file clo.c.

◆ clo_getOptionBool()

int clo_getOptionBool ( clo_option_t option)

return the first boolean value from option. If the option has not been set the default value is returned. Option must have only 1 value.

Parameters
optionoption to use
Returns
first value of the option

Definition at line 1087 of file clo.c.

◆ clo_getOptionBools()

int* clo_getOptionBools ( clo_option_t option,
int *  count 
)

Return the count and boolean array from the given option. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
optionoption to get the information from
count[out] pointer where number of booleans in array is written
Returns
array of booleans

Definition at line 1251 of file clo.c.

◆ clo_getOptionDouble()

double clo_getOptionDouble ( clo_option_t option)

return the first double value from option. If the option has not been set the default value is returned. Option must have only 1 value.

Parameters
optionoption to use
Returns
first value of the option

Definition at line 1195 of file clo.c.

◆ clo_getOptionDoubles()

double* clo_getOptionDoubles ( clo_option_t option,
int *  count 
)

Return the count and double array from the given option. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
optionoption to get the information from
count[out] pointer where number of doubles in array is written
Returns
array of doubles

Definition at line 1317 of file clo.c.

◆ clo_getOptionFloat()

float clo_getOptionFloat ( clo_option_t option)

return the first float value from option. If the option has not been set the default value is returned. Option must have only 1 value.

Parameters
optionoption to use
Returns
first value of the option

Definition at line 1167 of file clo.c.

◆ clo_getOptionFloats()

float* clo_getOptionFloats ( clo_option_t option,
int *  count 
)

Return the count and float array from the given option. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
optionoption to get the information from
countpointer where number of floats in array is written
Returns
array of floats

Definition at line 1295 of file clo.c.

◆ clo_getOptionInt()

int clo_getOptionInt ( clo_option_t option)

return the first integer value from option. If the option has not been set the default value is returned. Option must have only 1 value.

Parameters
optionoption to use
Returns
first value of the option

Definition at line 1113 of file clo.c.

◆ clo_getOptionInt64()

int64_t clo_getOptionInt64 ( clo_option_t option)

return the first integer value from option. If the option has not been set the default value is returned. Option must have only 1 value.

Parameters
optionoption to use
Returns
first value of the option

Definition at line 1140 of file clo.c.

◆ clo_getOptionInts()

int* clo_getOptionInts ( clo_option_t option,
int *  count 
)

Return the count and int array from the given option. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
optionoption to get the information from
count[out] pointer where number of ints in array is written
Returns
array of ints

Definition at line 1273 of file clo.c.

◆ clo_getOptionRawString()

char* clo_getOptionRawString ( clo_option_t option)

return the option's raw string. If the option has not been set the default value is returned. Exit is called if the option has not been set and the default value is NULL.

Parameters
optionoption to use
Returns
raw string value for the option

Definition at line 1030 of file clo.c.

◆ clo_getOptionString()

char* clo_getOptionString ( clo_option_t option)

return the first string value from option. If the option has not been set the default value is returned. Option must have only 1 value.

Parameters
optionoption to use
Returns
first value of the option

Definition at line 1050 of file clo.c.

◆ clo_getOptionStrings()

char** clo_getOptionStrings ( clo_option_t option,
int *  count 
)

Return the count and string array from the given option. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
optionoption to get the information from
count[out] pointer where number of strings in array is written
Returns
array of strings

Definition at line 1226 of file clo.c.

◆ clo_getPositionNumOptions()

int clo_getPositionNumOptions ( clo_optionList_t list)

get the number of position options in the list

Parameters
listlist to get the count for
Returns
number of options

Definition at line 1704 of file clo.c.

◆ clo_getPositionOption()

clo_option_t* clo_getPositionOption ( clo_optionList_t list,
int  i 
)

get the option at index i

Parameters
listlist to search through
iindex into the list
Returns
option pointer at i, or NULL if not found

Definition at line 1716 of file clo.c.

◆ clo_getPositionString()

char* clo_getPositionString ( clo_optionList_t list,
int  pos 
)

Definition at line 1723 of file clo.c.

◆ clo_getRawString()

char* clo_getRawString ( clo_optionList_t list,
const char *  key 
)

Find the option "key" and return the raw string value. Exit is called if "key" is not found. If the option has not been set the default value is returned. Exit is called if the option has not been set and the default value is NULL.

Parameters
listlist to search through
keyoption key to find
Returns
internal pointer to the raw string value

Definition at line 1339 of file clo.c.

◆ clo_getSelectOptionKeys()

char** clo_getSelectOptionKeys ( )

get the array of select option keys

Returns
NULL terminated array of key names

Definition at line 523 of file clo.c.

◆ clo_getString()

char* clo_getString ( clo_optionList_t list,
const char *  key 
)

Find the option "key" and return the first value. exit is called if "key" is not found. If the option has not been set the default value is returned.

Parameters
listlist of options to search
keyoption name to search for
Returns
internal pointer to the first string value

Definition at line 1357 of file clo.c.

◆ clo_getStrings()

char** clo_getStrings ( clo_optionList_t list,
const char *  key,
int *  count 
)

Find the option "key" and return the count and string array. exit is called if "key" is not found. If the option has not been set the default value is returned. The pointer returned references internally allocated memory stored in the option structure, so it should be valid until the value of option is changed.

Parameters
listlist of options to search through
keyoption name to search for
count[out] number of items in the array
Returns
an array of strings. This pointer is pointing to internal memory stored in the option structure.

Definition at line 1469 of file clo.c.

◆ clo_getVersion()

char* clo_getVersion ( )

get the version string for the program

Returns
the version string

Definition at line 478 of file clo.c.

◆ clo_insertOption()

void clo_insertOption ( clo_optionList_t list,
clo_option_t option 
)

add the given option to the option list

Parameters
listoption list to add the option into
optionpointer to option structure to add

Definition at line 666 of file clo.c.

◆ clo_isOptionSet()

int clo_isOptionSet ( clo_option_t option)

Was the option explicitly set.

Parameters
optionoption to check
Returns
1 if option was set else 0. 0 is returned if option not found.

Definition at line 2257 of file clo.c.

◆ clo_isSet()

int clo_isSet ( clo_optionList_t list,
const char *  key 
)

Was the option explicitly set.

Parameters
listlist of options to search through
keyname of option to search for
Returns
1 if option was set else 0. 0 is returned if option not found.

Definition at line 2270 of file clo.c.

◆ clo_printHelpString()

void clo_printHelpString ( )

print the help string

Definition at line 1978 of file clo.c.

◆ clo_printOption()

void clo_printOption ( clo_option_t option)

print the full description of the option

Parameters
optionoption to print

Definition at line 1865 of file clo.c.

◆ clo_printOptions()

void clo_printOptions ( clo_optionList_t list)

print the full description and value of all of the options

Parameters
listoption list to print

Definition at line 1931 of file clo.c.

◆ clo_printOptionVal()

void clo_printOptionVal ( clo_option_t option)

print the current value of the option

Parameters
optionoption pointer to print

Definition at line 1756 of file clo.c.

◆ clo_printUsage()

void clo_printUsage ( clo_optionList_t list)

print the program usage information

Parameters
listoption list to print out

Definition at line 1988 of file clo.c.

◆ clo_printVals()

void clo_printVals ( clo_optionList_t list)

print the options that have been set in a terse manner

Parameters
listoption list to print

Definition at line 1845 of file clo.c.

◆ clo_printVersion()

void clo_printVersion ( )

print the version information

Definition at line 1968 of file clo.c.

◆ clo_readArgs()

void clo_readArgs ( clo_optionList_t list,
int  argc,
char *  argv[] 
)

Read command line arguments handling function. First call to readArgsPar with file descending enabled, then disabled to allow Command Line options override

Parameters
listoption list to search
argcnumber of elements in argv
argvarray of command line argument strings

Definition at line 2103 of file clo.c.

◆ clo_readArgsPar()

void clo_readArgsPar ( clo_optionList_t list,
int  argc,
char *  argv[],
int  enableFileDescending 
)

Read command line arguments. Lookup the key in list and set the value.

Parameters
listoption list to search
argcnumber of elements in argv
argvarray of command line argument strings
enableFileDecendingenable file descending

Definition at line 2119 of file clo.c.

◆ clo_readFile()

void clo_readFile ( clo_optionList_t list,
const char *  fileName 
)

read a par file

Parameters
listoption list to write to
fileNameparameter file to read

Definition at line 2210 of file clo.c.

◆ clo_readOptions()

void clo_readOptions ( clo_optionList_t list,
clo_optionList_t readList 
)

copy (overwrite) options from readList that have been set

Parameters
listoption list to copy to
readListoption list to copy from

Definition at line 2173 of file clo.c.

◆ clo_readString()

void clo_readString ( clo_optionList_t list,
const char *  str,
const char *  source 
)

Read a string assuming it is one command line option. Lookup the key in list and set the value and the source.

Parameters
listoption list to search
strstring containing "key=value"
sourcesource of the string. Either "command line" or the file name

Definition at line 2019 of file clo.c.

◆ clo_setEnableDumpOptions()

void clo_setEnableDumpOptions ( int  val)

set whether or not the library looks for the "-dump_options" key

Parameters
val1 = enable dump, 0 = disable

Definition at line 410 of file clo.c.

◆ clo_setEnableExtraOptions()

void clo_setEnableExtraOptions ( int  val)

set whether or not the library will automatically add options to the list when reading the command line or par file.

Parameters
val1 = enable adding, 0 = disable

Definition at line 429 of file clo.c.

◆ clo_setEnableParOption()

void clo_setEnableParOption ( int  val)

set whether or not the library will add the par file option this must be set before calling clo_createList()

Parameters
val1 = enable processing, 0 = disable

Definition at line 1738 of file clo.c.

◆ clo_setEnablePositionOptions()

void clo_setEnablePositionOptions ( int  val)

set whether or not the library will accept positional options

Parameters
val1 = enable processing, 0 = disable

Definition at line 1685 of file clo.c.

◆ clo_setHelpStr()

void clo_setHelpStr ( const char *  str)

set the help string for the program

Parameters
strstring to use for help

Definition at line 487 of file clo.c.

◆ clo_setIgnoreKeyCase()

void clo_setIgnoreKeyCase ( int  val)

Tell the library to ignore the case of the option key or not

Parameters
val1 = case insensitive, 0 case sensitive

Definition at line 389 of file clo.c.

◆ clo_setOptionString()

int clo_setOptionString ( clo_option_t option,
const char *  val,
const char *  source 
)

Set the string for this option and run any callback

Parameters
optionstructure to modify
valstring to enter into the structure to have parsed
sourcewhere did this value come from
Returns
0 if OK, -1 if error

Definition at line 1579 of file clo.c.

◆ clo_setSelectOptionKeys()

void clo_setSelectOptionKeys ( char *  keys[])

◆ clo_setString()

int clo_setString ( clo_optionList_t list,
const char *  key,
const char *  val,
const char *  source 
)

Set the string for this option and run any callback

Parameters
listoption list to search
keyoption key to search for
valstring to enter into the structure to have parsed
sourcewhere did this value come from
Returns
0 if OK, -1 if error

Definition at line 1667 of file clo.c.

◆ clo_setVersion()

void clo_setVersion ( const char *  str)

set the version string for the program

Parameters
strstring to use for the version string

Definition at line 448 of file clo.c.

◆ clo_setVersion2()

void clo_setVersion2 ( const char *  programName,
const char *  versionStr 
)

Set the version string using the program name and version string. The string is set to: "progName versionStr (__DATE__ __TIME__)"

Parameters
programNamename of the program
versionStrstring to use for the version number

Definition at line 464 of file clo.c.

◆ clo_trimDashes()

void clo_trimDashes ( char *  str)

Remove the dashes from beginning of the string.

Parameters
strstring to remove the dashes from

Definition at line 918 of file clo.c.

◆ clo_trimDashesDup()

char* clo_trimDashesDup ( const char *  str)

Allocate a string without beginning dashes.

Parameters
strstring to use as source (left unmodified)
Returns
pointer to newly allocated string without whitespace on ends or dashes

Definition at line 954 of file clo.c.

◆ clo_writeParameterFile()

int clo_writeParameterFile ( clo_optionList_t list,
const char *  filename 
)

Write the list to a parameter file

Parameters
listoption list to write
filenamefile name to write to
Returns
0 if OK else -1

Definition at line 2287 of file clo.c.

◆ clo_writeXmlEndTag()

void clo_writeXmlEndTag ( FILE *  fout,
int  level,
const char *  tag 
)

write an XML end tag

Parameters
foutfile handle to write to
levelindent level
tagXML tag string

Definition at line 2395 of file clo.c.

◆ clo_writeXmlFile()

int clo_writeXmlFile ( clo_optionList_t list,
const char *  filename 
)

Write an XML file representation for this option list

Parameters
listoption list to write out
filenamefile to write to
Returns
0 if OK else -1 is returned

Definition at line 2568 of file clo.c.

◆ clo_writeXmlStartTag()

void clo_writeXmlStartTag ( FILE *  fout,
int  level,
const char *  tag 
)

write an XML start tag

Parameters
foutfile handle to write to
levelindent level
tagXML tag string

Definition at line 2381 of file clo.c.

◆ clo_writeXmlTag()

void clo_writeXmlTag ( FILE *  fout,
int  level,
const char *  tag,
const char *  value 
)

write an XML tag and escape the value with CDATA is necessary

Parameters
foutfile handle to write to
levelindent level
tagXML tag string
valueXML value string

Definition at line 2410 of file clo.c.