* Allows the definition of a custom output format using placeholders.
* Registers the two functions: custom_export_database() and custom_print_item()
respectively for e_filters and u_filters.
--outformatstr only applies if --outformat=custom has been specified and
if we are querying the database (presence of the --mutt-query option)
If the first character of --outformatstr is a '!', then each entry
is checked before output: it will be full skipped if any of its fields
among those requested is NULL.
Example:
$ abook --mutt-query "Max" --outformat custom --outformatstr "!{nick}: {mobile}"
max: +336863331XX
While querying is no more mutt-centric the --mutt-query option name
has *not* been duplicated nor renamed, given its wide use.
(http://sourceforge.net/mailarchive/message.php?msg_id=
27849095)
OPT_CONVERT,
OPT_INFORMAT,
OPT_OUTFORMAT,
OPT_CONVERT,
OPT_INFORMAT,
OPT_OUTFORMAT,
OPT_INFILE,
OPT_OUTFILE,
OPT_FORMATS
OPT_INFILE,
OPT_OUTFILE,
OPT_FORMATS
{ "convert", 0, 0, OPT_CONVERT },
{ "informat", 1, 0, OPT_INFORMAT },
{ "outformat", 1, 0, OPT_OUTFORMAT },
{ "convert", 0, 0, OPT_CONVERT },
{ "informat", 1, 0, OPT_INFORMAT },
{ "outformat", 1, 0, OPT_OUTFORMAT },
+ { "outformatstr", 1, 0, OPT_OUTFORMAT_STR },
{ "infile", 1, 0, OPT_INFILE },
{ "outfile", 1, 0, OPT_OUTFILE },
{ "formats", 0, 0, OPT_FORMATS },
{ "infile", 1, 0, OPT_INFILE },
{ "outfile", 1, 0, OPT_OUTFILE },
{ "formats", 0, 0, OPT_FORMATS },
outformat = optarg;
selected_item_filter = select_output_item_filter(outformat);
break;
outformat = optarg;
selected_item_filter = select_output_item_filter(outformat);
break;
+ case OPT_OUTFORMAT_STR:
+ strncpy(custom_format, optarg, FORMAT_STRING_LEN - 1);
+ custom_format[FORMAT_STRING_LEN] = 0;
+ break;
case OPT_INFILE:
set_convert_var(infile);
break;
case OPT_INFILE:
set_convert_var(infile);
break;
if(! selected_item_filter.func)
selected_item_filter = select_output_item_filter("muttq");
if(! selected_item_filter.func)
selected_item_filter = select_output_item_filter("muttq");
+ else if (! strcmp(outformat, "custom") && *custom_format) {
+ parsed_custom_format = (char *)malloc(FORMAT_STRING_LEN * sizeof(char*));
+ custom_format_fields = (enum field_types *)malloc(FORMAT_STRING_MAX_FIELDS * sizeof(enum field_types *));
+ parse_custom_format(custom_format, parsed_custom_format, custom_format_fields);
+ }
if(optind < argc) {
fprintf(stderr, _("%s: unrecognized arguments on command line\n"),
argv[0]);
if(optind < argc) {
fprintf(stderr, _("%s: unrecognized arguments on command line\n"),
argv[0]);
{ "wl", N_("Wanderlust address book"), wl_export_database },
{ "spruce", N_("Spruce address book"), spruce_export_database },
{ "bsdcal", N_("BSD calendar"), bsdcal_export_database },
{ "wl", N_("Wanderlust address book"), wl_export_database },
{ "spruce", N_("Spruce address book"), spruce_export_database },
{ "bsdcal", N_("BSD calendar"), bsdcal_export_database },
+ { "custom", N_("Custom format"), custom_export_database },
{ "\0", NULL, NULL }
};
struct abook_output_item_filter u_filters[] = {
{ "muttq", N_("mutt alias"), muttq_print_item },
{ "\0", NULL, NULL }
};
struct abook_output_item_filter u_filters[] = {
{ "muttq", N_("mutt alias"), muttq_print_item },
+ { "custom", N_("Custom format"), custom_print_item },