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

Diff of /imapfilter/response.c

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

revision 1.34 by lefcha, Sat Mar 15 18:39:55 2003 UTC revision 1.35 by lefcha, Fri Mar 28 17:02:19 2003 UTC
# Line 45  receive_response(int *sock, char *buf) Line 45  receive_response(int *sock, char *buf)
45  int  int
46  server_response(int *sock, unsigned int tag)  server_response(int *sock, unsigned int tag)
47  {  {
48          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
49    
50          reset_vbuf();          reset_vbuf();
51    
# Line 56  server_response(int *sock, unsigned int Line 56  server_response(int *sock, unsigned int
56                  strncat(vbuf, buf, vbufs - strlen(vbuf));                  strncat(vbuf, buf, vbufs - strlen(vbuf));
57          } while (!strcasestr(buf, ultostr(tag, 16)));          } while (!strcasestr(buf, ultostr(tag, 16)));
58    
59          return analyze_response(buf);          return analyze_response(sock, buf);
60  }  }
61    
62    
# Line 77  bye_response(char *buf) Line 77  bye_response(char *buf)
77  int  int
78  greeting_response(int *sock)  greeting_response(int *sock)
79  {  {
80          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
81    
82          receive_response(sock, buf);          receive_response(sock, buf);
83    
84            verbose("%s: %s", (sock == &sockpri ? "S" : "s"), buf);
85    
86          bye_response(buf);          bye_response(buf);
87    
88          if (strcasestr(buf, "* PREAUTH"))          if (strcasestr(buf, "* PREAUTH"))
# Line 95  greeting_response(int *sock) Line 98  greeting_response(int *sock)
98  int  int
99  logout_response(int *sock, unsigned int tag)  logout_response(int *sock, unsigned int tag)
100  {  {
101          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
102    
103          reset_vbuf();          reset_vbuf();
104    
# Line 105  logout_response(int *sock, unsigned int Line 108  logout_response(int *sock, unsigned int
108                  strncat(vbuf, buf, vbufs - strlen(vbuf));                  strncat(vbuf, buf, vbufs - strlen(vbuf));
109          } while (!strcasestr(buf, ultostr(tag, 16)));          } while (!strcasestr(buf, ultostr(tag, 16)));
110    
111          return analyze_response(buf);          return analyze_response(sock, buf);
112  }  }
113    
114    
# Line 115  logout_response(int *sock, unsigned int Line 118  logout_response(int *sock, unsigned int
118  int  int
119  capability_response(int *sock, unsigned int tag)  capability_response(int *sock, unsigned int tag)
120  {  {
121          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
122    
123          reset_vbuf();          reset_vbuf();
124    
# Line 135  capability_response(int *sock, unsigned Line 138  capability_response(int *sock, unsigned
138    
139          auth_mechanisms();          auth_mechanisms();
140    
141          return analyze_response(buf);          return analyze_response(sock, buf);
142  }  }
143    
144    
# Line 181  auth_mechanisms(void) Line 184  auth_mechanisms(void)
184  int  int
185  namespace_response(int *sock, unsigned int tag, namesp_t * nsp)  namespace_response(int *sock, unsigned int tag, namesp_t * nsp)
186  {  {
187          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
188          char *c, *d;          char *c, *d;
189    
190          reset_vbuf();          reset_vbuf();
# Line 208  namespace_response(int *sock, unsigned i Line 211  namespace_response(int *sock, unsigned i
211              (sock == &sockpri ? "primary" : "auxiliary"), nsp->prefix,              (sock == &sockpri ? "primary" : "auxiliary"), nsp->prefix,
212              nsp->delim);              nsp->delim);
213  #endif  #endif
214          return analyze_response(buf);          return analyze_response(sock, buf);
215  }  }
216    
217    
# Line 219  int Line 222  int
222  status_response(int *sock, unsigned int tag, char *mbox)  status_response(int *sock, unsigned int tag, char *mbox)
223  {  {
224          int r;          int r;
225          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
226          unsigned int exist, recent, unseen;          unsigned int exist, recent, unseen;
227          char *c;          char *c;
228    
# Line 234  status_response(int *sock, unsigned int Line 237  status_response(int *sock, unsigned int
237                  strncat(vbuf, buf, vbufs - strlen(vbuf));                  strncat(vbuf, buf, vbufs - strlen(vbuf));
238          } while (!strcasestr(buf, ultostr(tag, 16)));          } while (!strcasestr(buf, ultostr(tag, 16)));
239    
240          r = analyze_response(buf);          r = analyze_response(sock, buf);
241    
242          if (r == RESPONSE_NO)          if (r == RESPONSE_NO)
243                  return -2;                  return -2;
# Line 268  status_response(int *sock, unsigned int Line 271  status_response(int *sock, unsigned int
271  int  int
272  select_response(int *sock, unsigned int tag)  select_response(int *sock, unsigned int tag)
273  {  {
274          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
275    
276          reset_vbuf();          reset_vbuf();
277    
# Line 282  select_response(int *sock, unsigned int Line 285  select_response(int *sock, unsigned int
285          if (strcasestr(vbuf, "[READ-ONLY]"))          if (strcasestr(vbuf, "[READ-ONLY]"))
286                  return RESPONSE_READONLY;                  return RESPONSE_READONLY;
287    
288          return analyze_response(buf);          return analyze_response(sock, buf);
289  }  }
290    
291    
# Line 292  select_response(int *sock, unsigned int Line 295  select_response(int *sock, unsigned int
295  int  int
296  search_response(int *sock, unsigned int tag, char **mesgs)  search_response(int *sock, unsigned int tag, char **mesgs)
297  {  {
298          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
299          char *c, *m;          char *c, *m;
300          unsigned int blen;          unsigned int blen;
301    
# Line 317  search_response(int *sock, unsigned int Line 320  search_response(int *sock, unsigned int
320    
321                  *m = 0;                  *m = 0;
322          }          }
323          return analyze_response(buf);          return analyze_response(sock, buf);
324  }  }
325    
326    
# Line 327  search_response(int *sock, unsigned int Line 330  search_response(int *sock, unsigned int
330  int  int
331  fetch_response(int *sock, unsigned int tag, int reset, char *fetch)  fetch_response(int *sock, unsigned int tag, int reset, char *fetch)
332  {  {
333          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
334          unsigned int i;          unsigned int i;
335          static unsigned int s;          static unsigned int s;
336          char *b;          char *b;
# Line 367  fetch_response(int *sock, unsigned int t Line 370  fetch_response(int *sock, unsigned int t
370    
371          fetch[i] = '\0';          fetch[i] = '\0';
372    
373          return analyze_response(buf);          return analyze_response(sock, buf);
374  }  }
375    
376    
# Line 378  fetch_response(int *sock, unsigned int t Line 381  fetch_response(int *sock, unsigned int t
381  int  int
382  fetchsize_response(int *sock, unsigned int *size, unsigned int tag)  fetchsize_response(int *sock, unsigned int *size, unsigned int tag)
383  {  {
384          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
385          char *c;          char *c;
386    
387          *size = 0;          *size = 0;
# Line 396  fetchsize_response(int *sock, unsigned i Line 399  fetchsize_response(int *sock, unsigned i
399                  c += 19;                  c += 19;
400                  *size = strtoul(c, NULL, 10);                  *size = strtoul(c, NULL, 10);
401          }          }
402          return analyze_response(buf);          return analyze_response(sock, buf);
403  }  }
404    
405    
# Line 407  int Line 410  int
410  append_response(int *sock, unsigned int tag)  append_response(int *sock, unsigned int tag)
411  {  {
412          int r;          int r;
413          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
414    
415          r = RESPONSE_OK;          r = RESPONSE_OK;
416    
# Line 420  append_response(int *sock, unsigned int Line 423  append_response(int *sock, unsigned int
423                  strncat(vbuf, buf, vbufs - strlen(vbuf));                  strncat(vbuf, buf, vbufs - strlen(vbuf));
424          } while (!strcasestr(buf, ultostr(tag, 16)));          } while (!strcasestr(buf, ultostr(tag, 16)));
425    
426          if ((r = analyze_response(buf)) == RESPONSE_NO &&          if ((r = analyze_response(sock, buf)) == RESPONSE_NO &&
427              strcasestr(vbuf, "[TRYCREATE]"))              strcasestr(vbuf, "[TRYCREATE]"))
428                  return RESPONSE_TRYCREATE;                  return RESPONSE_TRYCREATE;
429    
# Line 435  int Line 438  int
438  copy_response(int *sock, unsigned int tag)  copy_response(int *sock, unsigned int tag)
439  {  {
440          int r;          int r;
441          char buf[RESPONSE_BUF];          char buf[RESPONSE_BUF + 1];
442    
443          r = RESPONSE_OK;          r = RESPONSE_OK;
444    
# Line 448  copy_response(int *sock, unsigned int ta Line 451  copy_response(int *sock, unsigned int ta
451                  strncat(vbuf, buf, vbufs - strlen(vbuf));                  strncat(vbuf, buf, vbufs - strlen(vbuf));
452          } while (!strcasestr(buf, ultostr(tag, 16)));          } while (!strcasestr(buf, ultostr(tag, 16)));
453    
454          if ((r = analyze_response(buf)) == RESPONSE_NO &&          if ((r = analyze_response(sock, buf)) == RESPONSE_NO &&
455              strcasestr(vbuf, "[TRYCREATE]"))              strcasestr(vbuf, "[TRYCREATE]"))
456                  return RESPONSE_TRYCREATE;                  return RESPONSE_TRYCREATE;
457    
# Line 461  copy_response(int *sock, unsigned int ta Line 464  copy_response(int *sock, unsigned int ta
464   * delivered or there was some kind of error.   * delivered or there was some kind of error.
465   */   */
466  int  int
467  analyze_response(char *buf)  analyze_response(int *sock, char *buf)
468  {  {
469          int r;          int r;
470          regex_t creg;          regex_t creg;
# Line 484  analyze_response(char *buf) Line 487  analyze_response(char *buf)
487                  else if (!strncasecmp(buf + match[2].rm_so, "BAD", 3))                  else if (!strncasecmp(buf + match[2].rm_so, "BAD", 3))
488                          r = RESPONSE_BAD;                          r = RESPONSE_BAD;
489    
490                  verbose("Server response: %s\n", result);                  verbose("%s: %s", (sock == &sockpri ? "S" : "s"),
491                        buf + match[0].rm_so);
492          } else          } else
493                  r = RESPONSE_NONE;                  r = RESPONSE_NONE;
494    

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26