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

Diff of /imapfilter/response.c

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

revision 1.25 by lefcha, Mon Aug 26 20:35:17 2002 UTC revision 1.26 by lefcha, Thu Aug 29 19:51:24 2002 UTC
# Line 7  Line 7 
7  #include <sys/time.h>  #include <sys/time.h>
8  #include <sys/types.h>  #include <sys/types.h>
9  #include <regex.h>  #include <regex.h>
10    #include <setjmp.h>
11    
12  #include "config.h"  #include "config.h"
13  #include "imapfilter.h"  #include "imapfilter.h"
# Line 14  Line 15 
15    
16  extern int sockpri;  extern int sockpri;
17  extern unsigned int capabilities;  extern unsigned int capabilities;
18    extern jmp_buf acctloop;
19    
20  static char *vbuf = NULL;       /* Virtual buffer. */  static char *vbuf = NULL;       /* Virtual buffer. */
21  static size_t vbufs = 0;        /* Virtual buffer size. */  static size_t vbufs = 0;        /* Virtual buffer size. */
# Line 44  int server_response(int *sock, unsigned Line 46  int server_response(int *sock, unsigned
46    
47      do {      do {
48          receive_response(sock, buf);          receive_response(sock, buf);
49            bye_response(buf);
50          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
51          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
52      } while (tag && !strcasestr(buf, ultostr(tag, 16)));      } while (tag && !strcasestr(buf, ultostr(tag, 16)));
# Line 53  int server_response(int *sock, unsigned Line 56  int server_response(int *sock, unsigned
56    
57    
58  /*  /*
59     * Check if server sent a BYE response (connection is closed immediately).
60     */
61    void bye_response(char *buf)
62    {
63        if (strcasestr(buf, "* BYE"))
64            longjmp(acctloop, -1);
65    }
66    
67    
68    /*
69   * Process the greeting that server sends during connection.   * Process the greeting that server sends during connection.
70   */   */
71  int greeting_response(int *sock)  int greeting_response(int *sock)
# Line 60  int greeting_response(int *sock) Line 73  int greeting_response(int *sock)
73      char buf[RESPONSE_BUF];      char buf[RESPONSE_BUF];
74    
75      receive_response(sock, buf);      receive_response(sock, buf);
76        bye_response(buf);
77    
78      if (strcasestr(buf, "* BYE"))      if (strcasestr(buf, "* PREAUTH"))
         return RESPONSE_BYE;  
     else if (strcasestr(buf, "* PREAUTH"))  
79          return RESPONSE_PREAUTH;          return RESPONSE_PREAUTH;
80    
81      return RESPONSE_OK;      return RESPONSE_OK;
# Line 100  int capability_response(int *sock, unsig Line 112  int capability_response(int *sock, unsig
112    
113      do {      do {
114          receive_response(sock, buf);          receive_response(sock, buf);
115            bye_response(buf);
116          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
117          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
118      } while (!strcasestr(buf, ultostr(tag, 16)));      } while (!strcasestr(buf, ultostr(tag, 16)));
# Line 127  int namespace_response(int *sock, unsign Line 140  int namespace_response(int *sock, unsign
140    
141      do {      do {
142          receive_response(sock, buf);          receive_response(sock, buf);
143            bye_response(buf);
144          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
145          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
146      } while (!strcasestr(buf, ultostr(tag, 16)));      } while (!strcasestr(buf, ultostr(tag, 16)));
# Line 164  int status_response(int *sock, unsigned Line 178  int status_response(int *sock, unsigned
178    
179      do {      do {
180          receive_response(sock, buf);          receive_response(sock, buf);
181            bye_response(buf);
182          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
183          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
184      } while (!strcasestr(buf, ultostr(tag, 16)));      } while (!strcasestr(buf, ultostr(tag, 16)));
# Line 207  int select_response(int *sock, unsigned Line 222  int select_response(int *sock, unsigned
222    
223      do {      do {
224          receive_response(sock, buf);          receive_response(sock, buf);
225            bye_response(buf);
226          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
227          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
228      } while (!strcasestr(buf, ultostr(tag, 16)));      } while (!strcasestr(buf, ultostr(tag, 16)));
# Line 231  int search_response(int *sock, unsigned Line 247  int search_response(int *sock, unsigned
247    
248      do {      do {
249          receive_response(sock, buf);          receive_response(sock, buf);
250            bye_response(buf);
251          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
252          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
253      } while (!strcasestr(buf, ultostr(tag, 16)));      } while (!strcasestr(buf, ultostr(tag, 16)));
# Line 268  int fetch_response(int *sock, int reset, Line 285  int fetch_response(int *sock, int reset,
285      i = 0;      i = 0;
286    
287      receive_response(sock, buf);      receive_response(sock, buf);
288        bye_response(buf);
289    
290      b = buf;      b = buf;
291    
# Line 302  int fetchsize_response(int *sock, unsign Line 320  int fetchsize_response(int *sock, unsign
320    
321      do {      do {
322          receive_response(sock, buf);          receive_response(sock, buf);
323            bye_response(buf);
324          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
325          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
326      } while (!strcasestr(buf, ultostr(tag, 16)));      } while (!strcasestr(buf, ultostr(tag, 16)));
# Line 326  int append_response(int *sock, unsigned Line 345  int append_response(int *sock, unsigned
345    
346      do {      do {
347          receive_response(sock, buf);          receive_response(sock, buf);
348            bye_response(buf);
349          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
350          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
351      } while (!strcasestr(buf, ultostr(tag, 16)));      } while (!strcasestr(buf, ultostr(tag, 16)));
# Line 350  int copy_response(int *sock, unsigned in Line 370  int copy_response(int *sock, unsigned in
370    
371      do {      do {
372          receive_response(sock, buf);          receive_response(sock, buf);
373            bye_response(buf);
374          check_vbuf(strlen(buf));          check_vbuf(strlen(buf));
375          strncat(vbuf, buf, vbufs - strlen(vbuf));          strncat(vbuf, buf, vbufs - strlen(vbuf));
376      } while (!strcasestr(buf, ultostr(tag, 16)));      } while (!strcasestr(buf, ultostr(tag, 16)));

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26