The ROme OpTimistic Simulator  3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
arg_parse.h
Go to the documentation of this file.
1 
11 #pragma once
12 
14 struct ap_option {
16  const char *name;
18 
19  int key;
21 
22  const char *arg;
24 
25  const char *doc;
26 };
27 
31  AP_KEY_INIT = 1 << 14,
34 };
35 
37 struct ap_section {
39  const char *header;
41  struct ap_option *opts;
43 
45  void (*parser)(int key, const char *arg);
46 };
47 
49 struct ap_settings {
51  const char *prog_doc;
53  const char *prog_version;
55  const char *prog_report;
57  struct ap_section *sects;
58 };
59 
60 extern void arg_parse_run(struct ap_settings *ap_s, char **argv);
61 extern const char *arg_parse_program_name(void);
62 extern void arg_parse_error(const char *fmt, ...);
ap_section::header
const char * header
The header printed before this section in the --help text.
Definition: arg_parse.h:39
ap_settings::prog_doc
const char * prog_doc
A description of the program.
Definition: arg_parse.h:51
ap_option::arg
const char * arg
The argument name for this option, shown in the --usage text.
Definition: arg_parse.h:22
ap_option
A single parsable command line option.
Definition: arg_parse.h:14
AP_KEY_INIT
@ AP_KEY_INIT
Signals the start of the parsing process.
Definition: arg_parse.h:31
ap_option::doc
const char * doc
The documentation of this option, shown in the --help text.
Definition: arg_parse.h:25
ap_section
A set of options organized and parsed together.
Definition: arg_parse.h:37
ap_option::key
int key
The key passed to the parsing function when encountering this option.
Definition: arg_parse.h:19
AP_KEY_FINI
@ AP_KEY_FINI
Signals the end of the parsing process.
Definition: arg_parse.h:33
ap_settings
A complete command line option parsing setup.
Definition: arg_parse.h:49
ap_settings::prog_version
const char * prog_version
A description of the program version.
Definition: arg_parse.h:53
arg_parse_error
void arg_parse_error(const char *fmt,...)
Prints a parsing related error message and exits with a bad exit code.
Definition: arg_parse.c:432
ap_event_key
ap_event_key
The special events keys passed to command line parsing functions.
Definition: arg_parse.h:29
arg_parse_program_name
const char * arg_parse_program_name(void)
Gets the program name.
Definition: arg_parse.c:422
ap_option::name
const char * name
The long option name.
Definition: arg_parse.h:16
ap_settings::prog_report
const char * prog_report
The email address of the maintainer.
Definition: arg_parse.h:55
arg_parse_run
void arg_parse_run(struct ap_settings *ap_s, char **argv)
Parses the command line options.
Definition: arg_parse.c:382
ap_settings::sects
struct ap_section * sects
The array of supported sections, terminated by a zeroed element.
Definition: arg_parse.h:57
ap_section::opts
struct ap_option * opts
The array of recognized options, terminated by a zeroed element.
Definition: arg_parse.h:41
ap_section::parser
void(* parser)(int key, const char *arg)
The parsing function.
Definition: arg_parse.h:45