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

Diff of /imapfilter/imap.c

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

revision 1.42 by lefcha, Mon Feb 9 22:03:12 2004 UTC revision 1.43 by lefcha, Wed Feb 11 00:03:46 2004 UTC
# Line 6  Line 6 
6  #include "buffer.h"  #include "buffer.h"
7    
8    
9    extern opts_t opts;
10  extern conn_t connpri, connaux;  extern conn_t connpri, connaux;
11    
12  buffer_t obuf;                  /* Output buffer. */  buffer_t obuf;                  /* Output buffer. */
# Line 24  void send_command_cont(conn_t * conn, ch Line 25  void send_command_cont(conn_t * conn, ch
25  unsigned int  unsigned int
26  send_command(conn_t * conn, char *cmd, char *alt)  send_command(conn_t * conn, char *cmd, char *alt)
27  {  {
28    
29          debug("sending command (%s):\n\n%s\n",          debug("sending command (%s):\n\n%s\n",
30              (conn == &connpri ? "primary" : "auxiliary"), (alt ? alt : cmd));              (conn == &connpri ? "primary" : "auxiliary"),
31                (opts.debug == 1 && alt ? alt : cmd));
32    
33          verbose("%s: %s", (conn == &connpri ? "C" : "c"), (alt ? alt : cmd));          verbose("%s: %s", (conn == &connpri ? "C" : "c"), (alt ? alt : cmd));
34    
35          socket_write(conn, cmd);          socket_write(conn, cmd);
# Line 44  send_command(conn_t * conn, char *cmd, c Line 48  send_command(conn_t * conn, char *cmd, c
48  void  void
49  send_command_cont(conn_t * conn, char *cmd)  send_command_cont(conn_t * conn, char *cmd)
50  {  {
51    
52          debug("sending command (%s):\n\n%s\r\n\n",          debug("sending command (%s):\n\n%s\r\n\n",
53              (conn == &connpri ? "primary" : "auxiliary"), cmd);              (conn == &connpri ? "primary" : "auxiliary"), cmd);
54    
# Line 59  send_command_cont(conn_t * conn, char *c Line 64  send_command_cont(conn_t * conn, char *c
64  int  int
65  imap_noop(conn_t * conn)  imap_noop(conn_t * conn)
66  {  {
67    
68          reset_buffer(&obuf);          reset_buffer(&obuf);
69          check_buffer(&obuf, strlen("NOOP") + 12);          check_buffer(&obuf, strlen("NOOP") + 12);
70    
# Line 74  imap_noop(conn_t * conn) Line 80  imap_noop(conn_t * conn)
80  int  int
81  imap_capability(conn_t * conn)  imap_capability(conn_t * conn)
82  {  {
83    
84          reset_buffer(&obuf);          reset_buffer(&obuf);
85          check_buffer(&obuf, strlen("CAPABILITY") + 12);          check_buffer(&obuf, strlen("CAPABILITY") + 12);
86    
# Line 90  imap_capability(conn_t * conn) Line 97  imap_capability(conn_t * conn)
97  int  int
98  imap_namespace(conn_t * conn)  imap_namespace(conn_t * conn)
99  {  {
100    
101          reset_buffer(&obuf);          reset_buffer(&obuf);
102          check_buffer(&obuf, strlen("NAMESPACE") + 12);          check_buffer(&obuf, strlen("NAMESPACE") + 12);
103    
# Line 105  imap_namespace(conn_t * conn) Line 113  imap_namespace(conn_t * conn)
113  int  int
114  imap_logout(conn_t * conn)  imap_logout(conn_t * conn)
115  {  {
116    
117          reset_buffer(&obuf);          reset_buffer(&obuf);
118          check_buffer(&obuf, strlen("LOGOUT") + 12);          check_buffer(&obuf, strlen("LOGOUT") + 12);
119    
# Line 120  imap_logout(conn_t * conn) Line 129  imap_logout(conn_t * conn)
129  int  int
130  imap_starttls(conn_t * conn)  imap_starttls(conn_t * conn)
131  {  {
132    
133          reset_buffer(&obuf);          reset_buffer(&obuf);
134          check_buffer(&obuf, strlen("STARTTLS") + 12);          check_buffer(&obuf, strlen("STARTTLS") + 12);
135    
# Line 137  imap_starttls(conn_t * conn) Line 147  imap_starttls(conn_t * conn)
147  int  int
148  imap_authenticate(conn_t * conn, char *auth, int cont)  imap_authenticate(conn_t * conn, char *auth, int cont)
149  {  {
150    
151          reset_buffer(&obuf);          reset_buffer(&obuf);
152          check_buffer(&obuf, strlen("AUTHENTICATE") + 12);          check_buffer(&obuf, strlen("AUTHENTICATE") + 12);
153    
# Line 169  imap_login(conn_t * conn, char *user, ch Line 180  imap_login(conn_t * conn, char *user, ch
180          /* Alternate command with password shrouded for safe printing. */          /* Alternate command with password shrouded for safe printing. */
181          reset_buffer(&obuf);          reset_buffer(&obuf);
182          check_buffer(&obuf, strlen("LOGIN") + strlen(user) + 18);          check_buffer(&obuf, strlen("LOGIN") + strlen(user) + 18);
183          snprintf(obuf.data, obuf.size, "%04X LOGIN \"%s\" \"\"\r\n", tag, user);          snprintf(obuf.data, obuf.size, "%04X LOGIN \"%s\" *\r\n", tag, user);
184    
185          r = send_command(conn, sbuf, obuf.data);          r = send_command(conn, sbuf, obuf.data);
186    
# Line 185  imap_login(conn_t * conn, char *user, ch Line 196  imap_login(conn_t * conn, char *user, ch
196   *   *
197  int imap_list(conn_t *conn, char *refer, char *mbox)  int imap_list(conn_t *conn, char *refer, char *mbox)
198  {  {
199          int r;  
           
200          reset_buffer(&obuf);          reset_buffer(&obuf);
201          check_buffer(&obuf, strlen("LIST") + strlen(refer) + strlen(mbox) + 18);          check_buffer(&obuf, strlen("LIST") + strlen(refer) + strlen(mbox) + 18);
202                    
203          snprintf(obuf.data, obuf.size, "%04X LIST \"%s\" \"%s\"\r\n", tag,          snprintf(obuf.data, obuf.size, "%04X LIST \"%s\" \"%s\"\r\n", tag,
204              refer, mbox);              refer, mbox);
205    
206          r = send_command(conn, obuf.data, NULL);          return send_command(conn, obuf.data, NULL);
   
         return r;  
207  }*/  }*/
208    
209    
# Line 206  int imap_list(conn_t *conn, char *refer, Line 214  int imap_list(conn_t *conn, char *refer,
214  int  int
215  imap_subscribe(conn_t * conn, char *mbox)  imap_subscribe(conn_t * conn, char *mbox)
216  {  {
217    
218          reset_buffer(&obuf);          reset_buffer(&obuf);
219          check_buffer(&obuf, strlen("SUBSCRIBE") + strlen(mbox) + 15);          check_buffer(&obuf, strlen("SUBSCRIBE") + strlen(mbox) + 15);
220    
# Line 221  imap_subscribe(conn_t * conn, char *mbox Line 230  imap_subscribe(conn_t * conn, char *mbox
230  int  int
231  imap_examine(conn_t *conn, char *mbox)  imap_examine(conn_t *conn, char *mbox)
232  {  {
233    
234          reset_buffer(&obuf);          reset_buffer(&obuf);
235          check_buffer(&obuf, strlen("EXAMINE") + strlen(mbox) + 15);          check_buffer(&obuf, strlen("EXAMINE") + strlen(mbox) + 15);
236    
# Line 236  imap_examine(conn_t *conn, char *mbox) Line 246  imap_examine(conn_t *conn, char *mbox)
246  int  int
247  imap_select(conn_t * conn, char *mbox)  imap_select(conn_t * conn, char *mbox)
248  {  {
249    
250          reset_buffer(&obuf);          reset_buffer(&obuf);
251          check_buffer(&obuf, strlen("SELECT") + strlen(mbox) + 15);          check_buffer(&obuf, strlen("SELECT") + strlen(mbox) + 15);
252    
# Line 251  imap_select(conn_t * conn, char *mbox) Line 262  imap_select(conn_t * conn, char *mbox)
262  int  int
263  imap_status(conn_t * conn, char *mbox, char *items)  imap_status(conn_t * conn, char *mbox, char *items)
264  {  {
265    
266          reset_buffer(&obuf);          reset_buffer(&obuf);
267          check_buffer(&obuf, strlen("STATUS") + strlen(mbox) +          check_buffer(&obuf, strlen("STATUS") + strlen(mbox) +
268              strlen(items) + 18);              strlen(items) + 18);
# Line 267  imap_status(conn_t * conn, char *mbox, c Line 279  imap_status(conn_t * conn, char *mbox, c
279  int  int
280  imap_create(conn_t * conn, char *mbox)  imap_create(conn_t * conn, char *mbox)
281  {  {
282    
283          reset_buffer(&obuf);          reset_buffer(&obuf);
284          check_buffer(&obuf, strlen("CREATE") + strlen(mbox) + 14);          check_buffer(&obuf, strlen("CREATE") + strlen(mbox) + 14);
285    
# Line 282  imap_create(conn_t * conn, char *mbox) Line 295  imap_create(conn_t * conn, char *mbox)
295  int  int
296  imap_search(conn_t * conn, char *charset, char *search)  imap_search(conn_t * conn, char *charset, char *search)
297  {  {
298    
299          reset_buffer(&obuf);          reset_buffer(&obuf);
300          check_buffer(&obuf, strlen("SEARCH CHARSET") + strlen(charset) +          check_buffer(&obuf, strlen("SEARCH CHARSET") + strlen(charset) +
301              strlen(search) + 15);              strlen(search) + 15);
# Line 302  imap_search(conn_t * conn, char *charset Line 316  imap_search(conn_t * conn, char *charset
316  int  int
317  imap_fetch(conn_t * conn, char *mesg, char *items)  imap_fetch(conn_t * conn, char *mesg, char *items)
318  {  {
319    
320          reset_buffer(&obuf);          reset_buffer(&obuf);
321          check_buffer(&obuf, strlen("FETCH") + strlen(mesg) + strlen(items) + 14);          check_buffer(&obuf, strlen("FETCH") + strlen(mesg) + strlen(items) + 14);
322    
# Line 317  imap_fetch(conn_t * conn, char *mesg, ch Line 332  imap_fetch(conn_t * conn, char *mesg, ch
332  int  int
333  imap_store(conn_t * conn, char *mesg, unsigned int mode, char *flags)  imap_store(conn_t * conn, char *mesg, unsigned int mode, char *flags)
334  {  {
335    
336          reset_buffer(&obuf);          reset_buffer(&obuf);
337          check_buffer(&obuf, strlen("STORE") + strlen(mesg) +          check_buffer(&obuf, strlen("STORE") + strlen(mesg) +
338              strlen("FLAGS.SILENT") + strlen(flags) + 18);              strlen("FLAGS.SILENT") + strlen(flags) + 18);
# Line 335  imap_store(conn_t * conn, char *mesg, un Line 351  imap_store(conn_t * conn, char *mesg, un
351  int  int
352  imap_copy(conn_t * conn, char *mesg, char *mbox)  imap_copy(conn_t * conn, char *mesg, char *mbox)
353  {  {
354    
355          reset_buffer(&obuf);          reset_buffer(&obuf);
356          check_buffer(&obuf, strlen("COPY") + strlen(mesg) + strlen(mbox) + 16);          check_buffer(&obuf, strlen("COPY") + strlen(mesg) + strlen(mbox) + 16);
357    
# Line 350  imap_copy(conn_t * conn, char *mesg, cha Line 367  imap_copy(conn_t * conn, char *mesg, cha
367  int  int
368  imap_append(conn_t * conn, char *mbox, char *flags, char *date, unsigned int size)  imap_append(conn_t * conn, char *mbox, char *flags, char *date, unsigned int size)
369  {  {
370    
371          reset_buffer(&obuf);          reset_buffer(&obuf);
372          check_buffer(&obuf, strlen("APPEND") + strlen(mbox) + strlen(flags) +          check_buffer(&obuf, strlen("APPEND") + strlen(mbox) + strlen(flags) +
373              strlen(date) + strlen(ultostr(size, 10)) + 24);              strlen(date) + strlen(ultostr(size, 10)) + 24);
# Line 368  imap_append(conn_t * conn, char *mbox, c Line 386  imap_append(conn_t * conn, char *mbox, c
386  int  int
387  imap_close(conn_t * conn)  imap_close(conn_t * conn)
388  {  {
389    
390          reset_buffer(&obuf);          reset_buffer(&obuf);
391          check_buffer(&obuf, strlen("CLOSE") + 12);          check_buffer(&obuf, strlen("CLOSE") + 12);
392    
# Line 383  imap_close(conn_t * conn) Line 402  imap_close(conn_t * conn)
402  int  int
403  imap_expunge(conn_t * conn)  imap_expunge(conn_t * conn)
404  {  {
405    
406          reset_buffer(&obuf);          reset_buffer(&obuf);
407          check_buffer(&obuf, strlen("EXPUNGE") + 12);          check_buffer(&obuf, strlen("EXPUNGE") + 12);
408    

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26