A simple argument parser, inspired by getopt. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "argparser.h"
Include dependency graph for argparser.c:Go to the source code of this file.
Functions | |
| int | _eurephia_getopt (const char *module, int *curarg, int argc, char **argv, e_options *argopts) |
| size_t | eurephia_arraycp (int stidx, int inargc, char **inargv, char **outargv, size_t outsize) |
Variables | |
| char * | optargs [64] |
A simple argument parser, inspired by getopt.
Definition in file argparser.c.
| int _eurephia_getopt | ( | const char * | module, | |
| int * | curarg, | |||
| int | argc, | |||
| char ** | argv, | |||
| e_options * | argopts | |||
| ) |
Internal argument parser. Normally called via the eurephia_getopt(...) macro. Parses an argument and prepares the char **optargs array with parameters to the arguments.
| module | string (const char *) containing a descriptive module name, used in error situations. | |
| curarg | pointer to the argument index counter which gets updated during parsing. | |
| argc | Input argument counter | |
| argv | Input argument array (char **) | |
| argopts | e_options struct array containing valid argument |
Definition at line 53 of file argparser.c.
| size_t eurephia_arraycp | ( | int | stidx, | |
| int | inargc, | |||
| char ** | inargv, | |||
| char ** | outargv, | |||
| size_t | outsize | |||
| ) |
This function will take (argc,argv) and copy pointers over to (**outargv), starting from the index given in stidx (start index). The outargv array must have been allocated first by calloc(sizeof(char *), elmnts). The outsize must not exceed the number of elements you have allocated space for. The function returns number of elements copied (the new argc, kind of)
| stidx | start index of where to start the copy | |
| inargc | input argument counter (size of the input array) | |
| inargv | input argument array (char **) | |
| outargv | pointer to an array of where to put the values being copied. | |
| outsize | Size of the output array. |
Definition at line 97 of file argparser.c.
Here is the caller graph for this function:| char* optargs[64] |
If an argument takes parameters, they will be put into this array
Definition at line 38 of file argparser.c.
1.7.1