if (cp == base)  break;
do_dcs(Char *dcsbuf, size_t dcslen){	TScreen *screen = &term->screen;	char reply[BUFSIZ];	char *cp = (char *)dcsbuf;	Bool okay;	Bool clear_all;	Bool lock_keys;	TRACE(("do_dcs(%s:%d)\n", (char *)dcsbuf, dcslen));	if (dcslen != strlen(cp))		/* shouldn't have nulls in the string */		return;	switch (*cp) {		/* intermediate character, or parameter */	case '$':		/* DECRQSS */		okay = True;		cp++;		if (*cp++ == 'q') {			if (!strcmp(cp, "\"q")) {		/* DECSCA */				sprintf(reply, "%d%s",					(screen->protected_mode == DEC_PROTECT)					 && (term->flags & PROTECTED) ? 1 : 0,					cp);			} else if (!strcmp(cp, "\"p")) {	/* DECSCL */				sprintf(reply, "%d%s%s",					(screen->ansi_level ?					 screen->ansi_level : 1) + 60,					(screen->ansi_level >= 2)					 ? (screen->control_eight_bits						? ";0" : ";1")					 : "",					cp);			} else if (!strcmp(cp, "r")) {		/* DECSTBM */				sprintf(reply, "%d;%dr",					screen->top_marg + 1,					screen->bot_marg + 1);			} else if (!strcmp(cp, "m")) {		/* SGR */				strcpy(reply, "0");				if (term->flags & BOLD)					strcat(reply, ";1");				if (term->flags & UNDERLINE)					strcat(reply, ";4");				if (term->flags & BLINK)					strcat(reply, ";5");				if (term->flags & INVERSE)					strcat(reply, ";7");				if (term->flags & INVISIBLE)					strcat(reply, ";8");				if_OPT_EXT_COLORS(screen,{				if (term->flags & FG_COLOR) {					if (term->cur_foreground >= 16)						sprintf(reply+strlen(reply),							";38;5;%d", term->cur_foreground);					else						sprintf(reply+strlen(reply),							";%d%d",							term->cur_foreground >= 8 ? 9 : 3,							term->cur_foreground >= 8 ?							term->cur_foreground - 8 :							term->cur_foreground);				}				if (term->flags & BG_COLOR) {					if (term->cur_background >= 16)						sprintf(reply+strlen(reply),							";48;5;%d", term->cur_foreground);					else						sprintf(reply+strlen(reply),							";%d%d",							term->cur_background >= 8 ? 10 : 4,							term->cur_background >= 8 ?							term->cur_background - 8 :							term->cur_background);				}				})				if_OPT_ISO_TRADITIONAL_COLORS(screen,{				if (term->flags & FG_COLOR)					sprintf(reply+strlen(reply),						";%d%d",						term->cur_foreground >= 8 ? 9 : 3,						term->cur_foreground >= 8 ?						term->cur_foreground - 8 :						term->cur_foreground);				if (term->flags & BG_COLOR)					sprintf(reply+strlen(reply),						";%d%d",						term->cur_background >= 8 ? 10 : 4,						term->cur_background >= 8 ?						term->cur_background - 8 :						term->cur_background);				})				strcat(reply, "m");			} else				okay = False;			unparseputc1(DCS, screen->respond);			unparseputc(okay ? '1' : '0', screen->respond);			unparseputc('$', screen->respond);			unparseputc('r', screen->respond);			if (okay)				cp = reply;			unparseputs(cp, screen->respond);			unparseputc1(ST, screen->respond);		} else {			unparseputc(CAN, screen->respond);		}		break;#if OPT_TCAP_QUERY	case '+':		cp++;		if (*cp == 'q') {			unsigned state;			int code;			char *tmp;			++cp;			code = xtermcapKeycode(cp, &state);			unparseputc1(DCS, screen->respond);			unparseputc(code >= 0 ? '1' : '0', screen->respond);			unparseputc('+', screen->respond);			unparseputc('r', screen->respond);			for (tmp = cp; *tmp; ++tmp)				unparseputc(*tmp, screen->respond);			if (code >= 0) {				unparseputc('=', screen->respond);				screen->tc_query = code;				/* XK_COLORS is a fake code for the "Co" entry (maximum				 * number of colors) */				if (code == XK_COLORS) {# if OPT_256_COLORS					unparseputc('2', screen->respond);					unparseputc('5', screen->respond);					unparseputc('6', screen->respond);# elif OPT_88_COLORS					unparseputc('8', screen->respond);					unparseputc('8', screen->respond);# else					unparseputc('1', screen->respond);					unparseputc('6', screen->respond);# endif				}				else {					XKeyEvent event;					event.state = state;					Input(&(term->keyboard), screen, &event, False);				}				screen->tc_query = -1;			}			unparseputc1(ST, screen->respond);		}		break;#endif	default:		if (isdigit(CharOf(*cp))) { /* digits are DECUDK, otherwise ignore */			clear_all = True;			lock_keys = True;			if (*cp == '0') {				cp++;			} else if (*cp == '1') {				cp++;				clear_all = False;			}			if (*cp == ';')				cp++;			else if (*cp != '|')				return;			if (*cp == '0') {				cp++;			} else if (*cp == '1') {				cp++;				lock_keys = False;			}			if (*cp++ != '|')				return;			if (clear_all)				reset_decudk();			while (*cp) {				char *str = (char *)malloc(strlen(cp) + 2);				unsigned key = 0;				int len = 0;				while (isdigit(CharOf(*cp)))					key = (key * 10) + (*cp++ - '0');				if (*cp == '/') {					cp++;					while (*cp != ';' && *cp != '\0') {						int hi = hexvalue(*cp++);						int lo = hexvalue(*cp++);						if (hi < 0 || lo < 0)							return;						str[len++] = (hi << 4) | lo;					}				}				if (len > 0 && key < MAX_UDK) {					if (user_keys[key].str != 0)						free(user_keys[key].str);					user_keys[key].str = str;					user_keys[key].len = len;				} else {					free(str);				}				if (*cp == ';')					cp++;			}		}		break;	}}