fprintf(stderr, "sending remote command: \"%s\"\nvia connect" " file: %s\n", cmd, client_connect_file);
fprintf(stderr, ">>> sending remote command: \"%s\"\n  via" " connect file: %s\n", cmd, client_connect_file);
int send_remote_cmd(char *cmd, int query, int wait) {	FILE *in = NULL;	if (client_connect_file) {		in = fopen(client_connect_file, "w");		if (in == NULL) {			fprintf(stderr, "send_remote_cmd: could not open "			    "connect file \"%s\" for writing\n",			    client_connect_file);			perror("fopen");			return 1;		}	} else if (vnc_connect_prop == None) {		initialize_vnc_connect_prop();		if (vnc_connect_prop == None) {			fprintf(stderr, "send_remote_cmd: could not obtain "			    "VNC_CONNECT X property\n");			return 1;		}	}	if (in != NULL) {		fprintf(stderr, "sending remote command: \"%s\"\nvia connect"		    " file: %s\n", cmd, client_connect_file);		fprintf(in, "%s\n", cmd);		fclose(in);	} else {		fprintf(stderr, "sending remote command: \"%s\" via VNC_CONNECT"		    " X property.\n", cmd);		set_vnc_connect_prop(cmd);		XFlush(dpy);	}	if (query || wait) {		char line[VNC_CONNECT_MAX];			int rc=1, i=0, max=70, ms_sl=50;		if (!strcmp(cmd, "cmd=stop")) {			max = 20;		}		for (i=0; i<max; i++) {			usleep(ms_sl * 1000);			if (client_connect_file) {				char *q;				in = fopen(client_connect_file, "r");				if (in == NULL) {					fprintf(stderr, "send_remote_cmd: could"					    " not open connect file \"%s\" for"					    " writing\n", client_connect_file);					perror("fopen");					return 1;				}				fgets(line, VNC_CONNECT_MAX, in);				fclose(in);				q = line;				while (*q != '\0') {					if (*q == '\n') *q = '\0';					q++;				}			} else {				read_vnc_connect_prop();				strncpy(line, vnc_connect_str, VNC_CONNECT_MAX);			}			if (strcmp(cmd, line)){				if (query) {					fprintf(stdout, "%s\n", line);					fflush(stdout);				}				rc = 0;				break;			}		}		if (rc) {			fprintf(stderr, "error: could not connect to "			    "an x11vnc server at %s  (rc=%d)\n",			    client_connect_file ? client_connect_file			    : DisplayString(dpy), rc);		}		return rc;	}	return 0;}