/* gs_trans() - General String Translation * GSTrans convert input string, as used by *KEY, etc. * On entry: pointer to string to convert * pointer to integer to receive length * On exit: returns pointer to converted string, overwriting input string * recognises | |" || |? |! * updates len with length of converted string * length is <0 if error in string encoding */ static char *gs_trans(char *instring, unsigned int *len) { int quoted=0, escape=0; char *result, *outstring; char ch; result=outstring=instring; while (*instring == ' ') instring++; // Skip leading spaces if ((quoted = (*instring == '"'))) instring++; // String is "quoted" while (*instring) { ch = *instring++; if (ch == '"' && *instring != '"' && quoted) break; // End of "quoted" string if ((ch == (char)124 || ch == (char)221) && *instring == '!') { instring++; escape=128; ch=*instring++; } if ((ch == (char)124 || ch == (char)221)) { if (*instring == (char)124 || *instring == (char)221) { instring++; ch = (char)124; } else { if (*instring == '"' || *instring == '?' || *instring >= '@') { ch = *instring++ ^ 64; if (ch < 64 ) ch = ch & 31; else if (ch == 98) ch = 34; } } } *outstring++=ch | escape; escape=0; } *outstring=0; *len=outstring-result; if (quoted && *(instring-1) != '"') *len = -1; // Bad string return result; } /* * *SHOW - show function key definition */ static void cmd_show(char *command) { int key1, key2, len; char *string; char c; while (*command == ' ') command++; // Skip spaces if (*command == 0) { key1 = 0; key2 = HIGH_FNKEY; // All keys } else { key2=(key1=cmd_parse_dec(&command)); // Get key number if (key1 > HIGH_FNKEY) error(ERR_BADKEY); } while (*command == ' ') command++; // Skip spaces if (*command != 0) error(ERR_BADCOMMAND); for (; key1 <= key2; key1++) { #ifdef NEWKBD string=kbd_fnkeyget(key1, &len); #else string=get_fn_string(key1, &len); #endif emulate_printf("*Key %d \x22", key1); while (len--) { c=*string++; if (c&128) { emulate_printf("|!"); c=c&127; } if (c<32 || c==127) { emulate_printf("|%c",c^64); } else { if (c==34 || c==124) { emulate_printf("|%c",c); } else { emulate_printf("%c",c); } } } emulate_printf("\x22\r\n"); } }