Commit 920a217a 920a217a52d60d5a42e3e6d3371198827e3cd611 by Sergey Poznyakoff

(amd_quick_get_message): Implement quick_get method.

1 parent 9f08b185
...@@ -76,6 +76,8 @@ static void amd_destroy (mu_mailbox_t mailbox); ...@@ -76,6 +76,8 @@ static void amd_destroy (mu_mailbox_t mailbox);
76 static int amd_open (mu_mailbox_t, int); 76 static int amd_open (mu_mailbox_t, int);
77 static int amd_close (mu_mailbox_t); 77 static int amd_close (mu_mailbox_t);
78 static int amd_get_message (mu_mailbox_t, size_t, mu_message_t *); 78 static int amd_get_message (mu_mailbox_t, size_t, mu_message_t *);
79 static int amd_quick_get_message (mu_mailbox_t mailbox, mu_message_qid_t qid,
80 mu_message_t *pmsg);
79 static int amd_append_message (mu_mailbox_t, mu_message_t); 81 static int amd_append_message (mu_mailbox_t, mu_message_t);
80 static int amd_messages_count (mu_mailbox_t, size_t *); 82 static int amd_messages_count (mu_mailbox_t, size_t *);
81 static int amd_messages_recent (mu_mailbox_t, size_t *); 83 static int amd_messages_recent (mu_mailbox_t, size_t *);
...@@ -276,6 +278,7 @@ amd_init_mailbox (mu_mailbox_t mailbox, size_t amd_size, ...@@ -276,6 +278,7 @@ amd_init_mailbox (mu_mailbox_t mailbox, size_t amd_size,
276 278
277 /* Overloading of the entire mailbox object methods. */ 279 /* Overloading of the entire mailbox object methods. */
278 mailbox->_get_message = amd_get_message; 280 mailbox->_get_message = amd_get_message;
281 mailbox->_quick_get_message = amd_quick_get_message;
279 mailbox->_append_message = amd_append_message; 282 mailbox->_append_message = amd_append_message;
280 mailbox->_messages_count = amd_messages_count; 283 mailbox->_messages_count = amd_messages_count;
281 mailbox->_messages_recent = amd_messages_recent; 284 mailbox->_messages_recent = amd_messages_recent;
...@@ -528,6 +531,36 @@ amd_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg) ...@@ -528,6 +531,36 @@ amd_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg)
528 return _amd_attach_message (mailbox, mhm, pmsg); 531 return _amd_attach_message (mailbox, mhm, pmsg);
529 } 532 }
530 533
534 static int
535 amd_quick_get_message (mu_mailbox_t mailbox, mu_message_qid_t qid,
536 mu_message_t *pmsg)
537 {
538 int status;
539 struct _amd_data *amd = mailbox->data;
540 if (amd->msg_count)
541 {
542 mu_message_qid_t vqid;
543 mu_message_t msg = amd->msg_array[0]->message;
544 status = mu_message_get_qid (msg, &vqid);
545 if (status)
546 return status;
547 status = strcmp (qid, vqid);
548 free (vqid);
549 if (status)
550 return MU_ERR_EXISTS;
551 *pmsg = msg;
552 }
553 else if (amd->qfetch)
554 {
555 status = amd->qfetch (amd, qid);
556 if (status)
557 return status;
558 return _amd_attach_message (mailbox, amd->msg_array[0], pmsg);
559 }
560
561 return ENOSYS;
562 }
563
531 static FILE * 564 static FILE *
532 _amd_tempfile(struct _amd_data *amd, char **namep) 565 _amd_tempfile(struct _amd_data *amd, char **namep)
533 { 566 {
......