version 1.18, 2003/11/08 19:17:29 |
version 1.18.2.1, 2005/03/29 20:20:10 |
|
|
#endif |
#endif |
|
|
case TELOPT_XDISPLOC: /* X Display location */ |
case TELOPT_XDISPLOC: /* X Display location */ |
if (env_getvalue((unsigned char *)"DISPLAY")) |
if (env_getvalue((unsigned char *)"DISPLAY", 0)) |
new_state_ok = 1; |
new_state_ok = 1; |
break; |
break; |
|
|
|
|
resettermname = 0; |
resettermname = 0; |
if (tnamep && tnamep != unknown) |
if (tnamep && tnamep != unknown) |
free(tnamep); |
free(tnamep); |
if ((tname = (char *)env_getvalue((unsigned char *)"TERM")) && |
if ((tname = (char *)env_getvalue((unsigned char *)"TERM", 0)) && |
(setupterm(tname, 1, &errret) == OK)) { |
(setupterm(tname, 1, &errret) == OK)) { |
tnamep = mklist(ttytype, tname); |
tnamep = mklist(ttytype, tname); |
} else { |
} else { |
|
|
unsigned char temp[50], *dp; |
unsigned char temp[50], *dp; |
int len; |
int len; |
|
|
if ((dp = env_getvalue((unsigned char *)"DISPLAY")) == NULL) { |
if ((dp = env_getvalue((unsigned char *)"DISPLAY", 0)) == NULL) { |
/* |
/* |
* Something happened, we no longer have a DISPLAY |
* Something happened, we no longer have a DISPLAY |
* variable. So, turn off the option. |
* variable. So, turn off the option. |
|
|
} |
} |
|
|
|
|
unsigned char slc_reply[128]; |
static unsigned char slc_reply[2 * SUBBUFSIZE]; |
unsigned char *slc_replyp; |
static unsigned char *slc_replyp; |
|
|
|
unsigned char |
|
slc_add(unsigned char ch) |
|
{ |
|
if (slc_replyp == slc_reply + sizeof(slc_reply)) |
|
return ch; |
|
return *slc_replyp++ = ch; |
|
} |
|
|
void |
void |
slc_start_reply() |
slc_start_reply() |
{ |
{ |
slc_replyp = slc_reply; |
slc_replyp = slc_reply; |
*slc_replyp++ = IAC; |
slc_add(IAC); |
*slc_replyp++ = SB; |
slc_add(SB); |
*slc_replyp++ = TELOPT_LINEMODE; |
slc_add(TELOPT_LINEMODE); |
*slc_replyp++ = LM_SLC; |
slc_add(LM_SLC); |
} |
} |
|
|
void |
void |
|
|
unsigned char flags; |
unsigned char flags; |
cc_t value; |
cc_t value; |
{ |
{ |
if ((*slc_replyp++ = func) == IAC) |
if (slc_replyp + 6 >= slc_reply + sizeof(slc_reply)) { |
*slc_replyp++ = IAC; |
printf("slc_add_reply: not enough room\n"); |
if ((*slc_replyp++ = flags) == IAC) |
return; |
*slc_replyp++ = IAC; |
} |
if ((*slc_replyp++ = (unsigned char)value) == IAC) |
if (slc_add(func) == IAC) |
*slc_replyp++ = IAC; |
slc_add(IAC); |
|
if (slc_add(flags) == IAC) |
|
slc_add(IAC); |
|
if (slc_add((unsigned char)value) == IAC) |
|
slc_add(IAC); |
} |
} |
|
|
void |
void |
|
|
{ |
{ |
int len; |
int len; |
|
|
*slc_replyp++ = IAC; |
if (slc_replyp + 2 >= slc_reply + sizeof(slc_reply)) { |
*slc_replyp++ = SE; |
printf("slc_end_reply: not enough room\n"); |
|
return; |
|
} |
|
|
|
slc_add(IAC); |
|
slc_add(SE); |
len = slc_replyp - slc_reply; |
len = slc_replyp - slc_reply; |
if (len <= 6) |
if (len <= 6) |
return; |
return; |
|
|
} |
} |
} |
} |
|
|
#define OPT_REPLY_SIZE 256 |
#define OPT_REPLY_SIZE (2 * SUBBUFSIZE) |
unsigned char *opt_reply; |
static unsigned char *opt_reply; |
unsigned char *opt_replyp; |
static unsigned char *opt_replyp; |
unsigned char *opt_replyend; |
static unsigned char *opt_replyend; |
|
|
void |
void |
|
opt_add(unsigned char ch) |
|
{ |
|
if (opt_replyp == opt_replyend) |
|
return; |
|
*opt_replyp++ = ch; |
|
} |
|
void |
env_opt_start() |
env_opt_start() |
{ |
{ |
unsigned char *p; |
unsigned char *p; |
|
|
} |
} |
opt_replyp = opt_reply; |
opt_replyp = opt_reply; |
opt_replyend = opt_reply + OPT_REPLY_SIZE; |
opt_replyend = opt_reply + OPT_REPLY_SIZE; |
*opt_replyp++ = IAC; |
opt_add(IAC); |
*opt_replyp++ = SB; |
opt_add(SB); |
*opt_replyp++ = telopt_environ; |
opt_add(telopt_environ); |
*opt_replyp++ = TELQUAL_IS; |
opt_add(TELQUAL_IS); |
} |
} |
|
|
void |
void |
|
|
env_opt_add(ep); |
env_opt_add(ep); |
return; |
return; |
} |
} |
vp = env_getvalue(ep); |
vp = env_getvalue(ep, 1); |
if (opt_replyp + (vp ? strlen((char *)vp) : 0) + |
if (opt_replyp + 2 * (vp ? strlen((char *)vp) : 0) + |
strlen((char *)ep) + 6 > opt_replyend) |
2 * strlen((char *)ep) + 6 > opt_replyend) |
{ |
{ |
int len; |
size_t len; |
unsigned char *p; |
unsigned char *p; |
opt_replyend += OPT_REPLY_SIZE; |
|
len = opt_replyend - opt_reply; |
len = opt_replyend - opt_reply; |
|
len += OPT_REPLY_SIZE + 2 * strlen(ep); |
|
if (vp) |
|
len += 2 * strlen(vp); |
p = (unsigned char *)realloc(opt_reply, len); |
p = (unsigned char *)realloc(opt_reply, len); |
if (p == NULL) |
if (p == NULL) { |
free(opt_reply); |
free(opt_reply); |
opt_reply = p; |
|
if (opt_reply == NULL) { |
|
/*@*/ printf("env_opt_add: realloc() failed!!!\n"); |
/*@*/ printf("env_opt_add: realloc() failed!!!\n"); |
opt_reply = opt_replyp = opt_replyend = NULL; |
opt_reply = opt_replyp = opt_replyend = NULL; |
return; |
return; |
} |
} |
opt_replyp = opt_reply + len - (opt_replyend - opt_replyp); |
opt_replyp = p + (opt_replyp - opt_reply); |
opt_replyend = opt_reply + len; |
opt_replyend = p + len; |
|
opt_reply = p; |
} |
} |
if (opt_welldefined((char *)ep)) |
if (opt_welldefined((char *)ep)) |
#ifdef OLD_ENVIRON |
#ifdef OLD_ENVIRON |
if (telopt_environ == TELOPT_OLD_ENVIRON) |
if (telopt_environ == TELOPT_OLD_ENVIRON) |
*opt_replyp++ = old_env_var; |
opt_add(old_env_var); |
else |
else |
#endif |
#endif |
*opt_replyp++ = NEW_ENV_VAR; |
opt_add(NEW_ENV_VAR); |
else |
else |
*opt_replyp++ = ENV_USERVAR; |
opt_add(ENV_USERVAR); |
|
|
for (;;) { |
for (;;) { |
while ((c = *ep++)) { |
while ((c = *ep++)) { |
switch(c&0xff) { |
switch(c&0xff) { |
case IAC: |
case IAC: |
*opt_replyp++ = IAC; |
opt_add(IAC); |
break; |
break; |
case NEW_ENV_VAR: |
case NEW_ENV_VAR: |
case NEW_ENV_VALUE: |
case NEW_ENV_VALUE: |
case ENV_ESC: |
case ENV_ESC: |
case ENV_USERVAR: |
case ENV_USERVAR: |
*opt_replyp++ = ENV_ESC; |
opt_add(ENV_ESC); |
break; |
break; |
} |
} |
*opt_replyp++ = c; |
opt_add(c); |
} |
} |
if ((ep = vp)) { |
if ((ep = vp)) { |
#ifdef OLD_ENVIRON |
#ifdef OLD_ENVIRON |
if (telopt_environ == TELOPT_OLD_ENVIRON) |
if (telopt_environ == TELOPT_OLD_ENVIRON) |
*opt_replyp++ = old_env_value; |
opt_add(old_env_value); |
else |
else |
#endif |
#endif |
*opt_replyp++ = NEW_ENV_VALUE; |
opt_add(NEW_ENV_VALUE); |
vp = NULL; |
vp = NULL; |
} else |
} else |
break; |
break; |
|
|
|
|
len = opt_replyp - opt_reply + 2; |
len = opt_replyp - opt_reply + 2; |
if (emptyok || len > 6) { |
if (emptyok || len > 6) { |
*opt_replyp++ = IAC; |
opt_add(IAC); |
*opt_replyp++ = SE; |
opt_add(SE); |
if (NETROOM() > len) { |
if (NETROOM() > len) { |
ring_supply_data(&netoring, opt_reply, len); |
ring_supply_data(&netoring, opt_reply, len); |
printsub('>', &opt_reply[2], len - 2); |
printsub('>', &opt_reply[2], len - 2); |
|
|
send_will(TELOPT_LINEMODE, 1); |
send_will(TELOPT_LINEMODE, 1); |
send_will(TELOPT_NEW_ENVIRON, 1); |
send_will(TELOPT_NEW_ENVIRON, 1); |
send_do(TELOPT_STATUS, 1); |
send_do(TELOPT_STATUS, 1); |
if (env_getvalue((unsigned char *)"DISPLAY")) |
if (env_getvalue((unsigned char *)"DISPLAY", 0)) |
send_will(TELOPT_XDISPLOC, 1); |
send_will(TELOPT_XDISPLOC, 1); |
if (binary) |
if (binary) |
tel_enter_binary(binary); |
tel_enter_binary(binary); |