summaryrefslogtreecommitdiffstats
path: root/cargs.c
diff options
context:
space:
mode:
authordscho <dscho>2002-12-30 09:33:35 +0000
committerdscho <dscho>2002-12-30 09:33:35 +0000
commit357844447caa9af50f78fb3cc17309621ee90e76 (patch)
treedfa794f2d91b5018a421c48fd84202787b9bd4de /cargs.c
parent49c2d82dcb0d521c9b8c1605d94deea53e6617d5 (diff)
downloadlibtdevnc-357844447caa9af50f78fb3cc17309621ee90e76.tar.gz
libtdevnc-357844447caa9af50f78fb3cc17309621ee90e76.zip
fixed cargs (segmentation fault!)
Diffstat (limited to 'cargs.c')
-rw-r--r--cargs.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/cargs.c b/cargs.c
index 03696a3..25d57e4 100644
--- a/cargs.c
+++ b/cargs.c
@@ -53,7 +53,7 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
if(!argc) return;
- for (i = i1 = 1; i < *argc; i++) {
+ for (i = i1 = 1; i < *argc;) {
if (strcmp(argv[i], "-help") == 0) {
rfbUsage();
exit(1);
@@ -73,7 +73,7 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
passwds[1] = 0;
rfbScreen->rfbAuthPasswdData = (void*)passwds;
rfbScreen->passwordCheck = rfbCheckPasswordByList;
- } else if (strcmp(argv[i], "-deferupdate") == 0) { /* -desktop desktop-name */
+ } else if (strcmp(argv[i], "-deferupdate") == 0) { /* -deferupdate milliseconds */
if (i + 1 >= *argc) rfbUsage();
rfbScreen->rfbDeferUpdateTime = atoi(argv[++i]);
} else if (strcmp(argv[i], "-desktop") == 0) { /* -desktop desktop-name */
@@ -85,19 +85,14 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
rfbScreen->rfbNeverShared = TRUE;
} else if (strcmp(argv[i], "-dontdisconnect") == 0) {
rfbScreen->rfbDontDisconnect = TRUE;
- } else if (strcmp(argv[i], "-width") == 0) {
- rfbScreen->width = atoi(argv[++i]);
- } else if (strcmp(argv[i], "-height") == 0) {
- rfbScreen->height = atoi(argv[++i]);
} else {
/* we just remove the processed arguments from the list */
if(i != i1)
- rfbPurgeArguments(argc,&i,i1-i,argv);
- i1++;
- i++;
+ rfbPurgeArguments(argc,&i1,i-i1,argv);
}
+ i1++;
+ i=i1;
}
- *argc -= i-i1;
}
void rfbSizeUsage()
@@ -113,7 +108,7 @@ rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[])
int i,i1;
if(!argc) return;
- for (i = i1 = 1; i < *argc-1; i++) {
+ for (i = i1 = 1; i < *argc-1;) {
if (strcmp(argv[i], "-bpp") == 0) {
*bpp = atoi(argv[++i]);
} else if (strcmp(argv[i], "-width") == 0) {
@@ -122,14 +117,12 @@ rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[])
*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;
- }
- i1++;
- i = i1-1;
+ if(i != i1)
+ if(i != i1)
+ rfbPurgeArguments(argc,&i1,i-i1,argv);
}
+ i1++;
+ i=i1;
}
- *argc -= i-i1;
}