rfbSendServerCutText(screen, selection_str, newlen);
len = newlen; if (check_sel_direction("send", "selection_send", selection_str, len)) { rfbSendServerCutText(screen, selection_str, len); }
static void selection_send(XEvent *ev) {	Atom type;	int format, slen, dlen, oldlen, newlen, toobig = 0;	static int err = 0, sent_one = 0;	char before[CHKSZ], after[CHKSZ];	unsigned long nitems = 0, bytes_after = 0;	unsigned char* data = NULL;	/*	 * remember info about our last value of PRIMARY (or CUT_BUFFER0)	 * so we can check for any changes below.	 */	oldlen = strlen(selection_str);	strncpy(before, selection_str, CHKSZ);	selection_str[0] = '\0';	slen = 0;	/* read in the current value of PRIMARY: */	do {		if (XGetWindowProperty(dpy, ev->xselection.requestor,		    ev->xselection.property, nitems/4, PROP_MAX/16, True,		    AnyPropertyType, &type, &format, &nitems, &bytes_after,		    &data) == Success) {			dlen = nitems * (format/8);			if (slen + dlen > PROP_MAX) {				/* too big */				toobig = 1;				XFree(data);				if (err) {	/* cut down on messages */					break;				} else {					err = 5;				}				rfbLog("warning: truncating large PRIMARY"				   " selection > %d bytes.\n", PROP_MAX);				break;			}			memcpy(selection_str+slen, data, dlen);			slen += dlen;			selection_str[slen] = '\0';			XFree(data);		}	} while (bytes_after > 0);	if (! toobig) {		err = 0;	} else if (err) {		err--;	}	if (! sent_one) {		/* try to force a send first time in */		oldlen = -1;		sent_one = 1;	}	/* look for changes in the new value */	newlen = strlen(selection_str);	strncpy(after, selection_str, CHKSZ);	if (oldlen == newlen && strncmp(before, after, CHKSZ) == 0) {		/* evidently no change */		return;	}	if (newlen == 0) {		/* do not bother sending a null string out */		return;	}	if (! all_clients_initialized()) {		rfbLog("selection_send: no send: uninitialized clients\n");		return; /* some clients initializing, cannot send */ 	}	/* now send it to any connected VNC clients (rfbServerCutText) */	if (!screen) {		return;	}	rfbSendServerCutText(screen, selection_str, newlen);}