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

Diff of /imapfilter/socket.c

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

revision 1.24 by lefcha, Sat Feb 1 19:44:40 2003 UTC revision 1.25 by lefcha, Fri Feb 21 18:54:18 2003 UTC
# Line 29  static SSL *sslaux = NULL; Line 29  static SSL *sslaux = NULL;
29  #endif  #endif
30    
31    
32    
33  /*  /*
34   * Connect to mail server.   * Connect to mail server.
35   */   */
# Line 169  int ssl_init(int *sock, unsigned int pro Line 170  int ssl_init(int *sock, unsigned int pro
170      return 0;      return 0;
171  }  }
172    
173  #endif  #endif                          /* SSL_TLS */
174    
175    
176  /*  /*
# Line 242  int socket_read(int *sock, char *buf) Line 243  int socket_read(int *sock, char *buf)
243              case SSL_ERROR_WANT_READ:              case SSL_ERROR_WANT_READ:
244              case SSL_ERROR_WANT_WRITE:              case SSL_ERROR_WANT_WRITE:
245                  continue;                  continue;
246                case SSL_ERROR_ZERO_RETURN:
247                    return ERROR_NETWORK;
248              case SSL_ERROR_SYSCALL:              case SSL_ERROR_SYSCALL:
249              case SSL_ERROR_SSL:              case SSL_ERROR_SSL:
250                  fatal(ERROR_NETWORK, "imapfilter: reading data; %s",                  fatal(ERROR_NETWORK, "imapfilter: reading data; %s",
# Line 253  int socket_read(int *sock, char *buf) Line 256  int socket_read(int *sock, char *buf)
256          }          }
257      } else      } else
258  #endif  #endif
259        {
260          if ((s = select(*sock + 1, &fds, NULL, NULL, tvp)) > 0 &&          if ((s = select(*sock + 1, &fds, NULL, NULL, tvp)) > 0 &&
261              FD_ISSET(*sock, &fds))              FD_ISSET(*sock, &fds))
262          e = read(*sock, buf, RESPONSE_BUF - 1);          e = read(*sock, buf, RESPONSE_BUF - 1);
263            
264      if (e == -1)          if (e == -1)
265          fatal(ERROR_NETWORK, "imapfilter: reading data; %s",              fatal(ERROR_NETWORK, "imapfilter: reading data; %s",
266                strerror(errno));                    strerror(errno));
267            else if (e == 0)
268                return ERROR_NETWORK;
269        }
270    
271      fcntl(*sock, F_SETFL, f);      fcntl(*sock, F_SETFL, f);
272    
273      if (s == -1)      if (s == -1)
274          fatal(ERROR_NETWORK, "imapfilter: waiting to read from socket; %s\n",          fatal(ERROR_NETWORK, "imapfilter: waiting to read from socket; %s\n",
275                strerror(errno));                strerror(errno));
276      else if (!s)      else if (s == 0)
277          fatal(ERROR_NETWORK,          fatal(ERROR_NETWORK,
278                "imapfilter: timeout period expired while waiting to read "                "imapfilter: timeout period expired while waiting to read "
279                "data\n");                "data\n");
# Line 316  int socket_write(int *sock, char *data) Line 323  int socket_write(int *sock, char *data)
323              case SSL_ERROR_WANT_READ:              case SSL_ERROR_WANT_READ:
324              case SSL_ERROR_WANT_WRITE:              case SSL_ERROR_WANT_WRITE:
325                  continue;                  continue;
326                case SSL_ERROR_ZERO_RETURN:
327                    return ERROR_NETWORK;
328              case SSL_ERROR_SYSCALL:              case SSL_ERROR_SYSCALL:
329              case SSL_ERROR_SSL:              case SSL_ERROR_SSL:
330                  fatal(ERROR_NETWORK, "imapfilter: writing data; %s",                  fatal(ERROR_NETWORK, "imapfilter: writing data; %s",
# Line 327  int socket_write(int *sock, char *data) Line 336  int socket_write(int *sock, char *data)
336          }          }
337      } else      } else
338  #endif  #endif
339        {
340          if ((s = select(*sock + 1, NULL, &fds, NULL, tvp)) > 0 &&          if ((s = select(*sock + 1, NULL, &fds, NULL, tvp)) > 0 &&
341              FD_ISSET(*sock, &fds))              FD_ISSET(*sock, &fds))
342          e = write(*sock, data, strlen(data));              e = write(*sock, data, strlen(data));
343            
344      if (e == -1)          if (e == -1)
345          fatal(ERROR_NETWORK, "imapfilter: writing data; %s",              fatal(ERROR_NETWORK, "imapfilter: writing data; %s",
346                strerror(errno));                    strerror(errno));
347        }
348    
349      fcntl(*sock, F_SETFL, f);      fcntl(*sock, F_SETFL, f);
350    
351      if (s == -1)      if (s == -1)
352          fatal(ERROR_NETWORK, "imapfilter: waiting to write to socket; %s\n",          fatal(ERROR_NETWORK, "imapfilter: waiting to write to socket; %s\n",
353                strerror(errno));                strerror(errno));
354      else if (!s)      else if (s == 0)
355          fatal(ERROR_NETWORK,          fatal(ERROR_NETWORK,
356                "imapfilter: timeout period expired while waiting to write "                "imapfilter: timeout period expired while waiting to write "
357                "data\n");                "data\n");

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26