A parser for command line arguments. More...
#include "cmdLineParser.h"#include <stdio.h>#include <getopt.h>#include <string.h>#include "mytype.h"#include "memUtils.h"
Go to the source code of this file.
Data Structures | |
| struct | MyOptionSt |
Macros | |
| #define | nextOption(o) ((MyOption*) o->next) |
Typedefs | |
| typedef struct MyOptionSt | MyOption |
Functions | |
| static char * | dupString (const char *s) |
| static MyOption * | myOptionAlloc (const char *longOption, const char shortOption, int has_arg, const char type, void *dataPtr, int dataSize, const char *help) |
| static MyOption * | myOptionFree (MyOption *o) |
| static MyOption * | lastOption (MyOption *o) |
| static MyOption * | findOption (MyOption *o, unsigned char shortArg) |
| int | addArg (const char *longOption, const char shortOption, int has_arg, const char type, void *dataPtr, int dataSize, const char *help) |
| Specifies a command line argument that should be accepted by the program. More... | |
| void | freeArgs () |
| void | printArgs () |
| Prints the arguments to the stdout stream. More... | |
| void | processArgs (int argc, char **argv) |
| Call this to process your arguments. More... | |
Variables | |
| static int | longest = 1 |
| static MyOption * | myargs =NULL |
A parser for command line arguments.
A general purpose command line parser that uses getopt_long() to parse the command line.
Definition in file cmdLineParser.c.
| #define nextOption | ( | o | ) | ((MyOption*) o->next) |
Definition at line 19 of file cmdLineParser.c.
| typedef struct MyOptionSt MyOption |
| int addArg | ( | const char * | longOption, |
| const char | shortOption, | ||
| int | has_arg, | ||
| const char | type, | ||
| void * | dataPtr, | ||
| int | dataSize, | ||
| const char * | help | ||
| ) |
Specifies a command line argument that should be accepted by the program.
| [in] | longOption | The long name of option i.e., –optionname |
| [in] | shortOption | The short name of option i.e., -o |
| [in] | has_arg | Whether this option has an argument i.e., -o value. If has_arg is 0, then dataPtr must be an integer pointer. |
| [in] | type | The type of the argument. Valid values are:
|
| [in] | dataPtr | A pointer to where the value will be stored. |
| [in] | dataSize | The length of dataPtr, only useful for character strings. |
| [in] | help | A short help string, preferably a single line or less. |
Definition at line 96 of file cmdLineParser.c.


|
static |
Definition at line 36 of file cmdLineParser.c.


| void freeArgs | ( | void | ) |
Definition at line 114 of file cmdLineParser.c.


|
static |
Definition at line 45 of file cmdLineParser.c.


| void printArgs | ( | void | ) |
Prints the arguments to the stdout stream.
Definition at line 123 of file cmdLineParser.c.

| void processArgs | ( | int | argc, |
| char ** | argv | ||
| ) |
Call this to process your arguments.
Definition at line 144 of file cmdLineParser.c.


|
static |
Definition at line 33 of file cmdLineParser.c.
|
static |
Definition at line 34 of file cmdLineParser.c.