~ubuntu-branches/ubuntu/hardy/curl/hardy-updates

« back to all changes in this revision

Viewing changes to lib/telnet.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:56:48 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030105648-uo8q8w9xklb40b4k
Tags: 7.15.5-1ubuntu1
* Merge from debian unstable. Remaining Ubuntu changes:
  - debian/control: Drop libdb4.2 build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: telnet.c,v 1.75 2006-05-04 22:39:47 bagder Exp $
 
21
 * $Id: telnet.c,v 1.78 2006-07-19 21:14:02 yangtse Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
71
71
#include "transfer.h"
72
72
#include "sendf.h"
73
73
#include "telnet.h"
 
74
#include "connect.h"
74
75
 
75
76
#define _MPRINTF_REPLACE /* use our functions only */
76
77
#include <curl/mprintf.h>
289
290
static void send_negotiation(struct connectdata *conn, int cmd, int option)
290
291
{
291
292
   unsigned char buf[3];
 
293
   ssize_t bytes_written;
 
294
   int err;
 
295
   struct SessionHandle *data = conn->data;
292
296
 
293
297
   buf[0] = CURL_IAC;
294
 
   buf[1] = cmd;
295
 
   buf[2] = option;
 
298
   buf[1] = (unsigned char)cmd;
 
299
   buf[2] = (unsigned char)option;
296
300
 
297
 
   (void)swrite(conn->sock[FIRSTSOCKET], (char *)buf, 3);
 
301
   bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
 
302
   if(bytes_written < 0) {
 
303
     err = Curl_sockerrno();
 
304
     failf(data,"Sending data failed (%d)",err);
 
305
   }
298
306
 
299
307
   printoption(conn->data, "SENT", cmd, option);
300
308
}
843
851
{
844
852
  struct curl_slist *v;
845
853
  unsigned char temp[2048];
 
854
  ssize_t bytes_written;
846
855
  size_t len;
847
856
  size_t tmplen;
 
857
  int err;
848
858
  char varname[128];
849
859
  char varval[128];
850
860
  struct SessionHandle *data = conn->data;
857
867
      snprintf((char *)temp, sizeof(temp),
858
868
               "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
859
869
               CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, CURL_SE);
860
 
      (void)swrite(conn->sock[FIRSTSOCKET], (char *)temp, len);
 
870
      bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
 
871
      if(bytes_written < 0) {
 
872
        err = Curl_sockerrno();
 
873
        failf(data,"Sending data failed (%d)",err);
 
874
      }
861
875
      printsub(data, '>', &temp[2], len-2);
862
876
      break;
863
877
    case CURL_TELOPT_XDISPLOC:
865
879
      snprintf((char *)temp, sizeof(temp),
866
880
               "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
867
881
               CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, CURL_SE);
868
 
      (void)swrite(conn->sock[FIRSTSOCKET], (char *)temp, len);
 
882
      bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
 
883
      if(bytes_written < 0) {
 
884
        err = Curl_sockerrno();
 
885
        failf(data,"Sending data failed (%d)",err);
 
886
      }
869
887
      printsub(data, '>', &temp[2], len-2);
870
888
      break;
871
889
    case CURL_TELOPT_NEW_ENVIRON:
888
906
      snprintf((char *)&temp[len], sizeof(temp) - len,
889
907
               "%c%c", CURL_IAC, CURL_SE);
890
908
      len += 2;
891
 
      (void)swrite(conn->sock[FIRSTSOCKET], (char *)temp, len);
 
909
      bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
 
910
      if(bytes_written < 0) {
 
911
        err = Curl_sockerrno();
 
912
        failf(data,"Sending data failed (%d)",err);
 
913
      }
892
914
      printsub(data, '>', &temp[2], len-2);
893
915
      break;
894
916
  }