creeper
|
Simple command-line argument parsing module. More...
Go to the source code of this file.
Functions | |
int | initArgumentParser (int argc, char *argv[]) |
Initializes the simple command-line parsing module. More... | |
char * | getCommand (void) |
Retrieves the program name. More... | |
char * | getValueForOption (char *keyName) |
Gets the corresponding value for a given option key ("-key=value") More... | |
int | getNumberOfArguments (void) |
char * | getArgument (int index) |
Retrieves an argument. More... | |
Simple command-line argument parsing module.
This module is useful for parsing the argv
array passed to a program via the command line, which can consist of the following argument classes:
argv
[0]), which can be retrieved by calling getCommand().Command-line argument format supported by this modul: <command> [arguments..] [options..] After the command an arbitray number of arguments followed by an arbitrary number of options can be specified. Both, arguments and options, are optional.
char* getArgument | ( | int | index | ) |
Retrieves an argument.
index | Zero-based index of the argument. |
NULL
if index is greater than or equal to the number of arguments. char* getCommand | ( | void | ) |
Retrieves the program name.
argv
[0]. int getNumberOfArguments | ( | void | ) |
Retrieves the number of arguments.
char* getValueForOption | ( | char * | keyName | ) |
Gets the corresponding value for a given option key ("-key=value")
If the same key appears several times in the command line, the value of its first occurrence is returned.
key | The key without leading dash. |
NULL
if no such pair exists. int initArgumentParser | ( | int | argc, |
char * | argv[] | ||
) |
Initializes the simple command-line parsing module.
This function must be invoked before any of the other functions.
argc | Number of command-line arguments. |
argv | Array of command-line arguments. The contents of this array are not modified in any manner. |
EINVAL
.