summaryrefslogtreecommitdiffstats
path: root/cargs.c
diff options
context:
space:
mode:
authordscho <dscho>2002-04-30 14:06:50 +0000
committerdscho <dscho>2002-04-30 14:06:50 +0000
commit22405c3dddfe5cb78b792f3d6b20ba1e5bd427a9 (patch)
treeff2538b39f237932b0dac11cd1ff2e785495dccc /cargs.c
parentdae41e0b3e72620cee8dd496f9f5271d791ee58f (diff)
downloadlibtdevnc-22405c3dddfe5cb78b792f3d6b20ba1e5bd427a9.tar.gz
libtdevnc-22405c3dddfe5cb78b792f3d6b20ba1e5bd427a9.zip
command line handling
Diffstat (limited to 'cargs.c')
-rw-r--r--cargs.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/cargs.c b/cargs.c
index 6e41ae5..03696a3 100644
--- a/cargs.c
+++ b/cargs.c
@@ -35,6 +35,17 @@ rfbUsage(void)
exit(1);
}
+/* purges COUNT arguments from ARGV at POSITION and decrements ARGC.
+ POSITION points to the first non purged argument afterwards. */
+void rfbPurgeArguments(int* argc,int* position,int count,char *argv[])
+{
+ int amount=(*argc)-(*position)-count;
+ if(amount)
+ memmove(argv+(*position),argv+(*position)+count,sizeof(char*)*amount);
+ (*argc)-=count;
+ (*position)--;
+}
+
void
rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
{
@@ -80,12 +91,10 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
rfbScreen->height = atoi(argv[++i]);
} else {
/* we just remove the processed arguments from the list */
- if(i != i1) {
- memmove(argv+i1,argv+i,sizeof(char*)*(*argc-i));
- *argc -= i-i1;
- }
+ if(i != i1)
+ rfbPurgeArguments(argc,&i,i1-i,argv);
i1++;
- i = i1-1;
+ i++;
}
}
*argc -= i-i1;