_mh_next_seq(): add 1 to the last used sequence number.
mh_append_message(): missed assignment to mhd member of struct _mh_data. mh_message_number(): new function. It is the only way to get the message sequence number.
Showing
1 changed file
with
13 additions
and
1 deletions
... | @@ -438,7 +438,7 @@ mh_get_message (mailbox_t mailbox, size_t msgno, message_t *pmsg) | ... | @@ -438,7 +438,7 @@ mh_get_message (mailbox_t mailbox, size_t msgno, message_t *pmsg) |
438 | static size_t | 438 | static size_t |
439 | _mh_next_seq (struct _mh_data *mhd) | 439 | _mh_next_seq (struct _mh_data *mhd) |
440 | { | 440 | { |
441 | return mhd->msg_tail ? mhd->msg_tail->seq_number : 1; | 441 | return (mhd->msg_tail ? mhd->msg_tail->seq_number : 0) + 1; |
442 | } | 442 | } |
443 | 443 | ||
444 | static FILE * | 444 | static FILE * |
... | @@ -576,6 +576,7 @@ mh_append_message (mailbox_t mailbox, message_t msg) | ... | @@ -576,6 +576,7 @@ mh_append_message (mailbox_t mailbox, message_t msg) |
576 | if (!mhm) | 576 | if (!mhm) |
577 | return ENOMEM; | 577 | return ENOMEM; |
578 | 578 | ||
579 | mhm->mhd = mhd; | ||
579 | mhm->seq_number = _mh_next_seq (mhd); | 580 | mhm->seq_number = _mh_next_seq (mhd); |
580 | mhm->uid = mhd->uidnext++; | 581 | mhm->uid = mhd->uidnext++; |
581 | mhm->message = msg; | 582 | mhm->message = msg; |
... | @@ -1436,3 +1437,14 @@ mh_envelope_sender (envelope_t envelope, char *buf, size_t len, | ... | @@ -1436,3 +1437,14 @@ mh_envelope_sender (envelope_t envelope, char *buf, size_t len, |
1436 | *psize = len; | 1437 | *psize = len; |
1437 | return 0; | 1438 | return 0; |
1438 | } | 1439 | } |
1440 | |||
1441 | int | ||
1442 | mh_message_number (message_t msg, size_t *pnum) | ||
1443 | { | ||
1444 | struct _mh_message *mhm = message_get_owner (msg); | ||
1445 | if (pnum) | ||
1446 | *pnum = mhm->seq_number; | ||
1447 | return 0; | ||
1448 | } | ||
1449 | |||
1450 | ... | ... |
-
Please register or sign in to post a comment