char *datafile = NULL;
static char *rcfile = NULL;
+// custom formatting
+char custom_format[FORMAT_STRING_LEN] = "{nick} ({name}): {mobile}";
+char *parsed_custom_format = NULL;
+enum field_types *custom_format_fields = 0;
+struct abook_output_item_filter selected_item_filter;
+
bool alternative_datafile = FALSE;
bool alternative_rcfile = FALSE;
*infile = "-",
*outfile = "-";
int c;
+ selected_item_filter = select_output_item_filter("muttq");
for(;;) {
int option_index = 0;
set_convert_var(informat);
break;
case OPT_OUTFORMAT:
- set_convert_var(outformat);
+ outformat = optarg;
+ selected_item_filter = select_output_item_filter(outformat);
break;
case OPT_INFILE:
set_convert_var(infile);
}
}
+ if(! selected_item_filter.func)
+ selected_item_filter = select_output_item_filter("muttq");
if(optind < argc) {
fprintf(stderr, _("%s: unrecognized arguments on command line\n"),
argv[0]);
exit(status);
}
-static void
-muttq_print_item(FILE *file, int item)
-{
- abook_list *emails, *e;
- char *tmp = db_email_get(item);
-
- emails = csv_to_abook_list(tmp);
- free(tmp);
-
- for(e = emails; e; e = e->next) {
- fprintf(file, "%s\t%s\t%s\n", e->data, db_name_get(item),
- !db_fget(item, NOTES) ?" " :db_fget(item, NOTES)
- );
- if(!opt_get_bool(BOOL_MUTT_RETURN_ALL_EMAILS))
- break;
- }
- abook_list_free(&emails);
-}
-
static void
mutt_query(char *str)
{
init_mutt_query();
if( str == NULL || !strcasecmp(str, "all") ) {
- struct db_enumerator e = init_db_enumerator(ENUM_ALL);
- printf("All items\n");
- db_enumerate_items(e)
- muttq_print_item(stdout, e.item);
+ export_file("muttq", "-");
} else {
int search_fields[] = {NAME, EMAIL, NICK, -1};
int i;
}
putchar('\n');
while(i >= 0) {
- muttq_print_item(stdout, i);
+ e_write_item(stdout, i, selected_item_filter.func);
i = find_item(str, i + 1, search_fields);
}
}