From: Pierre Habouzit Date: Thu, 30 Nov 2006 22:04:23 +0000 (+0100) Subject: more cosmetics. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=f2ff91d8b7627e22af9715d384b6f9e9e802a39e;p=apps%2Fmadmutt.git more cosmetics. Signed-off-by: Pierre Habouzit --- diff --git a/alias.c b/alias.c index 8d48a78..c511fd7 100644 --- a/alias.c +++ b/alias.c @@ -272,7 +272,7 @@ void mutt_create_alias(ENVELOPE *cur, address_t *iadr) new->addr->personal = m_strdup(buf); buf[0] = '\0'; - rfc822_write_address(buf, sizeof(buf), new->addr, 1); + rfc822_addrcat(buf, sizeof(buf), new->addr, 1); snprintf(prompt, sizeof(prompt), _("[%s = %s] Accept?"), new->name, buf); if (mutt_yesorno(prompt, M_YES) != M_YES) { alias_list_wipe(&new); @@ -298,7 +298,7 @@ void mutt_create_alias(ENVELOPE *cur, address_t *iadr) } buf[0] = '\0'; - rfc822_write_address(buf, sizeof(buf), new->addr, 0); + rfc822_addrcat(buf, sizeof(buf), new->addr, 0); write_safe_address(rc, buf); m_fclose(&rc); mutt_message _("Alias added."); @@ -497,7 +497,7 @@ static const format_t *alias_format_str (char *dest, size_t destlen, char op, break; case 'r': adr[0] = '\0'; - rfc822_write_address(adr, sizeof(adr), alias->addr, 1); + rfc822_addrcat(adr, sizeof(adr), alias->addr, 1); snprintf(tmp, sizeof(tmp), "%%%ss", fmt); snprintf(dest, destlen, tmp, adr); break; @@ -657,14 +657,14 @@ new_aliases: for (i = 0; i < menu->max; i++) { if (AliasTable[i]->tagged) { mutt_addrlist_to_local (AliasTable[i]->addr); - rfc822_write_address (buf, buflen, AliasTable[i]->addr, 0); + rfc822_addrcat(buf, buflen, AliasTable[i]->addr, 0); t = -1; } } if (t != -1) { mutt_addrlist_to_local (AliasTable[t]->addr); - rfc822_write_address (buf, buflen, AliasTable[t]->addr, 0); + rfc822_addrcat(buf, buflen, AliasTable[t]->addr, 0); } mutt_menuDestroy (&menu); diff --git a/commands.c b/commands.c index 7c7d869..82bc240 100644 --- a/commands.c +++ b/commands.c @@ -244,7 +244,7 @@ void ci_bounce_message (HEADER * h, int *redraw) } buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), adr, 1); + rfc822_addrcat(buf, sizeof (buf), adr, 1); #define extra_space (15 + 7 + 2) snprintf (prompt, sizeof (prompt), @@ -576,7 +576,7 @@ void mutt_display_address (ENVELOPE * env) */ buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), adr, 0); + rfc822_addrcat(buf, sizeof (buf), adr, 0); mutt_message ("%s: %s", pfx, buf); } diff --git a/compose.c b/compose.c index 6e68f53..630c6c9 100644 --- a/compose.c +++ b/compose.c @@ -231,7 +231,7 @@ static void draw_envelope_addr (int line, address_t * addr) char buf[STRING]; buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), addr, 1); + rfc822_addrcat(buf, sizeof (buf), addr, 1); mvprintw (line, SW, TITLE_FMT, Prompts[line - 1]); mutt_paddstr (W, buf); } @@ -281,7 +281,7 @@ static int edit_address_list (int line, address_t ** addr) char *err = NULL; mutt_addrlist_to_local (*addr); - rfc822_write_address (buf, sizeof (buf), *addr, 0); + rfc822_addrcat(buf, sizeof (buf), *addr, 0); if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0) { address_list_wipe(addr); *addr = mutt_parse_adrlist (*addr, buf); @@ -301,7 +301,7 @@ static int edit_address_list (int line, address_t ** addr) /* redraw the expanded list so the user can see the result */ buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), *addr, 1); + rfc822_addrcat(buf, sizeof (buf), *addr, 1); move (line, HDR_XOFFSET + SW); mutt_paddstr (W, buf); diff --git a/copy.c b/copy.c index 0c5f8b4..3a8cdfb 100644 --- a/copy.c +++ b/copy.c @@ -794,7 +794,7 @@ static void format_address_header (char **h, address_t * a) a->next = NULL; *buf = *cbuf = *c2buf = '\0'; - rfc822_write_address (buf, sizeof (buf), a, 0); + rfc822_addrcat(buf, sizeof (buf), a, 0); a->next = tmp; l = m_strlen(buf); diff --git a/init.c b/init.c index 21bdd4f..572663c 100644 --- a/init.c +++ b/init.c @@ -499,7 +499,7 @@ static void addr_to_string (char* dst, ssize_t dstlen, struct option_t* option) { char s[HUGE_STRING]; s[0] = '\0'; - rfc822_write_address (s, sizeof(s), *((address_t**) option->data), 0); + rfc822_addrcat(s, sizeof(s), *((address_t**) option->data), 0); snprintf (dst, dstlen, "%s=\"%s\"", option->option, NONULL (s)); } @@ -2302,8 +2302,7 @@ int mutt_var_value_complete (char *buffer, ssize_t len, int pos) mutt_pretty_mailbox (tmp); } else if (DTYPE (option->type) == DT_ADDR) { - rfc822_write_address (tmp, sizeof(tmp), - *((address_t **) option->data), 0); + rfc822_addrcat(tmp, sizeof(tmp), *((address_t **) option->data), 0); } else if (DTYPE (option->type) == DT_QUAD) m_strcpy(tmp, sizeof(tmp), vals[quadoption(option->data)]); diff --git a/lib-crypt/pgpinvoke.c b/lib-crypt/pgpinvoke.c index 39c10ad..551024a 100644 --- a/lib-crypt/pgpinvoke.c +++ b/lib-crypt/pgpinvoke.c @@ -263,10 +263,9 @@ void pgp_invoke_getkeys (address_t * addr) personal = addr->personal; addr->personal = NULL; - *tmp = '\0'; - mutt_addrlist_to_local (addr); - rfc822_write_address_single (tmp, sizeof (tmp), addr, 0); - mutt_quote_filename (buff, sizeof (buff), tmp); + mutt_addrlist_to_local(addr); + rfc822_addrcpy(tmp, sizeof(tmp), addr, 0); + mutt_quote_filename(buff, sizeof(buff), tmp); addr->personal = personal; diff --git a/lib-lib/str.h b/lib-lib/str.h index 25abac8..e456fdd 100644 --- a/lib-lib/str.h +++ b/lib-lib/str.h @@ -29,8 +29,8 @@ #define STRING 256 #define SHORT_STRING 128 -#define NONULL(x) (x?x:"") -#define ISSPACE(c) isspace((unsigned char)c) +#define NONULL(x) (x?x:"") +#define ISSPACE(c) isspace((unsigned char)c) extern unsigned char const __m_strdigits[128]; extern signed char const __m_b64digits[128]; @@ -100,7 +100,7 @@ static inline int m_strcasecmp(const char *a, const char *b) { } static inline int m_strncmp(const char *a, const char *b, ssize_t n) { - return strncmp (NONULL(a), NONULL(b), n); + return strncmp(NONULL(a), NONULL(b), n); } static inline int m_strncasecmp(const char *a, const char *b, ssize_t n) { diff --git a/lib-mime/mime.h b/lib-mime/mime.h index 8e0e0e7..e5ab93d 100644 --- a/lib-mime/mime.h +++ b/lib-mime/mime.h @@ -120,8 +120,8 @@ void rfc822_qualify(address_t *, const char *); address_t *rfc822_parse_adrlist(address_t *, const char *s); -ssize_t rfc822_write_address(char *, ssize_t, address_t *, int); -ssize_t rfc822_write_address_single(char *, ssize_t, address_t *, int); +ssize_t rfc822_addrcat(char *, ssize_t, address_t *, int); +ssize_t rfc822_addrcpy(char *, ssize_t, address_t *, int); ssize_t rfc822_strcpy(char *, ssize_t, const char *, const char *); /****************************************************************************/ diff --git a/lib-mime/rfc822address.c b/lib-mime/rfc822address.c index a6a06c4..6277ee9 100644 --- a/lib-mime/rfc822address.c +++ b/lib-mime/rfc822address.c @@ -389,8 +389,8 @@ rfc822_strcpy(char *buf, ssize_t buflen, const char *p, const char *specials) } } -ssize_t rfc822_write_address_single(char *buf, ssize_t buflen, - address_t *addr, int display) +ssize_t +rfc822_addrcpy(char *buf, ssize_t buflen, address_t *addr, int display) { ssize_t pos = 0; @@ -403,11 +403,8 @@ ssize_t rfc822_write_address_single(char *buf, ssize_t buflen, } if (addr->mailbox) { - if (!display) { - pos += m_strcpy(buf + pos, buflen - pos, addr->mailbox); - } else { - pos += m_strcpy(buf + pos, buflen - pos, mutt_addr_for_display(addr)); - } + pos += m_strcpy(buf + pos, buflen - pos, + display ? mutt_addr_for_display(addr) : addr->mailbox); if (addr->personal) { pos += m_strputc(buf + pos, buflen - pos, '>'); @@ -425,19 +422,15 @@ ssize_t rfc822_write_address_single(char *buf, ssize_t buflen, /* note: it is assumed that `buf' is nul terminated! */ ssize_t -rfc822_write_address(char *buf, ssize_t buflen, address_t *addr, int display) +rfc822_addrcat(char *buf, ssize_t buflen, address_t *addr, int display) { - ssize_t pos; + ssize_t pos = m_strnlen(buf, buflen); - pos = m_strnlen(buf, buflen); - - if (pos) { + if (pos) pos += m_strcpy(buf + pos, buflen - pos, ", "); - } for (; addr; addr = addr->next) { - pos += rfc822_write_address_single(buf + pos, buflen - pos, - addr, display); + pos += rfc822_addrcpy(buf + pos, buflen - pos, addr, display); if (!addr->group && addr->next && addr->next->mailbox) { /* if there is another address, and its not a group mailbox name or diff --git a/lib-ui/hdrline.c b/lib-ui/hdrline.c index fa3a28d..f3e138b 100644 --- a/lib-ui/hdrline.c +++ b/lib-ui/hdrline.c @@ -395,7 +395,7 @@ static const char *hdr_format_str (char *dest, case 'f': buf2[0] = 0; - rfc822_write_address (buf2, sizeof (buf2), hdr->env->from, 1); + rfc822_addrcat(buf2, sizeof (buf2), hdr->env->from, 1); mutt_format_s (dest, destlen, prefix, buf2); break; diff --git a/lib-ui/query.c b/lib-ui/query.c index 2ce8961..99631bf 100644 --- a/lib-ui/query.c +++ b/lib-ui/query.c @@ -171,7 +171,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, @@ -213,7 +213,7 @@ 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); @@ -426,7 +426,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); } @@ -435,8 +435,7 @@ static void query_menu (char *buf, ssize_t buflen, QUERY * results, int retbuf) mutt_addrlist_to_local (tmpa); m_strcat(buf, buflen, ", "); - rfc822_write_address ((char *) buf + curpos + 1, - buflen - curpos - 1, tmpa, 0); + rfc822_addrcat(buf + curpos + 1, buflen - curpos - 1, tmpa, 0); curpos = m_strlen(buf); address_list_wipe(&tmpa); } @@ -447,7 +446,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); } diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 134040c..68e14fc 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -896,7 +896,7 @@ int nntp_save_cache_group (CONTEXT * ctx) if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev) { h = ctx->hdrs[i]; addr[0] = 0; - rfc822_write_address (addr, sizeof (addr), h->env->from, 0); + rfc822_addrcat(addr, sizeof(addr), h->env->from, 0); tm = gmtime (&h->date_sent); snprintf (buf, sizeof (buf), "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t", diff --git a/recvcmd.c b/recvcmd.c index 0c99da8..289b580 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -153,7 +153,7 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr __attribute__ ((unused)), } buf[0] = 0; - rfc822_write_address (buf, sizeof (buf), adr, 1); + rfc822_addrcat(buf, sizeof(buf), adr, 1); #define extra_space (15+7+2) /* diff --git a/send.c b/send.c index f5ffa26..82579d5 100644 --- a/send.c +++ b/send.c @@ -164,7 +164,7 @@ static int edit_address (address_t ** a, const char *field) do { buf[0] = 0; mutt_addrlist_to_local (*a); - rfc822_write_address (buf, sizeof (buf), *a, 0); + rfc822_addrcat(buf, sizeof(buf), *a, 0); if (mutt_get_field (field, buf, sizeof (buf), M_ALIAS) != 0) return (-1); address_list_wipe(a); @@ -353,7 +353,7 @@ void mutt_forward_intro (FILE * fp, HEADER * cur) fputs ("----- Forwarded message from ", fp); buffer[0] = 0; - rfc822_write_address (buffer, sizeof (buffer), cur->env->from, 1); + rfc822_addrcat(buffer, sizeof(buffer), cur->env->from, 1); fputs (buffer, fp); fputs (" -----\n\n", fp); } diff --git a/sendlib.c b/sendlib.c index ff53c45..b8ece6d 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1279,9 +1279,7 @@ mutt_write_address_list(address_t *addr, FILE *fp, int linelen, int display) while (addr) { char buf[LONG_STRING]; - int len; - - len = rfc822_write_address_single(buf, ssizeof(buf), addr, display); + int len = rfc822_addrcpy(buf, ssizeof(buf), addr, display); if (!first) { if (linelen + len > 74) { @@ -1378,7 +1376,7 @@ int mutt_write_rfc822_header (FILE * fp, ENVELOPE * env, BODY * attach, */ if (env->from && !privacy) { buffer[0] = 0; - rfc822_write_address (buffer, sizeof (buffer), env->from, 0); + rfc822_addrcat(buffer, sizeof(buffer), env->from, 0); fprintf (fp, "From: %s\n", buffer); } @@ -1551,8 +1549,7 @@ const char *mutt_fqdn (short may_hide_host) p++; /* sanity check: don't hide the host if - * the fqdn is something like detebe.org. - */ + the fqdn is something like detebe.org. */ if (!p || !(q = strchr (p, '.'))) p = Fqdn; @@ -1730,8 +1727,7 @@ send_msg(const char *path, const char **args, const char *msg, char **tempfile) /* redirect stderr to *tempfile too */ if (dup (1) < 0) _exit (S_ERR); - } - else { + } else { if (open ("/dev/null", O_WRONLY | O_APPEND) < 0) /* stdout */ _exit (S_ERR); if (open ("/dev/null", O_RDWR | O_APPEND) < 0) /* stderr */ @@ -1773,8 +1769,7 @@ send_msg(const char *path, const char **args, const char *msg, char **tempfile) unlink (*tempfile); /* no longer needed */ p_delete(tempfile); } - } - else { + } else { st = (SendmailWait > 0 && errno == EINTR && SigAlrm) ? S_BKG : S_ERR; if (SendmailWait > 0) { unlink (*tempfile); @@ -2005,20 +2000,20 @@ void mutt_prepare_envelope (ENVELOPE * env, int final) void mutt_unprepare_envelope (ENVELOPE * env) { - string_list_t *item; + string_list_t *item; - for (item = env->userhdrs; item; item = item->next) - rfc2047_decode (&item->data); + for (item = env->userhdrs; item; item = item->next) + rfc2047_decode(&item->data); - address_list_wipe(&env->mail_followup_to); + address_list_wipe(&env->mail_followup_to); - /* back conversions */ - rfc2047_decode_adrlist (env->to); - rfc2047_decode_adrlist (env->cc); - rfc2047_decode_adrlist (env->bcc); - rfc2047_decode_adrlist (env->from); - rfc2047_decode_adrlist (env->reply_to); - rfc2047_decode (&env->subject); + /* back conversions */ + rfc2047_decode_adrlist(env->to); + rfc2047_decode_adrlist(env->cc); + rfc2047_decode_adrlist(env->bcc); + rfc2047_decode_adrlist(env->from); + rfc2047_decode_adrlist(env->reply_to); + rfc2047_decode(&env->subject); } static int _mutt_bounce_message (FILE * fp, HEADER * h, address_t * to, @@ -2087,12 +2082,12 @@ int mutt_bounce_message (FILE * fp, HEADER * h, address_t * to) rfc822_qualify(from, mutt_fqdn(1)); - rfc2047_encode_adrlist (from, "Resent-From"); + rfc2047_encode_adrlist(from, "Resent-From"); if (mutt_addrlist_to_idna (from, &err)) { mutt_error (_("Bad IDN %s while preparing resent-from."), err); return -1; } - rfc822_write_address (resent_from, sizeof (resent_from), from, 0); + rfc822_addrcat(resent_from, sizeof(resent_from), from, 0); #ifdef USE_NNTP unset_option (OPTNEWSSEND);