summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordscho <dscho>2005-01-14 14:33:52 +0000
committerdscho <dscho>2005-01-14 14:33:52 +0000
commitb7dae538f671a4598390d4f074c86c7ad3fdd796 (patch)
tree5260e226c61fa24a8f83f30fc5748d58f8d2309d
parente78a41c69c0b8d32c0742c11610f1918c98f35e4 (diff)
downloadlibtdevnc-b7dae538f671a4598390d4f074c86c7ad3fdd796.tar.gz
libtdevnc-b7dae538f671a4598390d4f074c86c7ad3fdd796.zip
argc and argv may be zero (which means to ignore them)
-rw-r--r--libvncclient/vncviewer.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c
index c97b234..07465c7 100644
--- a/libvncclient/vncviewer.c
+++ b/libvncclient/vncviewer.c
@@ -188,38 +188,44 @@ static rfbBool rfbInitConnection(rfbClient* client)
rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv) {
int i,j;
- if(client->programName==0)
- client->programName=argv[0];
-
- for (i = 1; i < *argc; i++) {
- j = i;
- if (strcmp(argv[i], "-listen") == 0) {
- listenForIncomingConnections(client);
- break;
- } else if (strcmp(argv[i], "-play") == 0) {
- client->serverPort = -1;
- j++;
- } else if (i+1<*argc && strcmp(argv[i], "-encodings") == 0) {
- client->appData.encodingsString = argv[i+1];
- j+=2;
- } else {
- char* colon=strchr(argv[i],':');
-
- if(colon) {
- client->serverHost=strdup(argv[i]);
- client->serverHost[(int)(colon-argv[i])]='\0';
- client->serverPort=atoi(colon+1);
+ if(argv==0 || argc==0 || *argc==0) {
+ client->programName="";
+ client->serverHost="";
+ client->serverPort=5900;
+ } else {
+ if(client->programName==0)
+ client->programName=argv[0];
+
+ for (i = 1; i < *argc; i++) {
+ j = i;
+ if (strcmp(argv[i], "-listen") == 0) {
+ listenForIncomingConnections(client);
+ break;
+ } else if (strcmp(argv[i], "-play") == 0) {
+ client->serverPort = -1;
+ j++;
+ } else if (i+1<*argc && strcmp(argv[i], "-encodings") == 0) {
+ client->appData.encodingsString = argv[i+1];
+ j+=2;
} else {
- client->serverHost=strdup(argv[i]);
+ char* colon=strchr(argv[i],':');
+
+ if(colon) {
+ client->serverHost=strdup(argv[i]);
+ client->serverHost[(int)(colon-argv[i])]='\0';
+ client->serverPort=atoi(colon+1);
+ } else {
+ client->serverHost=strdup(argv[i]);
+ }
+ if(client->serverPort>=0 && client->serverPort<5900)
+ client->serverPort+=5900;
+ }
+ /* purge arguments */
+ if (j>i) {
+ *argc-=j-i;
+ memmove(argv+i,argv+j,(*argc-i)*sizeof(char*));
+ i--;
}
- if(client->serverPort>=0 && client->serverPort<5900)
- client->serverPort+=5900;
- }
- /* purge arguments */
- if (j>i) {
- *argc-=j-i;
- memmove(argv+i,argv+j,(*argc-i)*sizeof(char*));
- i--;
}
}