if (pwlast || !strcmp("-passwd", argv[i]) || !strcmp("-viewpasswd", argv[i])) { char *p = argv[i]; if (pwlast) { pwlast = 0; } else { pwlast = 1; } while (*p != '\0') *p++ = '\0'; }
static void check_rcfile(int argc, char **argv) {	int i, norc = 0, argmax = 1024;	char *infile = NULL;	char rcfile[1024];	FILE *rc; 	for (i=1; i < argc; i++) {		if (!strcmp(argv[i], "-norc")) {			norc = 1;		}		if (!strcmp(argv[i], "-rc")) {			if (i+1 >= argc) {				fprintf(stderr, "-rc option requires a "				    "filename\n");				exit(1);			} else {				infile = argv[i+1];			}		}	}	if (norc) {		;	} else if (infile != NULL) {		rc = fopen(infile, "r");		if (rc == NULL) {			fprintf(stderr, "could not open rcfile: %s\n", infile);			perror("fopen");			exit(1);		}	} else if (getenv("HOME") == NULL) {		norc = 1;	} else {		strncpy(rcfile, getenv("HOME"), 500);		strcat(rcfile, "/.x11vncrc");		infile = rcfile;		rc = fopen(rcfile, "r");		if (rc == NULL) {			norc = 1;		}	}	argv2 = (char **) malloc(argmax * sizeof(char *));	argv2[argc2++] = strdup(argv[0]);	if (! norc) {		char line[4096], parm[100], tmp[101];		char *buf;		struct stat sbuf;		int sz;		if (fstat(fileno(rc), &sbuf) != 0) {			fprintf(stderr, "problem with %s\n", infile);			perror("fstat");			exit(1);		}		sz = sbuf.st_size+1;		if (sz < 1024) {			sz = 1024;		}		buf  = (char *) malloc(sz);		while (fgets(line, 4096, rc) != NULL) {			char *q, *p = line;			char c = '\0';			int cont = 0;			q = p;			while (*q) {				if (*q == '\n') {					if (c == '\\') {						cont = 1;						*q = '\0';						*(q-1) = ' ';						break;					}					while (isspace(*q)) {						*q = '\0';						if (q == p) {							break;						}						q--;					}					break;				}				c = *q;				q++;			}			if ( (q = strchr(p, '#')) != NULL) {				*q = '\0';			}			while (*p) {				if (! isspace(*p)) {					break;				}				p++;			}			strncat(buf, p, sz - strlen(buf) - 1);			if (cont) {				continue;			}			if (buf[0] == '\0') {				continue;			}			if (sscanf(buf, "%s", parm) != 1) {				fprintf(stderr, "invalid rcfile line: %s\n", p);				exit(1);			}			if (parm[0] == '-') {				strncpy(tmp, parm, 100); 			} else {				tmp[0] = '-';				strncpy(tmp+1, parm, 100); 			}			argv2[argc2++] = strdup(tmp);			if (argc2 >= argmax) {				fprintf(stderr, "too many rcfile options\n");				exit(1);			}						p = buf;			p += strlen(parm);			while (*p) {				if (! isspace(*p)) {					break;				}				p++;			}			if (*p == '\0') {				buf[0] = '\0';				continue;			}			argv2[argc2++] = strdup(p);			if (argc2 >= argmax) {				fprintf(stderr, "too many rcfile options\n");				exit(1);			}			buf[0] = '\0';		}		fclose(rc);		free(buf);	}	for (i=1; i < argc; i++) {		argv2[argc2++] = strdup(argv[i]);		if (argc2 >= argmax) {			fprintf(stderr, "too many rcfile options\n");			exit(1);		}	}}