R: sequence number to uid conversion

From: Toschi Pietro (no email)
Date: Thu Nov 08 2007 - 07:33:55 EST

  • Next message: Ken Murchison: "Re: Cyrus IMAPd 2.3.10 Released"

    Thank you Bron, very interesting!
    I'll try starting from the more crc32-safe way and I'll let you and the list know my results.

    P.

    Pietro Toschi
    Actalis S.p.A. Gruppo AlmavivA
    Via Luigi Rizzo, 20
    00136 Roma
    www.actalis.it
    Office: 06-39933169
    Mobile: 335-7244764
    Fax: 06-39935348
     

    -----Messaggio originale-----
    Da: Bron Gondwana [mailto:]
    Inviato: giovedì 8 novembre 2007 13.30
    A: Toschi Pietro
    Cc:
    Oggetto: Re: 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: Ken Murchison: "Re: Cyrus IMAPd 2.3.10 Released"





    Hosted Email Solutions

    Invaluement Anti-Spam DNSBLs



    Powered By FreeBSD   Powered By FreeBSD