Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/pop3/client.c @ 1640:db14aa8e2b5c HEAD
API change for expunging messages. Not exactly what I wanted, but good
enough.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 26 Jul 2003 19:33:21 +0300 |
parents | d22e03714d36 |
children | a7c742b940e5 |
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" |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "ioloop.h" |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "network.h" |
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 "istream.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 "ostream.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" |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 #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
|
10 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 #include <stdlib.h> |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 |
1053 | 13 /* max. length of input command line (spec says 512) */ |
14 #define MAX_INBUF_SIZE 2048 | |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 /* If we can't send a buffer in a minute, disconnect the client */ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 #define CLIENT_OUTPUT_TIMEOUT (60*1000) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 /* Disconnect client when it sends too many bad commands in a row */ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 #define CLIENT_MAX_BAD_COMMANDS 20 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 /* Disconnect client after idling this many seconds */ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 #define CLIENT_IDLE_TIMEOUT (60*30) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 extern struct mail_storage_callbacks mail_storage_callbacks; |
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 static struct client *my_client; /* we don't need more than one currently */ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 static struct timeout *to_idle; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 static void client_input(void *context); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 static void client_output_timeout(void *context) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 struct client *client = context; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 i_stream_close(client->input); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 o_stream_close(client->output); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 |
1044
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
40 static int init_mailbox(struct client *client) |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
41 { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
42 struct mail_fetch_context *ctx; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
43 struct mail *mail; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
44 struct mailbox_status status; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
45 const char *messageset; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
46 int i, all_found, failed; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
47 |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
48 if (!client->mailbox->get_status(client->mailbox, |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
49 STATUS_MESSAGES | STATUS_UIDVALIDITY, |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
50 &status)) { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
51 client_send_storage_error(client); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
52 return FALSE; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
53 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
54 |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
55 client->messages_count = status.messages; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
56 client->uidvalidity = status.uidvalidity; |
1056
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
57 |
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
58 if (client->messages_count == 0) |
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
59 return TRUE; |
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
60 |
1044
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
61 client->message_sizes = i_new(uoff_t, client->messages_count); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
62 messageset = t_strdup_printf("1:%u", client->messages_count); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
63 for (i = 0; i < 2; i++) { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
64 ctx = client->mailbox->fetch_init(client->mailbox, |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
65 MAIL_FETCH_SIZE, |
1640
db14aa8e2b5c
API change for expunging messages. Not exactly what I wanted, but good
Timo Sirainen <tss@iki.fi>
parents:
1622
diff
changeset
|
66 messageset, FALSE); |
1044
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
67 if (ctx == NULL) { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
68 client_send_storage_error(client); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
69 return FALSE; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
70 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
71 |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
72 client->total_size = 0; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
73 failed = FALSE; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
74 while ((mail = client->mailbox->fetch_next(ctx)) != NULL) { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
75 uoff_t size = mail->get_size(mail); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
76 |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
77 if (size == (uoff_t)-1) { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
78 failed = TRUE; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
79 break; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
80 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
81 client->total_size += size; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
82 |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
83 i_assert(mail->seq <= client->messages_count); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
84 client->message_sizes[mail->seq-1] = size; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
85 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
86 |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
87 if (!client->mailbox->fetch_deinit(ctx, &all_found)) { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
88 client_send_storage_error(client); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
89 return FALSE; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
90 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
91 |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
92 if (!failed && all_found) |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
93 return TRUE; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
94 |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
95 /* well, sync and try again */ |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
96 if (!client->mailbox->sync(client->mailbox, TRUE)) { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
97 client_send_storage_error(client); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
98 return FALSE; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
99 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
100 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
101 |
1059
d805c2f1d6a9
Support for CAPA command (rfc2449).
Timo Sirainen <tss@iki.fi>
parents:
1056
diff
changeset
|
102 client_send_line(client, "-ERR [IN-USE] Couldn't sync mailbox."); |
1044
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
103 return FALSE; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
104 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
105 |
1363
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
106 struct client *client_create(int hin, int hout, struct mail_storage *storage) |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 struct client *client; |
1622
d22e03714d36
index_mmap_invalidate = yes now invalidate memory maps before accessing
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
109 enum mailbox_open_flags flags; |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
110 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
111 client = i_new(struct client, 1); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
112 client->input = i_stream_create_file(hin, default_pool, |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
113 MAX_INBUF_SIZE, FALSE); |
1499
e850252cdc7e
Removed I/O priorities. They were pretty much useless and were just getting
Timo Sirainen <tss@iki.fi>
parents:
1416
diff
changeset
|
114 client->output = o_stream_create_file(hout, default_pool, 4096, 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
|
115 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
116 /* set timeout for sending data */ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 o_stream_set_blocking(client->output, CLIENT_OUTPUT_TIMEOUT, |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
118 client_output_timeout, client); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
119 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
120 client->io = io_add(hin, IO_READ, client_input, client); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
121 client->last_input = ioloop_time; |
1363
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
122 client->storage = storage; |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 |
1363
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
124 storage->set_callbacks(storage, &mail_storage_callbacks, 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
|
125 |
1622
d22e03714d36
index_mmap_invalidate = yes now invalidate memory maps before accessing
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
126 flags = getenv("MMAP_INVALIDATE") != NULL ? |
d22e03714d36
index_mmap_invalidate = yes now invalidate memory maps before accessing
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
127 MAILBOX_OPEN_MMAP_INVALIDATE : 0; |
d22e03714d36
index_mmap_invalidate = yes now invalidate memory maps before accessing
Timo Sirainen <tss@iki.fi>
parents:
1499
diff
changeset
|
128 client->mailbox = storage->open_mailbox(storage, "INBOX", flags); |
1363
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
129 if (client->mailbox == NULL) { |
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
130 client_send_line(client, "-ERR No INBOX for user."); |
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
131 return NULL; |
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
132 } |
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
133 |
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
134 if (!init_mailbox(client)) { |
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
135 client_destroy(client); |
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
136 return NULL; |
383e4b9e347c
Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents:
1059
diff
changeset
|
137 } |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
138 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
139 i_assert(my_client == NULL); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
140 my_client = client; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
141 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
142 return client; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
143 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
144 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
145 void client_destroy(struct client *client) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
146 { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
147 o_stream_flush(client->output); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
148 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
149 if (client->mailbox != NULL) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
150 client->mailbox->close(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
|
151 mail_storage_destroy(client->storage); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
152 |
1044
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
153 i_free(client->message_sizes); |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
154 i_free(client->deleted_bitmask); |
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 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
156 io_remove(client->io); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
157 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
158 i_stream_unref(client->input); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
159 o_stream_unref(client->output); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
160 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
161 i_free(client); |
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 /* quit the program */ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
164 my_client = NULL; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
165 io_loop_stop(ioloop); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
166 } |
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 void client_disconnect(struct client *client) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
169 { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
170 o_stream_flush(client->output); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
171 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
172 i_stream_close(client->input); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
173 o_stream_close(client->output); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
174 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
175 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
176 void client_send_line(struct client *client, const char *fmt, ...) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
177 { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
178 va_list va; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
179 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
180 if (client->output->closed) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
181 return; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
182 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
183 va_start(va, fmt); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
184 (void)o_stream_send_str(client->output, t_strdup_vprintf(fmt, va)); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
185 (void)o_stream_send(client->output, "\r\n", 2); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
186 va_end(va); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
187 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
188 |
1044
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
189 void client_send_storage_error(struct client *client) |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
190 { |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
191 const char *error; |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
192 |
1415
c1a7da406bbd
Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents:
1412
diff
changeset
|
193 if (client->mailbox->is_inconsistency_error(client->mailbox)) { |
c1a7da406bbd
Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents:
1412
diff
changeset
|
194 client_send_line(client, "-ERR Mailbox is in inconsistent " |
c1a7da406bbd
Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents:
1412
diff
changeset
|
195 "state, please relogin."); |
c1a7da406bbd
Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents:
1412
diff
changeset
|
196 client_disconnect(client); |
c1a7da406bbd
Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents:
1412
diff
changeset
|
197 return; |
c1a7da406bbd
Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents:
1412
diff
changeset
|
198 } |
c1a7da406bbd
Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents:
1412
diff
changeset
|
199 |
1044
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
200 error = client->storage->get_last_error(client->storage, NULL); |
1412
ac714d7d0b67
If no error is set, give "BUG: Unknown error" rather than try to print NULL
Timo Sirainen <tss@iki.fi>
parents:
1363
diff
changeset
|
201 client_send_line(client, "-ERR %s", error != NULL ? error : |
ac714d7d0b67
If no error is set, give "BUG: Unknown error" rather than try to print NULL
Timo Sirainen <tss@iki.fi>
parents:
1363
diff
changeset
|
202 "BUG: Unknown error"); |
1044
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
203 } |
50d258907c99
Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents:
1043
diff
changeset
|
204 |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
205 static void client_input(void *context) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
206 { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
207 struct client *client = context; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
208 char *line, *args; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
209 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
210 client->last_input = ioloop_time; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
211 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
212 switch (i_stream_read(client->input)) { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
213 case -1: |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
214 /* disconnected */ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
215 client_destroy(client); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
216 return; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
217 case -2: |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
218 /* line too long, kill it */ |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
219 client_send_line(client, "-ERR Input line too long."); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
220 client_destroy(client); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
221 return; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
222 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
223 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
224 o_stream_cork(client->output); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
225 while (!client->output->closed && |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
226 (line = i_stream_next_line(client->input)) != NULL) { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
227 args = strchr(line, ' '); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
228 if (args == NULL) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
229 args = ""; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
230 else |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
231 *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
|
232 |
1056
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
233 if (client_command_execute(client, line, args)) |
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
234 client->bad_counter = 0; |
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
235 else if (++client->bad_counter > CLIENT_MAX_BAD_COMMANDS) { |
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
236 client_send_line(client, "-ERR Too many bad commands."); |
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
237 client_disconnect(client); |
a9b499b2611e
Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents:
1053
diff
changeset
|
238 } |
1043
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
239 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
240 o_stream_flush(client->output); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
241 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
242 if (client->output->closed) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
243 client_destroy(client); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
244 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
245 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
246 static void idle_timeout(void *context __attr_unused__) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
247 { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
248 if (my_client == NULL) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
249 return; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
250 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
251 if (ioloop_time - my_client->last_input >= CLIENT_IDLE_TIMEOUT) { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
252 client_send_line(my_client, |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
253 "-ERR Disconnected for inactivity."); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
254 client_destroy(my_client); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
255 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
256 } |
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 void clients_init(void) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
259 { |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
260 my_client = NULL; |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
261 to_idle = timeout_add(10000, idle_timeout, NULL); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
262 } |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
263 |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
264 void clients_deinit(void) |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
265 { |
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 (my_client != 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_line(my_client, "-ERR Server shutting down."); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
268 client_destroy(my_client); |
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 timeout_remove(to_idle); |
cacabd33c68a
Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
272 } |