Lines Matching refs:data

93 CURLcode telrcv(struct Curl_easy *data,
98 static void printoption(struct Curl_easy *data,
103 static void negotiate(struct Curl_easy *data);
104 static void send_negotiation(struct Curl_easy *data, int cmd, int option);
105 static void set_local_option(struct Curl_easy *data,
107 static void set_remote_option(struct Curl_easy *data,
110 static void printsub(struct Curl_easy *data,
113 static void suboption(struct Curl_easy *data);
114 static void sendsuboption(struct Curl_easy *data, int option);
116 static CURLcode telnet_do(struct Curl_easy *data, bool *done);
117 static CURLcode telnet_done(struct Curl_easy *data,
119 static CURLcode send_telnet_data(struct Curl_easy *data,
200 CURLcode init_telnet(struct Curl_easy *data)
209 data->req.p.telnet = tn; /* make us known */
251 static void negotiate(struct Curl_easy *data)
254 struct TELNET *tn = data->req.p.telnet;
261 set_local_option(data, i, CURL_YES);
264 set_remote_option(data, i, CURL_YES);
269 static void printoption(struct Curl_easy *data,
272 if(data->set.verbose) {
275 infof(data, "%s IAC %s", direction, CURL_TELCMD(option));
277 infof(data, "%s IAC %d", direction, option);
294 infof(data, "%s %s %s", direction, fmt, opt);
296 infof(data, "%s %s %d", direction, fmt, option);
299 infof(data, "%s %d %d", direction, cmd, option);
305 static void send_negotiation(struct Curl_easy *data, int cmd, int option)
309 struct connectdata *conn = data->conn;
318 failf(data,"Sending data failed (%d)",err);
321 printoption(data, "SENT", cmd, option);
325 void set_remote_option(struct Curl_easy *data, int option, int newstate)
327 struct TELNET *tn = data->req.p.telnet;
332 send_negotiation(data, CURL_DO, option);
371 send_negotiation(data, CURL_DONT, option);
399 void rec_will(struct Curl_easy *data, int option)
401 struct TELNET *tn = data->req.p.telnet;
406 send_negotiation(data, CURL_DO, option);
409 send_negotiation(data, CURL_DONT, option);
439 send_negotiation(data, CURL_DONT, option);
447 void rec_wont(struct Curl_easy *data, int option)
449 struct TELNET *tn = data->req.p.telnet;
457 send_negotiation(data, CURL_DONT, option);
469 send_negotiation(data, CURL_DO, option);
489 set_local_option(struct Curl_easy *data, int option, int newstate)
491 struct TELNET *tn = data->req.p.telnet;
496 send_negotiation(data, CURL_WILL, option);
535 send_negotiation(data, CURL_WONT, option);
563 void rec_do(struct Curl_easy *data, int option)
565 struct TELNET *tn = data->req.p.telnet;
570 send_negotiation(data, CURL_WILL, option);
572 /* transmission of data option */
573 sendsuboption(data, option);
578 send_negotiation(data, CURL_WILL, option);
579 sendsuboption(data, option);
582 send_negotiation(data, CURL_WONT, option);
608 /* transmission of data option */
609 sendsuboption(data, option);
615 send_negotiation(data, CURL_WONT, option);
623 void rec_dont(struct Curl_easy *data, int option)
625 struct TELNET *tn = data->req.p.telnet;
633 send_negotiation(data, CURL_WONT, option);
645 send_negotiation(data, CURL_WILL, option);
665 static void printsub(struct Curl_easy *data,
667 unsigned char *pointer, /* where suboption data is */
668 size_t length) /* length of suboption data */
670 if(data->set.verbose) {
673 infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
681 infof(data, "(terminated by ");
683 infof(data, "%s ", CURL_TELOPT(i));
685 infof(data, "%s ", CURL_TELCMD(i));
687 infof(data, "%u ", i);
689 infof(data, "%s", CURL_TELOPT(j));
691 infof(data, "%s", CURL_TELCMD(j));
693 infof(data, "%d", j);
694 infof(data, ", not IAC SE) ");
700 infof(data, "(Empty suboption?)");
710 infof(data, "%s", CURL_TELOPT(pointer[0]));
713 infof(data, "%s (unsupported)", CURL_TELOPT(pointer[0]));
718 infof(data, "%d (unknown)", pointer[i]);
723 infof(data, "Width: %d ; Height: %d", (pointer[1]<<8) | pointer[2],
729 infof(data, " IS");
732 infof(data, " SEND");
735 infof(data, " INFO/REPLY");
738 infof(data, " NAME");
746 infof(data, " \"%s\"", &pointer[2]);
750 infof(data, " ");
754 infof(data, ", ");
757 infof(data, " = ");
760 infof(data, "%c", pointer[i]);
768 infof(data, " %.2x", pointer[i]);
793 static CURLcode check_telnet_options(struct Curl_easy *data)
797 struct TELNET *tn = data->req.p.telnet;
802 if(data->state.aptr.user) {
804 if(str_is_nonascii(data->conn->user)) {
805 DEBUGF(infof(data, "set a non ASCII user name in telnet"));
808 msnprintf(buffer, sizeof(buffer), "USER,%s", data->conn->user);
819 for(head = data->set.telnet_options; head && !result; head = head->next) {
821 char *option = head->data;
887 failf(data, "Syntax error in telnet option: %s", head->data);
896 /* To take care or not of the 8th bit in data exchange */
908 failf(data, "Unknown telnet option %s", head->data);
914 failf(data, "Syntax error in telnet option: %s", head->data);
934 static void suboption(struct Curl_easy *data)
941 struct TELNET *tn = data->req.p.telnet;
942 struct connectdata *conn = data->conn;
944 printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2);
954 failf(data,"Sending data failed (%d)",err);
956 printsub(data, '>', &temp[2], len-2);
966 failf(data,"Sending data failed (%d)",err);
968 printsub(data, '>', &temp[2], len-2);
977 size_t tmplen = (strlen(v->data) + 1);
980 char *s = strchr(v->data, ',');
983 "%c%s", CURL_NEW_ENV_VAR, v->data);
985 size_t vlen = s - v->data;
988 (int)vlen, v->data, CURL_NEW_ENV_VALUE, ++s);
998 failf(data,"Sending data failed (%d)",err);
1000 printsub(data, '>', &temp[2], len-2);
1013 static void sendsuboption(struct Curl_easy *data, int option)
1019 struct TELNET *tn = data->req.p.telnet;
1020 struct connectdata *conn = data->conn;
1024 /* We prepare data to be sent */
1043 /* data suboption is now ready */
1045 printsub(data, '>', (unsigned char *)tn->subbuffer + 2,
1052 failf(data, "Sending data failed (%d)", err);
1056 send_telnet_data(data, (char *)tn->subbuffer + 3, 4);
1061 failf(data, "Sending data failed (%d)", err);
1069 CURLcode telrcv(struct Curl_easy *data,
1077 struct TELNET *tn = data->req.p.telnet;
1081 result = Curl_client_write(data, \
1149 printoption(data, "RCVD", CURL_IAC, c);
1155 printoption(data, "RCVD", CURL_WILL, c);
1157 rec_will(data, c);
1162 printoption(data, "RCVD", CURL_WONT, c);
1164 rec_wont(data, c);
1169 printoption(data, "RCVD", CURL_DO, c);
1171 rec_do(data, c);
1176 printoption(data, "RCVD", CURL_DONT, c);
1178 rec_dont(data, c);
1206 printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
1207 suboption(data); /* handle sub-option */
1219 suboption(data); /* handle sub-option */
1230 /* Escape and send a telnet data block */
1231 static CURLcode send_telnet_data(struct Curl_easy *data,
1238 struct connectdata *conn = data->conn;
1239 struct TELNET *tn = data->req.p.telnet;
1273 result = Curl_nwrite(data, FIRSTSOCKET, outbuf + total_written,
1283 static CURLcode telnet_done(struct Curl_easy *data,
1286 struct TELNET *tn = data->req.p.telnet;
1299 static CURLcode telnet_do(struct Curl_easy *data, bool *done)
1302 struct connectdata *conn = data->conn;
1328 result = init_telnet(data);
1332 tn = data->req.p.telnet;
1334 result = check_telnet_options(data);
1347 failf(data, "WSACreateEvent failed (%d)", SOCKERRNO);
1367 data->set.is_fread_set) {
1388 if(data->set.is_fread_set) {
1391 n = data->state.fread_func(buffer, 1, buf_size, data->state.in);
1427 result = send_telnet_data(data, buffer, readfile_read);
1445 result = send_telnet_data(data, buffer, readfile_read);
1459 infof(data, "WSAEnumNetworkEvents failed (%d)", err);
1466 /* read data from network */
1467 result = Curl_read(data, sockfd, buffer, sizeof(buffer), &nread);
1483 result = telrcv(data, (unsigned char *) buffer, nread);
1493 negotiate(data);
1505 if(data->set.timeout) {
1507 if(Curl_timediff(now, conn->created) >= data->set.timeout) {
1508 failf(data, "Time-out");
1517 infof(data, "WSACloseEvent failed (%d)", SOCKERRNO);
1523 if(data->set.is_fread_set) {
1529 pfd[1].fd = fileno((FILE *)data->state.in);
1536 DEBUGF(infof(data, "telnet_do, poll %d fds", poll_cnt));
1547 /* read data from network */
1548 result = Curl_read(data, sockfd, buffer, sizeof(buffer), &nread);
1559 if(data->state.os_errno == ECONNRESET) {
1560 DEBUGF(infof(data, "telnet_do, unexpected ECONNRESET on recv"));
1572 result = Curl_pgrsSetDownloadCounter(data, total_dl);
1574 result = telrcv(data, (unsigned char *)buffer, nread);
1584 negotiate(data);
1597 nread = (int)data->state.fread_func(buffer, 1, sizeof(buffer),
1598 data->state.in);
1608 result = send_telnet_data(data, buffer, nread);
1614 Curl_pgrsSetUploadCounter(data, total_ul);
1622 if(data->set.timeout) {
1624 if(Curl_timediff(now, conn->created) >= data->set.timeout) {
1625 failf(data, "Time-out");
1631 if(Curl_pgrsUpdate(data)) {
1638 Curl_setup_transfer(data, -1, -1, FALSE, -1);