Re: sequence number to uid conversion

From: Bron Gondwana (no email)
Date: Thu Nov 08 2007 - 07:29:44 EST

  • Next message: Toschi Pietro: "R: sequence number to uid conversion"

    On Thu, Nov 08, 2007 at 11:17:23AM +0100, Toschi Pietro wrote:
    >
    > Hi
    > For an experiment I'm working at, I need to modify imapd.c so that COPY
    > and STORE commands are registered via syslog along with UIDs of messages
    > they apply to. It seems an easy job when clients issue commands
    > prepended with UID (eg. UID STORE <args>, UID COPY <args>), but I can't
    > face any way to convert a message sequence number to a message UID when
    > using the simple form. Is there some function and data structure that I
    > can use to obtain a message UID given a folder and a message sequence
    > number?

    This is also something I'm looking at doing - I want to log both the UID
    and the GUID to the log. I also want to make sure that APPEND gets
    logged as well, and DELETE.

    You should find that you can use the macro UID(msgno) or if you
    really feel like it the function index_getuid(msgno) from index.c.

    Both of these require the mailbox to be selected. Otherwise you
    can always just fetch it directly from the memory-mapped mailbox
    index:

    uid = ntohl(*((bit32 *)(mailbox->index_base + mailbox->start_offset +
                            (msgno - 1) * mailbox->record_size)));

    (yeah, a bit unwieldy!)

    Or there's the nice interface way:

    struct index_record record;
    mailbox_read_index_record(mailbox, msgno, &record);
    uid = record.uid;

    Which has the added benefit that it will work once I finish
    writing crc32 support in and you can't go doing random memory
    offset reads any more without missing out on the crc32 check.

    Bron.


  • Next message: Toschi Pietro: "R: sequence number to uid conversion"





    Hosted Email Solutions

    Invaluement Anti-Spam DNSBLs



    Powered By FreeBSD   Powered By FreeBSD