diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-04 00:48:52 +0200 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-04 00:48:52 +0200 |
| commit | da402ffcbe7e9a616bab83739b7294ce9f5e79c4 (patch) | |
| tree | 8e85cd3f72a1cfa5b1600461b687917423eb2c9d /eurephiadm/argparser.c | |
| parent | 2dcc5b5da4291e0cb4fb9fce6134dc836e92c344 (diff) | |
| download | eurephia-da402ffcbe7e9a616bab83739b7294ce9f5e79c4.tar.gz eurephia-da402ffcbe7e9a616bab83739b7294ce9f5e79c4.tar.xz eurephia-da402ffcbe7e9a616bab83739b7294ce9f5e79c4.zip | |
Added doxygen comments for the main eurephiadm parts
Diffstat (limited to 'eurephiadm/argparser.c')
| -rw-r--r-- | eurephiadm/argparser.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/eurephiadm/argparser.c b/eurephiadm/argparser.c index 5f0be4e..33dc7ec 100644 --- a/eurephiadm/argparser.c +++ b/eurephiadm/argparser.c @@ -19,6 +19,15 @@ * */ +/** + * @file argparser.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2008-12-04 + * + * @brief A simple argument parser, inspired by getopt. + * + */ + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -26,8 +35,21 @@ #define ARGPARSER_C #include "argparser.h" -char *optargs[MAX_ARGUMENTS]; +char *optargs[MAX_ARGUMENTS]; /**< If an argument takes parameters, they will be put into this array */ + +/** + * Internal argument parser. Normally called via the eurephia_getopt(...) macro. Parses an + * argument and prepares the char **optargs array with parameters to the arguments. + * + * @param module string (const char *) containing a descriptive module name, used in error situations. + * @param curarg pointer to the argument index counter which gets updated during parsing. + * @param argc Input argument counter + * @param argv Input argument array (char **) + * @param argopts e_options struct array containing valid argument + * + * @return returns the short arg value on success, or -1 on failure. + */ int _eurephia_getopt(const char *module, int *curarg, int argc, char **argv, e_options *argopts) { int i = 0; char *arg = argv[*curarg]; @@ -58,11 +80,20 @@ int _eurephia_getopt(const char *module, int *curarg, int argc, char **argv, e_o } -// 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) -// +/** + * 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) + * + * @param stidx start index of where to start the copy + * @param inargc input argument counter (size of the input array) + * @param inargv input argument array (char **) + * @param outargv pointer to an array of where to put the values being copied. + * @param outsize Size of the output array. + * + * @return Returns number of argument copied over to the output array. + */ size_t eurephia_arraycp(int stidx, int inargc, char **inargv, char **outargv, size_t outsize) { int i, outargc; |
