/[pengfork]/pengfork/src/cable/cable.c
ViewVC logotype

Diff of /pengfork/src/cable/cable.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by chupa, Fri Sep 6 23:03:55 2002 UTC revision 1.4 by chupa, Thu Sep 12 08:44:49 2002 UTC
# Line 28  Line 28 
28  #include <stdio.h>  #include <stdio.h>
29  #include <stdlib.h>  #include <stdlib.h>
30  #include <string.h>  #include <string.h>
31    #include <errno.h>
32    
33  #include <sys/types.h>  #include <sys/types.h>
34  #include <sys/socket.h>  #include <sys/socket.h>
35  #include <net/if.h>  #include <net/if.h>
36  #include <netinet/in.h>  #include <netinet/in.h>
37  #include <netdb.h>  #include <netdb.h>
38    #include <fcntl.h>
39    
40  #include "options.h"  #include "options.h"
41  #include "access.h"  #include "access.h"
42    #include "log.h"
43  #include "cable/cable.h"  #include "cable/cable.h"
44    #include "tcpip/tcpip.h"
 static int cablefd = -1;  
45    
46  const access_t cable_access = (access_t) {  const access_t cable_access = (access_t) {
47    cable_connect,    cable_connect,
48    cable_close,    cable_close,
49    cable_connected,    cable_connected,
50    &cablefd    &tcpipfd
51  };  };
52    
53    
# Line 53  const access_t cable_access = (access_t) Line 55  const access_t cable_access = (access_t)
55  int  int
56  cable_connect ()  cable_connect ()
57  {  {
58    int port = PARAM_CABLE_AOL_PORT;    return tcpip_connect();
   char *hostname = PARAM_CABLE_AOL_HOST;  
   
   struct sockaddr_in intcable;  
   struct hostent *hp;  
   
   if ((hp = gethostbyname (hostname)) == 0)  
     {  
       perror ("error gethostbyname() !\n");  
       return 1;  
     }  
   memset ((char *) &intcable, 0, sizeof (struct sockaddr_in));  
   intcable.sin_family = AF_INET;  
   intcable.sin_port = htons (port);  
   intcable.sin_addr.s_addr = *((unsigned long *) hp->h_addr);  
   /*  strcpy(PARAM_CABLE_CONNECT_IP,inet_ntoa(adresse)); */  
   
   if ((cablefd = socket (PF_INET, SOCK_STREAM, 0)) < 0)  
     {  
       perror ("error while opening socket !\n");  
       return 1;  
     }  
   
   
   if (connect (cablefd, (struct sockaddr *) &intcable,  
                sizeof (struct sockaddr_in)) == 0)  
     return 1;  
   
   return 0;  
59  }  }
60    
61  int  int
62  cable_close ()  cable_close ()
63  {  {
64    if (cablefd != -1)    return tcpip_close();
     {  
       if ((close (cablefd)) == -1)  
         {  
           perror ("error closing socket !\n");  
           return 1;  
         }  
       return 0;  
     }  
   perror ("error closing socket !\n");  
   return 1;  
65  }  }
66    
67  int  int
68  cable_connected ()  cable_connected ()
69  {  {
70    return 0;    return tcpip_connected();
71  }  }
72    
73  #endif  #endif

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26