version 1.45, 2012/10/26 14:35:42 |
version 1.46, 2012/11/22 14:26:04 |
|
|
int |
int |
tty_keys_device(struct tty *tty, const char *buf, size_t len, size_t *size) |
tty_keys_device(struct tty *tty, const char *buf, size_t len, size_t *size) |
{ |
{ |
u_int i, a, b; |
u_int i, n; |
char tmp[64], *endptr; |
char tmp[64], *endptr; |
|
|
/* |
/* |
* Primary device attributes are \033[?a;b and secondary are |
* Primary device attributes are \033[?a;b and secondary are |
* \033[>a;b;c. We only request attributes on xterm, so we only care |
* \033[>a;b;c. |
* about the middle values which is the xterm version. |
|
*/ |
*/ |
|
|
*size = 0; |
*size = 0; |
|
|
/* First three bytes are always \033[>. */ |
/* First three bytes are always \033[?. */ |
if (buf[0] != '\033') |
if (buf[0] != '\033') |
return (-1); |
return (-1); |
if (len == 1) |
if (len == 1) |
|
|
tmp[i] = '\0'; |
tmp[i] = '\0'; |
*size = 4 + i; |
*size = 4 + i; |
|
|
/* Only secondary is of interest. */ |
/* Only primary is of interest. */ |
if (buf[2] != '>') |
if (buf[2] != '?') |
return (0); |
return (0); |
|
|
/* Convert version numbers. */ |
/* Convert service class. */ |
a = strtoul(tmp, &endptr, 10); |
n = strtoul(tmp, &endptr, 10); |
if (*endptr == ';') { |
if (*endptr != ';') |
b = strtoul(endptr + 1, &endptr, 10); |
n = 0; |
if (*endptr != '\0' && *endptr != ';') |
|
b = 0; |
|
} else |
|
a = b = 0; |
|
|
|
log_debug("received xterm version %u", b); |
log_debug("received service class %u", n); |
if (b < 500) |
tty->service_class = n; |
tty_set_version(tty, b); |
|
|
|
return (0); |
return (0); |
} |
} |