annotate src/pop3/commands.c @ 1672:8920600a8cfc HEAD

Index cache file rewrite. It's not finished yet and mbox support is completely broken. But it's getting difficult to maintain outside cvs :)
author Timo Sirainen <tss@iki.fi>
date Wed, 06 Aug 2003 23:15:30 +0300
parents db14aa8e2b5c
children bd8b6ed35327
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 /* Copyright (C) 2002 Timo Sirainen */
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "common.h"
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
4 #include "istream.h"
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
5 #include "ostream.h"
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "str.h"
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "message-size.h"
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "mail-storage.h"
1059
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
9 #include "capability.h"
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 #include "commands.h"
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 #define MSGS_BITMASK_SIZE(client) \
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 ((client->messages_count + (CHAR_BIT-1)) / CHAR_BIT)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 static const char *get_msgnum(struct client *client, const char *args,
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 unsigned int *msgnum)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 unsigned int num, last_num;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 num = 0;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 while (*args != '\0' && *args != ' ') {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 if (*args < '0' || *args > '9') {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23 client_send_line(client,
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 "-ERR Invalid message number: %s", args);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 return NULL;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28 last_num = num;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29 num = num*10 + (*args - '0');
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30 if (num < last_num) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31 client_send_line(client,
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
32 "-ERR Message number too large: %s", args);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 return NULL;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 args++;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
36 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
38 if (num == 0 || num > client->messages_count) {
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 client_send_line(client,
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
40 "-ERR There's no message %u.", num);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 return NULL;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42 }
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
43 num--;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 if (client->deleted) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46 if (client->deleted_bitmask[num / CHAR_BIT] &
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47 (1 << (num % CHAR_BIT))) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 client_send_line(client, "-ERR Message is deleted.");
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 return NULL;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 while (*args == ' ') args++;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55 *msgnum = num;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56 return args;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
57 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
58
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
59 static const char *get_size(struct client *client, const char *args,
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60 uoff_t *size)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
61 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
62 uoff_t num, last_num;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
63
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
64 num = 0;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65 while (*args != '\0' && *args != ' ') {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
66 if (*args < '0' || *args > '9') {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
67 client_send_line(client, "-ERR Invalid size: %s",
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
68 args);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
69 return NULL;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
70 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72 last_num = num;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73 num = num*10 + (*args - '0');
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
74 if (num < last_num) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
75 client_send_line(client, "-ERR Size too large: %s",
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
76 args);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
77 return NULL;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 args++;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
80 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
81
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
82 while (*args == ' ') args++;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
83
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
84 *size = num;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
85 return args;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
87
1059
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
88 static int cmd_capa(struct client *client, const char *args __attr_unused__)
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
89 {
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
90 client_send_line(client, "+OK\r\n"POP3_CAPABILITY_REPLY".");
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
91 return TRUE;
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
92 }
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
93
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
94 static int cmd_dele(struct client *client, const char *args)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
95 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
96 unsigned int msgnum;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
97
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
98 if (get_msgnum(client, args, &msgnum) == NULL)
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
99 return FALSE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
100
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
101 if (!client->deleted) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
102 client->deleted_bitmask = i_malloc(MSGS_BITMASK_SIZE(client));
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
103 client->deleted = TRUE;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
104 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
105
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
106 client->deleted_bitmask[msgnum / CHAR_BIT] |= 1 << (msgnum % CHAR_BIT);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
107 client_send_line(client, "+OK Marked to be deleted.");
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
108 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
109 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
110
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
111 static int cmd_list(struct client *client, const char *args)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
112 {
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
113 unsigned int i;
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
114
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
115 if (*args == '\0') {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
116 client_send_line(client, "+OK %u messages:",
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
117 client->messages_count);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
118 for (i = 0; i < client->messages_count; i++) {
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
119 client_send_line(client, "%u %"PRIuUOFF_T,
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
120 i+1, client->message_sizes[i]);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
121 }
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
122 client_send_line(client, ".");
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
123 } else {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124 unsigned int msgnum;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
125
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
126 if (get_msgnum(client, args, &msgnum) == NULL)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
127 return FALSE;
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
128
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
129 client_send_line(client, "+OK %u %"PRIuUOFF_T, msgnum+1,
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
130 client->message_sizes[msgnum]);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
131 }
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
132
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
133 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
134 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
135
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
136 static int cmd_noop(struct client *client, const char *args __attr_unused__)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
137 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
138 client_send_line(client, "+OK");
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
139 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
140 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
141
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
142 static int expunge_mails(struct client *client, struct mailbox *box)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
143 {
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
144 struct mail_expunge_context *ctx;
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
145 struct mail *mail;
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
146 unsigned int i, j;
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
147 int failed = FALSE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
148
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
149 /* NOTE: if there's any external expunges, they'll get synced here.
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
150 Currently we update only the deleted_bitmask[] so we don't end up
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
151 expunging wrong messages, but message_sizes[] isn't updated. */
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
152 ctx = box->expunge_init(box, 0, TRUE);
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
153 if (ctx == NULL)
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
154 return FALSE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
155
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
156 i = j = 0;
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
157 while ((mail = box->expunge_fetch_next(ctx)) != NULL) {
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
158 if ((client->deleted_bitmask[i] & (1 << j)) != 0) {
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
159 if (!mail->expunge(mail, ctx, NULL, FALSE)) {
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
160 failed = TRUE;
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
161 break;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
162 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
163 }
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
164 if (++j == CHAR_BIT) {
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
165 j = 0; i++;
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
166 }
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
167 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
168
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
169 if (!box->expunge_deinit(ctx))
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
170 return FALSE;
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
171
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
172 return !failed;
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
173 }
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
174
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
175 static int cmd_quit(struct client *client, const char *args __attr_unused__)
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
176 {
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
177 if (!client->deleted)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
178 client_send_line(client, "+OK Logging out.");
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
179 else if (expunge_mails(client, client->mailbox))
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
180 client_send_line(client, "+OK Logging out, messages deleted.");
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
181 else
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
182 client_send_storage_error(client);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
183
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
184 client_disconnect(client);
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
185 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
186 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
187
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
188 static void stream_send_escaped(struct ostream *output, struct istream *input,
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
189 uoff_t body_lines)
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
190 {
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
191 const unsigned char *data;
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
192 unsigned char last, add;
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
193 size_t i, size;
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
194 int cr_skipped, in_header;
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
195
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
196 if (body_lines != (uoff_t)-1)
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
197 body_lines++; /* internally we count the empty line too */
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
198
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
199 cr_skipped = FALSE; in_header = TRUE; last = '\0';
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
200 while ((body_lines > 0 || in_header) &&
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
201 i_stream_read_data(input, &data, &size, 0) > 0) {
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
202 add = '\0';
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
203 for (i = 0; i < size; i++) {
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
204 if (in_header && (data[i] == '\r' || data[i] == '\n')) {
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
205 if (i == 0 && (last == '\0' || last == '\n'))
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
206 in_header = FALSE;
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
207 else if (i > 0 && data[i-1] == '\n')
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
208 in_header = FALSE;
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
209 }
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
210
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
211 if (data[i] == '\n') {
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
212 if ((i == 0 && last != '\r') ||
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
213 (i > 0 && data[i-1] != '\r')) {
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
214 /* missing CR */
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
215 add = '\r';
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
216 break;
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
217 }
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
218
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
219 if (!in_header) {
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
220 if (--body_lines == 0) {
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
221 i++;
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
222 break;
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
223 }
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
224 }
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
225 } else if (data[i] == '.' &&
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
226 ((i == 0 && last == '\n') ||
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
227 (i > 0 && data[i-1] == '\n'))) {
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
228 /* escape the dot */
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
229 add = '.';
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
230 i++;
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
231 break;
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
232 }
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
233 }
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
234
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
235 if (o_stream_send(output, data, i) < 0)
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
236 return;
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
237
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
238 if (add != '\0') {
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
239 if (o_stream_send(output, &add, 1) < 0)
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
240 return;
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
241 last = add;
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
242 } else {
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
243 last = data[i-1];
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
244 }
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
245
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
246 i_stream_skip(input, i);
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
247 }
1507
1fad8b3d7ef1 If mail didn't end with linefeed, we sent it wrong.
Timo Sirainen <tss@iki.fi>
parents: 1071
diff changeset
248
1fad8b3d7ef1 If mail didn't end with linefeed, we sent it wrong.
Timo Sirainen <tss@iki.fi>
parents: 1071
diff changeset
249 if (last != '\n') {
1fad8b3d7ef1 If mail didn't end with linefeed, we sent it wrong.
Timo Sirainen <tss@iki.fi>
parents: 1071
diff changeset
250 /* didn't end with CRLF */
1fad8b3d7ef1 If mail didn't end with linefeed, we sent it wrong.
Timo Sirainen <tss@iki.fi>
parents: 1071
diff changeset
251 (void)o_stream_send(output, "\r\n", 2);
1fad8b3d7ef1 If mail didn't end with linefeed, we sent it wrong.
Timo Sirainen <tss@iki.fi>
parents: 1071
diff changeset
252 }
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
253 }
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
254
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
255 static void fetch(struct client *client, unsigned int msgnum,
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
256 uoff_t body_lines)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
257 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
258 struct mail_fetch_context *ctx;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
259 struct mail *mail;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
260 struct istream *stream;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
261
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
262 ctx = client->mailbox->fetch_init(client->mailbox,
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
263 MAIL_FETCH_STREAM_HEADER |
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1640
diff changeset
264 MAIL_FETCH_STREAM_BODY, NULL,
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
265 dec2str(msgnum+1), FALSE);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
266 if (ctx == NULL) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
267 client_send_storage_error(client);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
268 return;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
269 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
270
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
271 mail = client->mailbox->fetch_next(ctx);
1071
d71e0aa00d75 Don't crash if we couldn't open message.
Timo Sirainen <tss@iki.fi>
parents: 1059
diff changeset
272 stream = mail == NULL ? NULL : mail->get_stream(mail, NULL, NULL);
d71e0aa00d75 Don't crash if we couldn't open message.
Timo Sirainen <tss@iki.fi>
parents: 1059
diff changeset
273 if (stream == NULL)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
274 client_send_line(client, "-ERR Message not found.");
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
275 else {
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
276 if (body_lines == (uoff_t)-1) {
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
277 client_send_line(client, "+OK %"PRIuUOFF_T" octets",
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
278 client->message_sizes[msgnum]);
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
279 } else {
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
280 client_send_line(client, "+OK");
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
281 }
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
282
1051
5c76c96f745f bugfixes
Timo Sirainen <tss@iki.fi>
parents: 1045
diff changeset
283 stream_send_escaped(client->output, stream, body_lines);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
284 client_send_line(client, ".");
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
285 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
286
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
287 (void)client->mailbox->fetch_deinit(ctx, NULL);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
288 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
289
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
290 static int cmd_retr(struct client *client, const char *args)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
291 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
292 unsigned int msgnum;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
293
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
294 if (get_msgnum(client, args, &msgnum) == NULL)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
295 return FALSE;
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
296
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
297 fetch(client, msgnum, (uoff_t)-1);
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
298 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
299 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
300
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
301 static int cmd_rset(struct client *client, const char *args __attr_unused__)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
302 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
303 if (client->deleted) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
304 client->deleted = FALSE;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
305 memset(client->deleted_bitmask, 0, MSGS_BITMASK_SIZE(client));
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
306 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
307
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
308 client_send_line(client, "+OK");
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
309 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
310 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
311
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
312 static int cmd_stat(struct client *client, const char *args __attr_unused__)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
313 {
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
314 client_send_line(client, "+OK %u %"PRIuUOFF_T, client->
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
315 messages_count, client->total_size);
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
316 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
317 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
318
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
319 static int cmd_top(struct client *client, const char *args)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
320 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
321 unsigned int msgnum;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
322 uoff_t max_lines;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
323
1045
be7710b9a819 Fixes, seems to be working now. Only thing left is the pop3-login..
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
324 args = get_msgnum(client, args, &msgnum);
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
325 if (args == NULL)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
326 return FALSE;
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
327 if (get_size(client, args, &max_lines) == NULL)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
328 return FALSE;
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
329
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
330 fetch(client, msgnum, max_lines);
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
331 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
332 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
333
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
334 static void list_uids(struct client *client, unsigned int message)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
335 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
336 struct mail_fetch_context *ctx;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
337 struct mail *mail;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
338 const char *messageset;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
339 int found = FALSE;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
340
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
341 if (client->messages_count == 0 && message == 0)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
342 return;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
343
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
344 messageset = message == 0 ?
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
345 t_strdup_printf("1:%u", client->messages_count) :
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
346 t_strdup_printf("%u", message);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
347
1672
8920600a8cfc Index cache file rewrite. It's not finished yet and mbox support is
Timo Sirainen <tss@iki.fi>
parents: 1640
diff changeset
348 ctx = client->mailbox->fetch_init(client->mailbox, 0, NULL,
1640
db14aa8e2b5c API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents: 1507
diff changeset
349 messageset, FALSE);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
350 if (ctx == NULL) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
351 client_send_storage_error(client);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
352 return;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
353 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
354
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
355 while ((mail = client->mailbox->fetch_next(ctx)) != NULL) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
356 client_send_line(client, message == 0 ?
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
357 "%u %u.%u" : "+OK %u %u.%u",
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
358 mail->seq, client->uidvalidity, mail->uid);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
359 found = TRUE;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
360 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
361
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
362 (void)client->mailbox->fetch_deinit(ctx, NULL);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
363
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
364 if (!found && message != 0)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
365 client_send_line(client, "-ERR Message not found.");
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
366 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
367
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
368 static int cmd_uidl(struct client *client, const char *args)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
369 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
370 if (*args == '\0') {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
371 client_send_line(client, "+OK");
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
372 list_uids(client, 0);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
373 client_send_line(client, ".");
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
374 } else {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
375 unsigned int msgnum;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
376
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
377 if (get_msgnum(client, args, &msgnum) == NULL)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
378 return FALSE;
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
379
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
380 list_uids(client, msgnum+1);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
381 }
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
382
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
383 return TRUE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
384 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
385
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
386 int client_command_execute(struct client *client,
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
387 const char *name, const char *args)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
388 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
389 /* keep the command uppercased */
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
390 name = str_ucase(t_strdup_noconst(name));
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
391
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
392 while (*args == ' ') args++;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
393
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
394 switch (*name) {
1059
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
395 case 'C':
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
396 if (strcmp(name, "CAPA") == 0)
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
397 return cmd_capa(client, args);
d805c2f1d6a9 Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents: 1056
diff changeset
398 break;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
399 case 'D':
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
400 if (strcmp(name, "DELE") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
401 return cmd_dele(client, args);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
402 break;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
403 case 'L':
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
404 if (strcmp(name, "LIST") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
405 return cmd_list(client, args);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
406 break;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
407 case 'N':
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
408 if (strcmp(name, "NOOP") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
409 return cmd_noop(client, args);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
410 break;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
411 case 'Q':
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
412 if (strcmp(name, "QUIT") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
413 return cmd_quit(client, args);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
414 break;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
415 case 'R':
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
416 if (strcmp(name, "RETR") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
417 return cmd_retr(client, args);
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
418 if (strcmp(name, "RSET") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
419 return cmd_rset(client, args);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
420 break;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
421 case 'S':
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
422 if (strcmp(name, "STAT") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
423 return cmd_stat(client, args);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
424 break;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
425 case 'T':
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
426 if (strcmp(name, "TOP") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
427 return cmd_top(client, args);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
428 break;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
429 case 'U':
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
430 if (strcmp(name, "UIDL") == 0)
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
431 return cmd_uidl(client, args);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
432 break;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
433 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
434
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
435 client_send_line(client, "-ERR Unknown command: %s", name);
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1051
diff changeset
436 return FALSE;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
437 }