summaryrefslogtreecommitdiffstats
path: root/eurephiadm/argparser.c
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-12-06 20:30:01 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-12-06 20:30:01 +0100
commit60e847c330420ac5029ac5ed6580776c26a52282 (patch)
treeef2c1019335a400f0cbcdf2e7a5ea7d78c7602ea /eurephiadm/argparser.c
parent156cf85d2d9b747896fb75d51ca4347d8909ffa5 (diff)
downloadeurephia-60e847c330420ac5029ac5ed6580776c26a52282.tar.gz
eurephia-60e847c330420ac5029ac5ed6580776c26a52282.tar.xz
eurephia-60e847c330420ac5029ac5ed6580776c26a52282.zip
More improvements to eurephia_getopt(...)
Sending the argument incrementer as reference instead of as value. This way eurephia_getopt(...) can directly increase the incrementer on arguments with extra options.
Diffstat (limited to 'eurephiadm/argparser.c')
-rw-r--r--eurephiadm/argparser.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/eurephiadm/argparser.c b/eurephiadm/argparser.c
index bc635e8..cbfdc67 100644
--- a/eurephiadm/argparser.c
+++ b/eurephiadm/argparser.c
@@ -27,9 +27,9 @@
char *optargs[MAX_ARGUMENTS];
-int _eurephia_getopt(const char *module, int curarg, int argc, char **argv, e_options *argopts) {
+int _eurephia_getopt(const char *module, int *curarg, int argc, char **argv, e_options *argopts) {
int i = 0;
- char *arg = argv[curarg];
+ char *arg = argv[*curarg];
if( arg == NULL ) {
return -1;
@@ -39,10 +39,11 @@ int _eurephia_getopt(const char *module, int curarg, int argc, char **argv, e_op
if( (strcmp(argopts[i].longarg, arg) == 0)
|| (strcmp(argopts[i].shortarg, arg) == 0) )
{
- if( (argopts[i].param > 0) && (argc > curarg+argopts[i].param) ) {
+ if( (argopts[i].param > 0) && (argc > (*curarg)+argopts[i].param) ) {
int j = 0;
for( j = 0; j < argopts[i].param; j++ ) {
- optargs[j] = argv[curarg+j+1];
+ optargs[j] = argv[(*curarg)+j+1];
+ (*curarg)++;
}
} else if( (argopts[i].param > 0) ) {
fprintf(stderr, "%s: ERROR :: Missing argument(s) to '%s'\n", module, arg);