On Sun, 14 Aug 2016, Jani Nikula <j...@nikula.org> wrote:
> I think we should use gmime for this, and expect the configuration to be
> a comma separated list of addresses, specifically in the format that
> internet_address_list_parse_string() parses [2].

Here's a little sample to get started and play around. Build using
something along the lines of:

gcc $(pkg-config --cflags gmime-2.6 --libs gmime-2.6) internetaddress.c

You can try e.g.

$ ./a.out "J. Random Hacker <j...@example.org>, d...@example.org, \"Hacker, J. 
Random\" <hac...@example.com>"
name[0]: J. Random Hacker
addr[0]: j...@example.org
name[1]: (null)
addr[1]: d...@example.org
name[2]: Hacker, J. Random
addr[2]: hac...@example.com

----------->%----------

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#include <gmime/gmime.h>

int main(int argc, char *argv[])
{
        InternetAddressList *list;
        InternetAddress *mailbox;
        int i;

        if (argc != 2) {
                fprintf(stderr, "usage: %s address-list\n", argv[0]);
                return EXIT_FAILURE;
        }

        list = internet_address_list_parse_string(argv[1]);

        for (i = 0; i < internet_address_list_length(list); i++) {
                InternetAddress *addr;
                InternetAddressMailbox *mbox;

                addr = internet_address_list_get_address(list, i);

                if (INTERNET_ADDRESS_IS_GROUP(addr)) {
                        printf("[%d] is a group, ignoring\n", i);
                        continue;
                }

                mbox = INTERNET_ADDRESS_MAILBOX(addr);

                printf("name[%d]: %s\n", i, internet_address_get_name(addr));
                printf("addr[%d]: %s\n", i, 
internet_address_mailbox_get_addr(mbox));
        }

        return EXIT_SUCCESS;    
}
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to