+static void
+print_address_list (const search_options_t *o, InternetAddressList *list)
+{
+ InternetAddress *address;
+ int i;
+
+ for (i = 0; i < internet_address_list_length (list); i++) {
+ address = internet_address_list_get_address (list, i);
+ if (INTERNET_ADDRESS_IS_GROUP (address)) {
+ InternetAddressGroup *group;
+ InternetAddressList *group_list;
+
+ group = INTERNET_ADDRESS_GROUP (address);
+ group_list = internet_address_group_get_members (group);
+ if (group_list == NULL)
+ continue;
+
+ print_address_list (o, group_list);
+ } else {
+ InternetAddressMailbox *mailbox;
+ const char *name;
+ const char *addr;
+ char *full_address;
+
+ mailbox = INTERNET_ADDRESS_MAILBOX (address);
+
+ name = internet_address_get_name (address);
+ addr = internet_address_mailbox_get_addr (mailbox);
+
+ if (name && *name)
+ full_address = talloc_asprintf (o->format, "%s <%s>", name, addr);
+ else
+ full_address = talloc_strdup (o->format, addr);
+
+ if (!full_address) {
+ fprintf (stderr, "Error: out of memory\n");
+ break;
+ }
+ o->format->string (o->format, full_address);
+ o->format->separator (o->format);
+
+ talloc_free (full_address);
+ }
+ }
+}
+
+static void
+print_address_string (const search_options_t *o, const char *recipients)
+{
+ InternetAddressList *list;
+
+ if (recipients == NULL)
+ return;
+
+ list = internet_address_list_parse_string (recipients);
+ if (list == NULL)
+ return;
+
+ print_address_list (o, list);
+}
+