/** * @file oh_args.h * @version $Id$ * * The header file that has the command line argument parsing functions. */ #ifndef _OH_ARGS_H_ #define _OH_ARGS_H_ #include "oh_port.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** * The struct of the parsed command line arguments. * * For example, "ohnes -t clib,fs -h /c/home/ohhara -c oh.cfg" is parsed like * following. * * asopts->opts[0] = "ohnes" * * asopts->nopts = 1 * * asopts->next->opts[0] = "-t" * * asopts->next->opts[1] = "clib" * * asopts->next->opts[2] = "fs" * * asopts->next->nopts = 3 * * asopts->next->next->opts[0] = "-h" * * asopts->next->next->opts[1] = "/c/home/ohhara" * * asopts->next->next->nopts = 2 * * asopts->next->next->next->opts[0] = "-c" * * asopts->next->next->next->opts[1] = "oh.cfg" * * asopts->next->next->next->nopts = 2 */ typedef struct oh_as_opts_t { /** * The array of the char strings that has the parsed command line arguments. */ oh_char **opts; /** * The length of the opts array. */ oh_int nopts; /** * The next parsed command line arguments. */ struct oh_as_opts_t *next; } oh_as_opts_t; extern oh_char **oh_as_parseRawArgs(const oh_char *rawargs, oh_int *argcp); extern oh_void oh_as_freeArgs(oh_char **args); extern oh_as_opts_t *oh_as_parseArgs(const oh_char *argsformat, oh_char **argv, oh_int *argcp); extern oh_void oh_as_freeOpts(oh_as_opts_t *opts); extern oh_as_opts_t *oh_as_findOpt(oh_as_opts_t *opts, const oh_char *opt); extern oh_as_opts_t *oh_as_newOpt(oh_int nopts, oh_char *opt, ...); extern oh_int oh_as_addOpt(oh_as_opts_t *opts, oh_as_opts_t *opt); extern oh_int oh_as_removeOpt(oh_as_opts_t *opts, const oh_char *opt); extern oh_as_opts_t *oh_as_parseCFG(const oh_char *argsformat, const oh_char *cfgfile); extern oh_int oh_as_saveToCFG(oh_as_opts_t *opts, const oh_char *cfgfile); extern oh_as_opts_t *oh_as_cloneOpts(oh_as_opts_t *opts); extern oh_as_opts_t *oh_as_mergeOpts(oh_as_opts_t *optsa, oh_as_opts_t *optsb); extern oh_void oh_as_setGlobalOpts(oh_as_opts_t *opts); extern oh_as_opts_t *oh_as_getGlobalOpts(oh_void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _OH_ARGS_H_ */