coan 4.2.4
|
![]() |
Modules | |
Macro-generated code. | |
Files | |
file | args.c |
Defines | |
#define | PROGRESS_GAGGED() ((GET_PUBLIC(args,diagnostic_filter) & MSGCLASS_PROGRESS) != 0) |
#define | VERSION "4.2.3" |
Enumerations | |
enum | option_codes { OPT_FILE = 'f', OPT_REPLACE = 'r', OPT_BACKUP = 'b', OPT_DEF = 'D', OPT_UNDEF = 'U', OPT_CONFLICT = 'x', OPT_GAG = 'g', OPT_VERBOSE = 'V', OPT_COMPLEMENT = 'c', OPT_DEBUG = 1, OPT_EVALCONSTS = 'E', OPT_DISCARD = 'k', OPT_LINE = 2, OPT_POD = 'P', OPT_RECURSE = 'R', OPT_FILTER = 'F', OPT_KEEPGOING = 'K', OPT_IFS = 'i', OPT_DEFS = 'd', OPT_UNDEFS = 'u', OPT_INCLUDES = 3, OPT_LOCATE = 'L', OPT_ONCE = 'o', OPT_SYSTEM = 's', OPT_LOCAL = 'l', OPT_ACTIVE = 'A', OPT_INACTIVE = 'I', OPT_EVALSYMS = 'e', OPT_IMPLICIT = 'm' } |
Functions | |
static void | make_opts_list (void) |
static void | usage (FILE *fp) |
static void | usage_error_summary (void) |
static void | usage_error (int reason, const char *format,...) |
static void | usage_help (void) |
static void | version (void) |
static void | config_diagnostics (const char *arg) |
static void | finalise_diagnostics (void) |
static void | error_invalid_opt (cmd_option_t const *cmd, int bad_opt) |
static bool | add_files (char const *path) |
static void | parse_args_file (const char *argsfile) |
static void | parse_command_args (int argc, char *argv[]) |
Variables | |
static struct option | long_options [] |
static char | opts [(sizeof(long_options)/sizeof(struct option))*3] |
static struct cmd_option | commands [] |
static int const | source_cmd_exclusions [] |
static int const | symbols_cmd_exclusions [] |
static int const | includes_cmd_exclusions [] |
static int const | directives_cmd_exclusions [] |
static int const | defs_cmd_exclusions [] |
static int const | pragmas_cmd_exclusions [] |
static int const | errors_cmd_exclusions [] |
static struct exclusion_list const | cmd_exclusion_lists [] |
#define PROGRESS_GAGGED | ( | ) | ((GET_PUBLIC(args,diagnostic_filter) & MSGCLASS_PROGRESS) != 0) |
Say whether we are suppressing progress messages
Definition at line 104 of file args.c.
Referenced by parse_command_args().
#define VERSION "4.2.3" |
enum option_codes |
Enumeraton of codes for the options of all coan commands
static bool add_files | ( | char const * | path | ) | [static] |
Add files to the input dataset.
path | File or directory to be included in the input dataset. |
path
is added to the input dataset, else false.If path is a file that satisfies any --filter
option it is added to the input dataset.
If path is a directory and --recurse
is in force then files recursively beneath it that satisfy any --filter
option are added to the input dataset.
If path is a directory and --recurse
is not in force then the directory is ignored.
Definition at line 665 of file args.c.
References dataset_add(), FS_IS_DIR, FS_IS_FILE, FS_IS_SLINK, FS_OBJ_NONE, fs_obj_type(), GET_PUBLIC, GRIPE_BROKEN_SYMLINK, GRIPE_DIR_IGNORED, GRIPE_NO_FILE, and report().
Referenced by finish_args(), and parse_command_args().
static void config_diagnostics | ( | const char * | arg | ) | [static] |
Configure diagnostic output in response to a --gag
or --verbose
option.
arg | Either "verbose" or an argument to the --gag option |
Definition at line 556 of file args.c.
References GET_PUBLIC, GRIPE_DUPLICATE_MASK, GRIPE_USAGE_ERROR, GRIPE_VERBOSE_ONLY, MSGCLASS_ABEND, MSGCLASS_ERROR, MSGCLASS_INFO, MSGCLASS_NONE, MSGCLASS_PROGRESS, MSGCLASS_SUMMARY, MSGCLASS_WARNING, report(), SET_PUBLIC, and usage_error().
Referenced by finalise_diagnostics(), and parse_command_args().
static void error_invalid_opt | ( | cmd_option_t const * | cmd, |
int | bad_opt | ||
) | [static] |
Raise a usage error when an option is invalid for the active command.
cmd | Pointer to details of the active coan command. |
bad_opt | The code of the invalid option. |
Definition at line 634 of file args.c.
References get_long_opt_name(), GRIPE_INVALID_ARGS, cmd_option::name, and usage_error().
Referenced by parse_command_args().
static void finalise_diagnostics | ( | void | ) | [static] |
Configure the final state of diagnostic output filtering.
If no --gag
or --verbose
option has been seen, default to --gag info --gag summary
.
Definition at line 613 of file args.c.
References config_diagnostics(), GET_PUBLIC, and SET_PUBLIC.
Referenced by parse_command_args().
static void make_opts_list | ( | void | ) | [static] |
Assemble the shortopts argument for getopts_long(). The string is constructed by scanning the long_options array to avoid the need for manually maintaining agreement between that structure and the shortopts string.
This function is called only once.
Definition at line 278 of file args.c.
References option::has_arg, long_options, option::name, no_argument, optional_argument, opts, required_argument, and option::val.
Referenced by parse_command_args().
static void parse_args_file | ( | const char * | argsfile | ) | [static] |
Parse commandline options from a file specified with the --file
option.
argsfile | Name of the file from which to read options Options are separated by whitespace in the file. The parsed options are stored in an argv array held in the component's private state. This array can then be parsed by parse_args() as if passed to main(). |
Definition at line 940 of file args.c.
References bail(), GET_PUBLIC, GET_STATE, GRIPE_CANT_READ_INPUT, GRIPE_MULTIPLE_ARGFILES, open_file(), parse_command_args(), ptr_vector_append(), ptr_vector_begin(), ptr_vector_count(), SET_STATE, and zallocate().
Referenced by parse_command_args().
static void parse_command_args | ( | int | argc, |
char * | argv[] | ||
) | [static] |
Parse the options to the active coan command.
argc | The number of arguments to be parsed. |
argv | The array of arguments to be parsed. |
Definition at line 706 of file args.c.
References add_files(), cmd_option::cmd_code, CMD_SOURCE, complement(), concatenate(), config_diagnostics(), CONTRADICTION_COMMENT, CONTRADICTION_DELETE, CONTRADICTION_ERROR, dataset_filter_filetypes(), debugging(), DISCARD_BLANK, DISCARD_COMMENT, DISCARD_DROP, error_invalid_opt(), finalise_diagnostics(), GET_PUBLIC, getopt_long(), GRIPE_NO_SYMS, GRIPE_USAGE_ERROR, make_opts_list(), OPT_ACTIVE, OPT_BACKUP, OPT_COMPLEMENT, OPT_CONFLICT, OPT_DEBUG, OPT_DEF, OPT_DEFS, OPT_DISCARD, OPT_EVALCONSTS, OPT_EVALSYMS, OPT_FILE, OPT_FILTER, OPT_GAG, OPT_IFS, OPT_IMPLICIT, OPT_INACTIVE, OPT_INCLUDES, OPT_KEEPGOING, OPT_LINE, OPT_LOCAL, OPT_LOCATE, OPT_ONCE, OPT_POD, OPT_RECURSE, OPT_REPLACE, OPT_SYSTEM, OPT_UNDEF, OPT_UNDEFS, OPT_VERBOSE, optarg, optind, opts, opts_are_compatible(), parse_args_file(), PROGRESS_BUILDING_TREE, PROGRESS_GAGGED, PROGRESS_GOT_OPTIONS, ptr_set_count(), report(), SET_PUBLIC, SET_STATE, symbol_evaluate_status(), and usage_error().
Referenced by parse_args(), and parse_args_file().
static void usage | ( | FILE * | fp | ) | [static] |
Write brief command usage information to a file
fp | Stream to which the info will be written. |
Definition at line 306 of file args.c.
References GET_PUBLIC.
Referenced by usage_error_summary(), and usage_help().
static void usage_error | ( | int | reason, |
const char * | format, | ||
... | |||
) | [static] |
Write a usage error diagnostic on stderr
followed by a usage summary, then terminate the program.
reason | Reason code the for usage error |
format | Format for composing error disgnostic with subsequent args. |
If format
is NULL
then the diagnostic is assumed to be "Invalid usage" and the reason is defaulted to GRIPE_USAGE_ERROR
Definition at line 508 of file args.c.
References GRIPE_USAGE_ERROR, usage_error_summary(), and vbail().
Referenced by config_diagnostics(), error_invalid_opt(), finish_args(), parse_args(), and parse_command_args().
static void usage_error_summary | ( | void | ) | [static] |
Wrapper for usage(stderr)
call, used for atexit()
registration
Definition at line 493 of file args.c.
References usage().
Referenced by usage_error().
static void usage_help | ( | void | ) | [static] |
Write brief command usage information to stdout
for the --help
option, then terminate the program wihtout error.
Definition at line 526 of file args.c.
References MSGCLASS_NONE, and usage().
Referenced by parse_args().
static void version | ( | void | ) | [static] |
Write version information about the program on stdout
Definition at line 544 of file args.c.
References GET_PUBLIC, MSGCLASS_NONE, OS_TYPE, and VERSION.
Referenced by parse_args().
struct exclusion_list const cmd_exclusion_lists[] [static] |
{ { 0, NULL }, { CMD_HELP, NULL }, { CMD_VERSION, NULL }, { CMD_SOURCE, source_cmd_exclusions}, { CMD_SYMBOLS, symbols_cmd_exclusions }, { CMD_INCLUDES, includes_cmd_exclusions }, { CMD_DEFS, defs_cmd_exclusions }, { CMD_PRAGMAS, pragmas_cmd_exclusions }, { CMD_ERRORS, errors_cmd_exclusions }, { CMD_DIRECTIVES, directives_cmd_exclusions }, { 0, NULL } }
Array of exclusion list for the coan commands, indexed by command code.
struct cmd_option commands[] [static] |
{ { "help", CMD_HELP, CMD_HELP_MASK }, { "-h", CMD_HELP, CMD_HELP_MASK }, { "--help", CMD_HELP, CMD_HELP_MASK }, { "version", CMD_VERSION, CMD_VERSION_MASK }, { "-v", CMD_VERSION, CMD_VERSION_MASK }, { "--version", CMD_VERSION, CMD_VERSION_MASK }, { "source", CMD_SOURCE, CMD_SOURCE_MASK }, { "symbols", CMD_SYMBOLS, CMD_SYMBOLS_MASK }, { "includes", CMD_INCLUDES, CMD_INCLUDES_MASK }, { "defs", CMD_DEFS, CMD_DEFS_MASK }, { "pragmas", CMD_PRAGMAS, CMD_PRAGMAS_MASK }, { "errors", CMD_ERRORS, CMD_ERRORS_MASK }, { "directives", CMD_DIRECTIVES, CMD_DIRECTIVES_MASK }, { 0, 0 } }
Array of structures specifying the valid coan commands
Definition at line 184 of file args.c.
Referenced by get_command_option().
int const defs_cmd_exclusions[] [static] |
{ OPT_REPLACE, OPT_CONFLICT, OPT_DISCARD, OPT_LINE, OPT_BACKUP, OPT_SYSTEM, OPT_LOCAL, OPT_IFS, OPT_DEFS, OPT_UNDEFS, OPT_INCLUDES, OPT_COMPLEMENT, OPT_EVALSYMS, 0 }
Excluded options for the defs command. .
int const directives_cmd_exclusions[] [static] |
{ OPT_REPLACE, OPT_CONFLICT, OPT_DISCARD, OPT_LINE, OPT_BACKUP, OPT_IFS, OPT_DEFS, OPT_UNDEFS, OPT_INCLUDES, OPT_COMPLEMENT, OPT_EVALSYMS, 0 }
Excluded options for the directives command. .
int const errors_cmd_exclusions[] [static] |
{ OPT_REPLACE, OPT_CONFLICT, OPT_DISCARD, OPT_LINE, OPT_BACKUP, OPT_SYSTEM, OPT_LOCAL, OPT_IFS, OPT_DEFS, OPT_UNDEFS, OPT_INCLUDES, OPT_COMPLEMENT, OPT_EVALSYMS, 0 }
Excluded options for the errors command.
int const includes_cmd_exclusions[] [static] |
{ OPT_REPLACE, OPT_CONFLICT, OPT_DISCARD, OPT_LINE, OPT_BACKUP, OPT_IFS, OPT_DEFS, OPT_UNDEFS, OPT_INCLUDES, OPT_COMPLEMENT, OPT_EVALSYMS, 0 }
Excluded options for the includes command. .
struct option long_options[] [static] |
Array of structures specifying the valid options for all coan commands
Definition at line 143 of file args.c.
Referenced by make_opts_list().
char opts[(sizeof(long_options)/sizeof(struct option))*3] [static] |
Array in which we will assemble the shortopts
arguments for getopts_long() We allow 3 bytes per short option, i,e, the short option code possibly followed by up to 2 colons.
Definition at line 181 of file args.c.
Referenced by make_opts_list(), and parse_command_args().
int const pragmas_cmd_exclusions[] [static] |
{ OPT_REPLACE, OPT_CONFLICT, OPT_DISCARD, OPT_LINE, OPT_BACKUP, OPT_SYSTEM, OPT_LOCAL, OPT_IFS, OPT_DEFS, OPT_UNDEFS, OPT_INCLUDES, OPT_COMPLEMENT, OPT_EVALSYMS, 0 }
Excluded options for the pragmas command.
int const source_cmd_exclusions[] [static] |
{ OPT_IFS, OPT_DEFS, OPT_UNDEFS, OPT_INCLUDES, OPT_LOCATE, OPT_ONCE, OPT_SYSTEM, OPT_LOCAL, OPT_ACTIVE, OPT_INACTIVE, OPT_EVALSYMS, 0 }
Excluded options for the source command. .
int const symbols_cmd_exclusions[] [static] |
{ OPT_REPLACE, OPT_CONFLICT, OPT_DISCARD, OPT_LINE, OPT_SYSTEM, OPT_LOCAL, OPT_BACKUP, OPT_COMPLEMENT, 0 }
Excluded options for the symbols command. .