]> code.citadel.org Git - citadel.git/blob - citadel/imap_fetch.c
* Dammit, I lost my changes
[citadel.git] / citadel / imap_fetch.c
1 /*
2  * $Id$
3  *
4  * Implements the FETCH command in IMAP.
5  * This command is way too convoluted.  Marc Crispin is a fscking idiot.
6  *
7  */
8
9
10 #include "sysdep.h"
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <stdio.h>
14 #include <fcntl.h>
15 #include <signal.h>
16 #include <pwd.h>
17 #include <errno.h>
18 #include <sys/types.h>
19 #include <sys/time.h>
20 #include <sys/wait.h>
21 #include <ctype.h>
22 #include <string.h>
23 #include <limits.h>
24 #include "citadel.h"
25 #include "server.h"
26 #include <time.h>
27 #include "sysdep_decls.h"
28 #include "citserver.h"
29 #include "support.h"
30 #include "config.h"
31 #include "dynloader.h"
32 #include "room_ops.h"
33 #include "user_ops.h"
34 #include "policy.h"
35 #include "database.h"
36 #include "msgbase.h"
37 #include "tools.h"
38 #include "internet_addressing.h"
39 #include "serv_imap.h"
40 #include "imap_tools.h"
41 #include "imap_fetch.h"
42
43
44
45 void imap_do_fetch(int lo, int hi, char *items) {
46 }
47
48
49
50
51 /*
52  * This function is called by the main command loop.
53  */
54 void imap_fetch(int num_parms, char *parms[]) {
55         int lo = 0;
56         int hi = 0;
57         char lostr[1024], histr[1024], items[1024];
58         int i;
59
60         if (num_parms < 4) {
61                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
62                 return;
63         }
64
65         extract_token(lostr, parms[2], 0, ':');
66         lo = atoi(lostr);
67         extract_token(histr, parms[2], 1, ':');
68         hi = atoi(histr);
69
70         if ( (lo < 1) || (hi < 1) || (lo > hi) || (hi > IMAP->num_msgs) ) {
71                 cprintf("%s BAD invalid sequence numbers %d:%d\r\n",
72                         parms[0], lo, hi);
73                 return;
74         }
75
76         strcpy(items, "");
77         for (i=3; i<num_parms; ++i) {
78                 strcat(items, parms[i]);
79                 if (i < (num_parms-1)) strcat(items, " ");
80         }
81
82         imap_do_fetch(lo, hi, items);
83         cprintf("%s OK FETCH completed\r\n", parms[0]);
84 }
85
86
87