|  | Flowgrind
    Advanced TCP traffic generator | 
Command line argument parser. More...
#include <stdbool.h>Go to the source code of this file.
| Data Structures | |
| struct | ap_Mutex_state | 
| Contains the state of all mutex.  More... | |
| struct | ap_Option | 
| Defines a valid command line option.  More... | |
| struct | ap_Record | 
| Holds a parsed command line option and its argument.  More... | |
| struct | arg_parser | 
| Internal state of the argument parser.  More... | |
| Enumerations | |
| enum | ap_Has_arg { ap_no = 0, ap_yes, ap_maybe } | 
| Specifies whether a command line option needs an argument.  More... | |
| Functions | |
| const char * | ap_argument (const struct arg_parser *const ap, const int i) | 
| Returns the argument of a parsed option.  More... | |
| int | ap_arguments (const struct arg_parser *const ap) | 
| Number of arguments parsed (may be different from argc).  More... | |
| bool | ap_check_mutex (const struct arg_parser *const ap, const struct ap_Mutex_state *const ms, const int i, int *conflict) | 
| Check a new option record for mutex.  More... | |
| int | ap_code (const struct arg_parser *const ap, const int i) | 
| Returns the code of a parsed option with given index.  More... | |
| const char * | ap_error (const struct arg_parser *const ap) | 
| Get the string containing errors encountered during parsing.  More... | |
| void | ap_free (struct arg_parser *const ap) | 
| Free internal state of arg-parser.  More... | |
| void | ap_free_mutex_state (struct ap_Mutex_state *const ms) | 
| Free a mutex context.  More... | |
| bool | ap_init (struct arg_parser *const ap, const int argc, const char *const argv[], const struct ap_Option options[], const char in_order) | 
| Initialize the arg-parser given command line and user-defined options.  More... | |
| bool | ap_init_mutex_state (const struct arg_parser *const ap, struct ap_Mutex_state *const ms) | 
| Initialize a new mutex state table.  More... | |
| bool | ap_is_used (const struct arg_parser *const ap, int code) | 
| Returns true if the option specified by codewas given at least once.  More... | |
| const char * | ap_opt_string (const struct arg_parser *const ap, const int i) | 
| Get the real command line option string (may be the short or long version).  More... | |
| const struct ap_Option * | ap_option (const struct arg_parser *const ap, const int i) | 
| Get the user-defined option for a given record position.  More... | |
| void | ap_reset_mutex (struct ap_Mutex_state *const ms) | 
| Reset a mutex context.  More... | |
| bool | ap_set_check_mutex (const struct arg_parser *const ap, struct ap_Mutex_state *const ms, const int i, int *conflict) | 
| Check a new option record for mutex and register it at the same time.  More... | |
| bool | ap_set_mutex (const struct arg_parser *const ap, struct ap_Mutex_state *const ms, const int i) | 
| Register an option record in a mutex context.  More... | |
Command line argument parser.
Definition in file fg_argparser.h.
| enum ap_Has_arg | 
Specifies whether a command line option needs an argument.
| Enumerator | |
|---|---|
| ap_no | Option without argument (flag). | 
| ap_yes | Argument required. | 
| ap_maybe | Optional Argument. | 
Definition at line 35 of file fg_argparser.h.
| const char* ap_argument | ( | const struct arg_parser *const | ap, | 
| const int | i | ||
| ) | 
Returns the argument of a parsed option.
| [in] | ap | pointer to arg-parser state | 
| [in] | i | index of the parsed option | 
i. If this option has code 0 (non-option), the non-option string is returned Definition at line 478 of file fg_argparser.c.
| int ap_arguments | ( | const struct arg_parser *const | ap | ) | 
Number of arguments parsed (may be different from argc).
| [in] | ap | pointer to arg-parser state | 
Definition at line 463 of file fg_argparser.c.
| bool ap_check_mutex | ( | const struct arg_parser *const | ap, | 
| const struct ap_Mutex_state *const | ms, | ||
| const int | i, | ||
| int * | conflict | ||
| ) | 
Check a new option record for mutex.
| [in] | ap | pointer to arg-parser state | 
| [in] | ms | pointer to an initialized mutex context | 
| [in] | i | index of the option to check for previous occurrences of mutexed options | 
| [in] | conflict | pointer to a single integer value. This will contain the conflicting record position, if a conflict has been found | 
ms has occurred, otherwise flase Definition at line 527 of file fg_argparser.c.
| int ap_code | ( | const struct arg_parser *const | ap, | 
| const int | i | ||
| ) | 
Returns the code of a parsed option with given index.
| [in] | ap | pointer to arg-parser state | 
| [in] | i | index of the parsed option | 
i. If this is a non-option, it returns 0 Definition at line 468 of file fg_argparser.c.
| const char* ap_error | ( | const struct arg_parser *const | ap | ) | 
Get the string containing errors encountered during parsing.
| [in] | ap | pointer to arg-parser state | 
Definition at line 458 of file fg_argparser.c.
| void ap_free | ( | struct arg_parser *const | ap | ) | 
Free internal state of arg-parser.
| [in] | ap | pointer to arg-parser state | 
Definition at line 448 of file fg_argparser.c.
| void ap_free_mutex_state | ( | struct ap_Mutex_state *const | ms | ) | 
Free a mutex context.
| [in] | ms | pointer to an initialized mutex context | 
Definition at line 583 of file fg_argparser.c.
| bool ap_init | ( | struct arg_parser *const | ap, | 
| const int | argc, | ||
| const char *const | argv[], | ||
| const struct ap_Option | options[], | ||
| const char | in_order | ||
| ) | 
Initialize the arg-parser given command line and user-defined options.
| [in] | ap | pointer to arg-parser state | 
| [in] | argc | number of command line arguments | 
| [in] | argv | array of command line argument strings | 
| [in] | options | array of user-defined options to parse for. The last entry of the array needs to have '0' members. This array will be copied over to the arg-parser state ap. | 
| [in] | in_order | if set to true, arguments are stored in the order in which they appear. If false, non-option arguments are stored after options | 
Definition at line 374 of file fg_argparser.c.
| bool ap_init_mutex_state | ( | const struct arg_parser *const | ap, | 
| struct ap_Mutex_state *const | ms | ||
| ) | 
Initialize a new mutex state table.
This can be seen as a separate context for checking mutex. Thus, by initializing more than one mutex state, mutual exclusions of options may be evaluated in independent contexts.
| [in] | ap | pointer to arg-parser state | 
| [in] | ms | pointer to a new mutex context. It can be used in the following to check and set mutual exclusions | 
Definition at line 516 of file fg_argparser.c.
| bool ap_is_used | ( | const struct arg_parser *const | ap, | 
| int | code | ||
| ) | 
Returns true if the option specified by code was given at least once. 
| [in] | ap | pointer to arg-parser state | 
| [in] | code | code of the option to check return return true if the option specified by codehas been parsed, otherwise false | 
Definition at line 503 of file fg_argparser.c.
| const char* ap_opt_string | ( | const struct arg_parser *const | ap, | 
| const int | i | ||
| ) | 
Get the real command line option string (may be the short or long version).
| [in] | ap | pointer to arg-parser state | 
| [in] | i | index of the parsed option | 
Definition at line 486 of file fg_argparser.c.
| const struct ap_Option* ap_option | ( | const struct arg_parser *const | ap, | 
| const int | i | ||
| ) | 
Get the user-defined option for a given record position.
| [in] | ap | pointer to arg-parser state | 
| [in] | i | index of the parsed option | 
i Definition at line 494 of file fg_argparser.c.
| void ap_reset_mutex | ( | struct ap_Mutex_state *const | ms | ) | 
Reset a mutex context.
| [in] | ms | pointer to an initialized mutex context | 
Definition at line 578 of file fg_argparser.c.
| bool ap_set_check_mutex | ( | const struct arg_parser *const | ap, | 
| struct ap_Mutex_state *const | ms, | ||
| const int | i, | ||
| int * | conflict | ||
| ) | 
Check a new option record for mutex and register it at the same time.
| [in] | ap | pointer to arg-parser state | 
| [in] | ms | pointer to an initialized mutex context | 
| [in] | i | index of the option to register in the mutex state ms | 
| [in] | conflict | pointer to a single integer value. This will contain the conflicting record position, if a conflict has been found | 
ms has occurred, otherwise false Definition at line 569 of file fg_argparser.c.
| bool ap_set_mutex | ( | const struct arg_parser *const | ap, | 
| struct ap_Mutex_state *const | ms, | ||
| const int | i | ||
| ) | 
Register an option record in a mutex context.
| [in] | ap | pointer to arg-parser state | 
| [in] | ms | pointer to an initialized mutex context | 
| [in] | i | index of the option to register in the mutex state ms | 
Definition at line 553 of file fg_argparser.c.