Some cleanup, I should not work on things late at night.
Still yucky, much more things need to be put on the sanity checks.
Showing
1 changed file
with
8 additions
and
34 deletions
... | @@ -121,16 +121,8 @@ imap4d_fetch (struct imap4d_command *command, char *arg) | ... | @@ -121,16 +121,8 @@ imap4d_fetch (struct imap4d_command *command, char *arg) |
121 | for (i = 0; i < n; i++) | 121 | for (i = 0; i < n; i++) |
122 | { | 122 | { |
123 | fcmd->states = set[i]; | 123 | fcmd->states = set[i]; |
124 | fcmd->tag = command->tag; | 124 | util_send ("* FETCH %d (%s", set[i], command->name); |
125 | fcmd->success = 1; | 125 | fcmd->func (fcmd, sp); |
126 | status = fcmd->func (fcmd, sp); | ||
127 | if (status != 0) | ||
128 | { | ||
129 | rc = RESP_BAD; | ||
130 | errmsg = "Bogus attribute"; | ||
131 | break; | ||
132 | } | ||
133 | else | ||
134 | util_send (")\r\n"); | 126 | util_send (")\r\n"); |
135 | } | 127 | } |
136 | free (set); | 128 | free (set); |
... | @@ -138,13 +130,6 @@ imap4d_fetch (struct imap4d_command *command, char *arg) | ... | @@ -138,13 +130,6 @@ imap4d_fetch (struct imap4d_command *command, char *arg) |
138 | } | 130 | } |
139 | 131 | ||
140 | /* --------------- Fetch commands definition ----- */ | 132 | /* --------------- Fetch commands definition ----- */ |
141 | #define EPILOGUE(command) \ | ||
142 | do { \ | ||
143 | if (command->success) \ | ||
144 | util_send ("* FETCH %d (%s", command->states, command->name); \ | ||
145 | else \ | ||
146 | util_send (" %s", command->name); \ | ||
147 | } while (0) | ||
148 | 133 | ||
149 | static int | 134 | static int |
150 | fetch_all (struct imap4d_command *command, char *arg) | 135 | fetch_all (struct imap4d_command *command, char *arg) |
... | @@ -152,7 +137,6 @@ fetch_all (struct imap4d_command *command, char *arg) | ... | @@ -152,7 +137,6 @@ fetch_all (struct imap4d_command *command, char *arg) |
152 | struct imap4d_command c_env = fetch_command_table[F_ENVELOPE]; | 137 | struct imap4d_command c_env = fetch_command_table[F_ENVELOPE]; |
153 | fetch_fast (command, arg); | 138 | fetch_fast (command, arg); |
154 | c_env.states = command->states; | 139 | c_env.states = command->states; |
155 | c_env.success = 0; | ||
156 | fetch_envelope (&c_env, arg); | 140 | fetch_envelope (&c_env, arg); |
157 | return 0; | 141 | return 0; |
158 | } | 142 | } |
... | @@ -163,7 +147,6 @@ fetch_full (struct imap4d_command *command, char *arg) | ... | @@ -163,7 +147,6 @@ fetch_full (struct imap4d_command *command, char *arg) |
163 | struct imap4d_command c_body = fetch_command_table[F_BODY]; | 147 | struct imap4d_command c_body = fetch_command_table[F_BODY]; |
164 | fetch_all (command, arg); | 148 | fetch_all (command, arg); |
165 | c_body.states = command->states; | 149 | c_body.states = command->states; |
166 | c_body.success = 0; | ||
167 | fetch_body (&c_body, arg); | 150 | fetch_body (&c_body, arg); |
168 | return 0; | 151 | return 0; |
169 | } | 152 | } |
... | @@ -175,14 +158,10 @@ fetch_fast (struct imap4d_command *command, char *arg) | ... | @@ -175,14 +158,10 @@ fetch_fast (struct imap4d_command *command, char *arg) |
175 | struct imap4d_command c_rfc = fetch_command_table[F_RFC822_SIZE]; | 158 | struct imap4d_command c_rfc = fetch_command_table[F_RFC822_SIZE]; |
176 | struct imap4d_command c_flags = fetch_command_table[F_FLAGS]; | 159 | struct imap4d_command c_flags = fetch_command_table[F_FLAGS]; |
177 | c_flags.states = command->states; | 160 | c_flags.states = command->states; |
178 | c_flags.success = command->success; | ||
179 | fetch_flags (&c_flags, arg); | 161 | fetch_flags (&c_flags, arg); |
180 | command->success = 0; | ||
181 | c_idate.states = command->states; | 162 | c_idate.states = command->states; |
182 | c_idate.success = 0; | ||
183 | fetch_internaldate (&c_idate, arg); | 163 | fetch_internaldate (&c_idate, arg); |
184 | c_rfc.states = command->states; | 164 | c_rfc.states = command->states; |
185 | c_rfc.success = 0; | ||
186 | fetch_rfc822_size (&c_rfc, arg); | 165 | fetch_rfc822_size (&c_rfc, arg); |
187 | return 0; | 166 | return 0; |
188 | } | 167 | } |
... | @@ -201,7 +180,7 @@ fetch_envelope (struct imap4d_command *command, char *arg) | ... | @@ -201,7 +180,7 @@ fetch_envelope (struct imap4d_command *command, char *arg) |
201 | int status; | 180 | int status; |
202 | mailbox_get_message (mbox, command->states, &msg); | 181 | mailbox_get_message (mbox, command->states, &msg); |
203 | message_get_header (msg, &header); | 182 | message_get_header (msg, &header); |
204 | EPILOGUE(command); | 183 | util_send (" %s", command->name); |
205 | status = header_get_value (header, "Date", buffer, sizeof (buffer), NULL); | 184 | status = header_get_value (header, "Date", buffer, sizeof (buffer), NULL); |
206 | util_send (" \"%s\"", buffer); | 185 | util_send (" \"%s\"", buffer); |
207 | status = header_get_value (header, "Subject", buffer, sizeof (buffer), NULL); | 186 | status = header_get_value (header, "Subject", buffer, sizeof (buffer), NULL); |
... | @@ -232,7 +211,7 @@ fetch_flags (struct imap4d_command *command, char *arg) | ... | @@ -232,7 +211,7 @@ fetch_flags (struct imap4d_command *command, char *arg) |
232 | message_t msg = NULL; | 211 | message_t msg = NULL; |
233 | mailbox_get_message (mbox, command->states, &msg); | 212 | mailbox_get_message (mbox, command->states, &msg); |
234 | message_get_attribute (msg, &attr); | 213 | message_get_attribute (msg, &attr); |
235 | EPILOGUE(command); | 214 | util_send (" %s", command->name); |
236 | util_send (" ("); | 215 | util_send (" ("); |
237 | if (attribute_is_deleted (attr)) | 216 | if (attribute_is_deleted (attr)) |
238 | util_send (" \\Deleted"); | 217 | util_send (" \\Deleted"); |
... | @@ -256,7 +235,7 @@ fetch_internaldate (struct imap4d_command *command, char *arg) | ... | @@ -256,7 +235,7 @@ fetch_internaldate (struct imap4d_command *command, char *arg) |
256 | message_get_envelope (msg, &env); | 235 | message_get_envelope (msg, &env); |
257 | date[0] = '\0'; | 236 | date[0] = '\0'; |
258 | envelope_date (env, date, sizeof (date), NULL); | 237 | envelope_date (env, date, sizeof (date), NULL); |
259 | EPILOGUE(command); | 238 | util_send (" %s", command->name); |
260 | if (date[strlen (date) - 1] == '\n') | 239 | if (date[strlen (date) - 1] == '\n') |
261 | date[strlen (date) - 1] = '\0'; | 240 | date[strlen (date) - 1] = '\0'; |
262 | util_send (" \"%s\"", date); | 241 | util_send (" \"%s\"", date); |
... | @@ -269,7 +248,6 @@ fetch_rfc822_header (struct imap4d_command *command, char *arg) | ... | @@ -269,7 +248,6 @@ fetch_rfc822_header (struct imap4d_command *command, char *arg) |
269 | char buffer[64]; | 248 | char buffer[64]; |
270 | struct imap4d_command c_body_p = fetch_command_table[F_BODY_PEEK]; | 249 | struct imap4d_command c_body_p = fetch_command_table[F_BODY_PEEK]; |
271 | c_body_p.states = command->states; | 250 | c_body_p.states = command->states; |
272 | c_body_p.success = command->success; | ||
273 | strcpy (buffer, "[HEADER]"); | 251 | strcpy (buffer, "[HEADER]"); |
274 | fetch_body_peek (&c_body_p, buffer); | 252 | fetch_body_peek (&c_body_p, buffer); |
275 | return 0; | 253 | return 0; |
... | @@ -284,7 +262,7 @@ fetch_rfc822_size (struct imap4d_command *command, char *arg) | ... | @@ -284,7 +262,7 @@ fetch_rfc822_size (struct imap4d_command *command, char *arg) |
284 | mailbox_get_message (mbox, command->states, &msg); | 262 | mailbox_get_message (mbox, command->states, &msg); |
285 | message_size (msg, &size); | 263 | message_size (msg, &size); |
286 | message_lines (msg, &lines); | 264 | message_lines (msg, &lines); |
287 | EPILOGUE(command); | 265 | util_send (" %s", command->name); |
288 | util_send (" %u", size + lines); | 266 | util_send (" %u", size + lines); |
289 | return 0; | 267 | return 0; |
290 | } | 268 | } |
... | @@ -295,7 +273,6 @@ fetch_rfc822_text (struct imap4d_command *command, char *arg) | ... | @@ -295,7 +273,6 @@ fetch_rfc822_text (struct imap4d_command *command, char *arg) |
295 | char buffer[64]; | 273 | char buffer[64]; |
296 | struct imap4d_command c_body = fetch_command_table[F_BODY]; | 274 | struct imap4d_command c_body = fetch_command_table[F_BODY]; |
297 | c_body.states = command->states; | 275 | c_body.states = command->states; |
298 | c_body.success = command->success; | ||
299 | strcpy (buffer, "[TEXT]"); | 276 | strcpy (buffer, "[TEXT]"); |
300 | fetch_body (&c_body, buffer); | 277 | fetch_body (&c_body, buffer); |
301 | return 0; | 278 | return 0; |
... | @@ -308,7 +285,6 @@ fetch_rfc822 (struct imap4d_command *command, char *arg) | ... | @@ -308,7 +285,6 @@ fetch_rfc822 (struct imap4d_command *command, char *arg) |
308 | char buffer[64]; | 285 | char buffer[64]; |
309 | struct imap4d_command c_body = fetch_command_table[F_BODY]; | 286 | struct imap4d_command c_body = fetch_command_table[F_BODY]; |
310 | c_body.states = command->states; | 287 | c_body.states = command->states; |
311 | c_body.success = command->success; | ||
312 | strcpy (buffer, "[]"); | 288 | strcpy (buffer, "[]"); |
313 | fetch_body (&c_body, buffer); | 289 | fetch_body (&c_body, buffer); |
314 | return 0; | 290 | return 0; |
... | @@ -330,7 +306,6 @@ fetch_body (struct imap4d_command *command, char *arg) | ... | @@ -330,7 +306,6 @@ fetch_body (struct imap4d_command *command, char *arg) |
330 | mailbox_get_message (mbox, command->states, &msg); | 306 | mailbox_get_message (mbox, command->states, &msg); |
331 | message_get_attribute (msg, &attr); | 307 | message_get_attribute (msg, &attr); |
332 | c_body_p.states = command->states; | 308 | c_body_p.states = command->states; |
333 | c_body_p.success = command->success; | ||
334 | fetch_body_peek (&c_body_p, arg); | 309 | fetch_body_peek (&c_body_p, arg); |
335 | attribute_set_seen (attr); | 310 | attribute_set_seen (attr); |
336 | return 0; | 311 | return 0; |
... | @@ -343,8 +318,7 @@ fetch_uid (struct imap4d_command *command, char *arg) | ... | @@ -343,8 +318,7 @@ fetch_uid (struct imap4d_command *command, char *arg) |
343 | message_t msg = NULL; | 318 | message_t msg = NULL; |
344 | mailbox_get_message (mbox, command->states, &msg); | 319 | mailbox_get_message (mbox, command->states, &msg); |
345 | message_get_uid (msg, &uid); | 320 | message_get_uid (msg, &uid); |
346 | EPILOGUE (command); | 321 | util_send (" %s %d", command->name, uid); |
347 | util_send (" %d", uid); | ||
348 | return 0; | 322 | return 0; |
349 | } | 323 | } |
350 | 324 | ||
... | @@ -356,7 +330,7 @@ fetch_body_peek (struct imap4d_command *command, char *arg) | ... | @@ -356,7 +330,7 @@ fetch_body_peek (struct imap4d_command *command, char *arg) |
356 | 330 | ||
357 | mailbox_get_message (mbox, command->states, &msg); | 331 | mailbox_get_message (mbox, command->states, &msg); |
358 | 332 | ||
359 | EPILOGUE(command); | 333 | util_send (" %s", command->name); |
360 | 334 | ||
361 | if (strncasecmp (arg, "[]", 2) == 0) | 335 | if (strncasecmp (arg, "[]", 2) == 0) |
362 | { | 336 | { | ... | ... |
-
Please register or sign in to post a comment