mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Prefix defines and symbols with CURL_ to reduce the risk of colliding with
various system's other defines.
This commit is contained in:
parent
073448e0ea
commit
be8f6c7f5c
@ -26,15 +26,15 @@
|
|||||||
/*
|
/*
|
||||||
* Telnet option defines. Add more here if in need.
|
* Telnet option defines. Add more here if in need.
|
||||||
*/
|
*/
|
||||||
#define TELOPT_BINARY 0 /* binary 8bit data */
|
#define CURL_TELOPT_BINARY 0 /* binary 8bit data */
|
||||||
#define TELOPT_SGA 3 /* Supress Go Ahead */
|
#define CURL_TELOPT_SGA 3 /* Supress Go Ahead */
|
||||||
#define TELOPT_EXOPL 255 /* EXtended OPtions List */
|
#define CURL_TELOPT_EXOPL 255 /* EXtended OPtions List */
|
||||||
#define TELOPT_TTYPE 24 /* Terminal TYPE */
|
#define CURL_TELOPT_TTYPE 24 /* Terminal TYPE */
|
||||||
#define TELOPT_XDISPLOC 35 /* X DISPlay LOCation */
|
#define CURL_TELOPT_XDISPLOC 35 /* X DISPlay LOCation */
|
||||||
|
|
||||||
#define TELOPT_NEW_ENVIRON 39 /* NEW ENVIRONment variables */
|
#define CURL_TELOPT_NEW_ENVIRON 39 /* NEW ENVIRONment variables */
|
||||||
#define NEW_ENV_VAR 0
|
#define CURL_NEW_ENV_VAR 0
|
||||||
#define NEW_ENV_VALUE 1
|
#define CURL_NEW_ENV_VALUE 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The telnet options represented as strings
|
* The telnet options represented as strings
|
||||||
@ -53,27 +53,27 @@ static const char *telnetoptions[]=
|
|||||||
"OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON"
|
"OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON"
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TELOPT_MAXIMUM TELOPT_NEW_ENVIRON
|
#define CURL_TELOPT_MAXIMUM CURL_TELOPT_NEW_ENVIRON
|
||||||
|
|
||||||
#define TELOPT_OK(x) ((x) <= TELOPT_MAXIMUM)
|
#define CURL_TELOPT_OK(x) ((x) <= CURL_TELOPT_MAXIMUM)
|
||||||
#define TELOPT(x) telnetoptions[x]
|
#define CURL_TELOPT(x) telnetoptions[x]
|
||||||
|
|
||||||
#define NTELOPTS 40
|
#define CURL_NTELOPTS 40
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First some defines
|
* First some defines
|
||||||
*/
|
*/
|
||||||
#define xEOF 236 /* End Of File */
|
#define CURL_xEOF 236 /* End Of File */
|
||||||
#define SE 240 /* Sub negotiation End */
|
#define CURL_SE 240 /* Sub negotiation End */
|
||||||
#define NOP 241 /* No OPeration */
|
#define CURL_NOP 241 /* No OPeration */
|
||||||
#define DM 242 /* Data Mark */
|
#define CURL_DM 242 /* Data Mark */
|
||||||
#define GA 249 /* Go Ahead, reverse the line */
|
#define CURL_GA 249 /* Go Ahead, reverse the line */
|
||||||
#define SB 250 /* SuBnegotiation */
|
#define CURL_SB 250 /* SuBnegotiation */
|
||||||
#define WILL 251 /* Our side WILL use this option */
|
#define CURL_WILL 251 /* Our side WILL use this option */
|
||||||
#define WONT 252 /* Our side WON'T use this option */
|
#define CURL_WONT 252 /* Our side WON'T use this option */
|
||||||
#define DO 253 /* DO use this option! */
|
#define CURL_DO 253 /* DO use this option! */
|
||||||
#define DONT 254 /* DON'T use this option! */
|
#define CURL_DONT 254 /* DON'T use this option! */
|
||||||
#define IAC 255 /* Interpret As Command */
|
#define CURL_IAC 255 /* Interpret As Command */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Then those numbers represented as strings:
|
* Then those numbers represented as strings:
|
||||||
@ -86,16 +86,16 @@ static const char *telnetcmds[]=
|
|||||||
"WILL", "WONT", "DO", "DONT", "IAC"
|
"WILL", "WONT", "DO", "DONT", "IAC"
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TELCMD_MINIMUM xEOF /* the first one */
|
#define CURL_TELCMD_MINIMUM CURL_xEOF /* the first one */
|
||||||
#define TELCMD_MAXIMUM IAC /* surprise, 255 is the last one! ;-) */
|
#define CURL_TELCMD_MAXIMUM CURL_IAC /* surprise, 255 is the last one! ;-) */
|
||||||
|
|
||||||
#define TELQUAL_IS 0
|
#define CURL_TELQUAL_IS 0
|
||||||
#define TELQUAL_SEND 1
|
#define CURL_TELQUAL_SEND 1
|
||||||
#define TELQUAL_INFO 2
|
#define CURL_TELQUAL_INFO 2
|
||||||
#define TELQUAL_NAME 3
|
#define CURL_TELQUAL_NAME 3
|
||||||
|
|
||||||
#define TELCMD_OK(x) ( ((unsigned int)(x) >= TELCMD_MINIMUM) && \
|
#define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
|
||||||
((unsigned int)(x) <= TELCMD_MAXIMUM) )
|
((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) )
|
||||||
#define TELCMD(x) telnetcmds[(x)-TELCMD_MINIMUM]
|
#define CURL_TELCMD(x) telnetcmds[(x)-CURL_TELCMD_MINIMUM]
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
550
lib/telnet.c
550
lib/telnet.c
@ -90,16 +90,17 @@
|
|||||||
|
|
||||||
#define SUBBUFSIZE 512
|
#define SUBBUFSIZE 512
|
||||||
|
|
||||||
#define SB_CLEAR(x) x->subpointer = x->subbuffer;
|
#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer;
|
||||||
#define SB_TERM(x) { x->subend = x->subpointer; SB_CLEAR(x); }
|
#define CURL_SB_TERM(x) { x->subend = x->subpointer; CURL_SB_CLEAR(x); }
|
||||||
#define SB_ACCUM(x,c) if (x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
|
#define CURL_SB_ACCUM(x,c) \
|
||||||
*x->subpointer++ = (c); \
|
if (x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
|
||||||
}
|
*x->subpointer++ = (c); \
|
||||||
|
}
|
||||||
|
|
||||||
#define SB_GET(x) ((*x->subpointer++)&0xff)
|
#define CURL_SB_GET(x) ((*x->subpointer++)&0xff)
|
||||||
#define SB_PEEK(x) ((*x->subpointer)&0xff)
|
#define CURL_SB_PEEK(x) ((*x->subpointer)&0xff)
|
||||||
#define SB_EOF(x) (x->subpointer >= x->subend)
|
#define CURL_SB_EOF(x) (x->subpointer >= x->subend)
|
||||||
#define SB_LEN(x) (x->subend - x->subpointer)
|
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
|
||||||
|
|
||||||
static
|
static
|
||||||
void telrcv(struct connectdata *,
|
void telrcv(struct connectdata *,
|
||||||
@ -120,28 +121,28 @@ static void printsub(struct SessionHandle *data,
|
|||||||
static void suboption(struct connectdata *);
|
static void suboption(struct connectdata *);
|
||||||
|
|
||||||
/* For negotiation compliant to RFC 1143 */
|
/* For negotiation compliant to RFC 1143 */
|
||||||
#define NO 0
|
#define CURL_NO 0
|
||||||
#define YES 1
|
#define CURL_YES 1
|
||||||
#define WANTYES 2
|
#define CURL_WANTYES 2
|
||||||
#define WANTNO 3
|
#define CURL_WANTNO 3
|
||||||
|
|
||||||
#define EMPTY 0
|
#define CURL_EMPTY 0
|
||||||
#define OPPOSITE 1
|
#define CURL_OPPOSITE 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Telnet receiver states for fsm
|
* Telnet receiver states for fsm
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
TS_DATA = 0,
|
CURL_TS_DATA = 0,
|
||||||
TS_IAC,
|
CURL_TS_IAC,
|
||||||
TS_WILL,
|
CURL_TS_WILL,
|
||||||
TS_WONT,
|
CURL_TS_WONT,
|
||||||
TS_DO,
|
CURL_TS_DO,
|
||||||
TS_DONT,
|
CURL_TS_DONT,
|
||||||
TS_CR,
|
CURL_TS_CR,
|
||||||
TS_SB, /* sub-option collection */
|
CURL_TS_SB, /* sub-option collection */
|
||||||
TS_SE /* looking for sub-option end */
|
CURL_TS_SE /* looking for sub-option end */
|
||||||
} TelnetReceive;
|
} TelnetReceive;
|
||||||
|
|
||||||
struct TELNET {
|
struct TELNET {
|
||||||
@ -177,26 +178,26 @@ CURLcode init_telnet(struct connectdata *conn)
|
|||||||
|
|
||||||
memset(tn, 0, sizeof(struct TELNET));
|
memset(tn, 0, sizeof(struct TELNET));
|
||||||
|
|
||||||
tn->telrcv_state = TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
|
|
||||||
/* Init suboptions */
|
/* Init suboptions */
|
||||||
SB_CLEAR(tn);
|
CURL_SB_CLEAR(tn);
|
||||||
|
|
||||||
/* Set all options to NO */
|
/* Set all options to NO */
|
||||||
#if 0
|
#if 0
|
||||||
/* NO is zero => default fill pattern */
|
/* NO is zero => default fill pattern */
|
||||||
memset(tn->us, NO, 256);
|
memset(tn->us, CURL_NO, 256);
|
||||||
memset(tn->usq, NO, 256);
|
memset(tn->usq, CURL_NO, 256);
|
||||||
memset(tn->us_preferred, NO, 256);
|
memset(tn->us_preferred, CURL_NO, 256);
|
||||||
memset(tn->him, NO, 256);
|
memset(tn->him, CURL_NO, 256);
|
||||||
memset(tn->himq, NO, 256);
|
memset(tn->himq, CURL_NO, 256);
|
||||||
memset(tn->him_preferred, NO, 256);
|
memset(tn->him_preferred, CURL_NO, 256);
|
||||||
#endif
|
#endif
|
||||||
/* Set the options we want by default */
|
/* Set the options we want by default */
|
||||||
tn->us_preferred[TELOPT_BINARY] = YES;
|
tn->us_preferred[CURL_TELOPT_BINARY] = CURL_YES;
|
||||||
tn->us_preferred[TELOPT_SGA] = YES;
|
tn->us_preferred[CURL_TELOPT_SGA] = CURL_YES;
|
||||||
tn->him_preferred[TELOPT_BINARY] = YES;
|
tn->him_preferred[CURL_TELOPT_BINARY] = CURL_YES;
|
||||||
tn->him_preferred[TELOPT_SGA] = YES;
|
tn->him_preferred[CURL_TELOPT_SGA] = CURL_YES;
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@ -206,13 +207,13 @@ static void negotiate(struct connectdata *conn)
|
|||||||
int i;
|
int i;
|
||||||
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
||||||
|
|
||||||
for(i = 0;i < NTELOPTS;i++)
|
for(i = 0;i < CURL_NTELOPTS;i++)
|
||||||
{
|
{
|
||||||
if(tn->us_preferred[i] == YES)
|
if(tn->us_preferred[i] == CURL_YES)
|
||||||
set_local_option(conn, i, YES);
|
set_local_option(conn, i, CURL_YES);
|
||||||
|
|
||||||
if(tn->him_preferred[i] == YES)
|
if(tn->him_preferred[i] == CURL_YES)
|
||||||
set_remote_option(conn, i, YES);
|
set_remote_option(conn, i, CURL_YES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,22 +225,22 @@ static void printoption(struct SessionHandle *data,
|
|||||||
|
|
||||||
if (data->set.verbose)
|
if (data->set.verbose)
|
||||||
{
|
{
|
||||||
if (cmd == IAC)
|
if (cmd == CURL_IAC)
|
||||||
{
|
{
|
||||||
if (TELCMD_OK(option))
|
if (CURL_TELCMD_OK(option))
|
||||||
Curl_infof(data, "%s IAC %s\n", direction, TELCMD(option));
|
Curl_infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option));
|
||||||
else
|
else
|
||||||
Curl_infof(data, "%s IAC %d\n", direction, option);
|
Curl_infof(data, "%s IAC %d\n", direction, option);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fmt = (cmd == WILL) ? "WILL" : (cmd == WONT) ? "WONT" :
|
fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
|
||||||
(cmd == DO) ? "DO" : (cmd == DONT) ? "DONT" : 0;
|
(cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
|
||||||
if (fmt)
|
if (fmt)
|
||||||
{
|
{
|
||||||
if (TELOPT_OK(option))
|
if (CURL_TELOPT_OK(option))
|
||||||
opt = TELOPT(option);
|
opt = CURL_TELOPT(option);
|
||||||
else if (option == TELOPT_EXOPL)
|
else if (option == CURL_TELOPT_EXOPL)
|
||||||
opt = "EXOPL";
|
opt = "EXOPL";
|
||||||
else
|
else
|
||||||
opt = NULL;
|
opt = NULL;
|
||||||
@ -259,7 +260,7 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
|
|||||||
{
|
{
|
||||||
unsigned char buf[3];
|
unsigned char buf[3];
|
||||||
|
|
||||||
buf[0] = IAC;
|
buf[0] = CURL_IAC;
|
||||||
buf[1] = cmd;
|
buf[1] = cmd;
|
||||||
buf[2] = option;
|
buf[2] = option;
|
||||||
|
|
||||||
@ -272,40 +273,40 @@ static
|
|||||||
void set_remote_option(struct connectdata *conn, int option, int newstate)
|
void set_remote_option(struct connectdata *conn, int option, int newstate)
|
||||||
{
|
{
|
||||||
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
||||||
if(newstate == YES)
|
if(newstate == CURL_YES)
|
||||||
{
|
{
|
||||||
switch(tn->him[option])
|
switch(tn->him[option])
|
||||||
{
|
{
|
||||||
case NO:
|
case CURL_NO:
|
||||||
tn->him[option] = WANTYES;
|
tn->him[option] = CURL_WANTYES;
|
||||||
send_negotiation(conn, DO, option);
|
send_negotiation(conn, CURL_DO, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YES:
|
case CURL_YES:
|
||||||
/* Already enabled */
|
/* Already enabled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTNO:
|
case CURL_WANTNO:
|
||||||
switch(tn->himq[option])
|
switch(tn->himq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
/* Already negotiating for YES, queue the request */
|
/* Already negotiating for CURL_YES, queue the request */
|
||||||
tn->himq[option] = OPPOSITE;
|
tn->himq[option] = CURL_OPPOSITE;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
/* Error: already queued an enable request */
|
/* Error: already queued an enable request */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTYES:
|
case CURL_WANTYES:
|
||||||
switch(tn->himq[option])
|
switch(tn->himq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
/* Error: already negotiating for enable */
|
/* Error: already negotiating for enable */
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->himq[option] = EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -315,34 +316,34 @@ void set_remote_option(struct connectdata *conn, int option, int newstate)
|
|||||||
{
|
{
|
||||||
switch(tn->him[option])
|
switch(tn->him[option])
|
||||||
{
|
{
|
||||||
case NO:
|
case CURL_NO:
|
||||||
/* Already disabled */
|
/* Already disabled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YES:
|
case CURL_YES:
|
||||||
tn->him[option] = WANTNO;
|
tn->him[option] = CURL_WANTNO;
|
||||||
send_negotiation(conn, DONT, option);
|
send_negotiation(conn, CURL_DONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTNO:
|
case CURL_WANTNO:
|
||||||
switch(tn->himq[option])
|
switch(tn->himq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
/* Already negotiating for NO */
|
/* Already negotiating for NO */
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->himq[option] = EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTYES:
|
case CURL_WANTYES:
|
||||||
switch(tn->himq[option])
|
switch(tn->himq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
tn->himq[option] = OPPOSITE;
|
tn->himq[option] = CURL_OPPOSITE;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -356,47 +357,47 @@ void rec_will(struct connectdata *conn, int option)
|
|||||||
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
||||||
switch(tn->him[option])
|
switch(tn->him[option])
|
||||||
{
|
{
|
||||||
case NO:
|
case CURL_NO:
|
||||||
if(tn->him_preferred[option] == YES)
|
if(tn->him_preferred[option] == CURL_YES)
|
||||||
{
|
{
|
||||||
tn->him[option] = YES;
|
tn->him[option] = CURL_YES;
|
||||||
send_negotiation(conn, DO, option);
|
send_negotiation(conn, CURL_DO, option);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
send_negotiation(conn, DONT, option);
|
send_negotiation(conn, CURL_DONT, option);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YES:
|
case CURL_YES:
|
||||||
/* Already enabled */
|
/* Already enabled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTNO:
|
case CURL_WANTNO:
|
||||||
switch(tn->himq[option])
|
switch(tn->himq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
/* Error: DONT answered by WILL */
|
/* Error: DONT answered by WILL */
|
||||||
tn->him[option] = NO;
|
tn->him[option] = CURL_NO;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
/* Error: DONT answered by WILL */
|
/* Error: DONT answered by WILL */
|
||||||
tn->him[option] = YES;
|
tn->him[option] = CURL_YES;
|
||||||
tn->himq[option] = EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTYES:
|
case CURL_WANTYES:
|
||||||
switch(tn->himq[option])
|
switch(tn->himq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
tn->him[option] = YES;
|
tn->him[option] = CURL_YES;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->him[option] = WANTNO;
|
tn->him[option] = CURL_WANTNO;
|
||||||
tn->himq[option] = EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
send_negotiation(conn, DONT, option);
|
send_negotiation(conn, CURL_DONT, option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -409,39 +410,39 @@ void rec_wont(struct connectdata *conn, int option)
|
|||||||
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
||||||
switch(tn->him[option])
|
switch(tn->him[option])
|
||||||
{
|
{
|
||||||
case NO:
|
case CURL_NO:
|
||||||
/* Already disabled */
|
/* Already disabled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YES:
|
case CURL_YES:
|
||||||
tn->him[option] = NO;
|
tn->him[option] = CURL_NO;
|
||||||
send_negotiation(conn, DONT, option);
|
send_negotiation(conn, CURL_DONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTNO:
|
case CURL_WANTNO:
|
||||||
switch(tn->himq[option])
|
switch(tn->himq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
tn->him[option] = NO;
|
tn->him[option] = CURL_NO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->him[option] = WANTYES;
|
tn->him[option] = CURL_WANTYES;
|
||||||
tn->himq[option] = EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
send_negotiation(conn, DO, option);
|
send_negotiation(conn, CURL_DO, option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTYES:
|
case CURL_WANTYES:
|
||||||
switch(tn->himq[option])
|
switch(tn->himq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
tn->him[option] = NO;
|
tn->him[option] = CURL_NO;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->him[option] = NO;
|
tn->him[option] = CURL_NO;
|
||||||
tn->himq[option] = EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -451,40 +452,40 @@ void rec_wont(struct connectdata *conn, int option)
|
|||||||
void set_local_option(struct connectdata *conn, int option, int newstate)
|
void set_local_option(struct connectdata *conn, int option, int newstate)
|
||||||
{
|
{
|
||||||
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
||||||
if(newstate == YES)
|
if(newstate == CURL_YES)
|
||||||
{
|
{
|
||||||
switch(tn->us[option])
|
switch(tn->us[option])
|
||||||
{
|
{
|
||||||
case NO:
|
case CURL_NO:
|
||||||
tn->us[option] = WANTYES;
|
tn->us[option] = CURL_WANTYES;
|
||||||
send_negotiation(conn, WILL, option);
|
send_negotiation(conn, CURL_WILL, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YES:
|
case CURL_YES:
|
||||||
/* Already enabled */
|
/* Already enabled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTNO:
|
case CURL_WANTNO:
|
||||||
switch(tn->usq[option])
|
switch(tn->usq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
/* Already negotiating for YES, queue the request */
|
/* Already negotiating for CURL_YES, queue the request */
|
||||||
tn->usq[option] = OPPOSITE;
|
tn->usq[option] = CURL_OPPOSITE;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
/* Error: already queued an enable request */
|
/* Error: already queued an enable request */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTYES:
|
case CURL_WANTYES:
|
||||||
switch(tn->usq[option])
|
switch(tn->usq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
/* Error: already negotiating for enable */
|
/* Error: already negotiating for enable */
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->usq[option] = EMPTY;
|
tn->usq[option] = CURL_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -494,34 +495,34 @@ void set_local_option(struct connectdata *conn, int option, int newstate)
|
|||||||
{
|
{
|
||||||
switch(tn->us[option])
|
switch(tn->us[option])
|
||||||
{
|
{
|
||||||
case NO:
|
case CURL_NO:
|
||||||
/* Already disabled */
|
/* Already disabled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YES:
|
case CURL_YES:
|
||||||
tn->us[option] = WANTNO;
|
tn->us[option] = CURL_WANTNO;
|
||||||
send_negotiation(conn, WONT, option);
|
send_negotiation(conn, CURL_WONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTNO:
|
case CURL_WANTNO:
|
||||||
switch(tn->usq[option])
|
switch(tn->usq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
/* Already negotiating for NO */
|
/* Already negotiating for NO */
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->usq[option] = EMPTY;
|
tn->usq[option] = CURL_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTYES:
|
case CURL_WANTYES:
|
||||||
switch(tn->usq[option])
|
switch(tn->usq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
tn->usq[option] = OPPOSITE;
|
tn->usq[option] = CURL_OPPOSITE;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -535,47 +536,47 @@ void rec_do(struct connectdata *conn, int option)
|
|||||||
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
||||||
switch(tn->us[option])
|
switch(tn->us[option])
|
||||||
{
|
{
|
||||||
case NO:
|
case CURL_NO:
|
||||||
if(tn->us_preferred[option] == YES)
|
if(tn->us_preferred[option] == CURL_YES)
|
||||||
{
|
{
|
||||||
tn->us[option] = YES;
|
tn->us[option] = CURL_YES;
|
||||||
send_negotiation(conn, WILL, option);
|
send_negotiation(conn, CURL_WILL, option);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
send_negotiation(conn, WONT, option);
|
send_negotiation(conn, CURL_WONT, option);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YES:
|
case CURL_YES:
|
||||||
/* Already enabled */
|
/* Already enabled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTNO:
|
case CURL_WANTNO:
|
||||||
switch(tn->usq[option])
|
switch(tn->usq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
/* Error: DONT answered by WILL */
|
/* Error: DONT answered by WILL */
|
||||||
tn->us[option] = NO;
|
tn->us[option] = CURL_NO;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
/* Error: DONT answered by WILL */
|
/* Error: DONT answered by WILL */
|
||||||
tn->us[option] = YES;
|
tn->us[option] = CURL_YES;
|
||||||
tn->usq[option] = EMPTY;
|
tn->usq[option] = CURL_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTYES:
|
case CURL_WANTYES:
|
||||||
switch(tn->usq[option])
|
switch(tn->usq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
tn->us[option] = YES;
|
tn->us[option] = CURL_YES;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->us[option] = WANTNO;
|
tn->us[option] = CURL_WANTNO;
|
||||||
tn->himq[option] = EMPTY;
|
tn->himq[option] = CURL_EMPTY;
|
||||||
send_negotiation(conn, WONT, option);
|
send_negotiation(conn, CURL_WONT, option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -588,39 +589,39 @@ void rec_dont(struct connectdata *conn, int option)
|
|||||||
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
||||||
switch(tn->us[option])
|
switch(tn->us[option])
|
||||||
{
|
{
|
||||||
case NO:
|
case CURL_NO:
|
||||||
/* Already disabled */
|
/* Already disabled */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YES:
|
case CURL_YES:
|
||||||
tn->us[option] = NO;
|
tn->us[option] = CURL_NO;
|
||||||
send_negotiation(conn, WONT, option);
|
send_negotiation(conn, CURL_WONT, option);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTNO:
|
case CURL_WANTNO:
|
||||||
switch(tn->usq[option])
|
switch(tn->usq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
tn->us[option] = NO;
|
tn->us[option] = CURL_NO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->us[option] = WANTYES;
|
tn->us[option] = CURL_WANTYES;
|
||||||
tn->usq[option] = EMPTY;
|
tn->usq[option] = CURL_EMPTY;
|
||||||
send_negotiation(conn, WILL, option);
|
send_negotiation(conn, CURL_WILL, option);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WANTYES:
|
case CURL_WANTYES:
|
||||||
switch(tn->usq[option])
|
switch(tn->usq[option])
|
||||||
{
|
{
|
||||||
case EMPTY:
|
case CURL_EMPTY:
|
||||||
tn->us[option] = NO;
|
tn->us[option] = CURL_NO;
|
||||||
break;
|
break;
|
||||||
case OPPOSITE:
|
case CURL_OPPOSITE:
|
||||||
tn->us[option] = NO;
|
tn->us[option] = CURL_NO;
|
||||||
tn->usq[option] = EMPTY;
|
tn->usq[option] = CURL_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -647,19 +648,19 @@ static void printsub(struct SessionHandle *data,
|
|||||||
i = pointer[length-2];
|
i = pointer[length-2];
|
||||||
j = pointer[length-1];
|
j = pointer[length-1];
|
||||||
|
|
||||||
if (i != IAC || j != SE)
|
if (i != CURL_IAC || j != CURL_SE)
|
||||||
{
|
{
|
||||||
Curl_infof(data, "(terminated by ");
|
Curl_infof(data, "(terminated by ");
|
||||||
if (TELOPT_OK(i))
|
if (CURL_TELOPT_OK(i))
|
||||||
Curl_infof(data, "%s ", TELOPT(i));
|
Curl_infof(data, "%s ", CURL_TELOPT(i));
|
||||||
else if (TELCMD_OK(i))
|
else if (CURL_TELCMD_OK(i))
|
||||||
Curl_infof(data, "%s ", TELCMD(i));
|
Curl_infof(data, "%s ", CURL_TELCMD(i));
|
||||||
else
|
else
|
||||||
Curl_infof(data, "%d ", i);
|
Curl_infof(data, "%d ", i);
|
||||||
if (TELOPT_OK(j))
|
if (CURL_TELOPT_OK(j))
|
||||||
Curl_infof(data, "%s", TELOPT(j));
|
Curl_infof(data, "%s", CURL_TELOPT(j));
|
||||||
else if (TELCMD_OK(j))
|
else if (CURL_TELCMD_OK(j))
|
||||||
Curl_infof(data, "%s", TELCMD(j));
|
Curl_infof(data, "%s", CURL_TELCMD(j));
|
||||||
else
|
else
|
||||||
Curl_infof(data, "%d", j);
|
Curl_infof(data, "%d", j);
|
||||||
Curl_infof(data, ", not IAC SE!) ");
|
Curl_infof(data, ", not IAC SE!) ");
|
||||||
@ -673,15 +674,15 @@ static void printsub(struct SessionHandle *data,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TELOPT_OK(pointer[0])) {
|
if (CURL_TELOPT_OK(pointer[0])) {
|
||||||
switch(pointer[0]) {
|
switch(pointer[0]) {
|
||||||
case TELOPT_TTYPE:
|
case CURL_TELOPT_TTYPE:
|
||||||
case TELOPT_XDISPLOC:
|
case CURL_TELOPT_XDISPLOC:
|
||||||
case TELOPT_NEW_ENVIRON:
|
case CURL_TELOPT_NEW_ENVIRON:
|
||||||
Curl_infof(data, "%s", TELOPT(pointer[0]));
|
Curl_infof(data, "%s", CURL_TELOPT(pointer[0]));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Curl_infof(data, "%s (unsupported)", TELOPT(pointer[0]));
|
Curl_infof(data, "%s (unsupported)", CURL_TELOPT(pointer[0]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -689,35 +690,35 @@ static void printsub(struct SessionHandle *data,
|
|||||||
Curl_infof(data, "%d (unknown)", pointer[i]);
|
Curl_infof(data, "%d (unknown)", pointer[i]);
|
||||||
|
|
||||||
switch(pointer[1]) {
|
switch(pointer[1]) {
|
||||||
case TELQUAL_IS:
|
case CURL_TELQUAL_IS:
|
||||||
Curl_infof(data, " IS");
|
Curl_infof(data, " IS");
|
||||||
break;
|
break;
|
||||||
case TELQUAL_SEND:
|
case CURL_TELQUAL_SEND:
|
||||||
Curl_infof(data, " SEND");
|
Curl_infof(data, " SEND");
|
||||||
break;
|
break;
|
||||||
case TELQUAL_INFO:
|
case CURL_TELQUAL_INFO:
|
||||||
Curl_infof(data, " INFO/REPLY");
|
Curl_infof(data, " INFO/REPLY");
|
||||||
break;
|
break;
|
||||||
case TELQUAL_NAME:
|
case CURL_TELQUAL_NAME:
|
||||||
Curl_infof(data, " NAME");
|
Curl_infof(data, " NAME");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(pointer[0]) {
|
switch(pointer[0]) {
|
||||||
case TELOPT_TTYPE:
|
case CURL_TELOPT_TTYPE:
|
||||||
case TELOPT_XDISPLOC:
|
case CURL_TELOPT_XDISPLOC:
|
||||||
pointer[length] = 0;
|
pointer[length] = 0;
|
||||||
Curl_infof(data, " \"%s\"", &pointer[2]);
|
Curl_infof(data, " \"%s\"", &pointer[2]);
|
||||||
break;
|
break;
|
||||||
case TELOPT_NEW_ENVIRON:
|
case CURL_TELOPT_NEW_ENVIRON:
|
||||||
if(pointer[1] == TELQUAL_IS) {
|
if(pointer[1] == CURL_TELQUAL_IS) {
|
||||||
Curl_infof(data, " ");
|
Curl_infof(data, " ");
|
||||||
for(i = 3;i < length;i++) {
|
for(i = 3;i < length;i++) {
|
||||||
switch(pointer[i]) {
|
switch(pointer[i]) {
|
||||||
case NEW_ENV_VAR:
|
case CURL_NEW_ENV_VAR:
|
||||||
Curl_infof(data, ", ");
|
Curl_infof(data, ", ");
|
||||||
break;
|
break;
|
||||||
case NEW_ENV_VALUE:
|
case CURL_NEW_ENV_VALUE:
|
||||||
Curl_infof(data, " = ");
|
Curl_infof(data, " = ");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -757,7 +758,7 @@ static int check_telnet_options(struct connectdata *conn)
|
|||||||
sprintf(buf, "USER,%s", data->state.user);
|
sprintf(buf, "USER,%s", data->state.user);
|
||||||
tn->telnet_vars = curl_slist_append(tn->telnet_vars, buf);
|
tn->telnet_vars = curl_slist_append(tn->telnet_vars, buf);
|
||||||
|
|
||||||
tn->us_preferred[TELOPT_NEW_ENVIRON] = YES;
|
tn->us_preferred[CURL_TELOPT_NEW_ENVIRON] = CURL_YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(head = data->set.telnet_options; head; head=head->next) {
|
for(head = data->set.telnet_options; head; head=head->next) {
|
||||||
@ -768,7 +769,7 @@ static int check_telnet_options(struct connectdata *conn)
|
|||||||
if(curl_strequal(option_keyword, "TTYPE")) {
|
if(curl_strequal(option_keyword, "TTYPE")) {
|
||||||
strncpy(tn->subopt_ttype, option_arg, 31);
|
strncpy(tn->subopt_ttype, option_arg, 31);
|
||||||
tn->subopt_ttype[31] = 0; /* String termination */
|
tn->subopt_ttype[31] = 0; /* String termination */
|
||||||
tn->us_preferred[TELOPT_TTYPE] = YES;
|
tn->us_preferred[CURL_TELOPT_TTYPE] = CURL_YES;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,7 +777,7 @@ static int check_telnet_options(struct connectdata *conn)
|
|||||||
if(curl_strequal(option_keyword, "XDISPLOC")) {
|
if(curl_strequal(option_keyword, "XDISPLOC")) {
|
||||||
strncpy(tn->subopt_xdisploc, option_arg, 127);
|
strncpy(tn->subopt_xdisploc, option_arg, 127);
|
||||||
tn->subopt_xdisploc[127] = 0; /* String termination */
|
tn->subopt_xdisploc[127] = 0; /* String termination */
|
||||||
tn->us_preferred[TELOPT_XDISPLOC] = YES;
|
tn->us_preferred[CURL_TELOPT_XDISPLOC] = CURL_YES;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,7 +787,7 @@ static int check_telnet_options(struct connectdata *conn)
|
|||||||
if(!buf)
|
if(!buf)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
tn->telnet_vars = curl_slist_append(tn->telnet_vars, buf);
|
tn->telnet_vars = curl_slist_append(tn->telnet_vars, buf);
|
||||||
tn->us_preferred[TELOPT_NEW_ENVIRON] = YES;
|
tn->us_preferred[CURL_TELOPT_NEW_ENVIRON] = CURL_YES;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,27 +821,28 @@ static void suboption(struct connectdata *conn)
|
|||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
struct TELNET *tn = (struct TELNET *)conn->proto.telnet;
|
||||||
|
|
||||||
printsub(data, '<', (unsigned char *)tn->subbuffer, SB_LEN(tn)+2);
|
printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn)+2);
|
||||||
switch (subchar = SB_GET(tn)) {
|
switch (subchar = CURL_SB_GET(tn)) {
|
||||||
case TELOPT_TTYPE:
|
case CURL_TELOPT_TTYPE:
|
||||||
len = strlen(tn->subopt_ttype) + 4 + 2;
|
len = strlen(tn->subopt_ttype) + 4 + 2;
|
||||||
snprintf((char *)temp, sizeof(temp),
|
snprintf((char *)temp, sizeof(temp),
|
||||||
"%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE,
|
"%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
|
||||||
TELQUAL_IS, tn->subopt_ttype, IAC, SE);
|
CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, CURL_SE);
|
||||||
(void)swrite(conn->firstsocket, temp, len);
|
(void)swrite(conn->firstsocket, temp, len);
|
||||||
printsub(data, '>', &temp[2], len-2);
|
printsub(data, '>', &temp[2], len-2);
|
||||||
break;
|
break;
|
||||||
case TELOPT_XDISPLOC:
|
case CURL_TELOPT_XDISPLOC:
|
||||||
len = strlen(tn->subopt_xdisploc) + 4 + 2;
|
len = strlen(tn->subopt_xdisploc) + 4 + 2;
|
||||||
snprintf((char *)temp, sizeof(temp),
|
snprintf((char *)temp, sizeof(temp),
|
||||||
"%c%c%c%c%s%c%c", IAC, SB, TELOPT_XDISPLOC,
|
"%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
|
||||||
TELQUAL_IS, tn->subopt_xdisploc, IAC, SE);
|
CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, CURL_SE);
|
||||||
(void)swrite(conn->firstsocket, temp, len);
|
(void)swrite(conn->firstsocket, temp, len);
|
||||||
printsub(data, '>', &temp[2], len-2);
|
printsub(data, '>', &temp[2], len-2);
|
||||||
break;
|
break;
|
||||||
case TELOPT_NEW_ENVIRON:
|
case CURL_TELOPT_NEW_ENVIRON:
|
||||||
snprintf((char *)temp, sizeof(temp),
|
snprintf((char *)temp, sizeof(temp),
|
||||||
"%c%c%c%c", IAC, SB, TELOPT_NEW_ENVIRON, TELQUAL_IS);
|
"%c%c%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
|
||||||
|
CURL_TELQUAL_IS);
|
||||||
len = 4;
|
len = 4;
|
||||||
|
|
||||||
for(v = tn->telnet_vars;v;v = v->next) {
|
for(v = tn->telnet_vars;v;v = v->next) {
|
||||||
@ -849,13 +851,13 @@ static void suboption(struct connectdata *conn)
|
|||||||
if(len + tmplen < (int)sizeof(temp)-6) {
|
if(len + tmplen < (int)sizeof(temp)-6) {
|
||||||
sscanf(v->data, "%127[^,],%s", varname, varval);
|
sscanf(v->data, "%127[^,],%s", varname, varval);
|
||||||
snprintf((char *)&temp[len], sizeof(temp) - len,
|
snprintf((char *)&temp[len], sizeof(temp) - len,
|
||||||
"%c%s%c%s", NEW_ENV_VAR, varname,
|
"%c%s%c%s", CURL_NEW_ENV_VAR, varname,
|
||||||
NEW_ENV_VALUE, varval);
|
CURL_NEW_ENV_VALUE, varval);
|
||||||
len += tmplen;
|
len += tmplen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snprintf((char *)&temp[len], sizeof(temp) - len,
|
snprintf((char *)&temp[len], sizeof(temp) - len,
|
||||||
"%c%c", IAC, SE);
|
"%c%c", CURL_IAC, CURL_SE);
|
||||||
len += 2;
|
len += 2;
|
||||||
(void)swrite(conn->firstsocket, temp, len);
|
(void)swrite(conn->firstsocket, temp, len);
|
||||||
printsub(data, '>', &temp[2], len-2);
|
printsub(data, '>', &temp[2], len-2);
|
||||||
@ -880,8 +882,8 @@ void telrcv(struct connectdata *conn,
|
|||||||
|
|
||||||
switch (tn->telrcv_state)
|
switch (tn->telrcv_state)
|
||||||
{
|
{
|
||||||
case TS_CR:
|
case CURL_TS_CR:
|
||||||
tn->telrcv_state = TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
if (c == '\0')
|
if (c == '\0')
|
||||||
{
|
{
|
||||||
break; /* Ignore \0 after CR */
|
break; /* Ignore \0 after CR */
|
||||||
@ -890,96 +892,96 @@ void telrcv(struct connectdata *conn,
|
|||||||
Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
|
Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TS_DATA:
|
case CURL_TS_DATA:
|
||||||
if (c == IAC)
|
if (c == CURL_IAC)
|
||||||
{
|
{
|
||||||
tn->telrcv_state = TS_IAC;
|
tn->telrcv_state = CURL_TS_IAC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(c == '\r')
|
else if(c == '\r')
|
||||||
{
|
{
|
||||||
tn->telrcv_state = TS_CR;
|
tn->telrcv_state = CURL_TS_CR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
|
Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TS_IAC:
|
case CURL_TS_IAC:
|
||||||
process_iac:
|
process_iac:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case WILL:
|
case CURL_WILL:
|
||||||
tn->telrcv_state = TS_WILL;
|
tn->telrcv_state = CURL_TS_WILL;
|
||||||
continue;
|
continue;
|
||||||
case WONT:
|
case CURL_WONT:
|
||||||
tn->telrcv_state = TS_WONT;
|
tn->telrcv_state = CURL_TS_WONT;
|
||||||
continue;
|
continue;
|
||||||
case DO:
|
case CURL_DO:
|
||||||
tn->telrcv_state = TS_DO;
|
tn->telrcv_state = CURL_TS_DO;
|
||||||
continue;
|
continue;
|
||||||
case DONT:
|
case CURL_DONT:
|
||||||
tn->telrcv_state = TS_DONT;
|
tn->telrcv_state = CURL_TS_DONT;
|
||||||
continue;
|
continue;
|
||||||
case SB:
|
case CURL_SB:
|
||||||
SB_CLEAR(tn);
|
CURL_SB_CLEAR(tn);
|
||||||
tn->telrcv_state = TS_SB;
|
tn->telrcv_state = CURL_TS_SB;
|
||||||
continue;
|
continue;
|
||||||
case IAC:
|
case CURL_IAC:
|
||||||
Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
|
Curl_client_write(data, CLIENTWRITE_BODY, (char *)&c, 1);
|
||||||
break;
|
break;
|
||||||
case DM:
|
case CURL_DM:
|
||||||
case NOP:
|
case CURL_NOP:
|
||||||
case GA:
|
case CURL_GA:
|
||||||
default:
|
default:
|
||||||
printoption(data, "RCVD", IAC, c);
|
printoption(data, "RCVD", CURL_IAC, c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tn->telrcv_state = TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TS_WILL:
|
case CURL_TS_WILL:
|
||||||
printoption(data, "RCVD", WILL, c);
|
printoption(data, "RCVD", CURL_WILL, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_will(conn, c);
|
rec_will(conn, c);
|
||||||
tn->telrcv_state = TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TS_WONT:
|
case CURL_TS_WONT:
|
||||||
printoption(data, "RCVD", WONT, c);
|
printoption(data, "RCVD", CURL_WONT, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_wont(conn, c);
|
rec_wont(conn, c);
|
||||||
tn->telrcv_state = TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TS_DO:
|
case CURL_TS_DO:
|
||||||
printoption(data, "RCVD", DO, c);
|
printoption(data, "RCVD", CURL_DO, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_do(conn, c);
|
rec_do(conn, c);
|
||||||
tn->telrcv_state = TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TS_DONT:
|
case CURL_TS_DONT:
|
||||||
printoption(data, "RCVD", DONT, c);
|
printoption(data, "RCVD", CURL_DONT, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_dont(conn, c);
|
rec_dont(conn, c);
|
||||||
tn->telrcv_state = TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TS_SB:
|
case CURL_TS_SB:
|
||||||
if (c == IAC)
|
if (c == CURL_IAC)
|
||||||
{
|
{
|
||||||
tn->telrcv_state = TS_SE;
|
tn->telrcv_state = CURL_TS_SE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SB_ACCUM(tn,c);
|
CURL_SB_ACCUM(tn,c);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TS_SE:
|
case CURL_TS_SE:
|
||||||
if (c != SE)
|
if (c != CURL_SE)
|
||||||
{
|
{
|
||||||
if (c != IAC)
|
if (c != CURL_IAC)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This is an error. We only expect to get
|
* This is an error. We only expect to get
|
||||||
@ -993,27 +995,27 @@ void telrcv(struct connectdata *conn,
|
|||||||
* we terminate the suboption, and process the
|
* we terminate the suboption, and process the
|
||||||
* partial suboption if we can.
|
* partial suboption if we can.
|
||||||
*/
|
*/
|
||||||
SB_ACCUM(tn, (unsigned char)IAC);
|
CURL_SB_ACCUM(tn, (unsigned char)CURL_IAC);
|
||||||
SB_ACCUM(tn, c);
|
CURL_SB_ACCUM(tn, c);
|
||||||
tn->subpointer -= 2;
|
tn->subpointer -= 2;
|
||||||
SB_TERM(tn);
|
CURL_SB_TERM(tn);
|
||||||
|
|
||||||
printoption(data, "In SUBOPTION processing, RCVD", IAC, c);
|
printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
|
||||||
suboption(conn); /* handle sub-option */
|
suboption(conn); /* handle sub-option */
|
||||||
tn->telrcv_state = TS_IAC;
|
tn->telrcv_state = CURL_TS_IAC;
|
||||||
goto process_iac;
|
goto process_iac;
|
||||||
}
|
}
|
||||||
SB_ACCUM(tn,c);
|
CURL_SB_ACCUM(tn,c);
|
||||||
tn->telrcv_state = TS_SB;
|
tn->telrcv_state = CURL_TS_SB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SB_ACCUM(tn, (unsigned char)IAC);
|
CURL_SB_ACCUM(tn, (unsigned char)CURL_IAC);
|
||||||
SB_ACCUM(tn, (unsigned char)SE);
|
CURL_SB_ACCUM(tn, (unsigned char)CURL_SE);
|
||||||
tn->subpointer -= 2;
|
tn->subpointer -= 2;
|
||||||
SB_TERM(tn);
|
CURL_SB_TERM(tn);
|
||||||
suboption(conn); /* handle sub-option */
|
suboption(conn); /* handle sub-option */
|
||||||
tn->telrcv_state = TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1102,8 +1104,8 @@ CURLcode Curl_telnet(struct connectdata *conn)
|
|||||||
while(nread--) {
|
while(nread--) {
|
||||||
outbuf[0] = *buffer++;
|
outbuf[0] = *buffer++;
|
||||||
out_count = 1;
|
out_count = 1;
|
||||||
if(outbuf[0] == IAC)
|
if(outbuf[0] == CURL_IAC)
|
||||||
outbuf[out_count++] = IAC;
|
outbuf[out_count++] = CURL_IAC;
|
||||||
|
|
||||||
Curl_write(conn, conn->firstsocket, outbuf,
|
Curl_write(conn, conn->firstsocket, outbuf,
|
||||||
out_count, &bytes_written);
|
out_count, &bytes_written);
|
||||||
@ -1173,8 +1175,8 @@ CURLcode Curl_telnet(struct connectdata *conn)
|
|||||||
while(nread--) {
|
while(nread--) {
|
||||||
outbuf[0] = *buffer++;
|
outbuf[0] = *buffer++;
|
||||||
out_count = 1;
|
out_count = 1;
|
||||||
if(outbuf[0] == IAC)
|
if(outbuf[0] == CURL_IAC)
|
||||||
outbuf[out_count++] = IAC;
|
outbuf[out_count++] = CURL_IAC;
|
||||||
|
|
||||||
Curl_write(conn, conn->firstsocket, outbuf,
|
Curl_write(conn, conn->firstsocket, outbuf,
|
||||||
out_count, &bytes_written);
|
out_count, &bytes_written);
|
||||||
|
Loading…
Reference in New Issue
Block a user