version 1.29, 2014/07/22 07:30:24 |
version 1.30, 2014/09/09 03:41:08 |
|
|
static void slc(unsigned char *, int); |
static void slc(unsigned char *, int); |
static int slc_update(void); |
static int slc_update(void); |
|
|
static void env_opt(unsigned char *, int); |
static void env_opt(char *, int); |
static void env_opt_start(void); |
static void env_opt_start(void); |
|
|
char options[256]; /* The combined options */ |
char options[256]; /* The combined options */ |
|
|
env_init(); |
env_init(); |
|
|
SB_CLEAR(); |
SB_CLEAR(); |
memset((char *)options, 0, sizeof options); |
memset(options, 0, sizeof options); |
|
|
connected = ISend = localflow = donebinarytoggle = 0; |
connected = ISend = localflow = donebinarytoggle = 0; |
restartany = -1; |
restartany = -1; |
|
|
break; |
break; |
|
|
case TELOPT_XDISPLOC: /* X Display location */ |
case TELOPT_XDISPLOC: /* X Display location */ |
if (env_getvalue((unsigned char *)"DISPLAY", 0)) |
if (env_getvalue("DISPLAY", 0)) |
new_state_ok = 1; |
new_state_ok = 1; |
break; |
break; |
|
|
|
|
char c, *cp, **argvp, *cp2, **argv, **avt; |
char c, *cp, **argvp, *cp2, **argv, **avt; |
|
|
if (name) { |
if (name) { |
if ((int)strlen(name) > 40) { |
if (strlen(name) > 40) { |
name = NULL; |
name = NULL; |
unknown[0] = name_unknown; |
unknown[0] = name_unknown; |
} else { |
} else { |
|
|
/* |
/* |
* Allocate an array to put the name pointers into |
* Allocate an array to put the name pointers into |
*/ |
*/ |
argv = (char **)malloc((n+3)*sizeof(char *)); |
argv = reallocarray(NULL, n+3, sizeof(char *)); |
if (argv == NULL) |
if (argv == NULL) |
return(unknown); |
return(unknown); |
|
|
|
|
resettermname = 0; |
resettermname = 0; |
if (tnamep && tnamep != unknown) |
if (tnamep && tnamep != unknown) |
free(tnamep); |
free(tnamep); |
if ((tname = (char *)env_getvalue((unsigned char *)"TERM", 0)) && |
if ((tname = env_getvalue("TERM", 0)) && |
(setupterm(tname, 1, &errret) == OK)) { |
(setupterm(tname, 1, &errret) == OK)) { |
tnamep = mklist(ttytype, tname); |
tnamep = mklist(ttytype, tname); |
} else { |
} else { |
if (tname && ((int)strlen(tname) <= 40)) { |
if (tname && (strlen(tname) <= 40)) { |
unknown[0] = tname; |
unknown[0] = tname; |
upcase(tname); |
upcase(tname); |
} else |
} else |
|
|
unsigned char temp[50], *dp; |
unsigned char temp[50], *dp; |
int len; |
int len; |
|
|
if ((dp = env_getvalue((unsigned char *)"DISPLAY", 0)) == NULL) { |
if ((dp = env_getvalue("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. |
|
|
} |
} |
|
|
static void |
static void |
env_opt(unsigned char *buf, int len) |
env_opt(char *buf, int len) |
{ |
{ |
unsigned char *ep = 0, *epc = 0; |
char *ep = 0, *epc = 0; |
int i; |
int i; |
|
|
switch(buf[0]&0xff) { |
switch(buf[0]&0xff) { |
|
|
{ |
{ |
unsigned char *p; |
unsigned char *p; |
|
|
p = (unsigned char *)realloc(opt_reply, OPT_REPLY_SIZE); |
p = realloc(opt_reply, OPT_REPLY_SIZE); |
if (p == NULL) |
if (p == NULL) |
free(opt_reply); |
free(opt_reply); |
opt_reply = p; |
opt_reply = p; |
|
|
} |
} |
|
|
void |
void |
env_opt_add(unsigned char *ep) |
env_opt_add(char *ep) |
{ |
{ |
unsigned char *vp, c; |
char *vp, c; |
|
|
if (opt_reply == NULL) /*XXX*/ |
if (opt_reply == NULL) /*XXX*/ |
return; /*XXX*/ |
return; /*XXX*/ |
|
|
return; |
return; |
} |
} |
vp = env_getvalue(ep, 1); |
vp = env_getvalue(ep, 1); |
if (opt_replyp + 2 * (vp ? strlen((char *)vp) : 0) + |
if (2 * (vp ? strlen(vp) : 0) + 2 * strlen(ep) + 6 > |
2 * strlen((char *)ep) + 6 > opt_replyend) |
opt_replyend - opt_replyp) |
{ |
{ |
size_t len; |
size_t len; |
unsigned char *p; |
unsigned char *p; |
|
|
len += OPT_REPLY_SIZE + 2 * strlen(ep); |
len += OPT_REPLY_SIZE + 2 * strlen(ep); |
if (vp) |
if (vp) |
len += 2 * strlen(vp); |
len += 2 * strlen(vp); |
p = (unsigned char *)realloc(opt_reply, len); |
p = realloc(opt_reply, len); |
if (p == NULL) { |
if (p == NULL) { |
free(opt_reply); |
free(opt_reply); |
/*@*/ printf("env_opt_add: realloc() failed!!!\n"); |
/*@*/ printf("env_opt_add: realloc() failed!!!\n"); |
|
|
opt_replyend = p + len; |
opt_replyend = p + len; |
opt_reply = p; |
opt_reply = p; |
} |
} |
if (opt_welldefined((char *)ep)) |
if (opt_welldefined(ep)) |
opt_add(NEW_ENV_VAR); |
opt_add(NEW_ENV_VAR); |
else |
else |
opt_add(ENV_USERVAR); |
opt_add(ENV_USERVAR); |
|
|
|
|
} |
} |
|
|
int |
int |
opt_welldefined(char *ep) |
opt_welldefined(const char *ep) |
{ |
{ |
if ((strcmp(ep, "USER") == 0) || |
if ((strcmp(ep, "USER") == 0) || |
(strcmp(ep, "DISPLAY") == 0) || |
(strcmp(ep, "DISPLAY") == 0) || |
|
|
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", 0)) |
if (env_getvalue("DISPLAY", 0)) |
send_will(TELOPT_XDISPLOC, 1); |
send_will(TELOPT_XDISPLOC, 1); |
if (binary) |
if (binary) |
tel_enter_binary(binary); |
tel_enter_binary(binary); |