X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=query.c;h=2a60afa1760c9247fbcf2a63953be27c2edb4843;hp=1aa7b8aa4af0ce788c3bab552760fae70c603ed0;hb=2a2f2f9a5bad73c883b7f9c9b4166d932b6aaf37;hpb=cfc49a0d8c3ac2c0bd4b217026d0740c55f2e5db diff --git a/query.c b/query.c index 1aa7b8a..2a60afa 100644 --- a/query.c +++ b/query.c @@ -11,23 +11,23 @@ # include "config.h" #endif +#include +#include +#include + #include #include #include #include #include +#include + #include "mutt.h" -#include "mutt_menu.h" +#include "alias.h" #include "mutt_idna.h" #include "sort.h" -#include "lib/debug.h" - -#include -#include -#include - typedef struct query { address_t *addr; char *name; @@ -54,14 +54,14 @@ static struct mapping_t QueryHelp[] = { static int FirstColumn; static int SecondColumn; -static void query_menu (char *buf, size_t buflen, QUERY * results, +static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf); static address_t *result_to_addr (QUERY * r) { static address_t *tmp; - tmp = rfc822_cpy_adr (r->addr); + tmp = address_list_dup (r->addr); if (!tmp->next && !tmp->personal) tmp->personal = m_strdup(r->name); @@ -77,7 +77,7 @@ static QUERY *run_query (char *s, int quiet) QUERY *cur = NULL; char cmd[_POSIX_PATH_MAX]; char *buf = NULL; - size_t buflen; + ssize_t buflen; int dummy = 0; char msg[STRING]; char *p; @@ -88,7 +88,6 @@ static QUERY *run_query (char *s, int quiet) mutt_expand_file_fmt (cmd, sizeof (cmd), QueryCmd, s); if ((thepid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) { - debug_print (1, ("unable to fork command: %s\n", cmd)); return 0; } if (!quiet) @@ -131,7 +130,6 @@ static QUERY *run_query (char *s, int quiet) p_delete(&buf); fclose (fp); if (mutt_wait_filter (thepid)) { - debug_print (1, ("Error: %s\n", msg)); if (!quiet) mutt_error ("%s", msg); } @@ -167,7 +165,7 @@ static int query_search (MUTTMENU * m, regex_t * re, int n) * a menu entry for the requested item number. */ #define QUERY_MIN_COLUMN_LENGHT 20 /* Must be < 70/2 */ -static void query_entry (char *s, size_t slen, MUTTMENU * m, int num) +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] = ""; @@ -206,7 +204,7 @@ static int query_tag (MUTTMENU * menu, int n, int m) return cur->tagged - ot; } -int mutt_query_complete (char *buf, size_t buflen) +int mutt_query_complete (char *buf, ssize_t buflen) { QUERY *results = NULL; address_t *tmpa; @@ -225,7 +223,7 @@ int mutt_query_complete (char *buf, size_t buflen) mutt_addrlist_to_local (tmpa); buf[0] = '\0'; rfc822_write_address (buf, buflen, tmpa, 0); - address_delete (&tmpa); + address_list_wipe(&tmpa); mutt_clear_error (); return (0); } @@ -235,7 +233,7 @@ int mutt_query_complete (char *buf, size_t buflen) return (0); } -void mutt_query_menu (char *buf, size_t buflen) +void mutt_query_menu (char *buf, ssize_t buflen) { if (!QueryCmd) { mutt_error _("Query command not defined."); @@ -253,7 +251,7 @@ void mutt_query_menu (char *buf, size_t buflen) } } -static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) +static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) { MUTTMENU *menu; HEADER *msg = NULL; @@ -310,7 +308,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) if (op == OP_QUERY) { queryp = results; while (queryp) { - address_delete (&queryp->addr); + address_list_wipe(&queryp->addr); p_delete(&queryp->name); p_delete(&queryp->other); results = queryp->next; @@ -380,10 +378,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) for (i = 0; i < menu->max; i++) if (QueryTable[i].tagged) { - address_t *a = result_to_addr (QueryTable[i].data); - - rfc822_append (&naddr, a); - address_delete (&a); + address_list_append(&naddr, result_to_addr(QueryTable[i].data)); } mutt_create_alias (NULL, naddr); @@ -392,7 +387,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) address_t *a = result_to_addr (QueryTable[menu->current].data); mutt_create_alias (NULL, a); - address_delete (&a); + address_list_wipe(&a); } break; @@ -404,18 +399,15 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) /* fall through to OP_MAIL */ case OP_MAIL: - msg = mutt_new_header (); - msg->env = mutt_new_envelope (); + msg = header_new(); + msg->env = envelope_new(); if (!menu->tagprefix) { msg->env->to = result_to_addr (QueryTable[menu->current].data); } else { for (i = 0; i < menu->max; i++) if (QueryTable[i].tagged) { - address_t *a = result_to_addr (QueryTable[i].data); - - rfc822_append (&msg->env->to, a); - address_delete (&a); + address_list_append(&msg->env->to, result_to_addr(QueryTable[i].data)); } } ci_send_message (0, msg, NULL, Context, NULL); @@ -431,7 +423,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) /* if we need to return the selected entries */ if (retbuf && (done == 2)) { int tagged = 0; - size_t curpos = 0; + ssize_t curpos = 0; p_clear(buf, buflen); @@ -445,7 +437,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) tagged = 1; rfc822_write_address (buf, buflen, tmpa, 0); curpos = m_strlen(buf); - address_delete (&tmpa); + address_list_wipe(&tmpa); } else if (curpos + 2 < buflen) { address_t *tmpa = result_to_addr (QueryTable[i].data); @@ -455,7 +447,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) rfc822_write_address ((char *) buf + curpos + 1, buflen - curpos - 1, tmpa, 0); curpos = m_strlen(buf); - address_delete (&tmpa); + address_list_wipe(&tmpa); } } } @@ -465,14 +457,14 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) mutt_addrlist_to_local (tmpa); rfc822_write_address (buf, buflen, tmpa, 0); - address_delete (&tmpa); + address_list_wipe(&tmpa); } } queryp = results; while (queryp) { - address_delete (&queryp->addr); + address_list_wipe(&queryp->addr); p_delete(&queryp->name); p_delete(&queryp->other); results = queryp->next;