24 |
|
|
25 |
#ifdef WITH_CABLE |
#ifdef WITH_CABLE |
26 |
|
|
27 |
|
#include <unistd.h> |
28 |
#include <stdio.h> |
#include <stdio.h> |
29 |
#include <stdlib.h> |
#include <stdlib.h> |
30 |
|
#include <string.h> |
31 |
|
|
32 |
|
#include <sys/types.h> |
33 |
#include <sys/socket.h> |
#include <sys/socket.h> |
34 |
#include <net/if.h> |
#include <net/if.h> |
35 |
#include <netinet/in.h> |
#include <netinet/in.h> |
36 |
#include <fcntl.h> |
#include <netdb.h> |
37 |
|
|
38 |
#include "options.h" |
#include "options.h" |
39 |
|
|
48 |
int |
int |
49 |
cable_connect () |
cable_connect () |
50 |
{ |
{ |
51 |
/* int port = PARAM_CABLE_AOL_PORT; |
int port = PARAM_CABLE_AOL_PORT; |
52 |
char *hostname = PARAM_CABLE_AOL_HOST; |
char *hostname = PARAM_CABLE_AOL_HOST; |
53 |
|
|
54 |
struct sockaddr_in intcable; |
struct sockaddr_in intcable; |
55 |
struct hosten *hp; |
struct hostent *hp; |
56 |
|
|
57 |
if ((hp = gethostbyname (hostname))== 0) |
if ((hp = gethostbyname (hostname))== 0) |
58 |
{ |
{ |
63 |
intcable.sin_family = AF_INET; |
intcable.sin_family = AF_INET; |
64 |
intcable.sin_port = htons(port); |
intcable.sin_port = htons(port); |
65 |
intcable.sin_addr.s_addr = *((unsigned long *) hp->h_addr); |
intcable.sin_addr.s_addr = *((unsigned long *) hp->h_addr); |
66 |
strcpy(PARAM_CABLE_CONNECT_IP,inet_ntoa(adresse)); |
// strcpy(PARAM_CABLE_CONNECT_IP,inet_ntoa(adresse)); |
67 |
|
|
68 |
if ((cablefd = socket (PF_INET, SOCK_STREAM, 0))<0) |
if ((cablefd = socket (PF_INET, SOCK_STREAM, 0))<0) |
69 |
{ |
{ |
74 |
|
|
75 |
if (connect (cablefd, (struct sockaddr *) &intcable, sizeof (struct sockaddr_in)) == 0) |
if (connect (cablefd, (struct sockaddr *) &intcable, sizeof (struct sockaddr_in)) == 0) |
76 |
return 1; |
return 1; |
77 |
*/ |
|
78 |
return 0; |
return 0; |
79 |
} |
} |
80 |
|
|
81 |
int |
int |
82 |
cable_close () |
cable_close () |
83 |
{ |
{ |
84 |
/* if (cablefd != -1) |
if (cablefd != -1) |
85 |
{ |
{ |
86 |
if ((close (cablefd)) == -1) |
if ((close (cablefd)) == -1) |
87 |
{ |
{ |
88 |
perror ("error closing socket !\n"); |
perror ("error closing socket !\n"); |
89 |
return -1; |
return 1; |
90 |
} |
} |
91 |
return 0; |
return 0; |
92 |
} |
} |
93 |
perror ("error closing socket !\n"); |
perror ("error closing socket !\n"); |
94 |
return -1; |
return 1; |
|
*/ |
|
|
return 0; |
|
95 |
} |
} |
96 |
|
|
97 |
int |
int |