/[imapfilter]/imapfilter/connect.c
ViewVC logotype

Diff of /imapfilter/connect.c

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

revision 1.13 by lefcha, Mon Oct 1 11:48:51 2001 UTC revision 1.14 by lefcha, Thu Oct 4 15:45:53 2001 UTC
# Line 25  int init_connection(char *serv, unsigned Line 25  int init_connection(char *serv, unsigned
25      memset((char *) &sa, 0, sizeof(struct sockaddr_in));      memset((char *) &sa, 0, sizeof(struct sockaddr_in));
26    
27      sock = socket(PF_INET, SOCK_STREAM, 0);      sock = socket(PF_INET, SOCK_STREAM, 0);
28    
29      if (sock < 0) {      if (sock < 0) {
30          error("imapfilter: create socket; %s\n", strerror(errno));          error("imapfilter: create socket; %s\n", strerror(errno));
31          return ERROR_NETWORK;          return ERROR_NETWORK;
32      }      }
   
33      if (!(he = gethostbyname(serv))) {      if (!(he = gethostbyname(serv))) {
34          error("imapfilter: get network host entry; %s\n", strerror(errno));          error("imapfilter: get network host entry; %s\n", strerror(errno));
35          close_connection();          close_connection();
36          return ERROR_NETWORK;          return ERROR_NETWORK;
37      }      }
   
38      sa.sin_family = AF_INET;      sa.sin_family = AF_INET;
39      sa.sin_port = htons(port);      sa.sin_port = htons(port);
40      sa.sin_addr = *(struct in_addr *) he->h_addr;      sa.sin_addr = *(struct in_addr *) he->h_addr;
41    
42      if (connect(sock, (struct sockaddr *) &sa, sizeof(struct sockaddr))) {      if (connect(sock, (struct sockaddr *) & sa, sizeof(struct sockaddr))) {
43          error("imapfilter: initiating connection; %s\n", strerror(errno));          error("imapfilter: initiating connection; %s\n", strerror(errno));
44          close_connection();          close_connection();
45          return ERROR_NETWORK;          return ERROR_NETWORK;
46      }      }
       
47      strncpy(serv, he->h_name, SERVER_LEN - 1);      strncpy(serv, he->h_name, SERVER_LEN - 1);
48    
49      info("Connected to %s.\n", serv);      info("Connected to %s.\n", serv);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26