(mh_qfetch): Implement quick_get method.
Showing
1 changed file
with
39 additions
and
0 deletions
... | @@ -246,6 +246,44 @@ mh_scan0 (mu_mailbox_t mailbox, size_t msgno MU_ARG_UNUSED, size_t *pcount, | ... | @@ -246,6 +246,44 @@ mh_scan0 (mu_mailbox_t mailbox, size_t msgno MU_ARG_UNUSED, size_t *pcount, |
246 | return status; | 246 | return status; |
247 | } | 247 | } |
248 | 248 | ||
249 | static int | ||
250 | mh_qfetch (struct _amd_data *amd, mu_message_qid_t qid) | ||
251 | { | ||
252 | char *p; | ||
253 | size_t num = 0; | ||
254 | int attr_flags = 0; | ||
255 | struct _mh_message *msg; | ||
256 | |||
257 | p = qid + strlen (qid) - 1; | ||
258 | if (!isdigit (*p)) | ||
259 | return EINVAL; | ||
260 | |||
261 | for (p--; p >= qid && isdigit (*p); p--) | ||
262 | ; | ||
263 | |||
264 | if (p == qid) | ||
265 | return EINVAL; | ||
266 | |||
267 | num = strtoul (p + 1, NULL, 10); | ||
268 | |||
269 | if (*p == ',') | ||
270 | { | ||
271 | attr_flags |= MU_ATTRIBUTE_DELETED; | ||
272 | p--; | ||
273 | } | ||
274 | |||
275 | if (*p != '/') | ||
276 | return EINVAL; | ||
277 | |||
278 | msg = calloc (1, sizeof (*msg)); | ||
279 | msg->seq_number = num; | ||
280 | msg->amd_message.attr_flags = attr_flags; | ||
281 | msg->amd_message.deleted = attr_flags & MU_ATTRIBUTE_DELETED; | ||
282 | _amd_message_insert (amd, (struct _amd_message*) msg); | ||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | |||
249 | /* Note: In this particular implementation the message sequence number | 287 | /* Note: In this particular implementation the message sequence number |
250 | serves also as its UID. This allows to avoid many problems related | 288 | serves also as its UID. This allows to avoid many problems related |
251 | to keeping the uids in the headers of the messages. */ | 289 | to keeping the uids in the headers of the messages. */ |
... | @@ -285,6 +323,7 @@ _mailbox_mh_init (mu_mailbox_t mailbox) | ... | @@ -285,6 +323,7 @@ _mailbox_mh_init (mu_mailbox_t mailbox) |
285 | amd->msg_finish_delivery = NULL; | 323 | amd->msg_finish_delivery = NULL; |
286 | amd->msg_file_name = _mh_message_name; | 324 | amd->msg_file_name = _mh_message_name; |
287 | amd->scan0 = mh_scan0; | 325 | amd->scan0 = mh_scan0; |
326 | amd->qfetch = mh_qfetch; | ||
288 | amd->msg_cmp = mh_message_cmp; | 327 | amd->msg_cmp = mh_message_cmp; |
289 | amd->message_uid = mh_message_uid; | 328 | amd->message_uid = mh_message_uid; |
290 | amd->next_uid = _mh_next_seq; | 329 | amd->next_uid = _mh_next_seq; | ... | ... |
-
Please register or sign in to post a comment