Commit 22405c3d authored by dscho's avatar dscho

command line handling

parent dae41e0b
...@@ -35,6 +35,17 @@ rfbUsage(void) ...@@ -35,6 +35,17 @@ rfbUsage(void)
exit(1); 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 void
rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]) rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
{ {
...@@ -80,12 +91,10 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]) ...@@ -80,12 +91,10 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
rfbScreen->height = atoi(argv[++i]); rfbScreen->height = atoi(argv[++i]);
} else { } else {
/* we just remove the processed arguments from the list */ /* we just remove the processed arguments from the list */
if(i != i1) { if(i != i1)
memmove(argv+i1,argv+i,sizeof(char*)*(*argc-i)); rfbPurgeArguments(argc,&i,i1-i,argv);
*argc -= i-i1;
}
i1++; i1++;
i = i1-1; i++;
} }
} }
*argc -= i-i1; *argc -= i-i1;
......
...@@ -760,6 +760,7 @@ extern int rfbSelectBox(rfbScreenInfoPtr rfbScreen, ...@@ -760,6 +760,7 @@ extern int rfbSelectBox(rfbScreenInfoPtr rfbScreen,
/* cargs.c */ /* cargs.c */
extern void rfbUsage(); extern void rfbUsage();
extern void rfbPurgeArguments(int* argc,int* position,int count,char *argv[]);
extern void rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]); extern void rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]);
extern void rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[]); extern void rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment