ocssw
V2022
|
argpar.c
Go to the documentation of this file.
63 fprintf(argpar_ostream ? argpar_ostream : stderr, "help=params is not enabled for this program.\n");
201 static void add_parser(parser_chain *parser_chain, argpar *argpar, parser *parent, unsigned parent_index) {
242 static int parser_chain_init(parser_chain *parser_chain, argpar *argpar, unsigned argc, char **argv, unsigned flags, void *input) {
298 for (p = parser_chain->parsers; p < parser_chain->last_parser && (!err || err == ARGPAR_ERR_UNKNOWN); p++) {
328 for (parser = p_chain->parsers; parser < p_chain->last_parser && (!err || err == ARGPAR_ERR_UNKNOWN); parser++) {
333 for (parser = p_chain->last_parser - 1; parser >= p_chain->parsers && (!err || err == ARGPAR_ERR_UNKNOWN); parser--) {
347 // fprintf(p_chain->state.err_stream, dgettext(p_chain->argp->argp_domain, "%s: Too many arguments\n"), p_chain->state.name);
364 for (parser = p_chain->last_parser - 1; parser >= p_chain->parsers && (!err || err == ARGPAR_ERR_UNKNOWN); parser--) {
417 if (o[i].name && !((o[i].flags & OPTION_PARENT) && !is_parent) && !((o[i].flags & OPTION_CHILD) && is_parent) && !strcmp(o[i].name, key)) {
484 for (parser = parser_chain->parsers; parser < parser_chain->last_parser && err == ARGPAR_ERR_UNKNOWN; parser++) {
553 size_t fread_count = fread(p->parfile_buffer[this_buffer_index], sizeof(char), ufile_size + 1, file_h);
679 int argpar_parse_args(argpar *p, unsigned argc, char *argv[], unsigned flags, unsigned *end_index, void *input) {
681 argpar_help(p, argpar_ostream ? argpar_ostream : stderr, flags, (argv == NULL ? "cmd" : nondestructive_basename(argv[0])));
756 fprintf(argpar_ostream ? argpar_ostream : stderr, "Failed to reallocate array of size %lu\n", ret_size_max);
Master structure containing options, document strings, child parsers, and text filters....
Definition: argpar.h:398
int(* argpar_parser)(int key, char *argv, argpar_state *state)
Pointer to a callback function to call for each argument and option parsed.
Definition: argpar.h:360
Definition: argpar.c:27
#define ARGPAR_KEY_END
Passed as the key to the parser callback function when there are no more arguments left to parse.
Definition: argpar.h:282
const argpar_option * options
Array of option structures, terminated by an empty entry (IE: {0}).
Definition: argpar.h:400
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
Definition: CMakeLists.txt:7
unsigned next
The index in ARGV of the next arg that to be parsed. May be modified.
Definition: argpar.h:206
char ** argpar_split_trim(char *str, const char *delim)
Splits a string on a delimiter, returning a NULL-terminated list of strings, trimming left and right ...
Definition: argpar.c:769
#define OPTION_INT
Cast this option as a long. The value and any error will be reflected in the argpar_state struct duri...
Definition: argpar.h:160
argpar_parser parser
Parser function handed all options and arguments, as well as various ARGPAR_KEY_ keys for events such...
Definition: argpar.h:403
int * argpar_split_int(char *str, const char *delim)
Splits a string on a delimiter, returning a NULL_INT-terminated list of ints.
Definition: argpar.c:785
#define ARGPAR_ERR_USAGE
Returned from the parser callback to signal argpar to stop parsing, print a usage summary,...
Definition: argpar.h:338
char * name
The name used when printing messages. This is initialized to ARGV[0], or PROGRAM_INVOCATION_NAME if t...
Definition: argpar.h:233
#define ARGPAR_KEY_ARG
This is not an option at all, but rather a command line argument. If a parser receiving this key retu...
Definition: argpar.h:271
#define ARGPAR_KEY_SUCCESS
Passed as the key to each parser callback function when parsing has finished and no errors were retur...
Definition: argpar.h:295
int shash_set(shash *h, const char *key, const char *value)
Add or overwrite a pointer, associating it with the given key.
Definition: shash.c:224
#define ARGPAR_KEY_INIT
Passed as the key to each parser callback function before any parsing occurs. For most cases,...
Definition: argpar.h:287
const char * argpar_version()
Returns the source code version and the implemented API version.
Definition: argpar.c:740
#define ARGPAR_CAST_ARGS
Passed to the argpar_parse_ functions, this tells the parser to cast all key arguments to long and do...
Definition: argpar.h:116
int argpar_parse_file(argpar *p, const char *path, unsigned flags, void *input)
Parse a key=value store file.
Definition: argpar.c:730
#define ARGPAR_KEY_ERROR
Passed as the key to each parser callback function when parsing has finished and an error was returne...
Definition: argpar.h:299
#define ARGPAR_NO_KEYARGS
Passed to the argpar_parse_ functions, this tells the parser to accept options without equal signs,...
Definition: argpar.h:125
#define ARGPAR_ERR_UNKNOWN
What to return for unrecognized keys within an argpar_parser function.
Definition: argpar.h:341
int argpar_help(argpar *argpar, FILE *stream, unsigned flags, char *name)
Print the default usage summary with all available sections.
Definition: argpar-help.c:512
int state(double tjdTDB, JPLIntUtilType *util, double posvel[13][6], double *pnut)
#define ARGPAR_NO_EXIT
Passed to the argpar_parse_ functions, this tells argpar not to call exit after printing help/usage,...
Definition: argpar.h:132
#define MAX_PARFILES
Maximum amount of parfiles to be able to load into one object.
Definition: argpar.h:49
int flags
Modify the behavior of the argument by OR'ing one or more OPTION_ macros.
Definition: argpar.h:100
const char * shash_get(shash *h, const char *key)
Find a pointer associated with the given string.
Definition: shash.c:205
char * strdup(const char *)
#define ARGPAR_KEY_NO_ARGS
Passed as the key to each parser callback function when parsing has finished and no key arguments wer...
Definition: argpar.h:303
#define ARGPAR_ERR_ABORT
Returned from the parser callback to signal argpar to stop parsing and return to the caller.
Definition: argpar.h:334
#define ARGPAR_KEY_FINI
Passed as the key to each parser callback function at the very end of the process....
Definition: argpar.h:291
int shash_next(shash *h, const char **key, const char **value)
Retrieves the next key-value pair in the shash. The order in which the pointers are returned shall be...
Definition: shash.c:283
#define ARGPAR_SKIP_PARFILES
Passed to argpar_parse_args, this tells the parser to ignore parfile= arguments, useful for overwriti...
Definition: argpar.h:120
int argpar_usage(argpar_state *state)
Print usage summary, called within a argpar_parser.
Definition: argpar-help.c:506
int shash_size(shash *h)
Retrieves the number of key-value pairs in the hash object.
Definition: shash.c:320
int errno
int shash_rewind(shash *h)
Rewind iterator for traversing all the keys and values.
Definition: shash.c:277
void(* argpar_program_version_hook)(FILE *stream, argpar_state *state)
Called to print the version string. If set, a version=1 option is automatically added.
Definition: argpar.c:20
unsigned argc
Total number of arguments being parsed by a call of argpar_parse_args.
Definition: argpar.h:201
int argpar_parse_args(argpar *p, unsigned argc, char *argv[], unsigned flags, unsigned *end_index, void *input)
Parse an array of key=value pairs and/or key arguments.
Definition: argpar.c:679
#define ARGPAR_STORE_PARAMS
Passed to the argpar_parse_ functions, this tells argpar to create a special parser that stores all p...
Definition: argpar.h:141
double * argpar_split_dbl(char *str, const char *delim)
Splits a string on a delimiter, returning a NAN-terminated list of doubles.
Definition: argpar.c:809
#define OPTION_ALIAS
Do not add an extra newline after this documentation string. Useful for lists and manual formatting.
Definition: argpar.h:175
#define OPTION_DOC
This option isn't actually an option, merely text for the usage summary.
Definition: argpar.h:152
int argpar_usage_json(argpar_state *state)
Print usage summary, called within a argpar_parser, in a format more suitable for automated parsing.
Definition: argpar-json.c:414
State variable to be filled before each call to the parser callback.
Definition: argpar.h:196
A simple dictionary library for storing strings.
#define ARGPAR_ERR_PARFILE
Returned from argpar_parse_args and argpar_parse_file when an error has occurred in reading a parfile...
Definition: argpar.h:345
Definition: argpar.c:47
const argpar_child * children
Array of argpar_child structures containing parsers to nest within this one. All options and argument...
Definition: argpar.h:413
Library for reading command-line arguments in the form of key=value.
#define OPTION_CHILD
This option only applies if this parser is not the top-most parser.
Definition: argpar.h:167
char ** argpar_split_str(char *str, const char *delim)
Splits a string on a delimiter, returning a NULL-terminated list of strings.
Definition: argpar.c:744
const char * parfile
The name of the parfile being parsed, or NULL if the argument comes from the command line.
Definition: argpar.h:229
#define ARGPAR_NO_HELP
Passed to the argpar_parse_ functions, this tells argpar not to add the help option.
Definition: argpar.h:128
#define ARGPAR_ACCEPT_ANY
Passed to the argpar_parse_ functions, this tells argpar to call every parser with every option found...
Definition: argpar.h:136
#define ARGPAR_KEY_UNKNOWN
Passed as the key to each parser callback function when an unknown option has been found....
Definition: argpar.h:307
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
#define ARGPAR_LIMIT_REACHED
Returned from argpar_parse_args and argpar_parse_file when attempting to load more than the maximum a...
Definition: argpar.h:349
#define OPTION_PARENT
This option only applies if this parser is the top-most parser. Useful for return value documentation...
Definition: argpar.h:164
Definition: argpar.c:37
const char * argpar_program_version
Used as the program version string. If set, a version=1 option is automatically added....
Definition: argpar.c:19
#define OPTION_DBL
Cast this option as a double. The value and any error will be reflected in the argpar_state struct du...
Definition: argpar.h:156
int key
The value to pass to the parser callback. Must be a positive and non-zero.
Definition: argpar.h:91