X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-ui%2Fquery.c;h=a9415e454d9f2931ab53be22d1911957fef09a74;hp=2a60afa1760c9247fbcf2a63953be27c2edb4843;hb=049b21f53af51ad7259613f5eefaa0f37b1b2167;hpb=96e4b6de291b2195b26289fb03536acd101c6650 diff --git a/lib-ui/query.c b/lib-ui/query.c index 2a60afa..a9415e4 100644 --- a/lib-ui/query.c +++ b/lib-ui/query.c @@ -7,19 +7,9 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif +#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include #include @@ -40,16 +30,6 @@ typedef struct entry { QUERY *data; } ENTRY; -static struct mapping_t QueryHelp[] = { - {N_("Exit"), OP_EXIT}, - {N_("Mail"), OP_MAIL}, - {N_("New Query"), OP_QUERY}, - {N_("Make Alias"), OP_CREATE_ALIAS}, - {N_("Search"), OP_SEARCH}, - {N_("Help"), OP_HELP}, - {NULL, OP_NULL} -}; - /* Variables for outsizing output format */ static int FirstColumn; static int SecondColumn; @@ -85,7 +65,7 @@ static QUERY *run_query (char *s, int quiet) int l; - mutt_expand_file_fmt (cmd, sizeof (cmd), QueryCmd, s); + m_quotefile_fmt(cmd, sizeof (cmd), QueryCmd, s); if ((thepid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) { return 0; @@ -109,14 +89,14 @@ static QUERY *run_query (char *s, int quiet) cur = cur->next; } - l = mutt_strwidth (p); + l = m_strwidth(p); if (l > SecondColumn) SecondColumn = l; cur->addr = rfc822_parse_adrlist (cur->addr, p); p = strtok (NULL, "\t\n"); if (p) { - l = mutt_strwidth (p); + l = m_strwidth(p); if (l > FirstColumn) FirstColumn = l; cur->name = m_strdup(p); @@ -128,7 +108,7 @@ static QUERY *run_query (char *s, int quiet) } } p_delete(&buf); - fclose (fp); + m_fclose(&fp); if (mutt_wait_filter (thepid)) { if (!quiet) mutt_error ("%s", msg); @@ -168,7 +148,7 @@ static int query_search (MUTTMENU * m, regex_t * re, int n) static void query_entry (char *s, ssize_t slen, MUTTMENU * m, int num) { ENTRY *table = (ENTRY *) m->data; - char buf2[SHORT_STRING], buf[SHORT_STRING] = ""; + char buf2[STRING], buf[STRING] = ""; /* need a query format ... hard coded constants are not good */ while (FirstColumn + SecondColumn > 70) { @@ -180,7 +160,7 @@ static void query_entry (char *s, ssize_t slen, MUTTMENU * m, int num) SecondColumn = QUERY_MIN_COLUMN_LENGHT; } - rfc822_write_address (buf, sizeof (buf), table[num].data->addr, 1); + rfc822_addrcat(buf, sizeof (buf), table[num].data->addr, 1); mutt_format_string (buf2, sizeof (buf2), FirstColumn + 2, FirstColumn + 2, @@ -222,15 +202,15 @@ int mutt_query_complete (char *buf, ssize_t buflen) tmpa = result_to_addr (results); mutt_addrlist_to_local (tmpa); buf[0] = '\0'; - rfc822_write_address (buf, buflen, tmpa, 0); + rfc822_addrcat(buf, buflen, tmpa, 0); address_list_wipe(&tmpa); mutt_clear_error (); - return (0); + return 0; } /* multiple results, choose from query menu */ query_menu (buf, buflen, results, 1); } - return (0); + return 0; } void mutt_query_menu (char *buf, ssize_t buflen) @@ -259,7 +239,6 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) QUERY *queryp = NULL; int i, done = 0; int op; - char helpstr[SHORT_STRING]; char title[STRING]; snprintf (title, sizeof (title), _("Query")); /* FIXME */ @@ -270,8 +249,6 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) menu->tag = query_tag; menu->menu = MENU_QUERY; menu->title = title; - menu->help = - mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp); if (results == NULL) { /* Prompt for Query */ @@ -334,9 +311,6 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) menu->tag = query_tag; menu->menu = MENU_QUERY; menu->title = title; - menu->help = - mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, - QueryHelp); /* count the number of results */ for (queryp = results; queryp; queryp = queryp->next) @@ -350,7 +324,7 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) QueryTable[i].data = queryp; } else { - int clear = 0; + int doclear = 0; /* append */ p_realloc(&QueryTable, menu->max); @@ -361,10 +335,10 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) queryp = queryp->next, i++) { /* once we hit new entries, clear/init the tag */ if (queryp == newresults) - clear = 1; + doclear = 1; QueryTable[i].data = queryp; - if (clear) + if (doclear) QueryTable[i].tagged = 0; } } @@ -435,7 +409,7 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) mutt_addrlist_to_local (tmpa); tagged = 1; - rfc822_write_address (buf, buflen, tmpa, 0); + rfc822_addrcat(buf, buflen, tmpa, 0); curpos = m_strlen(buf); address_list_wipe(&tmpa); } @@ -443,9 +417,8 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) address_t *tmpa = result_to_addr (QueryTable[i].data); mutt_addrlist_to_local (tmpa); - strcat (buf, ", "); /* __STRCAT_CHECKED__ */ - rfc822_write_address ((char *) buf + curpos + 1, - buflen - curpos - 1, tmpa, 0); + m_strcat(buf, buflen, ", "); + rfc822_addrcat(buf + curpos + 1, buflen - curpos - 1, tmpa, 0); curpos = m_strlen(buf); address_list_wipe(&tmpa); } @@ -456,7 +429,7 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) address_t *tmpa = result_to_addr (QueryTable[menu->current].data); mutt_addrlist_to_local (tmpa); - rfc822_write_address (buf, buflen, tmpa, 0); + rfc822_addrcat(buf, buflen, tmpa, 0); address_list_wipe(&tmpa); }