]> andersk Git - libfaim.git/blame - deprecated/tis_telnet_proxy.c
- Sun Oct 14 19:45:54 PDT 2001
[libfaim.git] / deprecated / tis_telnet_proxy.c
CommitLineData
9de3ca7e 1
2/*
3 * For working with TIS proxies. TODO: Fix for use with aim_conn.c.
4 *
5 */
6
7
8#include "aim.h"
9#ifdef TIS_TELNET_PROXY
10#include "tis_telnet_proxy.h"
11
12void
13tis_telnet_proxy_connect( int fd, char *host, int port )
14{
15 fd_set inset;
16 fd_set outset;
17 struct timeval tv;
18 char connectstring[512];
19 char responsestring[512];
20 char *ptr;
21 struct hostent *hent;
22
23 hent = gethostbyname( host );
24
25 snprintf( connectstring, 512, "connect %s %d\n", hent->h_name, port );
26 snprintf( responsestring, 512, "Connected to %s.\r\n", hent->h_name);
27
28 FD_ZERO( &outset );
29 FD_SET( fd, &outset );
30 tv.tv_sec = 0;
31 tv.tv_usec = 5;
32
33 if( select( fd + 1, NULL, &outset, NULL, &tv ) == 1 )
34 if( write( fd, connectstring, strlen(connectstring) ) !=
35 strlen(connectstring) )
36 printf("\n****ERROR ON WRITE**** (proxy connect)\n");
37
38
39 FD_ZERO( &inset );
40 FD_SET( fd, &inset );
41
42 ptr = responsestring;
43 while( select( fd + 1, &inset, NULL, NULL, NULL ) == 1 )
44 {
45 char c;
46
47 if( read( fd, &c, sizeof(c) ) != 1 )
48 printf("\n****ERROR ON READ**** (proxy response)\n");
49
50 if( c == *ptr )
51 {
52 if( *(++ptr) == '\0' )
53 break;
54 }
55 else
56 ptr = responsestring;
57
58 FD_ZERO( &inset );
59 FD_SET( fd, &inset );
60 }
61}
62
63#endif /* TIS_TELNET_PROXY */
64
This page took 0.234052 seconds and 5 git commands to generate.