From: Richard Russon Date: Thu, 16 Nov 2017 01:37:37 +0000 (+0000) Subject: rename string functions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fpull%2F955%2Fhead;p=neomutt rename string functions --- diff --git a/addrbook.c b/addrbook.c index 11405abb1..8eac5c9a9 100644 --- a/addrbook.c +++ b/addrbook.c @@ -104,7 +104,7 @@ static int alias_sort_alias(const void *a, const void *b) { struct Alias *pa = *(struct Alias **) a; struct Alias *pb = *(struct Alias **) b; - int r = mutt_strcasecmp(pa->name, pb->name); + int r = mutt_str_strcasecmp(pa->name, pb->name); return (RSORT(r)); } @@ -124,14 +124,14 @@ static int alias_sort_address(const void *a, const void *b) else if (pa->personal) { if (pb->personal) - r = mutt_strcasecmp(pa->personal, pb->personal); + r = mutt_str_strcasecmp(pa->personal, pb->personal); else r = 1; } else if (pb->personal) r = -1; else - r = mutt_strcasecmp(pa->mailbox, pb->mailbox); + r = mutt_str_strcasecmp(pa->mailbox, pb->mailbox); return (RSORT(r)); } diff --git a/alias.c b/alias.c index dc580a591..d5b8e126d 100644 --- a/alias.c +++ b/alias.c @@ -50,7 +50,7 @@ struct Address *mutt_lookup_alias(const char *s) struct Alias *t = Aliases; for (; t; t = t->next) - if (mutt_strcasecmp(s, t->name) == 0) + if (mutt_str_strcasecmp(s, t->name) == 0) return t->addr; return NULL; /* no such alias */ } @@ -73,7 +73,7 @@ static struct Address *expand_aliases_r(struct Address *a, struct ListHead *expn struct ListNode *np; STAILQ_FOREACH(np, expn, entries) { - if (mutt_strcmp(a->mailbox, np->data) == 0) /* alias already found */ + if (mutt_str_strcmp(a->mailbox, np->data) == 0) /* alias already found */ { mutt_debug(1, "expand_aliases_r(): loop in alias found for '%s'\n", a->mailbox); i = true; @@ -83,7 +83,7 @@ static struct Address *expand_aliases_r(struct Address *a, struct ListHead *expn if (!i) { - mutt_list_insert_head(expn, safe_strdup(a->mailbox)); + mutt_list_insert_head(expn, mutt_str_strdup(a->mailbox)); w = rfc822_cpy_adr(t, 0); w = expand_aliases_r(w, expn); if (head) @@ -228,11 +228,11 @@ static void recode_buf(char *buf, size_t buflen) if (!ConfigCharset || !*ConfigCharset || !Charset) return; - s = safe_strdup(buf); + s = mutt_str_strdup(buf); if (!s) return; if (mutt_convert_string(&s, Charset, ConfigCharset, 0) == 0) - strfcpy(buf, s, buflen); + mutt_str_strfcpy(buf, s, buflen); FREE(&s); } @@ -302,7 +302,7 @@ void mutt_create_alias(struct Envelope *cur, struct Address *iadr) if (adr && adr->mailbox) { - strfcpy(tmp, adr->mailbox, sizeof(tmp)); + mutt_str_strfcpy(tmp, adr->mailbox, sizeof(tmp)); if ((pc = strchr(tmp, '@'))) *pc = '\0'; } @@ -329,7 +329,7 @@ retry_name: switch (mutt_yesorno(_("Warning: This alias name may not work. Fix it?"), MUTT_YES)) { case MUTT_YES: - strfcpy(buf, fixed, sizeof(buf)); + mutt_str_strfcpy(buf, fixed, sizeof(buf)); goto retry_name; case MUTT_ABORT: return; @@ -337,12 +337,12 @@ retry_name: } new = mutt_mem_calloc(1, sizeof(struct Alias)); - new->name = safe_strdup(buf); + new->name = mutt_str_strdup(buf); mutt_addrlist_to_local(adr); if (adr && adr->mailbox) - strfcpy(buf, adr->mailbox, sizeof(buf)); + mutt_str_strfcpy(buf, adr->mailbox, sizeof(buf)); else buf[0] = '\0'; @@ -368,7 +368,7 @@ retry_name: } while (!new->addr); if (adr && adr->personal && !mutt_is_mail_list(adr)) - strfcpy(buf, adr->personal, sizeof(buf)); + mutt_str_strfcpy(buf, adr->personal, sizeof(buf)); else buf[0] = '\0'; @@ -377,7 +377,7 @@ retry_name: mutt_free_alias(&new); return; } - new->addr->personal = safe_strdup(buf); + new->addr->personal = mutt_str_strdup(buf); buf[0] = '\0'; rfc822_write_address(buf, sizeof(buf), new->addr, 1); @@ -399,7 +399,7 @@ retry_name: else Aliases = new; - strfcpy(buf, NONULL(AliasFile), sizeof(buf)); + mutt_str_strfcpy(buf, NONULL(AliasFile), sizeof(buf)); if (mutt_get_field(_("Save to file: "), buf, sizeof(buf), MUTT_FILE) != 0) return; mutt_expand_path(buf, sizeof(buf)); @@ -427,7 +427,7 @@ retry_name: if (check_alias_name(new->name, NULL, 0)) mutt_file_quote_filename(buf, sizeof(buf), new->name); else - strfcpy(buf, new->name, sizeof(buf)); + mutt_str_strfcpy(buf, new->name, sizeof(buf)); recode_buf(buf, sizeof(buf)); fprintf(rc, "alias %s ", buf); buf[0] = '\0'; @@ -520,7 +520,8 @@ int mutt_alias_complete(char *s, size_t buflen) if (a->name && strstr(a->name, s) == a->name) { if (!bestname[0]) /* init */ - strfcpy(bestname, a->name, MIN(mutt_strlen(a->name) + 1, sizeof(bestname))); + mutt_str_strfcpy(bestname, a->name, + MIN(mutt_str_strlen(a->name) + 1, sizeof(bestname))); else { for (i = 0; a->name[i] && a->name[i] == bestname[i]; i++) @@ -533,10 +534,10 @@ int mutt_alias_complete(char *s, size_t buflen) if (bestname[0] != 0) { - if (mutt_strcmp(bestname, s) != 0) + if (mutt_str_strcmp(bestname, s) != 0) { /* we are adding something to the completion */ - strfcpy(s, bestname, mutt_strlen(bestname) + 1); + mutt_str_strfcpy(s, bestname, mutt_str_strlen(bestname) + 1); return 1; } @@ -565,7 +566,7 @@ int mutt_alias_complete(char *s, size_t buflen) bestname[0] = '\0'; mutt_alias_menu(bestname, sizeof(bestname), a_list ? a_list : Aliases); if (bestname[0] != 0) - strfcpy(s, bestname, buflen); + mutt_str_strfcpy(s, bestname, buflen); /* free the alias list */ while (a_list) @@ -609,7 +610,7 @@ static bool string_is_address(const char *str, const char *u, const char *d) char buf[LONG_STRING]; snprintf(buf, sizeof(buf), "%s@%s", NONULL(u), NONULL(d)); - if (mutt_strcasecmp(str, buf) == 0) + if (mutt_str_strcasecmp(str, buf) == 0) return true; return false; @@ -635,7 +636,7 @@ bool mutt_addr_is_user(struct Address *addr) return false; } - if (mutt_strcasecmp(addr->mailbox, Username) == 0) + if (mutt_str_strcasecmp(addr->mailbox, Username) == 0) { mutt_debug(5, "mutt_addr_is_user: yes, %s = %s\n", addr->mailbox, Username); return true; @@ -661,7 +662,7 @@ bool mutt_addr_is_user(struct Address *addr) return true; } - if (From && (mutt_strcasecmp(From->mailbox, addr->mailbox) == 0)) + if (From && (mutt_str_strcasecmp(From->mailbox, addr->mailbox) == 0)) { mutt_debug(5, "mutt_addr_is_user: yes, %s = %s\n", addr->mailbox, From->mailbox); return true; diff --git a/attach.c b/attach.c index 92fde687f..7e4635404 100644 --- a/attach.c +++ b/attach.c @@ -110,9 +110,9 @@ int mutt_compose_attachment(struct Body *a) if (entry->composecommand || entry->composetypecommand) { if (entry->composetypecommand) - strfcpy(command, entry->composetypecommand, sizeof(command)); + mutt_str_strfcpy(command, entry->composetypecommand, sizeof(command)); else - strfcpy(command, entry->composecommand, sizeof(command)); + mutt_str_strfcpy(command, entry->composecommand, sizeof(command)); if (rfc1524_expand_filename(entry->nametemplate, a->filename, newfile, sizeof(newfile))) { mutt_debug(1, "oldfile: %s\t newfile: %s\n", a->filename, newfile); @@ -125,7 +125,7 @@ int mutt_compose_attachment(struct Body *a) unlink_newfile = true; } else - strfcpy(newfile, a->filename, sizeof(newfile)); + mutt_str_strfcpy(newfile, a->filename, sizeof(newfile)); if (rfc1524_expand_command(a, newfile, type, command, sizeof(command))) { @@ -246,7 +246,7 @@ int mutt_edit_attachment(struct Body *a) { if (entry->editcommand) { - strfcpy(command, entry->editcommand, sizeof(command)); + mutt_str_strfcpy(command, entry->editcommand, sizeof(command)); if (rfc1524_expand_filename(entry->nametemplate, a->filename, newfile, sizeof(newfile))) { mutt_debug(1, "oldfile: %s\t newfile: %s\n", a->filename, newfile); @@ -259,7 +259,7 @@ int mutt_edit_attachment(struct Body *a) unlink_newfile = true; } else - strfcpy(newfile, a->filename, sizeof(newfile)); + mutt_str_strfcpy(newfile, a->filename, sizeof(newfile)); if (rfc1524_expand_command(a, newfile, type, command, sizeof(command))) { @@ -314,10 +314,10 @@ void mutt_check_lookup_list(struct Body *b, char *type, int len) struct ListNode *np; STAILQ_FOREACH(np, &MimeLookupList, entries) { - i = mutt_strlen(np->data) - 1; + i = mutt_str_strlen(np->data) - 1; if ((i > 0 && np->data[i - 1] == '/' && np->data[i] == '*' && - (mutt_strncasecmp(type, np->data, i) == 0)) || - (mutt_strcasecmp(type, np->data) == 0)) + (mutt_str_strncasecmp(type, np->data, i) == 0)) || + (mutt_str_strcasecmp(type, np->data) == 0)) { struct Body tmp = { 0 }; int n; @@ -418,11 +418,11 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr, mutt_error(_("MIME type not defined. Cannot view attachment.")); goto return_error; } - strfcpy(command, entry->command, sizeof(command)); + mutt_str_strfcpy(command, entry->command, sizeof(command)); if (fp) { - fname = safe_strdup(a->filename); + fname = mutt_str_strdup(a->filename); mutt_file_sanitize_filename(fname, 1); } else @@ -430,13 +430,13 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr, if (rfc1524_expand_filename(entry->nametemplate, fname, tempfile, sizeof(tempfile))) { - if (fp == NULL && (mutt_strcmp(tempfile, a->filename) != 0)) + if (fp == NULL && (mutt_str_strcmp(tempfile, a->filename) != 0)) { /* send case: the file is already there */ if (mutt_file_symlink(a->filename, tempfile) == -1) { if (mutt_yesorno(_("Can't match nametemplate, continue?"), MUTT_YES) == MUTT_YES) - strfcpy(tempfile, a->filename, sizeof(tempfile)); + mutt_str_strfcpy(tempfile, a->filename, sizeof(tempfile)); else goto return_error; } @@ -445,7 +445,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr, } } else if (!fp) /* send case */ - strfcpy(tempfile, a->filename, sizeof(tempfile)); + mutt_str_strfcpy(tempfile, a->filename, sizeof(tempfile)); if (fp) { @@ -465,7 +465,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr, if (fp && !use_mailcap && a->filename) { /* recv case */ - strfcpy(pagerfile, a->filename, sizeof(pagerfile)); + mutt_str_strfcpy(pagerfile, a->filename, sizeof(pagerfile)); mutt_adv_mktemp(pagerfile, sizeof(pagerfile)); } else @@ -596,7 +596,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr, } if (a->description) - strfcpy(descrip, a->description, sizeof(descrip)); + mutt_str_strfcpy(descrip, a->description, sizeof(descrip)); else if (a->filename) snprintf(descrip, sizeof(descrip), _("---Attachment: %s: %s"), a->filename, type); else @@ -1012,7 +1012,7 @@ int mutt_print_attachment(FILE *fp, struct Body *a) rfc1524_free_entry(&entry); return 0; } - strfcpy(newfile, a->filename, sizeof(newfile)); + mutt_str_strfcpy(newfile, a->filename, sizeof(newfile)); } else unlink_newfile = true; @@ -1023,7 +1023,7 @@ int mutt_print_attachment(FILE *fp, struct Body *a) if (fp && (mutt_save_attachment(fp, a, newfile, 0, NULL) != 0)) return 0; - strfcpy(command, entry->printcommand, sizeof(command)); + mutt_str_strfcpy(command, entry->printcommand, sizeof(command)); piped = rfc1524_expand_command(a, newfile, type, command, sizeof(command)); mutt_endwin(NULL); @@ -1072,8 +1072,8 @@ int mutt_print_attachment(FILE *fp, struct Body *a) return 1; } - if ((mutt_strcasecmp("text/plain", type) == 0) || - (mutt_strcasecmp("application/postscript", type) == 0)) + if ((mutt_str_strcasecmp("text/plain", type) == 0) || + (mutt_str_strcasecmp("application/postscript", type) == 0)) { return (mutt_pipe_attachment(fp, a, NONULL(PrintCommand), NULL)); } diff --git a/bcache.c b/bcache.c index 1f83a09a2..ebc1aa8a5 100644 --- a/bcache.c +++ b/bcache.c @@ -71,7 +71,7 @@ static int bcache_path(struct Account *account, const char *mailbox, char *dst, mutt_encode_path(path, sizeof(path), NONULL(mailbox)); - int plen = mutt_strlen(path); + int plen = mutt_str_strlen(path); if (plen == 0) return -1; @@ -114,7 +114,7 @@ struct BodyCache *mutt_bcache_open(struct Account *account, const char *mailbox) bcache = mutt_mem_calloc(1, sizeof(struct BodyCache)); if (bcache_path(account, mailbox, bcache->path, sizeof(bcache->path)) < 0) goto bail; - bcache->pathlen = mutt_strlen(bcache->path); + bcache->pathlen = mutt_str_strlen(bcache->path); return bcache; @@ -140,8 +140,8 @@ FILE *mutt_bcache_get(struct BodyCache *bcache, const char *id) return NULL; path[0] = '\0'; - safe_strncat(path, sizeof(path), bcache->path, bcache->pathlen); - safe_strncat(path, sizeof(path), id, mutt_strlen(id)); + mutt_str_strncat(path, sizeof(path), bcache->path, bcache->pathlen); + mutt_str_strncat(path, sizeof(path), id, mutt_str_strlen(id)); fp = mutt_file_fopen(path, "r"); @@ -203,8 +203,8 @@ int mutt_bcache_del(struct BodyCache *bcache, const char *id) return -1; path[0] = '\0'; - safe_strncat(path, sizeof(path), bcache->path, bcache->pathlen); - safe_strncat(path, sizeof(path), id, mutt_strlen(id)); + mutt_str_strncat(path, sizeof(path), bcache->path, bcache->pathlen); + mutt_str_strncat(path, sizeof(path), id, mutt_str_strlen(id)); mutt_debug(3, "bcache: del: '%s'\n", path); @@ -221,8 +221,8 @@ int mutt_bcache_exists(struct BodyCache *bcache, const char *id) return -1; path[0] = '\0'; - safe_strncat(path, sizeof(path), bcache->path, bcache->pathlen); - safe_strncat(path, sizeof(path), id, mutt_strlen(id)); + mutt_str_strncat(path, sizeof(path), bcache->path, bcache->pathlen); + mutt_str_strncat(path, sizeof(path), id, mutt_str_strlen(id)); if (stat(path, &st) < 0) rc = -1; @@ -251,8 +251,8 @@ int mutt_bcache_list(struct BodyCache *bcache, while ((de = readdir(d))) { - if ((mutt_strncmp(de->d_name, ".", 1) == 0) || - (mutt_strncmp(de->d_name, "..", 2) == 0)) + if ((mutt_str_strncmp(de->d_name, ".", 1) == 0) || + (mutt_str_strncmp(de->d_name, "..", 2) == 0)) continue; mutt_debug(3, "bcache: list: dir: '%s', id :'%s'\n", bcache->path, de->d_name); diff --git a/body.c b/body.c index 272f58428..ae8219b33 100644 --- a/body.c +++ b/body.c @@ -60,7 +60,7 @@ int mutt_copy_body(FILE *fp, struct Body **tgt, struct Body *src) if (src->filename) { use_disp = true; - strfcpy(tmp, src->filename, sizeof(tmp)); + mutt_str_strfcpy(tmp, src->filename, sizeof(tmp)); } else { @@ -79,22 +79,22 @@ int mutt_copy_body(FILE *fp, struct Body **tgt, struct Body *src) b->parts = NULL; b->next = NULL; - b->filename = safe_strdup(tmp); + b->filename = mutt_str_strdup(tmp); b->use_disp = use_disp; b->unlink = true; if (mutt_is_text_part(b)) b->noconv = true; - b->xtype = safe_strdup(b->xtype); - b->subtype = safe_strdup(b->subtype); - b->form_name = safe_strdup(b->form_name); - b->d_filename = safe_strdup(b->d_filename); + b->xtype = mutt_str_strdup(b->xtype); + b->subtype = mutt_str_strdup(b->subtype); + b->form_name = mutt_str_strdup(b->form_name); + b->d_filename = mutt_str_strdup(b->d_filename); /* mutt_adv_mktemp() will mangle the filename in tmp, * so preserve it in d_filename */ if (!b->d_filename && use_disp) - b->d_filename = safe_strdup(src->filename); - b->description = safe_strdup(b->description); + b->d_filename = mutt_str_strdup(src->filename); + b->description = mutt_str_strdup(b->description); /* * we don't seem to need the Header structure currently. @@ -108,8 +108,8 @@ int mutt_copy_body(FILE *fp, struct Body **tgt, struct Body *src) for (par = b->parameter, ppar = &b->parameter; par; ppar = &(*ppar)->next, par = par->next) { *ppar = mutt_new_parameter(); - (*ppar)->attribute = safe_strdup(par->attribute); - (*ppar)->value = safe_strdup(par->value); + (*ppar)->attribute = mutt_str_strdup(par->attribute); + (*ppar)->value = mutt_str_strdup(par->value); } mutt_stamp_attachment(b); diff --git a/browser.c b/browser.c index b68e0699d..54d1eaf46 100644 --- a/browser.c +++ b/browser.c @@ -133,7 +133,7 @@ static int browser_compare_subject(const void *a, const void *b) /* inbox should be sorted ahead of its siblings */ int r = mutt_inbox_cmp(pa->name, pb->name); if (r == 0) - r = mutt_strcoll(pa->name, pb->name); + r = mutt_str_strcoll(pa->name, pb->name); return ((SortBrowser & SORT_REVERSE) ? -r : r); } @@ -142,7 +142,7 @@ static int browser_compare_desc(const void *a, const void *b) struct FolderFile *pa = (struct FolderFile *) a; struct FolderFile *pb = (struct FolderFile *) b; - int r = mutt_strcoll(pa->desc, pb->desc); + int r = mutt_str_strcoll(pa->desc, pb->desc); return ((SortBrowser & SORT_REVERSE) ? -r : r); } @@ -211,9 +211,9 @@ static int browser_compare(const void *a, const void *b) struct FolderFile *pa = (struct FolderFile *) a; struct FolderFile *pb = (struct FolderFile *) b; - if ((mutt_strcoll(pa->desc, "../") == 0) || (mutt_strcoll(pa->desc, "..") == 0)) + if ((mutt_str_strcoll(pa->desc, "../") == 0) || (mutt_str_strcoll(pa->desc, "..") == 0)) return -1; - if ((mutt_strcoll(pb->desc, "../") == 0) || (mutt_strcoll(pb->desc, "..") == 0)) + if ((mutt_str_strcoll(pb->desc, "../") == 0) || (mutt_str_strcoll(pb->desc, "..") == 0)) return 1; switch (SortBrowser & SORT_MASK) @@ -579,7 +579,7 @@ static const char *newsgroup_format_str(char *dest, size_t destlen, size_t col, case 'd': if (folder->ff->nd->desc) { - char *buf = safe_strdup(folder->ff->nd->desc); + char *buf = mutt_str_strdup(folder->ff->nd->desc); if (NewsgroupsCharset && *NewsgroupsCharset) mutt_convert_string(&buf, NewsgroupsCharset, Charset, MUTT_ICONV_HOOK_FROM); mutt_filter_unprintable(&buf); @@ -633,8 +633,8 @@ static void add_folder(struct Menu *m, struct BrowserState *state, const char *n (state->entry)[state->entrylen].msg_unread = b->msg_unread; } - (state->entry)[state->entrylen].name = safe_strdup(name); - (state->entry)[state->entrylen].desc = safe_strdup(desc ? desc : name); + (state->entry)[state->entrylen].name = mutt_str_strdup(name); + (state->entry)[state->entrylen].desc = mutt_str_strdup(desc ? desc : name); #ifdef USE_IMAP (state->entry)[state->entrylen].imap = false; #endif @@ -727,10 +727,11 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state, while ((de = readdir(dp)) != NULL) { - if (mutt_strcmp(de->d_name, ".") == 0) + if (mutt_str_strcmp(de->d_name, ".") == 0) continue; /* we don't need . */ - if (prefix && *prefix && (mutt_strncmp(prefix, de->d_name, mutt_strlen(prefix)) != 0)) + if (prefix && *prefix && + (mutt_str_strncmp(prefix, de->d_name, mutt_str_strlen(prefix)) != 0)) continue; if (!((regexec(Mask.regex, de->d_name, 0, NULL, 0) == 0) ^ Mask.not)) continue; @@ -743,9 +744,9 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state, continue; tmp = Incoming; - while (tmp && (mutt_strcmp(buffer, tmp->path) != 0)) + while (tmp && (mutt_str_strcmp(buffer, tmp->path) != 0)) tmp = tmp->next; - if (tmp && Context && (mutt_strcmp(tmp->realpath, Context->realpath) == 0)) + if (tmp && Context && (mutt_str_strcmp(tmp->realpath, Context->realpath) == 0)) { tmp->msg_count = Context->msgcount; tmp->msg_unread = Context->unread; @@ -820,13 +821,13 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) do { - if (Context && (mutt_strcmp(tmp->realpath, Context->realpath) == 0)) + if (Context && (mutt_str_strcmp(tmp->realpath, Context->realpath) == 0)) { tmp->msg_count = Context->msgcount; tmp->msg_unread = Context->unread; } - strfcpy(buffer, NONULL(tmp->path), sizeof(buffer)); + mutt_str_strfcpy(buffer, NONULL(tmp->path), sizeof(buffer)); mutt_pretty_mailbox(buffer, sizeof(buffer)); #ifdef USE_IMAP @@ -938,8 +939,8 @@ static void browser_highlight_default(struct BrowserState *state, struct Menu *m * We do not risk overflow as the init_menu function changes * current if it is bigger than state->entrylen. */ - if ((mutt_strcmp(state->entry[0].desc, "..") == 0) || - (mutt_strcmp(state->entry[0].desc, "../") == 0)) + if ((mutt_str_strcmp(state->entry[0].desc, "..") == 0) || + (mutt_str_strcmp(state->entry[0].desc, "../") == 0)) /* Skip the first entry, unless there's only one entry. */ menu->current = (menu->max > 1); else @@ -982,7 +983,7 @@ static void init_menu(struct BrowserState *state, struct Menu *menu, else { menu->is_mailbox_list = 0; - strfcpy(path, LastDir, sizeof(path)); + mutt_str_strfcpy(path, LastDir, sizeof(path)); mutt_pretty_mailbox(path, sizeof(path)); snprintf(title, titlelen, _("Directory [%s], File mask: %s"), path, NONULL(Mask.pattern)); @@ -994,8 +995,8 @@ static void init_menu(struct BrowserState *state, struct Menu *menu, * of OldLastDir (this occurs mostly when one hit "../"). It should also work * properly when the user is in examine_mailboxes-mode. */ - int ldlen = mutt_strlen(LastDir); - if ((ldlen > 0) && (mutt_strncmp(LastDir, OldLastDir, ldlen) == 0)) + int ldlen = mutt_str_strlen(LastDir); + if ((ldlen > 0) && (mutt_str_strncmp(LastDir, OldLastDir, ldlen) == 0)) { char TargetDir[_POSIX_PATH_MAX] = ""; @@ -1004,12 +1005,12 @@ static void init_menu(struct BrowserState *state, struct Menu *menu, */ if (mx_is_imap(OldLastDir)) { - strfcpy(TargetDir, OldLastDir, sizeof(TargetDir)); + mutt_str_strfcpy(TargetDir, OldLastDir, sizeof(TargetDir)); imap_clean_path(TargetDir, sizeof(TargetDir)); } else #endif - strfcpy(TargetDir, strrchr(OldLastDir, '/') + 1, sizeof(TargetDir)); + mutt_str_strfcpy(TargetDir, strrchr(OldLastDir, '/') + 1, sizeof(TargetDir)); /* If we get here, it means that LastDir is the parent directory of * OldLastDir. I.e., we're returning from a subdirectory, and we want @@ -1017,7 +1018,7 @@ static void init_menu(struct BrowserState *state, struct Menu *menu, bool matched = false; for (unsigned int i = 0; i < state->entrylen; i++) { - if (mutt_strcmp(state->entry[i].name, TargetDir) == 0) + if (mutt_str_strcmp(state->entry[i].name, TargetDir) == 0) { menu->current = i; matched = true; @@ -1059,7 +1060,7 @@ static int file_tag(struct Menu *menu, int n, int m) */ void mutt_browser_select_dir(char *f) { - strfcpy(OldLastDir, f, sizeof(OldLastDir)); + mutt_str_strfcpy(OldLastDir, f, sizeof(OldLastDir)); /* Method that will fetch the parent path depending on the type of the path. */ @@ -1093,7 +1094,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi if (option(OPT_NEWS)) { if (*f) - strfcpy(prefix, f, sizeof(prefix)); + mutt_str_strfcpy(prefix, f, sizeof(prefix)); else { struct NntpServer *nserv = CurrentNewsSrv; @@ -1123,14 +1124,14 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi state.imap_browse = true; if (!imap_browse(f, &state)) { - strfcpy(LastDir, state.folder, sizeof(LastDir)); + mutt_str_strfcpy(LastDir, state.folder, sizeof(LastDir)); browser_sort(&state); } } else { #endif - for (i = mutt_strlen(f) - 1; i > 0 && f[i] != '/'; i--) + for (i = mutt_str_strlen(f) - 1; i > 0 && f[i] != '/'; i--) ; if (i > 0) { @@ -1144,8 +1145,8 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi else { getcwd(LastDir, sizeof(LastDir)); - safe_strcat(LastDir, sizeof(LastDir), "/"); - safe_strncat(LastDir, sizeof(LastDir), f, i); + mutt_str_strcat(LastDir, sizeof(LastDir), "/"); + mutt_str_strncat(LastDir, sizeof(LastDir), f, i); } } else @@ -1157,9 +1158,9 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi } if (i <= 0 && f[0] != '/') - strfcpy(prefix, f, sizeof(prefix)); + mutt_str_strfcpy(prefix, f, sizeof(prefix)); else - strfcpy(prefix, f + i + 1, sizeof(prefix)); + mutt_str_strfcpy(prefix, f + i + 1, sizeof(prefix)); killPrefix = 1; #ifdef USE_IMAP } @@ -1224,7 +1225,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi case MUTT_MAILDIR: case MUTT_IMAP: if (Folder) - strfcpy(LastDir, NONULL(Folder), sizeof(LastDir)); + mutt_str_strfcpy(LastDir, NONULL(Folder), sizeof(LastDir)); else if (SpoolFile) mutt_browser_select_dir(SpoolFile); break; @@ -1233,7 +1234,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi break; } } - else if (mutt_strcmp(CurrentFolder, OldLastDir) != 0) + else if (mutt_str_strcmp(CurrentFolder, OldLastDir) != 0) { mutt_browser_select_dir(CurrentFolder); } @@ -1257,7 +1258,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi else #endif { - i = mutt_strlen(LastDir); + i = mutt_str_strlen(LastDir); while (i && LastDir[--i] == '/') LastDir[i] = '\0'; if (!LastDir[0]) @@ -1337,13 +1338,13 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi /* make sure this isn't a MH or maildir mailbox */ if (buffy) { - strfcpy(buf, state.entry[menu->current].name, sizeof(buf)); + mutt_str_strfcpy(buf, state.entry[menu->current].name, sizeof(buf)); mutt_expand_path(buf, sizeof(buf)); } #ifdef USE_IMAP else if (state.imap_browse) { - strfcpy(buf, state.entry[menu->current].name, sizeof(buf)); + mutt_str_strfcpy(buf, state.entry[menu->current].name, sizeof(buf)); } #endif else @@ -1357,11 +1358,11 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi ) { /* save the old directory */ - strfcpy(OldLastDir, LastDir, sizeof(OldLastDir)); + mutt_str_strfcpy(OldLastDir, LastDir, sizeof(OldLastDir)); - if (mutt_strcmp(state.entry[menu->current].name, "..") == 0) + if (mutt_str_strcmp(state.entry[menu->current].name, "..") == 0) { - if (mutt_strcmp("..", LastDir + mutt_strlen(LastDir) - 2) == 0) + if (mutt_str_strcmp("..", LastDir + mutt_str_strlen(LastDir) - 2) == 0) strcat(LastDir, "/.."); else { @@ -1380,7 +1381,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi } else if (buffy) { - strfcpy(LastDir, state.entry[menu->current].name, sizeof(LastDir)); + mutt_str_strfcpy(LastDir, state.entry[menu->current].name, sizeof(LastDir)); mutt_expand_path(LastDir, sizeof(LastDir)); } #ifdef USE_IMAP @@ -1389,7 +1390,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi int n; struct Url url; - strfcpy(LastDir, state.entry[menu->current].name, sizeof(LastDir)); + mutt_str_strfcpy(LastDir, state.entry[menu->current].name, sizeof(LastDir)); /* tack on delimiter here */ n = strlen(LastDir) + 1; @@ -1409,7 +1410,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi char tmp[_POSIX_PATH_MAX]; mutt_file_concat_path(tmp, LastDir, state.entry[menu->current].name, sizeof(tmp)); - strfcpy(LastDir, tmp, sizeof(LastDir)); + mutt_str_strfcpy(LastDir, tmp, sizeof(LastDir)); } destroy_state(&state); @@ -1433,10 +1434,10 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi if (examine_directory(menu, &state, LastDir, prefix) == -1) { /* try to restore the old values */ - strfcpy(LastDir, OldLastDir, sizeof(LastDir)); + mutt_str_strfcpy(LastDir, OldLastDir, sizeof(LastDir)); if (examine_directory(menu, &state, LastDir, prefix) == -1) { - strfcpy(LastDir, NONULL(HomeDir), sizeof(LastDir)); + mutt_str_strfcpy(LastDir, NONULL(HomeDir), sizeof(LastDir)); goto bail; } } @@ -1450,16 +1451,16 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi if (buffy || option(OPT_NEWS)) /* USE_NNTP */ { - strfcpy(f, state.entry[menu->current].name, flen); + mutt_str_strfcpy(f, state.entry[menu->current].name, flen); mutt_expand_path(f, flen); } #ifdef USE_IMAP else if (state.imap_browse) - strfcpy(f, state.entry[menu->current].name, flen); + mutt_str_strfcpy(f, state.entry[menu->current].name, flen); #endif #ifdef USE_NOTMUCH else if (mx_is_notmuch(state.entry[menu->current].name)) - strfcpy(f, state.entry[menu->current].name, flen); + mutt_str_strfcpy(f, state.entry[menu->current].name, flen); #endif else mutt_file_concat_path(f, LastDir, state.entry[menu->current].name, flen); @@ -1484,7 +1485,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi { mutt_file_concat_path(full, LastDir, ff.name, sizeof(full)); mutt_expand_path(full, sizeof(full)); - tfiles[k++] = safe_strdup(full); + tfiles[k++] = mutt_str_strdup(full); } } *files = tfiles; @@ -1494,7 +1495,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi *numfiles = 1; tfiles = mutt_mem_calloc(*numfiles, sizeof(char *)); mutt_expand_path(f, flen); - tfiles[0] = safe_strdup(f); + tfiles[0] = mutt_str_strdup(f); *files = tfiles; } } @@ -1610,13 +1611,13 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi break; #endif - strfcpy(buf, LastDir, sizeof(buf)); + mutt_str_strfcpy(buf, LastDir, sizeof(buf)); #ifdef USE_IMAP if (!state.imap_browse) #endif { /* add '/' at the end of the directory name if not already there */ - int len = mutt_strlen(buf); + int len = mutt_str_strlen(buf); if ((len > 0) && (buf[len - 1] != '/') && (sizeof(buf) > (len + 1))) { buf[len] = '/'; @@ -1631,7 +1632,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi #ifdef USE_IMAP if (mx_is_imap(buf)) { - strfcpy(LastDir, buf, sizeof(LastDir)); + mutt_str_strfcpy(LastDir, buf, sizeof(LastDir)); destroy_state(&state); init_state(&state, NULL); state.imap_browse = true; @@ -1650,7 +1651,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi * not current working dir */ char tmp[_POSIX_PATH_MAX]; mutt_file_concat_path(tmp, LastDir, buf, sizeof(tmp)); - strfcpy(buf, tmp, sizeof(buf)); + mutt_str_strfcpy(buf, tmp, sizeof(buf)); } if (stat(buf, &st) == 0) { @@ -1658,7 +1659,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi { destroy_state(&state); if (examine_directory(menu, &state, buf, prefix) == 0) - strfcpy(LastDir, buf, sizeof(LastDir)); + mutt_str_strfcpy(LastDir, buf, sizeof(LastDir)); else { mutt_error(_("Error scanning directory.")); @@ -1681,7 +1682,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi case OP_ENTER_MASK: - strfcpy(buf, NONULL(Mask.pattern), sizeof(buf)); + mutt_str_strfcpy(buf, NONULL(Mask.pattern), sizeof(buf)); if (mutt_get_field(_("File Mask: "), buf, sizeof(buf), 0) == 0) { regex_t *rx = mutt_mem_malloc(sizeof(regex_t)); @@ -1691,7 +1692,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi buffy = 0; /* assume that the user wants to see everything */ if (!buf[0]) - strfcpy(buf, ".", sizeof(buf)); + mutt_str_strfcpy(buf, ".", sizeof(buf)); SKIPWS(s); if (*s == '!') { @@ -1820,18 +1821,18 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi mutt_debug(5, "= hit! Folder: %s, LastDir: %s\n", Folder, LastDir); if (!GotoSwapper[0]) { - if (mutt_strcmp(LastDir, Folder) != 0) + if (mutt_str_strcmp(LastDir, Folder) != 0) { /* Stores into GotoSwapper LastDir, and swaps to Folder */ - strfcpy(GotoSwapper, LastDir, sizeof(GotoSwapper)); - strfcpy(OldLastDir, LastDir, sizeof(OldLastDir)); - strfcpy(LastDir, Folder, sizeof(LastDir)); + mutt_str_strfcpy(GotoSwapper, LastDir, sizeof(GotoSwapper)); + mutt_str_strfcpy(OldLastDir, LastDir, sizeof(OldLastDir)); + mutt_str_strfcpy(LastDir, Folder, sizeof(LastDir)); } } else { - strfcpy(OldLastDir, LastDir, sizeof(OldLastDir)); - strfcpy(LastDir, GotoSwapper, sizeof(LastDir)); + mutt_str_strfcpy(OldLastDir, LastDir, sizeof(OldLastDir)); + mutt_str_strfcpy(LastDir, GotoSwapper, sizeof(LastDir)); GotoSwapper[0] = '\0'; } } @@ -1868,7 +1869,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi snprintf(buf, sizeof(buf), "%s/", LastDir); if (mutt_get_field(_("New file name: "), buf, sizeof(buf), MUTT_FILE) == 0) { - strfcpy(f, buf, flen); + mutt_str_strfcpy(f, buf, flen); destroy_state(&state); goto bail; } @@ -1884,7 +1885,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi #ifdef USE_IMAP if (state.entry[menu->current].selectable) { - strfcpy(f, state.entry[menu->current].name, flen); + mutt_str_strfcpy(f, state.entry[menu->current].name, flen); destroy_state(&state); goto bail; } diff --git a/buffy.c b/buffy.c index 5ad0d4e3e..e335000ac 100644 --- a/buffy.c +++ b/buffy.c @@ -83,7 +83,7 @@ static int fseek_last_message(FILE *f) while ((pos -= bytes_read) >= 0) { /* we save in the buffer at the end the first 7 chars from the last read */ - strncpy(buffer + BUFSIZ, buffer, 5 + 2); /* 2 == 2 * mutt_strlen(CRLF) */ + strncpy(buffer + BUFSIZ, buffer, 5 + 2); /* 2 == 2 * mutt_str_strlen(CRLF) */ fseeko(f, pos, SEEK_SET); bytes_read = fread(buffer, sizeof(char), bytes_read, f); if (bytes_read == 0) @@ -91,7 +91,8 @@ static int fseek_last_message(FILE *f) /* 'i' is Index into `buffer' for scanning. */ for (int i = bytes_read; i >= 0; i--) { - if (mutt_strncmp(buffer + i, "\n\nFrom ", mutt_strlen("\n\nFrom ")) == 0) + if (mutt_str_strncmp(buffer + i, "\n\nFrom ", + mutt_str_strlen("\n\nFrom ")) == 0) { /* found it - go to the beginning of the From */ fseeko(f, pos + i + 2, SEEK_SET); return 0; @@ -101,7 +102,7 @@ static int fseek_last_message(FILE *f) } /* here we are at the beginning of the file */ - if (mutt_strncmp("From ", buffer, 5) == 0) + if (mutt_str_strncmp("From ", buffer, 5) == 0) { fseek(f, 0, SEEK_SET); return 0; @@ -161,9 +162,9 @@ static struct Buffy *buffy_new(const char *path) char *r = NULL; buffy = mutt_mem_calloc(1, sizeof(struct Buffy)); - strfcpy(buffy->path, path, sizeof(buffy->path)); + mutt_str_strfcpy(buffy->path, path, sizeof(buffy->path)); r = realpath(path, rp); - strfcpy(buffy->realpath, r ? rp : path, sizeof(buffy->realpath)); + mutt_str_strfcpy(buffy->realpath, r ? rp : path, sizeof(buffy->realpath)); buffy->next = NULL; buffy->magic = 0; @@ -402,7 +403,7 @@ static void buffy_check(struct Buffy *tmp, struct stat *contex_sb, bool check_st tmp->magic == MUTT_NOTMUCH || #endif tmp->magic == MUTT_POP) ? - (mutt_strcmp(tmp->path, Context->path) != 0) : + (mutt_str_strcmp(tmp->path, Context->path) != 0) : (sb.st_dev != contex_sb->st_dev || sb.st_ino != contex_sb->st_ino))) { switch (tmp->magic) @@ -463,14 +464,14 @@ static struct Buffy *buffy_get(const char *path) if (!path) return NULL; - epath = safe_strdup(path); - mutt_expand_path(epath, mutt_strlen(epath)); + epath = mutt_str_strdup(path); + mutt_expand_path(epath, mutt_str_strlen(epath)); for (cur = Incoming; cur; cur = cur->next) { /* must be done late because e.g. IMAP delimiter may change */ mutt_expand_path(cur->path, sizeof(cur->path)); - if (mutt_strcmp(cur->path, path) == 0) + if (mutt_str_strcmp(cur->path, path) == 0) { FREE(&epath); return cur; @@ -553,7 +554,7 @@ int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s, { mutt_extract_token(path, s, 0); if (path->data && *path->data) - desc = safe_strdup(path->data); + desc = mutt_str_strdup(path->data); else continue; } @@ -564,7 +565,7 @@ int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s, nm_normalize_uri(buf, path->data, sizeof(buf)); else #endif - strfcpy(buf, path->data, sizeof(buf)); + mutt_str_strfcpy(buf, path->data, sizeof(buf)); mutt_expand_path(buf, sizeof(buf)); @@ -579,7 +580,7 @@ int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s, p = realpath(buf, f1); for (b = &Incoming; *b; b = &((*b)->next)) { - if (mutt_strcmp(p ? p : buf, (*b)->realpath) == 0) + if (mutt_str_strcmp(p ? p : buf, (*b)->realpath) == 0) { mutt_debug(3, "mailbox '%s' already registered as '%s'\n", buf, (*b)->path); break; @@ -638,7 +639,7 @@ int mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s, { mutt_extract_token(path, s, 0); - if (mutt_strcmp(path->data, "*") == 0) + if (mutt_str_strcmp(path->data, "*") == 0) { clear_all = true; } @@ -652,7 +653,7 @@ int mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s, else #endif { - strfcpy(buf, path->data, sizeof(buf)); + mutt_str_strfcpy(buf, path->data, sizeof(buf)); mutt_expand_path(buf, sizeof(buf)); } } @@ -664,8 +665,8 @@ int mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s, bool norm = (((*b)->magic != MUTT_NOTMUCH) && !(data & MUTT_VIRTUAL)); bool clear_this = clear_all && (virt | norm); - if (clear_this || (mutt_strcasecmp(buf, (*b)->path) == 0) || - (mutt_strcasecmp(buf, (*b)->desc) == 0)) + if (clear_this || (mutt_str_strcasecmp(buf, (*b)->path) == 0) || + (mutt_str_strcasecmp(buf, (*b)->desc) == 0)) { struct Buffy *next = (*b)->next; #ifdef USE_SIDEBAR @@ -760,7 +761,7 @@ int mutt_buffy_list(void) if (!b->new || (have_unnotified && b->notified)) continue; - strfcpy(path, b->path, sizeof(path)); + mutt_str_strfcpy(path, b->path, sizeof(path)); mutt_pretty_mailbox(path, sizeof(path)); if (!first && (MuttMessageWindow->cols >= 7) && @@ -841,11 +842,11 @@ void mutt_buffy(char *s, size_t slen) mutt_expand_path(b->path, sizeof(b->path)); if ((found || pass) && b->new) { - strfcpy(s, b->path, slen); + mutt_str_strfcpy(s, b->path, slen); mutt_pretty_mailbox(s, slen); return; } - if (mutt_strcmp(s, b->path) == 0) + if (mutt_str_strcmp(s, b->path) == 0) found = 1; } } @@ -872,10 +873,10 @@ void mutt_buffy_vfolder(char *s, size_t slen) continue; if ((found || pass) && b->new) { - strfcpy(s, b->desc, slen); + mutt_str_strfcpy(s, b->desc, slen); return; } - if (mutt_strcmp(s, b->path) == 0) + if (mutt_str_strcmp(s, b->path) == 0) found = true; } } diff --git a/charset.c b/charset.c index ecf943fdc..407fd7c9c 100644 --- a/charset.c +++ b/charset.c @@ -210,13 +210,13 @@ void mutt_set_langinfo_charset(void) char buff[LONG_STRING]; char buff2[LONG_STRING]; - strfcpy(buff, nl_langinfo(CODESET), sizeof(buff)); + mutt_str_strfcpy(buff, nl_langinfo(CODESET), sizeof(buff)); mutt_canonical_charset(buff2, sizeof(buff2), buff); /* finally, set $charset */ - Charset = safe_strdup(buff2); + Charset = mutt_str_strdup(buff2); if (!Charset) - Charset = safe_strdup("iso-8859-1"); + Charset = mutt_str_strdup("iso-8859-1"); } /** @@ -230,37 +230,38 @@ void mutt_canonical_charset(char *dest, size_t dlen, const char *name) char *p = NULL, *ext = NULL; char in[LONG_STRING], scratch[LONG_STRING]; - strfcpy(in, name, sizeof(in)); + mutt_str_strfcpy(in, name, sizeof(in)); if ((ext = strchr(in, '/'))) *ext++ = '\0'; - if ((mutt_strcasecmp(in, "utf-8") == 0) || (mutt_strcasecmp(in, "utf8") == 0)) + if ((mutt_str_strcasecmp(in, "utf-8") == 0) || + (mutt_str_strcasecmp(in, "utf8") == 0)) { - strfcpy(dest, "utf-8", dlen); + mutt_str_strfcpy(dest, "utf-8", dlen); goto out; } /* catch some common iso-8859-something misspellings */ - if ((mutt_strncasecmp(in, "8859", 4) == 0) && in[4] != '-') + if ((mutt_str_strncasecmp(in, "8859", 4) == 0) && in[4] != '-') snprintf(scratch, sizeof(scratch), "iso-8859-%s", in + 4); - else if (mutt_strncasecmp(in, "8859-", 5) == 0) + else if (mutt_str_strncasecmp(in, "8859-", 5) == 0) snprintf(scratch, sizeof(scratch), "iso-8859-%s", in + 5); - else if ((mutt_strncasecmp(in, "iso8859", 7) == 0) && in[7] != '-') + else if ((mutt_str_strncasecmp(in, "iso8859", 7) == 0) && in[7] != '-') snprintf(scratch, sizeof(scratch), "iso_8859-%s", in + 7); - else if (mutt_strncasecmp(in, "iso8859-", 8) == 0) + else if (mutt_str_strncasecmp(in, "iso8859-", 8) == 0) snprintf(scratch, sizeof(scratch), "iso_8859-%s", in + 8); else - strfcpy(scratch, in, sizeof(scratch)); + mutt_str_strfcpy(scratch, in, sizeof(scratch)); for (size_t i = 0; PreferredMIMENames[i].key; i++) - if ((mutt_strcasecmp(scratch, PreferredMIMENames[i].key) == 0) || - (mutt_strcasecmp(scratch, PreferredMIMENames[i].key) == 0)) + if ((mutt_str_strcasecmp(scratch, PreferredMIMENames[i].key) == 0) || + (mutt_str_strcasecmp(scratch, PreferredMIMENames[i].key) == 0)) { - strfcpy(dest, PreferredMIMENames[i].pref, dlen); + mutt_str_strfcpy(dest, PreferredMIMENames[i].pref, dlen); goto out; } - strfcpy(dest, scratch, dlen); + mutt_str_strfcpy(dest, scratch, dlen); /* for cosmetics' sake, transform to lowercase. */ for (p = dest; *p; p++) @@ -269,8 +270,8 @@ void mutt_canonical_charset(char *dest, size_t dlen, const char *name) out: if (ext && *ext) { - safe_strcat(dest, dlen, "/"); - safe_strcat(dest, dlen, ext); + mutt_str_strcat(dest, dlen, "/"); + mutt_str_strcat(dest, dlen, ext); } } @@ -289,9 +290,9 @@ int mutt_chscmp(const char *s, const char *chs) we simply check if the shorter string is a prefix for the longer */ mutt_canonical_charset(buffer, sizeof(buffer), s); - a = mutt_strlen(buffer); - b = mutt_strlen(chs); - return (mutt_strncasecmp(a > b ? buffer : chs, a > b ? chs : buffer, MIN(a, b)) == 0); + a = mutt_str_strlen(buffer); + b = mutt_str_strlen(chs); + return (mutt_str_strncasecmp(a > b ? buffer : chs, a > b ? chs : buffer, MIN(a, b)) == 0); } char *mutt_get_default_charset(void) @@ -303,7 +304,7 @@ char *mutt_get_default_charset(void) if (c && *c) { c1 = strchr(c, ':'); - strfcpy(fcharset, c, c1 ? (c1 - c + 1) : sizeof(fcharset)); + mutt_str_strfcpy(fcharset, c, c1 ? (c1 - c + 1) : sizeof(fcharset)); return fcharset; } return strcpy(fcharset, "us-ascii"); @@ -640,8 +641,8 @@ bool mutt_check_charset(const char *s, bool strict) if (!strict) for (int i = 0; PreferredMIMENames[i].key; i++) { - if ((mutt_strcasecmp(PreferredMIMENames[i].key, s) == 0) || - (mutt_strcasecmp(PreferredMIMENames[i].pref, s) == 0)) + if ((mutt_str_strcasecmp(PreferredMIMENames[i].key, s) == 0) || + (mutt_str_strcasecmp(PreferredMIMENames[i].pref, s) == 0)) return true; } diff --git a/color.c b/color.c index ad381a74e..6ecc4c39b 100644 --- a/color.c +++ b/color.c @@ -211,15 +211,15 @@ static char *get_color_name(char *dest, size_t destlen, int val) switch (val) { case COLOR_YELLOW: - strfcpy(dest, missing[0], destlen); + mutt_str_strfcpy(dest, missing[0], destlen); return dest; case COLOR_WHITE: - strfcpy(dest, missing[1], destlen); + mutt_str_strfcpy(dest, missing[1], destlen); return dest; case COLOR_DEFAULT: - strfcpy(dest, missing[2], destlen); + mutt_str_strfcpy(dest, missing[2], destlen); return dest; } @@ -227,7 +227,7 @@ static char *get_color_name(char *dest, size_t destlen, int val) { if (Colors[i].value == val) { - strfcpy(dest, Colors[i].name, destlen); + mutt_str_strfcpy(dest, Colors[i].name, destlen); return dest; } } @@ -388,14 +388,14 @@ static int parse_color_name(const char *s, int *col, int *attr, int is_fg, struc char *eptr = NULL; int is_bright = 0; - if (mutt_strncasecmp(s, "bright", 6) == 0) + if (mutt_str_strncasecmp(s, "bright", 6) == 0) { is_bright = 1; s += 6; } /* allow aliases for xterm color resources */ - if (mutt_strncasecmp(s, "color", 5) == 0) + if (mutt_str_strncasecmp(s, "color", 5) == 0) { s += 5; *col = strtol(s, &eptr, 10); @@ -442,7 +442,7 @@ static void do_uncolor(struct Buffer *buf, struct Buffer *s, do { mutt_extract_token(buf, s, 0); - if (mutt_strcmp("*", buf->data) == 0) + if (mutt_str_strcmp("*", buf->data) == 0) { np = STAILQ_FIRST(cl); while (np) @@ -463,7 +463,7 @@ static void do_uncolor(struct Buffer *buf, struct Buffer *s, tmp = NULL; STAILQ_FOREACH(np, cl, entries) { - if (mutt_strcmp(buf->data, np->pattern) == 0) + if (mutt_str_strcmp(buf->data, np->pattern) == 0) { if (!*do_cache) { @@ -511,9 +511,9 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat return 0; } - if ((mutt_strncmp(buf->data, "body", 4) != 0) && - (mutt_strncmp(buf->data, "header", 6) != 0) && - (mutt_strncmp(buf->data, "index", 5) != 0)) + if ((mutt_str_strncmp(buf->data, "body", 4) != 0) && + (mutt_str_strncmp(buf->data, "header", 6) != 0) && + (mutt_str_strncmp(buf->data, "index", 5) != 0)) { snprintf(err->data, err->dsize, _("%s: command valid only for index, body, header objects"), @@ -605,12 +605,12 @@ static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive, { if (sensitive) { - if (mutt_strcmp(s, tmp->pattern) == 0) + if (mutt_str_strcmp(s, tmp->pattern) == 0) break; } else { - if (mutt_strcasecmp(s, tmp->pattern) == 0) + if (mutt_str_strcasecmp(s, tmp->pattern) == 0) break; } } @@ -641,7 +641,7 @@ static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive, tmp = new_color_line(); if (is_index) { - strfcpy(buf, NONULL(s), sizeof(buf)); + mutt_str_strfcpy(buf, NONULL(s), sizeof(buf)); mutt_check_simple(buf, sizeof(buf), NONULL(SimpleSearch)); tmp->color_pattern = mutt_pattern_comp(buf, MUTT_FULL_MSG, err); if (!tmp->color_pattern) @@ -659,7 +659,7 @@ static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive, free_color_line(tmp, 1); return -1; } - tmp->pattern = safe_strdup(s); + tmp->pattern = mutt_str_strdup(s); tmp->match = match; #ifdef HAVE_COLOR if (fg != -1 && bg != -1) @@ -684,12 +684,12 @@ static int parse_object(struct Buffer *buf, struct Buffer *s, int *o, int *ql, if (!MoreArgs(s)) { - strfcpy(err->data, _("Missing arguments."), err->dsize); + mutt_str_strfcpy(err->data, _("Missing arguments."), err->dsize); return -1; } mutt_extract_token(buf, s, 0); - if (mutt_strncmp(buf->data, "quoted", 6) == 0) + if (mutt_str_strncmp(buf->data, "quoted", 6) == 0) { if (buf->data[6]) { @@ -705,11 +705,11 @@ static int parse_object(struct Buffer *buf, struct Buffer *s, int *o, int *ql, *o = MT_COLOR_QUOTED; } - else if (!mutt_strcasecmp(buf->data, "compose")) + else if (!mutt_str_strcasecmp(buf->data, "compose")) { if (!MoreArgs(s)) { - strfcpy(err->data, _("Missing arguments."), err->dsize); + mutt_str_strfcpy(err->data, _("Missing arguments."), err->dsize); return -1; } @@ -741,7 +741,7 @@ static int parse_color_pair(struct Buffer *buf, struct Buffer *s, int *fg, { if (!MoreArgs(s)) { - strfcpy(err->data, _("color: too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("color: too few arguments"), err->dsize); return -1; } @@ -752,7 +752,7 @@ static int parse_color_pair(struct Buffer *buf, struct Buffer *s, int *fg, if (!MoreArgs(s)) { - strfcpy(err->data, _("color: too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("color: too few arguments"), err->dsize); return -1; } @@ -776,23 +776,23 @@ static int parse_attr_spec(struct Buffer *buf, struct Buffer *s, int *fg, if (!MoreArgs(s)) { - strfcpy(err->data, _("mono: too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("mono: too few arguments"), err->dsize); return -1; } mutt_extract_token(buf, s, 0); - if (mutt_strcasecmp("bold", buf->data) == 0) + if (mutt_str_strcasecmp("bold", buf->data) == 0) *attr |= A_BOLD; - else if (mutt_strcasecmp("underline", buf->data) == 0) + else if (mutt_str_strcasecmp("underline", buf->data) == 0) *attr |= A_UNDERLINE; - else if (mutt_strcasecmp("none", buf->data) == 0) + else if (mutt_str_strcasecmp("none", buf->data) == 0) *attr = A_NORMAL; - else if (mutt_strcasecmp("reverse", buf->data) == 0) + else if (mutt_str_strcasecmp("reverse", buf->data) == 0) *attr |= A_REVERSE; - else if (mutt_strcasecmp("standout", buf->data) == 0) + else if (mutt_str_strcasecmp("standout", buf->data) == 0) *attr |= A_STANDOUT; - else if (mutt_strcasecmp("normal", buf->data) == 0) + else if (mutt_str_strcasecmp("normal", buf->data) == 0) *attr = A_NORMAL; /* needs use = instead of |= to clear other bits */ else { @@ -840,7 +840,7 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err, { if (!MoreArgs(s)) { - strfcpy(err->data, _("too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too few arguments"), err->dsize); return -1; } @@ -849,7 +849,7 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err, if (MoreArgs(s) && (object != MT_COLOR_STATUS)) { - strfcpy(err->data, _("too many arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too many arguments"), err->dsize); return -1; } @@ -873,7 +873,7 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err, * a rc file. */ { - strfcpy(err->data, _("default colors not supported"), err->dsize); + mutt_str_strfcpy(err->data, _("default colors not supported"), err->dsize); return -1; } #endif /* HAVE_USE_DEFAULT_COLORS */ @@ -905,7 +905,7 @@ static int parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err, if (MoreArgs(s)) { - strfcpy(err->data, _("too many arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too many arguments"), err->dsize); return -1; } diff --git a/commands.c b/commands.c index d87a6cb79..9f4cc7ae3 100644 --- a/commands.c +++ b/commands.c @@ -148,7 +148,7 @@ int mutt_display_message(struct Header *cur) } } - if (!Pager || (mutt_strcmp(Pager, "builtin") == 0)) + if (!Pager || (mutt_str_strcmp(Pager, "builtin") == 0)) builtin = true; else { @@ -291,9 +291,9 @@ void ci_bounce_message(struct Header *h) } if (h) - strfcpy(prompt, _("Bounce message to: "), sizeof(prompt)); + mutt_str_strfcpy(prompt, _("Bounce message to: "), sizeof(prompt)); else - strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt)); + mutt_str_strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt)); rc = mutt_get_field(prompt, buf, sizeof(buf), MUTT_ALIAS); if (rc || !buf[0]) @@ -327,7 +327,7 @@ void ci_bounce_message(struct Header *h) { mutt_simple_format(prompt, sizeof(prompt), 0, MuttMessageWindow->cols - EXTRA_SPACE, FMT_LEFT, 0, scratch, sizeof(scratch), 0); - safe_strcat(prompt, sizeof(prompt), "...?"); + mutt_str_strcat(prompt, sizeof(prompt), "...?"); } else snprintf(prompt, sizeof(prompt), "%s?", scratch); @@ -616,7 +616,7 @@ void mutt_shell_escape(void) if (mutt_get_field(_("Shell command: "), buf, sizeof(buf), MUTT_CMD) == 0) { if (!buf[0] && Shell) - strfcpy(buf, Shell, sizeof(buf)); + mutt_str_strfcpy(buf, Shell, sizeof(buf)); if (buf[0]) { mutt_window_clearline(MuttMessageWindow, 0); @@ -827,10 +827,10 @@ int mutt_save_message(struct Header *h, int delete, int decode, int decrypt) /* This is an undocumented feature of ELM pointed out to me by Felix von * Leitner */ - if (mutt_strcmp(buf, ".") == 0) - strfcpy(buf, LastSaveFolder, sizeof(buf)); + if (mutt_str_strcmp(buf, ".") == 0) + mutt_str_strfcpy(buf, LastSaveFolder, sizeof(buf)); else - strfcpy(LastSaveFolder, buf, sizeof(LastSaveFolder)); + mutt_str_strfcpy(LastSaveFolder, buf, sizeof(LastSaveFolder)); mutt_expand_path(buf, sizeof(buf)); @@ -971,10 +971,10 @@ int mutt_edit_content_type(struct Header *h, struct Body *b, FILE *fp) short structure_changed = 0; cp = mutt_get_parameter("charset", b->parameter); - strfcpy(charset, NONULL(cp), sizeof(charset)); + mutt_str_strfcpy(charset, NONULL(cp), sizeof(charset)); snprintf(buf, sizeof(buf), "%s/%s", TYPE(b), b->subtype); - strfcpy(obuf, buf, sizeof(obuf)); + mutt_str_strfcpy(obuf, buf, sizeof(obuf)); if (b->parameter) { size_t l; @@ -998,8 +998,9 @@ int mutt_edit_content_type(struct Header *h, struct Body *b, FILE *fp) mutt_parse_content_type(buf, b); snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype)); - type_changed = mutt_strcasecmp(tmp, obuf); - charset_changed = mutt_strcasecmp(charset, mutt_get_parameter("charset", b->parameter)); + type_changed = mutt_str_strcasecmp(tmp, obuf); + charset_changed = + mutt_str_strcasecmp(charset, mutt_get_parameter("charset", b->parameter)); /* if in send mode, check for conversion - current setting is default. */ diff --git a/complete.c b/complete.c index a7b02ba78..f2de4ef46 100644 --- a/complete.c +++ b/complete.c @@ -69,11 +69,11 @@ int mutt_complete(char *s, size_t slen) struct NntpServer *nserv = CurrentNewsSrv; unsigned int n = 0; - strfcpy(filepart, s, sizeof(filepart)); + mutt_str_strfcpy(filepart, s, sizeof(filepart)); /* special case to handle when there is no filepart yet * find the first subscribed newsgroup */ - len = mutt_strlen(filepart); + len = mutt_str_strlen(filepart); if (len == 0) { for (; n < nserv->groups_num; n++) @@ -82,7 +82,7 @@ int mutt_complete(char *s, size_t slen) if (nntp_data && nntp_data->subscribed) { - strfcpy(filepart, nntp_data->group, sizeof(filepart)); + mutt_str_strfcpy(filepart, nntp_data->group, sizeof(filepart)); init = 1; n++; break; @@ -95,7 +95,7 @@ int mutt_complete(char *s, size_t slen) struct NntpData *nntp_data = nserv->groups_list[n]; if (nntp_data && nntp_data->subscribed && - (mutt_strncmp(nntp_data->group, filepart, len) == 0)) + (mutt_str_strncmp(nntp_data->group, filepart, len) == 0)) { if (init) { @@ -111,13 +111,13 @@ int mutt_complete(char *s, size_t slen) } else { - strfcpy(filepart, nntp_data->group, sizeof(filepart)); + mutt_str_strfcpy(filepart, nntp_data->group, sizeof(filepart)); init = 1; } } } - strfcpy(s, filepart, slen); + mutt_str_strfcpy(s, filepart, slen); return (init ? 0 : -1); } #endif @@ -134,7 +134,7 @@ int mutt_complete(char *s, size_t slen) mutt_file_concat_path(imap_path, p, s + 1, sizeof(imap_path)); } else - strfcpy(imap_path, s, sizeof(imap_path)); + mutt_str_strfcpy(imap_path, s, sizeof(imap_path)); if (mx_is_imap(imap_path)) return imap_complete(s, slen, imap_path); @@ -145,9 +145,9 @@ int mutt_complete(char *s, size_t slen) dirpart[0] = *s; dirpart[1] = '\0'; if (*s == '!') - strfcpy(exp_dirpart, NONULL(SpoolFile), sizeof(exp_dirpart)); + mutt_str_strfcpy(exp_dirpart, NONULL(SpoolFile), sizeof(exp_dirpart)); else - strfcpy(exp_dirpart, NONULL(Folder), sizeof(exp_dirpart)); + mutt_str_strfcpy(exp_dirpart, NONULL(Folder), sizeof(exp_dirpart)); if ((p = strrchr(s, '/'))) { char buf[_POSIX_PATH_MAX]; @@ -156,12 +156,12 @@ int mutt_complete(char *s, size_t slen) { return -1; } - strfcpy(exp_dirpart, buf, sizeof(exp_dirpart)); - mutt_substrcpy(dirpart, s, p + 1, sizeof(dirpart)); - strfcpy(filepart, p + 1, sizeof(filepart)); + mutt_str_strfcpy(exp_dirpart, buf, sizeof(exp_dirpart)); + mutt_str_substr_cpy(dirpart, s, p + 1, sizeof(dirpart)); + mutt_str_strfcpy(filepart, p + 1, sizeof(filepart)); } else - strfcpy(filepart, s + 1, sizeof(filepart)); + mutt_str_strfcpy(filepart, s + 1, sizeof(filepart)); dirp = opendir(exp_dirpart); } else @@ -171,16 +171,16 @@ int mutt_complete(char *s, size_t slen) if (p == s) /* absolute path */ { p = s + 1; - strfcpy(dirpart, "/", sizeof(dirpart)); + mutt_str_strfcpy(dirpart, "/", sizeof(dirpart)); exp_dirpart[0] = '\0'; - strfcpy(filepart, p, sizeof(filepart)); + mutt_str_strfcpy(filepart, p, sizeof(filepart)); dirp = opendir(dirpart); } else { - mutt_substrcpy(dirpart, s, p, sizeof(dirpart)); - strfcpy(filepart, p + 1, sizeof(filepart)); - strfcpy(exp_dirpart, dirpart, sizeof(exp_dirpart)); + mutt_str_substr_cpy(dirpart, s, p, sizeof(dirpart)); + mutt_str_strfcpy(filepart, p + 1, sizeof(filepart)); + mutt_str_strfcpy(exp_dirpart, dirpart, sizeof(exp_dirpart)); mutt_expand_path(exp_dirpart, sizeof(exp_dirpart)); dirp = opendir(exp_dirpart); } @@ -189,7 +189,7 @@ int mutt_complete(char *s, size_t slen) { /* no directory name, so assume current directory. */ dirpart[0] = '\0'; - strfcpy(filepart, s, sizeof(filepart)); + mutt_str_strfcpy(filepart, s, sizeof(filepart)); dirp = opendir("."); } } @@ -205,14 +205,15 @@ int mutt_complete(char *s, size_t slen) * special case to handle when there is no filepart yet. find the first * file/directory which is not ``.'' or ``..'' */ - len = mutt_strlen(filepart); + len = mutt_str_strlen(filepart); if (len == 0) { while ((de = readdir(dirp)) != NULL) { - if ((mutt_strcmp(".", de->d_name) != 0) && (mutt_strcmp("..", de->d_name) != 0)) + if ((mutt_str_strcmp(".", de->d_name) != 0) && + (mutt_str_strcmp("..", de->d_name) != 0)) { - strfcpy(filepart, de->d_name, sizeof(filepart)); + mutt_str_strfcpy(filepart, de->d_name, sizeof(filepart)); init++; break; } @@ -221,7 +222,7 @@ int mutt_complete(char *s, size_t slen) while ((de = readdir(dirp)) != NULL) { - if (mutt_strncmp(de->d_name, filepart, len) == 0) + if (mutt_str_strncmp(de->d_name, filepart, len) == 0) { if (init) { @@ -240,19 +241,20 @@ int mutt_complete(char *s, size_t slen) char buf[_POSIX_PATH_MAX]; struct stat st; - strfcpy(filepart, de->d_name, sizeof(filepart)); + mutt_str_strfcpy(filepart, de->d_name, sizeof(filepart)); /* check to see if it is a directory */ if (dirpart[0]) { - strfcpy(buf, exp_dirpart, sizeof(buf)); - strfcpy(buf + strlen(buf), "/", sizeof(buf) - strlen(buf)); + mutt_str_strfcpy(buf, exp_dirpart, sizeof(buf)); + mutt_str_strfcpy(buf + strlen(buf), "/", sizeof(buf) - strlen(buf)); } else buf[0] = 0; - strfcpy(buf + strlen(buf), filepart, sizeof(buf) - strlen(buf)); + mutt_str_strfcpy(buf + strlen(buf), filepart, sizeof(buf) - strlen(buf)); if (stat(buf, &st) != -1 && (st.st_mode & S_IFDIR)) - strfcpy(filepart + strlen(filepart), "/", sizeof(filepart) - strlen(filepart)); + mutt_str_strfcpy(filepart + strlen(filepart), "/", + sizeof(filepart) - strlen(filepart)); init = 1; } } @@ -261,13 +263,13 @@ int mutt_complete(char *s, size_t slen) if (dirpart[0]) { - strfcpy(s, dirpart, slen); - if ((mutt_strcmp("/", dirpart) != 0) && dirpart[0] != '=' && dirpart[0] != '+') - strfcpy(s + strlen(s), "/", slen - strlen(s)); - strfcpy(s + strlen(s), filepart, slen - strlen(s)); + mutt_str_strfcpy(s, dirpart, slen); + if ((mutt_str_strcmp("/", dirpart) != 0) && dirpart[0] != '=' && dirpart[0] != '+') + mutt_str_strfcpy(s + strlen(s), "/", slen - strlen(s)); + mutt_str_strfcpy(s + strlen(s), filepart, slen - strlen(s)); } else - strfcpy(s, filepart, slen); + mutt_str_strfcpy(s, filepart, slen); return (init ? 0 : -1); } diff --git a/compose.c b/compose.c index a1fcfeedb..28ff7c055 100644 --- a/compose.c +++ b/compose.c @@ -185,7 +185,7 @@ static void calc_header_width_padding(int idx, const char *header, int calc_max) { int width; - HeaderPadding[idx] = mutt_strlen(header); + HeaderPadding[idx] = mutt_str_strlen(header); width = mutt_strwidth(header); if (calc_max && MaxHeaderWidth < width) MaxHeaderWidth = width; @@ -344,14 +344,14 @@ static void redraw_mix_line(struct ListHead *chain) if (t && t[0] == '0' && t[1] == '\0') t = ""; - if (c + mutt_strlen(t) + 2 >= MuttIndexWindow->cols) + if (c + mutt_str_strlen(t) + 2 >= MuttIndexWindow->cols) break; addstr(NONULL(t)); if (STAILQ_NEXT(np, entries)) addstr(", "); - c += mutt_strlen(t) + 2; + c += mutt_str_strlen(t) + 2; } } #endif /* MIXMASTER */ @@ -364,7 +364,7 @@ static int check_attachments(struct AttachCtx *actx) for (int i = 0; i < actx->idxlen; i++) { - strfcpy(pretty, actx->idx[i]->content->filename, sizeof(pretty)); + mutt_str_strfcpy(pretty, actx->idx[i]->content->filename, sizeof(pretty)); if (stat(actx->idx[i]->content->filename, &st) != 0) { mutt_pretty_mailbox(pretty, sizeof(pretty)); @@ -859,7 +859,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ if (news) { if (msg->env->newsgroups) - strfcpy(buf, msg->env->newsgroups, sizeof(buf)); + mutt_str_strfcpy(buf, msg->env->newsgroups, sizeof(buf)); else buf[0] = 0; if (mutt_get_field("Newsgroups: ", buf, sizeof(buf), 0) == 0) @@ -877,7 +877,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ if (news) { if (msg->env->followup_to) - strfcpy(buf, msg->env->followup_to, sizeof(buf)); + mutt_str_strfcpy(buf, msg->env->followup_to, sizeof(buf)); else buf[0] = 0; if (mutt_get_field("Followup-To: ", buf, sizeof(buf), 0) == 0) @@ -895,7 +895,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ if (news && option(OPT_X_COMMENT_TO)) { if (msg->env->x_comment_to) - strfcpy(buf, msg->env->x_comment_to, sizeof(buf)); + mutt_str_strfcpy(buf, msg->env->x_comment_to, sizeof(buf)); else buf[0] = 0; if (mutt_get_field("X-Comment-To: ", buf, sizeof(buf), 0) == 0) @@ -912,7 +912,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ #endif case OP_COMPOSE_EDIT_SUBJECT: if (msg->env->subject) - strfcpy(buf, msg->env->subject, sizeof(buf)); + mutt_str_strfcpy(buf, msg->env->subject, sizeof(buf)); else buf[0] = 0; if (mutt_get_field(_("Subject: "), buf, sizeof(buf), 0) == 0) @@ -931,10 +931,10 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ mutt_message_hook(NULL, msg, MUTT_SEND2HOOK); break; case OP_COMPOSE_EDIT_FCC: - strfcpy(buf, fcc, sizeof(buf)); + mutt_str_strfcpy(buf, fcc, sizeof(buf)); if (mutt_get_field(_("Fcc: "), buf, sizeof(buf), MUTT_FILE | MUTT_CLEAR) == 0) { - strfcpy(fcc, buf, fcclen); + mutt_str_strfcpy(fcc, buf, fcclen); mutt_pretty_mailbox(fcc, fcclen); mutt_window_move(MuttIndexWindow, HDR_FCC, HDR_XOFFSET); mutt_paddstr(W, fcc); @@ -943,7 +943,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ mutt_message_hook(NULL, msg, MUTT_SEND2HOOK); break; case OP_COMPOSE_EDIT_MESSAGE: - if (Editor && (mutt_strcmp("builtin", Editor) != 0) && !option(OPT_EDIT_HEADERS)) + if (Editor && (mutt_str_strcmp("builtin", Editor) != 0) && !option(OPT_EDIT_HEADERS)) { mutt_edit_file(Editor, msg->content->filename); mutt_update_encoding(msg->content); @@ -953,7 +953,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ } /* fall through */ case OP_COMPOSE_EDIT_HEADERS: - if ((mutt_strcmp("builtin", Editor) != 0) && + if ((mutt_str_strcmp("builtin", Editor) != 0) && (op == OP_COMPOSE_EDIT_HEADERS || (op == OP_COMPOSE_EDIT_MESSAGE && option(OPT_EDIT_HEADERS)))) { @@ -1079,7 +1079,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == MUTT_NNTP)) #endif { - strfcpy(fname, NONULL(Context->path), sizeof(fname)); + mutt_str_strfcpy(fname, NONULL(Context->path), sizeof(fname)); mutt_pretty_mailbox(fname, sizeof(fname)); } @@ -1211,8 +1211,9 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ case OP_COMPOSE_EDIT_DESCRIPTION: CHECK_COUNT; - strfcpy(buf, CURATTACH->content->description ? CURATTACH->content->description : "", - sizeof(buf)); + mutt_str_strfcpy(buf, + CURATTACH->content->description ? CURATTACH->content->description : "", + sizeof(buf)); /* header names should not be translated */ if (mutt_get_field("Description: ", buf, sizeof(buf), 0) == 0) { @@ -1264,7 +1265,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ case OP_COMPOSE_EDIT_ENCODING: CHECK_COUNT; - strfcpy(buf, ENCODING(CURATTACH->content->encoding), sizeof(buf)); + mutt_str_strfcpy(buf, ENCODING(CURATTACH->content->encoding), sizeof(buf)); if (mutt_get_field("Content-Transfer-Encoding: ", buf, sizeof(buf), 0) == 0 && buf[0]) { if ((i = mutt_check_encoding(buf)) != ENCOTHER && i != ENCUUENCODED) @@ -1353,7 +1354,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ src = CURATTACH->content->d_filename; else src = CURATTACH->content->filename; - strfcpy(fname, mutt_file_basename(NONULL(src)), sizeof(fname)); + mutt_str_strfcpy(fname, mutt_file_basename(NONULL(src)), sizeof(fname)); ret = mutt_get_field(_("Send attachment with name: "), fname, sizeof(fname), MUTT_FILE); if (ret == 0) { @@ -1369,7 +1370,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ case OP_COMPOSE_RENAME_FILE: CHECK_COUNT; - strfcpy(fname, CURATTACH->content->filename, sizeof(fname)); + mutt_str_strfcpy(fname, CURATTACH->content->filename, sizeof(fname)); mutt_pretty_mailbox(fname, sizeof(fname)); if (mutt_get_field(_("Rename to: "), fname, sizeof(fname), MUTT_FILE) == 0 && fname[0]) @@ -1559,7 +1560,7 @@ int mutt_compose_menu(struct Header *msg, /* structure for new message */ fname[0] = '\0'; if (Context) { - strfcpy(fname, NONULL(Context->path), sizeof(fname)); + mutt_str_strfcpy(fname, NONULL(Context->path), sizeof(fname)); mutt_pretty_mailbox(fname, sizeof(fname)); } if (actx->idxlen) diff --git a/compress.c b/compress.c index 104a5f557..2e7f308ba 100644 --- a/compress.c +++ b/compress.c @@ -158,7 +158,7 @@ static int setup_paths(struct Context *ctx) /* We will uncompress to /tmp */ mutt_mktemp(tmppath, sizeof(tmppath)); - ctx->path = safe_strdup(tmppath); + ctx->path = mutt_str_strdup(tmppath); tmpfp = mutt_file_fopen(ctx->path, "w"); if (!tmpfp) @@ -259,9 +259,9 @@ static struct CompressInfo *set_compress_info(struct Context *ctx) struct CompressInfo *ci = mutt_mem_calloc(1, sizeof(struct CompressInfo)); ctx->compress_info = ci; - ci->open = safe_strdup(o); - ci->close = safe_strdup(c); - ci->append = safe_strdup(a); + ci->open = mutt_str_strdup(o); + ci->close = mutt_str_strdup(c); + ci->append = mutt_str_strdup(a); return ci; } diff --git a/conn/getdomain.c b/conn/getdomain.c index 0038f1d2c..e9540107c 100644 --- a/conn/getdomain.c +++ b/conn/getdomain.c @@ -106,7 +106,7 @@ int getdnsdomainname(char *d, size_t len) char *p = NULL; if (h != NULL && h->ai_canonname && (p = strchr(h->ai_canonname, '.'))) { - strfcpy(d, ++p, len); + mutt_str_strfcpy(d, ++p, len); ret = 0; mutt_debug(1, "getdnsdomainname(): %s\n", d); freeaddrinfo(h); diff --git a/conn/sasl.c b/conn/sasl.c index 5cf046b21..63e2602ca 100644 --- a/conn/sasl.c +++ b/conn/sasl.c @@ -666,7 +666,7 @@ int mutt_sasl_interact(sasl_interact_t *interaction) if (option(OPT_NO_CURSES) || mutt_get_field(prompt, resp, sizeof(resp), 0)) return SASL_FAIL; - interaction->len = mutt_strlen(resp) + 1; + interaction->len = mutt_str_strlen(resp) + 1; interaction->result = mutt_mem_malloc(interaction->len); memcpy((char *) interaction->result, resp, interaction->len); diff --git a/conn/socket.c b/conn/socket.c index 67192ed43..a9e4d27b5 100644 --- a/conn/socket.c +++ b/conn/socket.c @@ -82,7 +82,7 @@ static int socket_preconnect(void) int rc; int save_errno; - if (mutt_strlen(Preconnect)) + if (mutt_str_strlen(Preconnect)) { mutt_debug(2, "Executing preconnect: %s\n", Preconnect); rc = mutt_system(Preconnect); @@ -219,7 +219,7 @@ int mutt_socket_write_d(struct Connection *conn, const char *buf, int len, int d } if (len < 0) - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); while (sent < len) { diff --git a/conn/ssl.c b/conn/ssl.c index 383c4d589..d64142fdf 100644 --- a/conn/ssl.c +++ b/conn/ssl.c @@ -421,7 +421,7 @@ static char *x509_get_part(X509_NAME *name, int nid) static char ret[SHORT_STRING]; if (!name || X509_NAME_get_text_by_NID(name, nid, ret, sizeof(ret)) < 0) - strfcpy(ret, _("Unknown"), sizeof(ret)); + mutt_str_strfcpy(ret, _("Unknown"), sizeof(ret)); return ret; } @@ -448,7 +448,7 @@ static void x509_fingerprint(char *s, int l, X509 *cert, const EVP_MD *(*hashfun { char ch[8]; snprintf(ch, 8, "%02X%s", md[i], (i % 2 ? " " : "")); - safe_strcat(s, l, ch); + mutt_str_strcat(s, l, ch); } } } @@ -465,7 +465,7 @@ static char *asn1time_to_string(ASN1_UTCTIME *tm) static char buf[64]; BIO *bio = NULL; - strfcpy(buf, _("[invalid date]"), sizeof(buf)); + mutt_str_strfcpy(buf, _("[invalid date]"), sizeof(buf)); bio = BIO_new(BIO_s_mem()); if (bio) @@ -837,10 +837,10 @@ static int check_host(X509 *x509cert, const char *hostname, char *err, size_t er #ifdef HAVE_LIBIDN if (idna_to_ascii_lz(hostname, &hostname_ascii, 0) != IDNA_SUCCESS) { - hostname_ascii = safe_strdup(hostname); + hostname_ascii = mutt_str_strdup(hostname); } #else - hostname_ascii = safe_strdup(hostname); + hostname_ascii = mutt_str_strdup(hostname); #endif /* Try the DNS subjectAltNames. */ @@ -854,7 +854,7 @@ static int check_host(X509 *x509cert, const char *hostname, char *err, size_t er if (subj_alt_name->type == GEN_DNS) { if (subj_alt_name->d.ia5->length >= 0 && - mutt_strlen((char *) subj_alt_name->d.ia5->data) == + mutt_str_strlen((char *) subj_alt_name->d.ia5->data) == (size_t) subj_alt_name->d.ia5->length && (match_found = hostname_match(hostname_ascii, (char *) (subj_alt_name->d.ia5->data)))) @@ -873,7 +873,7 @@ static int check_host(X509 *x509cert, const char *hostname, char *err, size_t er if (!x509_subject) { if (err && errlen) - strfcpy(err, _("cannot get certificate subject"), errlen); + mutt_str_strfcpy(err, _("cannot get certificate subject"), errlen); goto out; } @@ -882,7 +882,7 @@ static int check_host(X509 *x509cert, const char *hostname, char *err, size_t er if (bufsize == -1) { if (err && errlen) - strfcpy(err, _("cannot get certificate common name"), errlen); + mutt_str_strfcpy(err, _("cannot get certificate common name"), errlen); goto out; } bufsize++; /* space for the terminal nul char */ @@ -890,13 +890,13 @@ static int check_host(X509 *x509cert, const char *hostname, char *err, size_t er if (X509_NAME_get_text_by_NID(x509_subject, NID_commonName, buf, bufsize) == -1) { if (err && errlen) - strfcpy(err, _("cannot get certificate common name"), errlen); + mutt_str_strfcpy(err, _("cannot get certificate common name"), errlen); goto out; } /* cast is safe since bufsize is incremented above, so bufsize-1 is always * zero or greater. */ - if (mutt_strlen(buf) == (size_t) bufsize - 1) + if (mutt_str_strlen(buf) == (size_t) bufsize - 1) { match_found = hostname_match(hostname_ascii, buf); } @@ -982,7 +982,7 @@ static int interactive_check_cert(X509 *cert, int idx, int len, SSL *ssl, int al menu->dialog[i] = mutt_mem_calloc(1, SHORT_STRING * sizeof(char)); row = 0; - strfcpy(menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING); row++; x509_subject = X509_get_subject_name(cert); for (unsigned int u = 0; u < mutt_array_size(part); u++) @@ -990,7 +990,7 @@ static int interactive_check_cert(X509 *cert, int idx, int len, SSL *ssl, int al x509_get_part(x509_subject, part[u])); row++; - strfcpy(menu->dialog[row], _("This certificate was issued by:"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], _("This certificate was issued by:"), SHORT_STRING); row++; x509_issuer = X509_get_issuer_name(cert); for (unsigned int u = 0; u < mutt_array_size(part); u++) @@ -1055,9 +1055,9 @@ static int interactive_check_cert(X509 *cert, int idx, int len, SSL *ssl, int al helpstr[0] = '\0'; mutt_make_help(buf, sizeof(buf), _("Exit "), MENU_GENERIC, OP_EXIT); - safe_strcat(helpstr, sizeof(helpstr), buf); + mutt_str_strcat(helpstr, sizeof(helpstr), buf); mutt_make_help(buf, sizeof(buf), _("Help"), MENU_GENERIC, OP_HELP); - safe_strcat(helpstr, sizeof(helpstr), buf); + mutt_str_strcat(helpstr, sizeof(helpstr), buf); menu->help = helpstr; done = 0; diff --git a/conn/ssl_gnutls.c b/conn/ssl_gnutls.c index 80cc5ed17..b64f9e087 100644 --- a/conn/ssl_gnutls.c +++ b/conn/ssl_gnutls.c @@ -294,7 +294,7 @@ static void tls_fingerprint(gnutls_digest_algorithm_t algo, char *s, int l, { char ch[8]; snprintf(ch, 8, "%02X%s", md[i], (i % 2 ? " " : "")); - safe_strcat(s, l, ch); + mutt_str_strcat(s, l, ch); } s[2 * n + n / 2 - 1] = '\0'; /* don't want trailing space */ } @@ -576,7 +576,7 @@ static char *tls_make_date(time_t t, char *s, size_t len) snprintf(s, len, "%s, %d %s %d %02d:%02d:%02d UTC", Weekdays[l->tm_wday], l->tm_mday, Months[l->tm_mon], l->tm_year + 1900, l->tm_hour, l->tm_min, l->tm_sec); else - strfcpy(s, _("[invalid date]"), len); + mutt_str_strfcpy(s, _("[invalid date]"), len); return s; } @@ -655,7 +655,7 @@ static int tls_check_one_certificate(const gnutls_datum_t *certdata, mutt_push_current_menu(menu); row = 0; - strfcpy(menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING); row++; buflen = sizeof(dn_common_name); @@ -693,7 +693,7 @@ static int tls_check_one_certificate(const gnutls_datum_t *certdata, dn_province, dn_country); row++; - strfcpy(menu->dialog[row], _("This certificate was issued by:"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], _("This certificate was issued by:"), SHORT_STRING); row++; buflen = sizeof(dn_common_name); @@ -752,31 +752,32 @@ static int tls_check_one_certificate(const gnutls_datum_t *certdata, if (certerr & CERTERR_NOTYETVALID) { row++; - strfcpy(menu->dialog[row], - _("WARNING: Server certificate is not yet valid"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], + _("WARNING: Server certificate is not yet valid"), SHORT_STRING); } if (certerr & CERTERR_EXPIRED) { row++; - strfcpy(menu->dialog[row], _("WARNING: Server certificate has expired"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], + _("WARNING: Server certificate has expired"), SHORT_STRING); } if (certerr & CERTERR_REVOKED) { row++; - strfcpy(menu->dialog[row], - _("WARNING: Server certificate has been revoked"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], + _("WARNING: Server certificate has been revoked"), SHORT_STRING); } if (certerr & CERTERR_HOSTNAME) { row++; - strfcpy(menu->dialog[row], - _("WARNING: Server hostname does not match certificate"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], + _("WARNING: Server hostname does not match certificate"), SHORT_STRING); } if (certerr & CERTERR_SIGNERNOTCA) { row++; - strfcpy(menu->dialog[row], - _("WARNING: Signer of server certificate is not a CA"), SHORT_STRING); + mutt_str_strfcpy(menu->dialog[row], + _("WARNING: Signer of server certificate is not a CA"), SHORT_STRING); } snprintf(title, sizeof(title), @@ -810,9 +811,9 @@ static int tls_check_one_certificate(const gnutls_datum_t *certdata, helpstr[0] = '\0'; mutt_make_help(buf, sizeof(buf), _("Exit "), MENU_GENERIC, OP_EXIT); - safe_strcat(helpstr, sizeof(helpstr), buf); + mutt_str_strcat(helpstr, sizeof(helpstr), buf); mutt_make_help(buf, sizeof(buf), _("Help"), MENU_GENERIC, OP_HELP); - safe_strcat(helpstr, sizeof(helpstr), buf); + mutt_str_strcat(helpstr, sizeof(helpstr), buf); menu->help = helpstr; done = 0; @@ -1036,34 +1037,34 @@ static int tls_set_priority(struct TlsSockData *data) size_t priority_size; int err; - priority_size = SHORT_STRING + mutt_strlen(SslCiphers); + priority_size = SHORT_STRING + mutt_str_strlen(SslCiphers); priority = mutt_mem_malloc(priority_size); priority[0] = 0; if (SslCiphers) - safe_strcat(priority, priority_size, SslCiphers); + mutt_str_strcat(priority, priority_size, SslCiphers); else - safe_strcat(priority, priority_size, "NORMAL"); + mutt_str_strcat(priority, priority_size, "NORMAL"); if (!option(OPT_SSL_USE_TLSV1_2)) { nproto--; - safe_strcat(priority, priority_size, ":-VERS-TLS1.2"); + mutt_str_strcat(priority, priority_size, ":-VERS-TLS1.2"); } if (!option(OPT_SSL_USE_TLSV1_1)) { nproto--; - safe_strcat(priority, priority_size, ":-VERS-TLS1.1"); + mutt_str_strcat(priority, priority_size, ":-VERS-TLS1.1"); } if (!option(OPT_SSL_USE_TLSV1)) { nproto--; - safe_strcat(priority, priority_size, ":-VERS-TLS1.0"); + mutt_str_strcat(priority, priority_size, ":-VERS-TLS1.0"); } if (!option(OPT_SSL_USE_SSLV3)) { nproto--; - safe_strcat(priority, priority_size, ":-VERS-SSL3.0"); + mutt_str_strcat(priority, priority_size, ":-VERS-SSL3.0"); } if (nproto == 0) @@ -1186,7 +1187,7 @@ static int tls_negotiate(struct Connection *conn) gnutls_transport_set_ptr(data->state, (gnutls_transport_ptr_t)(long) conn->fd); if (gnutls_server_name_set(data->state, GNUTLS_NAME_DNS, conn->account.host, - mutt_strlen(conn->account.host))) + mutt_str_strlen(conn->account.host))) { mutt_error(_("Warning: unable to set TLS SNI host name")); mutt_sleep(1); diff --git a/copy.c b/copy.c index 86d3c3590..c45bee5ab 100644 --- a/copy.c +++ b/copy.c @@ -101,31 +101,31 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, if (nl && buf[0] != ' ' && buf[0] != '\t') { ignore = true; - if (!from && (mutt_strncmp("From ", buf, 5) == 0)) + if (!from && (mutt_str_strncmp("From ", buf, 5) == 0)) { if ((flags & CH_FROM) == 0) continue; from = true; } - else if (flags & (CH_NOQFROM) && (mutt_strncasecmp(">From ", buf, 6) == 0)) + else if (flags & (CH_NOQFROM) && (mutt_str_strncasecmp(">From ", buf, 6) == 0)) continue; else if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n')) break; /* end of header */ if ((flags & (CH_UPDATE | CH_XMIT | CH_NOSTATUS)) && - ((mutt_strncasecmp("Status:", buf, 7) == 0) || - (mutt_strncasecmp("X-Status:", buf, 9) == 0))) + ((mutt_str_strncasecmp("Status:", buf, 7) == 0) || + (mutt_str_strncasecmp("X-Status:", buf, 9) == 0))) continue; if ((flags & (CH_UPDATE_LEN | CH_XMIT | CH_NOLEN)) && - ((mutt_strncasecmp("Content-Length:", buf, 15) == 0) || - (mutt_strncasecmp("Lines:", buf, 6) == 0))) + ((mutt_str_strncasecmp("Content-Length:", buf, 15) == 0) || + (mutt_str_strncasecmp("Lines:", buf, 6) == 0))) continue; - if ((flags & CH_UPDATE_REFS) && (mutt_strncasecmp("References:", buf, 11) == 0)) + if ((flags & CH_UPDATE_REFS) && (mutt_str_strncasecmp("References:", buf, 11) == 0)) continue; - if ((flags & CH_UPDATE_IRT) && (mutt_strncasecmp("In-Reply-To:", buf, 12) == 0)) + if ((flags & CH_UPDATE_IRT) && (mutt_str_strncasecmp("In-Reply-To:", buf, 12) == 0)) continue; - if (flags & CH_UPDATE_LABEL && (mutt_strncasecmp("X-Label:", buf, 8) == 0)) + if (flags & CH_UPDATE_LABEL && (mutt_str_strncasecmp("X-Label:", buf, 8) == 0)) continue; ignore = false; @@ -178,7 +178,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, { if (!address_header_decode(&this_one)) rfc2047_decode(&this_one); - this_one_len = mutt_strlen(this_one); + this_one_len = mutt_str_strlen(this_one); /* Convert CRLF line endings to LF */ if ((this_one_len > 2) && (this_one[this_one_len - 2] == '\r') && @@ -193,7 +193,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, headers[x] = this_one; else { - int hlen = mutt_strlen(headers[x]); + int hlen = mutt_str_strlen(headers[x]); mutt_mem_realloc(&headers[x], hlen + this_one_len + sizeof(char)); strcat(headers[x] + hlen, this_one); @@ -205,7 +205,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, ignore = true; this_is_from = false; - if (!from && (mutt_strncmp("From ", buf, 5) == 0)) + if (!from && (mutt_str_strncmp("From ", buf, 5) == 0)) { if ((flags & CH_FROM) == 0) continue; @@ -218,25 +218,26 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, if (!((flags & CH_FROM) && (flags & CH_FORCE_FROM) && this_is_from) && (flags & CH_WEED) && mutt_matches_ignore(buf)) continue; - if ((flags & CH_WEED_DELIVERED) && (mutt_strncasecmp("Delivered-To:", buf, 13) == 0)) + if ((flags & CH_WEED_DELIVERED) && + (mutt_str_strncasecmp("Delivered-To:", buf, 13) == 0)) continue; if ((flags & (CH_UPDATE | CH_XMIT | CH_NOSTATUS)) && - ((mutt_strncasecmp("Status:", buf, 7) == 0) || - (mutt_strncasecmp("X-Status:", buf, 9) == 0))) + ((mutt_str_strncasecmp("Status:", buf, 7) == 0) || + (mutt_str_strncasecmp("X-Status:", buf, 9) == 0))) continue; if ((flags & (CH_UPDATE_LEN | CH_XMIT | CH_NOLEN)) && - ((mutt_strncasecmp("Content-Length:", buf, 15) == 0) || - (mutt_strncasecmp("Lines:", buf, 6) == 0))) + ((mutt_str_strncasecmp("Content-Length:", buf, 15) == 0) || + (mutt_str_strncasecmp("Lines:", buf, 6) == 0))) continue; if ((flags & CH_MIME) && - (((mutt_strncasecmp("content-", buf, 8) == 0) && - ((mutt_strncasecmp("transfer-encoding:", buf + 8, 18) == 0) || - (mutt_strncasecmp("type:", buf + 8, 5) == 0))) || - (mutt_strncasecmp("mime-version:", buf, 13) == 0))) + (((mutt_str_strncasecmp("content-", buf, 8) == 0) && + ((mutt_str_strncasecmp("transfer-encoding:", buf + 8, 18) == 0) || + (mutt_str_strncasecmp("type:", buf + 8, 5) == 0))) || + (mutt_str_strncasecmp("mime-version:", buf, 13) == 0))) continue; - if ((flags & CH_UPDATE_REFS) && (mutt_strncasecmp("References:", buf, 11) == 0)) + if ((flags & CH_UPDATE_REFS) && (mutt_str_strncasecmp("References:", buf, 11) == 0)) continue; - if ((flags & CH_UPDATE_IRT) && (mutt_strncasecmp("In-Reply-To:", buf, 12) == 0)) + if ((flags & CH_UPDATE_IRT) && (mutt_str_strncasecmp("In-Reply-To:", buf, 12) == 0)) continue; /* Find x -- the array entry where this header is to be saved */ @@ -247,7 +248,7 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, STAILQ_FOREACH(np, &HeaderOrderList, entries) { ++x; - if (mutt_strncasecmp(buf, np->data, mutt_strlen(np->data)) == 0) + if (mutt_str_strncasecmp(buf, np->data, mutt_str_strlen(np->data)) == 0) { mutt_debug(2, "Reorder: %s matches %s\n", np->data, buf); break; @@ -263,12 +264,12 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, mutt_debug(2, "Reorder: x = %d; hdr_count = %d\n", x, hdr_count); if (!this_one) { - this_one = safe_strdup(buf); - this_one_len = mutt_strlen(this_one); + this_one = mutt_str_strdup(buf); + this_one_len = mutt_str_strlen(this_one); } else { - int blen = mutt_strlen(buf); + int blen = mutt_str_strlen(buf); mutt_mem_realloc(&this_one, this_one_len + blen + sizeof(char)); strcat(this_one + this_one_len, buf); @@ -284,14 +285,14 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, { if (!address_header_decode(&this_one)) rfc2047_decode(&this_one); - this_one_len = mutt_strlen(this_one); + this_one_len = mutt_str_strlen(this_one); } if (!headers[x]) headers[x] = this_one; else { - int hlen = mutt_strlen(headers[x]); + int hlen = mutt_str_strlen(headers[x]); mutt_mem_realloc(&headers[x], hlen + this_one_len + sizeof(char)); strcat(headers[x] + hlen, this_one); @@ -448,7 +449,7 @@ int mutt_copy_header(FILE *in, struct Header *h, FILE *out, int flags, const cha if (folder && !(option(OPT_WEED) && mutt_matches_ignore("folder"))) { char buf[LONG_STRING]; - strfcpy(buf, folder, sizeof(buf)); + mutt_str_strfcpy(buf, folder, sizeof(buf)); mutt_pretty_mailbox(buf, sizeof(buf)); fputs("Folder: ", out); @@ -551,7 +552,7 @@ int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Header *hdr, int flags, if (flags & MUTT_CM_PREFIX) { if (option(OPT_TEXT_FLOWED)) - strfcpy(prefix, ">", sizeof(prefix)); + mutt_str_strfcpy(prefix, ">", sizeof(prefix)); else mutt_make_string_flags(prefix, sizeof(prefix), NONULL(IndentString), Context, hdr, 0); } @@ -571,7 +572,7 @@ int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Header *hdr, int flags, char date[SHORT_STRING]; mutt_date_make_date(date, sizeof(date)); - int dlen = mutt_strlen(date); + int dlen = mutt_str_strlen(date); if (dlen == 0) return -1; @@ -895,7 +896,7 @@ static void format_address_header(char **h, struct Address *a) char *p = NULL; int l, linelen, buflen, cbuflen, c2buflen, plen; - linelen = mutt_strlen(*h); + linelen = mutt_str_strlen(*h); plen = linelen; buflen = linelen + 3; @@ -929,8 +930,8 @@ static void format_address_header(char **h, struct Address *a) strcpy(c2buf, ","); } - cbuflen = mutt_strlen(cbuf); - c2buflen = mutt_strlen(c2buf); + cbuflen = mutt_str_strlen(cbuf); + c2buflen = mutt_str_strlen(c2buf); buflen += l + cbuflen + c2buflen; mutt_mem_realloc(h, buflen); p = *h; @@ -959,13 +960,13 @@ static int address_header_decode(char **h) { case 'r': { - if (mutt_strncasecmp(s, "return-path:", 12) == 0) + if (mutt_str_strncasecmp(s, "return-path:", 12) == 0) { l = 12; rp = true; break; } - else if (mutt_strncasecmp(s, "reply-to:", 9) == 0) + else if (mutt_str_strncasecmp(s, "reply-to:", 9) == 0) { l = 9; break; @@ -974,42 +975,42 @@ static int address_header_decode(char **h) } case 'f': { - if (mutt_strncasecmp(s, "from:", 5) != 0) + if (mutt_str_strncasecmp(s, "from:", 5) != 0) return 0; l = 5; break; } case 'c': { - if (mutt_strncasecmp(s, "cc:", 3) != 0) + if (mutt_str_strncasecmp(s, "cc:", 3) != 0) return 0; l = 3; break; } case 'b': { - if (mutt_strncasecmp(s, "bcc:", 4) != 0) + if (mutt_str_strncasecmp(s, "bcc:", 4) != 0) return 0; l = 4; break; } case 's': { - if (mutt_strncasecmp(s, "sender:", 7) != 0) + if (mutt_str_strncasecmp(s, "sender:", 7) != 0) return 0; l = 7; break; } case 't': { - if (mutt_strncasecmp(s, "to:", 3) != 0) + if (mutt_str_strncasecmp(s, "to:", 3) != 0) return 0; l = 3; break; } case 'm': { - if (mutt_strncasecmp(s, "mail-followup-to:", 17) != 0) + if (mutt_str_strncasecmp(s, "mail-followup-to:", 17) != 0) return 0; l = 17; break; @@ -1026,16 +1027,16 @@ static int address_header_decode(char **h) rfc2047_decode_adrlist(a); for (cur = a; cur; cur = cur->next) if (cur->personal) - rfc822_dequote_comment(cur->personal); + mutt_str_dequote_comment(cur->personal); /* angle brackets for return path are mandated by RFC5322, * so leave Return-Path as-is */ if (rp) - *h = safe_strdup(s); + *h = mutt_str_strdup(s); else { *h = mutt_mem_calloc(1, l + 2); - strfcpy(*h, s, l + 1); + mutt_str_strfcpy(*h, s, l + 1); format_address_header(h, a); } diff --git a/curs_lib.c b/curs_lib.c index 3c4ba2ecd..d0cf44082 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -875,7 +875,7 @@ int mutt_do_pager(const char *banner, const char *tempfile, int do_color, struct { int rc; - if (!Pager || (mutt_strcmp(Pager, "builtin") == 0)) + if (!Pager || (mutt_str_strcmp(Pager, "builtin") == 0)) rc = mutt_pager(banner, tempfile, do_color, info); else { @@ -931,7 +931,7 @@ int mutt_enter_fname_full(const char *prompt, char *buf, size_t blen, int buffy, } else { - char *pc = mutt_mem_malloc(mutt_strlen(prompt) + 3); + char *pc = mutt_mem_malloc(mutt_str_strlen(prompt) + 3); sprintf(pc, "%s: ", prompt); mutt_unget_event(ch.op ? 0 : ch.ch, ch.op ? ch.op : 0); @@ -963,7 +963,7 @@ void mutt_unget_event(int ch, int op) void mutt_unget_string(char *s) { - char *p = s + mutt_strlen(s) - 1; + char *p = s + mutt_str_strlen(s) - 1; while (p >= s) { @@ -1112,7 +1112,7 @@ int mutt_multi_choice(char *prompt, char *letters) else if (ch.ch <= '9' && ch.ch > '0') { choice = ch.ch - '0'; - if (choice <= mutt_strlen(letters)) + if (choice <= mutt_str_strlen(letters)) break; } } @@ -1290,7 +1290,7 @@ static void format_s_x(char *dest, size_t destlen, const char *prefix, } mutt_simple_format(dest, destlen, min_width, max_width, justify, ' ', s, - mutt_strlen(s), arboreal); + mutt_str_strlen(s), arboreal); } void mutt_format_s(char *dest, size_t destlen, const char *prefix, const char *s) @@ -1313,7 +1313,7 @@ void mutt_paddstr(int n, const char *s) wchar_t wc; int w; size_t k; - size_t len = mutt_strlen(s); + size_t len = mutt_str_strlen(s); mbstate_t mbstate; memset(&mbstate, 0, sizeof(mbstate)); @@ -1362,7 +1362,7 @@ size_t mutt_wstr_trunc(const char *src, size_t maxlen, size_t maxwid, size_t *wi if (!src) goto out; - n = mutt_strlen(src); + n = mutt_str_strlen(src); memset(&mbstate, 0, sizeof(mbstate)); for (w = 0; n && (cl = mbrtowc(&wc, src, n, &mbstate)); src += cl, n -= cl) @@ -1412,7 +1412,7 @@ int mutt_strwidth(const char *s) if (!s) return 0; - n = mutt_strlen(s); + n = mutt_str_strlen(s); memset(&mbstate, 0, sizeof(mbstate)); for (w = 0; n && (k = mbrtowc(&wc, s, n, &mbstate)); s += k, n -= k) diff --git a/curs_main.c b/curs_main.c index 5c1d1ab3a..95d04add9 100644 --- a/curs_main.c +++ b/curs_main.c @@ -460,10 +460,10 @@ static int main_change_folder(struct Menu *menu, int op, char *buf, size_t bufsz #ifdef USE_COMPRESSED if (Context->compress_info && Context->realpath) - new_last_folder = safe_strdup(Context->realpath); + new_last_folder = mutt_str_strdup(Context->realpath); else #endif - new_last_folder = safe_strdup(Context->path); + new_last_folder = mutt_str_strdup(Context->path); *oldcount = Context ? Context->msgcount : 0; check = mx_close_mailbox(Context, index_hint); @@ -564,7 +564,7 @@ bool mutt_ts_capability(void) * necessarily asserting it in terminfo. */ for (termp = known; termp; termp++) { - if (term && *termp && (mutt_strncasecmp(term, *termp, strlen(*termp)) != 0)) + if (term && *termp && (mutt_str_strncasecmp(term, *termp, strlen(*termp)) != 0)) return true; } @@ -1251,7 +1251,8 @@ int mutt_index_menu(void) mutt_error(_("Article has no parent reference.")); break; } - strfcpy(buf, STAILQ_FIRST(&CURHDR->env->references)->data, sizeof(buf)); + mutt_str_strfcpy(buf, STAILQ_FIRST(&CURHDR->env->references)->data, + sizeof(buf)); } if (!Context->id_hash) Context->id_hash = mutt_make_id_hash(Context); @@ -1313,7 +1314,7 @@ int mutt_index_menu(void) mutt_message(_("Fetching message headers...")); if (!Context->id_hash) Context->id_hash = mutt_make_id_hash(Context); - strfcpy(buf, CURHDR->env->message_id, sizeof(buf)); + mutt_str_strfcpy(buf, CURHDR->env->message_id, sizeof(buf)); /* trying to find msgid of the root message */ if (op == OP_RECONSTRUCT_THREAD) @@ -1330,7 +1331,7 @@ int mutt_index_menu(void) /* the last msgid in References is the root message */ if (!STAILQ_NEXT(ref, entries)) - strfcpy(buf, ref->data, sizeof(buf)); + mutt_str_strfcpy(buf, ref->data, sizeof(buf)); } } @@ -1414,7 +1415,7 @@ int mutt_index_menu(void) break; } - if (mutt_atoi(buf, &i) < 0) + if (mutt_str_atoi(buf, &i) < 0) { mutt_error(_("Argument must be a message number.")); break; @@ -1521,13 +1522,13 @@ int mutt_index_menu(void) } else { - strfcpy(buf2, Context->pattern + 8, sizeof(buf2)); + mutt_str_strfcpy(buf2, Context->pattern + 8, sizeof(buf2)); if (!*buf2 || (strncmp(buf2, ".*", 2) == 0)) snprintf(buf2, sizeof(buf2), "~A"); unset_option(OPT_HIDE_READ); } FREE(&Context->pattern); - Context->pattern = safe_strdup(buf2); + Context->pattern = mutt_str_strdup(buf2); } if (((op == OP_LIMIT_CURRENT_THREAD) && mutt_limit_current_thread(CURHDR)) || @@ -2041,7 +2042,7 @@ int mutt_index_menu(void) buf[0] = '\0'; if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->path) { - strfcpy(buf, Context->path, sizeof(buf)); + mutt_str_strfcpy(buf, Context->path, sizeof(buf)); mutt_pretty_mailbox(buf, sizeof(buf)); mutt_buffy(buf, sizeof(buf)); if (!buf[0]) @@ -2067,7 +2068,7 @@ int mutt_index_menu(void) { if (Context && (Context->magic == MUTT_NOTMUCH)) { - strfcpy(buf, Context->path, sizeof(buf)); + mutt_str_strfcpy(buf, Context->path, sizeof(buf)); mutt_buffy_vfolder(buf, sizeof(buf)); } mutt_enter_vfolder(cp, buf, sizeof(buf), 1); @@ -2082,7 +2083,7 @@ int mutt_index_menu(void) { if (option(OPT_CHANGE_FOLDER_NEXT) && Context && Context->path) { - strfcpy(buf, Context->path, sizeof(buf)); + mutt_str_strfcpy(buf, Context->path, sizeof(buf)); mutt_pretty_mailbox(buf, sizeof(buf)); } #ifdef USE_NNTP @@ -3151,7 +3152,7 @@ int mutt_index_menu(void) CHECK_ATTACH; if (op != OP_FOLLOWUP || !CURHDR->env->followup_to || - (mutt_strcasecmp(CURHDR->env->followup_to, "poster") != 0) || + (mutt_str_strcasecmp(CURHDR->env->followup_to, "poster") != 0) || query_quadoption(OPT_FOLLOWUP_TO_POSTER, _("Reply by mail as poster prefers?")) != MUTT_YES) { diff --git a/edit.c b/edit.c index 5ba30d953..316ab8b19 100644 --- a/edit.c +++ b/edit.c @@ -83,8 +83,8 @@ static char **be_snarf_data(FILE *f, char **buf, int *bufmax, int *buflen, tmp[sizeof(tmp) - 1] = '\0'; if (prefix) { - strfcpy(tmp, NONULL(IndentString), sizeof(tmp)); - tmplen = mutt_strlen(tmp); + mutt_str_strfcpy(tmp, NONULL(IndentString), sizeof(tmp)); + tmplen = mutt_str_strlen(tmp); p = tmp + tmplen; tmplen = sizeof(tmp) - tmplen; } @@ -94,10 +94,10 @@ static char **be_snarf_data(FILE *f, char **buf, int *bufmax, int *buflen, { if (fgets(p, tmplen - 1, f) == NULL) break; - bytes -= mutt_strlen(p); + bytes -= mutt_str_strlen(p); if (*bufmax == *buflen) mutt_mem_realloc(&buf, sizeof(char *) * (*bufmax += 25)); - buf[(*buflen)++] = safe_strdup(tmp); + buf[(*buflen)++] = mutt_str_strdup(tmp); } if (buf && *bufmax == *buflen) { /* Do not smash memory past buf */ @@ -168,7 +168,7 @@ static char **be_include_messages(char *msg, char **buf, int *bufmax, while ((msg = strtok(msg, " ,")) != NULL) { - if (mutt_atoi(msg, &n) == 0 && n > 0 && n <= Context->msgcount) + if (mutt_str_atoi(msg, &n) == 0 && n > 0 && n <= Context->msgcount) { n--; @@ -183,7 +183,7 @@ static char **be_include_messages(char *msg, char **buf, int *bufmax, if (*bufmax == *buflen) mutt_mem_realloc(&buf, sizeof(char *) * (*bufmax += 25)); - buf[(*buflen)++] = safe_strdup(tmp); + buf[(*buflen)++] = mutt_str_strdup(tmp); bytes = Context->hdrs[n]->content->length; if (inc_hdrs) @@ -197,7 +197,7 @@ static char **be_include_messages(char *msg, char **buf, int *bufmax, if (*bufmax == *buflen) mutt_mem_realloc(&buf, sizeof(char *) * (*bufmax += 25)); - buf[(*buflen)++] = safe_strdup("\n"); + buf[(*buflen)++] = mutt_str_strdup("\n"); } else printw(_("%d: invalid message number.\n"), n); @@ -281,7 +281,7 @@ static void be_edit_header(struct Envelope *e, int force) if (!e->subject || force) { addstr("Subject: "); - strfcpy(tmp, e->subject ? e->subject : "", sizeof(tmp)); + mutt_str_strfcpy(tmp, e->subject ? e->subject : "", sizeof(tmp)); if (mutt_enter_string(tmp, sizeof(tmp), 9, 0) == 0) mutt_str_replace(&e->subject, tmp); addch('\n'); @@ -360,7 +360,7 @@ int mutt_builtin_editor(const char *path, struct Header *msg, struct Header *cur if (Escape && tmp[0] == Escape[0] && tmp[1] != Escape[0]) { /* remove trailing whitespace from the line */ - p = tmp + mutt_strlen(tmp) - 1; + p = tmp + mutt_str_strlen(tmp) - 1; while (p >= tmp && ISSPACE(*p)) *p-- = '\0'; @@ -393,9 +393,9 @@ int mutt_builtin_editor(const char *path, struct Header *msg, struct Header *cur if (!*p && cur) { /* include the current message */ - p = tmp + mutt_strlen(tmp) + 1; - snprintf(tmp + mutt_strlen(tmp), sizeof(tmp) - mutt_strlen(tmp), - " %d", cur->msgno + 1); + p = tmp + mutt_str_strlen(tmp) + 1; + snprintf(tmp + mutt_str_strlen(tmp), + sizeof(tmp) - mutt_str_strlen(tmp), " %d", cur->msgno + 1); } buf = be_include_messages(p, buf, &bufmax, &buflen, (tolower(tmp[1]) == 'm'), (isupper((unsigned char) tmp[1]))); @@ -440,8 +440,8 @@ int mutt_builtin_editor(const char *path, struct Header *msg, struct Header *cur if (buflen) { buflen--; - strfcpy(tmp, buf[buflen], sizeof(tmp)); - tmp[mutt_strlen(tmp) - 1] = '\0'; + mutt_str_strfcpy(tmp, buf[buflen], sizeof(tmp)); + tmp[mutt_str_strlen(tmp) - 1] = '\0'; FREE(&buf[buflen]); buf[buflen] = NULL; continue; @@ -488,14 +488,14 @@ int mutt_builtin_editor(const char *path, struct Header *msg, struct Header *cur break; } } - else if (mutt_strcmp(".", tmp) == 0) + else if (mutt_str_strcmp(".", tmp) == 0) done = true; else { - safe_strcat(tmp, sizeof(tmp), "\n"); + mutt_str_strcat(tmp, sizeof(tmp), "\n"); if (buflen == bufmax) mutt_mem_realloc(&buf, sizeof(char *) * (bufmax += 25)); - buf[buflen++] = safe_strdup(tmp[1] == '~' ? tmp + 1 : tmp); + buf[buflen++] = mutt_str_strdup(tmp[1] == '~' ? tmp + 1 : tmp); } tmp[0] = '\0'; diff --git a/enter.c b/enter.c index ae231ab35..26d3b164c 100644 --- a/enter.c +++ b/enter.c @@ -711,7 +711,7 @@ int mutt_enter_string_full(char *buf, size_t buflen, int col, int flags, int mul *numfiles = 1; tfiles = mutt_mem_calloc(*numfiles, sizeof(char *)); mutt_expand_path(buf, buflen); - tfiles[0] = safe_strdup(buf); + tfiles[0] = mutt_str_strdup(buf); *files = tfiles; } rv = 0; diff --git a/from.c b/from.c index d92cb62c9..5cfc329e5 100644 --- a/from.c +++ b/from.c @@ -43,10 +43,10 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) if (path) *path = '\0'; - if (mutt_strncmp("From ", s, 5) != 0) + if (mutt_str_strncmp("From ", s, 5) != 0) return 0; - s = next_word(s); /* skip over the From part. */ + s = mutt_str_next_word(s); /* skip over the From part. */ if (!*s) return 0; @@ -75,7 +75,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) return 0; /* pipermail archives have the return_path obscured such as "me at mutt.org" */ - if (mutt_strncasecmp(p, " at ", 4) == 0) + if (mutt_str_strncasecmp(p, " at ", 4) == 0) { p = strchr(p + 4, ' '); if (!p) @@ -109,7 +109,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) } } - s = next_word(s); + s = mutt_str_next_word(s); if (!*s) return 0; @@ -119,7 +119,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) */ if (mutt_date_is_day_name(s)) { - s = next_word(s); + s = mutt_str_next_word(s); if (!*s) return 0; } @@ -130,7 +130,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) return 0; /* day */ - s = next_word(s); + s = mutt_str_next_word(s); if (!*s) return 0; if (sscanf(s, "%d", &tm.tm_mday) != 1) @@ -139,7 +139,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) return 0; /* time */ - s = next_word(s); + s = mutt_str_next_word(s); if (!*s) return 0; @@ -155,14 +155,14 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) (tm.tm_min > 59) || (tm.tm_sec < 0) || (tm.tm_sec > 60)) return 0; - s = next_word(s); + s = mutt_str_next_word(s); if (!*s) return 0; /* timezone? */ if (isalpha((unsigned char) *s) || *s == '+' || *s == '-') { - s = next_word(s); + s = mutt_str_next_word(s); if (!*s) return 0; @@ -172,7 +172,7 @@ int is_from(const char *s, char *path, size_t pathlen, time_t *tp) */ if (isalpha((unsigned char) *s)) { - s = next_word(s); + s = mutt_str_next_word(s); if (!*s) return 0; } diff --git a/group.c b/group.c index faf8fd042..5e981e783 100644 --- a/group.c +++ b/group.c @@ -43,7 +43,7 @@ struct Group *mutt_pattern_group(const char *k) { mutt_debug(2, "mutt_pattern_group: Creating group %s.\n", k); p = mutt_mem_calloc(1, sizeof(struct Group)); - p->name = safe_strdup(k); + p->name = mutt_str_strdup(k); mutt_hash_insert(Groups, p->name, p); } @@ -198,7 +198,7 @@ bool mutt_group_match(struct Group *g, const char *s) if (mutt_match_regex_list(s, g->rs)) return true; for (ap = g->as; ap; ap = ap->next) - if (ap->mailbox && (mutt_strcasecmp(s, ap->mailbox) == 0)) + if (ap->mailbox && (mutt_str_strcasecmp(s, ap->mailbox) == 0)) return true; } return false; diff --git a/handler.c b/handler.c index 85fd2d6e1..5515b8166 100644 --- a/handler.c +++ b/handler.c @@ -384,16 +384,16 @@ static void decode_uuencoded(struct State *s, long len, int istext, iconv_t cd) { if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL) return; - len -= mutt_strlen(tmps); - if ((mutt_strncmp(tmps, "begin", 5) == 0) && ISSPACE(tmps[5])) + len -= mutt_str_strlen(tmps); + if ((mutt_str_strncmp(tmps, "begin", 5) == 0) && ISSPACE(tmps[5])) break; } while (len > 0) { if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL) return; - len -= mutt_strlen(tmps); - if (mutt_strncmp(tmps, "end", 3) == 0) + len -= mutt_str_strlen(tmps); + if (mutt_str_strncmp(tmps, "end", 3) == 0) break; pt = tmps; linelen = decode_byte(*pt); @@ -564,7 +564,7 @@ static void enriched_wrap(struct EnrichedState *stte) if (stte->s->prefix) { state_puts(stte->s->prefix, stte->s); - stte->indent_len += mutt_strlen(stte->s->prefix); + stte->indent_len += mutt_str_strlen(stte->s->prefix); } if (stte->tag_level[RICH_EXCERPT]) @@ -575,12 +575,12 @@ static void enriched_wrap(struct EnrichedState *stte) if (stte->s->prefix) { state_puts(stte->s->prefix, stte->s); - stte->indent_len += mutt_strlen(stte->s->prefix); + stte->indent_len += mutt_str_strlen(stte->s->prefix); } else { state_puts("> ", stte->s); - stte->indent_len += mutt_strlen("> "); + stte->indent_len += mutt_str_strlen("> "); } x--; } @@ -695,7 +695,7 @@ static void enriched_puts(const char *s, struct EnrichedState *stte) { const char *c = NULL; - if (stte->buff_len < stte->buff_used + mutt_strlen(s)) + if (stte->buff_len < stte->buff_used + mutt_str_strlen(s)) { stte->buff_len += LONG_STRING; mutt_mem_realloc(&stte->buffer, (stte->buff_len + 1) * sizeof(wchar_t)); @@ -823,7 +823,7 @@ static int text_enriched_handler(struct Body *a, struct State *s) if (s->prefix) { state_puts(s->prefix, s); - stte.indent_len += mutt_strlen(s->prefix); + stte.indent_len += mutt_str_strlen(s->prefix); } while (state != DONE) @@ -934,10 +934,10 @@ static int is_mmnoask(const char *buf) if ((p = getenv("MM_NOASK")) != NULL && *p) { - if (mutt_strcmp(p, "1") == 0) + if (mutt_str_strcmp(p, "1") == 0) return 1; - strfcpy(tmp, p, sizeof(tmp)); + mutt_str_strfcpy(tmp, p, sizeof(tmp)); p = tmp; while ((p = strtok(p, ",")) != NULL) @@ -947,19 +947,19 @@ static int is_mmnoask(const char *buf) { if (*(q + 1) == '*') { - if (mutt_strncasecmp(buf, p, q - p) == 0) + if (mutt_str_strncasecmp(buf, p, q - p) == 0) return 1; } else { - if (mutt_strcasecmp(buf, p) == 0) + if (mutt_str_strcasecmp(buf, p) == 0) return 1; } } else { - lng = mutt_strlen(p); - if (buf[lng] == '/' && (mutt_strncasecmp(buf, p, lng) == 0)) + lng = mutt_str_strlen(p); + if (buf[lng] == '/' && (mutt_str_strncasecmp(buf, p, lng) == 0)) return 1; } @@ -995,10 +995,10 @@ static int is_autoview(struct Body *b) struct ListNode *np; STAILQ_FOREACH(np, &AutoViewList, entries) { - int i = mutt_strlen(np->data) - 1; + int i = mutt_str_strlen(np->data) - 1; if ((i > 0 && np->data[i - 1] == '/' && np->data[i] == '*' && - (mutt_strncasecmp(type, np->data, i) == 0)) || - (mutt_strcasecmp(type, np->data) == 0)) + (mutt_str_strncasecmp(type, np->data, i) == 0)) || + (mutt_str_strcasecmp(type, np->data) == 0)) { is_av = 1; break; @@ -1038,9 +1038,9 @@ static int alternative_handler(struct Body *a, struct State *s) fstat(fileno(s->fpin), &st); b = mutt_new_body(); b->length = (long) st.st_size; - b->parts = mutt_parse_multipart(s->fpin, mutt_get_parameter("boundary", a->parameter), - (long) st.st_size, - (mutt_strcasecmp("digest", a->subtype) == 0)); + b->parts = mutt_parse_multipart( + s->fpin, mutt_get_parameter("boundary", a->parameter), + (long) st.st_size, (mutt_str_strcasecmp("digest", a->subtype) == 0)); } else b = a; @@ -1064,7 +1064,7 @@ static int alternative_handler(struct Body *a, struct State *s) else { wild = true; - btlen = mutt_strlen(np->data); + btlen = mutt_str_strlen(np->data); } if (a->parts) @@ -1074,10 +1074,10 @@ static int alternative_handler(struct Body *a, struct State *s) while (b) { const char *bt = TYPE(b); - if ((mutt_strncasecmp(bt, np->data, btlen) == 0) && (bt[btlen] == 0)) + if ((mutt_str_strncasecmp(bt, np->data, btlen) == 0) && (bt[btlen] == 0)) { /* the basetype matches */ - if (wild || (mutt_strcasecmp(np->data + btlen + 1, b->subtype) == 0)) + if (wild || (mutt_str_strcasecmp(np->data + btlen + 1, b->subtype) == 0)) { choice = b; } @@ -1115,17 +1115,17 @@ static int alternative_handler(struct Body *a, struct State *s) { if (b->type == TYPETEXT) { - if ((mutt_strcasecmp("plain", b->subtype) == 0) && type <= TXTPLAIN) + if ((mutt_str_strcasecmp("plain", b->subtype) == 0) && type <= TXTPLAIN) { choice = b; type = TXTPLAIN; } - else if ((mutt_strcasecmp("enriched", b->subtype) == 0) && type <= TXTENRICHED) + else if ((mutt_str_strcasecmp("enriched", b->subtype) == 0) && type <= TXTENRICHED) { choice = b; type = TXTENRICHED; } - else if ((mutt_strcasecmp("html", b->subtype) == 0) && type <= TXTHTML) + else if ((mutt_str_strcasecmp("html", b->subtype) == 0) && type <= TXTHTML) { choice = b; type = TXTHTML; @@ -1158,13 +1158,13 @@ static int alternative_handler(struct Body *a, struct State *s) mutt_file_copy_bytes(s->fpin, s->fpout, choice->offset - choice->hdr_offset); } - if (mutt_strcmp("info", ShowMultipartAlternative) == 0) + if (mutt_str_strcmp("info", ShowMultipartAlternative) == 0) { print_part_line(s, choice, 0); } mutt_body_handler(choice, s); - if (mutt_strcmp("info", ShowMultipartAlternative) == 0) + if (mutt_str_strcmp("info", ShowMultipartAlternative) == 0) { if (a->parts) b = a->parts; @@ -1264,8 +1264,8 @@ int mutt_can_decode(struct Body *a) { if (WithCrypto) { - if ((mutt_strcasecmp(a->subtype, "signed") == 0) || - (mutt_strcasecmp(a->subtype, "encrypted") == 0)) + if ((mutt_str_strcasecmp(a->subtype, "signed") == 0) || + (mutt_str_strcasecmp(a->subtype, "encrypted") == 0)) return 1; } @@ -1298,9 +1298,9 @@ static int multipart_handler(struct Body *a, struct State *s) fstat(fileno(s->fpin), &st); b = mutt_new_body(); b->length = (long) st.st_size; - b->parts = mutt_parse_multipart(s->fpin, mutt_get_parameter("boundary", a->parameter), - (long) st.st_size, - (mutt_strcasecmp("digest", a->subtype) == 0)); + b->parts = mutt_parse_multipart( + s->fpin, mutt_get_parameter("boundary", a->parameter), + (long) st.st_size, (mutt_str_strcasecmp("digest", a->subtype) == 0)); } else b = a; @@ -1369,14 +1369,14 @@ static int autoview_handler(struct Body *a, struct State *s) snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype); rfc1524_mailcap_lookup(a, type, entry, MUTT_AUTOVIEW); - fname = safe_strdup(a->filename); + fname = mutt_str_strdup(a->filename); mutt_file_sanitize_filename(fname, 1); rfc1524_expand_filename(entry->nametemplate, fname, tempfile, sizeof(tempfile)); FREE(&fname); if (entry->command) { - strfcpy(command, entry->command, sizeof(command)); + mutt_str_strfcpy(command, entry->command, sizeof(command)); /* rfc1524_expand_command returns 0 if the file is required */ piped = rfc1524_expand_command(a, tempfile, type, command, sizeof(command)); @@ -1510,7 +1510,7 @@ static int external_body_handler(struct Body *b, struct State *s) else expire = -1; - if (mutt_strcasecmp(access_type, "x-mutt-deleted") == 0) + if (mutt_str_strcasecmp(access_type, "x-mutt-deleted") == 0) { if (s->flags & (MUTT_DISPLAY | MUTT_PRINTING)) { @@ -1636,9 +1636,9 @@ static int text_plain_handler(struct Body *b, struct State *s) while ((buf = mutt_file_read_line(buf, &sz, s->fpin, NULL, 0))) { - if ((mutt_strcmp(buf, "-- ") != 0) && option(OPT_TEXT_FLOWED)) + if ((mutt_str_strcmp(buf, "-- ") != 0) && option(OPT_TEXT_FLOWED)) { - l = mutt_strlen(buf); + l = mutt_str_strlen(buf); while (l > 0 && buf[l - 1] == ' ') buf[--l] = '\0'; } @@ -1837,7 +1837,7 @@ int mutt_body_handler(struct Body *b, struct State *s) } else if (b->type == TYPETEXT) { - if (mutt_strcasecmp("plain", b->subtype) == 0) + if (mutt_str_strcasecmp("plain", b->subtype) == 0) { /* avoid copying this part twice since removing the transfer-encoding is * the only operation needed. @@ -1845,12 +1845,12 @@ int mutt_body_handler(struct Body *b, struct State *s) if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp(b)) handler = crypt_pgp_application_pgp_handler; else if (option(OPT_REFLOW_TEXT) && - (mutt_strcasecmp("flowed", mutt_get_parameter("format", b->parameter)) == 0)) + (mutt_str_strcasecmp("flowed", mutt_get_parameter("format", b->parameter)) == 0)) handler = rfc3676_handler; else handler = text_plain_handler; } - else if (mutt_strcasecmp("enriched", b->subtype) == 0) + else if (mutt_str_strcasecmp("enriched", b->subtype) == 0) handler = text_enriched_handler; else /* text body type without a handler */ plaintext = false; @@ -1859,19 +1859,19 @@ int mutt_body_handler(struct Body *b, struct State *s) { if (mutt_is_message_type(b->type, b->subtype)) handler = message_handler; - else if (mutt_strcasecmp("delivery-status", b->subtype) == 0) + else if (mutt_str_strcasecmp("delivery-status", b->subtype) == 0) plaintext = true; - else if (mutt_strcasecmp("external-body", b->subtype) == 0) + else if (mutt_str_strcasecmp("external-body", b->subtype) == 0) handler = external_body_handler; } else if (b->type == TYPEMULTIPART) { char *p = NULL; - if ((mutt_strcmp("inline", ShowMultipartAlternative) != 0) && - (mutt_strcasecmp("alternative", b->subtype) == 0)) + if ((mutt_str_strcmp("inline", ShowMultipartAlternative) != 0) && + (mutt_str_strcasecmp("alternative", b->subtype) == 0)) handler = alternative_handler; - else if (WithCrypto && (mutt_strcasecmp("signed", b->subtype) == 0)) + else if (WithCrypto && (mutt_str_strcasecmp("signed", b->subtype) == 0)) { p = mutt_get_parameter("protocol", b->parameter); @@ -1898,7 +1898,8 @@ int mutt_body_handler(struct Body *b, struct State *s) } else if (WithCrypto && b->type == TYPEAPPLICATION) { - if (option(OPT_DONT_HANDLE_PGP_KEYS) && (mutt_strcasecmp("pgp-keys", b->subtype) == 0)) + if (option(OPT_DONT_HANDLE_PGP_KEYS) && + (mutt_str_strcasecmp("pgp-keys", b->subtype) == 0)) { /* pass raw part through for key extraction */ plaintext = true; diff --git a/hcache/bdb.c b/hcache/bdb.c index 1f9d594dc..68bb88103 100644 --- a/hcache/bdb.c +++ b/hcache/bdb.c @@ -79,7 +79,7 @@ static void *hcache_bdb_open(const char *path) struct HcacheDbCtx *ctx = mutt_mem_malloc(sizeof(struct HcacheDbCtx)); - if (mutt_atoi(HeaderCachePageSize, &pagesize) < 0 || pagesize <= 0) + if (mutt_str_atoi(HeaderCachePageSize, &pagesize) < 0 || pagesize <= 0) pagesize = 16384; snprintf(ctx->lockfile, _POSIX_PATH_MAX, "%s-lock-hack", path); diff --git a/hcache/gdbm.c b/hcache/gdbm.c index 6d43e9507..aac5c021a 100644 --- a/hcache/gdbm.c +++ b/hcache/gdbm.c @@ -41,7 +41,7 @@ static void *hcache_gdbm_open(const char *path) { int pagesize; - if (mutt_atoi(HeaderCachePageSize, &pagesize) < 0 || pagesize <= 0) + if (mutt_str_atoi(HeaderCachePageSize, &pagesize) < 0 || pagesize <= 0) pagesize = 16384; GDBM_FILE db = gdbm_open((char *) path, pagesize, GDBM_WRCREAT, 00600, NULL); diff --git a/hcache/hcache.c b/hcache/hcache.c index d9f4377df..b9ed2ea1e 100644 --- a/hcache/hcache.c +++ b/hcache/hcache.c @@ -180,13 +180,13 @@ static unsigned char *dump_char_size(char *c, unsigned char *d, int *off, return d; } - if (convert && !is_ascii(c, size)) + if (convert && !mutt_str_is_ascii(c, size)) { - p = mutt_substrdup(c, c + size); + p = mutt_str_substr_dup(c, c + size); if (mutt_convert_string(&p, Charset, "utf-8", 0) == 0) { c = p; - size = mutt_strlen(c) + 1; + size = mutt_str_strlen(c) + 1; } } @@ -203,7 +203,7 @@ static unsigned char *dump_char_size(char *c, unsigned char *d, int *off, static unsigned char *dump_char(char *c, unsigned char *d, int *off, bool convert) { - return dump_char_size(c, d, off, mutt_strlen(c) + 1, convert); + return dump_char_size(c, d, off, mutt_str_strlen(c) + 1, convert); } static void restore_char(char **c, const unsigned char *d, int *off, bool convert) @@ -219,9 +219,9 @@ static void restore_char(char **c, const unsigned char *d, int *off, bool conver *c = mutt_mem_malloc(size); memcpy(*c, d + *off, size); - if (convert && !is_ascii(*c, size)) + if (convert && !mutt_str_is_ascii(*c, size)) { - char *tmp = safe_strdup(*c); + char *tmp = mutt_str_strdup(*c); if (mutt_convert_string(&tmp, "utf-8", Charset, 0) == 0) { mutt_str_replace(c, tmp); @@ -538,7 +538,7 @@ static bool create_hcache_dir(const char *path) return false; static char dir[_POSIX_PATH_MAX]; - strfcpy(dir, path, sizeof(dir)); + mutt_str_strfcpy(dir, path, sizeof(dir)); char *p = strrchr(dir, '/'); if (!p) @@ -583,7 +583,7 @@ static const char *hcache_per_folder(const char *path, const char *folder, hcach char suffix[32] = ""; struct stat sb; - int plen = mutt_strlen(path); + int plen = mutt_str_strlen(path); int ret = stat(path, &sb); int slash = (path[plen - 1] == '/'); @@ -921,7 +921,7 @@ const char *mutt_hcache_backend_list(void) len += snprintf(tmp + len, STRING - len, "%s", (*ops)->name); } - return safe_strdup(tmp); + return mutt_str_strdup(tmp); } int mutt_hcache_is_valid_backend(const char *s) diff --git a/hdrline.c b/hdrline.c index 74281fc0d..dd9eb2dde 100644 --- a/hdrline.c +++ b/hdrline.c @@ -169,7 +169,7 @@ static size_t add_index_color(char *buf, size_t buflen, enum FormatFlag flags, c if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */ - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); buf += len; buflen -= len; } @@ -237,7 +237,7 @@ static const char *make_from_prefix(enum FieldType disp) return long_prefixes[disp]; char *pchar = get_nth_wchar(FromChars, disp); - if (mutt_strlen(pchar) == 0) + if (mutt_str_strlen(pchar) == 0) return ""; snprintf(padded, sizeof(padded), "%s ", pchar); @@ -325,7 +325,7 @@ static void make_from_addr(struct Envelope *hdr, char *buf, size_t len, int do_l else if (me && hdr->cc) snprintf(buf, len, "%s", hdr->cc->mailbox); else if (hdr->from) - strfcpy(buf, hdr->from->mailbox, len); + mutt_str_strfcpy(buf, hdr->from->mailbox, len); else *buf = 0; } @@ -523,7 +523,7 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co dest[0] = 0; if (dest[0]) { - strfcpy(buf2, dest, sizeof(buf2)); + mutt_str_strfcpy(buf2, dest, sizeof(buf2)); mutt_format_s(dest, destlen, prefix, buf2); break; } @@ -540,13 +540,13 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co if (ctx) { if ((p = strrchr(ctx->path, '/'))) - strfcpy(dest, p + 1, destlen); + mutt_str_strfcpy(dest, p + 1, destlen); else - strfcpy(dest, ctx->path, destlen); + mutt_str_strfcpy(dest, ctx->path, destlen); } else - strfcpy(dest, "(null)", destlen); - strfcpy(buf2, dest, sizeof(buf2)); + mutt_str_strfcpy(dest, "(null)", destlen); + mutt_str_strfcpy(buf2, dest, sizeof(buf2)); mutt_format_s(dest, destlen, prefix, buf2); break; @@ -869,7 +869,7 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co if (!parent_tags && hdr->thread->parent && hdr->thread->parent->message) parent_tags = driver_tags_get_transformed(&hdr->thread->parent->message->tags); - if (parent_tags && mutt_strcasecmp(tags, parent_tags) == 0) + if (parent_tags && mutt_str_strcasecmp(tags, parent_tags) == 0) i = 0; FREE(&parent_tags); } @@ -923,7 +923,7 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co snprintf(dest, destlen, fmt, ctx->msgcount); } else - strfcpy(dest, "(null)", destlen); + mutt_str_strfcpy(dest, "(null)", destlen); break; case 'n': @@ -987,7 +987,7 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co break; case 'P': - strfcpy(dest, NONULL(hfi->pager_progress), destlen); + mutt_str_strfcpy(dest, NONULL(hfi->pager_progress), destlen); break; #ifdef USE_NNTP @@ -1091,7 +1091,7 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co case 'u': if (hdr->env->from && hdr->env->from->mailbox) { - strfcpy(buf2, mutt_addr_for_display(hdr->env->from), sizeof(buf2)); + mutt_str_strfcpy(buf2, mutt_addr_for_display(hdr->env->from), sizeof(buf2)); if ((p = strpbrk(buf2, "%@"))) *p = 0; } @@ -1169,7 +1169,7 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co (hdr->thread->parent && hdr->thread->parent->message && hdr->thread->parent->message->env->x_label)) htmp = hdr->thread->parent->message; - if (htmp && (mutt_strcasecmp(hdr->env->x_label, htmp->env->x_label) == 0)) + if (htmp && (mutt_str_strcasecmp(hdr->env->x_label, htmp->env->x_label) == 0)) i = 0; } else diff --git a/header.c b/header.c index 7170326e8..a73954bb2 100644 --- a/header.c +++ b/header.c @@ -134,8 +134,8 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, #endif if (!STAILQ_EMPTY(&msg->env->in_reply_to) && (STAILQ_EMPTY(&n->in_reply_to) || - (mutt_strcmp(STAILQ_FIRST(&n->in_reply_to)->data, - STAILQ_FIRST(&msg->env->in_reply_to)->data) != 0))) + (mutt_str_strcmp(STAILQ_FIRST(&n->in_reply_to)->data, + STAILQ_FIRST(&msg->env->in_reply_to)->data) != 0))) mutt_list_free(&msg->env->references); /* restore old info. */ @@ -157,23 +157,23 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, { keep = true; - if (fcc && (mutt_strncasecmp("fcc:", np->data, 4) == 0)) + if (fcc && (mutt_str_strncasecmp("fcc:", np->data, 4) == 0)) { - p = skip_email_wsp(np->data + 4); + p = mutt_str_skip_email_wsp(np->data + 4); if (*p) { - strfcpy(fcc, p, fcclen); + mutt_str_strfcpy(fcc, p, fcclen); mutt_pretty_mailbox(fcc, fcclen); } keep = false; } - else if (mutt_strncasecmp("attach:", np->data, 7) == 0) + else if (mutt_str_strncasecmp("attach:", np->data, 7) == 0) { struct Body *body2 = NULL; struct Body *parts = NULL; size_t l = 0; - p = skip_email_wsp(np->data + 7); + p = mutt_str_skip_email_wsp(np->data + 7); if (*p) { for (; *p && *p != ' ' && *p != '\t'; p++) @@ -187,13 +187,13 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, if (l < sizeof(path) - 1) path[l++] = *p; } - p = skip_email_wsp(p); + p = mutt_str_skip_email_wsp(p); path[l] = '\0'; mutt_expand_path(path, sizeof(path)); if ((body2 = mutt_make_file_attach(path))) { - body2->description = safe_strdup(p); + body2->description = mutt_str_strdup(p); for (parts = msg->content; parts->next; parts = parts->next) ; parts->next = body2; @@ -206,7 +206,8 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, } keep = false; } - else if ((WithCrypto & APPLICATION_PGP) && (mutt_strncasecmp("pgp:", np->data, 4) == 0)) + else if ((WithCrypto & APPLICATION_PGP) && + (mutt_str_strncasecmp("pgp:", np->data, 4) == 0)) { msg->security = mutt_parse_crypt_hdr(np->data + 4, 0, APPLICATION_PGP); if (msg->security) @@ -268,7 +269,7 @@ static int label_message(struct Context *ctx, struct Header *hdr, char *new) { if (!hdr) return 0; - if (mutt_strcmp(hdr->env->x_label, new) == 0) + if (mutt_str_strcmp(hdr->env->x_label, new) == 0) return 0; if (hdr->env->x_label) @@ -291,7 +292,7 @@ int mutt_label_message(struct Header *hdr) *buf = '\0'; if (hdr != NULL && hdr->env->x_label != NULL) { - strfcpy(buf, hdr->env->x_label, sizeof(buf)); + mutt_str_strfcpy(buf, hdr->env->x_label, sizeof(buf)); } if (mutt_get_field("Label: ", buf, sizeof(buf), MUTT_LABEL /* | MUTT_CLEAR */) != 0) diff --git a/help.c b/help.c index daf722962..1bcb0f353 100644 --- a/help.c +++ b/help.c @@ -92,7 +92,7 @@ char *mutt_compile_help(char *buf, size_t buflen, int menu, const struct Mapping buflen -= 2; } mutt_make_help(pbuf, buflen, _(items[i].name), menu, items[i].value); - len = mutt_strlen(pbuf); + len = mutt_str_strlen(pbuf); pbuf += len; buflen -= len; } @@ -105,7 +105,7 @@ static int print_macro(FILE *f, int maxwidth, const char **macro) wchar_t wc; int w; size_t k; - size_t len = mutt_strlen(*macro); + size_t len = mutt_str_strlen(*macro); mbstate_t mbstate1, mbstate2; memset(&mbstate1, 0, sizeof(mbstate1)); @@ -165,7 +165,7 @@ static int get_wrapped_width(const char *t, size_t wid) wchar_t wc; size_t k; size_t m, n; - size_t len = mutt_strlen(t); + size_t len = mutt_str_strlen(t); const char *s = t; mbstate_t mbstate; @@ -233,7 +233,7 @@ static void format_line(FILE *f, int ismacro, const char *t1, const char *t2, co if (ismacro > 0) { - if (mutt_strcmp(Pager, "builtin") == 0) + if (mutt_str_strcmp(Pager, "builtin") == 0) fputs("_\010", f); fputs("M ", f); col += 2; @@ -273,7 +273,7 @@ static void format_line(FILE *f, int ismacro, const char *t1, const char *t2, co if (*t3) { - if (mutt_strcmp(Pager, "builtin") != 0) + if (mutt_str_strcmp(Pager, "builtin") != 0) { fputc('\n', f); n = 0; diff --git a/history.c b/history.c index 29069d4ee..9559f97ad 100644 --- a/history.c +++ b/history.c @@ -137,7 +137,7 @@ void mutt_read_histfile(void) if (hclass >= HC_LAST) continue; *p = '\0'; - p = safe_strdup(linebuf + read); + p = mutt_str_strdup(linebuf + read); if (p) { mutt_convert_string(&p, "utf-8", Charset, 0); @@ -305,7 +305,7 @@ static void save_history(enum HistoryClass hclass, const char *s) return; } - tmp = safe_strdup(s); + tmp = mutt_str_strdup(s); mutt_convert_string(&tmp, Charset, "utf-8", 0); /* Format of a history item (1 line): ":|". @@ -349,7 +349,7 @@ static void remove_history_dups(enum HistoryClass hclass, const char *s) source = dest = 0; while (source < h->last) { - if (!mutt_strcmp(h->hist[source], s)) + if (!mutt_str_strcmp(h->hist[source], s)) FREE(&h->hist[source++]); else h->hist[dest++] = h->hist[source++]; @@ -368,7 +368,7 @@ static void remove_history_dups(enum HistoryClass hclass, const char *s) source = dest = History; while (source > old_last) { - if (!mutt_strcmp(h->hist[source], s)) + if (!mutt_str_strcmp(h->hist[source], s)) FREE(&h->hist[source--]); else h->hist[dest--] = h->hist[source--]; @@ -408,7 +408,7 @@ void mutt_history_add(enum HistoryClass hclass, const char *s, bool save) * - lines beginning by a space * - repeated lines */ - if (*s != ' ' && (!h->hist[prev] || (mutt_strcmp(h->hist[prev], s) != 0))) + if (*s != ' ' && (!h->hist[prev] || (mutt_str_strcmp(h->hist[prev], s) != 0))) { if (option(OPT_HISTORY_REMOVE_DUPS)) remove_history_dups(hclass, s); diff --git a/hook.c b/hook.c index 5d97ff78a..1ef1b7400 100644 --- a/hook.c +++ b/hook.c @@ -87,7 +87,7 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, if (!MoreArgs(s)) { - strfcpy(err->data, _("too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too few arguments"), err->dsize); goto error; } } @@ -100,13 +100,13 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, if (!command.data) { - strfcpy(err->data, _("too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too few arguments"), err->dsize); goto error; } if (MoreArgs(s)) { - strfcpy(err->data, _("too many arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too many arguments"), err->dsize); goto error; } @@ -116,31 +116,31 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, * common mistake */ if ((*pattern.data == '^') && (!CurrentFolder)) { - strfcpy(err->data, _("current mailbox shortcut '^' is unset"), err->dsize); + mutt_str_strfcpy(err->data, _("current mailbox shortcut '^' is unset"), err->dsize); goto error; } - strfcpy(path, pattern.data, sizeof(path)); + mutt_str_strfcpy(path, pattern.data, sizeof(path)); mutt_expand_path_regex(path, sizeof(path), 1); /* Check for other mailbox shortcuts that expand to the empty string. * This is likely a mistake too */ if (!*path && *pattern.data) { - strfcpy(err->data, _("mailbox shortcut expanded to empty regex"), err->dsize); + mutt_str_strfcpy(err->data, _("mailbox shortcut expanded to empty regex"), err->dsize); goto error; } FREE(&pattern.data); mutt_buffer_init(&pattern); - pattern.data = safe_strdup(path); + pattern.data = mutt_str_strdup(path); } #ifdef USE_COMPRESSED else if (data & (MUTT_APPENDHOOK | MUTT_OPENHOOK | MUTT_CLOSEHOOK)) { if (mutt_comp_valid_command(command.data) == 0) { - strfcpy(err->data, _("badly formatted command string"), err->dsize); + mutt_str_strfcpy(err->data, _("badly formatted command string"), err->dsize); return -1; } } @@ -155,20 +155,20 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, * send2-hooks, save-hooks, and fcc-hooks: All those allowing full * patterns. If given a simple regex, we expand $default_hook. */ - strfcpy(tmp, pattern.data, sizeof(tmp)); + mutt_str_strfcpy(tmp, pattern.data, sizeof(tmp)); mutt_check_simple(tmp, sizeof(tmp), DefaultHook); FREE(&pattern.data); mutt_buffer_init(&pattern); - pattern.data = safe_strdup(tmp); + pattern.data = mutt_str_strdup(tmp); } if (data & (MUTT_MBOXHOOK | MUTT_SAVEHOOK | MUTT_FCCHOOK)) { - strfcpy(path, command.data, sizeof(path)); + mutt_str_strfcpy(path, command.data, sizeof(path)); mutt_expand_path(path, sizeof(path)); FREE(&command.data); mutt_buffer_init(&command); - command.data = safe_strdup(path); + command.data = mutt_str_strdup(path); } /* check to make sure that a matching hook doesn't already exist */ @@ -177,14 +177,14 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, if (data & MUTT_GLOBALHOOK) { /* Ignore duplicate global hooks */ - if (mutt_strcmp(ptr->command, command.data) == 0) + if (mutt_str_strcmp(ptr->command, command.data) == 0) { FREE(&command.data); return 0; } } else if (ptr->type == data && - ptr->regex.not == not&&(mutt_strcmp(pattern.data, ptr->regex.pattern) == 0)) + ptr->regex.not == not&&(mutt_str_strcmp(pattern.data, ptr->regex.pattern) == 0)) { if (data & (MUTT_FOLDERHOOK | MUTT_SENDHOOK | MUTT_SEND2HOOK | MUTT_MESSAGEHOOK | MUTT_ACCOUNTHOOK | MUTT_REPLYHOOK | MUTT_CRYPTHOOK | @@ -193,7 +193,7 @@ int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, /* these hooks allow multiple commands with the same * pattern, so if we've already seen this pattern/command pair, just * ignore it instead of creating a duplicate */ - if (mutt_strcmp(ptr->command, command.data) == 0) + if (mutt_str_strcmp(ptr->command, command.data) == 0) { FREE(&command.data); FREE(&pattern.data); @@ -297,7 +297,7 @@ int mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data, while (MoreArgs(s)) { mutt_extract_token(buf, s, 0); - if (mutt_strcmp("*", buf->data) == 0) + if (mutt_str_strcmp("*", buf->data) == 0) { if (current_hook_type) { @@ -492,10 +492,10 @@ void mutt_select_fcc(char *path, size_t pathlen, struct Header *hdr) mutt_safe_path(buf, sizeof(buf), adr); mutt_file_concat_path(path, NONULL(Folder), buf, pathlen); if (!option(OPT_FORCE_NAME) && mx_access(path, W_OK) != 0) - strfcpy(path, NONULL(Record), pathlen); + mutt_str_strfcpy(path, NONULL(Record), pathlen); } else - strfcpy(path, NONULL(Record), pathlen); + mutt_str_strfcpy(path, NONULL(Record), pathlen); } mutt_pretty_mailbox(path, pathlen); } @@ -521,7 +521,7 @@ static void list_hook(struct ListHead *matches, const char *match, int hook) { if ((tmp->type & hook) && ((match && regexec(tmp->regex.regex, match, 0, NULL, 0) == 0) ^ tmp->regex.not)) - mutt_list_insert_tail(matches, safe_strdup(tmp->command)); + mutt_list_insert_tail(matches, mutt_str_strdup(tmp->command)); } } diff --git a/imap/auth.c b/imap/auth.c index 5ea3c7f0a..66f05c6bd 100644 --- a/imap/auth.c +++ b/imap/auth.c @@ -80,7 +80,7 @@ int imap_authenticate(struct ImapData *idata) if (ImapAuthenticators && *ImapAuthenticators) { /* Try user-specified list of authentication methods */ - methods = safe_strdup(ImapAuthenticators); + methods = mutt_str_strdup(ImapAuthenticators); for (method = methods; method; method = delim) { @@ -95,7 +95,8 @@ int imap_authenticate(struct ImapData *idata) while (authenticator->authenticate) { - if (!authenticator->method || (mutt_strcasecmp(authenticator->method, method) == 0)) + if (!authenticator->method || + (mutt_str_strcasecmp(authenticator->method, method) == 0)) if ((r = authenticator->authenticate(idata, method)) != IMAP_AUTH_UNAVAIL) { FREE(&methods); diff --git a/imap/auth_cram.c b/imap/auth_cram.c index 81d69efcb..d159ee782 100644 --- a/imap/auth_cram.c +++ b/imap/auth_cram.c @@ -68,11 +68,11 @@ static void hmac_md5(const char *password, char *challenge, unsigned char *respo if (secret_len > MD5_BLOCK_LEN) { mutt_md5_buf(password, secret_len, hash_passwd); - strfcpy((char *) secret, (char *) hash_passwd, MD5_DIGEST_LEN); + mutt_str_strfcpy((char *) secret, (char *) hash_passwd, MD5_DIGEST_LEN); secret_len = MD5_DIGEST_LEN; } else - strfcpy((char *) secret, password, sizeof(secret)); + mutt_str_strfcpy((char *) secret, password, sizeof(secret)); memset(ipad, 0, sizeof(ipad)); memset(opad, 0, sizeof(opad)); @@ -176,7 +176,7 @@ enum ImapAuthRes imap_auth_cram_md5(struct ImapData *idata, const char *method) /* ibuf must be long enough to store the base64 encoding of obuf, * plus the additional debris */ mutt_b64_encode(ibuf, obuf, strlen(obuf), sizeof(ibuf) - 2); - safe_strcat(ibuf, sizeof(ibuf), "\r\n"); + mutt_str_strcat(ibuf, sizeof(ibuf), "\r\n"); mutt_socket_write(idata->conn, ibuf); do diff --git a/imap/auth_gss.c b/imap/auth_gss.c index 00b1e8ad7..57d9cc9b8 100644 --- a/imap/auth_gss.c +++ b/imap/auth_gss.c @@ -77,14 +77,14 @@ static void print_gss_error(OM_uint32 err_maj, OM_uint32 err_min) GSS_C_NO_OID, &msg_ctx, &status_string); if (GSS_ERROR(maj_stat)) break; - strfcpy(buf_maj, (char *) status_string.value, sizeof(buf_maj)); + mutt_str_strfcpy(buf_maj, (char *) status_string.value, sizeof(buf_maj)); gss_release_buffer(&min_stat, &status_string); maj_stat = gss_display_status(&min_stat, err_min, GSS_C_MECH_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string); if (!GSS_ERROR(maj_stat)) { - strfcpy(buf_min, (char *) status_string.value, sizeof(buf_min)); + mutt_str_strfcpy(buf_min, (char *) status_string.value, sizeof(buf_min)); gss_release_buffer(&min_stat, &status_string); } } while (!GSS_ERROR(maj_stat) && msg_ctx != 0); @@ -178,7 +178,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) mutt_debug(2, "Sending credentials\n"); mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); gss_release_buffer(&min_stat, &send_token); - safe_strcat(buf1, sizeof(buf1), "\r\n"); + mutt_str_strcat(buf1, sizeof(buf1), "\r\n"); mutt_socket_write(idata->conn, buf1); while (maj_stat == GSS_S_CONTINUE_NEEDED) @@ -214,7 +214,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) } mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); gss_release_buffer(&min_stat, &send_token); - safe_strcat(buf1, sizeof(buf1), "\r\n"); + mutt_str_strcat(buf1, sizeof(buf1), "\r\n"); mutt_socket_write(idata->conn, buf1); } @@ -282,7 +282,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); mutt_debug(2, "Requesting authorisation as %s\n", idata->conn->account.user); - safe_strcat(buf1, sizeof(buf1), "\r\n"); + mutt_str_strcat(buf1, sizeof(buf1), "\r\n"); mutt_socket_write(idata->conn, buf1); /* Joy of victory or agony of defeat? */ diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index b4d3661f9..b45be0d61 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -87,10 +87,10 @@ enum ImapAuthRes imap_auth_sasl(struct ImapData *idata, const char *method) if (mutt_bit_isset(idata->capabilities, AUTH_ANON) && (!idata->conn->account.user[0] || - (mutt_strncmp(idata->conn->account.user, "anonymous", 9) == 0))) + (mutt_str_strncmp(idata->conn->account.user, "anonymous", 9) == 0))) rc = sasl_client_start(saslconn, "AUTH=ANONYMOUS", NULL, &pc, &olen, &mech); } - else if ((mutt_strcasecmp("login", method) == 0) && + else if ((mutt_str_strcasecmp("login", method) == 0) && !strstr(NONULL(idata->capstr), "AUTH=LOGIN")) /* do not use SASL login for regular IMAP login (#3556) */ return IMAP_AUTH_UNAVAIL; @@ -125,7 +125,7 @@ enum ImapAuthRes imap_auth_sasl(struct ImapData *idata, const char *method) snprintf(buf, bufsize, "AUTHENTICATE %s", mech); if (mutt_bit_isset(idata->capabilities, SASL_IR) && client_start) { - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); buf[len++] = ' '; if (sasl_encode64(pc, olen, buf + len, bufsize - len, &olen) != SASL_OK) { @@ -208,7 +208,7 @@ enum ImapAuthRes imap_auth_sasl(struct ImapData *idata, const char *method) if (irc == IMAP_CMD_RESPOND) { - strfcpy(buf + olen, "\r\n", bufsize - olen); + mutt_str_strfcpy(buf + olen, "\r\n", bufsize - olen); mutt_socket_write(idata->conn, buf); } diff --git a/imap/browse.c b/imap/browse.c index f8f46bfcf..f62fee190 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -86,12 +86,12 @@ static void add_folder(char delim, char *folder, int noselect, int noinferiors, /* render superiors as unix-standard ".." */ if (isparent) - strfcpy(relpath, "../", sizeof(relpath)); + mutt_str_strfcpy(relpath, "../", sizeof(relpath)); /* strip current folder from target, to render a relative path */ - else if (mutt_strncmp(mx.mbox, folder, mutt_strlen(mx.mbox)) == 0) - strfcpy(relpath, folder + mutt_strlen(mx.mbox), sizeof(relpath)); + else if (mutt_str_strncmp(mx.mbox, folder, mutt_str_strlen(mx.mbox)) == 0) + mutt_str_strfcpy(relpath, folder + mutt_str_strlen(mx.mbox), sizeof(relpath)); else - strfcpy(relpath, folder, sizeof(relpath)); + mutt_str_strfcpy(relpath, folder, sizeof(relpath)); /* apply filemask filter. This should really be done at menu setup rather * than at scan, since it's so expensive to scan. But that's big changes @@ -103,7 +103,7 @@ static void add_folder(char delim, char *folder, int noselect, int noinferiors, } imap_qualify_path(tmp, sizeof(tmp), &mx, folder); - (state->entry)[state->entrylen].name = safe_strdup(tmp); + (state->entry)[state->entrylen].name = mutt_str_strdup(tmp); /* mark desc with delim in browser if it can have subfolders */ if (!isparent && !noinferiors && strlen(relpath) < sizeof(relpath) - 1) @@ -112,7 +112,7 @@ static void add_folder(char delim, char *folder, int noselect, int noinferiors, relpath[strlen(relpath)] = delim; } - (state->entry)[state->entrylen].desc = safe_strdup(relpath); + (state->entry)[state->entrylen].desc = mutt_str_strdup(relpath); (state->entry)[state->entrylen].imap = true; /* delimiter at the root is useless. */ @@ -123,11 +123,11 @@ static void add_folder(char delim, char *folder, int noselect, int noinferiors, (state->entry)[state->entrylen].inferiors = !noinferiors; b = Incoming; - while (b && (mutt_strcmp(tmp, b->path) != 0)) + while (b && (mutt_str_strcmp(tmp, b->path) != 0)) b = b->next; if (b) { - if (Context && (mutt_strcmp(b->realpath, Context->realpath) == 0)) + if (Context && (mutt_str_strcmp(b->realpath, Context->realpath) == 0)) { b->msg_count = Context->msgcount; b->msg_unread = Context->unread; @@ -180,7 +180,7 @@ static int browse_add_list_result(struct ImapData *idata, const char *cmd, if (isparent) list.noselect = true; /* prune current folder from output */ - if (isparent || (mutt_strncmp(list.name, mx.mbox, strlen(list.name)) != 0)) + if (isparent || (mutt_str_strncmp(list.name, mx.mbox, strlen(list.name)) != 0)) add_folder(list.delim, list.name, list.noselect, list.noinferiors, state, isparent); } } while (rc == IMAP_CMD_CONTINUE); @@ -221,7 +221,8 @@ int imap_browse(char *path, struct BrowserState *state) save_lsub = option(OPT_IMAP_CHECK_SUBSCRIBED); unset_option(OPT_IMAP_CHECK_SUBSCRIBED); - strfcpy(list_cmd, option(OPT_IMAP_LIST_SUBSCRIBED) ? "LSUB" : "LIST", sizeof(list_cmd)); + mutt_str_strfcpy(list_cmd, option(OPT_IMAP_LIST_SUBSCRIBED) ? "LSUB" : "LIST", + sizeof(list_cmd)); idata = imap_conn_find(&(mx.account), 0); if (!idata) @@ -233,7 +234,7 @@ int imap_browse(char *path, struct BrowserState *state) if (mx.mbox && mx.mbox[0] != '\0') { imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox)); - n = mutt_strlen(mbox); + n = mutt_str_strlen(mbox); } else { @@ -274,7 +275,7 @@ int imap_browse(char *path, struct BrowserState *state) { showparents = true; imap_qualify_path(buf, sizeof(buf), &mx, mbox); - state->folder = safe_strdup(buf); + state->folder = mutt_str_strdup(buf); n--; } @@ -307,7 +308,7 @@ int imap_browse(char *path, struct BrowserState *state) ctmp = mbox[n]; mbox[n] = '\0'; imap_qualify_path(buf, sizeof(buf), &mx, mbox); - state->folder = safe_strdup(buf); + state->folder = mutt_str_strdup(buf); } mbox[n] = ctmp; } @@ -322,7 +323,7 @@ int imap_browse(char *path, struct BrowserState *state) if (!state->folder) { imap_qualify_path(buf, sizeof(buf), &mx, relpath); - state->folder = safe_strdup(buf); + state->folder = mutt_str_strdup(buf); } } } @@ -331,7 +332,7 @@ int imap_browse(char *path, struct BrowserState *state) if (!state->folder) { imap_qualify_path(buf, sizeof(buf), &mx, NULL); - state->folder = safe_strdup(buf); + state->folder = mutt_str_strdup(buf); } mutt_debug(3, "imap_browse: Quoting mailbox scan: %s -> ", mbox); @@ -392,10 +393,10 @@ int imap_mailbox_create(const char *folder) goto fail; } - strfcpy(buf, NONULL(mx.mbox), sizeof(buf)); + mutt_str_strfcpy(buf, NONULL(mx.mbox), sizeof(buf)); /* append a delimiter if necessary */ - n = mutt_strlen(buf); + n = mutt_str_strlen(buf); if (n && (n < sizeof(buf) - 1) && (buf[n - 1] != idata->delim)) { buf[n++] = idata->delim; @@ -405,7 +406,7 @@ int imap_mailbox_create(const char *folder) if (mutt_get_field(_("Create mailbox: "), buf, sizeof(buf), MUTT_FILE) < 0) goto fail; - if (!mutt_strlen(buf)) + if (!mutt_str_strlen(buf)) { mutt_error(_("Mailbox must have a name.")); mutt_sleep(1); @@ -462,12 +463,12 @@ int imap_mailbox_rename(const char *mailbox) } snprintf(buf, sizeof(buf), _("Rename mailbox %s to: "), mx.mbox); - strfcpy(newname, mx.mbox, sizeof(newname)); + mutt_str_strfcpy(newname, mx.mbox, sizeof(newname)); if (mutt_get_field(buf, newname, sizeof(newname), MUTT_FILE) < 0) goto fail; - if (!mutt_strlen(newname)) + if (!mutt_str_strlen(newname)) { mutt_error(_("Mailbox must have a name.")); mutt_sleep(1); diff --git a/imap/command.c b/imap/command.c index 26ce6301e..e9a4064cb 100644 --- a/imap/command.c +++ b/imap/command.c @@ -230,9 +230,9 @@ static int cmd_status(const char *s) { s = imap_next_word((char *) s); - if (mutt_strncasecmp("OK", s, 2) == 0) + if (mutt_str_strncasecmp("OK", s, 2) == 0) return IMAP_CMD_OK; - if (mutt_strncasecmp("NO", s, 2) == 0) + if (mutt_str_strncasecmp("NO", s, 2) == 0) return IMAP_CMD_NO; return IMAP_CMD_BAD; @@ -329,7 +329,7 @@ static void cmd_parse_fetch(struct ImapData *idata, char *s) { SKIPWS(s); - if (mutt_strncasecmp("FLAGS", s, 5) == 0) + if (mutt_str_strncasecmp("FLAGS", s, 5) == 0) { imap_set_flags(idata, h, s, &server_changes); if (server_changes) @@ -342,7 +342,7 @@ static void cmd_parse_fetch(struct ImapData *idata, char *s) } return; } - else if (mutt_strncasecmp("UID", s, 3) == 0) + else if (mutt_str_strncasecmp("UID", s, 3) == 0) { s += 3; SKIPWS(s); @@ -379,7 +379,7 @@ static void cmd_parse_capability(struct ImapData *idata, char *s) if ((bracket = strchr(s, ']'))) *bracket = '\0'; FREE(&idata->capstr); - idata->capstr = safe_strdup(s); + idata->capstr = mutt_str_strdup(s); memset(idata->capabilities, 0, sizeof(idata->capabilities)); @@ -387,7 +387,7 @@ static void cmd_parse_capability(struct ImapData *idata, char *s) { for (int i = 0; i < CAPMAX; i++) { - if (imap_wordcasecmp(Capabilities[i], s) == 0) + if (mutt_str_word_casecmp(Capabilities[i], s) == 0) { mutt_bit_set(idata->capabilities, i); mutt_debug(4, " Found capability \"%s\": %d\n", Capabilities[i], i); @@ -427,12 +427,12 @@ static void cmd_parse_list(struct ImapData *idata, char *s) s++; while (*s) { - if (mutt_strncasecmp(s, "\\NoSelect", 9) == 0) + if (mutt_str_strncasecmp(s, "\\NoSelect", 9) == 0) list->noselect = true; - else if (mutt_strncasecmp(s, "\\NoInferiors", 12) == 0) + else if (mutt_str_strncasecmp(s, "\\NoInferiors", 12) == 0) list->noinferiors = true; /* See draft-gahrns-imap-child-mailbox-?? */ - else if (mutt_strncasecmp(s, "\\HasNoChildren", 14) == 0) + else if (mutt_str_strncasecmp(s, "\\HasNoChildren", 14) == 0) list->noinferiors = true; s = imap_next_word(s); @@ -441,10 +441,10 @@ static void cmd_parse_list(struct ImapData *idata, char *s) } /* Delimiter */ - if (mutt_strncasecmp(s, "NIL", 3) != 0) + if (mutt_str_strncasecmp(s, "NIL", 3) != 0) { delimbuf[0] = '\0'; - safe_strcat(delimbuf, 5, s); + mutt_str_strcat(delimbuf, 5, s); imap_unquote_string(delimbuf); list->delim = delimbuf[0]; } @@ -507,16 +507,16 @@ static void cmd_parse_lsub(struct ImapData *idata, char *s) mutt_debug(3, "Subscribing to %s\n", list.name); - strfcpy(buf, "mailboxes \"", sizeof(buf)); + mutt_str_strfcpy(buf, "mailboxes \"", sizeof(buf)); mutt_account_tourl(&idata->conn->account, &url); /* escape \ and " */ imap_quote_string(errstr, sizeof(errstr), list.name); url.path = errstr + 1; url.path[strlen(url.path) - 1] = '\0'; - if (mutt_strcmp(url.user, ImapUser) == 0) + if (mutt_str_strcmp(url.user, ImapUser) == 0) url.user = NULL; url_tostring(&url, buf + 11, sizeof(buf) - 11, 0); - safe_strcat(buf, sizeof(buf), "\""); + mutt_str_strcat(buf, sizeof(buf), "\""); mutt_buffer_init(&token); mutt_buffer_init(&err); err.data = errstr; @@ -674,18 +674,18 @@ static void cmd_parse_status(struct ImapData *idata, char *s) value = imap_next_word(s); count = strtol(value, &value, 10); - if (mutt_strncmp("MESSAGES", s, 8) == 0) + if (mutt_str_strncmp("MESSAGES", s, 8) == 0) { status->messages = count; new_msg_count = 1; } - else if (mutt_strncmp("RECENT", s, 6) == 0) + else if (mutt_str_strncmp("RECENT", s, 6) == 0) status->recent = count; - else if (mutt_strncmp("UIDNEXT", s, 7) == 0) + else if (mutt_str_strncmp("UIDNEXT", s, 7) == 0) status->uidnext = count; - else if (mutt_strncmp("UIDVALIDITY", s, 11) == 0) + else if (mutt_str_strncmp("UIDVALIDITY", s, 11) == 0) status->uidvalidity = count; - else if (mutt_strncmp("UNSEEN", s, 6) == 0) + else if (mutt_str_strncmp("UNSEEN", s, 6) == 0) status->unseen = count; s = value; @@ -723,12 +723,12 @@ static void cmd_parse_status(struct ImapData *idata, char *s) { if (mx.mbox) { - value = safe_strdup(mx.mbox); - imap_fix_path(idata, mx.mbox, value, mutt_strlen(value) + 1); + value = mutt_str_strdup(mx.mbox); + imap_fix_path(idata, mx.mbox, value, mutt_str_strlen(value) + 1); FREE(&mx.mbox); } else - value = safe_strdup("INBOX"); + value = mutt_str_strdup("INBOX"); if (value && (imap_mxcmp(mailbox, value) == 0)) { @@ -788,8 +788,8 @@ static void cmd_parse_enabled(struct ImapData *idata, const char *s) while ((s = imap_next_word((char *) s)) && *s != '\0') { - if ((mutt_strncasecmp(s, "UTF8=ACCEPT", 11) == 0) || - (mutt_strncasecmp(s, "UTF8=ONLY", 9) == 0)) + if ((mutt_str_strncasecmp(s, "UTF8=ACCEPT", 11) == 0) || + (mutt_str_strncasecmp(s, "UTF8=ONLY", 9) == 0)) idata->unicode = 1; } } @@ -817,7 +817,7 @@ static int cmd_handle_untagged(struct ImapData *idata) /* EXISTS and EXPUNGE are always related to the SELECTED mailbox for the * connection, so update that one. */ - if (mutt_strncasecmp("EXISTS", s, 6) == 0) + if (mutt_str_strncasecmp("EXISTS", s, 6) == 0) { mutt_debug(2, "Handling EXISTS\n"); @@ -848,30 +848,30 @@ static int cmd_handle_untagged(struct ImapData *idata) } } /* pn vs. s: need initial seqno */ - else if (mutt_strncasecmp("EXPUNGE", s, 7) == 0) + else if (mutt_str_strncasecmp("EXPUNGE", s, 7) == 0) cmd_parse_expunge(idata, pn); - else if (mutt_strncasecmp("FETCH", s, 5) == 0) + else if (mutt_str_strncasecmp("FETCH", s, 5) == 0) cmd_parse_fetch(idata, pn); } - else if (mutt_strncasecmp("CAPABILITY", s, 10) == 0) + else if (mutt_str_strncasecmp("CAPABILITY", s, 10) == 0) cmd_parse_capability(idata, s); - else if (mutt_strncasecmp("OK [CAPABILITY", s, 14) == 0) + else if (mutt_str_strncasecmp("OK [CAPABILITY", s, 14) == 0) cmd_parse_capability(idata, pn); - else if (mutt_strncasecmp("OK [CAPABILITY", pn, 14) == 0) + else if (mutt_str_strncasecmp("OK [CAPABILITY", pn, 14) == 0) cmd_parse_capability(idata, imap_next_word(pn)); - else if (mutt_strncasecmp("LIST", s, 4) == 0) + else if (mutt_str_strncasecmp("LIST", s, 4) == 0) cmd_parse_list(idata, s); - else if (mutt_strncasecmp("LSUB", s, 4) == 0) + else if (mutt_str_strncasecmp("LSUB", s, 4) == 0) cmd_parse_lsub(idata, s); - else if (mutt_strncasecmp("MYRIGHTS", s, 8) == 0) + else if (mutt_str_strncasecmp("MYRIGHTS", s, 8) == 0) cmd_parse_myrights(idata, s); - else if (mutt_strncasecmp("SEARCH", s, 6) == 0) + else if (mutt_str_strncasecmp("SEARCH", s, 6) == 0) cmd_parse_search(idata, s); - else if (mutt_strncasecmp("STATUS", s, 6) == 0) + else if (mutt_str_strncasecmp("STATUS", s, 6) == 0) cmd_parse_status(idata, s); - else if (mutt_strncasecmp("ENABLED", s, 7) == 0) + else if (mutt_str_strncasecmp("ENABLED", s, 7) == 0) cmd_parse_enabled(idata, s); - else if (mutt_strncasecmp("BYE", s, 3) == 0) + else if (mutt_str_strncasecmp("BYE", s, 3) == 0) { mutt_debug(2, "Handling BYE\n"); @@ -888,7 +888,7 @@ static int cmd_handle_untagged(struct ImapData *idata) return -1; } - else if (option(OPT_IMAP_SERVERNOISE) && (mutt_strncasecmp("NO", s, 2) == 0)) + else if (option(OPT_IMAP_SERVERNOISE) && (mutt_str_strncasecmp("NO", s, 2) == 0)) { mutt_debug(2, "Handling untagged NO\n"); @@ -977,8 +977,8 @@ int imap_cmd_step(struct ImapData *idata) idata->lastread = time(NULL); /* handle untagged messages. The caller still gets its shot afterwards. */ - if (((mutt_strncmp(idata->buf, "* ", 2) == 0) || - (mutt_strncmp(imap_next_word(idata->buf), "OK [", 4) == 0)) && + if (((mutt_str_strncmp(idata->buf, "* ", 2) == 0) || + (mutt_str_strncmp(imap_next_word(idata->buf), "OK [", 4) == 0)) && cmd_handle_untagged(idata)) return IMAP_CMD_BAD; @@ -1003,7 +1003,7 @@ int imap_cmd_step(struct ImapData *idata) cmd = &idata->cmds[c]; if (cmd->state == IMAP_CMD_NEW) { - if (mutt_strncmp(idata->buf, cmd->seq, SEQLEN) == 0) + if (mutt_str_strncmp(idata->buf, cmd->seq, SEQLEN) == 0) { if (!stillrunning) { @@ -1062,8 +1062,9 @@ const char *imap_cmd_trailer(struct ImapData *idata) } s = imap_next_word((char *) s); - if (!s || ((mutt_strncasecmp(s, "OK", 2) != 0) && (mutt_strncasecmp(s, "NO", 2) != 0) && - (mutt_strncasecmp(s, "BAD", 3) != 0))) + if (!s || ((mutt_str_strncasecmp(s, "OK", 2) != 0) && + (mutt_str_strncasecmp(s, "NO", 2) != 0) && + (mutt_str_strncasecmp(s, "BAD", 3) != 0))) { mutt_debug(2, "imap_cmd_trailer: not a command completion: %s\n", idata->buf); return notrailer; diff --git a/imap/imap.c b/imap/imap.c index 7792caae4..0777c4bdc 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -150,7 +150,7 @@ static char *get_flags(struct ListHead *hflags, char *s) char ctmp; /* sanity-check string */ - if (mutt_strncasecmp("FLAGS", s, 5) != 0) + if (mutt_str_strncasecmp("FLAGS", s, 5) != 0) { mutt_debug(1, "get_flags: not a FLAGS response: %s\n", s); return NULL; @@ -174,7 +174,7 @@ static char *get_flags(struct ListHead *hflags, char *s) ctmp = *s; *s = '\0'; if (*flag_word) - mutt_list_insert_tail(hflags, safe_strdup(flag_word)); + mutt_list_insert_tail(hflags, mutt_str_strdup(flag_word)); *s = ctmp; } @@ -206,7 +206,7 @@ static void set_flag(struct ImapData *idata, int aclbit, int flag, { if (mutt_bit_isset(idata->ctx->rights, aclbit)) if (flag && imap_has_flag(&idata->flags, str)) - safe_strcat(flags, flsize, str); + mutt_str_strcat(flags, flsize, str); } /** @@ -398,7 +398,7 @@ static int get_mailbox(const char *path, struct ImapData **hidata, char *buf, si imap_fix_path(*hidata, mx.mbox, buf, blen); if (!*buf) - strfcpy(buf, "INBOX", blen); + mutt_str_strfcpy(buf, "INBOX", blen); FREE(&mx.mbox); return 0; @@ -589,14 +589,14 @@ static int complete_hosts(char *dest, size_t len) int rc = -1; size_t matchlen; - matchlen = mutt_strlen(dest); + matchlen = mutt_str_strlen(dest); for (mailbox = Incoming; mailbox; mailbox = mailbox->next) { - if (mutt_strncmp(dest, mailbox->path, matchlen) == 0) + if (mutt_str_strncmp(dest, mailbox->path, matchlen) == 0) { if (rc) { - strfcpy(dest, mailbox->path, len); + mutt_str_strfcpy(dest, mailbox->path, len); rc = 0; } else @@ -617,11 +617,11 @@ static int complete_hosts(char *dest, size_t len) url.user = NULL; url.path = NULL; url_tostring(&url, urlstr, sizeof(urlstr), 0); - if (mutt_strncmp(dest, urlstr, matchlen) == 0) + if (mutt_str_strncmp(dest, urlstr, matchlen) == 0) { if (rc) { - strfcpy(dest, urlstr, len); + mutt_str_strfcpy(dest, urlstr, len); rc = 0; } else @@ -661,10 +661,10 @@ int imap_access(const char *path) imap_fix_path(idata, mx.mbox, mailbox, sizeof(mailbox)); if (!*mailbox) - strfcpy(mailbox, "INBOX", sizeof(mailbox)); + mutt_str_strfcpy(mailbox, "INBOX", sizeof(mailbox)); /* we may already be in the folder we're checking */ - if (mutt_strcmp(idata->mailbox, mx.mbox) == 0) + if (mutt_str_strcmp(idata->mailbox, mx.mbox) == 0) { FREE(&mx.mbox); return 0; @@ -1058,9 +1058,9 @@ int imap_open_connection(struct ImapData *idata) return -1; } - if (mutt_strncasecmp("* OK", idata->buf, 4) == 0) + if (mutt_str_strncasecmp("* OK", idata->buf, 4) == 0) { - if ((mutt_strncasecmp("* OK [CAPABILITY", idata->buf, 16) != 0) && + if ((mutt_str_strncasecmp("* OK [CAPABILITY", idata->buf, 16) != 0) && check_capabilities(idata)) goto bail; #ifdef USE_SSL @@ -1106,7 +1106,7 @@ int imap_open_connection(struct ImapData *idata) } #endif } - else if (mutt_strncasecmp("* PREAUTH", idata->buf, 9) == 0) + else if (mutt_str_strncasecmp("* PREAUTH", idata->buf, 9) == 0) { idata->state = IMAP_AUTHENTICATED; if (check_capabilities(idata) != 0) @@ -1182,10 +1182,10 @@ bool imap_has_flag(struct ListHead *flag_list, const char *flag) struct ListNode *np; STAILQ_FOREACH(np, flag_list, entries) { - if (mutt_strncasecmp(np->data, flag, strlen(np->data)) == 0) + if (mutt_str_strncasecmp(np->data, flag, strlen(np->data)) == 0) return true; - if (mutt_strncmp(np->data, "\\*", strlen(np->data)) == 0) + if (mutt_str_strncmp(np->data, "\\*", strlen(np->data)) == 0) return true; } @@ -1318,17 +1318,17 @@ int imap_sync_message_for_copy(struct ImapData *idata, struct Header *hdr, { /* restore system flags */ if (HEADER_DATA(hdr)->flags_system) - safe_strcat(flags, sizeof(flags), HEADER_DATA(hdr)->flags_system); + mutt_str_strcat(flags, sizeof(flags), HEADER_DATA(hdr)->flags_system); /* set custom flags */ tags = driver_tags_get_with_hidden(&hdr->tags); if (tags) { - safe_strcat(flags, sizeof(flags), tags); + mutt_str_strcat(flags, sizeof(flags), tags); FREE(&tags); } } - mutt_remove_trailing_ws(flags); + mutt_str_remove_trailing_ws(flags); /* UW-IMAP is OK with null flags, Cyrus isn't. The only solution is to * explicitly revoke all system flags (if we have permission) */ @@ -1343,9 +1343,9 @@ int imap_sync_message_for_copy(struct ImapData *idata, struct Header *hdr, /* erase custom flags */ if (mutt_bit_isset(idata->ctx->rights, MUTT_ACL_WRITE) && HEADER_DATA(hdr)->flags_remote) - safe_strcat(flags, sizeof(flags), HEADER_DATA(hdr)->flags_remote); + mutt_str_strcat(flags, sizeof(flags), HEADER_DATA(hdr)->flags_remote); - mutt_remove_trailing_ws(flags); + mutt_str_remove_trailing_ws(flags); mutt_buffer_addstr(cmd, " -FLAGS.SILENT ("); } @@ -1648,7 +1648,7 @@ struct ImapStatus *imap_mboxcache_get(struct ImapData *idata, const char *mbox, scache->name = (char *) mbox; mutt_list_insert_tail(&idata->mboxcache, (char *) scache); status = imap_mboxcache_get(idata, mbox, 0); - status->name = safe_strdup(mbox); + status->name = mutt_str_strdup(mbox); } #ifdef USE_HCACHE @@ -1759,7 +1759,7 @@ int imap_subscribe(char *path, bool subscribe) imap_fix_path(idata, mx.mbox, buf, sizeof(buf)); if (!*buf) - strfcpy(buf, "INBOX", sizeof(buf)); + mutt_str_strfcpy(buf, "INBOX", sizeof(buf)); if (option(OPT_IMAP_CHECK_SUBSCRIBED)) { @@ -1823,7 +1823,7 @@ int imap_complete(char *dest, size_t dlen, char *path) if (imap_parse_path(path, &mx)) { - strfcpy(dest, path, dlen); + mutt_str_strfcpy(dest, path, dlen); return complete_hosts(dest, dlen); } @@ -1833,7 +1833,7 @@ int imap_complete(char *dest, size_t dlen, char *path) if (!idata) { FREE(&mx.mbox); - strfcpy(dest, path, dlen); + mutt_str_strfcpy(dest, path, dlen); return complete_hosts(dest, dlen); } @@ -1851,7 +1851,7 @@ int imap_complete(char *dest, size_t dlen, char *path) imap_cmd_start(idata, buf); /* and see what the results are */ - strfcpy(completion, NONULL(mx.mbox), sizeof(completion)); + mutt_str_strfcpy(completion, NONULL(mx.mbox), sizeof(completion)); idata->cmdtype = IMAP_CT_LIST; idata->cmddata = &listresp; do @@ -1872,7 +1872,7 @@ int imap_complete(char *dest, size_t dlen, char *path) /* copy in first word */ if (!completions) { - strfcpy(completion, listresp.name, sizeof(completion)); + mutt_str_strfcpy(completion, listresp.name, sizeof(completion)); matchlen = strlen(completion); completions++; continue; @@ -1934,7 +1934,7 @@ int imap_fast_trash(struct Context *ctx, char *dest) imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox)); if (!*mbox) - strfcpy(mbox, "INBOX", sizeof(mbox)); + mutt_str_strfcpy(mbox, "INBOX", sizeof(mbox)); imap_munge_mbox_name(idata, mmbox, sizeof(mmbox), mbox); sync_cmd = mutt_buffer_new(); @@ -1980,7 +1980,7 @@ int imap_fast_trash(struct Context *ctx, char *dest) break; } /* bail out if command failed for reasons other than nonexistent target */ - if (mutt_strncasecmp(imap_get_qualifier(idata->buf), "[TRYCREATE]", 11) != 0) + if (mutt_str_strncasecmp(imap_get_qualifier(idata->buf), "[TRYCREATE]", 11) != 0) break; mutt_debug(3, "imap_fast_trash: server suggests TRYCREATE\n"); snprintf(prompt, sizeof(prompt), _("Create %s?"), mbox); @@ -2045,15 +2045,15 @@ static int imap_open_mailbox(struct Context *ctx) /* Clean up path and replace the one in the ctx */ imap_fix_path(idata, mx.mbox, buf, sizeof(buf)); if (!*buf) - strfcpy(buf, "INBOX", sizeof(buf)); + mutt_str_strfcpy(buf, "INBOX", sizeof(buf)); FREE(&(idata->mailbox)); - idata->mailbox = safe_strdup(buf); + idata->mailbox = mutt_str_strdup(buf); imap_qualify_path(buf, sizeof(buf), &mx, idata->mailbox); FREE(&(ctx->path)); FREE(&(ctx->realpath)); - ctx->path = safe_strdup(buf); - ctx->realpath = safe_strdup(ctx->path); + ctx->path = mutt_str_strdup(buf); + ctx->realpath = mutt_str_strdup(ctx->path); idata->ctx = ctx; @@ -2112,7 +2112,7 @@ static int imap_open_mailbox(struct Context *ctx) /* Obtain list of available flags here, may be overridden by a * PERMANENTFLAGS tag in the OK response */ - if (mutt_strncasecmp("FLAGS", pc, 5) == 0) + if (mutt_str_strncasecmp("FLAGS", pc, 5) == 0) { /* don't override PERMANENTFLAGS */ if (STAILQ_EMPTY(&idata->flags)) @@ -2124,7 +2124,7 @@ static int imap_open_mailbox(struct Context *ctx) } } /* PERMANENTFLAGS are massaged to look like FLAGS, then override FLAGS */ - else if (mutt_strncasecmp("OK [PERMANENTFLAGS", pc, 18) == 0) + else if (mutt_str_strncasecmp("OK [PERMANENTFLAGS", pc, 18) == 0) { mutt_debug(3, "Getting mailbox PERMANENTFLAGS\n"); /* safe to call on NULL */ @@ -2136,7 +2136,7 @@ static int imap_open_mailbox(struct Context *ctx) goto fail; } /* save UIDVALIDITY for the header cache */ - else if (mutt_strncasecmp("OK [UIDVALIDITY", pc, 14) == 0) + else if (mutt_str_strncasecmp("OK [UIDVALIDITY", pc, 14) == 0) { mutt_debug(3, "Getting mailbox UIDVALIDITY\n"); pc += 3; @@ -2144,7 +2144,7 @@ static int imap_open_mailbox(struct Context *ctx) idata->uid_validity = strtol(pc, NULL, 10); status->uidvalidity = idata->uid_validity; } - else if (mutt_strncasecmp("OK [UIDNEXT", pc, 11) == 0) + else if (mutt_str_strncasecmp("OK [UIDNEXT", pc, 11) == 0) { mutt_debug(3, "Getting mailbox UIDNEXT\n"); pc += 3; @@ -2155,7 +2155,7 @@ static int imap_open_mailbox(struct Context *ctx) else { pc = imap_next_word(pc); - if (mutt_strncasecmp("EXISTS", pc, 6) == 0) + if (mutt_str_strncasecmp("EXISTS", pc, 6) == 0) { count = idata->new_mail_count; idata->new_mail_count = 0; @@ -2177,7 +2177,7 @@ static int imap_open_mailbox(struct Context *ctx) goto fail; /* check for READ-ONLY notification */ - if ((mutt_strncasecmp(imap_get_qualifier(idata->buf), "[READ-ONLY]", 11) == 0) && + if ((mutt_str_strncasecmp(imap_get_qualifier(idata->buf), "[READ-ONLY]", 11) == 0) && !mutt_bit_isset(idata->capabilities, ACL)) { mutt_debug(2, "Mailbox is read-only.\n"); @@ -2268,7 +2268,7 @@ static int imap_open_mailbox_append(struct Context *ctx, int flags) imap_fix_path(idata, mx.mbox, mailbox, sizeof(mailbox)); if (!*mailbox) - strfcpy(mailbox, "INBOX", sizeof(mailbox)); + mutt_str_strfcpy(mailbox, "INBOX", sizeof(mailbox)); FREE(&mx.mbox); rc = imap_access(ctx->path); @@ -2373,7 +2373,7 @@ static int imap_open_new_message(struct Message *msg, struct Context *dest, stru mutt_perror(tmp); return -1; } - msg->path = safe_strdup(tmp); + msg->path = mutt_str_strdup(tmp); return 0; } @@ -2673,9 +2673,9 @@ static int imap_edit_message_tags(struct Context *ctx, const char *tags, char *b } *new = '\0'; new = buf; /* rewind */ - mutt_remove_trailing_ws(new); + mutt_str_remove_trailing_ws(new); - if (mutt_strcmp(tags, buf) == 0) + if (mutt_str_strcmp(tags, buf) == 0) return 0; return 1; } diff --git a/imap/imap_private.h b/imap/imap_private.h index ab857c0a5..508d00115 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -343,7 +343,7 @@ void imap_allow_reopen(struct Context *ctx); void imap_disallow_reopen(struct Context *ctx); #ifdef USE_HCACHE -#define imap_hcache_keylen mutt_strlen +#define imap_hcache_keylen mutt_str_strlen #endif /* USE_HCACHE */ #endif /* _IMAP_PRIVATE_H */ diff --git a/imap/message.c b/imap/message.c index 71bb35fde..d67e1ddd4 100644 --- a/imap/message.c +++ b/imap/message.c @@ -213,7 +213,7 @@ static char *msg_parse_flags(struct ImapHeader *h, char *s) struct ImapHeaderData *hd = h->data; /* sanity-check string */ - if (mutt_strncasecmp("FLAGS", s, 5) != 0) + if (mutt_str_strncasecmp("FLAGS", s, 5) != 0) { mutt_debug(1, "msg_parse_flags: not a FLAGS response: %s\n", s); return NULL; @@ -235,29 +235,29 @@ static char *msg_parse_flags(struct ImapHeader *h, char *s) /* start parsing */ while (*s && *s != ')') { - if (mutt_strncasecmp("\\deleted", s, 8) == 0) + if (mutt_str_strncasecmp("\\deleted", s, 8) == 0) { s += 8; hd->deleted = true; } - else if (mutt_strncasecmp("\\flagged", s, 8) == 0) + else if (mutt_str_strncasecmp("\\flagged", s, 8) == 0) { s += 8; hd->flagged = true; } - else if (mutt_strncasecmp("\\answered", s, 9) == 0) + else if (mutt_str_strncasecmp("\\answered", s, 9) == 0) { s += 9; hd->replied = true; } - else if (mutt_strncasecmp("\\seen", s, 5) == 0) + else if (mutt_str_strncasecmp("\\seen", s, 5) == 0) { s += 5; hd->read = true; } - else if (mutt_strncasecmp("\\recent", s, 7) == 0) + else if (mutt_str_strncasecmp("\\recent", s, 7) == 0) s += 7; - else if (mutt_strncasecmp("old", s, 3) == 0) + else if (mutt_str_strncasecmp("old", s, 3) == 0) { s += 3; hd->old = option(OPT_MARK_OLD) ? true : false; @@ -266,7 +266,7 @@ static char *msg_parse_flags(struct ImapHeader *h, char *s) { char ctmp; char *flag_word = s; - bool is_system_keyword = (mutt_strncasecmp("\\", s, 1) == 0); + bool is_system_keyword = (mutt_str_strncasecmp("\\", s, 1) == 0); while (*s && !ISSPACE(*s) && *s != ')') s++; @@ -318,13 +318,13 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) { SKIPWS(s); - if (mutt_strncasecmp("FLAGS", s, 5) == 0) + if (mutt_str_strncasecmp("FLAGS", s, 5) == 0) { s = msg_parse_flags(h, s); if (!s) return -1; } - else if (mutt_strncasecmp("UID", s, 3) == 0) + else if (mutt_str_strncasecmp("UID", s, 3) == 0) { s += 3; SKIPWS(s); @@ -332,7 +332,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) s = imap_next_word(s); } - else if (mutt_strncasecmp("INTERNALDATE", s, 12) == 0) + else if (mutt_str_strncasecmp("INTERNALDATE", s, 12) == 0) { s += 12; SKIPWS(s); @@ -351,7 +351,7 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) *ptmp = '\0'; h->received = mutt_date_parse_imap(tmp); } - else if (mutt_strncasecmp("RFC822.SIZE", s, 11) == 0) + else if (mutt_str_strncasecmp("RFC822.SIZE", s, 11) == 0) { s += 11; SKIPWS(s); @@ -361,8 +361,8 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s) *ptmp = '\0'; h->content_length = atoi(tmp); } - else if ((mutt_strncasecmp("BODY", s, 4) == 0) || - (mutt_strncasecmp("RFC822.HEADER", s, 13) == 0)) + else if ((mutt_str_strncasecmp("BODY", s, 4) == 0) || + (mutt_str_strncasecmp("RFC822.HEADER", s, 13) == 0)) { /* handle above, in msg_fetch_header */ return -2; @@ -410,7 +410,7 @@ static int msg_fetch_header(struct Context *ctx, struct ImapHeader *h, char *buf /* find FETCH tag */ buf = imap_next_word(buf); - if (mutt_strncasecmp("FETCH", buf, 5) != 0) + if (mutt_str_strncasecmp("FETCH", buf, 5) != 0) return rc; rc = -2; /* we've got a FETCH response, for better or worse */ @@ -558,7 +558,7 @@ static void generate_seqset(struct Buffer *b, struct ImapData *idata, } /* Too big. Just query the whole range then. */ - if (chunks == 150 || mutt_strlen(b->data) > 500) + if (chunks == 150 || mutt_str_strlen(b->data) > 500) { b->dptr = b->data; mutt_buffer_printf(b, "%u:%u", msn_begin, msn_end); @@ -770,7 +770,7 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned i /* ctx->hdrs[msgno]->received is restored from mutt_hcache_restore */ ctx->hdrs[idx]->data = (void *) (h.data); STAILQ_INIT(&ctx->hdrs[idx]->tags); - driver_tags_replace(&ctx->hdrs[idx]->tags, safe_strdup(h.data->flags_remote)); + driver_tags_replace(&ctx->hdrs[idx]->tags, mutt_str_strdup(h.data->flags_remote)); ctx->msgcount++; ctx->size += ctx->hdrs[idx]->content->length; @@ -891,7 +891,7 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned i ctx->hdrs[idx]->received = h.received; ctx->hdrs[idx]->data = (void *) (h.data); STAILQ_INIT(&ctx->hdrs[idx]->tags); - driver_tags_replace(&ctx->hdrs[idx]->tags, safe_strdup(h.data->flags_remote)); + driver_tags_replace(&ctx->hdrs[idx]->tags, mutt_str_strdup(h.data->flags_remote)); if (maxuid < h.data->uid) maxuid = h.data->uid; @@ -1054,7 +1054,7 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno) { cache->uid = HEADER_DATA(h)->uid; mutt_mktemp(path, sizeof(path)); - cache->path = safe_strdup(path); + cache->path = mutt_str_strdup(path); msg->fp = mutt_file_fopen(path, "w+"); if (!msg->fp) { @@ -1084,14 +1084,14 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno) pc = imap_next_word(pc); pc = imap_next_word(pc); - if (mutt_strncasecmp("FETCH", pc, 5) == 0) + if (mutt_str_strncasecmp("FETCH", pc, 5) == 0) { while (*pc) { pc = imap_next_word(pc); if (pc[0] == '(') pc++; - if (mutt_strncasecmp("UID", pc, 3) == 0) + if (mutt_str_strncasecmp("UID", pc, 3) == 0) { pc = imap_next_word(pc); uid = atoi(pc); @@ -1099,8 +1099,8 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno) mutt_error(_( "The message index is incorrect. Try reopening the mailbox.")); } - else if ((mutt_strncasecmp("RFC822", pc, 6) == 0) || - (mutt_strncasecmp("BODY[]", pc, 6) == 0)) + else if ((mutt_str_strncasecmp("RFC822", pc, 6) == 0) || + (mutt_str_strncasecmp("BODY[]", pc, 6) == 0)) { pc = imap_next_word(pc); if (imap_get_literal_count(pc, &bytes) < 0) @@ -1128,7 +1128,7 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno) * change (eg from \Unseen to \Seen). * Uncommitted changes in neomutt take precedence. If we decide to * incrementally update flags later, this won't stop us syncing */ - else if ((mutt_strncasecmp("FLAGS", pc, 5) == 0) && !h->changed) + else if ((mutt_str_strncasecmp("FLAGS", pc, 5) == 0) && !h->changed) { pc = imap_set_flags(idata, h, pc, NULL); if (!pc) @@ -1266,7 +1266,7 @@ int imap_append_message(struct Context *ctx, struct Message *msg) imap_fix_path(idata, mx.mbox, mailbox, sizeof(mailbox)); if (!*mailbox) - strfcpy(mailbox, "INBOX", sizeof(mailbox)); + mutt_str_strfcpy(mailbox, "INBOX", sizeof(mailbox)); fp = fopen(msg->path, "r"); if (!fp) @@ -1298,13 +1298,13 @@ int imap_append_message(struct Context *ctx, struct Message *msg) imap_flags[0] = imap_flags[1] = 0; if (msg->flags.read) - safe_strcat(imap_flags, sizeof(imap_flags), " \\Seen"); + mutt_str_strcat(imap_flags, sizeof(imap_flags), " \\Seen"); if (msg->flags.replied) - safe_strcat(imap_flags, sizeof(imap_flags), " \\Answered"); + mutt_str_strcat(imap_flags, sizeof(imap_flags), " \\Answered"); if (msg->flags.flagged) - safe_strcat(imap_flags, sizeof(imap_flags), " \\Flagged"); + mutt_str_strcat(imap_flags, sizeof(imap_flags), " \\Flagged"); if (msg->flags.draft) - safe_strcat(imap_flags, sizeof(imap_flags), " \\Draft"); + mutt_str_strcat(imap_flags, sizeof(imap_flags), " \\Draft"); snprintf(buf, sizeof(buf), "APPEND %s (%s) \"%s\" {%lu}", mbox, imap_flags + 1, internaldate, (unsigned long) len); @@ -1422,7 +1422,7 @@ int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, int de imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox)); if (!*mbox) - strfcpy(mbox, "INBOX", sizeof(mbox)); + mutt_str_strfcpy(mbox, "INBOX", sizeof(mbox)); imap_munge_mbox_name(idata, mmbox, sizeof(mmbox), mbox); /* loop in case of TRYCREATE */ @@ -1507,7 +1507,7 @@ int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, int de break; } /* bail out if command failed for reasons other than nonexistent target */ - if (mutt_strncasecmp(imap_get_qualifier(idata->buf), "[TRYCREATE]", 11) != 0) + if (mutt_str_strncasecmp(imap_get_qualifier(idata->buf), "[TRYCREATE]", 11) != 0) break; mutt_debug(3, "imap_copy_messages: server suggests TRYCREATE\n"); snprintf(prompt, sizeof(prompt), _("Create %s?"), mbox); @@ -1653,7 +1653,7 @@ char *imap_set_flags(struct ImapData *idata, struct Header *h, char *s, int *ser return NULL; /* Update tags system */ - driver_tags_replace(&h->tags, safe_strdup(hd->flags_remote)); + driver_tags_replace(&h->tags, mutt_str_strdup(hd->flags_remote)); /* YAUH (yet another ugly hack): temporarily set context to * read-write even if it's read-only, so *server* updates of diff --git a/imap/utf7.c b/imap/utf7.c index 421005716..bb26cece8 100644 --- a/imap/utf7.c +++ b/imap/utf7.c @@ -321,12 +321,12 @@ void imap_utf_encode(struct ImapData *idata, char **s) { if (Charset) { - char *t = safe_strdup(*s); + char *t = mutt_str_strdup(*s); if (t && !mutt_convert_string(&t, Charset, "utf-8", 0)) { FREE(s); if (idata->unicode) - *s = safe_strdup(t); + *s = mutt_str_strdup(t); else *s = utf8_to_utf7(t, strlen(t), NULL, 0); } @@ -346,7 +346,7 @@ void imap_utf_decode(struct ImapData *idata, char **s) if (Charset) { if (idata->unicode) - t = safe_strdup(*s); + t = mutt_str_strdup(*s); else t = utf7_to_utf8(*s, strlen(*s), 0, 0); diff --git a/imap/util.c b/imap/util.c index a55313e99..a2beb8397 100644 --- a/imap/util.c +++ b/imap/util.c @@ -145,9 +145,9 @@ void imap_get_parent(char *output, const char *mbox, size_t olen, char delim) /* Make a copy of the mailbox name, but only if the pointers are different */ if (mbox != output) - strfcpy(output, mbox, olen); + mutt_str_strfcpy(output, mbox, olen); - n = mutt_strlen(output); + n = mutt_str_strlen(output); /* Let's go backwards until the next delimiter * @@ -193,14 +193,14 @@ void imap_get_parent_path(char *output, const char *path, size_t olen) if (imap_parse_path(path, &mx) < 0) { - strfcpy(output, path, olen); + mutt_str_strfcpy(output, path, olen); return; } idata = imap_conn_find(&mx.account, MUTT_IMAP_CONN_NONEW); if (!idata) { - strfcpy(output, path, olen); + mutt_str_strfcpy(output, path, olen); return; } @@ -411,7 +411,7 @@ int imap_parse_path(const char *path, struct ImapMbox *mx) mx->account.port = ImapPort; mx->account.type = MUTT_ACCT_TYPE_IMAP; - c = safe_strdup(path); + c = mutt_str_strdup(path); url_parse(&url, c); if (url.scheme == U_IMAP || url.scheme == U_IMAPS) { @@ -422,7 +422,7 @@ int imap_parse_path(const char *path, struct ImapMbox *mx) return -1; } - mx->mbox = safe_strdup(url.path); + mx->mbox = mutt_str_strdup(url.path); if (url.scheme == U_IMAPS) mx->account.flags |= MUTT_ACCT_SSL; @@ -443,13 +443,13 @@ int imap_parse_path(const char *path, struct ImapMbox *mx) return -1; else /* walk past closing '}' */ - mx->mbox = safe_strdup(c + 1); + mx->mbox = mutt_str_strdup(c + 1); if ((c = strrchr(tmp, '@'))) { *c = '\0'; - strfcpy(mx->account.user, tmp, sizeof(mx->account.user)); - strfcpy(tmp, c + 1, sizeof(tmp)); + mutt_str_strfcpy(mx->account.user, tmp, sizeof(mx->account.user)); + mutt_str_strfcpy(tmp, c + 1, sizeof(tmp)); mx->account.flags |= MUTT_ACCT_USER; } @@ -467,7 +467,7 @@ int imap_parse_path(const char *path, struct ImapMbox *mx) mx->account.flags |= MUTT_ACCT_PORT; if (sscanf(tmp, "/%s", tmp) == 1) { - if (mutt_strncmp(tmp, "ssl", 3) == 0) + if (mutt_str_strncmp(tmp, "ssl", 3) == 0) mx->account.flags |= MUTT_ACCT_SSL; else { @@ -506,7 +506,8 @@ int imap_mxcmp(const char *mx1, const char *mx2) mx1 = "INBOX"; if (!mx2 || !*mx2) mx2 = "INBOX"; - if ((mutt_strcasecmp(mx1, "INBOX") == 0) && (mutt_strcasecmp(mx2, "INBOX") == 0)) + if ((mutt_str_strcasecmp(mx1, "INBOX") == 0) && + (mutt_str_strcasecmp(mx2, "INBOX") == 0)) return 0; b1 = mutt_mem_malloc(strlen(mx1) + 1); @@ -515,7 +516,7 @@ int imap_mxcmp(const char *mx1, const char *mx2) imap_fix_path(NULL, mx1, b1, strlen(mx1) + 1); imap_fix_path(NULL, mx2, b2, strlen(mx2) + 1); - rc = mutt_strcmp(b1, b2); + rc = mutt_str_strcmp(b1, b2); FREE(&b1); FREE(&b2); @@ -540,13 +541,13 @@ void imap_pretty_mailbox(char *path) if (imap_parse_path(path, &target) < 0) return; - tlen = mutt_strlen(target.mbox); + tlen = mutt_str_strlen(target.mbox); /* check whether we can do '=' substitution */ if (mx_is_imap(Folder) && !imap_parse_path(Folder, &home)) { - hlen = mutt_strlen(home.mbox); + hlen = mutt_str_strlen(home.mbox); if (tlen && mutt_account_match(&home.account, &target.account) && - (mutt_strncmp(home.mbox, target.mbox, hlen) == 0)) + (mutt_str_strncmp(home.mbox, target.mbox, hlen) == 0)) { if (!hlen) home_match = true; @@ -910,7 +911,7 @@ void imap_munge_mbox_name(struct ImapData *idata, char *dest, size_t dlen, const { char *buf = NULL; - buf = safe_strdup(src); + buf = mutt_str_strdup(src); imap_utf_encode(idata, &buf); imap_quote_string(dest, dlen, buf); @@ -931,7 +932,7 @@ void imap_unmunge_mbox_name(struct ImapData *idata, char *s) imap_unquote_string(s); - buf = safe_strdup(s); + buf = mutt_str_strdup(s); if (buf) { imap_utf_decode(idata, &buf); diff --git a/init.c b/init.c index af81e83e2..f8e62cce7 100644 --- a/init.c +++ b/init.c @@ -96,14 +96,14 @@ static void myvar_set(const char *var, const char *val) struct MyVar **cur = NULL; for (cur = &MyVars; *cur; cur = &((*cur)->next)) - if (mutt_strcmp((*cur)->name, var) == 0) + if (mutt_str_strcmp((*cur)->name, var) == 0) break; if (!*cur) *cur = mutt_mem_calloc(1, sizeof(struct MyVar)); if (!(*cur)->name) - (*cur)->name = safe_strdup(var); + (*cur)->name = mutt_str_strdup(var); mutt_str_replace(&(*cur)->value, val); } @@ -114,7 +114,7 @@ static void myvar_del(const char *var) struct MyVar *tmp = NULL; for (cur = &MyVars; *cur; cur = &((*cur)->next)) - if (mutt_strcmp((*cur)->name, var) == 0) + if (mutt_str_strcmp((*cur)->name, var) == 0) break; if (*cur) @@ -149,16 +149,16 @@ static int parse_regex(int idx, struct Buffer *tmp, struct Buffer *err) regex_t *rx = NULL; struct Regex *ptr = (struct Regex *) MuttVars[idx].data; - if (!ptr->pattern || (mutt_strcmp(ptr->pattern, tmp->data) != 0)) + if (!ptr->pattern || (mutt_str_strcmp(ptr->pattern, tmp->data) != 0)) { bool not = false; /* $mask is case-sensitive */ - if (mutt_strcmp(MuttVars[idx].option, "mask") != 0) + if (mutt_str_strcmp(MuttVars[idx].option, "mask") != 0) flags |= mutt_which_case(tmp->data); p = tmp->data; - if (mutt_strcmp(MuttVars[idx].option, "mask") == 0) + if (mutt_str_strcmp(MuttVars[idx].option, "mask") == 0) { if (*p == '!') { @@ -184,7 +184,7 @@ static int parse_regex(int idx, struct Buffer *tmp, struct Buffer *err) FREE(&ptr->regex); } - ptr->pattern = safe_strdup(tmp->data); + ptr->pattern = mutt_str_strdup(tmp->data); ptr->regex = rx; ptr->not = not; @@ -238,7 +238,7 @@ int query_quadoption(int opt, const char *prompt) int mutt_option_index(const char *s) { for (int i = 0; MuttVars[i].option; i++) - if (mutt_strcmp(s, MuttVars[i].option) == 0) + if (mutt_str_strcmp(s, MuttVars[i].option) == 0) return (MuttVars[i].type == DT_SYNONYM ? mutt_option_index((char *) MuttVars[i].data) : i); @@ -266,7 +266,7 @@ bool mutt_option_get(const char *s, struct Option *opt) return true; } - if (mutt_strncmp("my_", s, 3) == 0) + if (mutt_str_strncmp("my_", s, 3) == 0) { const char *mv = myvar_get(s); if (!mv) @@ -303,11 +303,11 @@ static struct MbTable *parse_mbtable(const char *s) char *d = NULL; t = mutt_mem_calloc(1, sizeof(struct MbTable)); - slen = mutt_strlen(s); + slen = mutt_str_strlen(s); if (!slen) return t; - t->orig_str = safe_strdup(s); + t->orig_str = mutt_str_strdup(s); /* This could be more space efficient. However, being used on tiny * strings (ToChars and StatusChars), the overhead is not great. */ t->chars = mutt_mem_calloc(slen, sizeof(char *)); @@ -339,13 +339,13 @@ static int parse_sort(short *val, const char *s, const struct Mapping *map, stru { int i, flags = 0; - if (mutt_strncmp("reverse-", s, 8) == 0) + if (mutt_str_strncmp("reverse-", s, 8) == 0) { s += 8; flags = SORT_REVERSE; } - if (mutt_strncmp("last-", s, 5) == 0) + if (mutt_str_strncmp("last-", s, 5) == 0) { s += 5; flags |= SORT_LAST; @@ -387,7 +387,7 @@ int mutt_option_set(const struct Option *val, struct Buffer *err) { /* $reply_regexp and $alternates require special treatment */ if (Context && Context->msgcount && - (mutt_strcmp(MuttVars[idx].option, "reply_regexp") == 0)) + (mutt_str_strcmp(MuttVars[idx].option, "reply_regexp") == 0)) { regmatch_t pmatch[1]; @@ -464,12 +464,12 @@ int mutt_option_set(const struct Option *val, struct Buffer *err) case DT_PATH: { char scratch[LONG_STRING]; - strfcpy(scratch, NONULL((const char *) val->data), sizeof(scratch)); + mutt_str_strfcpy(scratch, NONULL((const char *) val->data), sizeof(scratch)); mutt_expand_path(scratch, sizeof(scratch)); /* MuttVars[idx].data is already 'char**' (or some 'void**') or... * so cast to 'void*' is okay */ FREE((void *) MuttVars[idx].data); - *((char **) MuttVars[idx].data) = safe_strdup(scratch); + *((char **) MuttVars[idx].data) = mutt_str_strdup(scratch); break; } case DT_STRING: @@ -477,7 +477,7 @@ int mutt_option_set(const struct Option *val, struct Buffer *err) /* MuttVars[idx].data is already 'char**' (or some 'void**') or... * so cast to 'void*' is okay */ FREE((void *) MuttVars[idx].data); - *((char **) MuttVars[idx].data) = safe_strdup((char *) val->data); + *((char **) MuttVars[idx].data) = mutt_str_strdup((char *) val->data); } break; case DT_BOOL: @@ -497,7 +497,7 @@ int mutt_option_set(const struct Option *val, struct Buffer *err) } } /* set the string as a myvar if it's one */ - if (mutt_strncmp("my_", val->option, 3) == 0) + if (mutt_str_strncmp("my_", val->option, 3) == 0) { myvar_set(val->option, (const char *) val->data); } @@ -616,7 +616,7 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, int flags) mutt_debug(1, "mutt_get_token: mismatched backticks\n"); return -1; } - cmd = mutt_substrdup(tok->dptr, pc); + cmd = mutt_str_substr_dup(tok->dptr, pc); pid = mutt_create_filter(cmd, NULL, &fp, NULL); if (pid < 0) { @@ -645,8 +645,8 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, int flags) } else if (expn.data) { - expnlen = mutt_strlen(expn.data); - tok->dsize = expnlen + mutt_strlen(tok->dptr) + 1; + expnlen = mutt_str_strlen(expn.data); + tok->dsize = expnlen + mutt_str_strlen(tok->dptr) + 1; ptr = mutt_mem_malloc(tok->dsize); memcpy(ptr, expn.data, expnlen); strcpy(ptr + expnlen, tok->dptr); @@ -671,7 +671,7 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, int flags) tok->dptr++; if ((pc = strchr(tok->dptr, '}'))) { - var = mutt_substrdup(tok->dptr, pc); + var = mutt_str_substr_dup(tok->dptr, pc); tok->dptr = pc + 1; } } @@ -679,7 +679,7 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, int flags) { for (pc = tok->dptr; isalnum((unsigned char) *pc) || *pc == '_'; pc++) ; - var = mutt_substrdup(tok->dptr, pc); + var = mutt_str_substr_dup(tok->dptr, pc); tok->dptr = pc; } if (var) @@ -757,12 +757,12 @@ static void add_to_stailq(struct ListHead *head, const char *str) struct ListNode *np; STAILQ_FOREACH(np, head, entries) { - if (mutt_strcasecmp(str, np->data) == 0) + if (mutt_str_strcasecmp(str, np->data) == 0) { return; } } - mutt_list_insert_tail(head, safe_strdup(str)); + mutt_list_insert_tail(head, mutt_str_strdup(str)); } static struct RegexList *new_regex_list(void) @@ -789,7 +789,7 @@ int mutt_add_to_regex_list(struct RegexList **list, const char *s, int flags, /* check to make sure the item is not already on this list */ for (last = *list; last; last = last->next) { - if (mutt_strcasecmp(rx->pattern, last->regex->pattern) == 0) + if (mutt_str_strcasecmp(rx->pattern, last->regex->pattern) == 0) { /* already on the list, so just ignore it */ last = NULL; @@ -826,7 +826,7 @@ static int remove_from_replace_list(struct ReplaceList **list, const char *pat) cur = *list; if (!cur) return 0; - if (cur->regex && (mutt_strcmp(cur->regex->pattern, pat) == 0)) + if (cur->regex && (mutt_str_strcmp(cur->regex->pattern, pat) == 0)) { *list = cur->next; mutt_free_regex(&cur->regex); @@ -838,7 +838,7 @@ static int remove_from_replace_list(struct ReplaceList **list, const char *pat) prev = cur; for (cur = prev->next; cur;) { - if (mutt_strcmp(cur->regex->pattern, pat) == 0) + if (mutt_str_strcmp(cur->regex->pattern, pat) == 0) { prev->next = cur->next; mutt_free_regex(&cur->regex); @@ -880,7 +880,7 @@ static int add_to_replace_list(struct ReplaceList **list, const char *pat, /* check to make sure the item is not already on this list */ for (last = *list; last; last = last->next) { - if (mutt_strcasecmp(rx->pattern, last->regex->pattern) == 0) + if (mutt_str_strcasecmp(rx->pattern, last->regex->pattern) == 0) { /* Already on the list. Formerly we just skipped this case, but * now we're supporting removals, which means we're supporting @@ -913,7 +913,7 @@ static int add_to_replace_list(struct ReplaceList **list, const char *pat, mutt_free_regex(&rx); /* Now t is the ReplaceList* that we want to modify. It is prepared. */ - t->template = safe_strdup(templ); + t->template = mutt_str_strdup(templ); /* Find highest match number in template string */ t->nmatch = 0; @@ -1015,7 +1015,7 @@ static int parse_ifdef(struct Buffer *tmp, struct Buffer *s, unsigned long data, for (int j = 0; b[j].name; j++) { - if (mutt_strcmp(tmp->data, b[j].name) == 0) + if (mutt_str_strcmp(tmp->data, b[j].name) == 0) { res = true; break; @@ -1029,7 +1029,7 @@ static int parse_ifdef(struct Buffer *tmp, struct Buffer *s, unsigned long data, { for (int i = 0; Commands[i].name; i++) { - if (mutt_strcmp(tmp->data, Commands[i].name) == 0) + if (mutt_str_strcmp(tmp->data, Commands[i].name) == 0) { res = true; break; @@ -1069,14 +1069,14 @@ static int parse_ifdef(struct Buffer *tmp, struct Buffer *s, unsigned long data, static void remove_from_stailq(struct ListHead *head, const char *str) { - if (mutt_strcmp("*", str) == 0) + if (mutt_str_strcmp("*", str) == 0) mutt_list_free(head); /* ``unCMD *'' means delete all current entries */ else { struct ListNode *np, *tmp; STAILQ_FOREACH_SAFE(np, head, entries, tmp) { - if (mutt_strcasecmp(str, np->data) == 0) + if (mutt_str_strcasecmp(str, np->data) == 0) { STAILQ_REMOVE(head, np, ListNode, entries); FREE(&np->data); @@ -1138,7 +1138,7 @@ static int parse_unstailq(struct Buffer *buf, struct Buffer *s, /* * Check for deletion of entire list */ - if (mutt_strcmp(buf->data, "*") == 0) + if (mutt_str_strcmp(buf->data, "*") == 0) { mutt_list_free((struct ListHead *) data); break; @@ -1198,7 +1198,7 @@ static int parse_unalternates(struct Buffer *buf, struct Buffer *s, mutt_extract_token(buf, s, 0); mutt_remove_from_regex_list(&Alternates, buf->data); - if ((mutt_strcmp(buf->data, "*") != 0) && + if ((mutt_str_strcmp(buf->data, "*") != 0) && mutt_add_to_regex_list(&UnAlternates, buf->data, REG_ICASE, err) != 0) return -1; @@ -1218,7 +1218,7 @@ static int parse_replace_list(struct Buffer *buf, struct Buffer *s, /* First token is a regex. */ if (!MoreArgs(s)) { - strfcpy(err->data, _("not enough arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("not enough arguments"), err->dsize); return -1; } mutt_extract_token(buf, s, 0); @@ -1226,7 +1226,7 @@ static int parse_replace_list(struct Buffer *buf, struct Buffer *s, /* Second token is a replacement template */ if (!MoreArgs(s)) { - strfcpy(err->data, _("not enough arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("not enough arguments"), err->dsize); return -1; } mutt_extract_token(&templ, s, 0); @@ -1249,14 +1249,14 @@ static int parse_unreplace_list(struct Buffer *buf, struct Buffer *s, /* First token is a regex. */ if (!MoreArgs(s)) { - strfcpy(err->data, _("not enough arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("not enough arguments"), err->dsize); return -1; } mutt_extract_token(buf, s, 0); /* "*" is a special case. */ - if (mutt_strcmp(buf->data, "*") == 0) + if (mutt_str_strcmp(buf->data, "*") == 0) { mutt_free_replace_list(list); return 0; @@ -1308,9 +1308,9 @@ static int parse_spam_list(struct Buffer *buf, struct Buffer *s, if (!MoreArgs(s)) { if (data == MUTT_SPAM) - strfcpy(err->data, _("spam: no matching pattern"), err->dsize); + mutt_str_strfcpy(err->data, _("spam: no matching pattern"), err->dsize); else - strfcpy(err->data, _("nospam: no matching pattern"), err->dsize); + mutt_str_strfcpy(err->data, _("nospam: no matching pattern"), err->dsize); return -1; } @@ -1349,7 +1349,7 @@ static int parse_spam_list(struct Buffer *buf, struct Buffer *s, /* nospam only ever has one parameter. */ /* "*" is a special case. */ - if (mutt_strcmp(buf->data, "*") == 0) + if (mutt_str_strcmp(buf->data, "*") == 0) { mutt_free_replace_list(&SpamList); mutt_free_regex_list(&NoSpamList); @@ -1368,7 +1368,7 @@ static int parse_spam_list(struct Buffer *buf, struct Buffer *s, } /* This should not happen. */ - strfcpy(err->data, "This is no good at all.", err->dsize); + mutt_str_strfcpy(err->data, "This is no good at all.", err->dsize); return -1; } @@ -1381,7 +1381,7 @@ static int parse_path_list(struct Buffer *buf, struct Buffer *s, do { mutt_extract_token(buf, s, 0); - strfcpy(path, buf->data, sizeof(path)); + mutt_str_strfcpy(path, buf->data, sizeof(path)); mutt_expand_path(path, sizeof(path)); add_to_stailq((struct ListHead *) data, path); } while (MoreArgs(s)); @@ -1400,12 +1400,12 @@ static int parse_path_unlist(struct Buffer *buf, struct Buffer *s, /* * Check for deletion of entire list */ - if (mutt_strcmp(buf->data, "*") == 0) + if (mutt_str_strcmp(buf->data, "*") == 0) { mutt_list_free((struct ListHead *) data); break; } - strfcpy(path, buf->data, sizeof(path)); + mutt_str_strfcpy(path, buf->data, sizeof(path)); mutt_expand_path(path, sizeof(path)); remove_from_stailq((struct ListHead *) data, path); } while (MoreArgs(s)); @@ -1467,16 +1467,16 @@ static int parse_group(struct Buffer *buf, struct Buffer *s, unsigned long data, if (parse_group_context(&gc, buf, s, data, err) == -1) goto bail; - if (data == MUTT_UNGROUP && (mutt_strcasecmp(buf->data, "*") == 0)) + if (data == MUTT_UNGROUP && (mutt_str_strcasecmp(buf->data, "*") == 0)) { if (mutt_group_context_clear(&gc) < 0) goto bail; goto out; } - if (mutt_strcasecmp(buf->data, "-rx") == 0) + if (mutt_str_strcasecmp(buf->data, "-rx") == 0) state = GS_RX; - else if (mutt_strcasecmp(buf->data, "-addr") == 0) + else if (mutt_str_strcasecmp(buf->data, "-addr") == 0) state = GS_ADDR; else { @@ -1558,12 +1558,12 @@ static int parse_attach_list(struct Buffer *buf, struct Buffer *s, a = mutt_mem_malloc(sizeof(struct AttachMatch)); /* some cheap hacks that I expect to remove */ - if (mutt_strcasecmp(buf->data, "any") == 0) - a->major = safe_strdup("*/.*"); - else if (mutt_strcasecmp(buf->data, "none") == 0) - a->major = safe_strdup("cheap_hack/this_should_never_match"); + if (mutt_str_strcasecmp(buf->data, "any") == 0) + a->major = mutt_str_strdup("*/.*"); + else if (mutt_str_strcasecmp(buf->data, "none") == 0) + a->major = mutt_str_strdup("cheap_hack/this_should_never_match"); else - a->major = safe_strdup(buf->data); + a->major = mutt_str_strdup(buf->data); if ((p = strchr(a->major, '/'))) { @@ -1618,12 +1618,12 @@ static int parse_unattach_list(struct Buffer *buf, struct Buffer *s, mutt_extract_token(buf, s, 0); FREE(&tmp); - if (mutt_strcasecmp(buf->data, "any") == 0) - tmp = safe_strdup("*/.*"); - else if (mutt_strcasecmp(buf->data, "none") == 0) - tmp = safe_strdup("cheap_hack/this_should_never_match"); + if (mutt_str_strcasecmp(buf->data, "any") == 0) + tmp = mutt_str_strdup("*/.*"); + else if (mutt_str_strcasecmp(buf->data, "none") == 0) + tmp = mutt_str_strdup("cheap_hack/this_should_never_match"); else - tmp = safe_strdup(buf->data); + tmp = mutt_str_strdup(buf->data); if ((minor = strchr(tmp, '/'))) { @@ -1642,7 +1642,7 @@ static int parse_unattach_list(struct Buffer *buf, struct Buffer *s, a = (struct AttachMatch *) np->data; mutt_debug(5, "parse_unattach_list: check %s/%s [%d] : %s/%s [%d]\n", a->major, a->minor, a->major_int, tmp, minor, major); - if (a->major_int == major && (mutt_strcasecmp(minor, a->minor) == 0)) + if (a->major_int == major && (mutt_str_strcasecmp(minor, a->minor) == 0)) { mutt_debug(5, "parse_unattach_list: removed %s/%s [%d]\n", a->major, a->minor, a->major_int); @@ -1683,7 +1683,7 @@ static int parse_attachments(struct Buffer *buf, struct Buffer *s, mutt_extract_token(buf, s, 0); if (!buf->data || *buf->data == '\0') { - strfcpy(err->data, _("attachments: no disposition"), err->dsize); + mutt_str_strfcpy(err->data, _("attachments: no disposition"), err->dsize); return -1; } @@ -1708,14 +1708,14 @@ static int parse_attachments(struct Buffer *buf, struct Buffer *s, op = '+'; category--; } - if (mutt_strncasecmp(category, "attachment", strlen(category)) == 0) + if (mutt_str_strncasecmp(category, "attachment", strlen(category)) == 0) { if (op == '+') head = &AttachAllow; else head = &AttachExclude; } - else if (mutt_strncasecmp(category, "inline", strlen(category)) == 0) + else if (mutt_str_strncasecmp(category, "inline", strlen(category)) == 0) { if (op == '+') head = &InlineAllow; @@ -1724,7 +1724,7 @@ static int parse_attachments(struct Buffer *buf, struct Buffer *s, } else { - strfcpy(err->data, _("attachments: invalid disposition"), err->dsize); + mutt_str_strfcpy(err->data, _("attachments: invalid disposition"), err->dsize); return -1; } @@ -1740,7 +1740,7 @@ static int parse_unattachments(struct Buffer *buf, struct Buffer *s, mutt_extract_token(buf, s, 0); if (!buf->data || *buf->data == '\0') { - strfcpy(err->data, _("unattachments: no disposition"), err->dsize); + mutt_str_strfcpy(err->data, _("unattachments: no disposition"), err->dsize); return -1; } @@ -1751,14 +1751,14 @@ static int parse_unattachments(struct Buffer *buf, struct Buffer *s, op = '+'; p--; } - if (mutt_strncasecmp(p, "attachment", strlen(p)) == 0) + if (mutt_str_strncasecmp(p, "attachment", strlen(p)) == 0) { if (op == '+') head = &AttachAllow; else head = &AttachExclude; } - else if (mutt_strncasecmp(p, "inline", strlen(p)) == 0) + else if (mutt_str_strncasecmp(p, "inline", strlen(p)) == 0) { if (op == '+') head = &InlineAllow; @@ -1767,7 +1767,7 @@ static int parse_unattachments(struct Buffer *buf, struct Buffer *s, } else { - strfcpy(err->data, _("unattachments: invalid disposition"), err->dsize); + mutt_str_strfcpy(err->data, _("unattachments: invalid disposition"), err->dsize); return -1; } @@ -1783,7 +1783,7 @@ static int parse_unlists(struct Buffer *buf, struct Buffer *s, mutt_remove_from_regex_list(&SubscribedLists, buf->data); mutt_remove_from_regex_list(&MailLists, buf->data); - if ((mutt_strcmp(buf->data, "*") != 0) && + if ((mutt_str_strcmp(buf->data, "*") != 0) && mutt_add_to_regex_list(&UnMailLists, buf->data, REG_ICASE, err) != 0) return -1; } while (MoreArgs(s)); @@ -1830,7 +1830,7 @@ static int parse_unsubscribe(struct Buffer *buf, struct Buffer *s, mutt_extract_token(buf, s, 0); mutt_remove_from_regex_list(&SubscribedLists, buf->data); - if ((mutt_strcmp(buf->data, "*") != 0) && + if ((mutt_str_strcmp(buf->data, "*") != 0) && mutt_add_to_regex_list(&UnSubscribedLists, buf->data, REG_ICASE, err) != 0) return -1; } while (MoreArgs(s)); @@ -1847,7 +1847,7 @@ static int parse_unalias(struct Buffer *buf, struct Buffer *s, { mutt_extract_token(buf, s, 0); - if (mutt_strcmp("*", buf->data) == 0) + if (mutt_str_strcmp("*", buf->data) == 0) { if (CurrentMenu == MENU_ALIAS) { @@ -1862,7 +1862,7 @@ static int parse_unalias(struct Buffer *buf, struct Buffer *s, else for (tmp = Aliases; tmp; tmp = tmp->next) { - if (mutt_strcasecmp(buf->data, tmp->name) == 0) + if (mutt_str_strcasecmp(buf->data, tmp->name) == 0) { if (CurrentMenu == MENU_ALIAS) { @@ -1895,7 +1895,7 @@ static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data, if (!MoreArgs(s)) { - strfcpy(err->data, _("alias: no address"), err->dsize); + mutt_str_strfcpy(err->data, _("alias: no address"), err->dsize); return -1; } @@ -1907,7 +1907,7 @@ static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data, /* check to see if an alias with this name already exists */ for (; tmp; tmp = tmp->next) { - if (mutt_strcasecmp(tmp->name, buf->data) == 0) + if (mutt_str_strcasecmp(tmp->name, buf->data) == 0) break; last = tmp; } @@ -1916,7 +1916,7 @@ static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data, { /* create a new alias */ tmp = mutt_mem_calloc(1, sizeof(struct Alias)); - tmp->name = safe_strdup(buf->data); + tmp->name = mutt_str_strdup(buf->data); /* give the main addressbook code a chance */ if (CurrentMenu == MENU_ALIAS) set_option(OPT_MENU_CALLER); @@ -1980,19 +1980,19 @@ static int parse_unmy_hdr(struct Buffer *buf, struct Buffer *s, do { mutt_extract_token(buf, s, 0); - if (mutt_strcmp("*", buf->data) == 0) + if (mutt_str_strcmp("*", buf->data) == 0) { mutt_list_free(&UserHeader); continue; } - l = mutt_strlen(buf->data); + l = mutt_str_strlen(buf->data); if (buf->data[l - 1] == ':') l--; STAILQ_FOREACH_SAFE(np, &UserHeader, entries, tmp) { - if ((mutt_strncasecmp(buf->data, np->data, l) == 0) && np->data[l] == ':') + if ((mutt_str_strncasecmp(buf->data, np->data, l) == 0) && np->data[l] == ':') { STAILQ_REMOVE(&UserHeader, np, ListNode, entries); FREE(&np->data); @@ -2013,7 +2013,7 @@ static int parse_my_hdr(struct Buffer *buf, struct Buffer *s, mutt_extract_token(buf, s, MUTT_TOKEN_SPACE | MUTT_TOKEN_QUOTE); if ((p = strpbrk(buf->data, ": \t")) == NULL || *p != ':') { - strfcpy(err->data, _("invalid header field"), err->dsize); + mutt_str_strfcpy(err->data, _("invalid header field"), err->dsize); return -1; } keylen = p - buf->data + 1; @@ -2021,7 +2021,7 @@ static int parse_my_hdr(struct Buffer *buf, struct Buffer *s, STAILQ_FOREACH(n, &UserHeader, entries) { /* see if there is already a field by this name */ - if (mutt_strncasecmp(buf->data, n->data, keylen) == 0) + if (mutt_str_strncasecmp(buf->data, n->data, keylen) == 0) { break; } @@ -2050,12 +2050,12 @@ static void set_default(struct Option *p) { case DT_STRING: if (!p->init && *((char **) p->data)) - p->init = (unsigned long) safe_strdup(*((char **) p->data)); + p->init = (unsigned long) mutt_str_strdup(*((char **) p->data)); break; case DT_PATH: if (!p->init && *((char **) p->data)) { - char *cp = safe_strdup(*((char **) p->data)); + char *cp = mutt_str_strdup(*((char **) p->data)); /* mutt_pretty_mailbox (cp); */ p->init = (unsigned long) cp; } @@ -2066,14 +2066,14 @@ static void set_default(struct Option *p) char tmp[HUGE_STRING]; *tmp = '\0'; rfc822_write_address(tmp, sizeof(tmp), *((struct Address **) p->data), 0); - p->init = (unsigned long) safe_strdup(tmp); + p->init = (unsigned long) mutt_str_strdup(tmp); } break; case DT_REGEX: { struct Regex *pp = (struct Regex *) p->data; if (!p->init && pp->pattern) - p->init = (unsigned long) safe_strdup(pp->pattern); + p->init = (unsigned long) mutt_str_strdup(pp->pattern); break; } } @@ -2094,7 +2094,7 @@ static void restore_default(struct Option *p) FREE((char **) p->data); char *init = NULL; #ifdef DEBUG - if (mutt_strcmp(p->option, "debug_file") == 0 && debugfile_cmdline) + if (mutt_str_strcmp(p->option, "debug_file") == 0 && debugfile_cmdline) init = debugfile_cmdline; else #endif @@ -2102,9 +2102,9 @@ static void restore_default(struct Option *p) if (init) { char path[_POSIX_PATH_MAX]; - strfcpy(path, init, sizeof(path)); + mutt_str_strfcpy(path, init, sizeof(path)); mutt_expand_path(path, sizeof(path)); - *((char **) p->data) = safe_strdup(path); + *((char **) p->data) = mutt_str_strdup(path); } break; case DT_ADDRESS: @@ -2125,7 +2125,7 @@ static void restore_default(struct Option *p) case DT_SORT: case DT_MAGIC: #ifdef DEBUG - if (mutt_strcmp(p->option, "debug_level") == 0 && debuglevel_cmdline) + if (mutt_str_strcmp(p->option, "debug_level") == 0 && debuglevel_cmdline) *((short *) p->data) = debuglevel_cmdline; else #endif @@ -2149,10 +2149,10 @@ static void restore_default(struct Option *p) char *s = (char *) p->init; pp->regex = mutt_mem_calloc(1, sizeof(regex_t)); - pp->pattern = safe_strdup((char *) p->init); - if (mutt_strcmp(p->option, "mask") != 0) + pp->pattern = mutt_str_strdup((char *) p->init); + if (mutt_str_strcmp(p->option, "mask") != 0) flags |= mutt_which_case((const char *) p->init); - if ((mutt_strcmp(p->option, "mask") == 0) && *s == '!') + if ((mutt_str_strcmp(p->option, "mask") == 0) && *s == '!') { s++; pp->not = true; @@ -2246,9 +2246,9 @@ static void pretty_var(char *dst, size_t len, const char *option, const char *va if (!len) return; - strfcpy(dst, option, len); + mutt_str_strfcpy(dst, option, len); len--; /* save room for \0 */ - p = dst + mutt_strlen(dst); + p = dst + mutt_str_strlen(dst); if (p - dst < len) *p++ = '='; @@ -2262,7 +2262,7 @@ static void pretty_var(char *dst, size_t len, const char *option, const char *va static int check_charset(struct Option *opt, const char *val) { - char *q = NULL, *s = safe_strdup(val); + char *q = NULL, *s = mutt_str_strdup(val); int rc = 0; bool strict = (strcmp(opt->option, "send_charset") == 0); @@ -2286,8 +2286,8 @@ static int check_charset(struct Option *opt, const char *val) static bool valid_show_multipart_alternative(const char *val) { - return ((mutt_strcmp(val, "inline") == 0) || - (mutt_strcmp(val, "info") == 0) || !val || (*val == 0)); + return ((mutt_str_strcmp(val, "inline") == 0) || + (mutt_str_strcmp(val, "info") == 0) || !val || (*val == 0)); } char **mutt_envlist(void) @@ -2339,8 +2339,8 @@ static void restart_debug(void) bool disable_debug = (debuglevel > 0 && DebugLevel == 0); bool enable_debug = (debuglevel == 0 && DebugLevel > 0); bool file_changed = - ((mutt_strlen(debugfilename) - 1) != mutt_strlen(DebugFile) || - mutt_strncmp(debugfilename, DebugFile, mutt_strlen(debugfilename) - 1)); + ((mutt_str_strlen(debugfilename) - 1) != mutt_str_strlen(DebugFile) || + mutt_str_strncmp(debugfilename, DebugFile, mutt_str_strlen(debugfilename) - 1)); if (disable_debug || file_changed) { @@ -2372,13 +2372,13 @@ void mutt_envlist_set(const char *name, const char *value, bool overwrite) char work[LONG_STRING]; int count, len; - len = mutt_strlen(name); + len = mutt_str_strlen(name); /* Look for current slot to overwrite */ count = 0; while (envp && *envp) { - if ((mutt_strncmp(name, *envp, len) == 0) && (*envp)[len] == '=') + if ((mutt_str_strncmp(name, *envp, len) == 0) && (*envp)[len] == '=') { if (!overwrite) return; @@ -2399,7 +2399,7 @@ void mutt_envlist_set(const char *name, const char *value, bool overwrite) else { mutt_mem_realloc(&envlist, sizeof(char *) * (count + 2)); - envlist[count] = safe_strdup(work); + envlist[count] = mutt_str_strdup(work); envlist[count + 1] = NULL; } } @@ -2416,7 +2416,7 @@ static int parse_setenv(struct Buffer *tmp, struct Buffer *s, if (!MoreArgs(s)) { - strfcpy(err->data, _("too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too few arguments"), err->dsize); return -1; } @@ -2435,7 +2435,7 @@ static int parse_setenv(struct Buffer *tmp, struct Buffer *s, int found = 0; while (envp && *envp) { - if (mutt_strncmp(tmp->data, *envp, len) == 0) + if (mutt_str_strncmp(tmp->data, *envp, len) == 0) { if (!found) { @@ -2462,7 +2462,7 @@ static int parse_setenv(struct Buffer *tmp, struct Buffer *s, count = 0; while (envp && *envp) { - if ((mutt_strncmp(tmp->data, *envp, len) == 0) && (*envp)[len] == '=') + if ((mutt_str_strncmp(tmp->data, *envp, len) == 0) && (*envp)[len] == '=') { /* shuffle down */ save = envp++; @@ -2491,11 +2491,11 @@ static int parse_setenv(struct Buffer *tmp, struct Buffer *s, if (!MoreArgs(s)) { - strfcpy(err->data, _("too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too few arguments"), err->dsize); return -1; } - name = safe_strdup(tmp->data); + name = mutt_str_strdup(tmp->data); mutt_extract_token(tmp, s, 0); mutt_envlist_set(name, tmp->data, true); FREE(&name); @@ -2526,12 +2526,12 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, query = 1; s->dptr++; } - else if (mutt_strncmp("no", s->dptr, 2) == 0) + else if (mutt_str_strncmp("no", s->dptr, 2) == 0) { s->dptr += 2; unset = !unset; } - else if (mutt_strncmp("inv", s->dptr, 3) == 0) + else if (mutt_str_strncmp("inv", s->dptr, 3) == 0) { s->dptr += 3; inv = !inv; @@ -2545,10 +2545,10 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, /* get the variable name */ mutt_extract_token(tmp, s, MUTT_TOKEN_EQUAL); - if (mutt_strncmp("my_", tmp->data, 3) == 0) + if (mutt_str_strncmp("my_", tmp->data, 3) == 0) myvar = tmp->data; else if ((idx = mutt_option_index(tmp->data)) == -1 && - !(reset && (mutt_strcmp("all", tmp->data) == 0))) + !(reset && (mutt_str_strcmp("all", tmp->data) == 0))) { snprintf(err->data, err->dsize, _("%s: unknown variable"), tmp->data); return -1; @@ -2570,7 +2570,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, return -1; } - if (mutt_strcmp("all", tmp->data) == 0) + if (mutt_str_strcmp("all", tmp->data) == 0) { if (CurrentMenu == MENU_PAGER) { @@ -2609,9 +2609,9 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, s->dptr++; mutt_extract_token(tmp, s, 0); - if (mutt_strcasecmp("yes", tmp->data) == 0) + if (mutt_str_strcasecmp("yes", tmp->data) == 0) unset = inv = 0; - else if (mutt_strcasecmp("no", tmp->data) == 0) + else if (mutt_str_strcasecmp("no", tmp->data) == 0) unset = 1; else { @@ -2683,7 +2683,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, else if (DTYPE(MuttVars[idx].type) == DT_PATH) { _tmp[0] = '\0'; - strfcpy(_tmp, NONULL(*((char **) MuttVars[idx].data)), sizeof(_tmp)); + mutt_str_strfcpy(_tmp, NONULL(*((char **) MuttVars[idx].data)), sizeof(_tmp)); mutt_pretty_mailbox(_tmp, sizeof(_tmp)); val = _tmp; } @@ -2707,7 +2707,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, if (myvar) { /* myvar is a pointer to tmp and will be lost on extract_token */ - myvar = safe_strdup(myvar); + myvar = mutt_str_strdup(myvar); myvar_del(myvar); } @@ -2722,7 +2722,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, else if (DTYPE(MuttVars[idx].type) == DT_PATH) { #ifdef DEBUG - if (mutt_strcmp(MuttVars[idx].option, "debug_file") == 0 && debugfile_cmdline) + if (mutt_str_strcmp(MuttVars[idx].option, "debug_file") == 0 && debugfile_cmdline) { mutt_message(_("set debug_file ignored, it have been overridden " "with cmdline")); @@ -2733,11 +2733,11 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, * so cast to 'void*' is okay */ FREE((void *) MuttVars[idx].data); - strfcpy(scratch, tmp->data, sizeof(scratch)); + mutt_str_strfcpy(scratch, tmp->data, sizeof(scratch)); mutt_expand_path(scratch, sizeof(scratch)); - *((char **) MuttVars[idx].data) = safe_strdup(scratch); + *((char **) MuttVars[idx].data) = mutt_str_strdup(scratch); #ifdef DEBUG - if (mutt_strcmp(MuttVars[idx].option, "debug_file") == 0) + if (mutt_str_strcmp(MuttVars[idx].option, "debug_file") == 0) restart_debug(); #endif } @@ -2755,12 +2755,12 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, } FREE((void *) MuttVars[idx].data); - *((char **) MuttVars[idx].data) = safe_strdup(tmp->data); - if (mutt_strcmp(MuttVars[idx].option, "charset") == 0) + *((char **) MuttVars[idx].data) = mutt_str_strdup(tmp->data); + if (mutt_str_strcmp(MuttVars[idx].option, "charset") == 0) mutt_set_charset(Charset); - if ((mutt_strcmp(MuttVars[idx].option, - "show_multipart_alternative") == 0) && + if ((mutt_str_strcmp(MuttVars[idx].option, + "show_multipart_alternative") == 0) && !valid_show_multipart_alternative(tmp->data)) { snprintf(err->data, err->dsize, @@ -2793,7 +2793,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, } if (option(OPT_ATTACH_MSG) && - (mutt_strcmp(MuttVars[idx].option, "reply_regexp") == 0)) + (mutt_str_strcmp(MuttVars[idx].option, "reply_regexp") == 0)) { snprintf(err->data, err->dsize, "Operation not permitted when in attach-message mode."); @@ -2810,7 +2810,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, if (parse_regex(idx, tmp, err)) /* $reply_regexp and $alternates require special treatment */ if (Context && Context->msgcount && - (mutt_strcmp(MuttVars[idx].option, "reply_regexp") == 0)) + (mutt_str_strcmp(MuttVars[idx].option, "reply_regexp") == 0)) { regmatch_t pmatch[1]; @@ -2874,7 +2874,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, { val = *ptr; /* compatibility alias */ - if (mutt_strcmp(MuttVars[idx].option, "wrapmargin") == 0) + if (mutt_str_strcmp(MuttVars[idx].option, "wrapmargin") == 0) val = *ptr < 0 ? -*ptr : 0; /* user requested the value of this variable */ @@ -2886,7 +2886,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, s->dptr++; mutt_extract_token(tmp, s, 0); - rc = mutt_atos(tmp->data, (short *) &val); + rc = mutt_str_atos(tmp->data, (short *) &val); if (rc < 0 || !*tmp->data) { @@ -2896,7 +2896,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, break; } #ifdef DEBUG - else if (mutt_strcmp(MuttVars[idx].option, "debug_level") == 0 && debuglevel_cmdline) + else if (mutt_str_strcmp(MuttVars[idx].option, "debug_level") == 0 && debuglevel_cmdline) { mutt_message( _("set debug_level ignored, it have been overridden with cmdline")); @@ -2907,26 +2907,26 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, *ptr = val; /* these ones need a sanity check */ - if (mutt_strcmp(MuttVars[idx].option, "history") == 0) + if (mutt_str_strcmp(MuttVars[idx].option, "history") == 0) { if (*ptr < 0) *ptr = 0; mutt_init_history(); } #ifdef DEBUG - else if (mutt_strcmp(MuttVars[idx].option, "debug_level") == 0) + else if (mutt_str_strcmp(MuttVars[idx].option, "debug_level") == 0) { if (*ptr < 0) *ptr = 0; restart_debug(); } #endif - else if (mutt_strcmp(MuttVars[idx].option, "pager_index_lines") == 0) + else if (mutt_str_strcmp(MuttVars[idx].option, "pager_index_lines") == 0) { if (*ptr < 0) *ptr = 0; } - else if (mutt_strcmp(MuttVars[idx].option, "wrapmargin") == 0) + else if (mutt_str_strcmp(MuttVars[idx].option, "wrapmargin") == 0) { if (*ptr < 0) *ptr = 0; @@ -2934,7 +2934,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, *ptr = -*ptr; } #ifdef USE_IMAP - else if (mutt_strcmp(MuttVars[idx].option, "imap_pipeline_depth") == 0) + else if (mutt_str_strcmp(MuttVars[idx].option, "imap_pipeline_depth") == 0) { if (*ptr < 0) *ptr = 0; @@ -2957,13 +2957,13 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, { s->dptr++; mutt_extract_token(tmp, s, 0); - if (mutt_strcasecmp("yes", tmp->data) == 0) + if (mutt_str_strcasecmp("yes", tmp->data) == 0) set_quadoption(MuttVars[idx].data, MUTT_YES); - else if (mutt_strcasecmp("no", tmp->data) == 0) + else if (mutt_str_strcasecmp("no", tmp->data) == 0) set_quadoption(MuttVars[idx].data, MUTT_NO); - else if (mutt_strcasecmp("ask-yes", tmp->data) == 0) + else if (mutt_str_strcasecmp("ask-yes", tmp->data) == 0) set_quadoption(MuttVars[idx].data, MUTT_ASKYES); - else if (mutt_strcasecmp("ask-no", tmp->data) == 0) + else if (mutt_str_strcasecmp("ask-no", tmp->data) == 0) set_quadoption(MuttVars[idx].data, MUTT_ASKNO); else { @@ -3053,7 +3053,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data, if (mutt_hcache_is_valid_backend(tmp->data)) { FREE((void *) MuttVars[idx].data); - *(char **) (MuttVars[idx].data) = safe_strdup(tmp->data); + *(char **) (MuttVars[idx].data) = mutt_str_strdup(tmp->data); } else { @@ -3128,9 +3128,9 @@ static int source_rc(const char *rcfile_path, struct Buffer *err) pid_t pid; - strfcpy(rcfile, rcfile_path, PATH_MAX); + mutt_str_strfcpy(rcfile, rcfile_path, PATH_MAX); - rcfilelen = mutt_strlen(rcfile); + rcfilelen = mutt_str_strlen(rcfile); if (rcfilelen == 0) return -1; @@ -3147,14 +3147,14 @@ static int source_rc(const char *rcfile_path, struct Buffer *err) STAILQ_FOREACH(np, &MuttrcStack, entries) { - if (mutt_strcmp(np->data, rcfile) == 0) + if (mutt_str_strcmp(np->data, rcfile) == 0) { break; } } if (!np) { - mutt_list_insert_head(&MuttrcStack, safe_strdup(rcfile)); + mutt_list_insert_head(&MuttrcStack, mutt_str_strdup(rcfile)); } else { @@ -3178,7 +3178,7 @@ static int source_rc(const char *rcfile_path, struct Buffer *err) conv = ConfigCharset && (*ConfigCharset) && Charset; if (conv) { - currentline = safe_strdup(linebuf); + currentline = mutt_str_strdup(linebuf); if (!currentline) continue; mutt_convert_string(¤tline, ConfigCharset, Charset, 0); @@ -3262,7 +3262,7 @@ static int parse_source(struct Buffer *tmp, struct Buffer *token, snprintf(err->data, err->dsize, _("source: error at %s"), token->dptr); return -1; } - strfcpy(path, tmp->data, sizeof(path)); + mutt_str_strfcpy(path, tmp->data, sizeof(path)); mutt_expand_path(path, sizeof(path)); if (source_rc(path, err) < 0) @@ -3298,7 +3298,7 @@ int mutt_parse_rc_line(/* const */ char *line, struct Buffer *token, struct Buff mutt_buffer_init(&expn); expn.data = expn.dptr = line; - expn.dsize = mutt_strlen(line); + expn.dsize = mutt_str_strlen(line); *err->data = 0; @@ -3315,7 +3315,7 @@ int mutt_parse_rc_line(/* const */ char *line, struct Buffer *token, struct Buff mutt_extract_token(token, &expn, 0); for (i = 0; Commands[i].name; i++) { - if (mutt_strcmp(token->data, Commands[i].name) == 0) + if (mutt_str_strcmp(token->data, Commands[i].name) == 0) { r = Commands[i].func(token, &expn, Commands[i].data, err); if (r != 0) @@ -3386,7 +3386,7 @@ static void candidate(char *dest, char *try, const char *src, int len) matches_ensure_morespace(Num_matched); Matches[Num_matched++] = src; if (dest[0] == 0) - strfcpy(dest, src, len); + mutt_str_strfcpy(dest, src, len); else { int l; @@ -3401,7 +3401,7 @@ static void candidate(char *dest, char *try, const char *src, int len) const struct Command *mutt_command_get(const char *s) { for (int i = 0; Commands[i].name; i++) - if (mutt_strcmp(s, Commands[i].name) == 0) + if (mutt_str_strcmp(s, Commands[i].name) == 0) return &Commands[i]; return NULL; } @@ -3433,7 +3433,7 @@ int mutt_command_complete(char *buffer, size_t len, int pos, int numtabs) if (numtabs == 1) { Num_matched = 0; - strfcpy(User_typed, pt, sizeof(User_typed)); + mutt_str_strfcpy(User_typed, pt, sizeof(User_typed)); memset(Matches, 0, Matches_listsize); memset(Completed, 0, sizeof(Completed)); for (num = 0; Commands[num].name; num++) @@ -3461,22 +3461,22 @@ int mutt_command_complete(char *buffer, size_t len, int pos, int numtabs) /* return the completed command */ strncpy(buffer, Completed, len - spaces); } - else if ((mutt_strncmp(buffer, "set", 3) == 0) || - (mutt_strncmp(buffer, "unset", 5) == 0) || - (mutt_strncmp(buffer, "reset", 5) == 0) || - (mutt_strncmp(buffer, "toggle", 6) == 0)) + else if ((mutt_str_strncmp(buffer, "set", 3) == 0) || + (mutt_str_strncmp(buffer, "unset", 5) == 0) || + (mutt_str_strncmp(buffer, "reset", 5) == 0) || + (mutt_str_strncmp(buffer, "toggle", 6) == 0)) { /* complete variables */ static const char *const prefixes[] = { "no", "inv", "?", "&", 0 }; pt++; /* loop through all the possible prefixes (no, inv, ...) */ - if (mutt_strncmp(buffer, "set", 3) == 0) + if (mutt_str_strncmp(buffer, "set", 3) == 0) { for (num = 0; prefixes[num]; num++) { - if (mutt_strncmp(pt, prefixes[num], mutt_strlen(prefixes[num])) == 0) + if (mutt_str_strncmp(pt, prefixes[num], mutt_str_strlen(prefixes[num])) == 0) { - pt += mutt_strlen(prefixes[num]); + pt += mutt_str_strlen(prefixes[num]); break; } } @@ -3486,7 +3486,7 @@ int mutt_command_complete(char *buffer, size_t len, int pos, int numtabs) if (numtabs == 1) { Num_matched = 0; - strfcpy(User_typed, pt, sizeof(User_typed)); + mutt_str_strfcpy(User_typed, pt, sizeof(User_typed)); memset(Matches, 0, Matches_listsize); memset(Completed, 0, sizeof(Completed)); for (num = 0; MuttVars[num].option; num++) @@ -3515,7 +3515,7 @@ int mutt_command_complete(char *buffer, size_t len, int pos, int numtabs) strncpy(pt, Completed, buffer + len - pt - spaces); } - else if (mutt_strncmp(buffer, "exec", 4) == 0) + else if (mutt_str_strncmp(buffer, "exec", 4) == 0) { const struct Binding *menu = km_get_table(CurrentMenu); @@ -3527,7 +3527,7 @@ int mutt_command_complete(char *buffer, size_t len, int pos, int numtabs) if (numtabs == 1) { Num_matched = 0; - strfcpy(User_typed, pt, sizeof(User_typed)); + mutt_str_strfcpy(User_typed, pt, sizeof(User_typed)); memset(Matches, 0, Matches_listsize); memset(Completed, 0, sizeof(Completed)); for (num = 0; menu[num].name; num++) @@ -3585,15 +3585,15 @@ int mutt_var_value_complete(char *buffer, size_t len, int pos) if (*pt == '=') /* abort if no var before the '=' */ return 0; - if (mutt_strncmp(buffer, "set", 3) == 0) + if (mutt_str_strncmp(buffer, "set", 3) == 0) { int idx; char val[LONG_STRING]; const char *myvarval = NULL; - strfcpy(var, pt, sizeof(var)); + mutt_str_strfcpy(var, pt, sizeof(var)); /* ignore the trailing '=' when comparing */ - int vlen = mutt_strlen(var); + int vlen = mutt_str_strlen(var); if (vlen == 0) return 0; @@ -3629,7 +3629,7 @@ static int complete_all_nm_tags(const char *pt) int tag_count_2 = 0; Num_matched = 0; - strfcpy(User_typed, pt, sizeof(User_typed)); + mutt_str_strfcpy(User_typed, pt, sizeof(User_typed)); memset(Matches, 0, Matches_listsize); memset(Completed, 0, sizeof(Completed)); @@ -3686,7 +3686,7 @@ bool mutt_nm_query_complete(char *buffer, size_t len, int pos, int numtabs) SKIPWS(buffer); spaces = buffer - pt; - pt = (char *) rstrnstr((char *) buffer, pos, "tag:"); + pt = (char *) mutt_str_rstrnstr((char *) buffer, pos, "tag:"); if (pt) { pt += 4; @@ -3783,27 +3783,27 @@ int var_to_string(int idx, char *val, size_t len) if ((DTYPE(MuttVars[idx].type) == DT_STRING) || (DTYPE(MuttVars[idx].type) == DT_PATH) || (DTYPE(MuttVars[idx].type) == DT_REGEX)) { - strfcpy(tmp, NONULL(*((char **) MuttVars[idx].data)), sizeof(tmp)); + mutt_str_strfcpy(tmp, NONULL(*((char **) MuttVars[idx].data)), sizeof(tmp)); if (DTYPE(MuttVars[idx].type) == DT_PATH) mutt_pretty_mailbox(tmp, sizeof(tmp)); } else if (DTYPE(MuttVars[idx].type) == DT_MBTABLE) { struct MbTable *mbt = (*((struct MbTable **) MuttVars[idx].data)); - strfcpy(tmp, mbt ? NONULL(mbt->orig_str) : "", sizeof(tmp)); + mutt_str_strfcpy(tmp, mbt ? NONULL(mbt->orig_str) : "", sizeof(tmp)); } else if (DTYPE(MuttVars[idx].type) == DT_ADDRESS) { rfc822_write_address(tmp, sizeof(tmp), *((struct Address **) MuttVars[idx].data), 0); } else if (DTYPE(MuttVars[idx].type) == DT_QUAD) - strfcpy(tmp, vals[quadoption(MuttVars[idx].data)], sizeof(tmp)); + mutt_str_strfcpy(tmp, vals[quadoption(MuttVars[idx].data)], sizeof(tmp)); else if (DTYPE(MuttVars[idx].type) == DT_NUMBER) { short sval = *((short *) MuttVars[idx].data); /* avert your eyes, gentle reader */ - if (mutt_strcmp(MuttVars[idx].option, "wrapmargin") == 0) + if (mutt_str_strcmp(MuttVars[idx].option, "wrapmargin") == 0) sval = sval > 0 ? 0 : -sval; snprintf(tmp, sizeof(tmp), "%d", sval); @@ -3857,10 +3857,10 @@ int var_to_string(int idx, char *val, size_t len) default: p = "unknown"; } - strfcpy(tmp, p, sizeof(tmp)); + mutt_str_strfcpy(tmp, p, sizeof(tmp)); } else if (DTYPE(MuttVars[idx].type) == DT_BOOL) - strfcpy(tmp, option(MuttVars[idx].data) ? "yes" : "no", sizeof(tmp)); + mutt_str_strfcpy(tmp, option(MuttVars[idx].data) ? "yes" : "no", sizeof(tmp)); else return 0; @@ -4001,7 +4001,7 @@ static char *find_cfg(const char *home, const char *xdg_cfg_home) snprintf(buffer, sizeof(buffer), "%s/%s%s", locations[i][0], locations[i][1], names[j]); if (access(buffer, F_OK) == 0) - return safe_strdup(buffer); + return mutt_str_strdup(buffer); } } @@ -4036,19 +4036,19 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) /* on one of the systems I use, getcwd() does not return the same prefix as is listed in the passwd file */ if ((p = getenv("HOME"))) - HomeDir = safe_strdup(p); + HomeDir = mutt_str_strdup(p); /* Get some information about the user */ if ((pw = getpwuid(getuid()))) { char rnbuf[STRING]; - Username = safe_strdup(pw->pw_name); + Username = mutt_str_strdup(pw->pw_name); if (!HomeDir) - HomeDir = safe_strdup(pw->pw_dir); + HomeDir = mutt_str_strdup(pw->pw_dir); - RealName = safe_strdup(mutt_gecos_name(rnbuf, sizeof(rnbuf), pw)); - Shell = safe_strdup(pw->pw_shell); + RealName = mutt_str_strdup(mutt_gecos_name(rnbuf, sizeof(rnbuf), pw)); + Shell = mutt_str_strdup(pw->pw_shell); endpwent(); } else @@ -4060,14 +4060,14 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) exit(1); } if ((p = getenv("USER"))) - Username = safe_strdup(p); + Username = mutt_str_strdup(p); else { mutt_endwin(NULL); fputs(_("unable to determine username"), stderr); exit(1); } - Shell = safe_strdup((p = getenv("SHELL")) ? p : "/bin/sh"); + Shell = mutt_str_strdup((p = getenv("SHELL")) ? p : "/bin/sh"); } #ifdef DEBUG @@ -4077,13 +4077,13 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) debuglevel = debuglevel_cmdline; if (debugfile_cmdline) { - DebugFile = safe_strdup(debugfile_cmdline); + DebugFile = mutt_str_strdup(debugfile_cmdline); } else { int i = mutt_option_index("debug_file"); if ((i >= 0) && (MuttVars[i].init != 0)) - DebugFile = safe_strdup((const char *) MuttVars[i].init); + DebugFile = mutt_str_strdup((const char *) MuttVars[i].init); } start_debug(); } @@ -4105,19 +4105,20 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) /* some systems report the FQDN instead of just the hostname */ if ((p = strchr(utsname.nodename, '.'))) - ShortHostname = mutt_substrdup(utsname.nodename, p); + ShortHostname = mutt_str_substr_dup(utsname.nodename, p); else - ShortHostname = safe_strdup(utsname.nodename); + ShortHostname = mutt_str_strdup(utsname.nodename); /* now get FQDN. Use configured domain first, DNS next, then uname */ #ifdef DOMAIN /* we have a compile-time domain name, use that for Hostname */ - Hostname = mutt_mem_malloc(mutt_strlen(DOMAIN) + mutt_strlen(ShortHostname) + 2); + Hostname = mutt_mem_malloc(mutt_str_strlen(DOMAIN) + mutt_str_strlen(ShortHostname) + 2); sprintf(Hostname, "%s.%s", NONULL(ShortHostname), DOMAIN); #else if (!(getdnsdomainname(buffer, sizeof(buffer)))) { - Hostname = mutt_mem_malloc(mutt_strlen(buffer) + mutt_strlen(ShortHostname) + 2); + Hostname = + mutt_mem_malloc(mutt_str_strlen(buffer) + mutt_str_strlen(ShortHostname) + 2); sprintf(Hostname, "%s.%s", NONULL(ShortHostname), buffer); } else @@ -4130,26 +4131,26 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) * user to provide the correct hostname if the nodename won't work in their * network. */ - Hostname = safe_strdup(utsname.nodename); + Hostname = mutt_str_strdup(utsname.nodename); #endif #ifdef USE_NNTP if ((p = getenv("NNTPSERVER"))) { FREE(&NewsServer); - NewsServer = safe_strdup(p); + NewsServer = mutt_str_strdup(p); } else { p = mutt_file_read_keyword(SYSCONFDIR "/nntpserver", buffer, sizeof(buffer)); - NewsServer = safe_strdup(p); + NewsServer = mutt_str_strdup(p); } #endif if ((p = getenv("MAIL"))) - SpoolFile = safe_strdup(p); + SpoolFile = mutt_str_strdup(p); else if ((p = getenv("MAILDIR"))) - SpoolFile = safe_strdup(p); + SpoolFile = mutt_str_strdup(p); else { #ifdef HOMESPOOL @@ -4157,20 +4158,20 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) #else mutt_file_concat_path(buffer, MAILPATH, NONULL(Username), sizeof(buffer)); #endif - SpoolFile = safe_strdup(buffer); + SpoolFile = mutt_str_strdup(buffer); } if ((p = getenv("MAILCAPS"))) - MailcapPath = safe_strdup(p); + MailcapPath = mutt_str_strdup(p); else { /* Default search path from RFC1524 */ - MailcapPath = safe_strdup( + MailcapPath = mutt_str_strdup( "~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap"); } - Tmpdir = safe_strdup((p = getenv("TMPDIR")) ? p : "/tmp"); + Tmpdir = mutt_str_strdup((p = getenv("TMPDIR")) ? p : "/tmp"); p = getenv("VISUAL"); if (!p) @@ -4179,8 +4180,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) if (!p) p = "vi"; } - Editor = safe_strdup(p); - Visual = safe_strdup(p); + Editor = mutt_str_strdup(p); + Visual = mutt_str_strdup(p); p = getenv("REPLYTO"); if (p) @@ -4191,7 +4192,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) mutt_buffer_init(&buf); buf.data = buf.dptr = buffer; - buf.dsize = mutt_strlen(buffer); + buf.dsize = mutt_str_strlen(buffer); mutt_buffer_init(&token); parse_my_hdr(&token, &buf, 0, &err); @@ -4267,10 +4268,10 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) struct ListNode *np; STAILQ_FOREACH(np, &Muttrc, entries) { - strfcpy(buffer, np->data, sizeof(buffer)); + mutt_str_strfcpy(buffer, np->data, sizeof(buffer)); FREE(&np->data); mutt_expand_path(buffer, sizeof(buffer)); - np->data = safe_strdup(buffer); + np->data = mutt_str_strdup(buffer); if (access(np->data, F_OK)) { snprintf(buffer, sizeof(buffer), "%s: %s", np->data, strerror(errno)); @@ -4283,7 +4284,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) if (!STAILQ_EMPTY(&Muttrc)) { FREE(&AliasFile); - AliasFile = safe_strdup(STAILQ_FIRST(&Muttrc)->data); + AliasFile = mutt_str_strdup(STAILQ_FIRST(&Muttrc)->data); } /* Process the global rc file if it exists and the user hasn't explicitly @@ -4372,7 +4373,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) int mutt_get_hook_type(const char *name) { for (const struct Command *c = Commands; c->name; c++) - if (c->func == mutt_parse_hook && (mutt_strcasecmp(c->name, name) == 0)) + if (c->func == mutt_parse_hook && (mutt_str_strcasecmp(c->name, name) == 0)) return c->data; return 0; } @@ -4380,11 +4381,11 @@ int mutt_get_hook_type(const char *name) static int parse_group_context(struct GroupContext **ctx, struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err) { - while (mutt_strcasecmp(buf->data, "-group") == 0) + while (mutt_str_strcasecmp(buf->data, "-group") == 0) { if (!MoreArgs(s)) { - strfcpy(err->data, _("-group: no group name"), err->dsize); + mutt_str_strfcpy(err->data, _("-group: no group name"), err->dsize); goto bail; } @@ -4394,7 +4395,7 @@ static int parse_group_context(struct GroupContext **ctx, struct Buffer *buf, if (!MoreArgs(s)) { - strfcpy(err->data, _("out of arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("out of arguments"), err->dsize); goto bail; } @@ -4422,12 +4423,12 @@ static int parse_tag_transforms(struct Buffer *b, struct Buffer *s, mutt_extract_token(b, s, 0); if (b->data && *b->data) - tag = safe_strdup(b->data); + tag = mutt_str_strdup(b->data); else continue; mutt_extract_token(b, s, 0); - transform = safe_strdup(b->data); + transform = mutt_str_strdup(b->data); /* avoid duplicates */ tmp = mutt_hash_find(TagTransforms, tag); @@ -4458,12 +4459,12 @@ static int parse_tag_formats(struct Buffer *b, struct Buffer *s, mutt_extract_token(b, s, 0); if (b->data && *b->data) - tag = safe_strdup(b->data); + tag = mutt_str_strdup(b->data); else continue; mutt_extract_token(b, s, 0); - format = safe_strdup(b->data); + format = mutt_str_strdup(b->data); /* avoid duplicates */ tmp = mutt_hash_find(TagFormats, format); @@ -4597,7 +4598,7 @@ const char *myvar_get(const char *var) struct MyVar *cur = NULL; for (cur = MyVars; cur; cur = cur->next) - if (mutt_strcmp(cur->name, var) == 0) + if (mutt_str_strcmp(cur->name, var) == 0) return NONULL(cur->value); return NULL; @@ -4621,14 +4622,14 @@ int mutt_label_complete(char *buffer, size_t len, int numtabs) struct HashWalkState state; Num_matched = 0; - strfcpy(User_typed, buffer, sizeof(User_typed)); + mutt_str_strfcpy(User_typed, buffer, sizeof(User_typed)); memset(Matches, 0, Matches_listsize); memset(Completed, 0, sizeof(Completed)); memset(&state, 0, sizeof(state)); while ((entry = mutt_hash_walk(Context->label_hash, &state))) candidate(Completed, User_typed, entry->key.strkey, sizeof(Completed)); matches_ensure_morespace(Num_matched); - qsort(Matches, Num_matched, sizeof(char *), (sort_t *) mutt_strcasecmp); + qsort(Matches, Num_matched, sizeof(char *), (sort_t *) mutt_str_strcasecmp); Matches[Num_matched++] = User_typed; /* All matches are stored. Longest non-ambiguous string is "" diff --git a/keymap.c b/keymap.c index 730d3f625..0a55a3ae5 100644 --- a/keymap.c +++ b/keymap.c @@ -190,7 +190,7 @@ static int parsekeys(const char *str, keycode_t *d, int max) char c; char *s = NULL, *t = NULL; - strfcpy(buff, str, sizeof(buff)); + mutt_str_strfcpy(buff, str, sizeof(buff)); s = buff; while (*s && len) @@ -251,8 +251,8 @@ int km_bind_err(char *s, int menu, int op, char *macro, char *descr, struct Buff map = alloc_keys(len, buf); map->op = op; - map->macro = safe_strdup(macro); - map->descr = safe_strdup(descr); + map->macro = mutt_str_strdup(macro); + map->descr = mutt_str_strdup(descr); tmp = Keymaps[menu]; @@ -354,8 +354,8 @@ static int get_op(const struct Binding *bindings, const char *start, size_t len) { for (int i = 0; bindings[i].name; i++) { - if ((mutt_strncasecmp(start, bindings[i].name, len) == 0) && - mutt_strlen(bindings[i].name) == len) + if ((mutt_str_strncasecmp(start, bindings[i].name, len) == 0) && + mutt_str_strlen(bindings[i].name) == len) return bindings[i].op; } @@ -382,7 +382,7 @@ static char *get_func(const struct Binding *bindings, int op) */ static void generic_tokenize_push_string(char *s, void (*generic_push)(int, int)) { - char *pp = NULL, *p = s + mutt_strlen(s) - 1; + char *pp = NULL, *p = s + mutt_str_strlen(s) - 1; size_t l; int i, op = OP_NULL; @@ -407,7 +407,7 @@ static void generic_tokenize_push_string(char *s, void (*generic_push)(int, int) l = p - pp + 1; for (i = 0; KeyNames[i].name; i++) { - if (mutt_strncasecmp(pp, KeyNames[i].name, l) == 0) + if (mutt_str_strncasecmp(pp, KeyNames[i].name, l) == 0) break; } if (KeyNames[i].name) @@ -651,8 +651,8 @@ int km_expand_key(char *s, size_t len, struct Keymap *map) while (true) { - strfcpy(s, km_keyname(map->keys[p]), len); - len -= (l = mutt_strlen(s)); + mutt_str_strfcpy(s, km_keyname(map->keys[p]), len); + len -= (l = mutt_str_strlen(s)); if (++p >= map->len || !len) return 1; @@ -955,7 +955,7 @@ int mutt_parse_push(struct Buffer *buf, struct Buffer *s, unsigned long data, mutt_extract_token(buf, s, MUTT_TOKEN_CONDENSE); if (MoreArgs(s)) { - strfcpy(err->data, _("push: too many arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("push: too many arguments"), err->dsize); r = -1; } else @@ -1005,14 +1005,14 @@ char *parse_keymap(int *menu, struct Buffer *s, int maxmenus, int *nummenus, str if (!*buf.data) { - strfcpy(err->data, _("null key sequence"), err->dsize); + mutt_str_strfcpy(err->data, _("null key sequence"), err->dsize); } else if (MoreArgs(s)) return buf.data; } else { - strfcpy(err->data, _("too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("too few arguments"), err->dsize); } error: FREE(&buf.data); @@ -1024,7 +1024,7 @@ static int try_bind(char *key, int menu, char *func, { for (int i = 0; bindings[i].name; i++) { - if (mutt_strcmp(func, bindings[i].name) == 0) + if (mutt_str_strcmp(func, bindings[i].name) == 0) { return km_bindkey_err(key, menu, bindings[i].op, err); } @@ -1101,10 +1101,10 @@ int mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data, mutt_extract_token(buf, s, 0); if (MoreArgs(s)) { - strfcpy(err->data, _("bind: too many arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("bind: too many arguments"), err->dsize); r = -1; } - else if (mutt_strcasecmp("noop", buf->data) == 0) + else if (mutt_str_strcasecmp("noop", buf->data) == 0) { for (int i = 0; i < nummenus; ++i) { @@ -1159,18 +1159,18 @@ int mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data, /* make sure the macro sequence is not an empty string */ if (!*buf->data) { - strfcpy(err->data, _("macro: empty key sequence"), err->dsize); + mutt_str_strfcpy(err->data, _("macro: empty key sequence"), err->dsize); } else { if (MoreArgs(s)) { - seq = safe_strdup(buf->data); + seq = mutt_str_strdup(buf->data); mutt_extract_token(buf, s, MUTT_TOKEN_CONDENSE); if (MoreArgs(s)) { - strfcpy(err->data, _("macro: too many arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("macro: too many arguments"), err->dsize); } else { @@ -1207,7 +1207,7 @@ int mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data, if (!MoreArgs(s)) { - strfcpy(err->data, _("exec: no arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("exec: no arguments"), err->dsize); return -1; } @@ -1219,9 +1219,9 @@ int mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data, if ((bindings = km_get_table(CurrentMenu)) == NULL && CurrentMenu != MENU_PAGER) bindings = OpGeneric; - ops[nops] = get_op(bindings, function, mutt_strlen(function)); + ops[nops] = get_op(bindings, function, mutt_str_strlen(function)); if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER) - ops[nops] = get_op(OpGeneric, function, mutt_strlen(function)); + ops[nops] = get_op(OpGeneric, function, mutt_str_strlen(function)); if (ops[nops] == OP_NULL) { diff --git a/main.c b/main.c index 75f29027f..5819fe4d4 100644 --- a/main.c +++ b/main.c @@ -250,7 +250,7 @@ int main(int argc, char **argv, char **env) count++; envlist = mutt_mem_calloc(count + 1, sizeof(char *)); for (srcp = env, dstp = envlist; srcp && *srcp; srcp++, dstp++) - *dstp = safe_strdup(*srcp); + *dstp = mutt_str_strdup(*srcp); } for (optind = 1; optind < double_dash;) @@ -271,7 +271,7 @@ int main(int argc, char **argv, char **env) /* non-option, either an attachment or address */ if (!STAILQ_EMPTY(&attach)) - mutt_list_insert_tail(&attach, safe_strdup(argv[optind])); + mutt_list_insert_tail(&attach, mutt_str_strdup(argv[optind])); else argv[nargc++] = argv[optind]; } @@ -282,19 +282,19 @@ int main(int argc, char **argv, char **env) switch (i) { case 'A': - mutt_list_insert_tail(&alias_queries, safe_strdup(optarg)); + mutt_list_insert_tail(&alias_queries, mutt_str_strdup(optarg)); break; case 'a': - mutt_list_insert_tail(&attach, safe_strdup(optarg)); + mutt_list_insert_tail(&attach, mutt_str_strdup(optarg)); break; case 'F': /* mutt_str_replace (&Muttrc, optarg); */ - mutt_list_insert_tail(&Muttrc, safe_strdup(optarg)); + mutt_list_insert_tail(&Muttrc, mutt_str_strdup(optarg)); break; case 'f': - strfcpy(folder, optarg, sizeof(folder)); + mutt_str_strfcpy(folder, optarg, sizeof(folder)); explicit_folder = true; break; @@ -320,7 +320,7 @@ int main(int argc, char **argv, char **env) case 'd': #ifdef DEBUG - if (mutt_atoi(optarg, &debuglevel_cmdline) < 0 || debuglevel_cmdline <= 0) + if (mutt_str_atoi(optarg, &debuglevel_cmdline) < 0 || debuglevel_cmdline <= 0) { fprintf(stderr, _("Error: value '%s' is invalid for -d.\n"), optarg); return 1; @@ -337,7 +337,7 @@ int main(int argc, char **argv, char **env) break; case 'e': - mutt_list_insert_tail(&commands, safe_strdup(optarg)); + mutt_list_insert_tail(&commands, mutt_str_strdup(optarg)); break; case 'H': @@ -371,7 +371,7 @@ int main(int argc, char **argv, char **env) break; case 'Q': - mutt_list_insert_tail(&queries, safe_strdup(optarg)); + mutt_list_insert_tail(&queries, mutt_str_strdup(optarg)); break; case 'R': @@ -404,7 +404,7 @@ int main(int argc, char **argv, char **env) char buf[LONG_STRING]; snprintf(buf, sizeof(buf), "set news_server=%s", optarg); - mutt_list_insert_tail(&commands, safe_strdup(buf)); + mutt_list_insert_tail(&commands, mutt_str_strdup(buf)); } case 'G': /* List of newsgroups */ @@ -478,7 +478,7 @@ int main(int argc, char **argv, char **env) if (!STAILQ_EMPTY(&queries)) { for (; optind < argc; optind++) - mutt_list_insert_tail(&queries, safe_strdup(argv[optind])); + mutt_list_insert_tail(&queries, mutt_str_strdup(argv[optind])); return mutt_query_variables(&queries); } if (dump_variables) @@ -489,7 +489,7 @@ int main(int argc, char **argv, char **env) int rv = 0; struct Address *a = NULL; for (; optind < argc; optind++) - mutt_list_insert_tail(&alias_queries, safe_strdup(argv[optind])); + mutt_list_insert_tail(&alias_queries, mutt_str_strdup(argv[optind])); struct ListNode *np; STAILQ_FOREACH(np, &alias_queries, entries) { @@ -524,7 +524,7 @@ int main(int argc, char **argv, char **env) char fpath[_POSIX_PATH_MAX]; char msg2[STRING]; - strfcpy(fpath, Folder, sizeof(fpath)); + mutt_str_strfcpy(fpath, Folder, sizeof(fpath)); mutt_expand_path(fpath, sizeof(fpath)); bool skip = false; #ifdef USE_IMAP @@ -600,7 +600,7 @@ int main(int argc, char **argv, char **env) } if (subject) - msg->env->subject = safe_strdup(subject); + msg->env->subject = mutt_str_strdup(subject); if (draftFile) { @@ -617,7 +617,7 @@ int main(int argc, char **argv, char **env) /* Prepare fin and expanded_infile. */ if (infile) { - if (mutt_strcmp("-", infile) == 0) + if (mutt_str_strcmp("-", infile) == 0) { if (edit_infile) { @@ -628,7 +628,7 @@ int main(int argc, char **argv, char **env) } else { - strfcpy(expanded_infile, infile, sizeof(expanded_infile)); + mutt_str_strfcpy(expanded_infile, infile, sizeof(expanded_infile)); mutt_expand_path(expanded_infile, sizeof(expanded_infile)); fin = fopen(expanded_infile, "r"); if (!fin) @@ -648,7 +648,7 @@ int main(int argc, char **argv, char **env) if (!edit_infile) { mutt_mktemp(buf, sizeof(buf)); - tempfile = safe_strdup(buf); + tempfile = mutt_str_strdup(buf); fout = mutt_file_fopen(tempfile, "w"); if (!fout) @@ -717,7 +717,7 @@ int main(int argc, char **argv, char **env) struct ListNode *np, *tmp; STAILQ_FOREACH_SAFE(np, &msg->env->userhdrs, entries, tmp) { - if (mutt_strncasecmp("X-Mutt-Resume-Draft:", np->data, 20) == 0) + if (mutt_str_strncasecmp("X-Mutt-Resume-Draft:", np->data, 20) == 0) { if (option(OPT_RESUME_EDITED_DRAFT_FILES)) set_option(OPT_RESUME_DRAFT_FILES); @@ -893,9 +893,9 @@ int main(int argc, char **argv, char **env) if (!folder[0]) { if (SpoolFile) - strfcpy(folder, NONULL(SpoolFile), sizeof(folder)); + mutt_str_strfcpy(folder, NONULL(SpoolFile), sizeof(folder)); else if (Folder) - strfcpy(folder, NONULL(Folder), sizeof(folder)); + mutt_str_strfcpy(folder, NONULL(Folder), sizeof(folder)); /* else no folder */ } diff --git a/mbox.c b/mbox.c index 60cc273f6..18ef95e89 100644 --- a/mbox.c +++ b/mbox.c @@ -135,7 +135,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) if (SigInt == 1) break; - if (mutt_strcmp(buf, MMDF_SEP) == 0) + if (mutt_str_strcmp(buf, MMDF_SEP) == 0) { loc = ftello(ctx->fp); if (loc < 0) @@ -186,7 +186,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) { if (fseeko(ctx->fp, tmploc, SEEK_SET) != 0 || fgets(buf, sizeof(buf) - 1, ctx->fp) == NULL || - (mutt_strcmp(MMDF_SEP, buf) != 0)) + (mutt_str_strcmp(MMDF_SEP, buf) != 0)) { if (fseeko(ctx->fp, loc, SEEK_SET) != 0) mutt_debug(1, "mmdf_parse_mailbox: fseek() failed\n"); @@ -210,7 +210,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) if (fgets(buf, sizeof(buf) - 1, ctx->fp) == NULL) break; lines++; - } while (mutt_strcmp(buf, MMDF_SEP) != 0); + } while (mutt_str_strcmp(buf, MMDF_SEP) != 0); hdr->lines = lines; hdr->content->length = loc - hdr->content->offset; @@ -338,7 +338,7 @@ static int mbox_parse_mailbox(struct Context *ctx) */ if (fseeko(ctx->fp, tmploc, SEEK_SET) != 0 || fgets(buf, sizeof(buf), ctx->fp) == NULL || - (mutt_strncmp("From ", buf, 5) != 0)) + (mutt_str_strncmp("From ", buf, 5) != 0)) { mutt_debug(1, "mbox_parse_mailbox: bad content-length in message " "%d (cl=" OFF_T_FMT ")\n", @@ -563,8 +563,8 @@ static int strict_addrcmp(const struct Address *a, const struct Address *b) { while (a && b) { - if ((mutt_strcmp(a->mailbox, b->mailbox) != 0) || - (mutt_strcmp(a->personal, b->personal) != 0)) + if ((mutt_str_strcmp(a->mailbox, b->mailbox) != 0) || + (mutt_str_strcmp(a->personal, b->personal) != 0)) return 0; a = a->next; @@ -580,8 +580,8 @@ static int strict_cmp_envelopes(const struct Envelope *e1, const struct Envelope { if (e1 && e2) { - if ((mutt_strcmp(e1->message_id, e2->message_id) != 0) || - (mutt_strcmp(e1->subject, e2->subject) != 0) || + if ((mutt_str_strcmp(e1->message_id, e2->message_id) != 0) || + (mutt_str_strcmp(e1->subject, e2->subject) != 0) || !mutt_list_compare(&e1->references, &e2->references) || !strict_addrcmp(e1->from, e2->from) || !strict_addrcmp(e1->sender, e2->sender) || !strict_addrcmp(e1->reply_to, e2->reply_to) || @@ -610,8 +610,8 @@ static int strict_cmp_parameters(const struct Parameter *p1, const struct Parame { while (p1 && p2) { - if ((mutt_strcmp(p1->attribute, p2->attribute) != 0) || - (mutt_strcmp(p1->value, p2->value) != 0)) + if ((mutt_str_strcmp(p1->attribute, p2->attribute) != 0) || + (mutt_str_strcmp(p1->value, p2->value) != 0)) return 0; p1 = p1->next; @@ -626,8 +626,8 @@ static int strict_cmp_parameters(const struct Parameter *p1, const struct Parame static int strict_cmp_bodies(const struct Body *b1, const struct Body *b2) { if (b1->type != b2->type || b1->encoding != b2->encoding || - (mutt_strcmp(b1->subtype, b2->subtype) != 0) || - (mutt_strcmp(b1->description, b2->description) != 0) || + (mutt_str_strcmp(b1->subtype, b2->subtype) != 0) || + (mutt_str_strcmp(b1->description, b2->description) != 0) || !strict_cmp_parameters(b1->parameter, b2->parameter) || b1->length != b2->length) return 0; return 1; @@ -895,8 +895,8 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint) mutt_debug(1, "mbox_check_mailbox: fseek() failed\n"); if (fgets(buffer, sizeof(buffer), ctx->fp) != NULL) { - if ((ctx->magic == MUTT_MBOX && (mutt_strncmp("From ", buffer, 5) == 0)) || - (ctx->magic == MUTT_MMDF && (mutt_strcmp(MMDF_SEP, buffer) == 0))) + if ((ctx->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buffer, 5) == 0)) || + (ctx->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buffer) == 0))) { if (fseeko(ctx->fp, ctx->size, SEEK_SET) != 0) mutt_debug(1, "mbox_check_mailbox: fseek() failed\n"); @@ -1235,8 +1235,8 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint) if (fseeko(ctx->fp, offset, SEEK_SET) != 0 || /* seek the append location */ /* do a sanity check to make sure the mailbox looks ok */ fgets(buf, sizeof(buf), ctx->fp) == NULL || - (ctx->magic == MUTT_MBOX && (mutt_strncmp("From ", buf, 5) != 0)) || - (ctx->magic == MUTT_MMDF && (mutt_strcmp(MMDF_SEP, buf) != 0))) + (ctx->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buf, 5) != 0)) || + (ctx->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buf) != 0))) { mutt_debug(1, "mbox_sync_mailbox: message not in expected position.\n"); mutt_debug(1, "\tLINE: %s\n", buf); diff --git a/menu.c b/menu.c index 45bc0316f..ad614eb5c 100644 --- a/menu.c +++ b/menu.c @@ -100,7 +100,7 @@ static void print_enriched_string(int index, int attr, unsigned char *s, int do_ { wchar_t wc; size_t k; - size_t n = mutt_strlen((char *) s); + size_t n = mutt_str_strlen((char *) s); mbstate_t mbstate; memset(&mbstate, 0, sizeof(mbstate)); @@ -286,11 +286,11 @@ static void menu_make_entry(char *s, int l, struct Menu *menu, int i) static void menu_pad_string(struct Menu *menu, char *s, size_t n) { - char *scratch = safe_strdup(s); + char *scratch = mutt_str_strdup(s); int shift = option(OPT_ARROW_CURSOR) ? 3 : 0; int cols = menu->indexwin->cols - shift; - mutt_simple_format(s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen(scratch), 1); + mutt_simple_format(s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_str_strlen(scratch), 1); s[n - 1] = '\0'; FREE(&scratch); } @@ -539,7 +539,7 @@ static void menu_jump(struct Menu *menu) buf[0] = '\0'; if (mutt_get_field(_("Jump to: "), buf, sizeof(buf), 0) == 0 && buf[0]) { - if (mutt_atoi(buf, &n) == 0 && n > 0 && n < menu->max + 1) + if (mutt_str_atoi(buf, &n) == 0 && n > 0 && n < menu->max + 1) { n--; /* msg numbers are 0-based */ menu->current = n; @@ -934,7 +934,7 @@ static int menu_search(struct Menu *menu, int op) if (!(searchBuf && *searchBuf) || (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)) { - strfcpy(buf, searchBuf && *searchBuf ? searchBuf : "", sizeof(buf)); + mutt_str_strfcpy(buf, searchBuf && *searchBuf ? searchBuf : "", sizeof(buf)); if (mutt_get_field((op == OP_SEARCH || op == OP_SEARCH_NEXT) ? _("Search for: ") : _("Reverse search for: "), diff --git a/mh.c b/mh.c index 3285159bd..33c3bca8c 100644 --- a/mh.c +++ b/mh.c @@ -152,12 +152,12 @@ static int mh_read_token(char *t, int *first, int *last) if ((p = strchr(t, '-'))) { *p++ = '\0'; - if (mutt_atoi(t, first) < 0 || mutt_atoi(p, last) < 0) + if (mutt_str_atoi(t, first) < 0 || mutt_str_atoi(p, last) < 0) return -1; } else { - if (mutt_atoi(t, first) < 0) + if (mutt_str_atoi(t, first) < 0) return -1; *last = *first; } @@ -188,11 +188,11 @@ static int mh_read_sequences(struct MhSequences *mhs, const char *path) if (!t) continue; - if (mutt_strcmp(t, MhSeqUnseen) == 0) + if (mutt_str_strcmp(t, MhSeqUnseen) == 0) f = MH_SEQ_UNSEEN; - else if (mutt_strcmp(t, MhSeqFlagged) == 0) + else if (mutt_str_strcmp(t, MhSeqFlagged) == 0) f = MH_SEQ_FLAGGED; - else if (mutt_strcmp(t, MhSeqReplied) == 0) + else if (mutt_str_strcmp(t, MhSeqReplied) == 0) f = MH_SEQ_REPLIED; else /* unknown sequence */ continue; @@ -398,7 +398,7 @@ static int mh_mkstemp(struct Context *dest, FILE **fp, char **tgt) } else { - *tgt = safe_strdup(path); + *tgt = mutt_str_strdup(path); break; } } @@ -502,11 +502,11 @@ static void mh_update_sequences(struct Context *ctx) { while ((buff = mutt_file_read_line(buff, &s, ofp, &l, 0))) { - if (mutt_strncmp(buff, seq_unseen, mutt_strlen(seq_unseen)) == 0) + if (mutt_str_strncmp(buff, seq_unseen, mutt_str_strlen(seq_unseen)) == 0) continue; - if (mutt_strncmp(buff, seq_flagged, mutt_strlen(seq_flagged)) == 0) + if (mutt_str_strncmp(buff, seq_flagged, mutt_str_strlen(seq_flagged)) == 0) continue; - if (mutt_strncmp(buff, seq_replied, mutt_strlen(seq_replied)) == 0) + if (mutt_str_strncmp(buff, seq_replied, mutt_str_strlen(seq_replied)) == 0) continue; fprintf(nfp, "%s\n", buff); @@ -525,7 +525,7 @@ static void mh_update_sequences(struct Context *ctx) else p = ctx->hdrs[l]->path; - if (mutt_atoi(p, &i) < 0) + if (mutt_str_atoi(p, &i) < 0) continue; if (!ctx->hdrs[l]->read) @@ -600,17 +600,17 @@ static void mh_sequences_add_one(struct Context *ctx, int n, short unseen, { while ((buff = mutt_file_read_line(buff, &sz, ofp, &line, 0))) { - if (unseen && (strncmp(buff, seq_unseen, mutt_strlen(seq_unseen)) == 0)) + if (unseen && (strncmp(buff, seq_unseen, mutt_str_strlen(seq_unseen)) == 0)) { fprintf(nfp, "%s %d\n", buff, n); unseen_done = 1; } - else if (flagged && (strncmp(buff, seq_flagged, mutt_strlen(seq_flagged)) == 0)) + else if (flagged && (strncmp(buff, seq_flagged, mutt_str_strlen(seq_flagged)) == 0)) { fprintf(nfp, "%s %d\n", buff, n); flagged_done = 1; } - else if (replied && (strncmp(buff, seq_replied, mutt_strlen(seq_replied)) == 0)) + else if (replied && (strncmp(buff, seq_replied, mutt_str_strlen(seq_replied)) == 0)) { fprintf(nfp, "%s %d\n", buff, n); replied_done = 1; @@ -651,7 +651,7 @@ static void mh_update_maildir(struct Maildir *md, struct MhSequences *mhs) else p = md->h->path; - if (mutt_atoi(p, &i) < 0) + if (mutt_str_atoi(p, &i) < 0) continue; f = mhs_check(mhs, i); @@ -698,7 +698,7 @@ void maildir_parse_flags(struct Header *h, const char *path) h->read = false; h->replied = false; - if ((p = strrchr(path, ':')) != NULL && (mutt_strncmp(p + 1, "2,", 2) == 0)) + if ((p = strrchr(path, ':')) != NULL && (mutt_str_strncmp(p + 1, "2,", 2) == 0)) { p += 3; @@ -765,7 +765,7 @@ static void maildir_update_mtime(struct Context *ctx) if (stat(buf, &st) == 0) data->mtime_cur = st.st_mtime; - strfcpy(buf, ctx->path, sizeof(buf)); + mutt_str_strfcpy(buf, ctx->path, sizeof(buf)); } if (stat(buf, &st) == 0) @@ -845,10 +845,10 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last, if (subdir) { snprintf(buf, sizeof(buf), "%s/%s", ctx->path, subdir); - is_old = option(OPT_MARK_OLD) ? (mutt_strcmp("cur", subdir) == 0) : false; + is_old = option(OPT_MARK_OLD) ? (mutt_str_strcmp("cur", subdir) == 0) : false; } else - strfcpy(buf, ctx->path, sizeof(buf)); + mutt_str_strfcpy(buf, ctx->path, sizeof(buf)); dirp = opendir(buf); if (!dirp) @@ -879,10 +879,10 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last, { char tmp[LONG_STRING]; snprintf(tmp, sizeof(tmp), "%s/%s", subdir, de->d_name); - h->path = safe_strdup(tmp); + h->path = mutt_str_strdup(tmp); } else - h->path = safe_strdup(de->d_name); + h->path = mutt_str_strdup(de->d_name); entry = mutt_mem_calloc(1, sizeof(struct Maildir)); entry->h = h; @@ -951,7 +951,7 @@ static int maildir_move_to_context(struct Context *ctx, struct Maildir **md) static size_t maildir_hcache_keylen(const char *fn) { const char *p = strrchr(fn, ':'); - return p ? (size_t)(p - fn) : mutt_strlen(fn); + return p ? (size_t)(p - fn) : mutt_str_strlen(fn); } #endif @@ -1198,7 +1198,7 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md, { struct Header *h = mutt_hcache_restore((unsigned char *) data); h->old = p->h->old; - h->path = safe_strdup(p->h->path); + h->path = mutt_str_strdup(p->h->path); mutt_free_header(&p->h); p->h = h; if (ctx->magic == MUTT_MAILDIR) @@ -1514,9 +1514,9 @@ static int maildir_open_new_message(struct Message *msg, struct Context *dest, *suffix = '\0'; if (hdr && (hdr->read || hdr->old)) - strfcpy(subdir, "cur", sizeof(subdir)); + mutt_str_strfcpy(subdir, "cur", sizeof(subdir)); else - strfcpy(subdir, "new", sizeof(subdir)); + mutt_str_strfcpy(subdir, "new", sizeof(subdir)); omask = umask(mh_umask(dest)); while (true) @@ -1539,7 +1539,7 @@ static int maildir_open_new_message(struct Message *msg, struct Context *dest, else { mutt_debug(2, "maildir_open_new_message (): Success.\n"); - msg->path = safe_strdup(path); + msg->path = mutt_str_strdup(path); break; } } @@ -1592,11 +1592,11 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He /* extract the subdir */ s = strrchr(msg->path, '/') + 1; - strfcpy(subdir, s, 4); + mutt_str_strfcpy(subdir, s, 4); /* extract the flags */ if ((s = strchr(s, ':'))) - strfcpy(suffix, s, sizeof(suffix)); + mutt_str_strfcpy(suffix, s, sizeof(suffix)); else suffix[0] = '\0'; @@ -1771,7 +1771,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno) if (rc == 0) { snprintf(oldpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path); - strfcpy(partpath, h->path, _POSIX_PATH_MAX); + mutt_str_strfcpy(partpath, h->path, _POSIX_PATH_MAX); if (ctx->magic == MUTT_MAILDIR) rc = md_commit_message(ctx, dest, h); @@ -1864,7 +1864,7 @@ static int maildir_sync_message(struct Context *ctx, int msgno) return -1; } p++; - strfcpy(newpath, p, sizeof(newpath)); + mutt_str_strfcpy(newpath, p, sizeof(newpath)); /* kill the previous flags */ p = strchr(newpath, ':'); @@ -1878,7 +1878,7 @@ static int maildir_sync_message(struct Context *ctx, int msgno) snprintf(fullpath, sizeof(fullpath), "%s/%s", ctx->path, partpath); snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->path, h->path); - if (mutt_strcmp(fullpath, oldpath) == 0) + if (mutt_str_strcmp(fullpath, oldpath) == 0) { /* message hasn't really changed */ return 0; @@ -1987,7 +1987,7 @@ static char *maildir_canon_filename(char *dest, const char *src, size_t l) if ((t = strrchr(src, '/'))) src = t + 1; - strfcpy(dest, src, l); + mutt_str_strfcpy(dest, src, l); if ((u = strrchr(dest, ':'))) *u = '\0'; @@ -2095,7 +2095,7 @@ static int maildir_check_mailbox(struct Context *ctx, int *index_hint) for (p = md; p; p = p->next) { maildir_canon_filename(buf, p->h->path, sizeof(buf)); - p->canon_fname = safe_strdup(buf); + p->canon_fname = mutt_str_strdup(buf); mutt_hash_insert(fnames, p->canon_fname, p); } @@ -2113,7 +2113,7 @@ static int maildir_check_mailbox(struct Context *ctx, int *index_hint) /* check to see if the message has moved to a different * subdirectory. If so, update the associated filename. */ - if (mutt_strcmp(ctx->hdrs[i]->path, p->h->path) != 0) + if (mutt_str_strcmp(ctx->hdrs[i]->path, p->h->path) != 0) mutt_str_replace(&ctx->hdrs[i]->path, p->h->path); /* if the user hasn't modified the flags on this message, update @@ -2205,7 +2205,7 @@ static int mh_check_mailbox(struct Context *ctx, int *index_hint) if (!option(OPT_CHECK_NEW)) return 0; - strfcpy(buf, ctx->path, sizeof(buf)); + mutt_str_strfcpy(buf, ctx->path, sizeof(buf)); if (stat(buf, &st) == -1) return -1; @@ -2256,7 +2256,7 @@ static int mh_check_mailbox(struct Context *ctx, int *index_hint) for (p = md; p; p = p->next) { /* the hash key must survive past the header, which is freed below. */ - p->canon_fname = safe_strdup(p->h->path); + p->canon_fname = mutt_str_strdup(p->h->path); mutt_hash_insert(fnames, p->canon_fname, p); } @@ -2447,7 +2447,7 @@ static FILE *md_open_find_message(const char *folder, const char *unique, { maildir_canon_filename(tunique, de->d_name, sizeof(tunique)); - if (mutt_strcmp(tunique, unique) == 0) + if (mutt_str_strcmp(tunique, unique) == 0) { snprintf(fname, sizeof(fname), "%s/%s/%s", folder, subfolder, de->d_name); fp = fopen(fname, "r"); @@ -2459,7 +2459,7 @@ static FILE *md_open_find_message(const char *folder, const char *unique, closedir(dp); if (newname && fp) - *newname = safe_strdup(fname); + *newname = mutt_str_strdup(fname); errno = oe; return fp; diff --git a/mutt/buffer.c b/mutt/buffer.c index f1c724996..0a703dfa0 100644 --- a/mutt/buffer.c +++ b/mutt/buffer.c @@ -103,8 +103,8 @@ struct Buffer *mutt_buffer_from(char *seed) return NULL; b = mutt_buffer_new(); - b->data = safe_strdup(seed); - b->dsize = mutt_strlen(seed); + b->data = mutt_str_strdup(seed); + b->dsize = mutt_str_strlen(seed); b->dptr = (char *) b->data + b->dsize; return b; } @@ -212,7 +212,7 @@ int mutt_buffer_printf(struct Buffer *buf, const char *fmt, ...) */ void mutt_buffer_addstr(struct Buffer *buf, const char *s) { - mutt_buffer_add(buf, s, mutt_strlen(s)); + mutt_buffer_add(buf, s, mutt_str_strlen(s)); } /** diff --git a/mutt/date.c b/mutt/date.c index 665dc7bf8..cce32cebe 100644 --- a/mutt/date.c +++ b/mutt/date.c @@ -198,7 +198,7 @@ static const char *uncomment_timezone(char *buf, size_t buflen, const char *tz) if (*tz != '(') return tz; /* no need to do anything */ - tz = skip_email_wsp(tz + 1); + tz = mutt_str_skip_email_wsp(tz + 1); p = strpbrk(tz, " )"); if (!p) return tz; @@ -413,7 +413,7 @@ char *mutt_date_make_date(char *buf, size_t buflen) int mutt_date_check_month(const char *s) { for (int i = 0; i < 12; i++) - if (mutt_strncasecmp(s, Months[i], 3) == 0) + if (mutt_str_strncasecmp(s, Months[i], 3) == 0) return i; return -1; /* error */ @@ -433,7 +433,7 @@ bool mutt_date_is_day_name(const char *s) return false; for (int i = 0; i < 7; i++) - if (mutt_strncasecmp(s, Weekdays[i], 3) == 0) + if (mutt_str_strncasecmp(s, Weekdays[i], 3) == 0) return true; return false; @@ -469,14 +469,14 @@ time_t mutt_date_parse_date(const char *s, struct Tz *tz_out) * the date format imposes a natural limit. */ - strfcpy(scratch, s, sizeof(scratch)); + mutt_str_strfcpy(scratch, s, sizeof(scratch)); /* kill the day of the week, if it exists. */ if ((t = strchr(scratch, ','))) t++; else t = scratch; - t = skip_email_wsp(t); + t = mutt_str_skip_email_wsp(t); memset(&tm, 0, sizeof(tm)); @@ -485,7 +485,7 @@ time_t mutt_date_parse_date(const char *s, struct Tz *tz_out) switch (count) { case 0: /* day of the month */ - if ((mutt_atoi(t, &tm.tm_mday) < 0) || (tm.tm_mday < 0)) + if ((mutt_str_atoi(t, &tm.tm_mday) < 0) || (tm.tm_mday < 0)) return -1; if (tm.tm_mday > 31) return -1; @@ -499,7 +499,7 @@ time_t mutt_date_parse_date(const char *s, struct Tz *tz_out) break; case 2: /* year */ - if ((mutt_atoi(t, &tm.tm_year) < 0) || (tm.tm_year < 0)) + if ((mutt_str_atoi(t, &tm.tm_year) < 0) || (tm.tm_year < 0)) return -1; if ((tm.tm_year < 0) || (tm.tm_year > 9999)) return -1; @@ -552,7 +552,7 @@ time_t mutt_date_parse_date(const char *s, struct Tz *tz_out) /* This is safe to do: A pointer to a struct equals a pointer to its first element */ tz = bsearch(ptz, TimeZones, sizeof(TimeZones) / sizeof(struct Tz), sizeof(struct Tz), - (int (*)(const void *, const void *)) mutt_strcasecmp); + (int (*)(const void *, const void *)) mutt_str_strcasecmp); if (tz) { @@ -562,12 +562,12 @@ time_t mutt_date_parse_date(const char *s, struct Tz *tz_out) } /* ad hoc support for the European MET (now officially CET) TZ */ - if (mutt_strcasecmp(t, "MET") == 0) + if (mutt_str_strcasecmp(t, "MET") == 0) { t = strtok(NULL, " \t"); if (t) { - if (mutt_strcasecmp(t, "DST") == 0) + if (mutt_str_strcasecmp(t, "DST") == 0) zhours++; } } diff --git a/mutt/file.c b/mutt/file.c index 46c8e6927..74ccdcd35 100644 --- a/mutt/file.c +++ b/mutt/file.c @@ -123,7 +123,7 @@ static int mkwrapdir(const char *path, char *newfile, size_t nflen, char *newdir char parent[_POSIX_PATH_MAX]; char *p = NULL; - strfcpy(parent, NONULL(path), sizeof(parent)); + mutt_str_strfcpy(parent, NONULL(path), sizeof(parent)); p = strrchr(parent, '/'); if (p) @@ -133,7 +133,7 @@ static int mkwrapdir(const char *path, char *newfile, size_t nflen, char *newdir } else { - strfcpy(parent, ".", sizeof(parent)); + mutt_str_strfcpy(parent, ".", sizeof(parent)); basename = path; } @@ -865,7 +865,7 @@ int mutt_file_mkdir(const char *path, mode_t mode) return 0; /* Create a mutable copy */ - strfcpy(_path, path, sizeof(_path)); + mutt_str_strfcpy(_path, path, sizeof(_path)); for (char *p = _path + 1; *p; p++) { @@ -935,7 +935,7 @@ time_t mutt_file_decrease_mtime(const char *f, struct stat *st) const char *mutt_file_dirname(const char *p) { static char buf[_POSIX_PATH_MAX]; - strfcpy(buf, p, sizeof(buf)); + mutt_str_strfcpy(buf, p, sizeof(buf)); return dirname(buf); } @@ -1194,12 +1194,12 @@ int mutt_file_to_absolute_path(char *path, const char *reference) } dirpath = mutt_file_dirname(reference); - strfcpy(abs_path, dirpath, PATH_MAX); - safe_strncat(abs_path, sizeof(abs_path), "/", 1); /* append a / at the end of the path */ + mutt_str_strfcpy(abs_path, dirpath, PATH_MAX); + mutt_str_strncat(abs_path, sizeof(abs_path), "/", 1); /* append a / at the end of the path */ path_len = PATH_MAX - strlen(path); - safe_strncat(abs_path, sizeof(abs_path), path, path_len > 0 ? path_len : 0); + mutt_str_strncat(abs_path, sizeof(abs_path), path, path_len > 0 ? path_len : 0); path = realpath(abs_path, path); diff --git a/mutt/hash.c b/mutt/hash.c index 81a3a38cf..bbf3501d1 100644 --- a/mutt/hash.c +++ b/mutt/hash.c @@ -78,7 +78,7 @@ static unsigned int gen_string_hash(union HashKey key, unsigned int n) */ static int cmp_string_key(union HashKey a, union HashKey b) { - return mutt_strcmp(a.strkey, b.strkey); + return mutt_str_strcmp(a.strkey, b.strkey); } /** @@ -109,7 +109,7 @@ static unsigned int gen_case_string_hash(union HashKey key, unsigned int n) */ static int cmp_case_string_key(union HashKey a, union HashKey b) { - return mutt_strcasecmp(a.strkey, b.strkey); + return mutt_str_strcasecmp(a.strkey, b.strkey); } /** @@ -338,7 +338,7 @@ struct Hash *mutt_hash_int_create(int nelem, int flags) int mutt_hash_insert(struct Hash *table, const char *strkey, void *data) { union HashKey key; - key.strkey = table->strdup_keys ? safe_strdup(strkey) : strkey; + key.strkey = table->strdup_keys ? mutt_str_strdup(strkey) : strkey; return union_hash_insert(table, key, data); } diff --git a/mutt/list.c b/mutt/list.c index 34377d856..010ac971e 100644 --- a/mutt/list.c +++ b/mutt/list.c @@ -98,7 +98,7 @@ struct ListNode *mutt_list_find(struct ListHead *h, const char *data) struct ListNode *np; STAILQ_FOREACH(np, h, entries) { - if (np->data == data || mutt_strcmp(np->data, data) == 0) + if (np->data == data || mutt_str_strcmp(np->data, data) == 0) { return np; } @@ -159,7 +159,7 @@ bool mutt_list_match(const char *s, struct ListHead *h) struct ListNode *np; STAILQ_FOREACH(np, h, entries) { - if ((*np->data == '*') || (mutt_strncasecmp(s, np->data, strlen(np->data)) == 0)) + if ((*np->data == '*') || (mutt_str_strncasecmp(s, np->data, strlen(np->data)) == 0)) return true; } return false; @@ -181,7 +181,7 @@ int mutt_list_compare(const struct ListHead *ah, const struct ListHead *bh) while (a && b) { - if (mutt_strcmp(a->data, b->data) != 0) + if (mutt_str_strcmp(a->data, b->data) != 0) return 0; a = STAILQ_NEXT(a, entries); diff --git a/mutt/mapping.c b/mutt/mapping.c index fe6b560c2..c76d22b28 100644 --- a/mutt/mapping.c +++ b/mutt/mapping.c @@ -60,7 +60,7 @@ const char *mutt_map_get_name(int val, const struct Mapping *map) int mutt_map_get_value(const char *name, const struct Mapping *map) { for (int i = 0; map[i].name; i++) - if (mutt_strcasecmp(map[i].name, name) == 0) + if (mutt_str_strcasecmp(map[i].name, name) == 0) return map[i].value; return -1; } diff --git a/mutt/mbyte.c b/mutt/mbyte.c index 42b46d5df..2620522a4 100644 --- a/mutt/mbyte.c +++ b/mutt/mbyte.c @@ -79,7 +79,7 @@ int mutt_mb_charlen(const char *s, int *width) if (!s || !*s) return 0; - n = mutt_strlen(s); + n = mutt_str_strlen(s); memset(&mbstate, 0, sizeof(mbstate)); k = mbrtowc(&wc, s, n, &mbstate); if (width) diff --git a/mutt/string.c b/mutt/string.c index e4ea87f37..17c0f230c 100644 --- a/mutt/string.c +++ b/mutt/string.c @@ -25,41 +25,42 @@ * * Lots of commonly-used string manipulation routines. * - * | Function | Description - * | :------------------------ | :--------------------------------------------------------- - * | find_word() | Find the next word (non-space) - * | imap_wordcasecmp() | Find word a in word list b - * | is_ascii() | Is a string ASCII (7-bit)? - * | is_email_wsp() | Is this a whitespace character (for an email header) - * | lwslen() | Measure the linear-white-space at the beginning of a string - * | lwsrlen() | Measure the linear-white-space at the end of a string - * | mutt_atoi() | Convert ASCII string to an integer - * | mutt_atos() | Convert ASCII string to a short - * | mutt_remove_trailing_ws() | Trim trailing whitespace from a string - * | mutt_skip_whitespace() | Find the first non-whitespace character in a string - * | mutt_strcasecmp() | Compare two strings ignoring case, safely - * | mutt_strchrnul() | Find first occurrence of character in string - * | mutt_strcmp() | Compare two strings, safely - * | mutt_strcoll() | Collate two strings (compare using locale), safely - * | mutt_stristr() | Find first occurrence of string (ignoring case) - * | mutt_strlen() | Calculate the length of a string, safely - * | mutt_strlower() | convert all characters in the string to lowercase - * | mutt_strncasecmp() | Compare two strings ignoring case (to a maximum), safely - * | mutt_strncmp() | Compare two strings (to a maximum), safely - * | mutt_str_adjust() | Shrink-to-fit a string - * | mutt_str_append_item() | Add string to another seprated by sep - * | mutt_str_replace() | Replace one string with another - * | mutt_substrcpy() | Copy a sub-string into a buffer - * | mutt_substrdup() | Duplicate a sub-string - * | next_word() | Find the next word in a string - * | rfc822_dequote_comment() | Un-escape characters in an email address comment - * | rstrnstr() | Find last instance of a substring - * | safe_strcat() | Concatenate two strings - * | safe_strdup() | Copy a string, safely - * | safe_strncat() | Concatenate two strings - * | skip_email_wsp() | Skip over whitespace as defined by RFC5322 - * | strfcpy() | Copy a string into a buffer (guaranteeing NUL-termination) - * | strnfcpy() | Copy a limited string into a buffer (guaranteeing NUL-termination) + * | Function | Description + * | :---------------------------- | :--------------------------------------------------------- + * | mutt_str_adjust() | Shrink-to-fit a string + * | mutt_str_append_item() | Add string to another separated by sep + * | mutt_str_atoi() | Convert ASCII string to an integer + * | mutt_str_atol() | Convert ASCII string to a long + * | mutt_str_atos() | Convert ASCII string to a short + * | mutt_str_dequote_comment() | Un-escape characters in an email address comment + * | mutt_str_find_word() | Find the next word (non-space) + * | mutt_str_is_ascii() | Is a string ASCII (7-bit)? + * | mutt_str_is_email_wsp() | Is this a whitespace character (for an email header) + * | mutt_str_lws_len() | Measure the linear-white-space at the beginning of a string + * | mutt_str_lws_rlen() | Measure the linear-white-space at the end of a string + * | mutt_str_next_word() | Find the next word in a string + * | mutt_str_remove_trailing_ws() | Trim trailing whitespace from a string + * | mutt_str_replace() | Replace one string with another + * | mutt_str_rstrnstr() | Find last instance of a substring + * | mutt_str_skip_email_wsp() | Skip over whitespace as defined by RFC5322 + * | mutt_str_skip_whitespace() | Find the first non-whitespace character in a string + * | mutt_str_strcasecmp() | Compare two strings ignoring case, safely + * | mutt_str_strcat() | Concatenate two strings + * | mutt_str_strchrnul() | Find first occurrence of character in string + * | mutt_str_strcmp() | Compare two strings, safely + * | mutt_str_strcoll() | Collate two strings (compare using locale), safely + * | mutt_str_strdup() | Copy a string, safely + * | mutt_str_strfcpy() | Copy a string into a buffer (guaranteeing NUL-termination) + * | mutt_str_stristr() | Find first occurrence of string (ignoring case) + * | mutt_str_strlen() | Calculate the length of a string, safely + * | mutt_str_strlower() | convert all characters in the string to lowercase + * | mutt_str_strncasecmp() | Compare two strings ignoring case (to a maximum), safely + * | mutt_str_strncat() | Concatenate two strings + * | mutt_str_strncmp() | Compare two strings (to a maximum), safely + * | mutt_str_strnfcpy() | Copy a limited string into a buffer (guaranteeing NUL-termination) + * | mutt_str_substr_cpy() | Copy a sub-string into a buffer + * | mutt_str_substr_dup() | Duplicate a sub-string + * | mutt_str_word_casecmp() | Find word a in word list b */ #include "config.h" @@ -73,7 +74,7 @@ #include "string2.h" /** - * mutt_atol - Convert ASCII string to a long + * mutt_str_atol - Convert ASCII string to a long * @param[in] str String to read * @param[out] dst Store the result * @retval 0 Success @@ -82,7 +83,7 @@ * This is a strtol() wrapper with range checking. * errno may be set on error, e.g. ERANGE */ -static int mutt_atol(const char *str, long *dst) +int mutt_str_atol(const char *str, long *dst) { long r; long *res = dst ? dst : &r; @@ -102,7 +103,7 @@ static int mutt_atol(const char *str, long *dst) } /** - * mutt_atos - Convert ASCII string to a short + * mutt_str_atos - Convert ASCII string to a short * @param[in] str String to read * @param[out] dst Store the result * @retval 0 Success @@ -114,7 +115,7 @@ static int mutt_atol(const char *str, long *dst) * * errno may be set on error, e.g. ERANGE */ -int mutt_atos(const char *str, short *dst) +int mutt_str_atos(const char *str, short *dst) { int rc; long res; @@ -123,7 +124,7 @@ int mutt_atos(const char *str, short *dst) *t = 0; - rc = mutt_atol(str, &res); + rc = mutt_str_atol(str, &res); if (rc < 0) return rc; if ((short) res != res) @@ -134,7 +135,7 @@ int mutt_atos(const char *str, short *dst) } /** - * mutt_atoi - Convert ASCII string to an integer + * mutt_str_atoi - Convert ASCII string to an integer * @param[in] str String to read * @param[out] dst Store the result * @retval 0 Success @@ -145,7 +146,7 @@ int mutt_atos(const char *str, short *dst) * If @a dst is NULL, the string will be tested only (without conversion). * errno may be set on error, e.g. ERANGE */ -int mutt_atoi(const char *str, int *dst) +int mutt_str_atoi(const char *str, int *dst) { int rc; long res; @@ -154,7 +155,7 @@ int mutt_atoi(const char *str, int *dst) *t = 0; - rc = mutt_atol(str, &res); + rc = mutt_str_atol(str, &res); if (rc < 0) return rc; if ((int) res != res) @@ -165,12 +166,12 @@ int mutt_atoi(const char *str, int *dst) } /** - * safe_strdup - Copy a string, safely + * mutt_str_strdup - Copy a string, safely * @param s String to copy * @retval ptr Copy of the string * @retval NULL if s was NULL */ -char *safe_strdup(const char *s) +char *mutt_str_strdup(const char *s) { char *p = NULL; size_t l; @@ -184,13 +185,13 @@ char *safe_strdup(const char *s) } /** - * safe_strcat - Concatenate two strings + * mutt_str_strcat - Concatenate two strings * @param d Buffer containing source string * @param l Length of buffer * @param s String to add * @retval ptr Start of joined string */ -char *safe_strcat(char *d, size_t l, const char *s) +char *mutt_str_strcat(char *d, size_t l, const char *s) { char *p = d; @@ -210,7 +211,7 @@ char *safe_strcat(char *d, size_t l, const char *s) } /** - * safe_strncat - Concatenate two strings + * mutt_str_strncat - Concatenate two strings * @param d Buffer containing source string * @param l Length of buffer * @param s String to add @@ -219,7 +220,7 @@ char *safe_strcat(char *d, size_t l, const char *s) * * Add a string to a maximum of @a sl bytes. */ -char *safe_strncat(char *d, size_t l, const char *s, size_t sl) +char *mutt_str_strncat(char *d, size_t l, const char *s, size_t sl) { char *p = d; @@ -251,7 +252,7 @@ char *safe_strncat(char *d, size_t l, const char *s, size_t sl) void mutt_str_replace(char **p, const char *s) { FREE(p); - *p = safe_strdup(s); + *p = mutt_str_strdup(s); } /** @@ -295,13 +296,13 @@ void mutt_str_adjust(char **p) } /** - * mutt_strlower - convert all characters in the string to lowercase + * mutt_str_strlower - convert all characters in the string to lowercase * @param s String to lowercase * @retval ptr Lowercase string * * The string is transformed in place. */ -char *mutt_strlower(char *s) +char *mutt_str_strlower(char *s) { char *p = s; @@ -315,7 +316,7 @@ char *mutt_strlower(char *s) } /** - * mutt_strchrnul - Find first occurrence of character in string + * mutt_str_strchrnul - Find first occurrence of character in string * @param s Haystack * @param c Needle * @retval ptr Success, first occurrence of the character @@ -327,7 +328,7 @@ char *mutt_strlower(char *s) * returning NULL like its standard counterpart, this function returns a * pointer to the terminating NUL character. */ -const char *mutt_strchrnul(const char *s, char c) +const char *mutt_str_strchrnul(const char *s, char c) { for (; *s && (*s != c); s++) ; @@ -335,14 +336,14 @@ const char *mutt_strchrnul(const char *s, char c) } /** - * mutt_substrcpy - Copy a sub-string into a buffer + * mutt_str_substr_cpy - Copy a sub-string into a buffer * @param dest Buffer for the result * @param begin Start of the string to copy * @param end End of the string to copy * @param destlen Length of buffer * @retval ptr Destination buffer */ -char *mutt_substrcpy(char *dest, const char *begin, const char *end, size_t destlen) +char *mutt_str_substr_cpy(char *dest, const char *begin, const char *end, size_t destlen) { size_t len; @@ -355,7 +356,7 @@ char *mutt_substrcpy(char *dest, const char *begin, const char *end, size_t dest } /** - * mutt_substrdup - Duplicate a sub-string + * mutt_str_substr_dup - Duplicate a sub-string * @param begin Start of the string to copy * @param end End of the string to copy * @retval ptr New string @@ -364,7 +365,7 @@ char *mutt_substrcpy(char *dest, const char *begin, const char *end, size_t dest * * The caller must free the returned string. */ -char *mutt_substrdup(const char *begin, const char *end) +char *mutt_str_substr_dup(const char *begin, const char *end) { size_t len; char *p = NULL; @@ -393,33 +394,33 @@ char *mutt_substrdup(const char *begin, const char *end) } /** - * mutt_strcmp - Compare two strings, safely + * mutt_str_strcmp - Compare two strings, safely * @param a First string to compare * @param b Second string to compare * @retval -1 a precedes b * @retval 0 a and b are identical * @retval 1 b precedes a */ -int mutt_strcmp(const char *a, const char *b) +int mutt_str_strcmp(const char *a, const char *b) { return strcmp(NONULL(a), NONULL(b)); } /** - * mutt_strcasecmp - Compare two strings ignoring case, safely + * mutt_str_strcasecmp - Compare two strings ignoring case, safely * @param a First string to compare * @param b Second string to compare * @retval -1 a precedes b * @retval 0 a and b are identical * @retval 1 b precedes a */ -int mutt_strcasecmp(const char *a, const char *b) +int mutt_str_strcasecmp(const char *a, const char *b) { return strcasecmp(NONULL(a), NONULL(b)); } /** - * mutt_strncmp - Compare two strings (to a maximum), safely + * mutt_str_strncmp - Compare two strings (to a maximum), safely * @param a First string to compare * @param b Second string to compare * @param l Maximum number of bytes to compare @@ -427,13 +428,13 @@ int mutt_strcasecmp(const char *a, const char *b) * @retval 0 a and b are identical * @retval 1 b precedes a */ -int mutt_strncmp(const char *a, const char *b, size_t l) +int mutt_str_strncmp(const char *a, const char *b, size_t l) { return strncmp(NONULL(a), NONULL(b), l); } /** - * mutt_strncasecmp - Compare two strings ignoring case (to a maximum), safely + * mutt_str_strncasecmp - Compare two strings ignoring case (to a maximum), safely * @param a First string to compare * @param b Second string to compare * @param l Maximum number of bytes to compare @@ -441,42 +442,42 @@ int mutt_strncmp(const char *a, const char *b, size_t l) * @retval 0 a and b are identical * @retval 1 b precedes a */ -int mutt_strncasecmp(const char *a, const char *b, size_t l) +int mutt_str_strncasecmp(const char *a, const char *b, size_t l) { return strncasecmp(NONULL(a), NONULL(b), l); } /** - * mutt_strlen - Calculate the length of a string, safely + * mutt_str_strlen - Calculate the length of a string, safely * @param a String to measure * @retval num Length in bytes */ -size_t mutt_strlen(const char *a) +size_t mutt_str_strlen(const char *a) { return a ? strlen(a) : 0; } /** - * mutt_strcoll - Collate two strings (compare using locale), safely + * mutt_str_strcoll - Collate two strings (compare using locale), safely * @param a First string to compare * @param b Second string to compare * @retval -1 a precedes b * @retval 0 a and b are identical * @retval 1 b precedes a */ -int mutt_strcoll(const char *a, const char *b) +int mutt_str_strcoll(const char *a, const char *b) { return strcoll(NONULL(a), NONULL(b)); } /** - * mutt_stristr - Find first occurrence of string (ignoring case) + * mutt_str_stristr - Find first occurrence of string (ignoring case) * @param haystack String to search through * @param needle String to find * @retval ptr First match of the search string * @retval NULL No match, or an error */ -const char *mutt_stristr(const char *haystack, const char *needle) +const char *mutt_str_stristr(const char *haystack, const char *needle) { const char *p = NULL, *q = NULL; @@ -498,37 +499,37 @@ const char *mutt_stristr(const char *haystack, const char *needle) } /** - * mutt_skip_whitespace - Find the first non-whitespace character in a string + * mutt_str_skip_whitespace - Find the first non-whitespace character in a string * @param p String to search * @retval ptr First non-whitespace character * @retval ptr Terminating NUL character, if the string was entirely whitespace */ -char *mutt_skip_whitespace(char *p) +char *mutt_str_skip_whitespace(char *p) { SKIPWS(p); return p; } /** - * mutt_remove_trailing_ws - Trim trailing whitespace from a string + * mutt_str_remove_trailing_ws - Trim trailing whitespace from a string * @param s String to trim * * The string is modified in place. */ -void mutt_remove_trailing_ws(char *s) +void mutt_str_remove_trailing_ws(char *s) { - for (char *p = s + mutt_strlen(s) - 1; p >= s && ISSPACE(*p); p--) + for (char *p = s + mutt_str_strlen(s) - 1; p >= s && ISSPACE(*p); p--) *p = '\0'; } /** - * strfcpy - Copy a string into a buffer (guaranteeing NUL-termination) + * mutt_str_strfcpy - Copy a string into a buffer (guaranteeing NUL-termination) * @param dest Buffer for the result * @param src String to copy * @param dlen Length of buffer * @retval ptr Destination buffer */ -char *strfcpy(char *dest, const char *src, size_t dlen) +char *mutt_str_strfcpy(char *dest, const char *src, size_t dlen) { char *dest0 = dest; while ((--dlen > 0) && (*src != '\0')) @@ -539,14 +540,14 @@ char *strfcpy(char *dest, const char *src, size_t dlen) } /** - * skip_email_wsp - Skip over whitespace as defined by RFC5322 + * mutt_str_skip_email_wsp - Skip over whitespace as defined by RFC5322 * @param s String to search * @retval ptr First non-whitespace character * @retval ptr Terminating NUL character, if the string was entirely whitespace * * This is used primarily for parsing header fields. */ -char *skip_email_wsp(const char *s) +char *mutt_str_skip_email_wsp(const char *s) { if (s) return (char *) (s + strspn(s, EMAIL_WSP)); @@ -554,32 +555,32 @@ char *skip_email_wsp(const char *s) } /** - * is_email_wsp - Is this a whitespace character (for an email header) + * mutt_str_is_email_wsp - Is this a whitespace character (for an email header) * @param c Character to test * @retval boolean */ -int is_email_wsp(char c) +int mutt_str_is_email_wsp(char c) { return c && (strchr(EMAIL_WSP, c) != NULL); } /** - * strnfcpy - Copy a limited string into a buffer (guaranteeing NUL-termination) + * mutt_str_strnfcpy - Copy a limited string into a buffer (guaranteeing NUL-termination) * @param dest Buffer for the result * @param src String to copy * @param size Maximum number of characters to copy * @param dlen Length of buffer * @retval ptr Destination buffer */ -char *strnfcpy(char *dest, char *src, size_t size, size_t dlen) +char *mutt_str_strnfcpy(char *dest, char *src, size_t size, size_t dlen) { if (dlen > size) dlen = size - 1; - return strfcpy(dest, src, dlen); + return mutt_str_strfcpy(dest, src, dlen); } /** - * lwslen - Measure the linear-white-space at the beginning of a string + * mutt_str_lws_len - Measure the linear-white-space at the beginning of a string * @param s String to check * @param n Maximum number of characters to check * @retval num Count of whitespace characters @@ -587,7 +588,7 @@ char *strnfcpy(char *dest, char *src, size_t size, size_t dlen) * Count the number of whitespace characters at the beginning of a string. * They can be ``, ``, `` or ``. */ -size_t lwslen(const char *s, size_t n) +size_t mutt_str_lws_len(const char *s, size_t n) { const char *p = s; size_t len = n; @@ -610,7 +611,7 @@ size_t lwslen(const char *s, size_t n) } /** - * lwsrlen - Measure the linear-white-space at the end of a string + * mutt_str_lws_rlen - Measure the linear-white-space at the end of a string * @param s String to check * @param n Maximum number of characters to check * @retval num Count of whitespace characters @@ -618,7 +619,7 @@ size_t lwslen(const char *s, size_t n) * Count the number of whitespace characters at the end of a string. * They can be ``, ``, `` or ``. */ -size_t lwsrlen(const char *s, size_t n) +size_t mutt_str_lws_rlen(const char *s, size_t n) { const char *p = s + n - 1; size_t len = n; @@ -642,12 +643,12 @@ size_t lwsrlen(const char *s, size_t n) } /** - * rfc822_dequote_comment - Un-escape characters in an email address comment + * mutt_str_dequote_comment - Un-escape characters in an email address comment * @param s String to the un-escaped * * @note The string is changed in-place */ -void rfc822_dequote_comment(char *s) +void mutt_str_dequote_comment(char *s) { char *w = s; @@ -670,7 +671,7 @@ void rfc822_dequote_comment(char *s) } /** - * next_word - Find the next word in a string + * mutt_str_next_word - Find the next word in a string * @param s String to examine * @retval ptr Next word * @@ -679,7 +680,7 @@ void rfc822_dequote_comment(char *s) * * @note What is/isn't a word is determined by isspace() */ -const char *next_word(const char *s) +const char *mutt_str_next_word(const char *s) { while (*s && !ISSPACE(*s)) s++; @@ -688,7 +689,7 @@ const char *next_word(const char *s) } /** - * rstrnstr - Find last instance of a substring + * mutt_str_rstrnstr - Find last instance of a substring * @param haystack String to search through * @param haystack_length Length of the string * @param needle String to find @@ -698,7 +699,7 @@ const char *next_word(const char *s) * Return the last instance of needle in the haystack, or NULL. * Like strstr(), only backwards, and for a limited haystack length. */ -const char *rstrnstr(const char *haystack, size_t haystack_length, const char *needle) +const char *mutt_str_rstrnstr(const char *haystack, size_t haystack_length, const char *needle) { int needle_length = strlen(needle); const char *haystack_end = haystack + haystack_length - needle_length; @@ -718,7 +719,7 @@ const char *rstrnstr(const char *haystack, size_t haystack_length, const char *n } /** - * imap_wordcasecmp - Find word a in word list b + * mutt_str_word_casecmp - Find word a in word list b * @param a Word to find * @param b String to check * @retval 0 Word was found @@ -730,7 +731,7 @@ const char *rstrnstr(const char *haystack, size_t haystack_length, const char *n * * The case of the words is ignored. */ -int imap_wordcasecmp(const char *a, const char *b) +int mutt_str_word_casecmp(const char *a, const char *b) { char tmp[SHORT_STRING] = ""; @@ -746,16 +747,16 @@ int imap_wordcasecmp(const char *a, const char *b) } tmp[i + 1] = '\0'; - return mutt_strcasecmp(a, tmp); + return mutt_str_strcasecmp(a, tmp); } /** - * is_ascii - Is a string ASCII (7-bit)? + * mutt_str_is_ascii - Is a string ASCII (7-bit)? * @param p String to examine * @param len Length of string * @retval bool True if there are no 8-bit chars */ -bool is_ascii(const char *p, size_t len) +bool mutt_str_is_ascii(const char *p, size_t len) { const char *s = p; while (s && (unsigned int) (s - p) < len) @@ -768,7 +769,7 @@ bool is_ascii(const char *p, size_t len) } /** - * find_word - Find the next word (non-space) + * mutt_str_find_word - Find the next word (non-space) * @param src String to search * @retval ptr Beginning of the next word * @@ -778,7 +779,7 @@ bool is_ascii(const char *p, size_t len) * @note If there aren't any more words, this will return a pointer to the * final NUL character. */ -const char *find_word(const char *src) +const char *mutt_str_find_word(const char *src) { const char *p = src; diff --git a/mutt/string2.h b/mutt/string2.h index e3c5bf5ea..84a7714ae 100644 --- a/mutt/string2.h +++ b/mutt/string2.h @@ -57,38 +57,39 @@ #define terminate_buffer(a, b) terminate_string(a, b, sizeof(a) - 1) -const char *find_word(const char *src); -int imap_wordcasecmp(const char *a, const char *b); -bool is_ascii(const char *p, size_t len); -int is_email_wsp(char c); -size_t lwslen(const char *s, size_t n); -size_t lwsrlen(const char *s, size_t n); -int mutt_atoi(const char *str, int *dst); -int mutt_atos(const char *str, short *dst); -void mutt_remove_trailing_ws(char *s); -char * mutt_skip_whitespace(char *p); void mutt_str_adjust(char **p); void mutt_str_append_item(char **p, const char *item, int sep); -int mutt_strcasecmp(const char *a, const char *b); -const char *mutt_strchrnul(const char *s, char c); -int mutt_strcmp(const char *a, const char *b); -int mutt_strcoll(const char *a, const char *b); -const char *mutt_stristr(const char *haystack, const char *needle); -size_t mutt_strlen(const char *a); -char * mutt_strlower(char *s); -int mutt_strncasecmp(const char *a, const char *b, size_t l); -int mutt_strncmp(const char *a, const char *b, size_t l); +int mutt_str_atoi(const char *str, int *dst); +int mutt_str_atol(const char *str, long *dst); +int mutt_str_atos(const char *str, short *dst); +void mutt_str_dequote_comment(char *s); +const char *mutt_str_find_word(const char *src); +bool mutt_str_is_ascii(const char *p, size_t len); +int mutt_str_is_email_wsp(char c); +size_t mutt_str_lws_len(const char *s, size_t n); +size_t mutt_str_lws_rlen(const char *s, size_t n); +const char *mutt_str_next_word(const char *s); +void mutt_str_remove_trailing_ws(char *s); void mutt_str_replace(char **p, const char *s); -char * mutt_substrcpy(char *dest, const char *begin, const char *end, size_t destlen); -char * mutt_substrdup(const char *begin, const char *end); -const char *next_word(const char *s); -void rfc822_dequote_comment(char *s); -const char *rstrnstr(const char *haystack, size_t haystack_length, const char *needle); -char * safe_strcat(char *d, size_t l, const char *s); -char * safe_strdup(const char *s); -char * safe_strncat(char *d, size_t l, const char *s, size_t sl); -char * skip_email_wsp(const char *s); -char * strfcpy(char *dest, const char *src, size_t dlen); -char * strnfcpy(char *dest, char *src, size_t size, size_t dlen); +const char *mutt_str_rstrnstr(const char *haystack, size_t haystack_length, const char *needle); +char * mutt_str_skip_email_wsp(const char *s); +char * mutt_str_skip_whitespace(char *p); +int mutt_str_strcasecmp(const char *a, const char *b); +char * mutt_str_strcat(char *d, size_t l, const char *s); +const char *mutt_str_strchrnul(const char *s, char c); +int mutt_str_strcmp(const char *a, const char *b); +int mutt_str_strcoll(const char *a, const char *b); +char * mutt_str_strdup(const char *s); +char * mutt_str_strfcpy(char *dest, const char *src, size_t dlen); +const char *mutt_str_stristr(const char *haystack, const char *needle); +size_t mutt_str_strlen(const char *a); +char * mutt_str_strlower(char *s); +int mutt_str_strncasecmp(const char *a, const char *b, size_t l); +char * mutt_str_strncat(char *d, size_t l, const char *s, size_t sl); +int mutt_str_strncmp(const char *a, const char *b, size_t l); +char * mutt_str_strnfcpy(char *dest, char *src, size_t size, size_t dlen); +char * mutt_str_substr_cpy(char *dest, const char *begin, const char *end, size_t destlen); +char * mutt_str_substr_dup(const char *begin, const char *end); +int mutt_str_word_casecmp(const char *a, const char *b); #endif /* _MUTT_STRING_H */ diff --git a/mutt_account.c b/mutt_account.c index e1a80c289..9b2f9dbff 100644 --- a/mutt_account.c +++ b/mutt_account.c @@ -43,7 +43,7 @@ int mutt_account_match(const struct Account *a1, const struct Account *a2) if (a1->type != a2->type) return 0; - if (mutt_strcasecmp(a1->host, a2->host) != 0) + if (mutt_str_strcasecmp(a1->host, a2->host) != 0) return 0; if (a1->port != a2->port) return 0; @@ -91,18 +91,18 @@ int mutt_account_fromurl(struct Account *account, struct Url *url) { /* must be present */ if (url->host) - strfcpy(account->host, url->host, sizeof(account->host)); + mutt_str_strfcpy(account->host, url->host, sizeof(account->host)); else return -1; if (url->user) { - strfcpy(account->user, url->user, sizeof(account->user)); + mutt_str_strfcpy(account->user, url->user, sizeof(account->user)); account->flags |= MUTT_ACCT_USER; } if (url->pass) { - strfcpy(account->pass, url->pass, sizeof(account->pass)); + mutt_str_strfcpy(account->pass, url->pass, sizeof(account->pass)); account->flags |= MUTT_ACCT_PASS; } if (url->port) @@ -195,15 +195,15 @@ int mutt_account_getuser(struct Account *account) return 0; #ifdef USE_IMAP else if ((account->type == MUTT_ACCT_TYPE_IMAP) && ImapUser) - strfcpy(account->user, ImapUser, sizeof(account->user)); + mutt_str_strfcpy(account->user, ImapUser, sizeof(account->user)); #endif #ifdef USE_POP else if ((account->type == MUTT_ACCT_TYPE_POP) && PopUser) - strfcpy(account->user, PopUser, sizeof(account->user)); + mutt_str_strfcpy(account->user, PopUser, sizeof(account->user)); #endif #ifdef USE_NNTP else if ((account->type == MUTT_ACCT_TYPE_NNTP) && NntpUser) - strfcpy(account->user, NntpUser, sizeof(account->user)); + mutt_str_strfcpy(account->user, NntpUser, sizeof(account->user)); #endif else if (option(OPT_NO_CURSES)) return -1; @@ -212,7 +212,7 @@ int mutt_account_getuser(struct Account *account) { /* L10N: Example: Username at myhost.com */ snprintf(prompt, sizeof(prompt), _("Username at %s: "), account->host); - strfcpy(account->user, NONULL(Username), sizeof(account->user)); + mutt_str_strfcpy(account->user, NONULL(Username), sizeof(account->user)); if (mutt_get_field_unbuffered(prompt, account->user, sizeof(account->user), 0)) return -1; } @@ -238,7 +238,7 @@ int mutt_account_getlogin(struct Account *account) { if (ImapLogin) { - strfcpy(account->login, ImapLogin, sizeof(account->login)); + mutt_str_strfcpy(account->login, ImapLogin, sizeof(account->login)); account->flags |= MUTT_ACCT_LOGIN; } } @@ -248,7 +248,7 @@ int mutt_account_getlogin(struct Account *account) { if (mutt_account_getuser(account) == 0) { - strfcpy(account->login, account->user, sizeof(account->login)); + mutt_str_strfcpy(account->login, account->user, sizeof(account->login)); account->flags |= MUTT_ACCT_LOGIN; } else @@ -275,19 +275,19 @@ int mutt_account_getpass(struct Account *account) return 0; #ifdef USE_IMAP else if ((account->type == MUTT_ACCT_TYPE_IMAP) && ImapPass) - strfcpy(account->pass, ImapPass, sizeof(account->pass)); + mutt_str_strfcpy(account->pass, ImapPass, sizeof(account->pass)); #endif #ifdef USE_POP else if ((account->type == MUTT_ACCT_TYPE_POP) && PopPass) - strfcpy(account->pass, PopPass, sizeof(account->pass)); + mutt_str_strfcpy(account->pass, PopPass, sizeof(account->pass)); #endif #ifdef USE_SMTP else if ((account->type == MUTT_ACCT_TYPE_SMTP) && SmtpPass) - strfcpy(account->pass, SmtpPass, sizeof(account->pass)); + mutt_str_strfcpy(account->pass, SmtpPass, sizeof(account->pass)); #endif #ifdef USE_NNTP else if ((account->type == MUTT_ACCT_TYPE_NNTP) && NntpPass) - strfcpy(account->pass, NntpPass, sizeof(account->pass)); + mutt_str_strfcpy(account->pass, NntpPass, sizeof(account->pass)); #endif else if (option(OPT_NO_CURSES)) return -1; diff --git a/mutt_idna.c b/mutt_idna.c index 689af4232..3760098dc 100644 --- a/mutt_idna.c +++ b/mutt_idna.c @@ -38,12 +38,12 @@ static bool check_idn(char *domain) if (!domain) return false; - if (mutt_strncasecmp(domain, "xn--", 4) == 0) + if (mutt_str_strncasecmp(domain, "xn--", 4) == 0) return true; while ((domain = strchr(domain, '.')) != NULL) { - if (mutt_strncasecmp(++domain, "xn--", 4) == 0) + if (mutt_str_strncasecmp(++domain, "xn--", 4) == 0) return true; } @@ -104,8 +104,8 @@ static char *intl_to_local(char *orig_user, char *orig_domain, int flags) bool is_idn_encoded = false; #endif /* HAVE_LIBIDN */ - local_user = safe_strdup(orig_user); - local_domain = safe_strdup(orig_domain); + local_user = mutt_str_strdup(orig_user); + local_domain = mutt_str_strdup(orig_domain); #ifdef HAVE_LIBIDN is_idn_encoded = check_idn(local_domain); @@ -131,7 +131,7 @@ static char *intl_to_local(char *orig_user, char *orig_domain, int flags) */ if ((flags & MI_MAY_BE_IRREVERSIBLE) == 0) { - reversed_user = safe_strdup(local_user); + reversed_user = mutt_str_strdup(local_user); if (mutt_convert_string(&reversed_user, Charset, "utf-8", 0) == -1) { @@ -141,7 +141,7 @@ static char *intl_to_local(char *orig_user, char *orig_domain, int flags) goto cleanup; } - if (mutt_strcasecmp(orig_user, reversed_user) != 0) + if (mutt_str_strcasecmp(orig_user, reversed_user) != 0) { mutt_debug( 1, "intl_to_local: Not reversible. orig = '%s', reversed = '%s'.\n", @@ -149,7 +149,7 @@ static char *intl_to_local(char *orig_user, char *orig_domain, int flags) goto cleanup; } - reversed_domain = safe_strdup(local_domain); + reversed_domain = mutt_str_strdup(local_domain); if (mutt_convert_string(&reversed_domain, Charset, "utf-8", 0) == -1) { @@ -177,7 +177,7 @@ static char *intl_to_local(char *orig_user, char *orig_domain, int flags) } #endif /* HAVE_LIBIDN */ - if (mutt_strcasecmp(orig_domain, reversed_domain) != 0) + if (mutt_str_strcasecmp(orig_domain, reversed_domain) != 0) { mutt_debug( 1, "intl_to_local: Not reversible. orig = '%s', reversed = '%s'.\n", @@ -186,7 +186,7 @@ static char *intl_to_local(char *orig_user, char *orig_domain, int flags) } } - mailbox = mutt_mem_malloc(mutt_strlen(local_user) + mutt_strlen(local_domain) + 2); + mailbox = mutt_mem_malloc(mutt_str_strlen(local_user) + mutt_str_strlen(local_domain) + 2); sprintf(mailbox, "%s@%s", NONULL(local_user), NONULL(local_domain)); cleanup: @@ -205,8 +205,8 @@ static char *local_to_intl(char *user, char *domain) char *mailbox = NULL; char *tmp = NULL; - intl_user = safe_strdup(user); - intl_domain = safe_strdup(domain); + intl_user = mutt_str_strdup(user); + intl_domain = mutt_str_strdup(domain); /* we don't want charset-hook effects, so we set flags to 0 */ if (mutt_convert_string(&intl_user, Charset, "utf-8", 0) == -1) @@ -224,7 +224,7 @@ static char *local_to_intl(char *user, char *domain) } #endif /* HAVE_LIBIDN */ - mailbox = mutt_mem_malloc(mutt_strlen(intl_user) + mutt_strlen(intl_domain) + 2); + mailbox = mutt_mem_malloc(mutt_str_strlen(intl_user) + mutt_str_strlen(intl_domain) + 2); sprintf(mailbox, "%s@%s", NONULL(intl_user), NONULL(intl_domain)); cleanup: @@ -259,7 +259,7 @@ int mutt_addrlist_to_intl(struct Address *a, char **err) { rv = -1; if (err && !*err) - *err = safe_strdup(a->mailbox); + *err = mutt_str_strdup(a->mailbox); continue; } diff --git a/mutt_lua.c b/mutt_lua.c index cf912131c..3c9d3d924 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -88,12 +88,12 @@ static int lua_mutt_call(lua_State *l) for (int i = 2; i <= lua_gettop(l); i++) { const char *s = lua_tostring(l, i); - safe_strncat(buffer, sizeof(buffer), s, mutt_strlen(s)); - safe_strncat(buffer, sizeof(buffer), " ", 1); + mutt_str_strncat(buffer, sizeof(buffer), s, mutt_str_strlen(s)); + mutt_str_strncat(buffer, sizeof(buffer), " ", 1); } expn.data = expn.dptr = buffer; - expn.dsize = mutt_strlen(buffer); + expn.dsize = mutt_str_strlen(buffer); if (command->func(&token, &expn, command->data, &err)) { @@ -139,7 +139,7 @@ static int lua_mutt_set(lua_State *l) case DT_PATH: case DT_SORT: case DT_STRING: - opt.data = (long) safe_strdup(lua_tostring(l, -1)); + opt.data = (long) mutt_str_strdup(lua_tostring(l, -1)); rv = mutt_option_set(&opt, &err); FREE(&opt.data); break; @@ -217,7 +217,7 @@ static int lua_mutt_get(lua_State *l) } case DT_PATH: case DT_STRING: - if (mutt_strncmp("my_", param, 3) == 0) + if (mutt_str_strncmp("my_", param, 3) == 0) { char *option = (char *) opt.option; char *value = (char *) opt.data; @@ -267,7 +267,7 @@ static int lua_mutt_enter(lua_State *l) { mutt_debug(2, " * lua_mutt_enter()\n"); struct Buffer token, err; - char *buffer = safe_strdup(lua_tostring(l, -1)); + char *buffer = mutt_str_strdup(lua_tostring(l, -1)); int rv = 0; mutt_buffer_init(&err); @@ -416,10 +416,10 @@ int mutt_lua_source_file(struct Buffer *tmp, struct Buffer *s, } if (MoreArgs(s)) { - strfcpy(err->data, _("source: too many arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("source: too many arguments"), err->dsize); return -1; } - strfcpy(path, tmp->data, sizeof(path)); + mutt_str_strfcpy(path, tmp->data, sizeof(path)); mutt_expand_path(path, sizeof(path)); if (luaL_dofile(Lua, path)) diff --git a/mutt_notmuch.c b/mutt_notmuch.c index a99f44462..818496130 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -236,7 +236,7 @@ static struct NmCtxData *new_ctxdata(const char *uri) mutt_debug(1, "nm: initialize context data %p\n", (void *) data); data->db_limit = NmDbLimit; - data->db_url_holder = safe_strdup(uri); + data->db_url_holder = mutt_str_strdup(uri); if (url_parse(&data->db_url, data->db_url_holder) < 0) { @@ -293,9 +293,9 @@ static struct NmCtxData *get_ctxdata(struct Context *ctx) static enum NmQueryType string_to_query_type(const char *str) { - if (mutt_strcmp(str, "threads") == 0) + if (mutt_str_strcmp(str, "threads") == 0) return NM_QUERY_TYPE_THREADS; - else if (mutt_strcmp(str, "messages") == 0) + else if (mutt_str_strcmp(str, "messages") == 0) return NM_QUERY_TYPE_MESGS; mutt_error(_("failed to parse notmuch query type: %s"), NONULL(str)); @@ -456,14 +456,14 @@ static char *get_query_string(struct NmCtxData *data, bool window) if (strcmp(item->name, "limit") == 0) { - if (mutt_atoi(item->value, &data->db_limit)) + if (mutt_str_atoi(item->value, &data->db_limit)) mutt_error(_("failed to parse notmuch limit: %s"), item->value); } else if (strcmp(item->name, "type") == 0) data->query_type = string_to_query_type(item->value); else if (strcmp(item->name, "query") == 0) - data->db_query = safe_strdup(item->value); + data->db_query = mutt_str_strdup(item->value); } if (!data->db_query) @@ -480,7 +480,7 @@ static char *get_query_string(struct NmCtxData *data, bool window) */ if (!strstr(data->db_query, "date:") && windowed_query_from_query(data->db_query, buf, sizeof(buf))) - data->db_query = safe_strdup(buf); + data->db_query = mutt_str_strdup(buf); mutt_debug(2, "nm: query (windowed) '%s'\n", data->db_query); } @@ -670,7 +670,7 @@ static void apply_exclude_tags(notmuch_query_t *query) if (!NmExcludeTags || !*NmExcludeTags) return; - buf = safe_strdup(NmExcludeTags); + buf = mutt_str_strdup(NmExcludeTags); for (char *p = buf; p && *p; p++) { @@ -790,12 +790,12 @@ static int update_message_path(struct Header *h, const char *path) FREE(&data->folder); p -= 3; /* skip subfolder (e.g. "new") */ - h->path = safe_strdup(p); + h->path = mutt_str_strdup(p); for (; (p > path) && (*(p - 1) == '/'); p--) ; - data->folder = mutt_substrdup(path, p); + data->folder = mutt_str_substr_dup(path, p); mutt_debug(2, "nm: folder='%s', file='%s'\n", data->folder, h->path); return 0; @@ -816,7 +816,7 @@ static char *get_folder_from_path(const char *path) for (; (p > path) && (*(p - 1) == '/'); p--) ; - return mutt_substrdup(path, p); + return mutt_str_substr_dup(path, p); } return NULL; @@ -868,7 +868,7 @@ static int init_header(struct Header *h, const char *path, notmuch_message_t *ms * Notmuch ensures that message Id exists (if not notmuch Notmuch will * generate an ID), so it's more safe than use neomutt Header->env->id */ - ((struct NmHdrData *) h->data)->virtual_id = safe_strdup(id); + ((struct NmHdrData *) h->data)->virtual_id = mutt_str_strdup(id); mutt_debug(2, "nm: initialize header data: [hdr=%p, data=%p] (%s)\n", (void *) h, (void *) h->data, id); @@ -1058,7 +1058,7 @@ static void append_message(struct Context *ctx, notmuch_query_t *q, if (hd) { mutt_debug(1, "nm: remember obsolete path: %s\n", path); - hd->oldpath = safe_strdup(path); + hd->oldpath = mutt_str_strdup(path); } } progress_update(ctx, q); @@ -1199,7 +1199,7 @@ static bool nm_message_has_tag(notmuch_message_t *msg, char *tag) notmuch_tags_move_to_next(tags)) { possible_match_tag = notmuch_tags_get(tags); - if (mutt_strcmp(possible_match_tag, tag) == 0) + if (mutt_str_strcmp(possible_match_tag, tag) == 0) { return true; } @@ -1210,7 +1210,7 @@ static bool nm_message_has_tag(notmuch_message_t *msg, char *tag) static int update_tags(notmuch_message_t *msg, const char *tags) { char *tag = NULL, *end = NULL, *p = NULL; - char *buf = safe_strdup(tags); + char *buf = mutt_str_strdup(tags); if (!buf) return -1; @@ -1274,7 +1274,7 @@ static int update_tags(notmuch_message_t *msg, const char *tags) static int update_header_flags(struct Context *ctx, struct Header *hdr, const char *tags) { char *tag = NULL, *end = NULL; - char *buf = safe_strdup(tags); + char *buf = mutt_str_strdup(tags); if (!buf) return -1; @@ -1331,7 +1331,7 @@ static int rename_maildir_filename(const char *old, char *newpath, size_t newsz, char folder[_POSIX_PATH_MAX]; char *p = NULL; - strfcpy(folder, old, sizeof(folder)); + mutt_str_strfcpy(folder, old, sizeof(folder)); p = strrchr(folder, '/'); if (p) { @@ -1341,7 +1341,7 @@ static int rename_maildir_filename(const char *old, char *newpath, size_t newsz, else p = folder; - strfcpy(filename, p, sizeof(filename)); + mutt_str_strfcpy(filename, p, sizeof(filename)); /* remove (new,cur,...) from folder path */ p = strrchr(folder, '/'); @@ -1709,7 +1709,7 @@ bool nm_normalize_uri(char *new_uri, const char *orig_uri, size_t new_uri_sz) mutt_debug(2, "nm_normalize_uri #2 () -> db_query: %s\n", tmp_ctxdata->db_query); - strfcpy(buf, tmp_ctxdata->db_query, sizeof(buf)); + mutt_str_strfcpy(buf, tmp_ctxdata->db_query, sizeof(buf)); if (nm_uri_from_query(&tmp_ctx, buf, sizeof(buf)) == NULL) goto gone; @@ -1903,7 +1903,7 @@ int nm_nonctx_get_count(char *path, int *all, int *new) { struct UrlQueryString *item = NULL; struct Url url; - char *url_holder = safe_strdup(path); + char *url_holder = mutt_str_strdup(path); char *db_filename = NULL, *db_query = NULL; notmuch_database_t *db = NULL; int rc = -1; @@ -2088,7 +2088,7 @@ int nm_get_all_tags(struct Context *ctx, char **tag_list, int *tag_count) if (*tag) { if (tag_list) - tag_list[*tag_count] = safe_strdup(tag); + tag_list[*tag_count] = mutt_str_strdup(tag); (*tag_count)++; } notmuch_tags_move_to_next(tags); @@ -2266,7 +2266,7 @@ static int nm_check_mailbox(struct Context *ctx, int *index_hint) new = get_message_last_filename(m); header_get_fullpath(h, old, sizeof(old)); - if (mutt_strcmp(old, new) != 0) + if (mutt_str_strcmp(old, new) != 0) update_message_path(h, new); if (!h->changed) diff --git a/mutt_tags.c b/mutt_tags.c index 1c1996419..cd7a3f33e 100644 --- a/mutt_tags.c +++ b/mutt_tags.c @@ -72,7 +72,7 @@ static char *driver_tags_getter(struct TagHead *head, bool show_hidden, struct TagNode *np; STAILQ_FOREACH(np, head, entries) { - if (filter && mutt_strcmp(np->name, filter) != 0) + if (filter && mutt_str_strcmp(np->name, filter) != 0) continue; if (show_hidden || !np->hidden) { @@ -147,16 +147,16 @@ static void driver_tags_add(struct TagHead *head, char *new_tag) char *new_tag_transformed = mutt_hash_find(TagTransforms, new_tag); struct TagNode *np = mutt_mem_calloc(1, sizeof(struct TagNode)); - np->name = safe_strdup(new_tag); + np->name = mutt_str_strdup(new_tag); np->hidden = false; if (new_tag_transformed) - np->transformed = safe_strdup(new_tag_transformed); + np->transformed = mutt_str_strdup(new_tag_transformed); /* filter out hidden tags */ if (HiddenTags) { char *p = strstr(HiddenTags, new_tag); - size_t xsz = p ? mutt_strlen(new_tag) : 0; + size_t xsz = p ? mutt_str_strlen(new_tag) : 0; if (p && ((p == HiddenTags) || (*(p - 1) == ',') || (*(p - 1) == ' ')) && ((*(p + xsz) == '\0') || (*(p + xsz) == ',') || (*(p + xsz) == ' '))) diff --git a/muttlib.c b/muttlib.c index 99f0984dd..80ef4ff4d 100644 --- a/muttlib.c +++ b/muttlib.c @@ -102,7 +102,7 @@ void mutt_adv_mktemp(char *s, size_t l) } else { - strfcpy(prefix, s, sizeof(prefix)); + mutt_str_strfcpy(prefix, s, sizeof(prefix)); mutt_file_sanitize_filename(prefix, 1); snprintf(s, l, "%s/%s", NONULL(Tmpdir), prefix); if (lstat(s, &sb) == -1 && errno == ENOENT) @@ -123,7 +123,7 @@ int mutt_remove_from_regex_list(struct RegexList **l, const char *str) struct RegexList *p = NULL, *last = NULL; int rv = -1; - if (mutt_strcmp("*", str) == 0) + if (mutt_str_strcmp("*", str) == 0) { mutt_free_regex_list(l); /* ``unCMD *'' means delete all current entries */ rv = 0; @@ -134,7 +134,7 @@ int mutt_remove_from_regex_list(struct RegexList **l, const char *str) last = NULL; while (p) { - if (mutt_strcasecmp(str, p->regex->pattern) == 0) + if (mutt_str_strcasecmp(str, p->regex->pattern) == 0) { mutt_free_regex(&p->regex); if (last) @@ -190,7 +190,7 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) { if (*(s + 1) == '/' || *(s + 1) == 0) { - strfcpy(p, NONULL(HomeDir), sizeof(p)); + mutt_str_strfcpy(p, NONULL(HomeDir), sizeof(p)); tail = s + 1; } else @@ -201,7 +201,7 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) if ((pw = getpwnam(s + 1))) { - strfcpy(p, pw->pw_dir, sizeof(p)); + mutt_str_strfcpy(p, pw->pw_dir, sizeof(p)); if (t) { *t = '/'; @@ -229,16 +229,16 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) /* if folder = {host} or imap[s]://host/: don't append slash */ if (mx_is_imap(NONULL(Folder)) && (Folder[strlen(Folder) - 1] == '}' || Folder[strlen(Folder) - 1] == '/')) - strfcpy(p, NONULL(Folder), sizeof(p)); + mutt_str_strfcpy(p, NONULL(Folder), sizeof(p)); else #endif #ifdef USE_NOTMUCH if (mx_is_notmuch(NONULL(Folder))) - strfcpy(p, NONULL(Folder), sizeof(p)); + mutt_str_strfcpy(p, NONULL(Folder), sizeof(p)); else #endif if (Folder && *Folder && Folder[strlen(Folder) - 1] == '/') - strfcpy(p, NONULL(Folder), sizeof(p)); + mutt_str_strfcpy(p, NONULL(Folder), sizeof(p)); else snprintf(p, sizeof(p), "%s/", NONULL(Folder)); @@ -272,14 +272,14 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) case '>': { - strfcpy(p, NONULL(Mbox), sizeof(p)); + mutt_str_strfcpy(p, NONULL(Mbox), sizeof(p)); tail = s + 1; } break; case '<': { - strfcpy(p, NONULL(Record), sizeof(p)); + mutt_str_strfcpy(p, NONULL(Record), sizeof(p)); tail = s + 1; } break; @@ -288,12 +288,12 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) { if (*(s + 1) == '!') { - strfcpy(p, NONULL(LastFolder), sizeof(p)); + mutt_str_strfcpy(p, NONULL(LastFolder), sizeof(p)); tail = s + 2; } else { - strfcpy(p, NONULL(SpoolFile), sizeof(p)); + mutt_str_strfcpy(p, NONULL(SpoolFile), sizeof(p)); tail = s + 1; } } @@ -301,14 +301,14 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) case '-': { - strfcpy(p, NONULL(LastFolder), sizeof(p)); + mutt_str_strfcpy(p, NONULL(LastFolder), sizeof(p)); tail = s + 1; } break; case '^': { - strfcpy(p, NONULL(CurrentFolder), sizeof(p)); + mutt_str_strfcpy(p, NONULL(CurrentFolder), sizeof(p)); tail = s + 1; } break; @@ -328,7 +328,7 @@ char *mutt_expand_path_regex(char *s, size_t slen, int regex) else snprintf(tmp, sizeof(tmp), "%s%s", p, tail); - strfcpy(s, tmp, slen); + mutt_str_strfcpy(s, tmp, slen); } while (recurse); #ifdef USE_IMAP @@ -363,13 +363,13 @@ char *mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw) if (GecosMask.regex) { if (regexec(GecosMask.regex, pw->pw_gecos, 1, pat_match, 0) == 0) - strfcpy(dest, pw->pw_gecos + pat_match[0].rm_so, - MIN(pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen)); + mutt_str_strfcpy(dest, pw->pw_gecos + pat_match[0].rm_so, + MIN(pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen)); } else if ((p = strchr(pw->pw_gecos, ','))) - strfcpy(dest, pw->pw_gecos, MIN(destlen, p - pw->pw_gecos + 1)); + mutt_str_strfcpy(dest, pw->pw_gecos, MIN(destlen, p - pw->pw_gecos + 1)); else - strfcpy(dest, pw->pw_gecos, destlen); + mutt_str_strfcpy(dest, pw->pw_gecos, destlen); pwnl = strlen(pw->pw_name); @@ -398,7 +398,7 @@ bool mutt_needs_mailcap(struct Body *m) switch (m->type) { case TYPETEXT: - if (mutt_strcasecmp("plain", m->subtype) == 0) + if (mutt_str_strcasecmp("plain", m->subtype) == 0) return false; break; case TYPEAPPLICATION: @@ -429,13 +429,13 @@ bool mutt_is_text_part(struct Body *b) if (t == TYPEMESSAGE) { - if (mutt_strcasecmp("delivery-status", s) == 0) + if (mutt_str_strcasecmp("delivery-status", s) == 0) return true; } if ((WithCrypto & APPLICATION_PGP) && t == TYPEAPPLICATION) { - if (mutt_strcasecmp("pgp-keys", s) == 0) + if (mutt_str_strcasecmp("pgp-keys", s) == 0) return true; } @@ -585,24 +585,25 @@ void mutt_pretty_mailbox(char *s, size_t buflen) *q = 0; } else if (strstr(p, "..") && (scheme == U_UNKNOWN || scheme == U_FILE) && realpath(p, tmp)) - strfcpy(p, tmp, buflen - (p - s)); + mutt_str_strfcpy(p, tmp, buflen - (p - s)); - if ((mutt_strncmp(s, Folder, (len = mutt_strlen(Folder))) == 0) && s[len] == '/') + if ((mutt_str_strncmp(s, Folder, (len = mutt_str_strlen(Folder))) == 0) && s[len] == '/') { *s++ = '='; - memmove(s, s + len, mutt_strlen(s + len) + 1); + memmove(s, s + len, mutt_str_strlen(s + len) + 1); } - else if ((mutt_strncmp(s, HomeDir, (len = mutt_strlen(HomeDir))) == 0) && s[len] == '/') + else if ((mutt_str_strncmp(s, HomeDir, (len = mutt_str_strlen(HomeDir))) == 0) && + s[len] == '/') { *s++ = '~'; - memmove(s, s + len - 1, mutt_strlen(s + len - 1) + 1); + memmove(s, s + len - 1, mutt_str_strlen(s + len - 1) + 1); } } void mutt_pretty_size(char *s, size_t len, LOFF_T n) { if (n == 0) - strfcpy(s, "0K", len); + mutt_str_strfcpy(s, "0K", len); else if (n < 10189) /* 0.1K - 9.9K */ snprintf(s, len, "%3.1fK", (n < 103) ? 0.1 : n / 1024.0); else if (n < 1023949) /* 10K - 999K */ @@ -634,7 +635,7 @@ void mutt_expand_fmt(char *dest, size_t destlen, const char *fmt, const char *sr size_t slen; bool found = false; - slen = mutt_strlen(src); + slen = mutt_str_strlen(src); destlen--; for (p = fmt, d = dest; destlen && *p; p++) @@ -649,7 +650,7 @@ void mutt_expand_fmt(char *dest, size_t destlen, const char *fmt, const char *sr break; case 's': found = true; - strfcpy(d, src, destlen + 1); + mutt_str_strfcpy(d, src, destlen + 1); d += destlen > slen ? slen : destlen; destlen -= destlen > slen ? slen : destlen; p++; @@ -671,8 +672,8 @@ void mutt_expand_fmt(char *dest, size_t destlen, const char *fmt, const char *sr if (!found && destlen > 0) { - safe_strcat(dest, destlen, " "); - safe_strcat(dest, destlen, src); + mutt_str_strcat(dest, destlen, " "); + mutt_str_strcat(dest, destlen, src); } } @@ -689,7 +690,7 @@ int mutt_check_overwrite(const char *attname, const char *path, char *fname, char tmp[_POSIX_PATH_MAX]; struct stat st; - strfcpy(fname, path, flen); + mutt_str_strfcpy(fname, path, flen); if (access(fname, F_OK) != 0) return 0; if (stat(fname, &st) != 0) @@ -724,7 +725,7 @@ int mutt_check_overwrite(const char *attname, const char *path, char *fname, else if ((rc = mutt_yesorno(_("File is a directory, save under it?"), MUTT_YES)) != MUTT_YES) return (rc == MUTT_NO) ? 1 : -1; - strfcpy(tmp, mutt_file_basename(NONULL(attname)), sizeof(tmp)); + mutt_str_strfcpy(tmp, mutt_file_basename(NONULL(attname)), sizeof(tmp)); if (mutt_get_field(_("File under directory: "), tmp, sizeof(tmp), MUTT_FILE | MUTT_CLEAR) != 0 || !tmp[0]) @@ -757,7 +758,7 @@ void mutt_save_path(char *d, size_t dsize, struct Address *a) { if (a && a->mailbox) { - strfcpy(d, a->mailbox, dsize); + mutt_str_strfcpy(d, a->mailbox, dsize); if (!option(OPT_SAVE_ADDRESS)) { char *p = NULL; @@ -765,7 +766,7 @@ void mutt_save_path(char *d, size_t dsize, struct Address *a) if ((p = strpbrk(d, "%@"))) *p = 0; } - mutt_strlower(d); + mutt_str_strlower(d); } else *d = 0; @@ -808,7 +809,7 @@ char *mutt_apply_replace(char *dbuf, size_t dlen, char *sbuf, struct ReplaceList src = twinbuf[switcher]; dst = src; - strfcpy(src, sbuf, LONG_STRING); + mutt_str_strfcpy(src, sbuf, LONG_STRING); for (l = rlist; l; l = l->next) { @@ -870,9 +871,9 @@ char *mutt_apply_replace(char *dbuf, size_t dlen, char *sbuf, struct ReplaceList } if (dbuf) - strfcpy(dbuf, dst, dlen); + mutt_str_strfcpy(dbuf, dst, dlen); else - dbuf = safe_strdup(dst); + dbuf = mutt_str_strdup(dst); return dbuf; } @@ -900,7 +901,7 @@ void mutt_expando_format(char *dest, size_t destlen, size_t col, int cols, char *recycler = NULL; char src2[STRING]; - strfcpy(src2, src, mutt_strlen(src) + 1); + mutt_str_strfcpy(src2, src, mutt_str_strlen(src) + 1); src = src2; prefix[0] = '\0'; @@ -913,7 +914,7 @@ void mutt_expando_format(char *dest, size_t destlen, size_t col, int cols, int off = -1; /* Do not consider filters if no pipe at end */ - n = mutt_strlen(src); + n = mutt_str_strlen(src); if (n > 1 && src[n - 1] == '|') { /* Scan backwards for backslashes */ @@ -1002,7 +1003,7 @@ void mutt_expando_format(char *dest, size_t destlen, size_t col, int cols, dest[n] = '\0'; /* remove '%' */ if ((n > 0) && dest[n - 1] != '%') { - recycler = safe_strdup(dest); + recycler = mutt_str_strdup(dest); if (recycler) { /* destlen is decremented at the start of this function @@ -1215,7 +1216,7 @@ void mutt_expando_format(char *dest, size_t destlen, size_t col, int cols, /* get contents after padding */ mutt_expando_format(buf, sizeof(buf), 0, cols, src + pl, callback, data, flags); - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); wid = mutt_strwidth(buf); pad = (cols - col - wid) / pw; @@ -1321,7 +1322,7 @@ void mutt_expando_format(char *dest, size_t destlen, size_t col, int cols, elsestring, data, flags); if (tolower) - mutt_strlower(buf); + mutt_str_strlower(buf); if (nodots) { char *p = buf; @@ -1330,7 +1331,7 @@ void mutt_expando_format(char *dest, size_t destlen, size_t col, int cols, *p = '_'; } - if ((len = mutt_strlen(buf)) + wlen > destlen) + if ((len = mutt_str_strlen(buf)) + wlen > destlen) len = mutt_wstr_trunc(buf, destlen - wlen, cols - col, NULL); memcpy(wptr, buf, len); @@ -1406,13 +1407,13 @@ FILE *mutt_open_read(const char *path, pid_t *thepid) FILE *f = NULL; struct stat s; - int len = mutt_strlen(path); + int len = mutt_str_strlen(path); if (path[len - 1] == '|') { /* read from a pipe */ - char *p = safe_strdup(path); + char *p = mutt_str_strdup(path); p[len - 1] = 0; mutt_endwin(NULL); @@ -1545,7 +1546,7 @@ const char *mutt_make_version(void) struct Regex *mutt_compile_regex(const char *s, int flags) { struct Regex *pp = mutt_mem_calloc(1, sizeof(struct Regex)); - pp->pattern = safe_strdup(s); + pp->pattern = mutt_str_strdup(s); pp->regex = mutt_mem_calloc(1, sizeof(regex_t)); if (REGCOMP(pp->regex, NONULL(s), flags) != 0) mutt_free_regex(&pp); @@ -1697,10 +1698,10 @@ bool mutt_match_spam_list(const char *s, struct ReplaceList *l, char *text, int void mutt_encode_path(char *dest, size_t dlen, const char *src) { - char *p = safe_strdup(src); + char *p = mutt_str_strdup(src); int rc = mutt_convert_string(&p, Charset, "utf-8", 0); /* `src' may be NULL, such as when called from the pop3 driver. */ - strfcpy(dest, (rc == 0) ? NONULL(p) : NONULL(src), dlen); + mutt_str_strfcpy(dest, (rc == 0) ? NONULL(p) : NONULL(src), dlen); FREE(&p); } @@ -1716,8 +1717,8 @@ void mutt_encode_path(char *dest, size_t dlen, const char *src) int mutt_set_xdg_path(enum XdgType type, char *buf, size_t bufsize) { char *xdg_env = getenv(xdg_env_vars[type]); - char *xdg = (xdg_env && *xdg_env) ? safe_strdup(xdg_env) : - safe_strdup(xdg_defaults[type]); + char *xdg = (xdg_env && *xdg_env) ? mutt_str_strdup(xdg_env) : + mutt_str_strdup(xdg_defaults[type]); char *x = xdg; /* strsep() changes xdg, so free x instead later */ char *token = NULL; int rc = 0; @@ -1756,12 +1757,12 @@ void mutt_get_parent_path(char *output, char *path, size_t olen) #endif #ifdef USE_NOTMUCH if (mx_is_notmuch(path)) - strfcpy(output, NONULL(Folder), olen); + mutt_str_strfcpy(output, NONULL(Folder), olen); else #endif { - strfcpy(output, path, olen); - int n = mutt_strlen(output); + mutt_str_strfcpy(output, path, olen); + int n = mutt_str_strlen(output); /* Remove everything until the next slash */ for (n--; ((n >= 0) && (output[n] != '/')); n--) @@ -1908,9 +1909,9 @@ int mutt_inbox_cmp(const char *a, const char *b) { /* fast-track in case the paths have been mutt_pretty_mailbox'ified */ if (a[0] == '=' && b[0] == '=') - return (mutt_strcasecmp(a + 1, "inbox") == 0) ? + return (mutt_str_strcasecmp(a + 1, "inbox") == 0) ? -1 : - (mutt_strcasecmp(b + 1, "inbox") == 0) ? 1 : 0; + (mutt_str_strcasecmp(b + 1, "inbox") == 0) ? 1 : 0; const char *a_end = strrchr(a, '/'); const char *b_end = strrchr(b, '/'); @@ -1928,15 +1929,15 @@ int mutt_inbox_cmp(const char *a, const char *b) size_t b_len = b_end - b; size_t min = MIN(a_len, b_len); int same = (a[min] == '/') && (b[min] == '/') && (a[min + 1] != '\0') && - (b[min + 1] != '\0') && (mutt_strncasecmp(a, b, min) == 0); + (b[min + 1] != '\0') && (mutt_str_strncasecmp(a, b, min) == 0); if (!same) return 0; - if (mutt_strcasecmp(&a[min + 1], "inbox") == 0) + if (mutt_str_strcasecmp(&a[min + 1], "inbox") == 0) return -1; - if (mutt_strcasecmp(&b[min + 1], "inbox") == 0) + if (mutt_str_strcasecmp(&b[min + 1], "inbox") == 0) return 1; return 0; diff --git a/mx.c b/mx.c index 1783d45c3..d3883d141 100644 --- a/mx.c +++ b/mx.c @@ -111,7 +111,7 @@ struct MxOps *mx_get_ops(int magic) static bool mutt_is_spool(const char *str) { - return (mutt_strcmp(SpoolFile, str) == 0); + return (mutt_str_strcmp(SpoolFile, str) == 0); } #ifdef USE_IMAP @@ -281,9 +281,9 @@ int mx_get_magic(const char *path) if (fgets(tmp, sizeof(tmp), f)) { - if (mutt_strncmp("From ", tmp, 5) == 0) + if (mutt_str_strncmp("From ", tmp, 5) == 0) magic = MUTT_MBOX; - else if (mutt_strcmp(MMDF_SEP, tmp) == 0) + else if (mutt_str_strcmp(MMDF_SEP, tmp) == 0) magic = MUTT_MMDF; } mutt_file_fclose(&f); @@ -319,13 +319,13 @@ int mx_get_magic(const char *path) */ int mx_set_magic(const char *s) { - if (mutt_strcasecmp(s, "mbox") == 0) + if (mutt_str_strcasecmp(s, "mbox") == 0) MboxType = MUTT_MBOX; - else if (mutt_strcasecmp(s, "mmdf") == 0) + else if (mutt_str_strcasecmp(s, "mmdf") == 0) MboxType = MUTT_MMDF; - else if (mutt_strcasecmp(s, "mh") == 0) + else if (mutt_str_strcasecmp(s, "mh") == 0) MboxType = MUTT_MH; - else if (mutt_strcasecmp(s, "maildir") == 0) + else if (mutt_str_strcasecmp(s, "maildir") == 0) MboxType = MUTT_MAILDIR; else return -1; @@ -417,7 +417,7 @@ struct Context *mx_open_mailbox(const char *path, int flags, struct Context *pct ctx = mutt_mem_malloc(sizeof(struct Context)); memset(ctx, 0, sizeof(struct Context)); - ctx->path = safe_strdup(path); + ctx->path = mutt_str_strdup(path); if (!ctx->path) { if (!pctx) @@ -426,7 +426,7 @@ struct Context *mx_open_mailbox(const char *path, int flags, struct Context *pct } ctx->realpath = realpath(ctx->path, NULL); if (!ctx->realpath) - ctx->realpath = safe_strdup(ctx->path); + ctx->realpath = mutt_str_strdup(ctx->path); ctx->msgnotreadyet = -1; ctx->collapsed = false; @@ -699,11 +699,11 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint) if ((p = mutt_find_hook(MUTT_MBOXHOOK, ctx->path))) { isSpool = 1; - strfcpy(mbox, p, sizeof(mbox)); + mutt_str_strfcpy(mbox, p, sizeof(mbox)); } else { - strfcpy(mbox, NONULL(Mbox), sizeof(mbox)); + mutt_str_strfcpy(mbox, NONULL(Mbox), sizeof(mbox)); isSpool = mutt_is_spool(ctx->path) && !mutt_is_spool(mbox); } @@ -818,7 +818,7 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint) } /* copy mails to the trash before expunging */ - if (purge && ctx->deleted && (mutt_strcmp(ctx->path, Trash) != 0)) + if (purge && ctx->deleted && (mutt_str_strcmp(ctx->path, Trash) != 0)) { if (trash_append(ctx) != 0) { @@ -1002,7 +1002,7 @@ int mx_sync_mailbox(struct Context *ctx, int *index_hint) if (km_expand_key(buf, sizeof(buf), km_find_func(MENU_MAIN, OP_TOGGLE_WRITE))) snprintf(tmp, sizeof(tmp), _(" Press '%s' to toggle write"), buf); else - strfcpy(tmp, _("Use 'toggle-write' to re-enable write!"), sizeof(tmp)); + mutt_str_strfcpy(tmp, _("Use 'toggle-write' to re-enable write!"), sizeof(tmp)); mutt_error(_("Mailbox is marked unwritable. %s"), tmp); return -1; @@ -1055,7 +1055,7 @@ int mx_sync_mailbox(struct Context *ctx, int *index_hint) msgcount = ctx->msgcount; deleted = ctx->deleted; - if (purge && ctx->deleted && (mutt_strcmp(ctx->path, Trash) != 0)) + if (purge && ctx->deleted && (mutt_str_strcmp(ctx->path, Trash) != 0)) { if (trash_append(ctx) != 0) return -1; diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index bca944a5d..d8d678148 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -149,7 +149,7 @@ int mutt_protect(struct Header *msg, char *keylist) if ((WithCrypto & APPLICATION_PGP) && ((msg->security & PGPINLINE) == PGPINLINE)) { if ((msg->content->type != TYPETEXT) || - (mutt_strcasecmp(msg->content->subtype, "plain") != 0)) + (mutt_str_strcasecmp(msg->content->subtype, "plain") != 0)) { if (query_quadoption(OPT_PGP_MIME_AUTO, _("Inline PGP can't be used with attachments. " @@ -160,8 +160,8 @@ int mutt_protect(struct Header *msg, char *keylist) return -1; } } - else if (!mutt_strcasecmp("flowed", - mutt_get_parameter("format", msg->content->parameter))) + else if (!mutt_str_strcasecmp( + "flowed", mutt_get_parameter("format", msg->content->parameter))) { if ((query_quadoption(OPT_PGP_MIME_AUTO, _("Inline PGP can't be used with format=flowed. " @@ -316,25 +316,25 @@ int mutt_is_multipart_signed(struct Body *b) char *p = NULL; if (!b || !(b->type == TYPEMULTIPART) || !b->subtype || - (mutt_strcasecmp(b->subtype, "signed") != 0)) + (mutt_str_strcasecmp(b->subtype, "signed") != 0)) return 0; p = mutt_get_parameter("protocol", b->parameter); if (!p) return 0; - if (!(mutt_strcasecmp(p, "multipart/mixed") != 0)) + if (!(mutt_str_strcasecmp(p, "multipart/mixed") != 0)) return SIGN; if ((WithCrypto & APPLICATION_PGP) && - !(mutt_strcasecmp(p, "application/pgp-signature") != 0)) + !(mutt_str_strcasecmp(p, "application/pgp-signature") != 0)) return PGPSIGN; if ((WithCrypto & APPLICATION_SMIME) && - !(mutt_strcasecmp(p, "application/x-pkcs7-signature") != 0)) + !(mutt_str_strcasecmp(p, "application/x-pkcs7-signature") != 0)) return SMIMESIGN; if ((WithCrypto & APPLICATION_SMIME) && - !(mutt_strcasecmp(p, "application/pkcs7-signature") != 0)) + !(mutt_str_strcasecmp(p, "application/pkcs7-signature") != 0)) return SMIMESIGN; return 0; @@ -347,9 +347,9 @@ int mutt_is_multipart_encrypted(struct Body *b) char *p = NULL; if (!b || b->type != TYPEMULTIPART || !b->subtype || - (mutt_strcasecmp(b->subtype, "encrypted") != 0) || + (mutt_str_strcasecmp(b->subtype, "encrypted") != 0) || !(p = mutt_get_parameter("protocol", b->parameter)) || - (mutt_strcasecmp(p, "application/pgp-encrypted") != 0)) + (mutt_str_strcasecmp(p, "application/pgp-encrypted") != 0)) return 0; return PGPENCRYPT; @@ -365,12 +365,12 @@ int mutt_is_valid_multipart_pgp_encrypted(struct Body *b) b = b->parts; if (!b || b->type != TYPEAPPLICATION || !b->subtype || - (mutt_strcasecmp(b->subtype, "pgp-encrypted") != 0)) + (mutt_str_strcasecmp(b->subtype, "pgp-encrypted") != 0)) return 0; b = b->next; if (!b || b->type != TYPEAPPLICATION || !b->subtype || - (mutt_strcasecmp(b->subtype, "octet-stream") != 0)) + (mutt_str_strcasecmp(b->subtype, "octet-stream") != 0)) return 0; return PGPENCRYPT; @@ -395,22 +395,22 @@ int mutt_is_malformed_multipart_pgp_encrypted(struct Body *b) return 0; if (!b || b->type != TYPEMULTIPART || !b->subtype || - (mutt_strcasecmp(b->subtype, "mixed") != 0)) + (mutt_str_strcasecmp(b->subtype, "mixed") != 0)) return 0; b = b->parts; if (!b || b->type != TYPETEXT || !b->subtype || - (mutt_strcasecmp(b->subtype, "plain") != 0) || b->length != 0) + (mutt_str_strcasecmp(b->subtype, "plain") != 0) || b->length != 0) return 0; b = b->next; if (!b || b->type != TYPEAPPLICATION || !b->subtype || - (mutt_strcasecmp(b->subtype, "pgp-encrypted") != 0)) + (mutt_str_strcasecmp(b->subtype, "pgp-encrypted") != 0)) return 0; b = b->next; if (!b || b->type != TYPEAPPLICATION || !b->subtype || - (mutt_strcasecmp(b->subtype, "octet-stream") != 0)) + (mutt_str_strcasecmp(b->subtype, "octet-stream") != 0)) return 0; b = b->next; @@ -427,38 +427,38 @@ int mutt_is_application_pgp(struct Body *m) if (m->type == TYPEAPPLICATION) { - if ((mutt_strcasecmp(m->subtype, "pgp") == 0) || - (mutt_strcasecmp(m->subtype, "x-pgp-message") == 0)) + if ((mutt_str_strcasecmp(m->subtype, "pgp") == 0) || + (mutt_str_strcasecmp(m->subtype, "x-pgp-message") == 0)) { if ((p = mutt_get_parameter("x-action", m->parameter)) && - ((mutt_strcasecmp(p, "sign") == 0) || - (mutt_strcasecmp(p, "signclear") == 0))) + ((mutt_str_strcasecmp(p, "sign") == 0) || + (mutt_str_strcasecmp(p, "signclear") == 0))) t |= PGPSIGN; if ((p = mutt_get_parameter("format", m->parameter)) && - (mutt_strcasecmp(p, "keys-only") == 0)) + (mutt_str_strcasecmp(p, "keys-only") == 0)) t |= PGPKEY; if (!t) t |= PGPENCRYPT; /* not necessarily correct, but... */ } - if (mutt_strcasecmp(m->subtype, "pgp-signed") == 0) + if (mutt_str_strcasecmp(m->subtype, "pgp-signed") == 0) t |= PGPSIGN; - if (mutt_strcasecmp(m->subtype, "pgp-keys") == 0) + if (mutt_str_strcasecmp(m->subtype, "pgp-keys") == 0) t |= PGPKEY; } - else if (m->type == TYPETEXT && (mutt_strcasecmp("plain", m->subtype) == 0)) + else if (m->type == TYPETEXT && (mutt_str_strcasecmp("plain", m->subtype) == 0)) { if (((p = mutt_get_parameter("x-mutt-action", m->parameter)) || (p = mutt_get_parameter("x-action", m->parameter)) || (p = mutt_get_parameter("action", m->parameter))) && - (mutt_strncasecmp("pgp-sign", p, 8) == 0)) + (mutt_str_strncasecmp("pgp-sign", p, 8) == 0)) t |= PGPSIGN; - else if (p && (mutt_strncasecmp("pgp-encrypt", p, 11) == 0)) + else if (p && (mutt_str_strncasecmp("pgp-encrypt", p, 11) == 0)) t |= PGPENCRYPT; - else if (p && (mutt_strncasecmp("pgp-keys", p, 7) == 0)) + else if (p && (mutt_str_strncasecmp("pgp-keys", p, 7) == 0)) t |= PGPKEY; } if (t) @@ -479,14 +479,14 @@ int mutt_is_application_smime(struct Body *m) if ((m->type & TYPEAPPLICATION) && m->subtype) { /* S/MIME MIME types don't need x- anymore, see RFC2311 */ - if ((mutt_strcasecmp(m->subtype, "x-pkcs7-mime") == 0) || - (mutt_strcasecmp(m->subtype, "pkcs7-mime") == 0)) + if ((mutt_str_strcasecmp(m->subtype, "x-pkcs7-mime") == 0) || + (mutt_str_strcasecmp(m->subtype, "pkcs7-mime") == 0)) { if ((t = mutt_get_parameter("smime-type", m->parameter))) { - if (mutt_strcasecmp(t, "enveloped-data") == 0) + if (mutt_str_strcasecmp(t, "enveloped-data") == 0) return SMIMEENCRYPT; - else if (mutt_strcasecmp(t, "signed-data") == 0) + else if (mutt_str_strcasecmp(t, "signed-data") == 0) return (SMIMESIGN | SMIMEOPAQUE); else return 0; @@ -495,11 +495,11 @@ int mutt_is_application_smime(struct Body *m) * Content-Description: S/MIME Encrypted Message * instead of Content-Type parameter */ - if (mutt_strcasecmp(m->description, "S/MIME Encrypted Message") == 0) + if (mutt_str_strcasecmp(m->description, "S/MIME Encrypted Message") == 0) return SMIMEENCRYPT; complain = true; } - else if (mutt_strcasecmp(m->subtype, "octet-stream") != 0) + else if (mutt_str_strcasecmp(m->subtype, "octet-stream") != 0) return 0; t = mutt_get_parameter("name", m->parameter); @@ -518,15 +518,15 @@ int mutt_is_application_smime(struct Body *m) /* no .p7c, .p10 support yet. */ - len = mutt_strlen(t) - 4; + len = mutt_str_strlen(t) - 4; if (len > 0 && *(t + len) == '.') { len++; - if (mutt_strcasecmp((t + len), "p7m") == 0) + if (mutt_str_strcasecmp((t + len), "p7m") == 0) /* Not sure if this is the correct thing to do, but it's required for compatibility with Outlook */ return (SMIMESIGN | SMIMEOPAQUE); - else if (mutt_strcasecmp((t + len), "p7s") == 0) + else if (mutt_str_strcasecmp((t + len), "p7s") == 0) return (SMIMESIGN | SMIMEOPAQUE); } } @@ -670,7 +670,7 @@ void convert_to_7bit(struct Body *a) convert_to_7bit(a->parts); } else if (a->type == TYPEMESSAGE && - (mutt_strcasecmp(a->subtype, "delivery-status") != 0)) + (mutt_str_strcasecmp(a->subtype, "delivery-status") != 0)) { if (a->encoding != ENC7BIT) mutt_message_to_7bit(a, NULL); @@ -869,8 +869,8 @@ int crypt_get_keys(struct Header *msg, char **keylist, int oppenc_mode) if (!oppenc_mode && self_encrypt && *self_encrypt) { - keylist_size = mutt_strlen(*keylist); - mutt_mem_realloc(keylist, keylist_size + mutt_strlen(self_encrypt) + 2); + keylist_size = mutt_str_strlen(*keylist); + mutt_mem_realloc(keylist, keylist_size + mutt_str_strlen(self_encrypt) + 2); sprintf(*keylist + keylist_size, " %s", self_encrypt); } @@ -963,18 +963,18 @@ int mutt_signed_handler(struct Body *a, struct State *s) { case SIGN: if (a->next->type != TYPEMULTIPART || - (mutt_strcasecmp(a->next->subtype, "mixed") != 0)) + (mutt_str_strcasecmp(a->next->subtype, "mixed") != 0)) inconsistent = true; break; case PGPSIGN: if (a->next->type != TYPEAPPLICATION || - (mutt_strcasecmp(a->next->subtype, "pgp-signature") != 0)) + (mutt_str_strcasecmp(a->next->subtype, "pgp-signature") != 0)) inconsistent = true; break; case SMIMESIGN: if (a->next->type != TYPEAPPLICATION || - ((mutt_strcasecmp(a->next->subtype, "x-pkcs7-signature") != 0) && - (mutt_strcasecmp(a->next->subtype, "pkcs7-signature") != 0))) + ((mutt_str_strcasecmp(a->next->subtype, "x-pkcs7-signature") != 0) && + (mutt_str_strcasecmp(a->next->subtype, "pkcs7-signature") != 0))) inconsistent = true; break; default: @@ -1001,7 +1001,7 @@ int mutt_signed_handler(struct Body *a, struct State *s) for (int i = 0; i < sigcnt; i++) { if ((WithCrypto & APPLICATION_PGP) && signatures[i]->type == TYPEAPPLICATION && - (mutt_strcasecmp(signatures[i]->subtype, "pgp-signature") == 0)) + (mutt_str_strcasecmp(signatures[i]->subtype, "pgp-signature") == 0)) { if (crypt_pgp_verify_one(signatures[i], s, tempfile) != 0) goodsig = false; @@ -1010,8 +1010,10 @@ int mutt_signed_handler(struct Body *a, struct State *s) } if ((WithCrypto & APPLICATION_SMIME) && signatures[i]->type == TYPEAPPLICATION && - ((mutt_strcasecmp(signatures[i]->subtype, "x-pkcs7-signature") == 0) || - (mutt_strcasecmp(signatures[i]->subtype, "pkcs7-signature") == 0))) + ((mutt_str_strcasecmp(signatures[i]->subtype, + "x-pkcs7-signature") == 0) || + (mutt_str_strcasecmp(signatures[i]->subtype, + "pkcs7-signature") == 0))) { if (crypt_smime_verify_one(signatures[i], s, tempfile) != 0) goodsig = false; @@ -1079,8 +1081,8 @@ const char *crypt_get_fingerprint_or_id(char *p, const char **pphint, * if an ID was found and to simplify logic in the key loop's inner * condition of the caller. */ - pf = mutt_skip_whitespace(p); - if (mutt_strncasecmp(pf, "0x", 2) == 0) + pf = mutt_str_skip_whitespace(p); + if (mutt_str_strncasecmp(pf, "0x", 2) == 0) pf += 2; /* Check if a fingerprint is given, must be hex digits only, blanks @@ -1108,7 +1110,7 @@ const char *crypt_get_fingerprint_or_id(char *p, const char **pphint, } while (c); /* If at end of input, check for correct fingerprint length and copy if. */ - pfcopy = (!c && ((hexdigits == 40) || (hexdigits == 32)) ? safe_strdup(pf) : NULL); + pfcopy = (!c && ((hexdigits == 40) || (hexdigits == 32)) ? mutt_str_strdup(pf) : NULL); if (pfcopy) { @@ -1116,7 +1118,7 @@ const char *crypt_get_fingerprint_or_id(char *p, const char **pphint, s1 = s2 = pfcopy; do { - *(s1++) = *(s2 = mutt_skip_whitespace(s2)); + *(s1++) = *(s2 = mutt_str_skip_whitespace(s2)); } while (*(s2++)); phint = pfcopy; @@ -1128,9 +1130,9 @@ const char *crypt_get_fingerprint_or_id(char *p, const char **pphint, ps = pl = NULL; if (isid == 1) { - if (mutt_strlen(pf) == 16) + if (mutt_str_strlen(pf) == 16) pl = pf; /* long key ID */ - else if (mutt_strlen(pf) == 8) + else if (mutt_str_strlen(pf) == 8) ps = pf; /* short key ID */ } } diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 6c0cff50c..07d29d92b 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -132,7 +132,7 @@ static char *current_sender = NULL; static bool is_pka_notation(gpgme_sig_notation_t notation) { - return (mutt_strcmp(notation->name, PKA_NOTATION_NAME) == 0); + return (mutt_str_strcmp(notation->name, PKA_NOTATION_NAME) == 0); } /** @@ -440,13 +440,13 @@ static int crypt_id_matches_addr(struct Address *addr, struct Address *u_addr, if (addr && u_addr) { if (addr->mailbox && u_addr->mailbox && - (mutt_strcasecmp(addr->mailbox, u_addr->mailbox) == 0)) + (mutt_str_strcasecmp(addr->mailbox, u_addr->mailbox) == 0)) { rv |= CRYPT_KV_ADDR; } if (addr->personal && u_addr->personal && - (mutt_strcasecmp(addr->personal, u_addr->personal) == 0)) + (mutt_str_strcasecmp(addr->personal, u_addr->personal) == 0)) { rv |= CRYPT_KV_STRING; } @@ -696,7 +696,7 @@ static char *data_object_to_tempfile(gpgme_data_t data, char *tempf, FILE **ret_ } if (ret_fp) *ret_fp = fp; - return safe_strdup(tempf); + return mutt_str_strdup(tempf); } static void free_recipient_set(gpgme_key_t **p_rset) @@ -1056,7 +1056,7 @@ static struct Body *sign_message(struct Body *a, int use_smime) t = mutt_new_body(); t->type = TYPEMULTIPART; - t->subtype = safe_strdup("signed"); + t->subtype = mutt_str_strdup("signed"); t->encoding = ENC7BIT; t->use_disp = false; t->disposition = DISPINLINE; @@ -1082,16 +1082,16 @@ static struct Body *sign_message(struct Body *a, int use_smime) t->type = TYPEAPPLICATION; if (use_smime) { - t->subtype = safe_strdup("pkcs7-signature"); + t->subtype = mutt_str_strdup("pkcs7-signature"); mutt_set_parameter("name", "smime.p7s", &t->parameter); t->encoding = ENCBASE64; t->use_disp = true; t->disposition = DISPATTACH; - t->d_filename = safe_strdup("smime.p7s"); + t->d_filename = mutt_str_strdup("smime.p7s"); } else { - t->subtype = safe_strdup("pgp-signature"); + t->subtype = mutt_str_strdup("pgp-signature"); mutt_set_parameter("name", "signature.asc", &t->parameter); t->use_disp = false; t->disposition = DISPNONE; @@ -1151,7 +1151,7 @@ struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, int sign) t = mutt_new_body(); t->type = TYPEMULTIPART; - t->subtype = safe_strdup("encrypted"); + t->subtype = mutt_str_strdup("encrypted"); t->encoding = ENC7BIT; t->use_disp = false; t->disposition = DISPINLINE; @@ -1161,18 +1161,18 @@ struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, int sign) t->parts = mutt_new_body(); t->parts->type = TYPEAPPLICATION; - t->parts->subtype = safe_strdup("pgp-encrypted"); + t->parts->subtype = mutt_str_strdup("pgp-encrypted"); t->parts->encoding = ENC7BIT; t->parts->next = mutt_new_body(); t->parts->next->type = TYPEAPPLICATION; - t->parts->next->subtype = safe_strdup("octet-stream"); + t->parts->next->subtype = mutt_str_strdup("octet-stream"); t->parts->next->encoding = ENC7BIT; t->parts->next->filename = outfile; t->parts->next->use_disp = true; t->parts->next->disposition = DISPATTACH; t->parts->next->unlink = true; /* delete after sending the message */ - t->parts->next->d_filename = safe_strdup("msg.asc"); /* non pgp/mime + t->parts->next->d_filename = mutt_str_strdup("msg.asc"); /* non pgp/mime can save */ return t; @@ -1218,13 +1218,13 @@ struct Body *smime_gpgme_build_smime_entity(struct Body *a, char *keylist) t = mutt_new_body(); t->type = TYPEAPPLICATION; - t->subtype = safe_strdup("pkcs7-mime"); + t->subtype = mutt_str_strdup("pkcs7-mime"); mutt_set_parameter("name", "smime.p7m", &t->parameter); mutt_set_parameter("smime-type", "enveloped-data", &t->parameter); t->encoding = ENCBASE64; /* The output of OpenSSL SHOULD be binary */ t->use_disp = true; t->disposition = DISPATTACH; - t->d_filename = safe_strdup("smime.p7m"); + t->d_filename = mutt_str_strdup("smime.p7m"); t->filename = outfile; t->unlink = true; /* delete after sending the message */ t->parts = 0; @@ -2236,7 +2236,7 @@ static int pgp_gpgme_extract_keys(gpgme_data_t keydata, FILE **fp, int dryrun) while (subkey) { shortid = subkey->keyid; - len = mutt_strlen(subkey->keyid); + len = mutt_str_strlen(subkey->keyid); if (len > 8) shortid += len - 8; tt = subkey->timestamp; @@ -2286,7 +2286,7 @@ err_ctx: */ static int line_compare(const char *a, size_t n, const char *b) { - if (mutt_strncmp(a, b, n) == 0) + if (mutt_str_strncmp(a, b, n) == 0) { /* at this point we know that 'b' is at least 'n' chars long */ if (b[n] == '\n' || (b[n] == '\r' && b[n + 1] == '\n')) @@ -2333,7 +2333,7 @@ static int pgp_check_traditional_one_body(FILE *fp, struct Body *b) while (fgets(buf, sizeof(buf), tfp)) { - if (mutt_strncmp("-----BEGIN PGP ", buf, 15) == 0) + if (mutt_str_strncmp("-----BEGIN PGP ", buf, 15) == 0) { if (MESSAGE(buf + 15)) { @@ -2514,7 +2514,7 @@ int pgp_gpgme_application_handler(struct Body *m, struct State *s) but we know that this may only be text thus we assume Latin-1 here. */ if (!mutt_get_body_charset(body_charset, sizeof(body_charset), m)) - strfcpy(body_charset, "iso-8859-1", sizeof(body_charset)); + mutt_str_strfcpy(body_charset, "iso-8859-1", sizeof(body_charset)); fseeko(s->fpin, m->offset, SEEK_SET); last_pos = m->offset; @@ -2525,10 +2525,10 @@ int pgp_gpgme_application_handler(struct Body *m, struct State *s) break; offset = ftello(s->fpin); - bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */ + bytes -= (offset - last_pos); /* don't rely on mutt_str_strlen(buf) */ last_pos = offset; - if (mutt_strncmp("-----BEGIN PGP ", buf, 15) == 0) + if (mutt_str_strncmp("-----BEGIN PGP ", buf, 15) == 0) { clearsign = false; @@ -3133,10 +3133,10 @@ static int compare_key_address(const void *a, const void *b) struct CryptKeyInfo **t = (struct CryptKeyInfo **) b; int r; - if ((r = mutt_strcasecmp((*s)->uid, (*t)->uid))) + if ((r = mutt_str_strcasecmp((*s)->uid, (*t)->uid))) return r > 0; else - return (mutt_strcasecmp(crypt_fpr_or_lkeyid(*s), crypt_fpr_or_lkeyid(*t)) > 0); + return (mutt_str_strcasecmp(crypt_fpr_or_lkeyid(*s), crypt_fpr_or_lkeyid(*t)) > 0); } static int crypt_compare_address(const void *a, const void *b) @@ -3154,10 +3154,10 @@ static int compare_keyid(const void *a, const void *b) struct CryptKeyInfo **t = (struct CryptKeyInfo **) b; int r; - if ((r = mutt_strcasecmp(crypt_fpr_or_lkeyid(*s), crypt_fpr_or_lkeyid(*t)))) + if ((r = mutt_str_strcasecmp(crypt_fpr_or_lkeyid(*s), crypt_fpr_or_lkeyid(*t)))) return r > 0; else - return (mutt_strcasecmp((*s)->uid, (*t)->uid) > 0); + return (mutt_str_strcasecmp((*s)->uid, (*t)->uid) > 0); } static int crypt_compare_keyid(const void *a, const void *b) @@ -3184,7 +3184,7 @@ static int compare_key_date(const void *a, const void *b) if (ts < tt) return 0; - return (mutt_strcasecmp((*s)->uid, (*t)->uid) > 0); + return (mutt_str_strcasecmp((*s)->uid, (*t)->uid) > 0); } static int crypt_compare_date(const void *a, const void *b) @@ -3229,9 +3229,9 @@ static int compare_key_trust(const void *a, const void *b) if (ts < tt) return 0; - if ((r = mutt_strcasecmp((*s)->uid, (*t)->uid))) + if ((r = mutt_str_strcasecmp((*s)->uid, (*t)->uid))) return r > 0; - return (mutt_strcasecmp(crypt_fpr_or_lkeyid((*s)), crypt_fpr_or_lkeyid((*t))) > 0); + return (mutt_str_strcasecmp(crypt_fpr_or_lkeyid((*s)), crypt_fpr_or_lkeyid((*t))) > 0); } static int crypt_compare_trust(const void *a, const void *b) @@ -3583,7 +3583,7 @@ static void print_key_info(gpgme_key_t key, FILE *fp) { for (int i = 0; i < KIP_END; i++) { - KeyInfoPadding[i] = mutt_strlen(_(KeyInfoPrompts[i])); + KeyInfoPadding[i] = mutt_str_strlen(_(KeyInfoPrompts[i])); width = mutt_strwidth(_(KeyInfoPrompts[i])); if (max_header_width < width) max_header_width = width; @@ -3997,7 +3997,7 @@ static struct CryptKeyInfo *get_candidates(struct ListHead *hints, unsigned int STAILQ_FOREACH(np, hints, entries) { if (np->data && *np->data) - patarr[n++] = safe_strdup(np->data); + patarr[n++] = mutt_str_strdup(np->data); } patarr[n] = NULL; err = gpgme_op_keylist_ext_start(ctx, (const char **) patarr, secret, 0); @@ -4106,14 +4106,14 @@ static void crypt_add_string_to_hints(struct ListHead *hints, const char *str) char *scratch = NULL; char *t = NULL; - scratch = safe_strdup(str); + scratch = mutt_str_strdup(str); if (!scratch) return; for (t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n")) { if (strlen(t) > 3) - mutt_list_insert_tail(hints, safe_strdup(t)); + mutt_list_insert_tail(hints, mutt_str_strdup(t)); } FREE(&scratch); @@ -4483,10 +4483,10 @@ static struct CryptKeyInfo *crypt_getkeybystr(char *p, short abilities, "key %s, \"%s\": ", p, crypt_long_keyid(k), k->uid); - if (!*p || (pfcopy && (mutt_strcasecmp(pfcopy, crypt_fpr(k)) == 0)) || - (pl && (mutt_strcasecmp(pl, crypt_long_keyid(k)) == 0)) || - (ps && (mutt_strcasecmp(ps, crypt_short_keyid(k)) == 0)) || - mutt_stristr(k->uid, p)) + if (!*p || (pfcopy && (mutt_str_strcasecmp(pfcopy, crypt_fpr(k)) == 0)) || + (pl && (mutt_str_strcasecmp(pl, crypt_long_keyid(k)) == 0)) || + (ps && (mutt_str_strcasecmp(ps, crypt_short_keyid(k)) == 0)) || + mutt_str_stristr(k->uid, p)) { struct CryptKeyInfo *tmp = NULL; @@ -4541,9 +4541,9 @@ static struct CryptKeyInfo *crypt_ask_for_key(char *tag, char *whatfor, short ab if (whatfor) { for (l = id_defaults; l; l = l->next) - if (mutt_strcasecmp(whatfor, l->what) == 0) + if (mutt_str_strcasecmp(whatfor, l->what) == 0) { - strfcpy(resp, NONULL(l->dflt), sizeof(resp)); + mutt_str_strfcpy(resp, NONULL(l->dflt), sizeof(resp)); break; } } @@ -4563,8 +4563,8 @@ static struct CryptKeyInfo *crypt_ask_for_key(char *tag, char *whatfor, short ab l = mutt_mem_malloc(sizeof(struct CryptCache)); l->next = id_defaults; id_defaults = l; - l->what = safe_strdup(whatfor); - l->dflt = safe_strdup(resp); + l->what = mutt_str_strdup(whatfor); + l->dflt = mutt_str_strdup(resp); } } @@ -4686,11 +4686,11 @@ static char *find_keys(struct Address *adrlist, unsigned int app, int oppenc_mod keyID = crypt_fpr_or_lkeyid(k_info); bypass_selection: - keylist_size += mutt_strlen(keyID) + 4 + 1; + keylist_size += mutt_str_strlen(keyID) + 4 + 1; mutt_mem_realloc(&keylist, keylist_size); sprintf(keylist + keylist_used, "%s0x%s%s", keylist_used ? " " : "", keyID, forced_valid ? "!" : ""); - keylist_used = mutt_strlen(keylist); + keylist_used = mutt_str_strlen(keylist); key_selected = true; @@ -4758,13 +4758,13 @@ struct Body *pgp_gpgme_make_key_attachment(char *tempf) att->unlink = true; att->use_disp = false; att->type = TYPEAPPLICATION; - att->subtype = safe_strdup("pgp-keys"); + att->subtype = mutt_str_strdup("pgp-keys"); /* L10N: MIME description for exported (attached) keys. You can translate this entry to a non-ASCII string (it will be encoded), but it may be safer to keep it untranslated. */ snprintf(buff, sizeof(buff), _("PGP Key 0x%s."), crypt_keyid(key)); - att->description = safe_strdup(buff); + att->description = mutt_str_strdup(buff); mutt_update_encoding(att); stat(tempf, &sb); @@ -5087,5 +5087,5 @@ int smime_gpgme_verify_sender(struct Header *h) void mutt_gpgme_set_sender(const char *sender) { FREE(¤t_sender); - current_sender = safe_strdup(sender); + current_sender = mutt_str_strdup(sender); } diff --git a/ncrypt/gnupgparse.c b/ncrypt/gnupgparse.c index 6ea64c4ee..8cf979a83 100644 --- a/ncrypt/gnupgparse.c +++ b/ncrypt/gnupgparse.c @@ -162,17 +162,17 @@ static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKe { mutt_debug(2, "record type: %s\n", p); - if (mutt_strcmp(p, "pub") == 0) + if (mutt_str_strcmp(p, "pub") == 0) is_pub = true; - else if (mutt_strcmp(p, "sub") == 0) + else if (mutt_str_strcmp(p, "sub") == 0) *is_subkey = 1; - else if (mutt_strcmp(p, "sec") == 0) + else if (mutt_str_strcmp(p, "sec") == 0) ; - else if (mutt_strcmp(p, "ssb") == 0) + else if (mutt_str_strcmp(p, "ssb") == 0) *is_subkey = 1; - else if (mutt_strcmp(p, "uid") == 0) + else if (mutt_str_strcmp(p, "uid") == 0) is_uid = true; - else if (mutt_strcmp(p, "fpr") == 0) + else if (mutt_str_strcmp(p, "fpr") == 0) is_fpr = true; else return NULL; @@ -220,7 +220,8 @@ static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKe { mutt_debug(2, "key len: %s\n", p); - if (!(*is_subkey && option(OPT_PGP_IGNORE_SUBKEYS)) && mutt_atos(p, &tmp.keylen) < 0) + if (!(*is_subkey && option(OPT_PGP_IGNORE_SUBKEYS)) && + mutt_str_atos(p, &tmp.keylen) < 0) goto bail; break; } @@ -231,7 +232,7 @@ static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKe if (!(*is_subkey && option(OPT_PGP_IGNORE_SUBKEYS))) { int x = 0; - if (mutt_atoi(p, &x) < 0) + if (mutt_str_atoi(p, &x) < 0) goto bail; tmp.numalg = x; tmp.algorithm = pgp_pkalgbytype(x); @@ -261,19 +262,19 @@ static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKe strncpy(tstr, p, 11); tstr[4] = '\0'; tstr[7] = '\0'; - if (mutt_atoi(tstr, &time.tm_year) < 0) + if (mutt_str_atoi(tstr, &time.tm_year) < 0) { p = tstr; goto bail; } time.tm_year -= 1900; - if (mutt_atoi(tstr + 5, &time.tm_mon) < 0) + if (mutt_str_atoi(tstr + 5, &time.tm_mon) < 0) { p = tstr + 5; goto bail; } time.tm_mon -= 1; - if (mutt_atoi(tstr + 8, &time.tm_mday) < 0) + if (mutt_str_atoi(tstr + 8, &time.tm_mday) < 0) { p = tstr + 8; goto bail; @@ -302,7 +303,7 @@ static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKe { /* don't let a subkey fpr overwrite an existing primary key fpr */ if (!tmp.fingerprint) - tmp.fingerprint = safe_strdup(p); + tmp.fingerprint = mutt_str_strdup(p); break; } @@ -314,7 +315,7 @@ static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKe uid = mutt_mem_calloc(1, sizeof(struct PgpUid)); fix_uid(p); - uid->addr = safe_strdup(p); + uid->addr = mutt_str_strdup(p); uid->trust = trust; uid->flags |= flags; uid->next = tmp.address; diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 29b20322d..511712e04 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -300,12 +300,12 @@ static void pgp_copy_clearsigned(FILE *fpin, struct State *s, char *charset) continue; } - if (mutt_strcmp(buf, "-----BEGIN PGP SIGNATURE-----\n") == 0) + if (mutt_str_strcmp(buf, "-----BEGIN PGP SIGNATURE-----\n") == 0) break; if (armor_header) { - char *p = mutt_skip_whitespace(buf); + char *p = mutt_str_skip_whitespace(buf); if (*p == '\0') armor_header = false; continue; @@ -361,21 +361,21 @@ int pgp_application_pgp_handler(struct Body *m, struct State *s) break; offset = ftello(s->fpin); - bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */ + bytes -= (offset - last_pos); /* don't rely on mutt_str_strlen(buf) */ last_pos = offset; - if (mutt_strncmp("-----BEGIN PGP ", buf, 15) == 0) + if (mutt_str_strncmp("-----BEGIN PGP ", buf, 15) == 0) { clearsign = false; - if (mutt_strcmp("MESSAGE-----\n", buf + 15) == 0) + if (mutt_str_strcmp("MESSAGE-----\n", buf + 15) == 0) needpass = 1; - else if (mutt_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0) + else if (mutt_str_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0) { clearsign = true; needpass = 0; } - else if (mutt_strcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) + else if (mutt_str_strcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) { needpass = 0; pgp_keyblock = true; @@ -405,22 +405,23 @@ int pgp_application_pgp_handler(struct Body *m, struct State *s) while (bytes > 0 && fgets(buf, sizeof(buf) - 1, s->fpin) != NULL) { offset = ftello(s->fpin); - bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */ + bytes -= (offset - last_pos); /* don't rely on mutt_str_strlen(buf) */ last_pos = offset; fputs(buf, tmpfp); - if ((needpass && (mutt_strcmp("-----END PGP MESSAGE-----\n", buf) == 0)) || - (!needpass && ((mutt_strcmp("-----END PGP SIGNATURE-----\n", buf) == 0) || - (mutt_strcmp("-----END PGP PUBLIC KEY BLOCK-----\n", buf) == 0)))) + if ((needpass && (mutt_str_strcmp("-----END PGP MESSAGE-----\n", buf) == 0)) || + (!needpass && + ((mutt_str_strcmp("-----END PGP SIGNATURE-----\n", buf) == 0) || + (mutt_str_strcmp("-----END PGP PUBLIC KEY BLOCK-----\n", buf) == 0)))) break; /* remember optional Charset: armor header as defined by RFC4880 */ - if (mutt_strncmp("Charset: ", buf, 9) == 0) + if (mutt_str_strncmp("Charset: ", buf, 9) == 0) { size_t l = 0; FREE(&gpgcharset); - gpgcharset = safe_strdup(buf + 9); - if ((l = mutt_strlen(gpgcharset)) > 0 && gpgcharset[l - 1] == '\n') + gpgcharset = mutt_str_strdup(buf + 9); + if ((l = mutt_str_strlen(gpgcharset)) > 0 && gpgcharset[l - 1] == '\n') gpgcharset[l - 1] = 0; if (!mutt_check_charset(gpgcharset, 0)) mutt_str_replace(&gpgcharset, "UTF-8"); @@ -650,13 +651,13 @@ static int pgp_check_traditional_one_body(FILE *fp, struct Body *b) while (fgets(buf, sizeof(buf), tfp)) { - if (mutt_strncmp("-----BEGIN PGP ", buf, 15) == 0) + if (mutt_str_strncmp("-----BEGIN PGP ", buf, 15) == 0) { - if (mutt_strcmp("MESSAGE-----\n", buf + 15) == 0) + if (mutt_str_strcmp("MESSAGE-----\n", buf + 15) == 0) enc = 1; - else if (mutt_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0) + else if (mutt_str_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0) sgn = 1; - else if (mutt_strcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) + else if (mutt_str_strcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) key = 1; } } @@ -886,7 +887,7 @@ static struct Body *pgp_decrypt_part(struct Body *a, struct State *s, */ while (fgets(buf, sizeof(buf) - 1, pgpout) != NULL) { - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); if (len > 1 && buf[len - 2] == '\r') strcpy(buf + len - 2, "\n"); fputs(buf, fpout); @@ -1160,9 +1161,9 @@ struct Body *pgp_sign_message(struct Body *a) */ while (fgets(buffer, sizeof(buffer) - 1, pgpout) != NULL) { - if (mutt_strcmp("-----BEGIN PGP MESSAGE-----\n", buffer) == 0) + if (mutt_str_strcmp("-----BEGIN PGP MESSAGE-----\n", buffer) == 0) fputs("-----BEGIN PGP SIGNATURE-----\n", fp); - else if (mutt_strcmp("-----END PGP MESSAGE-----\n", buffer) == 0) + else if (mutt_str_strcmp("-----END PGP MESSAGE-----\n", buffer) == 0) fputs("-----END PGP SIGNATURE-----\n", fp); else fputs(buffer, fp); @@ -1203,7 +1204,7 @@ struct Body *pgp_sign_message(struct Body *a) t = mutt_new_body(); t->type = TYPEMULTIPART; - t->subtype = safe_strdup("signed"); + t->subtype = mutt_str_strdup("signed"); t->encoding = ENC7BIT; t->use_disp = false; t->disposition = DISPINLINE; @@ -1218,8 +1219,8 @@ struct Body *pgp_sign_message(struct Body *a) t->parts->next = mutt_new_body(); t = t->parts->next; t->type = TYPEAPPLICATION; - t->subtype = safe_strdup("pgp-signature"); - t->filename = safe_strdup(sigfile); + t->subtype = mutt_str_strdup("pgp-signature"); + t->filename = mutt_str_strdup(sigfile); t->use_disp = false; t->disposition = DISPNONE; t->encoding = ENC7BIT; @@ -1331,10 +1332,10 @@ char *pgp_find_keys(struct Address *adrlist, int oppenc_mode) keyID = pgp_fpr_or_lkeyid(k_info); bypass_selection: - keylist_size += mutt_strlen(keyID) + 4; + keylist_size += mutt_str_strlen(keyID) + 4; mutt_mem_realloc(&keylist, keylist_size); sprintf(keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", keyID); - keylist_used = mutt_strlen(keylist); + keylist_used = mutt_str_strlen(keylist); key_selected = true; @@ -1458,7 +1459,7 @@ struct Body *pgp_encrypt_message(struct Body *a, char *keylist, int sign) t = mutt_new_body(); t->type = TYPEMULTIPART; - t->subtype = safe_strdup("encrypted"); + t->subtype = mutt_str_strdup("encrypted"); t->encoding = ENC7BIT; t->use_disp = false; t->disposition = DISPINLINE; @@ -1468,18 +1469,18 @@ struct Body *pgp_encrypt_message(struct Body *a, char *keylist, int sign) t->parts = mutt_new_body(); t->parts->type = TYPEAPPLICATION; - t->parts->subtype = safe_strdup("pgp-encrypted"); + t->parts->subtype = mutt_str_strdup("pgp-encrypted"); t->parts->encoding = ENC7BIT; t->parts->next = mutt_new_body(); t->parts->next->type = TYPEAPPLICATION; - t->parts->next->subtype = safe_strdup("octet-stream"); + t->parts->next->subtype = mutt_str_strdup("octet-stream"); t->parts->next->encoding = ENC7BIT; - t->parts->next->filename = safe_strdup(tempfile); + t->parts->next->filename = mutt_str_strdup(tempfile); t->parts->next->use_disp = true; t->parts->next->disposition = DISPATTACH; t->parts->next->unlink = true; /* delete after sending the message */ - t->parts->next->d_filename = safe_strdup("msg.asc"); /* non pgp/mime can save */ + t->parts->next->d_filename = mutt_str_strdup("msg.asc"); /* non pgp/mime can save */ return t; } @@ -1508,7 +1509,7 @@ struct Body *pgp_traditional_encryptsign(struct Body *a, int flags, char *keylis if (a->type != TYPETEXT) return NULL; - if (mutt_strcasecmp(a->subtype, "plain") != 0) + if (mutt_str_strcasecmp(a->subtype, "plain") != 0) return NULL; fp = fopen(a->filename, "r"); @@ -1639,13 +1640,13 @@ struct Body *pgp_traditional_encryptsign(struct Body *a, int flags, char *keylis b->encoding = ENC7BIT; b->type = TYPETEXT; - b->subtype = safe_strdup("plain"); + b->subtype = mutt_str_strdup("plain"); mutt_set_parameter("x-action", flags & ENCRYPT ? "pgp-encrypted" : "pgp-signed", &b->parameter); mutt_set_parameter("charset", send_charset, &b->parameter); - b->filename = safe_strdup(pgpoutfile); + b->filename = mutt_str_strdup(pgpoutfile); b->disposition = DISPNONE; b->unlink = true; diff --git a/ncrypt/pgpkey.c b/ncrypt/pgpkey.c index 7d732b49d..d887ac4da 100644 --- a/ncrypt/pgpkey.c +++ b/ncrypt/pgpkey.c @@ -314,11 +314,11 @@ static int compare_key_address(const void *a, const void *b) struct PgpUid **s = (struct PgpUid **) a; struct PgpUid **t = (struct PgpUid **) b; - if ((r = mutt_strcasecmp((*s)->addr, (*t)->addr))) + if ((r = mutt_str_strcasecmp((*s)->addr, (*t)->addr))) return r > 0; else - return (mutt_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), - pgp_fpr_or_lkeyid((*t)->parent)) > 0); + return (mutt_str_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), + pgp_fpr_or_lkeyid((*t)->parent)) > 0); } static int pgp_compare_address(const void *a, const void *b) @@ -334,10 +334,11 @@ static int compare_keyid(const void *a, const void *b) struct PgpUid **s = (struct PgpUid **) a; struct PgpUid **t = (struct PgpUid **) b; - if ((r = mutt_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), pgp_fpr_or_lkeyid((*t)->parent)))) + if ((r = mutt_str_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), + pgp_fpr_or_lkeyid((*t)->parent)))) return r > 0; else - return (mutt_strcasecmp((*s)->addr, (*t)->addr) > 0); + return (mutt_str_strcasecmp((*s)->addr, (*t)->addr) > 0); } static int pgp_compare_keyid(const void *a, const void *b) @@ -353,7 +354,7 @@ static int compare_key_date(const void *a, const void *b) if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time))) return r > 0; - return (mutt_strcasecmp((*s)->addr, (*t)->addr) > 0); + return (mutt_str_strcasecmp((*s)->addr, (*t)->addr) > 0); } static int pgp_compare_date(const void *a, const void *b) @@ -377,10 +378,10 @@ static int compare_key_trust(const void *a, const void *b) return r < 0; if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time))) return r < 0; - if ((r = mutt_strcasecmp((*s)->addr, (*t)->addr))) + if ((r = mutt_str_strcasecmp((*s)->addr, (*t)->addr))) return r > 0; - return (mutt_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), - pgp_fpr_or_lkeyid((*t)->parent)) > 0); + return (mutt_str_strcasecmp(pgp_fpr_or_lkeyid((*s)->parent), + pgp_fpr_or_lkeyid((*t)->parent)) > 0); } static int pgp_compare_trust(const void *a, const void *b) @@ -436,11 +437,11 @@ static int pgp_id_matches_addr(struct Address *addr, struct Address *u_addr, str rv |= PGP_KV_STRONGID; if (addr->mailbox && u_addr->mailbox && - (mutt_strcasecmp(addr->mailbox, u_addr->mailbox) == 0)) + (mutt_str_strcasecmp(addr->mailbox, u_addr->mailbox) == 0)) rv |= PGP_KV_ADDR; if (addr->personal && u_addr->personal && - (mutt_strcasecmp(addr->personal, u_addr->personal) == 0)) + (mutt_str_strcasecmp(addr->personal, u_addr->personal) == 0)) rv |= PGP_KV_STRING; return rv; @@ -671,9 +672,9 @@ struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, en if (whatfor) { for (l = id_defaults; l; l = l->next) - if (mutt_strcasecmp(whatfor, l->what) == 0) + if (mutt_str_strcasecmp(whatfor, l->what) == 0) { - strfcpy(resp, NONULL(l->dflt), sizeof(resp)); + mutt_str_strfcpy(resp, NONULL(l->dflt), sizeof(resp)); break; } } @@ -693,8 +694,8 @@ struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, en l = mutt_mem_malloc(sizeof(struct PgpCache)); l->next = id_defaults; id_defaults = l; - l->what = safe_strdup(whatfor); - l->dflt = safe_strdup(resp); + l->what = mutt_str_strdup(whatfor); + l->dflt = mutt_str_strdup(resp); } } @@ -771,13 +772,13 @@ struct Body *pgp_make_key_attachment(char *tempf) mutt_file_fclose(&devnull); att = mutt_new_body(); - att->filename = safe_strdup(tempf); + att->filename = mutt_str_strdup(tempf); att->unlink = true; att->use_disp = false; att->type = TYPEAPPLICATION; - att->subtype = safe_strdup("pgp-keys"); + att->subtype = mutt_str_strdup("pgp-keys"); snprintf(buff, sizeof(buff), _("PGP Key %s."), tmp); - att->description = safe_strdup(buff); + att->description = mutt_str_strdup(buff); mutt_update_encoding(att); stat(tempf, &sb); @@ -791,14 +792,14 @@ static void pgp_add_string_to_hints(struct ListHead *hints, const char *str) char *scratch = NULL; char *t = NULL; - scratch = safe_strdup(str); + scratch = mutt_str_strdup(str); if (!scratch) return; for (t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n")) { if (strlen(t) > 3) - mutt_list_insert_tail(hints, safe_strdup(t)); + mutt_list_insert_tail(hints, mutt_str_strdup(t)); } FREE(&scratch); @@ -952,7 +953,7 @@ struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, enum PgpRing keyrin size_t l; const char *ps = NULL, *pl = NULL, *pfcopy = NULL, *phint = NULL; - if ((l = mutt_strlen(p)) && p[l - 1] == '!') + if ((l = mutt_str_strlen(p)) && p[l - 1] == '!') p[l - 1] = 0; mutt_message(_("Looking for keys matching \"%s\"..."), p); @@ -982,9 +983,9 @@ struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, enum PgpRing keyrin mutt_debug(5, "pgp_getkeybystr: matching \"%s\" against key %s:\n", p, pgp_long_keyid(k)); - if (!*p || (pfcopy && (mutt_strcasecmp(pfcopy, k->fingerprint) == 0)) || - (pl && (mutt_strcasecmp(pl, pgp_long_keyid(k)) == 0)) || - (ps && (mutt_strcasecmp(ps, pgp_short_keyid(k)) == 0))) + if (!*p || (pfcopy && (mutt_str_strcasecmp(pfcopy, k->fingerprint) == 0)) || + (pl && (mutt_str_strcasecmp(pl, pgp_long_keyid(k)) == 0)) || + (ps && (mutt_str_strcasecmp(ps, pgp_short_keyid(k)) == 0))) { mutt_debug(5, "\t\tmatch.\n"); match = true; @@ -996,7 +997,7 @@ struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, enum PgpRing keyrin mutt_debug(5, "pgp_getkeybystr: matching \"%s\" against key %s, \"%s\":\n", p, pgp_long_keyid(k), NONULL(a->addr)); - if (mutt_stristr(a->addr, p)) + if (mutt_str_stristr(a->addr, p)) { mutt_debug(5, "\t\tmatch.\n"); match = true; diff --git a/ncrypt/pgplib.c b/ncrypt/pgplib.c index fbe7a673b..90641d97c 100644 --- a/ncrypt/pgplib.c +++ b/ncrypt/pgplib.c @@ -131,7 +131,7 @@ struct PgpUid *pgp_copy_uids(struct PgpUid *up, struct PgpKeyInfo *parent) *lp = mutt_mem_calloc(1, sizeof(struct PgpUid)); (*lp)->trust = up->trust; (*lp)->flags = up->flags; - (*lp)->addr = safe_strdup(up->addr); + (*lp)->addr = mutt_str_strdup(up->addr); (*lp)->parent = parent; lp = &(*lp)->next; } diff --git a/ncrypt/smime.c b/ncrypt/smime.c index a886c8931..2f3ccf52e 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -107,10 +107,10 @@ static struct SmimeKey *smime_copy_key(struct SmimeKey *key) return NULL; copy = mutt_mem_calloc(1, sizeof(struct SmimeKey)); - copy->email = safe_strdup(key->email); - copy->hash = safe_strdup(key->hash); - copy->label = safe_strdup(key->label); - copy->issuer = safe_strdup(key->issuer); + copy->email = mutt_str_strdup(key->email); + copy->hash = mutt_str_strdup(key->hash); + copy->label = mutt_str_strdup(key->label); + copy->issuer = mutt_str_strdup(key->issuer); copy->trust = key->trust; copy->flags = key->flags; @@ -178,7 +178,7 @@ static const char *fmt_smime_command(char *dest, size_t destlen, size_t col, int char buf1[LONG_STRING], buf2[LONG_STRING]; struct stat sb; - strfcpy(path, NONULL(SmimeCALocation), sizeof(path)); + mutt_str_strfcpy(path, NONULL(SmimeCALocation), sizeof(path)); mutt_expand_path(path, sizeof(path)); mutt_file_quote_filename(buf1, sizeof(buf1), path); @@ -507,16 +507,16 @@ static struct SmimeKey *smime_parse_key(char *buf) switch (field) { case 1: /* mailbox */ - key->email = safe_strdup(p); + key->email = mutt_str_strdup(p); break; case 2: /* hash */ - key->hash = safe_strdup(p); + key->hash = mutt_str_strdup(p); break; case 3: /* label */ - key->label = safe_strdup(p); + key->label = mutt_str_strdup(p); break; case 4: /* issuer */ - key->issuer = safe_strdup(p); + key->issuer = mutt_str_strdup(p); break; case 5: /* trust */ key->trust = *p; @@ -548,7 +548,7 @@ static struct SmimeKey *smime_parse_key(char *buf) } if (field < 4) - key->issuer = safe_strdup("?"); + key->issuer = mutt_str_strdup("?"); if (field < 5) key->trust = 't'; @@ -581,7 +581,7 @@ static struct SmimeKey *smime_get_candidates(char *search, short public) while (fgets(buf, sizeof(buf), fp)) { - if ((!*search) || mutt_stristr(buf, search)) + if ((!*search) || mutt_str_stristr(buf, search)) { key = smime_parse_key(buf); if (key) @@ -611,7 +611,7 @@ static struct SmimeKey *smime_get_key_by_hash(char *hash, short public) results = smime_get_candidates(hash, public); for (result = results; result; result = result->next) { - if (mutt_strcasecmp(hash, result->hash) == 0) + if (mutt_str_strcasecmp(hash, result->hash) == 0) { match = smime_copy_key(result); break; @@ -646,7 +646,7 @@ static struct SmimeKey *smime_get_key_by_addr(char *mailbox, short abilities, continue; } - if (mutt_strcasecmp(mailbox, result->email) == 0) + if (mutt_str_strcasecmp(mailbox, result->email) == 0) { match = smime_copy_key(result); *matches_end = match; @@ -654,7 +654,7 @@ static struct SmimeKey *smime_get_key_by_addr(char *mailbox, short abilities, if (match->trust == 't') { - if (trusted_match && (mutt_strcasecmp(match->hash, trusted_match->hash) != 0)) + if (trusted_match && (mutt_str_strcasecmp(match->hash, trusted_match->hash) != 0)) { multi_trusted_matches = 1; } @@ -714,8 +714,8 @@ static struct SmimeKey *smime_get_key_by_str(char *str, short abilities, short p continue; } - if ((mutt_strcasecmp(str, result->hash) == 0) || - mutt_stristr(result->email, str) || mutt_stristr(result->label, str)) + if ((mutt_str_strcasecmp(str, result->hash) == 0) || + mutt_str_stristr(result->email, str) || mutt_str_stristr(result->label, str)) { match = smime_copy_key(result); *matches_end = match; @@ -784,7 +784,7 @@ static void getkeys(char *mailbox) /* the key used last time. */ if (*SmimeKeyToUse && - (mutt_strcasecmp(k, SmimeKeyToUse + mutt_strlen(SmimeKeys) + 1) == 0)) + (mutt_str_strcasecmp(k, SmimeKeyToUse + mutt_str_strlen(SmimeKeys) + 1) == 0)) { smime_free_key(&key); return; @@ -796,7 +796,7 @@ static void getkeys(char *mailbox) snprintf(SmimeCertToUse, sizeof(SmimeCertToUse), "%s/%s", NONULL(SmimeCertificates), k); - if (mutt_strcasecmp(k, SmimeDefaultKey) != 0) + if (mutt_str_strcasecmp(k, SmimeDefaultKey) != 0) smime_void_passphrase(); smime_free_key(&key); @@ -805,7 +805,8 @@ static void getkeys(char *mailbox) if (*SmimeKeyToUse) { - if (mutt_strcasecmp(SmimeDefaultKey, SmimeKeyToUse + mutt_strlen(SmimeKeys) + 1) == 0) + if (mutt_str_strcasecmp(SmimeDefaultKey, + SmimeKeyToUse + mutt_str_strlen(SmimeKeys) + 1) == 0) return; smime_void_passphrase(); @@ -888,10 +889,10 @@ char *smime_find_keys(struct Address *adrlist, int oppenc_mode) } keyID = key->hash; - keylist_size += mutt_strlen(keyID) + 2; + keylist_size += mutt_str_strlen(keyID) + 2; mutt_mem_realloc(&keylist, keylist_size); sprintf(keylist + keylist_used, "%s%s", keylist_used ? " " : "", keyID); - keylist_used = mutt_strlen(keylist); + keylist_used = mutt_str_strlen(keylist); smime_free_key(&key); } @@ -946,10 +947,10 @@ static int smime_handle_cert_email(char *certificate, char *mailbox, int copy, while ((fgets(email, sizeof(email), fpout))) { - len = mutt_strlen(email); + len = mutt_str_strlen(email); if (len && (email[len - 1] == '\n')) email[len - 1] = '\0'; - if (mutt_strncasecmp(email, mailbox, mutt_strlen(mailbox)) == 0) + if (mutt_str_strncasecmp(email, mailbox, mutt_str_strlen(mailbox)) == 0) ret = 1; ret = ret < 0 ? 0 : ret; @@ -977,11 +978,11 @@ static int smime_handle_cert_email(char *certificate, char *mailbox, int copy, rewind(fpout); while ((fgets(email, sizeof(email), fpout))) { - len = mutt_strlen(email); + len = mutt_str_strlen(email); if (len && (email[len - 1] == '\n')) email[len - 1] = '\0'; - (*buffer)[count] = mutt_mem_calloc(mutt_strlen(email) + 1, sizeof(char)); - strncpy((*buffer)[count], email, mutt_strlen(email)); + (*buffer)[count] = mutt_mem_calloc(mutt_str_strlen(email) + 1, sizeof(char)); + strncpy((*buffer)[count], email, mutt_str_strlen(email)); count++; } } @@ -1095,7 +1096,7 @@ static char *smime_extract_certificate(char *infile) mutt_file_fclose(&fpout); mutt_file_fclose(&fperr); - return safe_strdup(certfile); + return mutt_str_strdup(certfile); } static char *smime_extract_signer_certificate(char *infile) @@ -1158,7 +1159,7 @@ static char *smime_extract_signer_certificate(char *infile) mutt_file_fclose(&fpout); mutt_file_fclose(&fperr); - return safe_strdup(certfile); + return mutt_str_strdup(certfile); } /** @@ -1363,7 +1364,7 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist) *cert_end = '\0'; if (*cert_start) { - off = mutt_strlen(certfile); + off = mutt_str_strlen(certfile); snprintf(certfile + off, sizeof(certfile) - off, "%s%s/%s", off ? " " : "", NONULL(SmimeCertificates), cert_start); } @@ -1422,14 +1423,14 @@ struct Body *smime_build_smime_entity(struct Body *a, char *certlist) t = mutt_new_body(); t->type = TYPEAPPLICATION; - t->subtype = safe_strdup("x-pkcs7-mime"); + t->subtype = mutt_str_strdup("x-pkcs7-mime"); mutt_set_parameter("name", "smime.p7m", &t->parameter); mutt_set_parameter("smime-type", "enveloped-data", &t->parameter); t->encoding = ENCBASE64; /* The output of OpenSSL SHOULD be binary */ t->use_disp = true; t->disposition = DISPATTACH; - t->d_filename = safe_strdup("smime.p7m"); - t->filename = safe_strdup(tempfile); + t->d_filename = mutt_str_strdup("smime.p7m"); + t->filename = mutt_str_strdup(tempfile); t->unlink = true; /* delete after sending the message */ t->parts = 0; t->next = 0; @@ -1453,7 +1454,7 @@ static char *openssl_md_to_smime_micalg(char *md) if (!md) return 0; - if (mutt_strncasecmp("sha", md, 3) == 0) + if (mutt_str_strncasecmp("sha", md, 3) == 0) { l = strlen(md) + 2; micalg = mutt_mem_malloc(l); @@ -1461,7 +1462,7 @@ static char *openssl_md_to_smime_micalg(char *md) } else { - micalg = safe_strdup(md); + micalg = mutt_str_strdup(md); } return micalg; @@ -1517,7 +1518,7 @@ struct Body *smime_sign_message(struct Body *a) NONULL(SmimeCertificates), SmimeDefaultKey); default_key = smime_get_key_by_hash(SmimeDefaultKey, 1); - if ((!default_key) || (mutt_strcmp("?", default_key->issuer) == 0)) + if ((!default_key) || (mutt_str_strcmp("?", default_key->issuer) == 0)) intermediates = SmimeDefaultKey; /* so openssl won't complain in any case */ else intermediates = default_key->issuer; @@ -1572,7 +1573,7 @@ struct Body *smime_sign_message(struct Body *a) t = mutt_new_body(); t->type = TYPEMULTIPART; - t->subtype = safe_strdup("signed"); + t->subtype = mutt_str_strdup("signed"); t->encoding = ENC7BIT; t->use_disp = false; t->disposition = DISPINLINE; @@ -1591,9 +1592,9 @@ struct Body *smime_sign_message(struct Body *a) t->parts->next = mutt_new_body(); t = t->parts->next; t->type = TYPEAPPLICATION; - t->subtype = safe_strdup("x-pkcs7-signature"); - t->filename = safe_strdup(signedfile); - t->d_filename = safe_strdup("smime.p7s"); + t->subtype = mutt_str_strdup("x-pkcs7-signature"); + t->filename = mutt_str_strdup(signedfile); + t->d_filename = mutt_str_strdup("smime.p7s"); t->use_disp = true; t->disposition = DISPATTACH; t->encoding = ENCBASE64; @@ -1703,7 +1704,7 @@ int smime_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile) rewind(smimeerr); line = mutt_file_read_line(line, &linelen, smimeerr, &lineno, 0); - if (linelen && (mutt_strcasecmp(line, "verification successful") == 0)) + if (linelen && (mutt_str_strcasecmp(line, "verification successful") == 0)) badsig = 0; FREE(&line); @@ -1870,7 +1871,7 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o } while (fgets(buf, sizeof(buf) - 1, smimeout) != NULL) { - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); if (len > 1 && buf[len - 2] == '\r') { buf[len - 2] = '\n'; @@ -1926,7 +1927,7 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o rewind(smimeerr); line = mutt_file_read_line(line, &linelen, smimeerr, &lineno, 0); - if (linelen && (mutt_strcasecmp(line, "verification successful") == 0)) + if (linelen && (mutt_str_strcasecmp(line, "verification successful") == 0)) m->goodsig = true; FREE(&line); } diff --git a/newsrc.c b/newsrc.c index c2c75d5b4..7dcf334da 100644 --- a/newsrc.c +++ b/newsrc.c @@ -68,7 +68,7 @@ static struct NntpData *nntp_data_find(struct NntpServer *nserv, const char *gro /* create NntpData structure and add it to hash */ nntp_data = mutt_mem_calloc(1, sizeof(struct NntpData) + len); nntp_data->group = (char *) nntp_data + sizeof(struct NntpData); - strfcpy(nntp_data->group, group, len); + mutt_str_strfcpy(nntp_data->group, group, len); nntp_data->nserv = nserv; nntp_data->deleted = true; mutt_hash_insert(nserv->groups_hash, nntp_data->group, nntp_data); @@ -520,7 +520,7 @@ static void cache_expand(char *dst, size_t dstlen, struct Account *acct, char *s url_tostring(&url, file, sizeof(file), U_PATH); } else - strfcpy(file, src ? src : "", sizeof(file)); + mutt_str_strfcpy(file, src ? src : "", sizeof(file)); snprintf(dst, dstlen, "%s/%s", NewsCacheDir, file); @@ -539,7 +539,7 @@ void nntp_expand_path(char *line, size_t len, struct Account *acct) struct Url url; mutt_account_tourl(acct, &url); - url.path = safe_strdup(line); + url.path = mutt_str_strdup(line); url_tostring(&url, line, len, 0); FREE(&url.path); } @@ -804,7 +804,7 @@ void nntp_clear_cache(struct NntpServer *nserv) dp = opendir(file); if (dp) { - safe_strncat(file, sizeof(file), "/", 1); + mutt_str_strncat(file, sizeof(file), "/", 1); fp = file + strlen(file); while ((entry = readdir(dp))) { @@ -813,10 +813,10 @@ void nntp_clear_cache(struct NntpServer *nserv) struct NntpData *nntp_data = NULL; struct NntpData nntp_tmp; - if ((mutt_strcmp(group, ".") == 0) || (mutt_strcmp(group, "..") == 0)) + if ((mutt_str_strcmp(group, ".") == 0) || (mutt_str_strcmp(group, "..") == 0)) continue; *fp = '\0'; - safe_strncat(file, sizeof(file), group, strlen(group)); + mutt_str_strncat(file, sizeof(file), group, strlen(group)); if (stat(file, &sb)) continue; @@ -824,7 +824,7 @@ void nntp_clear_cache(struct NntpServer *nserv) if (S_ISREG(sb.st_mode)) { char *ext = group + strlen(group) - 7; - if (strlen(group) < 8 || (mutt_strcmp(ext, ".hcache") != 0)) + if (strlen(group) < 8 || (mutt_str_strcmp(ext, ".hcache") != 0)) continue; *ext = '\0'; } @@ -900,7 +900,7 @@ const char *nntp_format_str(char *dest, size_t destlen, size_t col, int cols, break; case 's': strncpy(fn, acct->host, sizeof(fn) - 1); - mutt_strlower(fn); + mutt_str_strlower(fn); snprintf(tmp, sizeof(tmp), "%%%ss", fmt); snprintf(dest, destlen, tmp, fn); break; @@ -1033,7 +1033,7 @@ struct NntpServer *nntp_select_server(char *server, bool leave_lock) mutt_expando_format(file, sizeof(file), 0, MuttIndexWindow->cols, NONULL(NewsRc), nntp_format_str, (unsigned long) nserv, 0); mutt_expand_path(file, sizeof(file)); - nserv->newsrc_file = safe_strdup(file); + nserv->newsrc_file = mutt_str_strdup(file); rc = nntp_newsrc_parse(nserv); } if (rc >= 0) @@ -1288,7 +1288,7 @@ void nntp_buffy(char *buf, size_t len) continue; if (Context && Context->magic == MUTT_NNTP && - (mutt_strcmp(nntp_data->group, ((struct NntpData *) Context->data)->group) == 0)) + (mutt_str_strcmp(nntp_data->group, ((struct NntpData *) Context->data)->group) == 0)) { unsigned int unread = 0; @@ -1298,7 +1298,7 @@ void nntp_buffy(char *buf, size_t len) if (!unread) continue; } - strfcpy(buf, nntp_data->group, len); + mutt_str_strfcpy(buf, nntp_data->group, len); break; } } diff --git a/nntp.c b/nntp.c index 1b69ac350..cdbd14337 100644 --- a/nntp.c +++ b/nntp.c @@ -90,7 +90,7 @@ static int nntp_capabilities(struct NntpServer *nserv) return nntp_connect_error(nserv); /* no capabilities */ - if (mutt_strncmp("101", buf, 3) != 0) + if (mutt_str_strncmp("101", buf, 3) != 0) return 1; nserv->hasCAPABILITIES = true; @@ -99,33 +99,33 @@ static int nntp_capabilities(struct NntpServer *nserv) { if (mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strcmp("STARTTLS", buf) == 0) + if (mutt_str_strcmp("STARTTLS", buf) == 0) nserv->hasSTARTTLS = true; - else if (mutt_strcmp("MODE-READER", buf) == 0) + else if (mutt_str_strcmp("MODE-READER", buf) == 0) mode_reader = true; - else if (mutt_strcmp("READER", buf) == 0) + else if (mutt_str_strcmp("READER", buf) == 0) { nserv->hasDATE = true; nserv->hasLISTGROUP = true; nserv->hasLISTGROUPrange = true; } - else if (mutt_strncmp("AUTHINFO ", buf, 9) == 0) + else if (mutt_str_strncmp("AUTHINFO ", buf, 9) == 0) { - safe_strcat(buf, sizeof(buf), " "); - strfcpy(authinfo, buf + 8, sizeof(authinfo)); + mutt_str_strcat(buf, sizeof(buf), " "); + mutt_str_strfcpy(authinfo, buf + 8, sizeof(authinfo)); } #ifdef USE_SASL - else if (mutt_strncmp("SASL ", buf, 5) == 0) + else if (mutt_str_strncmp("SASL ", buf, 5) == 0) { char *p = buf + 5; while (*p == ' ') p++; - nserv->authenticators = safe_strdup(p); + nserv->authenticators = mutt_str_strdup(p); } #endif - else if (mutt_strcmp("OVER", buf) == 0) + else if (mutt_str_strcmp("OVER", buf) == 0) nserv->hasOVER = true; - else if (mutt_strncmp("LIST ", buf, 5) == 0) + else if (mutt_str_strncmp("LIST ", buf, 5) == 0) { char *p = strstr(buf, " NEWSGROUPS"); if (p) @@ -135,17 +135,17 @@ static int nntp_capabilities(struct NntpServer *nserv) nserv->hasLIST_NEWSGROUPS = true; } } - } while (mutt_strcmp(".", buf) != 0); + } while (mutt_str_strcmp(".", buf) != 0); *buf = '\0'; #ifdef USE_SASL if (nserv->authenticators && strcasestr(authinfo, " SASL ")) - strfcpy(buf, nserv->authenticators, sizeof(buf)); + mutt_str_strfcpy(buf, nserv->authenticators, sizeof(buf)); #endif if (strcasestr(authinfo, " USER ")) { if (*buf) - safe_strcat(buf, sizeof(buf), " "); - safe_strcat(buf, sizeof(buf), "USER"); + mutt_str_strcat(buf, sizeof(buf), " "); + mutt_str_strcat(buf, sizeof(buf), "USER"); } mutt_str_replace(&nserv->authenticators, buf); @@ -187,27 +187,27 @@ static int nntp_attempt_features(struct NntpServer *nserv) if (mutt_socket_write(conn, "DATE\r\n") < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("500", buf, 3) != 0) + if (mutt_str_strncmp("500", buf, 3) != 0) nserv->hasDATE = true; if (mutt_socket_write(conn, "LISTGROUP\r\n") < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("500", buf, 3) != 0) + if (mutt_str_strncmp("500", buf, 3) != 0) nserv->hasLISTGROUP = true; if (mutt_socket_write(conn, "LIST NEWSGROUPS +\r\n") < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("500", buf, 3) != 0) + if (mutt_str_strncmp("500", buf, 3) != 0) nserv->hasLIST_NEWSGROUPS = true; - if (mutt_strncmp("215", buf, 3) == 0) + if (mutt_str_strncmp("215", buf, 3) == 0) { do { if (mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - } while (mutt_strcmp(".", buf) != 0); + } while (mutt_str_strcmp(".", buf) != 0); } } @@ -217,7 +217,7 @@ static int nntp_attempt_features(struct NntpServer *nserv) if (mutt_socket_write(conn, "XGTITLE\r\n") < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("500", buf, 3) != 0) + if (mutt_str_strncmp("500", buf, 3) != 0) nserv->hasXGTITLE = true; } @@ -227,7 +227,7 @@ static int nntp_attempt_features(struct NntpServer *nserv) if (mutt_socket_write(conn, "XOVER\r\n") < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("500", buf, 3) != 0) + if (mutt_str_strncmp("500", buf, 3) != 0) nserv->hasXOVER = true; } @@ -237,7 +237,7 @@ static int nntp_attempt_features(struct NntpServer *nserv) if (mutt_socket_write(conn, "LIST OVERVIEW.FMT\r\n") < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("215", buf, 3) != 0) + if (mutt_str_strncmp("215", buf, 3) != 0) nserv->overview_fmt = OverviewFmt; else { @@ -263,7 +263,7 @@ static int nntp_attempt_features(struct NntpServer *nserv) return nntp_connect_error(nserv); } - if (!cont && (mutt_strcmp(".", nserv->overview_fmt + off) == 0)) + if (!cont && (mutt_str_strcmp(".", nserv->overview_fmt + off) == 0)) break; cont = chunk >= buflen - off ? 1 : 0; @@ -285,7 +285,7 @@ static int nntp_attempt_features(struct NntpServer *nserv) if (strcasecmp(nserv->overview_fmt + b, "Bytes:") == 0) { int len = strlen(nserv->overview_fmt + b); - strfcpy(nserv->overview_fmt + b, "Content-Length:", len + 1); + mutt_str_strfcpy(nserv->overview_fmt + b, "Content-Length:", len + 1); off = b + len; } nserv->overview_fmt[off++] = '\0'; @@ -319,10 +319,10 @@ static int nntp_auth(struct NntpServer *nserv) /* get list of authenticators */ if (NntpAuthenticators && *NntpAuthenticators) - strfcpy(authenticators, NntpAuthenticators, sizeof(authenticators)); + mutt_str_strfcpy(authenticators, NntpAuthenticators, sizeof(authenticators)); else if (nserv->hasCAPABILITIES) { - strfcpy(authenticators, NONULL(nserv->authenticators), sizeof(authenticators)); + mutt_str_strfcpy(authenticators, NONULL(nserv->authenticators), sizeof(authenticators)); p = authenticators; while (*p) { @@ -382,11 +382,11 @@ static int nntp_auth(struct NntpServer *nserv) break; /* authenticated, password is not required */ - if (mutt_strncmp("281", buf, 3) == 0) + if (mutt_str_strncmp("281", buf, 3) == 0) return 0; /* username accepted, sending password */ - if (mutt_strncmp("381", buf, 3) == 0) + if (mutt_str_strncmp("381", buf, 3) == 0) { #ifdef DEBUG if (debuglevel < MUTT_SOCK_LOG_FULL) @@ -398,7 +398,7 @@ static int nntp_auth(struct NntpServer *nserv) break; /* authenticated */ - if (mutt_strncmp("281", buf, 3) == 0) + if (mutt_str_strncmp("281", buf, 3) == 0) return 0; } @@ -465,7 +465,7 @@ static int nntp_auth(struct NntpServer *nserv) #endif if (*buf) - safe_strcat(buf, sizeof(buf), " "); + mutt_str_strcat(buf, sizeof(buf), " "); len = strlen(buf); if (sasl_encode64(client_out, client_len, buf + len, sizeof(buf) - len, &len) != SASL_OK) @@ -476,7 +476,7 @@ static int nntp_auth(struct NntpServer *nserv) } } - safe_strcat(buf, sizeof(buf), "\r\n"); + mutt_str_strcat(buf, sizeof(buf), "\r\n"); #ifdef DEBUG if (debuglevel < MUTT_SOCK_LOG_FULL) { @@ -491,8 +491,8 @@ static int nntp_auth(struct NntpServer *nserv) if (mutt_socket_write_d(conn, buf, -1, MUTT_SOCK_LOG_FULL) < 0 || mutt_socket_readln_d(inbuf, sizeof(inbuf), conn, MUTT_SOCK_LOG_FULL) < 0) break; - if ((mutt_strncmp(inbuf, "283 ", 4) != 0) && - (mutt_strncmp(inbuf, "383 ", 4) != 0)) + if ((mutt_str_strncmp(inbuf, "283 ", 4) != 0) && + (mutt_str_strncmp(inbuf, "383 ", 4) != 0)) { #ifdef DEBUG if (debuglevel < MUTT_SOCK_LOG_FULL) @@ -555,7 +555,7 @@ static int nntp_auth(struct NntpServer *nserv) sasl_dispose(&saslconn); if (conn->fd < 0) break; - if (mutt_strncmp(inbuf, "383 ", 4) == 0) + if (mutt_str_strncmp(inbuf, "383 ", 4) == 0) { if (mutt_socket_write(conn, "*\r\n") < 0 || mutt_socket_readln(inbuf, sizeof(inbuf), conn) < 0) @@ -612,12 +612,12 @@ int nntp_open_connection(struct NntpServer *nserv) if (mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("200", buf, 3) == 0) + if (mutt_str_strncmp("200", buf, 3) == 0) posting = true; - else if (mutt_strncmp("201", buf, 3) != 0) + else if (mutt_str_strncmp("201", buf, 3) != 0) { mutt_socket_close(conn); - mutt_remove_trailing_ws(buf); + mutt_str_remove_trailing_ws(buf); mutt_error("%s", buf); mutt_sleep(2); return -1; @@ -635,9 +635,9 @@ int nntp_open_connection(struct NntpServer *nserv) mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("200", buf, 3) == 0) + if (mutt_str_strncmp("200", buf, 3) == 0) posting = true; - else if (mutt_strncmp("201", buf, 3) == 0) + else if (mutt_str_strncmp("201", buf, 3) == 0) posting = false; /* error if has capabilities, ignore result if no capabilities */ else if (nserv->hasCAPABILITIES) @@ -677,7 +677,7 @@ int nntp_open_connection(struct NntpServer *nserv) if (mutt_socket_write(conn, "STARTTLS\r\n") < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("382", buf, 3) != 0) + if (mutt_str_strncmp("382", buf, 3) != 0) { nserv->use_tls = 0; mutt_error("STARTTLS: %s", buf); @@ -714,7 +714,7 @@ int nntp_open_connection(struct NntpServer *nserv) if (mutt_socket_write(conn, "STAT\r\n") < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) return nntp_connect_error(nserv); - if (mutt_strncmp("480", buf, 3) != 0) + if (mutt_str_strncmp("480", buf, 3) != 0) auth = false; } @@ -803,7 +803,7 @@ static int nntp_query(struct NntpData *nntp_data, char *line, size_t linelen) break; } - strfcpy(line, buf, linelen); + mutt_str_strfcpy(line, buf, linelen); return 0; } @@ -834,12 +834,12 @@ static int nntp_fetch_lines(struct NntpData *nntp_data, char *query, size_t qlen if (msg) mutt_progress_init(&progress, msg, MUTT_PROGRESS_MSG, ReadInc, -1); - strfcpy(buf, query, sizeof(buf)); + mutt_str_strfcpy(buf, query, sizeof(buf)); if (nntp_query(nntp_data, buf, sizeof(buf)) < 0) return -1; if (buf[0] != '2') { - strfcpy(query, buf, qlen); + mutt_str_strfcpy(query, buf, qlen); return 1; } @@ -869,7 +869,7 @@ static int nntp_fetch_lines(struct NntpData *nntp_data, char *query, size_t qlen p++; } - strfcpy(line + off, p, sizeof(buf)); + mutt_str_strfcpy(line + off, p, sizeof(buf)); if (chunk >= sizeof(buf)) off += strlen(p); @@ -913,7 +913,7 @@ static int fetch_description(char *line, void *data) desc = strchr(line, '\0'); nntp_data = mutt_hash_find(nserv->groups_hash, line); - if (nntp_data && (mutt_strcmp(desc, nntp_data->desc) != 0)) + if (nntp_data && (mutt_str_strcmp(desc, nntp_data->desc) != 0)) { mutt_str_replace(&nntp_data->desc, desc); mutt_debug(2, "group: %s, desc: %s\n", line, desc); @@ -969,7 +969,7 @@ static void nntp_parse_xref(struct Context *ctx, struct Header *hdr) struct NntpData *nntp_data = ctx->data; char *buf = NULL, *p = NULL; - buf = p = safe_strdup(hdr->env->xref); + buf = p = mutt_str_strdup(hdr->env->xref); while (p) { char *grp = NULL, *colon = NULL; @@ -993,7 +993,7 @@ static void nntp_parse_xref(struct Context *ctx, struct Header *hdr) continue; nntp_article_status(ctx, hdr, grp, anum); - if (hdr && !NHDR(hdr)->article_num && (mutt_strcmp(nntp_data->group, grp) == 0)) + if (hdr && !NHDR(hdr)->article_num && (mutt_str_strcmp(nntp_data->group, grp) == 0)) NHDR(hdr)->article_num = anum; } FREE(&buf); @@ -1127,7 +1127,7 @@ static int parse_overview_line(char *line, void *data) /* parse header */ hdr = ctx->hdrs[ctx->msgcount] = mutt_new_header(); hdr->env = mutt_read_rfc822_header(fp, hdr, 0, 0); - hdr->env->newsgroups = safe_strdup(nntp_data->group); + hdr->env->newsgroups = mutt_str_strdup(nntp_data->group); hdr->received = hdr->date_sent; mutt_file_fclose(&fp); unlink(tempfile); @@ -1362,7 +1362,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, break; /* invalid response */ - if (mutt_strncmp("423", buf, 3) != 0) + if (mutt_str_strncmp("423", buf, 3) != 0) { mutt_error("HEAD: %s", buf); mutt_sleep(2); @@ -1449,7 +1449,7 @@ static int nntp_open_mailbox(struct Context *ctx) anum_t first, last, count = 0; struct Url url; - strfcpy(buf, ctx->path, sizeof(buf)); + mutt_str_strfcpy(buf, ctx->path, sizeof(buf)); if (url_parse(&url, buf) < 0 || !url.host || !url.path || !(url.scheme == U_NNTP || url.scheme == U_NNTPS)) { @@ -1492,7 +1492,7 @@ static int nntp_open_mailbox(struct Context *ctx) } /* newsgroup not found, remove it */ - if (mutt_strncmp("411", buf, 3) == 0) + if (mutt_str_strncmp("411", buf, 3) == 0) { mutt_error(_("Newsgroup %s has been removed from the server."), nntp_data->group); if (!nntp_data->deleted) @@ -1622,7 +1622,7 @@ static int nntp_open_message(struct Context *ctx, struct Message *msg, int msgno if (!msg->fp) { mutt_mktemp(buf, sizeof(buf)); - acache->path = safe_strdup(buf); + acache->path = mutt_str_strdup(buf); acache->index = hdr->index; msg->fp = mutt_file_fopen(acache->path, "w+"); if (!msg->fp) @@ -1648,7 +1648,7 @@ static int nntp_open_message(struct Context *ctx, struct Message *msg, int msgno } if (rc > 0) { - if (mutt_strncmp(NHDR(hdr)->article_num ? "423" : "430", buf, 3) == 0) + if (mutt_str_strncmp(NHDR(hdr)->article_num ? "423" : "430", buf, 3) == 0) mutt_error(_("Article %d not found on the server."), NHDR(hdr)->article_num ? article : hdr->env->message_id); else @@ -1735,7 +1735,7 @@ int nntp_post(const char *msg) return -1; } - strfcpy(buf, "POST\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "POST\r\n", sizeof(buf)); if (nntp_query(nntp_data, buf, sizeof(buf)) < 0) { mutt_file_fclose(&fp); @@ -2156,7 +2156,7 @@ static int nntp_date(struct NntpServer *nserv, time_t *now) nntp_data.nserv = nserv; nntp_data.group = NULL; - strfcpy(buf, "DATE\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "DATE\r\n", sizeof(buf)); if (nntp_query(&nntp_data, buf, sizeof(buf)) < 0) return -1; @@ -2197,7 +2197,7 @@ int nntp_active_fetch(struct NntpServer *nserv, bool new) nntp_data.nserv = nserv; nntp_data.group = NULL; i = nserv->groups_num; - strfcpy(buf, "LIST\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "LIST\r\n", sizeof(buf)); rc = nntp_fetch_lines(&nntp_data, buf, sizeof(buf), msg, nntp_add_group, nserv); if (rc) { @@ -2383,7 +2383,7 @@ int nntp_check_msgid(struct Context *ctx, const char *msgid) unlink(tempfile); if (rc < 0) return -1; - if (mutt_strncmp("430", buf, 3) == 0) + if (mutt_str_strncmp("430", buf, 3) == 0) return 1; mutt_error("HEAD: %s", buf); return -1; @@ -2488,7 +2488,7 @@ int nntp_check_children(struct Context *ctx, const char *msgid) FREE(&cc.child); if (rc > 0) { - if (mutt_strncmp("500", buf, 3) != 0) + if (mutt_str_strncmp("500", buf, 3) != 0) mutt_error("XPAT: %s", buf); else mutt_error(_("Unable to find child articles because server does not " diff --git a/pager.c b/pager.c index 3104b62ba..b07dd91da 100644 --- a/pager.c +++ b/pager.c @@ -463,7 +463,7 @@ static struct QClass *classify_quote(struct QClass **quote_list, const char *qpt { /* case 1: check the top level nodes */ - if (mutt_strncmp(qptr, q_list->prefix, length) == 0) + if (mutt_str_strncmp(qptr, q_list->prefix, length) == 0) { if (length == q_list->length) return q_list; /* same prefix: return the current class */ @@ -557,7 +557,7 @@ static struct QClass *classify_quote(struct QClass **quote_list, const char *qpt /* case 2: try subclassing the current top level node */ /* tmp != NULL means we already found a shorter prefix at case 1 */ - if (tmp == NULL && (mutt_strncmp(qptr, q_list->prefix, q_list->length) == 0)) + if (tmp == NULL && (mutt_str_strncmp(qptr, q_list->prefix, q_list->length) == 0)) { /* ok, it's a subclass somewhere on this branch */ @@ -572,7 +572,7 @@ static struct QClass *classify_quote(struct QClass **quote_list, const char *qpt { if (length <= q_list->length) { - if (mutt_strncmp(tail_qptr, (q_list->prefix) + offset, tail_lng) == 0) + if (mutt_str_strncmp(tail_qptr, (q_list->prefix) + offset, tail_lng) == 0) { /* same prefix: return the current class */ if (length == q_list->length) @@ -659,8 +659,8 @@ static struct QClass *classify_quote(struct QClass **quote_list, const char *qpt else { /* longer than the current prefix: try subclassing it */ - if (tmp == NULL && (mutt_strncmp(tail_qptr, (q_list->prefix) + offset, - q_list->length - offset) == 0)) + if (tmp == NULL && (mutt_str_strncmp(tail_qptr, (q_list->prefix) + offset, + q_list->length - offset) == 0)) { /* still a subclass: go down one level */ ptr = q_list; @@ -823,11 +823,11 @@ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n, } } } - else if (mutt_strncmp("\033[0m", raw, 4) == 0) /* a little hack... */ + else if (mutt_str_strncmp("\033[0m", raw, 4) == 0) /* a little hack... */ line_info[n].type = MT_COLOR_NORMAL; else if (check_attachment_marker((char *) raw) == 0) line_info[n].type = MT_COLOR_ATTACHMENT; - else if ((mutt_strcmp("-- \n", buf) == 0) || (mutt_strcmp("-- \r\n", buf) == 0)) + else if ((mutt_str_strcmp("-- \n", buf) == 0) || (mutt_str_strcmp("-- \r\n", buf) == 0)) { i = n + 1; @@ -895,7 +895,7 @@ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n, /* don't consider line endings part of the buffer * for regex matching */ - if ((nl = mutt_strlen(buf)) > 0 && buf[nl - 1] == '\n') + if ((nl = mutt_str_strlen(buf)) > 0 && buf[nl - 1] == '\n') buf[nl - 1] = 0; i = 0; @@ -967,7 +967,7 @@ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n, size_t nl; /* don't consider line endings part of the buffer for regex matching */ - nl = mutt_strlen(buf); + nl = mutt_str_strlen(buf); if ((nl > 0) && (buf[nl - 1] == '\n')) buf[nl - 1] = 0; @@ -1965,8 +1965,8 @@ static void pager_menu_redraw(struct Menu *pager_menu) snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * rd->last_offset / rd->sb.st_size)); else - strfcpy(pager_progress_str, (rd->topline == 0) ? "all" : "end", - sizeof(pager_progress_str)); + mutt_str_strfcpy(pager_progress_str, (rd->topline == 0) ? "all" : "end", + sizeof(pager_progress_str)); /* print out the pager status bar */ mutt_window_move(rd->pager_status_window, 0, 0); @@ -2098,7 +2098,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e mutt_compile_help(helpstr, sizeof(helpstr), MENU_PAGER, PagerHelp); if (IsHeader(extra)) { - strfcpy(tmphelp, helpstr, sizeof(tmphelp)); + mutt_str_strfcpy(tmphelp, helpstr, sizeof(tmphelp)); mutt_compile_help(buffer, sizeof(buffer), MENU_PAGER, #ifdef USE_NNTP (Context && (Context->magic == MUTT_NNTP)) ? PagerNewsHelpExtra : @@ -2108,7 +2108,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e } if (!InHelp) { - strfcpy(tmphelp, helpstr, sizeof(tmphelp)); + mutt_str_strfcpy(tmphelp, helpstr, sizeof(tmphelp)); mutt_make_help(buffer, sizeof(buffer), _("Help"), MENU_PAGER, OP_HELP); snprintf(helpstr, sizeof(helpstr), "%s %s", tmphelp, buffer); } @@ -2450,7 +2450,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e case OP_SEARCH: case OP_SEARCH_REVERSE: - strfcpy(buffer, searchbuf, sizeof(buffer)); + mutt_str_strfcpy(buffer, searchbuf, sizeof(buffer)); if (mutt_get_field((ch == OP_SEARCH || ch == OP_SEARCH_NEXT) ? _("Search for: ") : _("Reverse search for: "), @@ -2475,7 +2475,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e if (!buffer[0]) break; - strfcpy(searchbuf, buffer, sizeof(searchbuf)); + mutt_str_strfcpy(searchbuf, buffer, sizeof(searchbuf)); /* leave search_back alone if ch == OP_SEARCH_NEXT */ if (ch == OP_SEARCH) @@ -2916,7 +2916,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e else followup_to = extra->hdr->env->followup_to; - if (!followup_to || (mutt_strcasecmp(followup_to, "poster") != 0) || + if (!followup_to || (mutt_str_strcasecmp(followup_to, "poster") != 0) || query_quadoption(OPT_FOLLOWUP_TO_POSTER, _("Reply by mail as poster prefers?")) != MUTT_YES) { diff --git a/parameter.c b/parameter.c index a3068e369..8539bde33 100644 --- a/parameter.c +++ b/parameter.c @@ -66,7 +66,7 @@ void mutt_free_parameter(struct Parameter **p) char *mutt_get_parameter(const char *s, struct Parameter *p) { for (; p; p = p->next) - if (mutt_strcasecmp(s, p->attribute) == 0) + if (mutt_str_strcasecmp(s, p->attribute) == 0) return p->value; return NULL; @@ -95,7 +95,7 @@ void mutt_set_parameter(const char *attribute, const char *value, struct Paramet for (q = *p; q; q = q->next) { - if (mutt_strcasecmp(attribute, q->attribute) == 0) + if (mutt_str_strcasecmp(attribute, q->attribute) == 0) { mutt_str_replace(&q->value, value); return; @@ -103,8 +103,8 @@ void mutt_set_parameter(const char *attribute, const char *value, struct Paramet } q = mutt_new_parameter(); - q->attribute = safe_strdup(attribute); - q->value = safe_strdup(value); + q->attribute = mutt_str_strdup(attribute); + q->value = mutt_str_strdup(value); q->next = *p; *p = q; } @@ -118,7 +118,7 @@ void mutt_delete_parameter(const char *attribute, struct Parameter **p) { for (struct Parameter *q = *p; q; p = &q->next, q = q->next) { - if (mutt_strcasecmp(attribute, q->attribute) == 0) + if (mutt_str_strcasecmp(attribute, q->attribute) == 0) { *p = q->next; q->next = NULL; diff --git a/parse.c b/parse.c index bd98b2c2b..aa7364267 100644 --- a/parse.c +++ b/parse.c @@ -73,7 +73,7 @@ char *mutt_read_rfc822_line(FILE *f, char *line, size_t *linelen) return line; } - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); if (!len) return line; @@ -127,20 +127,21 @@ static void parse_references(struct ListHead *head, char *s) int mutt_check_encoding(const char *c) { - if (mutt_strncasecmp("7bit", c, sizeof("7bit") - 1) == 0) + if (mutt_str_strncasecmp("7bit", c, sizeof("7bit") - 1) == 0) return ENC7BIT; - else if (mutt_strncasecmp("8bit", c, sizeof("8bit") - 1) == 0) + else if (mutt_str_strncasecmp("8bit", c, sizeof("8bit") - 1) == 0) return ENC8BIT; - else if (mutt_strncasecmp("binary", c, sizeof("binary") - 1) == 0) + else if (mutt_str_strncasecmp("binary", c, sizeof("binary") - 1) == 0) return ENCBINARY; - else if (mutt_strncasecmp("quoted-printable", c, sizeof("quoted-printable") - 1) == 0) + else if (mutt_str_strncasecmp("quoted-printable", c, + sizeof("quoted-printable") - 1) == 0) return ENCQUOTEDPRINTABLE; - else if (mutt_strncasecmp("base64", c, sizeof("base64") - 1) == 0) + else if (mutt_str_strncasecmp("base64", c, sizeof("base64") - 1) == 0) return ENCBASE64; - else if (mutt_strncasecmp("x-uuencode", c, sizeof("x-uuencode") - 1) == 0) + else if (mutt_str_strncasecmp("x-uuencode", c, sizeof("x-uuencode") - 1) == 0) return ENCUUENCODED; #ifdef SUN_ATTACHMENT - else if (mutt_strncasecmp("uuencode", c, sizeof("uuencode") - 1) == 0) + else if (mutt_str_strncasecmp("uuencode", c, sizeof("uuencode") - 1) == 0) return ENCUUENCODED; #endif else @@ -170,7 +171,7 @@ static struct Parameter *parse_parameters(const char *s) { i = p - s; /* remove whitespace from the end of the attribute name */ - while (i > 0 && is_email_wsp(s[i - 1])) + while (i > 0 && mutt_str_is_email_wsp(s[i - 1])) i--; /* the check for the missing parameter token is here so that we can skip @@ -184,10 +185,10 @@ static struct Parameter *parse_parameters(const char *s) else { new = mutt_new_parameter(); - new->attribute = mutt_substrdup(s, s + i); + new->attribute = mutt_str_substr_dup(s, s + i); } - s = skip_email_wsp(p + 1); /* skip over the = */ + s = mutt_str_skip_email_wsp(p + 1); /* skip over the = */ if (*s == '"') { @@ -233,7 +234,7 @@ static struct Parameter *parse_parameters(const char *s) /* if the attribute token was missing, 'new' will be NULL */ if (new) { - new->value = safe_strdup(buffer); + new->value = mutt_str_strdup(buffer); mutt_debug(2, "parse_parameter: `%s' = `%s'\n", new->attribute ? new->attribute : "", new->value ? new->value : ""); @@ -261,7 +262,7 @@ static struct Parameter *parse_parameters(const char *s) do { /* Move past any leading whitespace. the +1 skips over the semicolon */ - s = skip_email_wsp(s + 1); + s = mutt_str_skip_email_wsp(s + 1); } while (*s == ';'); /* skip empty parameters */ } @@ -273,29 +274,29 @@ bail: int mutt_check_mime_type(const char *s) { - if (mutt_strcasecmp("text", s) == 0) + if (mutt_str_strcasecmp("text", s) == 0) return TYPETEXT; - else if (mutt_strcasecmp("multipart", s) == 0) + else if (mutt_str_strcasecmp("multipart", s) == 0) return TYPEMULTIPART; #ifdef SUN_ATTACHMENT - else if (mutt_strcasecmp("x-sun-attachment", s) == 0) + else if (mutt_str_strcasecmp("x-sun-attachment", s) == 0) return TYPEMULTIPART; #endif - else if (mutt_strcasecmp("application", s) == 0) + else if (mutt_str_strcasecmp("application", s) == 0) return TYPEAPPLICATION; - else if (mutt_strcasecmp("message", s) == 0) + else if (mutt_str_strcasecmp("message", s) == 0) return TYPEMESSAGE; - else if (mutt_strcasecmp("image", s) == 0) + else if (mutt_str_strcasecmp("image", s) == 0) return TYPEIMAGE; - else if (mutt_strcasecmp("audio", s) == 0) + else if (mutt_str_strcasecmp("audio", s) == 0) return TYPEAUDIO; - else if (mutt_strcasecmp("video", s) == 0) + else if (mutt_str_strcasecmp("video", s) == 0) return TYPEVIDEO; - else if (mutt_strcasecmp("model", s) == 0) + else if (mutt_str_strcasecmp("model", s) == 0) return TYPEMODEL; - else if (mutt_strcasecmp("*", s) == 0) + else if (mutt_str_strcasecmp("*", s) == 0) return TYPEANY; - else if (mutt_strcasecmp(".*", s) == 0) + else if (mutt_str_strcasecmp(".*", s) == 0) return TYPEANY; else return TYPEOTHER; @@ -322,7 +323,7 @@ void mutt_parse_content_type(char *s, struct Body *ct) * but if a filename has already been set in the content-disposition, * let that take precedence, and don't set it here */ if ((pc = mutt_get_parameter("name", ct->parameter)) && !ct->filename) - ct->filename = safe_strdup(pc); + ct->filename = mutt_str_strdup(pc); #ifdef SUN_ATTACHMENT /* this is deep and utter perversion */ @@ -338,20 +339,20 @@ void mutt_parse_content_type(char *s, struct Body *ct) for (pc = subtype; *pc && !ISSPACE(*pc) && *pc != ';'; pc++) ; *pc = '\0'; - ct->subtype = safe_strdup(subtype); + ct->subtype = mutt_str_strdup(subtype); } /* Finally, get the major type */ ct->type = mutt_check_mime_type(s); #ifdef SUN_ATTACHMENT - if (mutt_strcasecmp("x-sun-attachment", s) == 0) - ct->subtype = safe_strdup("x-sun-attachment"); + if (mutt_str_strcasecmp("x-sun-attachment", s) == 0) + ct->subtype = mutt_str_strdup("x-sun-attachment"); #endif if (ct->type == TYPEOTHER) { - ct->xtype = safe_strdup(s); + ct->xtype = mutt_str_strdup(s); } if (!ct->subtype) @@ -360,21 +361,21 @@ void mutt_parse_content_type(char *s, struct Body *ct) * field, so we can attempt to convert the type to Body here. */ if (ct->type == TYPETEXT) - ct->subtype = safe_strdup("plain"); + ct->subtype = mutt_str_strdup("plain"); else if (ct->type == TYPEAUDIO) - ct->subtype = safe_strdup("basic"); + ct->subtype = mutt_str_strdup("basic"); else if (ct->type == TYPEMESSAGE) - ct->subtype = safe_strdup("rfc822"); + ct->subtype = mutt_str_strdup("rfc822"); else if (ct->type == TYPEOTHER) { char buffer[SHORT_STRING]; ct->type = TYPEAPPLICATION; snprintf(buffer, sizeof(buffer), "x-%s", s); - ct->subtype = safe_strdup(buffer); + ct->subtype = mutt_str_strdup(buffer); } else - ct->subtype = safe_strdup("x-unknown"); + ct->subtype = mutt_str_strdup("x-unknown"); } /* Default character set for text types. */ @@ -394,9 +395,9 @@ static void parse_content_disposition(const char *s, struct Body *ct) { struct Parameter *parms = NULL; - if (mutt_strncasecmp("inline", s, 6) == 0) + if (mutt_str_strncasecmp("inline", s, 6) == 0) ct->disposition = DISPINLINE; - else if (mutt_strncasecmp("form-data", s, 9) == 0) + else if (mutt_str_strncasecmp("form-data", s, 9) == 0) ct->disposition = DISPFORMDATA; else ct->disposition = DISPATTACH; @@ -405,11 +406,11 @@ static void parse_content_disposition(const char *s, struct Body *ct) s = strchr(s, ';'); if (s) { - s = skip_email_wsp(s + 1); + s = mutt_str_skip_email_wsp(s + 1); if ((s = mutt_get_parameter("filename", (parms = parse_parameters(s))))) mutt_str_replace(&ct->filename, s); if ((s = mutt_get_parameter("name", parms))) - ct->form_name = safe_strdup(s); + ct->form_name = mutt_str_strdup(s); mutt_free_parameter(&parms); } } @@ -438,7 +439,7 @@ struct Body *mutt_read_mime_header(FILE *fp, int digest) if ((c = strchr(line, ':'))) { *c = 0; - c = skip_email_wsp(c + 1); + c = mutt_str_skip_email_wsp(c + 1); if (!*c) { mutt_debug(1, @@ -452,30 +453,30 @@ struct Body *mutt_read_mime_header(FILE *fp, int digest) break; } - if (mutt_strncasecmp("content-", line, 8) == 0) + if (mutt_str_strncasecmp("content-", line, 8) == 0) { - if (mutt_strcasecmp("type", line + 8) == 0) + if (mutt_str_strcasecmp("type", line + 8) == 0) mutt_parse_content_type(c, p); - else if (mutt_strcasecmp("transfer-encoding", line + 8) == 0) + else if (mutt_str_strcasecmp("transfer-encoding", line + 8) == 0) p->encoding = mutt_check_encoding(c); - else if (mutt_strcasecmp("disposition", line + 8) == 0) + else if (mutt_str_strcasecmp("disposition", line + 8) == 0) parse_content_disposition(c, p); - else if (mutt_strcasecmp("description", line + 8) == 0) + else if (mutt_str_strcasecmp("description", line + 8) == 0) { mutt_str_replace(&p->description, c); rfc2047_decode(&p->description); } } #ifdef SUN_ATTACHMENT - else if (mutt_strncasecmp("x-sun-", line, 6) == 0) + else if (mutt_str_strncasecmp("x-sun-", line, 6) == 0) { - if (mutt_strcasecmp("data-type", line + 6) == 0) + if (mutt_str_strcasecmp("data-type", line + 6) == 0) mutt_parse_content_type(c, p); - else if (mutt_strcasecmp("encoding-info", line + 6) == 0) + else if (mutt_str_strcasecmp("encoding-info", line + 6) == 0) p->encoding = mutt_check_encoding(c); - else if (mutt_strcasecmp("content-lines", line + 6) == 0) + else if (mutt_str_strcasecmp("content-lines", line + 6) == 0) mutt_set_parameter("content-lines", c, &(p->parameter)); - else if (mutt_strcasecmp("data-description", line + 6) == 0) + else if (mutt_str_strcasecmp("data-description", line + 6) == 0) { mutt_str_replace(&p->description, c); rfc2047_decode(&p->description); @@ -485,9 +486,9 @@ struct Body *mutt_read_mime_header(FILE *fp, int digest) } p->offset = ftello(fp); /* Mark the start of the real data */ if (p->type == TYPETEXT && !p->subtype) - p->subtype = safe_strdup("plain"); + p->subtype = mutt_str_strdup("plain"); else if (p->type == TYPEMESSAGE && !p->subtype) - p->subtype = safe_strdup("rfc822"); + p->subtype = mutt_str_strdup("rfc822"); FREE(&line); @@ -502,7 +503,7 @@ void mutt_parse_part(FILE *fp, struct Body *b) { case TYPEMULTIPART: #ifdef SUN_ATTACHMENT - if (mutt_strcasecmp(b->subtype, "x-sun-attachment") == 0) + if (mutt_str_strcasecmp(b->subtype, "x-sun-attachment") == 0) bound = "--------"; else #endif @@ -510,7 +511,7 @@ void mutt_parse_part(FILE *fp, struct Body *b) fseeko(fp, b->offset, SEEK_SET); b->parts = mutt_parse_multipart(fp, bound, b->offset + b->length, - (mutt_strcasecmp("digest", b->subtype) == 0)); + (mutt_str_strcasecmp("digest", b->subtype) == 0)); break; case TYPEMESSAGE: @@ -519,7 +520,7 @@ void mutt_parse_part(FILE *fp, struct Body *b) fseeko(fp, b->offset, SEEK_SET); if (mutt_is_message_type(b->type, b->subtype)) b->parts = mutt_parse_message_rfc822(fp, b); - else if (mutt_strcasecmp(b->subtype, "external-body") == 0) + else if (mutt_str_strcasecmp(b->subtype, "external-body") == 0) b->parts = mutt_read_mime_header(fp, 0); else return; @@ -592,15 +593,15 @@ struct Body *mutt_parse_multipart(FILE *fp, const char *boundary, LOFF_T end_off return NULL; } - blen = mutt_strlen(boundary); + blen = mutt_str_strlen(boundary); while (ftello(fp) < end_off && fgets(buffer, LONG_STRING, fp) != NULL) { - len = mutt_strlen(buffer); + len = mutt_str_strlen(buffer); crlf = (len > 1 && buffer[len - 2] == '\r') ? 1 : 0; if (buffer[0] == '-' && buffer[1] == '-' && - (mutt_strncmp(buffer + 2, boundary, blen) == 0)) + (mutt_str_strncmp(buffer + 2, boundary, blen) == 0)) { if (last) { @@ -617,7 +618,7 @@ struct Body *mutt_parse_multipart(FILE *fp, const char *boundary, LOFF_T end_off buffer[i] = 0; /* Check for the end boundary */ - if (mutt_strcmp(buffer + blen + 2, "--") == 0) + if (mutt_str_strcmp(buffer + blen + 2, "--") == 0) { final = true; break; /* done parsing */ @@ -629,7 +630,7 @@ struct Body *mutt_parse_multipart(FILE *fp, const char *boundary, LOFF_T end_off #ifdef SUN_ATTACHMENT if (mutt_get_parameter("content-lines", new->parameter)) { - if (mutt_atoi(mutt_get_parameter("content-lines", new->parameter), &lines) < 0) + if (mutt_str_atoi(mutt_get_parameter("content-lines", new->parameter), &lines) < 0) lines = 0; for (; lines; lines--) if (ftello(fp) >= end_off || fgets(buffer, LONG_STRING, fp) == NULL) @@ -765,12 +766,12 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, switch (tolower(line[0])) { case 'a': - if (mutt_strcasecmp(line + 1, "pparently-to") == 0) + if (mutt_str_strcasecmp(line + 1, "pparently-to") == 0) { e->to = rfc822_parse_adrlist(e->to, p); matched = 1; } - else if (mutt_strcasecmp(line + 1, "pparently-from") == 0) + else if (mutt_str_strcasecmp(line + 1, "pparently-from") == 0) { e->from = rfc822_parse_adrlist(e->from, p); matched = 1; @@ -778,7 +779,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 'b': - if (mutt_strcasecmp(line + 1, "cc") == 0) + if (mutt_str_strcasecmp(line + 1, "cc") == 0) { e->bcc = rfc822_parse_adrlist(e->bcc, p); matched = 1; @@ -786,26 +787,26 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 'c': - if (mutt_strcasecmp(line + 1, "c") == 0) + if (mutt_str_strcasecmp(line + 1, "c") == 0) { e->cc = rfc822_parse_adrlist(e->cc, p); matched = 1; } - else if (mutt_strncasecmp(line + 1, "ontent-", 7) == 0) + else if (mutt_str_strncasecmp(line + 1, "ontent-", 7) == 0) { - if (mutt_strcasecmp(line + 8, "type") == 0) + if (mutt_str_strcasecmp(line + 8, "type") == 0) { if (hdr) mutt_parse_content_type(p, hdr->content); matched = 1; } - else if (mutt_strcasecmp(line + 8, "transfer-encoding") == 0) + else if (mutt_str_strcasecmp(line + 8, "transfer-encoding") == 0) { if (hdr) hdr->content->encoding = mutt_check_encoding(p); matched = 1; } - else if (mutt_strcasecmp(line + 8, "length") == 0) + else if (mutt_str_strcasecmp(line + 8, "length") == 0) { if (hdr) { @@ -815,7 +816,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, } matched = 1; } - else if (mutt_strcasecmp(line + 8, "description") == 0) + else if (mutt_str_strcasecmp(line + 8, "description") == 0) { if (hdr) { @@ -824,7 +825,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, } matched = 1; } - else if (mutt_strcasecmp(line + 8, "disposition") == 0) + else if (mutt_str_strcasecmp(line + 8, "disposition") == 0) { if (hdr) parse_content_disposition(p, hdr->content); @@ -834,7 +835,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 'd': - if (mutt_strcasecmp("ate", line + 1) == 0) + if (mutt_str_strcasecmp("ate", line + 1) == 0) { mutt_str_replace(&e->date, p); if (hdr) @@ -853,24 +854,24 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 'e': - if ((mutt_strcasecmp("xpires", line + 1) == 0) && hdr && + if ((mutt_str_strcasecmp("xpires", line + 1) == 0) && hdr && mutt_date_parse_date(p, NULL) < time(NULL)) hdr->expired = true; break; case 'f': - if (mutt_strcasecmp("rom", line + 1) == 0) + if (mutt_str_strcasecmp("rom", line + 1) == 0) { e->from = rfc822_parse_adrlist(e->from, p); matched = 1; } #ifdef USE_NNTP - else if (mutt_strcasecmp(line + 1, "ollowup-to") == 0) + else if (mutt_str_strcasecmp(line + 1, "ollowup-to") == 0) { if (!e->followup_to) { - mutt_remove_trailing_ws(p); - e->followup_to = safe_strdup(mutt_skip_whitespace(p)); + mutt_str_remove_trailing_ws(p); + e->followup_to = mutt_str_strdup(mutt_str_skip_whitespace(p)); } matched = 1; } @@ -878,7 +879,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 'i': - if (mutt_strcasecmp(line + 1, "n-reply-to") == 0) + if (mutt_str_strcasecmp(line + 1, "n-reply-to") == 0) { mutt_list_free(&e->in_reply_to); parse_references(&e->in_reply_to, p); @@ -887,7 +888,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 'l': - if (mutt_strcasecmp(line + 1, "ines") == 0) + if (mutt_str_strcasecmp(line + 1, "ines") == 0) { if (hdr) { @@ -895,13 +896,13 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, * HACK - neomutt has, for a very short time, produced negative * Lines header values. Ignore them. */ - if (mutt_atoi(p, &hdr->lines) < 0 || hdr->lines < 0) + if (mutt_str_atoi(p, &hdr->lines) < 0 || hdr->lines < 0) hdr->lines = 0; } matched = 1; } - else if (mutt_strcasecmp(line + 1, "ist-Post") == 0) + else if (mutt_str_strcasecmp(line + 1, "ist-Post") == 0) { /* RFC2369. FIXME: We should ignore whitespace, but don't. */ if (strncmp(p, "NO", 2) != 0) @@ -918,7 +919,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, if (url_check_scheme(beg) == U_MAILTO) { FREE(&e->list_post); - e->list_post = mutt_substrdup(beg, end); + e->list_post = mutt_str_substr_dup(beg, end); break; } } @@ -928,29 +929,29 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 'm': - if (mutt_strcasecmp(line + 1, "ime-version") == 0) + if (mutt_str_strcasecmp(line + 1, "ime-version") == 0) { if (hdr) hdr->mime = true; matched = 1; } - else if (mutt_strcasecmp(line + 1, "essage-id") == 0) + else if (mutt_str_strcasecmp(line + 1, "essage-id") == 0) { /* We add a new "Message-ID:" when building a message */ FREE(&e->message_id); e->message_id = mutt_extract_message_id(p, NULL); matched = 1; } - else if (mutt_strncasecmp(line + 1, "ail-", 4) == 0) + else if (mutt_str_strncasecmp(line + 1, "ail-", 4) == 0) { - if (mutt_strcasecmp(line + 5, "reply-to") == 0) + if (mutt_str_strcasecmp(line + 5, "reply-to") == 0) { /* override the Reply-To: field */ rfc822_free_address(&e->reply_to); e->reply_to = rfc822_parse_adrlist(e->reply_to, p); matched = 1; } - else if (mutt_strcasecmp(line + 5, "followup-to") == 0) + else if (mutt_str_strcasecmp(line + 5, "followup-to") == 0) { e->mail_followup_to = rfc822_parse_adrlist(e->mail_followup_to, p); matched = 1; @@ -960,11 +961,11 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, #ifdef USE_NNTP case 'n': - if (mutt_strcasecmp(line + 1, "ewsgroups") == 0) + if (mutt_str_strcasecmp(line + 1, "ewsgroups") == 0) { FREE(&e->newsgroups); - mutt_remove_trailing_ws(p); - e->newsgroups = safe_strdup(mutt_skip_whitespace(p)); + mutt_str_remove_trailing_ws(p); + e->newsgroups = mutt_str_strdup(mutt_str_skip_whitespace(p)); matched = 1; } break; @@ -972,31 +973,31 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, case 'o': /* field `Organization:' saves only for pager! */ - if (mutt_strcasecmp(line + 1, "rganization") == 0) + if (mutt_str_strcasecmp(line + 1, "rganization") == 0) { - if (!e->organization && (mutt_strcasecmp(p, "unknown") != 0)) - e->organization = safe_strdup(p); + if (!e->organization && (mutt_str_strcasecmp(p, "unknown") != 0)) + e->organization = mutt_str_strdup(p); } break; case 'r': - if (mutt_strcasecmp(line + 1, "eferences") == 0) + if (mutt_str_strcasecmp(line + 1, "eferences") == 0) { mutt_list_free(&e->references); parse_references(&e->references, p); matched = 1; } - else if (mutt_strcasecmp(line + 1, "eply-to") == 0) + else if (mutt_str_strcasecmp(line + 1, "eply-to") == 0) { e->reply_to = rfc822_parse_adrlist(e->reply_to, p); matched = 1; } - else if (mutt_strcasecmp(line + 1, "eturn-path") == 0) + else if (mutt_str_strcasecmp(line + 1, "eturn-path") == 0) { e->return_path = rfc822_parse_adrlist(e->return_path, p); matched = 1; } - else if (mutt_strcasecmp(line + 1, "eceived") == 0) + else if (mutt_str_strcasecmp(line + 1, "eceived") == 0) { if (hdr && !hdr->received) { @@ -1009,18 +1010,18 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 's': - if (mutt_strcasecmp(line + 1, "ubject") == 0) + if (mutt_str_strcasecmp(line + 1, "ubject") == 0) { if (!e->subject) - e->subject = safe_strdup(p); + e->subject = mutt_str_strdup(p); matched = 1; } - else if (mutt_strcasecmp(line + 1, "ender") == 0) + else if (mutt_str_strcasecmp(line + 1, "ender") == 0) { e->sender = rfc822_parse_adrlist(e->sender, p); matched = 1; } - else if (mutt_strcasecmp(line + 1, "tatus") == 0) + else if (mutt_str_strcasecmp(line + 1, "tatus") == 0) { if (hdr) { @@ -1043,17 +1044,17 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, } matched = 1; } - else if (((mutt_strcasecmp("upersedes", line + 1) == 0) || - (mutt_strcasecmp("upercedes", line + 1) == 0)) && + else if (((mutt_str_strcasecmp("upersedes", line + 1) == 0) || + (mutt_str_strcasecmp("upercedes", line + 1) == 0)) && hdr) { FREE(&e->supersedes); - e->supersedes = safe_strdup(p); + e->supersedes = mutt_str_strdup(p); } break; case 't': - if (mutt_strcasecmp(line + 1, "o") == 0) + if (mutt_str_strcasecmp(line + 1, "o") == 0) { e->to = rfc822_parse_adrlist(e->to, p); matched = 1; @@ -1061,7 +1062,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, break; case 'x': - if (mutt_strcasecmp(line + 1, "-status") == 0) + if (mutt_str_strcasecmp(line + 1, "-status") == 0) { if (hdr) { @@ -1086,27 +1087,27 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, } matched = 1; } - else if (mutt_strcasecmp(line + 1, "-label") == 0) + else if (mutt_str_strcasecmp(line + 1, "-label") == 0) { FREE(&e->x_label); - e->x_label = safe_strdup(p); + e->x_label = mutt_str_strdup(p); matched = 1; } #ifdef USE_NNTP - else if (mutt_strcasecmp(line + 1, "-comment-to") == 0) + else if (mutt_str_strcasecmp(line + 1, "-comment-to") == 0) { if (!e->x_comment_to) - e->x_comment_to = safe_strdup(p); + e->x_comment_to = mutt_str_strdup(p); matched = 1; } - else if (mutt_strcasecmp(line + 1, "ref") == 0) + else if (mutt_str_strcasecmp(line + 1, "ref") == 0) { if (!e->xref) - e->xref = safe_strdup(p); + e->xref = mutt_str_strdup(p); matched = 1; } #endif - else if (mutt_strcasecmp(line + 1, "-original-to") == 0) + else if (mutt_str_strcasecmp(line + 1, "-original-to") == 0) { e->x_original_to = rfc822_parse_adrlist(e->x_original_to, p); matched = 1; @@ -1124,7 +1125,7 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, if (!(weed && option(OPT_WEED) && mutt_matches_ignore(line))) { - struct ListNode *np = mutt_list_insert_tail(&e->userhdrs, safe_strdup(line)); + struct ListNode *np = mutt_list_insert_tail(&e->userhdrs, mutt_str_strdup(line)); if (do_2047) rfc2047_decode(&np->data); } @@ -1164,7 +1165,7 @@ struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr, /* set the defaults from RFC1521 */ hdr->content->type = TYPETEXT; - hdr->content->subtype = safe_strdup("plain"); + hdr->content->subtype = mutt_str_strdup("plain"); hdr->content->encoding = ENC7BIT; hdr->content->length = -1; @@ -1184,7 +1185,7 @@ struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr, time_t t; /* some bogus MTAs will quote the original "From " line */ - if (mutt_strncmp(">From ", line, 6) == 0) + if (mutt_str_strncmp(">From ", line, 6) == 0) continue; /* just ignore */ else if (is_from(line, return_path, sizeof(return_path), &t)) { @@ -1241,7 +1242,7 @@ struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr, } *p = 0; - p = skip_email_wsp(p + 1); + p = mutt_str_skip_email_wsp(p + 1); if (!*p) continue; /* skip empty header fields */ @@ -1316,7 +1317,7 @@ struct Address *mutt_parse_adrlist(struct Address *p, const char *s) char tmp[HUGE_STRING]; char *r = NULL; - strfcpy(tmp, s, sizeof(tmp)); + mutt_str_strfcpy(tmp, s, sizeof(tmp)); r = tmp; while ((r = strtok(r, " \t")) != NULL) { @@ -1390,7 +1391,7 @@ static int count_body_parts(struct Body *body, int flags) shallrecurse = true; /* If it's an external body pointer, don't recurse it. */ - if (mutt_strcasecmp(bp->subtype, "external-body") == 0) + if (mutt_str_strcasecmp(bp->subtype, "external-body") == 0) shallrecurse = false; /* Don't count containers if they're top-level. */ @@ -1401,7 +1402,7 @@ static int count_body_parts(struct Body *body, int flags) { /* Always recurse multiparts, except multipart/alternative. */ shallrecurse = true; - if (mutt_strcasecmp(bp->subtype, "alternative") == 0) + if (mutt_str_strcasecmp(bp->subtype, "alternative") == 0) shallrecurse = false; /* Don't count containers if they're top-level. */ diff --git a/pattern.c b/pattern.c index 9491f9ea9..23df1fbbc 100644 --- a/pattern.c +++ b/pattern.c @@ -100,7 +100,7 @@ static bool eat_regex(struct Pattern *pat, struct Buffer *s, struct Buffer *err) if (pat->stringmatch) { - pat->p.str = safe_strdup(buf.data); + pat->p.str = mutt_str_strdup(buf.data); pat->ign_case = mutt_which_case(buf.data) == REG_ICASE; FREE(&buf.data); } @@ -657,7 +657,7 @@ static bool is_context_available(struct Buffer *s, regmatch_t pmatch[], return true; /* Nope. */ - strfcpy(err->data, _("No current message"), err->dsize); + mutt_str_strfcpy(err->data, _("No current message"), err->dsize); return false; } @@ -764,7 +764,7 @@ static int eat_range_by_regex(struct Pattern *pat, struct Buffer *s, int kind, { if (!Context->menu) { - strfcpy(err->data, _("No current message"), err->dsize); + mutt_str_strfcpy(err->data, _("No current message"), err->dsize); return RANGE_E_CTX; } pat->min = pat->max = CTX_MSGNO(Context); @@ -785,7 +785,7 @@ static bool eat_message_range(struct Pattern *pat, struct Buffer *s, struct Buff /* We need a Context for pretty much anything. */ if (!Context) { - strfcpy(err->data, _("No Context"), err->dsize); + mutt_str_strfcpy(err->data, _("No Context"), err->dsize); return false; } @@ -1057,7 +1057,7 @@ static int msg_search(struct Context *ctx, struct Pattern *pat, int msgno) match = 1; break; } - lng -= mutt_strlen(buf); + lng -= mutt_str_strlen(buf); } FREE(&buf); @@ -1148,7 +1148,7 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer mutt_buffer_init(&ps); ps.dptr = s; - ps.dsize = mutt_strlen(s); + ps.dsize = mutt_str_strlen(s); while (*ps.dptr) { @@ -1236,7 +1236,7 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer alladdr = false; isalias = false; /* compile the sub-expression */ - buf = mutt_substrdup(ps.dptr + 1, p); + buf = mutt_str_substr_dup(ps.dptr + 1, p); tmp2 = mutt_pattern_comp(buf, flags, err); if (!tmp2) { @@ -1320,7 +1320,7 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer return NULL; } /* compile the sub-expression */ - buf = mutt_substrdup(ps.dptr + 1, p); + buf = mutt_str_substr_dup(ps.dptr + 1, p); tmp = mutt_pattern_comp(buf, flags, err); if (!tmp) { @@ -1350,7 +1350,7 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer } if (!curlist) { - strfcpy(err->data, _("empty pattern"), err->dsize); + mutt_str_strfcpy(err->data, _("empty pattern"), err->dsize); return NULL; } if (curlist->next) @@ -1815,32 +1815,32 @@ void mutt_check_simple(char *s, size_t len, const char *simple) } } - /* XXX - is mutt_strcasecmp() right here, or should we use locale's + /* XXX - is mutt_str_strcasecmp() right here, or should we use locale's * equivalences? */ if (do_simple) /* yup, so spoof a real request */ { /* convert old tokens into the new format */ - if ((mutt_strcasecmp("all", s) == 0) || (mutt_strcmp("^", s) == 0) || - (mutt_strcmp(".", s) == 0)) /* ~A is more efficient */ - strfcpy(s, "~A", len); - else if (mutt_strcasecmp("del", s) == 0) - strfcpy(s, "~D", len); - else if (mutt_strcasecmp("flag", s) == 0) - strfcpy(s, "~F", len); - else if (mutt_strcasecmp("new", s) == 0) - strfcpy(s, "~N", len); - else if (mutt_strcasecmp("old", s) == 0) - strfcpy(s, "~O", len); - else if (mutt_strcasecmp("repl", s) == 0) - strfcpy(s, "~Q", len); - else if (mutt_strcasecmp("read", s) == 0) - strfcpy(s, "~R", len); - else if (mutt_strcasecmp("tag", s) == 0) - strfcpy(s, "~T", len); - else if (mutt_strcasecmp("unread", s) == 0) - strfcpy(s, "~U", len); + if ((mutt_str_strcasecmp("all", s) == 0) || (mutt_str_strcmp("^", s) == 0) || + (mutt_str_strcmp(".", s) == 0)) /* ~A is more efficient */ + mutt_str_strfcpy(s, "~A", len); + else if (mutt_str_strcasecmp("del", s) == 0) + mutt_str_strfcpy(s, "~D", len); + else if (mutt_str_strcasecmp("flag", s) == 0) + mutt_str_strfcpy(s, "~F", len); + else if (mutt_str_strcasecmp("new", s) == 0) + mutt_str_strfcpy(s, "~N", len); + else if (mutt_str_strcasecmp("old", s) == 0) + mutt_str_strfcpy(s, "~O", len); + else if (mutt_str_strcasecmp("repl", s) == 0) + mutt_str_strfcpy(s, "~Q", len); + else if (mutt_str_strcasecmp("read", s) == 0) + mutt_str_strfcpy(s, "~R", len); + else if (mutt_str_strcasecmp("tag", s) == 0) + mutt_str_strfcpy(s, "~T", len); + else if (mutt_str_strcasecmp("unread", s) == 0) + mutt_str_strfcpy(s, "~U", len); else { quote_simple(tmp, sizeof(tmp), s); @@ -1919,14 +1919,14 @@ int mutt_pattern_func(int op, char *prompt) struct Buffer err; struct Progress progress; - strfcpy(buf, NONULL(Context->pattern), sizeof(buf)); + mutt_str_strfcpy(buf, NONULL(Context->pattern), sizeof(buf)); if (prompt || op != MUTT_LIMIT) if (mutt_get_field(prompt, buf, sizeof(buf), MUTT_PATTERN | MUTT_CLEAR) != 0 || !buf[0]) return -1; mutt_message(_("Compiling search pattern...")); - simple = safe_strdup(buf); + simple = mutt_str_strdup(buf); mutt_check_simple(buf, sizeof(buf), NONULL(SimpleSearch)); mutt_buffer_init(&err); @@ -2014,7 +2014,7 @@ int mutt_pattern_func(int op, char *prompt) mutt_error(_("No messages matched criteria.")); /* record new limit pattern, unless match all */ - if (mutt_strcmp(buf, "~A") != 0) + if (mutt_str_strcmp(buf, "~A") != 0) { Context->pattern = simple; simple = NULL; /* don't clobber it */ @@ -2039,7 +2039,7 @@ int mutt_search_command(int cur, int op) if (!*LastSearch || (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)) { - strfcpy(buf, *LastSearch ? LastSearch : "", sizeof(buf)); + mutt_str_strfcpy(buf, *LastSearch ? LastSearch : "", sizeof(buf)); if (mutt_get_field((op == OP_SEARCH || op == OP_SEARCH_NEXT) ? _("Search for: ") : _("Reverse search for: "), @@ -2054,15 +2054,15 @@ int mutt_search_command(int cur, int op) /* compare the *expanded* version of the search pattern in case $simple_search has changed while we were searching */ - strfcpy(temp, buf, sizeof(temp)); + mutt_str_strfcpy(temp, buf, sizeof(temp)); mutt_check_simple(temp, sizeof(temp), NONULL(SimpleSearch)); - if (!SearchPattern || (mutt_strcmp(temp, LastSearchExpn) != 0)) + if (!SearchPattern || (mutt_str_strcmp(temp, LastSearchExpn) != 0)) { struct Buffer err; mutt_buffer_init(&err); set_option(OPT_SEARCH_INVALID); - strfcpy(LastSearch, buf, sizeof(LastSearch)); + mutt_str_strfcpy(LastSearch, buf, sizeof(LastSearch)); mutt_message(_("Compiling search pattern...")); mutt_pattern_free(&SearchPattern); err.dsize = STRING; diff --git a/pgppubring.c b/pgppubring.c index 3915ad11c..5f25ce10d 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -186,7 +186,7 @@ static bool pgpring_string_matches_hint(const char *s, const char *hints[], int for (int i = 0; i < nhints; i++) { - if (mutt_stristr(s, hints[i]) != NULL) + if (mutt_str_stristr(s, hints[i]) != NULL) return true; } @@ -298,7 +298,7 @@ static struct PgpKeyInfo *pgp_parse_pgp2_key(unsigned char *buff, size_t l) snprintf((char *) scratch + k * 8, sizeof(scratch) - k * 8, "%08lX", id); } - p->keyid = safe_strdup((char *) scratch); + p->keyid = mutt_str_strdup((char *) scratch); return p; @@ -395,7 +395,7 @@ static struct PgpKeyInfo *pgp_parse_pgp3_key(unsigned char *buff, size_t l) snprintf((char *) scratch + k * 8, sizeof(scratch) - k * 8, "%08lX", id); } - p->keyid = safe_strdup((char *) scratch); + p->keyid = mutt_str_strdup((char *) scratch); return p; } @@ -889,11 +889,11 @@ int main(int argc, char *const argv[]) } if (_kring) - strfcpy(kring, _kring, sizeof(kring)); + mutt_str_strfcpy(kring, _kring, sizeof(kring)); else { if ((env_pgppath = getenv("PGPPATH"))) - strfcpy(pgppath, env_pgppath, sizeof(pgppath)); + mutt_str_strfcpy(pgppath, env_pgppath, sizeof(pgppath)); else if ((env_home = getenv("HOME"))) snprintf(pgppath, sizeof(pgppath), "%s/.pgp", env_home); else diff --git a/pop.c b/pop.c index 9e886c238..f5c91212b 100644 --- a/pop.c +++ b/pop.c @@ -175,7 +175,7 @@ static int fetch_uidl(char *line, void *data) memmove(line, endp, strlen(endp) + 1); for (i = 0; i < ctx->msgcount; i++) - if (mutt_strcmp(line, ctx->hdrs[i]->data) == 0) + if (mutt_str_strcmp(line, ctx->hdrs[i]->data) == 0) break; if (i == ctx->msgcount) @@ -187,7 +187,7 @@ static int fetch_uidl(char *line, void *data) ctx->msgcount++; ctx->hdrs[i] = mutt_new_header(); - ctx->hdrs[i]->data = safe_strdup(line); + ctx->hdrs[i]->data = mutt_str_strdup(line); } else if (ctx->hdrs[i]->index != index - 1) pop_data->clear_cache = true; @@ -218,7 +218,7 @@ static int msg_cache_check(const char *id, struct BodyCache *bcache, void *data) for (int i = 0; i < ctx->msgcount; i++) /* if the id we get is known for a header: done (i.e. keep in cache) */ - if (ctx->hdrs[i]->data && (mutt_strcmp(ctx->hdrs[i]->data, id) == 0)) + if (ctx->hdrs[i]->data && (mutt_str_strcmp(ctx->hdrs[i]->data, id) == 0)) return 0; /* message not found in context -> remove it from cache @@ -327,7 +327,7 @@ static int pop_fetch_headers(struct Context *ctx) #ifdef USE_HCACHE if ((data = mutt_hcache_fetch(hc, ctx->hdrs[i]->data, strlen(ctx->hdrs[i]->data)))) { - char *uidl = safe_strdup(ctx->hdrs[i]->data); + char *uidl = mutt_str_strdup(ctx->hdrs[i]->data); int refno = ctx->hdrs[i]->refno; int index = ctx->hdrs[i]->index; /* @@ -446,8 +446,8 @@ static int pop_open_mailbox(struct Context *ctx) FREE(&ctx->path); FREE(&ctx->realpath); - ctx->path = safe_strdup(buf); - ctx->realpath = safe_strdup(ctx->path); + ctx->path = mutt_str_strdup(buf); + ctx->realpath = mutt_str_strdup(ctx->path); pop_data = mutt_mem_calloc(1, sizeof(struct PopData)); pop_data->conn = conn; @@ -655,7 +655,7 @@ static int pop_fetch_message(struct Context *ctx, struct Message *msg, int msgno else { cache->index = h->index; - cache->path = safe_strdup(path); + cache->path = mutt_str_strdup(path); } rewind(msg->fp); uidl = h->data; @@ -756,7 +756,7 @@ static int pop_sync_mailbox(struct Context *ctx, int *index_hint) if (ret == 0) { - strfcpy(buf, "QUIT\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "QUIT\r\n", sizeof(buf)); ret = pop_query(pop_data, buf, sizeof(buf)); } @@ -867,7 +867,7 @@ void pop_fetch_mail(void) mutt_message(_("Checking for new messages...")); /* find out how many messages are in the mailbox. */ - strfcpy(buffer, "STAT\r\n", sizeof(buffer)); + mutt_str_strfcpy(buffer, "STAT\r\n", sizeof(buffer)); ret = pop_query(pop_data, buffer, sizeof(buffer)); if (ret == -1) goto fail; @@ -882,7 +882,7 @@ void pop_fetch_mail(void) /* only get unread messages */ if (msgs > 0 && option(OPT_POP_LAST)) { - strfcpy(buffer, "LAST\r\n", sizeof(buffer)); + mutt_str_strfcpy(buffer, "LAST\r\n", sizeof(buffer)); ret = pop_query(pop_data, buffer, sizeof(buffer)); if (ret == -1) goto fail; @@ -957,14 +957,14 @@ void pop_fetch_mail(void) if (rset) { /* make sure no messages get deleted */ - strfcpy(buffer, "RSET\r\n", sizeof(buffer)); + mutt_str_strfcpy(buffer, "RSET\r\n", sizeof(buffer)); if (pop_query(pop_data, buffer, sizeof(buffer)) == -1) goto fail; } finish: /* exit gracefully */ - strfcpy(buffer, "QUIT\r\n", sizeof(buffer)); + mutt_str_strfcpy(buffer, "QUIT\r\n", sizeof(buffer)); if (pop_query(pop_data, buffer, sizeof(buffer)) == -1) goto fail; mutt_socket_close(conn); diff --git a/pop_auth.c b/pop_auth.c index a85a646c8..0b2cd9796 100644 --- a/pop_auth.c +++ b/pop_auth.c @@ -98,7 +98,7 @@ static enum PopAuthRes pop_auth_sasl(struct PopData *pop_data, const char *metho /* looping protocol */ while (true) { - strfcpy(buf + olen, "\r\n", bufsize - olen); + mutt_str_strfcpy(buf + olen, "\r\n", bufsize - olen); mutt_socket_write(pop_data->conn, buf); if (mutt_socket_readln(inbuf, sizeof(inbuf), pop_data->conn) < 0) { @@ -116,7 +116,7 @@ static enum PopAuthRes pop_auth_sasl(struct PopData *pop_data, const char *metho if (!client_start && rc != SASL_CONTINUE) break; - if ((mutt_strncmp(inbuf, "+ ", 2) == 0) && + if ((mutt_str_strncmp(inbuf, "+ ", 2) == 0) && sasl_decode64(inbuf + 2, strlen(inbuf + 2), buf, bufsize - 1, &len) != SASL_OK) { mutt_debug(1, "pop_auth_sasl: error base64-decoding server response.\n"); @@ -163,7 +163,7 @@ static enum PopAuthRes pop_auth_sasl(struct PopData *pop_data, const char *metho if (rc != SASL_OK) goto bail; - if (mutt_strncmp(inbuf, "+OK", 3) == 0) + if (mutt_str_strncmp(inbuf, "+OK", 3) == 0) { mutt_sasl_setup_conn(pop_data->conn, saslconn); FREE(&buf); @@ -174,7 +174,7 @@ bail: sasl_dispose(&saslconn); /* terminate SASL session if the last response is not +OK nor -ERR */ - if (mutt_strncmp(inbuf, "+ ", 2) == 0) + if (mutt_str_strncmp(inbuf, "+ ", 2) == 0) { snprintf(buf, bufsize, "*\r\n"); if (pop_query(pop_data, buf, bufsize) == -1) @@ -204,7 +204,7 @@ void pop_apop_timestamp(struct PopData *pop_data, char *buf) if ((p1 = strchr(buf, '<')) && (p2 = strchr(p1, '>'))) { p2[1] = '\0'; - pop_data->timestamp = safe_strdup(p1); + pop_data->timestamp = mutt_str_strdup(p1); } } @@ -350,7 +350,7 @@ int pop_authenticate(struct PopData *pop_data) if (PopAuthenticators && *PopAuthenticators) { /* Try user-specified list of authentication methods */ - methods = safe_strdup(PopAuthenticators); + methods = mutt_str_strdup(PopAuthenticators); method = methods; while (method) @@ -363,7 +363,8 @@ int pop_authenticate(struct PopData *pop_data) while (authenticator->authenticate) { - if (!authenticator->method || (mutt_strcasecmp(authenticator->method, method) == 0)) + if (!authenticator->method || + (mutt_str_strcasecmp(authenticator->method, method) == 0)) { ret = authenticator->authenticate(pop_data, method); if (ret == POP_A_SOCKET) diff --git a/pop_lib.c b/pop_lib.c index 659b01abb..c3b72dccb 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -62,7 +62,7 @@ int pop_parse_path(const char *path, struct Account *acct) acct->type = MUTT_ACCT_TYPE_POP; acct->port = 0; - c = safe_strdup(path); + c = mutt_str_strdup(path); url_parse(&url, c); if ((url.scheme != U_POP && url.scheme != U_POPS) || !url.host || @@ -105,16 +105,16 @@ static void pop_error(struct PopData *pop_data, char *msg) t = strchr(pop_data->err_msg, '\0'); c = msg; - if (mutt_strncmp(msg, "-ERR ", 5) == 0) + if (mutt_str_strncmp(msg, "-ERR ", 5) == 0) { - c2 = skip_email_wsp(msg + 5); + c2 = mutt_str_skip_email_wsp(msg + 5); if (*c2) c = c2; } - strfcpy(t, c, sizeof(pop_data->err_msg) - strlen(pop_data->err_msg)); - mutt_remove_trailing_ws(pop_data->err_msg); + mutt_str_strfcpy(t, c, sizeof(pop_data->err_msg) - strlen(pop_data->err_msg)); + mutt_str_remove_trailing_ws(pop_data->err_msg); } /** @@ -128,23 +128,23 @@ static int fetch_capa(char *line, void *data) struct PopData *pop_data = (struct PopData *) data; char *c = NULL; - if (mutt_strncasecmp(line, "SASL", 4) == 0) + if (mutt_str_strncasecmp(line, "SASL", 4) == 0) { FREE(&pop_data->auth_list); - c = skip_email_wsp(line + 4); - pop_data->auth_list = safe_strdup(c); + c = mutt_str_skip_email_wsp(line + 4); + pop_data->auth_list = mutt_str_strdup(c); } - else if (mutt_strncasecmp(line, "STLS", 4) == 0) + else if (mutt_str_strncasecmp(line, "STLS", 4) == 0) pop_data->cmd_stls = true; - else if (mutt_strncasecmp(line, "USER", 4) == 0) + else if (mutt_str_strncasecmp(line, "USER", 4) == 0) pop_data->cmd_user = 1; - else if (mutt_strncasecmp(line, "UIDL", 4) == 0) + else if (mutt_str_strncasecmp(line, "UIDL", 4) == 0) pop_data->cmd_uidl = 1; - else if (mutt_strncasecmp(line, "TOP", 3) == 0) + else if (mutt_str_strncasecmp(line, "TOP", 3) == 0) pop_data->cmd_top = 1; return 0; @@ -208,7 +208,7 @@ static int pop_capabilities(struct PopData *pop_data, int mode) /* Execute CAPA command */ if (mode == 0 || pop_data->cmd_capa) { - strfcpy(buf, "CAPA\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "CAPA\r\n", sizeof(buf)); switch (pop_fetch_data(pop_data, buf, NULL, fetch_capa, pop_data)) { case 0: @@ -228,7 +228,7 @@ static int pop_capabilities(struct PopData *pop_data, int mode) pop_data->cmd_uidl = 2; pop_data->cmd_top = 2; - strfcpy(buf, "AUTH\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "AUTH\r\n", sizeof(buf)); if (pop_fetch_data(pop_data, buf, NULL, fetch_auth, pop_data) == -1) return -1; } @@ -276,7 +276,7 @@ int pop_connect(struct PopData *pop_data) pop_data->status = POP_CONNECTED; - if (mutt_strncmp(buf, "+OK", 3) != 0) + if (mutt_str_strncmp(buf, "+OK", 3) != 0) { *pop_data->err_msg = '\0'; pop_error(pop_data, buf); @@ -337,7 +337,7 @@ int pop_open_connection(struct PopData *pop_data) } if (pop_data->use_stls == 2) { - strfcpy(buf, "STLS\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "STLS\r\n", sizeof(buf)); ret = pop_query(pop_data, buf, sizeof(buf)); if (ret == -1) goto err_conn; @@ -394,7 +394,7 @@ int pop_open_connection(struct PopData *pop_data) } /* get total size of mailbox */ - strfcpy(buf, "STAT\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "STAT\r\n", sizeof(buf)); ret = pop_query(pop_data, buf, sizeof(buf)); if (ret == -1) goto err_conn; @@ -432,13 +432,13 @@ void pop_logout(struct Context *ctx) if (ctx->readonly) { - strfcpy(buf, "RSET\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "RSET\r\n", sizeof(buf)); ret = pop_query(pop_data, buf, sizeof(buf)); } if (ret != -1) { - strfcpy(buf, "QUIT\r\n", sizeof(buf)); + mutt_str_strfcpy(buf, "QUIT\r\n", sizeof(buf)); ret = pop_query(pop_data, buf, sizeof(buf)); } @@ -491,7 +491,7 @@ int pop_query_d(struct PopData *pop_data, char *buf, size_t buflen, char *msg) pop_data->status = POP_DISCONNECTED; return -1; } - if (mutt_strncmp(buf, "+OK", 3) == 0) + if (mutt_str_strncmp(buf, "+OK", 3) == 0) return 0; pop_error(pop_data, buf); @@ -518,7 +518,7 @@ int pop_fetch_data(struct PopData *pop_data, char *query, struct Progress *progr long pos = 0; size_t lenbuf = 0; - strfcpy(buf, query, sizeof(buf)); + mutt_str_strfcpy(buf, query, sizeof(buf)); ret = pop_query(pop_data, buf, sizeof(buf)); if (ret < 0) return ret; @@ -543,7 +543,7 @@ int pop_fetch_data(struct PopData *pop_data, char *query, struct Progress *progr p++; } - strfcpy(inbuf + lenbuf, p, sizeof(buf)); + mutt_str_strfcpy(inbuf + lenbuf, p, sizeof(buf)); pos += chunk; /* cast is safe since we break out of the loop when chunk<=0 */ @@ -590,7 +590,7 @@ static int check_uidl(char *line, void *data) for (int i = 0; i < ctx->msgcount; i++) { - if (mutt_strcmp(ctx->hdrs[i]->data, line) == 0) + if (mutt_str_strcmp(ctx->hdrs[i]->data, line) == 0) { ctx->hdrs[i]->refno = index; break; diff --git a/postpone.c b/postpone.c index 9e7ec75f2..d76b58fb1 100644 --- a/postpone.c +++ b/postpone.c @@ -86,10 +86,10 @@ int mutt_num_postponed(int force) force = 1; } - if (mutt_strcmp(Postponed, OldPostponed) != 0) + if (mutt_str_strcmp(Postponed, OldPostponed) != 0) { FREE(&OldPostponed); - OldPostponed = safe_strdup(Postponed); + OldPostponed = mutt_str_strdup(Postponed); LastModify = 0; force = 1; } @@ -322,13 +322,13 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, struct ListNode *np, *tmp; STAILQ_FOREACH_SAFE(np, &hdr->env->userhdrs, entries, tmp) { - if (mutt_strncasecmp("X-Mutt-References:", np->data, 18) == 0) + if (mutt_str_strncasecmp("X-Mutt-References:", np->data, 18) == 0) { if (ctx) { /* if a mailbox is currently open, look to see if the original message the user attempted to reply to is in this mailbox */ - p = skip_email_wsp(np->data + 18); + p = mutt_str_skip_email_wsp(np->data + 18); if (!ctx->id_hash) ctx->id_hash = mutt_make_id_hash(ctx); *cur = mutt_hash_find(ctx->id_hash, p); @@ -336,10 +336,10 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, if (*cur) code |= SENDREPLY; } - else if (mutt_strncasecmp("X-Mutt-Fcc:", np->data, 11) == 0) + else if (mutt_str_strncasecmp("X-Mutt-Fcc:", np->data, 11) == 0) { - p = skip_email_wsp(np->data + 11); - strfcpy(fcc, p, fcclen); + p = mutt_str_skip_email_wsp(np->data + 11); + mutt_str_strfcpy(fcc, p, fcclen); mutt_pretty_mailbox(fcc, fcclen); /* note that x-mutt-fcc was present. we do this because we want to add a @@ -350,23 +350,23 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, code |= SENDPOSTPONEDFCC; } else if ((WithCrypto & APPLICATION_PGP) && - ((mutt_strncmp("Pgp:", np->data, 4) == 0) /* this is generated + ((mutt_str_strncmp("Pgp:", np->data, 4) == 0) /* this is generated * by old neomutt versions */ - || (mutt_strncmp("X-Mutt-PGP:", np->data, 11) == 0))) + || (mutt_str_strncmp("X-Mutt-PGP:", np->data, 11) == 0))) { hdr->security = mutt_parse_crypt_hdr(strchr(np->data, ':') + 1, 1, APPLICATION_PGP); hdr->security |= APPLICATION_PGP; } else if ((WithCrypto & APPLICATION_SMIME) && - (mutt_strncmp("X-Mutt-SMIME:", np->data, 13) == 0)) + (mutt_str_strncmp("X-Mutt-SMIME:", np->data, 13) == 0)) { hdr->security = mutt_parse_crypt_hdr(strchr(np->data, ':') + 1, 1, APPLICATION_SMIME); hdr->security |= APPLICATION_SMIME; } #ifdef MIXMASTER - else if (mutt_strncmp("X-Mutt-Mix:", np->data, 11) == 0) + else if (mutt_str_strncmp("X-Mutt-Mix:", np->data, 11) == 0) { char *t = NULL; mutt_list_free(&hdr->chain); @@ -374,7 +374,7 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, t = strtok(np->data + 11, " \t\n"); while (t) { - mutt_list_insert_tail(&hdr->chain, safe_strdup(t)); + mutt_list_insert_tail(&hdr->chain, mutt_str_strdup(t)); t = strtok(NULL, " \t\n"); } } @@ -407,7 +407,7 @@ int mutt_parse_crypt_hdr(const char *p, int set_empty_signas, int crypt_app) if (!WithCrypto) return 0; - p = skip_email_wsp(p); + p = mutt_str_skip_email_wsp(p); for (; *p; p++) { switch (*p) @@ -597,8 +597,8 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, { newhdr->security |= SIGN; if ((WithCrypto & APPLICATION_PGP) && - (mutt_strcasecmp(mutt_get_parameter("protocol", newhdr->content->parameter), - "application/pgp-signature") == 0)) + (mutt_str_strcasecmp(mutt_get_parameter("protocol", newhdr->content->parameter), + "application/pgp-signature") == 0)) newhdr->security |= APPLICATION_PGP; else if ((WithCrypto & APPLICATION_SMIME)) newhdr->security |= APPLICATION_SMIME; @@ -633,8 +633,8 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, file[0] = '\0'; if (b->filename) { - strfcpy(file, b->filename, sizeof(file)); - b->d_filename = safe_strdup(b->filename); + mutt_str_strfcpy(file, b->filename, sizeof(file)); + b->d_filename = mutt_str_strdup(b->filename); } else { @@ -648,7 +648,7 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, if (b->type == TYPETEXT) { - if (mutt_strcasecmp("yes", mutt_get_parameter("x-mutt-noconv", b->parameter)) == 0) + if (mutt_str_strcasecmp("yes", mutt_get_parameter("x-mutt-noconv", b->parameter)) == 0) b->noconv = true; else { diff --git a/query.c b/query.c index 41611fd1d..23e2c9ca5 100644 --- a/query.c +++ b/query.c @@ -87,7 +87,7 @@ static struct Address *result_to_addr(struct Query *r) return NULL; if (!tmp->next && !tmp->personal) - tmp->personal = safe_strdup(r->name); + tmp->personal = mutt_str_strdup(r->name); mutt_addrlist_to_intl(tmp, NULL); return tmp; @@ -157,10 +157,10 @@ static struct Query *run_query(char *s, int quiet) p = strtok(NULL, "\t\n"); if (p) { - cur->name = safe_strdup(p); + cur->name = mutt_str_strdup(p); p = strtok(NULL, "\t\n"); if (p) - cur->other = safe_strdup(p); + cur->other = mutt_str_strdup(p); } } } @@ -471,7 +471,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb mutt_addrlist_to_local(tmpa); tagged = true; rfc822_write_address(buf, buflen, tmpa, 0); - curpos = mutt_strlen(buf); + curpos = mutt_str_strlen(buf); rfc822_free_address(&tmpa); } else if (curpos + 2 < buflen) @@ -480,7 +480,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb mutt_addrlist_to_local(tmpa); strcat(buf, ", "); rfc822_write_address((char *) buf + curpos + 1, buflen - curpos - 1, tmpa, 0); - curpos = mutt_strlen(buf); + curpos = mutt_str_strlen(buf); rfc822_free_address(&tmpa); } } diff --git a/recvattach.c b/recvattach.c index 50b9438d9..a2f0ece28 100644 --- a/recvattach.c +++ b/recvattach.c @@ -124,11 +124,11 @@ void mutt_update_tree(struct AttachCtx *actx) if (actx->idx[rindex]->tree) { - if (mutt_strcmp(actx->idx[rindex]->tree, buf) != 0) + if (mutt_str_strcmp(actx->idx[rindex]->tree, buf) != 0) mutt_str_replace(&actx->idx[rindex]->tree, buf); } else - actx->idx[rindex]->tree = safe_strdup(buf); + actx->idx[rindex]->tree = mutt_str_strdup(buf); if (2 * (actx->idx[rindex]->level + 2) < sizeof(buf) && actx->idx[rindex]->level) { @@ -252,7 +252,7 @@ const char *mutt_attach_fmt(char *dest, size_t destlen, size_t col, int cols, { char path[_POSIX_PATH_MAX]; - strfcpy(path, aptr->content->filename, sizeof(path)); + mutt_str_strfcpy(path, aptr->content->filename, sizeof(path)); mutt_pretty_mailbox(path, sizeof(path)); mutt_format_s(dest, destlen, prefix, path); } @@ -404,8 +404,8 @@ bool mutt_is_message_type(int type, const char *subtype) return false; subtype = NONULL(subtype); - return ((mutt_strcasecmp(subtype, "rfc822") == 0) || - (mutt_strcasecmp(subtype, "news") == 0)); + return ((mutt_str_strcasecmp(subtype, "rfc822") == 0) || + (mutt_str_strcasecmp(subtype, "news") == 0)); } static void prepend_curdir(char *dst, size_t dstlen) @@ -441,7 +441,7 @@ static int query_save_attachment(FILE *fp, struct Body *body, mutt_file_concat_path(buf, *directory, mutt_file_basename(body->filename), sizeof(buf)); else - strfcpy(buf, body->filename, sizeof(buf)); + mutt_str_strfcpy(buf, body->filename, sizeof(buf)); } else if (body->hdr && body->encoding != ENCBASE64 && body->encoding != ENCQUOTEDPRINTABLE && mutt_is_message_type(body->type, body->subtype)) @@ -480,7 +480,7 @@ static int query_save_attachment(FILE *fp, struct Body *body, } else if (rc == -1) return -1; - strfcpy(tfile, buf, sizeof(tfile)); + mutt_str_strfcpy(tfile, buf, sizeof(tfile)); } else { @@ -536,7 +536,7 @@ void mutt_save_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, { int append = 0; - strfcpy(buf, mutt_file_basename(NONULL(top->filename)), sizeof(buf)); + mutt_str_strfcpy(buf, mutt_file_basename(NONULL(top->filename)), sizeof(buf)); prepend_curdir(buf, sizeof(buf)); if (mutt_get_field(_("Save to file: "), buf, sizeof(buf), MUTT_FILE | MUTT_CLEAR) != 0 || @@ -727,8 +727,8 @@ static bool can_print(struct AttachCtx *actx, struct Body *top, bool tag) { if (!rfc1524_mailcap_lookup(top, type, NULL, MUTT_PRINT)) { - if ((mutt_strcasecmp("text/plain", top->subtype) != 0) && - (mutt_strcasecmp("application/postscript", top->subtype) != 0)) + if ((mutt_str_strcasecmp("text/plain", top->subtype) != 0) && + (mutt_str_strcasecmp("application/postscript", top->subtype) != 0)) { if (!mutt_can_decode(top)) { @@ -761,8 +761,8 @@ static void print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, snprintf(type, sizeof(type), "%s/%s", TYPE(top), top->subtype); if (!option(OPT_ATTACH_SPLIT) && !rfc1524_mailcap_lookup(top, type, NULL, MUTT_PRINT)) { - if ((mutt_strcasecmp("text/plain", top->subtype) == 0) || - (mutt_strcasecmp("application/postscript", top->subtype) == 0)) + if ((mutt_str_strcasecmp("text/plain", top->subtype) == 0) || + (mutt_str_strcasecmp("application/postscript", top->subtype) == 0)) pipe_attachment(fp, top, state); else if (mutt_can_decode(top)) { @@ -1010,7 +1010,7 @@ static void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Header /* Strip out the top level multipart */ if (m->type == TYPEMULTIPART && m->parts && !need_secured && - (parent_type == -1 && mutt_strcasecmp("alternative", m->subtype))) + (parent_type == -1 && mutt_str_strcasecmp("alternative", m->subtype))) { mutt_generate_recvattach_list(actx, hdr, m->parts, fp, m->type, level, decrypted); } @@ -1042,7 +1042,7 @@ void mutt_attach_init(struct AttachCtx *actx) { /* Collapse the attachments if '$digest_collapse' is set AND if... * the outer container is of type 'multipart/digest' */ - bool digest = (mutt_strcasecmp(actx->hdr->content->subtype, "digest") == 0); + bool digest = (mutt_str_strcasecmp(actx->hdr->content->subtype, "digest") == 0); for (int i = 0; i < actx->idxlen; i++) { @@ -1053,7 +1053,7 @@ void mutt_attach_init(struct AttachCtx *actx) (option(OPT_DIGEST_COLLAPSE) && (digest || ((actx->idx[i]->content->type == TYPEMULTIPART) && - (mutt_strcasecmp(actx->idx[i]->content->subtype, "digest") == 0)))); + (mutt_str_strcasecmp(actx->idx[i]->content->subtype, "digest") == 0)))); } } @@ -1092,7 +1092,7 @@ static void attach_collapse(struct AttachCtx *actx, struct Menu *menu) while ((rindex < actx->idxlen) && (actx->idx[rindex]->level > curlevel)) { if (option(OPT_DIGEST_COLLAPSE) && actx->idx[rindex]->content->type == TYPEMULTIPART && - !mutt_strcasecmp(actx->idx[rindex]->content->subtype, "digest")) + !mutt_str_strcasecmp(actx->idx[rindex]->content->subtype, "digest")) actx->idx[rindex]->content->collapsed = true; else actx->idx[rindex]->content->collapsed = false; @@ -1343,8 +1343,8 @@ void mutt_view_attachments(struct Header *hdr) CHECK_ATTACH; if (!CURATTACH->content->hdr->env->followup_to || - (mutt_strcasecmp(CURATTACH->content->hdr->env->followup_to, - "poster") != 0) || + (mutt_str_strcasecmp(CURATTACH->content->hdr->env->followup_to, + "poster") != 0) || query_quadoption(OPT_FOLLOWUP_TO_POSTER, _("Reply by mail as poster prefers?")) != MUTT_YES) { diff --git a/recvcmd.c b/recvcmd.c index cdac9c9ff..7eba9c54b 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -163,9 +163,9 @@ void mutt_attach_bounce(FILE *fp, struct Header *hdr, struct AttachCtx *actx, st } if (p) - strfcpy(prompt, _("Bounce message to: "), sizeof(prompt)); + mutt_str_strfcpy(prompt, _("Bounce message to: "), sizeof(prompt)); else - strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt)); + mutt_str_strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt)); buf[0] = '\0'; if (mutt_get_field(prompt, buf, sizeof(buf), MUTT_ALIAS) || buf[0] == '\0') @@ -202,10 +202,10 @@ void mutt_attach_bounce(FILE *fp, struct Header *hdr, struct AttachCtx *actx, st { mutt_simple_format(prompt, sizeof(prompt) - 4, 0, MuttMessageWindow->cols - EXTRA_SPACE, FMT_LEFT, 0, prompt, sizeof(prompt), 0); - safe_strcat(prompt, sizeof(prompt), "...?"); + mutt_str_strcat(prompt, sizeof(prompt), "...?"); } else - safe_strcat(prompt, sizeof(prompt), "?"); + mutt_str_strcat(prompt, sizeof(prompt), "?"); if (query_quadoption(OPT_BOUNCE, prompt) != MUTT_YES) { @@ -339,11 +339,11 @@ static void include_header(int quote, FILE *ifp, struct Header *hdr, FILE *ofp, if (quote) { if (_prefix) - strfcpy(prefix, _prefix, sizeof(prefix)); + mutt_str_strfcpy(prefix, _prefix, sizeof(prefix)); else if (!option(OPT_TEXT_FLOWED)) mutt_make_string_flags(prefix, sizeof(prefix), NONULL(IndentString), Context, hdr, 0); else - strfcpy(prefix, ">", sizeof(prefix)); + mutt_str_strfcpy(prefix, ">", sizeof(prefix)); chflags |= CH_PREFIX; } @@ -436,7 +436,7 @@ static void attach_forward_bodies(FILE *fp, struct Header *hdr, struct AttachCtx mutt_make_string_flags(prefix, sizeof(prefix), NONULL(IndentString), Context, parent_hdr, 0); else - strfcpy(prefix, ">", sizeof(prefix)); + mutt_str_strfcpy(prefix, ">", sizeof(prefix)); } include_header(option(OPT_FORWARD_QUOTE), parent_fp, parent_hdr, tmpfp, prefix); @@ -722,8 +722,8 @@ static int attach_reply_envelope_defaults(struct Envelope *env, struct AttachCtx { /* in case followup set Newsgroups: with Followup-To: if it present */ if (!env->newsgroups && curenv && - (mutt_strcasecmp(curenv->followup_to, "poster") != 0)) - env->newsgroups = safe_strdup(curenv->followup_to); + (mutt_str_strcasecmp(curenv->followup_to, "poster") != 0)) + env->newsgroups = mutt_str_strdup(curenv->followup_to); } else #endif @@ -885,7 +885,7 @@ void mutt_attach_reply(FILE *fp, struct Header *hdr, struct AttachCtx *actx, mutt_make_string_flags(prefix, sizeof(prefix), NONULL(IndentString), Context, parent_hdr, 0); else - strfcpy(prefix, ">", sizeof(prefix)); + mutt_str_strfcpy(prefix, ">", sizeof(prefix)); st.prefix = prefix; st.flags = MUTT_CHARCONV; diff --git a/remailer.c b/remailer.c index ee7863a8e..3c7aaf84b 100644 --- a/remailer.c +++ b/remailer.c @@ -157,7 +157,7 @@ static struct Remailer **mix_type2_list(size_t *l) /* first, generate the "random" remailer */ p = mix_new_remailer(); - p->shortname = safe_strdup(_("")); + p->shortname = mutt_str_strdup(_("")); mix_add_entry(&type2_list, p, &slots, &used); while (fgets(line, sizeof(line), fp)) @@ -168,13 +168,13 @@ static struct Remailer **mix_type2_list(size_t *l) if (!t) goto problem; - p->shortname = safe_strdup(t); + p->shortname = mutt_str_strdup(t); t = strtok(NULL, " \t\n"); if (!t) goto problem; - p->addr = safe_strdup(t); + p->addr = mutt_str_strdup(t); t = strtok(NULL, " \t\n"); if (!t) @@ -184,7 +184,7 @@ static struct Remailer **mix_type2_list(size_t *l) if (!t) goto problem; - p->ver = safe_strdup(t); + p->ver = mutt_str_strdup(t); t = strtok(NULL, " \t\n"); if (!t) @@ -426,7 +426,7 @@ static int mix_chain_add(struct MixChain *chain, const char *s, struct Remailer if (chain->cl >= MAXMIXES) return -1; - if ((mutt_strcmp(s, "0") == 0) || (mutt_strcasecmp(s, "") == 0)) + if ((mutt_str_strcmp(s, "0") == 0) || (mutt_str_strcasecmp(s, "") == 0)) { chain->ch[chain->cl++] = 0; return 0; @@ -434,7 +434,7 @@ static int mix_chain_add(struct MixChain *chain, const char *s, struct Remailer for (i = 0; type2_list[i]; i++) { - if (mutt_strcasecmp(s, type2_list[i]->shortname) == 0) + if (mutt_str_strcasecmp(s, type2_list[i]->shortname) == 0) { chain->ch[chain->cl++] = i; return 0; @@ -657,7 +657,7 @@ void mix_make_chain(struct ListHead *chainhead) else t = "*"; - mutt_list_insert_tail(chainhead, safe_strdup(t)); + mutt_list_insert_tail(chainhead, mutt_str_strdup(t)); } } @@ -726,7 +726,7 @@ int mix_send_message(struct ListHead *chain, const char *tempfile) struct ListNode *np; STAILQ_FOREACH(np, chain, entries) { - strfcpy(tmp, cmd, sizeof(tmp)); + mutt_str_strfcpy(tmp, cmd, sizeof(tmp)); mutt_file_quote_filename(cd_quoted, sizeof(cd_quoted), np->data); snprintf(cmd, sizeof(cmd), "%s%s%s", tmp, (np == STAILQ_FIRST(chain)) ? " -l " : ",", cd_quoted); diff --git a/resize.c b/resize.c index f1de053d3..d36d2272d 100644 --- a/resize.c +++ b/resize.c @@ -62,12 +62,12 @@ void mutt_resize_screen(void) } if (SLtt_Screen_Rows <= 0) { - if ((cp = getenv("LINES")) != NULL && mutt_atoi(cp, &SLtt_Screen_Rows) < 0) + if ((cp = getenv("LINES")) != NULL && mutt_str_atoi(cp, &SLtt_Screen_Rows) < 0) SLtt_Screen_Rows = 24; } if (SLtt_Screen_Cols <= 0) { - if ((cp = getenv("COLUMNS")) != NULL && mutt_atoi(cp, &SLtt_Screen_Cols) < 0) + if ((cp = getenv("COLUMNS")) != NULL && mutt_str_atoi(cp, &SLtt_Screen_Cols) < 0) SLtt_Screen_Cols = 80; } #ifdef USE_SLANG_CURSES diff --git a/rfc1524.c b/rfc1524.c index 6dfd4ca74..33e83805e 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -67,7 +67,7 @@ int rfc1524_expand_command(struct Body *a, char *filename, char *_type, char *co char buf[LONG_STRING]; char type[LONG_STRING]; - strfcpy(type, _type, sizeof(type)); + mutt_str_strfcpy(type, _type, sizeof(type)); if (option(OPT_MAILCAP_SANITIZE)) mutt_file_sanitize_filename(type, 0); @@ -95,7 +95,7 @@ int rfc1524_expand_command(struct Body *a, char *filename, char *_type, char *co param[z] = '\0'; _pvalue = mutt_get_parameter(param, a->parameter); - strfcpy(pvalue, NONULL(_pvalue), sizeof(pvalue)); + mutt_str_strfcpy(pvalue, NONULL(_pvalue), sizeof(pvalue)); if (option(OPT_MAILCAP_SANITIZE)) mutt_file_sanitize_filename(pvalue, 0); @@ -116,7 +116,7 @@ int rfc1524_expand_command(struct Body *a, char *filename, char *_type, char *co buf[y++] = command[x++]; } buf[y] = '\0'; - strfcpy(command, buf, clen); + mutt_str_strfcpy(command, buf, clen); return needspipe; } @@ -145,23 +145,23 @@ static char *get_field(char *s) else { *ch = 0; - ch = skip_email_wsp(ch + 1); + ch = mutt_str_skip_email_wsp(ch + 1); break; } } - mutt_remove_trailing_ws(s); + mutt_str_remove_trailing_ws(s); return ch; } static int get_field_text(char *field, char **entry, char *type, char *filename, int line) { - field = mutt_skip_whitespace(field); + field = mutt_str_skip_whitespace(field); if (*field == '=') { if (entry) { field++; - field = mutt_skip_whitespace(field); + field = mutt_str_skip_whitespace(field); mutt_str_replace(entry, field); } return 1; @@ -219,17 +219,17 @@ static int rfc1524_mailcap_parse(struct Body *a, char *filename, char *type, /* check type */ ch = get_field(buf); - if ((mutt_strcasecmp(buf, type) != 0) && - ((mutt_strncasecmp(buf, type, btlen) != 0) || - (buf[btlen] != 0 && /* implicit wild */ - (mutt_strcmp(buf + btlen, "/*") != 0)))) /* wildsubtype */ + if ((mutt_str_strcasecmp(buf, type) != 0) && + ((mutt_str_strncasecmp(buf, type, btlen) != 0) || + (buf[btlen] != 0 && /* implicit wild */ + (mutt_str_strcmp(buf + btlen, "/*") != 0)))) /* wildsubtype */ continue; /* next field is the viewcommand */ field = ch; ch = get_field(ch); if (entry) - entry->command = safe_strdup(field); + entry->command = mutt_str_strdup(field); /* parse the optional fields */ found = true; @@ -244,51 +244,51 @@ static int rfc1524_mailcap_parse(struct Body *a, char *filename, char *type, ch = get_field(ch); mutt_debug(2, "field: %s\n", field); - if (mutt_strcasecmp(field, "needsterminal") == 0) + if (mutt_str_strcasecmp(field, "needsterminal") == 0) { if (entry) entry->needsterminal = true; } - else if (mutt_strcasecmp(field, "copiousoutput") == 0) + else if (mutt_str_strcasecmp(field, "copiousoutput") == 0) { copiousoutput = true; if (entry) entry->copiousoutput = true; } - else if (mutt_strncasecmp(field, "composetyped", 12) == 0) + else if (mutt_str_strncasecmp(field, "composetyped", 12) == 0) { /* this compare most occur before compose to match correctly */ if (get_field_text(field + 12, entry ? &entry->composetypecommand : NULL, type, filename, line)) composecommand = true; } - else if (mutt_strncasecmp(field, "compose", 7) == 0) + else if (mutt_str_strncasecmp(field, "compose", 7) == 0) { if (get_field_text(field + 7, entry ? &entry->composecommand : NULL, type, filename, line)) composecommand = true; } - else if (mutt_strncasecmp(field, "print", 5) == 0) + else if (mutt_str_strncasecmp(field, "print", 5) == 0) { if (get_field_text(field + 5, entry ? &entry->printcommand : NULL, type, filename, line)) printcommand = true; } - else if (mutt_strncasecmp(field, "edit", 4) == 0) + else if (mutt_str_strncasecmp(field, "edit", 4) == 0) { if (get_field_text(field + 4, entry ? &entry->editcommand : NULL, type, filename, line)) editcommand = true; } - else if (mutt_strncasecmp(field, "nametemplate", 12) == 0) + else if (mutt_str_strncasecmp(field, "nametemplate", 12) == 0) { get_field_text(field + 12, entry ? &entry->nametemplate : NULL, type, filename, line); } - else if (mutt_strncasecmp(field, "x-convert", 9) == 0) + else if (mutt_str_strncasecmp(field, "x-convert", 9) == 0) { get_field_text(field + 9, entry ? &entry->convert : NULL, type, filename, line); } - else if (mutt_strncasecmp(field, "test", 4) == 0) + else if (mutt_str_strncasecmp(field, "test", 4) == 0) { /* * This routine executes the given test command to determine @@ -299,7 +299,7 @@ static int rfc1524_mailcap_parse(struct Body *a, char *filename, char *type, if (get_field_text(field + 4, &test_command, type, filename, line) && test_command) { - len = mutt_strlen(test_command) + STRING; + len = mutt_str_strlen(test_command) + STRING; mutt_mem_realloc(&test_command, len); rfc1524_expand_command(a, a->filename, type, test_command, len); if (mutt_system(test_command) != 0) @@ -486,7 +486,7 @@ int rfc1524_expand_filename(char *nametemplate, char *oldfile, char *newfile, si if (!nametemplate) { if (oldfile) - strfcpy(newfile, oldfile, nflen); + mutt_str_strfcpy(newfile, oldfile, nflen); } else if (!oldfile) { @@ -532,7 +532,7 @@ int rfc1524_expand_filename(char *nametemplate, char *oldfile, char *newfile, si rmatch = true; - for (j = mutt_strlen(oldfile) - 1, k = mutt_strlen(nametemplate) - 1; + for (j = mutt_str_strlen(oldfile) - 1, k = mutt_str_strlen(nametemplate) - 1; j >= (lmatch ? i : 0) && k >= i + 2; j--, k--) { if (nametemplate[k] != oldfile[j]) @@ -550,19 +550,19 @@ int rfc1524_expand_filename(char *nametemplate, char *oldfile, char *newfile, si if (lmatch) *left = 0; else - strnfcpy(left, nametemplate, sizeof(left), i); + mutt_str_strnfcpy(left, nametemplate, sizeof(left), i); if (rmatch) *right = 0; else - strfcpy(right, nametemplate + i + 2, sizeof(right)); + mutt_str_strfcpy(right, nametemplate + i + 2, sizeof(right)); snprintf(newfile, nflen, "%s%s%s", left, oldfile, right); } else { /* no "%s" in the name template. */ - strfcpy(newfile, nametemplate, nflen); + mutt_str_strfcpy(newfile, nametemplate, nflen); } } diff --git a/rfc2047.c b/rfc2047.c index fb1087c60..8d7aaaa08 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -98,18 +98,18 @@ int convert_nonmime_string(char **ps) char *s = NULL; char *fromcode = NULL; size_t m, n; - size_t ulen = mutt_strlen(*ps); + size_t ulen = mutt_str_strlen(*ps); size_t slen; if (!u || !*u) return 0; c1 = strchr(c, ':'); - n = c1 ? c1 - c : mutt_strlen(c); + n = c1 ? c1 - c : mutt_str_strlen(c); if (!n) return 0; fromcode = mutt_mem_malloc(n + 1); - strfcpy(fromcode, c, n + 1); + mutt_str_strfcpy(fromcode, c, n + 1); m = convert_string(u, ulen, fromcode, Charset, &s, &slen); FREE(&fromcode); if (m != (size_t)(-1)) @@ -317,7 +317,7 @@ static size_t try_block(ICONV_CONST char *d, size_t dlen, const char *fromcode, len_q = len + (ob - buf1) + 2 * count; /* Apparently RFC1468 says to use B encoding for iso-2022-jp. */ - if (mutt_strcasecmp(tocode, "ISO-2022-JP") == 0) + if (mutt_str_strcasecmp(tocode, "ISO-2022-JP") == 0) len_q = ENCWORD_LEN_MAX + 1; if (len_b < len_q && len_b <= ENCWORD_LEN_MAX) @@ -387,7 +387,7 @@ static size_t choose_block(char *d, size_t dlen, int col, const char *fromcode, const char *tocode, encoder_t *encoder, size_t *wlen) { size_t n, nn; - int utf8 = fromcode && (mutt_strcasecmp(fromcode, "utf-8") == 0); + int utf8 = fromcode && (mutt_str_strcasecmp(fromcode, "utf-8") == 0); n = dlen; for (;;) @@ -677,7 +677,7 @@ static int rfc2047_decode_word(char *d, const char *s, size_t len) t = pp1; if ((t1 = memchr(pp, '*', t - pp))) t = t1; - charset = mutt_substrdup(pp, t); + charset = mutt_str_substr_dup(pp, t); break; case 3: if (toupper((unsigned char) *pp) == 'Q') @@ -736,7 +736,7 @@ static int rfc2047_decode_word(char *d, const char *s, size_t len) if (charset) mutt_convert_string(&d0, charset, Charset, MUTT_ICONV_HOOK_FROM); mutt_filter_unprintable(&d0); - strfcpy(d, d0, len); + mutt_str_strfcpy(d, d0, len); rv = 0; error_out_0: FREE(&charset); @@ -808,8 +808,8 @@ void rfc2047_decode(char **pd) /* no encoded words */ if (option(OPT_IGNORE_LINEAR_WHITE_SPACE)) { - n = mutt_strlen(s); - if (found_encoded && (m = lwslen(s, n)) != 0) + n = mutt_str_strlen(s); + if (found_encoded && (m = mutt_str_lws_len(s, n)) != 0) { if (m != n) { @@ -825,11 +825,11 @@ void rfc2047_decode(char **pd) char *t = NULL; size_t tlen; - n = mutt_strlen(s); + n = mutt_str_strlen(s); t = mutt_mem_malloc(n + 1); - strfcpy(t, s, n + 1); + mutt_str_strfcpy(t, s, n + 1); convert_nonmime_string(&t); - tlen = mutt_strlen(t); + tlen = mutt_str_strlen(t); strncpy(d, t, tlen); d += tlen; FREE(&t); @@ -847,7 +847,7 @@ void rfc2047_decode(char **pd) * and linear-white-space between encoded word and *text */ if (option(OPT_IGNORE_LINEAR_WHITE_SPACE)) { - if (found_encoded && (m = lwslen(s, n)) != 0) + if (found_encoded && (m = mutt_str_lws_len(s, n)) != 0) { if (m != n) { @@ -859,7 +859,7 @@ void rfc2047_decode(char **pd) s += m; } - m = n - lwsrlen(s, n); + m = n - mutt_str_lws_rlen(s, n); if (m != 0) { if (m > dlen) @@ -888,11 +888,11 @@ void rfc2047_decode(char **pd) if (rfc2047_decode_word(d, p, dlen) == -1) { /* could not decode word, fall back to displaying the raw string */ - strfcpy(d, p, dlen); + mutt_str_strfcpy(d, p, dlen); } found_encoded = true; s = q; - n = mutt_strlen(d); + n = mutt_str_strlen(d); dlen -= n; d += n; } diff --git a/rfc2231.c b/rfc2231.c index 41d3e0d1b..b0ed778b6 100644 --- a/rfc2231.c +++ b/rfc2231.c @@ -87,7 +87,7 @@ static char *rfc2231_get_charset(char *value, char *charset, size_t chslen) } *t = '\0'; - strfcpy(charset, value, chslen); + mutt_str_strfcpy(charset, value, chslen); if ((u = strchr(t + 1, '\''))) return u + 1; @@ -175,7 +175,7 @@ static void rfc2231_join_continuations(struct Parameter **head, struct Rfc2231Pa value = NULL; l = 0; - strfcpy(attribute, par->attribute, sizeof(attribute)); + mutt_str_strfcpy(attribute, par->attribute, sizeof(attribute)); if ((encoded = par->encoded)) valp = rfc2231_get_charset(par->value, charset, sizeof(charset)); @@ -202,7 +202,7 @@ static void rfc2231_join_continuations(struct Parameter **head, struct Rfc2231Pa if (encoded) mutt_convert_string(&value, charset, Charset, MUTT_ICONV_HOOK_FROM); *head = mutt_new_parameter(); - (*head)->attribute = safe_strdup(attribute); + (*head)->attribute = mutt_str_strdup(attribute); (*head)->value = value; head = &(*head)->next; } @@ -327,7 +327,7 @@ int rfc2231_encode_string(char **pd) if (!Charset || !SendCharset || !(charset = mutt_choose_charset(Charset, SendCharset, *pd, strlen(*pd), &d, &dlen))) { - charset = safe_strdup(Charset ? Charset : "unknown-8bit"); + charset = mutt_str_strdup(Charset ? Charset : "unknown-8bit"); FREE(&d); d = *pd; dlen = strlen(d); diff --git a/rfc3676.c b/rfc3676.c index 16b268a85..7723d789a 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -199,7 +199,7 @@ static void print_flowed_line(char *line, struct State *s, int ql, } width = quote_width(s, ql); - last = line[mutt_strlen(line) - 1]; + last = line[mutt_str_strlen(line) - 1]; mutt_debug(4, "f=f: line [%s], width = %ld, spaces = %lu\n", NONULL(line), (long) width, fst->spaces); @@ -279,7 +279,7 @@ int rfc3676_handler(struct Body *a, struct State *s) /* respect DelSp of RFC3676 only with f=f parts */ if ((t = (char *) mutt_get_parameter("delsp", a->parameter))) { - delsp = mutt_strlen(t) == 3 && (mutt_strncasecmp(t, "yes", 3) == 0); + delsp = mutt_str_strlen(t) == 3 && (mutt_str_strncasecmp(t, "yes", 3) == 0); t = NULL; fst.delsp = 1; } @@ -288,7 +288,7 @@ int rfc3676_handler(struct Body *a, struct State *s) while ((buf = mutt_file_read_line(buf, &sz, s->fpin, NULL, 0))) { - buf_len = mutt_strlen(buf); + buf_len = mutt_str_strlen(buf); newql = get_quote_level(buf); /* end flowed paragraph (if we're within one) if quoting level @@ -305,7 +305,7 @@ int rfc3676_handler(struct Body *a, struct State *s) buf_off++; /* test for signature separator */ - sigsep = (mutt_strcmp(buf + buf_off, "-- ") == 0); + sigsep = (mutt_str_strcmp(buf + buf_off, "-- ") == 0); /* a fixed line either has no trailing space or is the * signature separator */ @@ -379,12 +379,12 @@ void rfc3676_space_stuff(struct Header *hdr) while (fgets(buf, sizeof(buf), in)) { - if ((mutt_strncmp("From ", buf, 5) == 0) || buf[0] == ' ') + if ((mutt_str_strncmp("From ", buf, 5) == 0) || buf[0] == ' ') { fputc(' ', out); #ifdef DEBUG lc++; - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); if (len > 0) { c = buf[len - 1]; diff --git a/rfc822.c b/rfc822.c index 4560ee32b..254d064db 100644 --- a/rfc822.c +++ b/rfc822.c @@ -115,7 +115,7 @@ int rfc822_remove_from_adrlist(struct Address **a, const char *mailbox) last = NULL; while (p) { - if (mutt_strcasecmp(mailbox, p->mailbox) == 0) + if (mutt_str_strcasecmp(mailbox, p->mailbox) == 0) { if (last) last->next = p->next; @@ -250,7 +250,7 @@ static const char *next_token(const char *s, char *token, size_t *tokenlen, size } while (*s) { - if (is_email_wsp(*s) || is_special(*s)) + if (mutt_str_is_email_wsp(*s) || is_special(*s)) break; if (*tokenlen < tokenmax) token[(*tokenlen)++] = *s; @@ -292,7 +292,7 @@ static const char *parse_mailboxdomain(const char *s, const char *nonspecial, while (*s) { - s = skip_email_wsp(s); + s = mutt_str_skip_email_wsp(s); if (!*s) return s; @@ -348,12 +348,12 @@ static const char *parse_address(const char *s, char *token, size_t *tokenlen, } terminate_string(token, *tokenlen, tokenmax); - addr->mailbox = safe_strdup(token); + addr->mailbox = mutt_str_strdup(token); if (*commentlen && !addr->personal) { terminate_string(comment, *commentlen, commentmax); - addr->personal = safe_strdup(comment); + addr->personal = mutt_str_strdup(comment); } return s; @@ -374,7 +374,7 @@ static const char *parse_route_addr(const char *s, char *comment, size_t *commen char token[LONG_STRING]; size_t tokenlen = 0; - s = skip_email_wsp(s); + s = mutt_str_skip_email_wsp(s); /* find the end of the route */ if (*s == '@') @@ -408,7 +408,7 @@ static const char *parse_route_addr(const char *s, char *comment, size_t *commen } if (!addr->mailbox) - addr->mailbox = safe_strdup("@"); + addr->mailbox = mutt_str_strdup("@"); s++; return s; @@ -487,11 +487,11 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s) while (last && last->next) last = last->next; - ws_pending = is_email_wsp(*s); - if ((nl = mutt_strlen(s))) + ws_pending = mutt_str_is_email_wsp(*s); + if ((nl = mutt_str_strlen(s))) nl = s[nl - 1] == '\n'; - s = skip_email_wsp(s); + s = mutt_str_skip_email_wsp(s); while (*s) { if (*s == ',') @@ -504,7 +504,7 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s) else if (commentlen && last && !last->personal) { terminate_buffer(comment, commentlen); - last->personal = safe_strdup(comment); + last->personal = mutt_str_strdup(comment); } commentlen = 0; @@ -539,7 +539,7 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s) { cur = rfc822_new_address(); terminate_buffer(phrase, phraselen); - cur->mailbox = safe_strdup(phrase); + cur->mailbox = mutt_str_strdup(phrase); cur->group = 1; if (last) @@ -562,7 +562,7 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s) else if (commentlen && last && !last->personal) { terminate_buffer(comment, commentlen); - last->personal = safe_strdup(comment); + last->personal = mutt_str_strdup(comment); } /* add group terminator */ @@ -582,7 +582,7 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s) terminate_buffer(phrase, phraselen); cur = rfc822_new_address(); if (phraselen) - cur->personal = safe_strdup(phrase); + cur->personal = mutt_str_strdup(phrase); ps = parse_route_addr(s + 1, comment, &commentlen, sizeof(comment) - 1, cur); if (!ps) { @@ -613,8 +613,8 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s) } s = ps; } - ws_pending = is_email_wsp(*s); - s = skip_email_wsp(s); + ws_pending = mutt_str_is_email_wsp(*s); + s = mutt_str_skip_email_wsp(s); } if (phraselen) @@ -626,7 +626,7 @@ struct Address *rfc822_parse_adrlist(struct Address *top, const char *s) else if (commentlen && last && !last->personal) { terminate_buffer(comment, commentlen); - last->personal = safe_strdup(comment); + last->personal = mutt_str_strdup(comment); } return top; @@ -647,7 +647,7 @@ void rfc822_qualify(struct Address *addr, const char *host) for (; addr; addr = addr->next) if (!addr->group && addr->mailbox && strchr(addr->mailbox, '@') == NULL) { - p = mutt_mem_malloc(mutt_strlen(addr->mailbox) + mutt_strlen(host) + 2); + p = mutt_mem_malloc(mutt_str_strlen(addr->mailbox) + mutt_str_strlen(host) + 2); sprintf(p, "%s@%s", addr->mailbox, host); FREE(&addr->mailbox); addr->mailbox = p; @@ -681,10 +681,10 @@ void rfc822_cat(char *buf, size_t buflen, const char *value, const char *special } *pc++ = '"'; *pc = 0; - strfcpy(buf, tmp, buflen); + mutt_str_strfcpy(buf, tmp, buflen); } else - strfcpy(buf, value, buflen); + mutt_str_strfcpy(buf, value, buflen); } void rfc822_write_address_single(char *buf, size_t buflen, struct Address *addr, int display) @@ -727,8 +727,8 @@ void rfc822_write_address_single(char *buf, size_t buflen, struct Address *addr, { if (!buflen) goto done; - strfcpy(pbuf, addr->personal, buflen); - len = mutt_strlen(pbuf); + mutt_str_strfcpy(pbuf, addr->personal, buflen); + len = mutt_str_strlen(pbuf); pbuf += len; buflen -= len; } @@ -751,15 +751,15 @@ void rfc822_write_address_single(char *buf, size_t buflen, struct Address *addr, { if (!buflen) goto done; - if ((mutt_strcmp(addr->mailbox, "@") != 0) && !display) + if ((mutt_str_strcmp(addr->mailbox, "@") != 0) && !display) { - strfcpy(pbuf, addr->mailbox, buflen); - len = mutt_strlen(pbuf); + mutt_str_strfcpy(pbuf, addr->mailbox, buflen); + len = mutt_str_strlen(pbuf); } - else if ((mutt_strcmp(addr->mailbox, "@") != 0) && display) + else if ((mutt_str_strcmp(addr->mailbox, "@") != 0) && display) { - strfcpy(pbuf, mutt_addr_for_display(addr), buflen); - len = mutt_strlen(pbuf); + mutt_str_strfcpy(pbuf, mutt_addr_for_display(addr), buflen); + len = mutt_str_strlen(pbuf); } else { @@ -810,7 +810,7 @@ done: int rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int display) { char *pbuf = buf; - size_t len = mutt_strlen(buf); + size_t len = mutt_str_strlen(buf); buflen--; /* save room for the terminal nul */ @@ -839,7 +839,7 @@ int rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int dis /* this should be safe since we always have at least 1 char passed into the above call, which means `pbuf' should always be nul terminated */ - len = mutt_strlen(pbuf); + len = mutt_str_strlen(pbuf); pbuf += len; buflen -= len; @@ -873,8 +873,8 @@ struct Address *rfc822_cpy_adr_real(struct Address *addr) { struct Address *p = rfc822_new_address(); - p->personal = safe_strdup(addr->personal); - p->mailbox = safe_strdup(addr->mailbox); + p->personal = mutt_str_strdup(addr->personal); + p->mailbox = mutt_str_strdup(addr->mailbox); p->group = addr->group; p->is_intl = addr->is_intl; p->intl_checked = addr->intl_checked; @@ -971,7 +971,7 @@ bool rfc822_valid_msgid(const char *msgid) if (!msgid || !*msgid) return false; - l = mutt_strlen(msgid); + l = mutt_str_strlen(msgid); if (l < 5) /* */ return false; if (msgid[0] != '<' || msgid[l - 1] != '>') diff --git a/rfc822.h b/rfc822.h index b4c287b24..7de3cec57 100644 --- a/rfc822.h +++ b/rfc822.h @@ -42,7 +42,7 @@ enum AddressError ERR_BAD_ADDR_SPEC }; -void rfc822_dequote_comment(char *s); +void mutt_str_dequote_comment(char *s); void rfc822_free_address(struct Address **p); void rfc822_qualify(struct Address *addr, const char *host); struct Address *rfc822_parse_adrlist(struct Address *top, const char *s); diff --git a/score.c b/score.c index d728ab821..20053b9cf 100644 --- a/score.c +++ b/score.c @@ -83,7 +83,7 @@ int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data, mutt_extract_token(buf, s, 0); if (!MoreArgs(s)) { - strfcpy(err->data, _("score: too few arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("score: too few arguments"), err->dsize); return -1; } pattern = buf->data; @@ -92,14 +92,14 @@ int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data, if (MoreArgs(s)) { FREE(&pattern); - strfcpy(err->data, _("score: too many arguments"), err->dsize); + mutt_str_strfcpy(err->data, _("score: too many arguments"), err->dsize); return -1; } /* look for an existing entry and update the value, else add it to the end of the list */ for (ptr = ScoreList, last = NULL; ptr; last = ptr, ptr = ptr->next) - if (mutt_strcmp(pattern, ptr->str) == 0) + if (mutt_str_strcmp(pattern, ptr->str) == 0) break; if (!ptr) { @@ -129,10 +129,10 @@ int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data, ptr->exact = 1; pc++; } - if (mutt_atoi(pc, &ptr->val) < 0) + if (mutt_str_atoi(pc, &ptr->val) < 0) { FREE(&pattern); - strfcpy(err->data, _("Error: score: invalid number"), err->dsize); + mutt_str_strfcpy(err->data, _("Error: score: invalid number"), err->dsize); return -1; } set_option(OPT_NEED_RESCORE); @@ -177,7 +177,7 @@ int mutt_parse_unscore(struct Buffer *buf, struct Buffer *s, unsigned long data, while (MoreArgs(s)) { mutt_extract_token(buf, s, 0); - if (mutt_strcmp("*", buf->data) == 0) + if (mutt_str_strcmp("*", buf->data) == 0) { for (tmp = ScoreList; tmp;) { @@ -192,7 +192,7 @@ int mutt_parse_unscore(struct Buffer *buf, struct Buffer *s, unsigned long data, { for (tmp = ScoreList; tmp; last = tmp, tmp = tmp->next) { - if (mutt_strcmp(buf->data, tmp->str) == 0) + if (mutt_str_strcmp(buf->data, tmp->str) == 0) { if (last) last->next = tmp->next; diff --git a/send.c b/send.c index 6ae6909a5..919129fb4 100644 --- a/send.c +++ b/send.c @@ -95,7 +95,7 @@ static bool addrcmp(struct Address *a, struct Address *b) { if (!a->mailbox || !b->mailbox) return false; - if (mutt_strcasecmp(a->mailbox, b->mailbox) != 0) + if (mutt_str_strcasecmp(a->mailbox, b->mailbox) != 0) return false; return true; } @@ -258,33 +258,33 @@ static int edit_envelope(struct Envelope *en, int flags) if (option(OPT_NEWS_SEND)) { if (en->newsgroups) - strfcpy(buf, en->newsgroups, sizeof(buf)); + mutt_str_strfcpy(buf, en->newsgroups, sizeof(buf)); else buf[0] = 0; if (mutt_get_field("Newsgroups: ", buf, sizeof(buf), 0) != 0) return -1; FREE(&en->newsgroups); - en->newsgroups = safe_strdup(buf); + en->newsgroups = mutt_str_strdup(buf); if (en->followup_to) - strfcpy(buf, en->followup_to, sizeof(buf)); + mutt_str_strfcpy(buf, en->followup_to, sizeof(buf)); else buf[0] = 0; if (option(OPT_ASK_FOLLOW_UP) && mutt_get_field("Followup-To: ", buf, sizeof(buf), 0) != 0) return -1; FREE(&en->followup_to); - en->followup_to = safe_strdup(buf); + en->followup_to = mutt_str_strdup(buf); if (en->x_comment_to) - strfcpy(buf, en->x_comment_to, sizeof(buf)); + mutt_str_strfcpy(buf, en->x_comment_to, sizeof(buf)); else buf[0] = 0; if (option(OPT_X_COMMENT_TO) && option(OPT_ASK_X_COMMENT_TO) && mutt_get_field("X-Comment-To: ", buf, sizeof(buf), 0) != 0) return -1; FREE(&en->x_comment_to); - en->x_comment_to = safe_strdup(buf); + en->x_comment_to = mutt_str_strdup(buf); } else #endif @@ -306,7 +306,7 @@ static int edit_envelope(struct Envelope *en, int flags) if (option(OPT_FAST_REPLY)) return 0; else - strfcpy(buf, en->subject, sizeof(buf)); + mutt_str_strfcpy(buf, en->subject, sizeof(buf)); } else { @@ -316,10 +316,10 @@ static int edit_envelope(struct Envelope *en, int flags) struct ListNode *uh; STAILQ_FOREACH(uh, &UserHeader, entries) { - if (mutt_strncasecmp("subject:", uh->data, 8) == 0) + if (mutt_str_strncasecmp("subject:", uh->data, 8) == 0) { - p = skip_email_wsp(uh->data + 8); - strfcpy(buf, p, sizeof(buf)); + p = mutt_str_skip_email_wsp(uh->data + 8); + mutt_str_strfcpy(buf, p, sizeof(buf)); } } } @@ -340,7 +340,7 @@ static int edit_envelope(struct Envelope *en, int flags) static char *nntp_get_header(const char *s) { SKIPWS(s); - return safe_strdup(s); + return mutt_str_strdup(s); } #endif @@ -349,18 +349,18 @@ static void process_user_recips(struct Envelope *env) struct ListNode *uh; STAILQ_FOREACH(uh, &UserHeader, entries) { - if (mutt_strncasecmp("to:", uh->data, 3) == 0) + if (mutt_str_strncasecmp("to:", uh->data, 3) == 0) env->to = rfc822_parse_adrlist(env->to, uh->data + 3); - else if (mutt_strncasecmp("cc:", uh->data, 3) == 0) + else if (mutt_str_strncasecmp("cc:", uh->data, 3) == 0) env->cc = rfc822_parse_adrlist(env->cc, uh->data + 3); - else if (mutt_strncasecmp("bcc:", uh->data, 4) == 0) + else if (mutt_str_strncasecmp("bcc:", uh->data, 4) == 0) env->bcc = rfc822_parse_adrlist(env->bcc, uh->data + 4); #ifdef USE_NNTP - else if (mutt_strncasecmp("newsgroups:", uh->data, 11) == 0) + else if (mutt_str_strncasecmp("newsgroups:", uh->data, 11) == 0) env->newsgroups = nntp_get_header(uh->data + 11); - else if (mutt_strncasecmp("followup-to:", uh->data, 12) == 0) + else if (mutt_str_strncasecmp("followup-to:", uh->data, 12) == 0) env->followup_to = nntp_get_header(uh->data + 12); - else if (mutt_strncasecmp("x-comment-to:", uh->data, 13) == 0) + else if (mutt_str_strncasecmp("x-comment-to:", uh->data, 13) == 0) env->x_comment_to = nntp_get_header(uh->data + 13); #endif } @@ -371,18 +371,18 @@ static void process_user_header(struct Envelope *env) struct ListNode *uh; STAILQ_FOREACH(uh, &UserHeader, entries) { - if (mutt_strncasecmp("from:", uh->data, 5) == 0) + if (mutt_str_strncasecmp("from:", uh->data, 5) == 0) { /* User has specified a default From: address. Remove default address */ rfc822_free_address(&env->from); env->from = rfc822_parse_adrlist(env->from, uh->data + 5); } - else if (mutt_strncasecmp("reply-to:", uh->data, 9) == 0) + else if (mutt_str_strncasecmp("reply-to:", uh->data, 9) == 0) { rfc822_free_address(&env->reply_to); env->reply_to = rfc822_parse_adrlist(env->reply_to, uh->data + 9); } - else if (mutt_strncasecmp("message-id:", uh->data, 11) == 0) + else if (mutt_str_strncasecmp("message-id:", uh->data, 11) == 0) { char *tmp = mutt_extract_message_id(uh->data + 11, NULL); if (rfc822_valid_msgid(tmp)) @@ -393,19 +393,19 @@ static void process_user_header(struct Envelope *env) else FREE(&tmp); } - else if ((mutt_strncasecmp("to:", uh->data, 3) != 0) && - (mutt_strncasecmp("cc:", uh->data, 3) != 0) && - (mutt_strncasecmp("bcc:", uh->data, 4) != 0) && + else if ((mutt_str_strncasecmp("to:", uh->data, 3) != 0) && + (mutt_str_strncasecmp("cc:", uh->data, 3) != 0) && + (mutt_str_strncasecmp("bcc:", uh->data, 4) != 0) && #ifdef USE_NNTP - (mutt_strncasecmp("newsgroups:", uh->data, 11) != 0) && - (mutt_strncasecmp("followup-to:", uh->data, 12) != 0) && - (mutt_strncasecmp("x-comment-to:", uh->data, 13) != 0) && + (mutt_str_strncasecmp("newsgroups:", uh->data, 11) != 0) && + (mutt_str_strncasecmp("followup-to:", uh->data, 12) != 0) && + (mutt_str_strncasecmp("x-comment-to:", uh->data, 13) != 0) && #endif - (mutt_strncasecmp("supersedes:", uh->data, 11) != 0) && - (mutt_strncasecmp("subject:", uh->data, 8) != 0) && - (mutt_strncasecmp("return-path:", uh->data, 12) != 0)) + (mutt_str_strncasecmp("supersedes:", uh->data, 11) != 0) && + (mutt_str_strncasecmp("subject:", uh->data, 8) != 0) && + (mutt_str_strncasecmp("return-path:", uh->data, 12) != 0)) { - mutt_list_insert_tail(&env->userhdrs, safe_strdup(uh->data)); + mutt_list_insert_tail(&env->userhdrs, mutt_str_strdup(uh->data)); } } } @@ -656,7 +656,7 @@ static void add_references(struct ListHead *head, struct Envelope *e) src = !STAILQ_EMPTY(&e->references) ? &e->references : &e->in_reply_to; STAILQ_FOREACH(np, src, entries) { - mutt_list_insert_tail(head, safe_strdup(np->data)); + mutt_list_insert_tail(head, mutt_str_strdup(np->data)); } } @@ -664,7 +664,7 @@ static void add_message_id(struct ListHead *head, struct Envelope *e) { if (e->message_id) { - mutt_list_insert_head(head, safe_strdup(e->message_id)); + mutt_list_insert_head(head, mutt_str_strdup(e->message_id)); } } @@ -715,11 +715,11 @@ void mutt_make_misc_reply_headers(struct Envelope *env, struct Context *ctx, if (curenv->real_subj) { FREE(&env->subject); - env->subject = mutt_mem_malloc(mutt_strlen(curenv->real_subj) + 5); + env->subject = mutt_mem_malloc(mutt_str_strlen(curenv->real_subj) + 5); sprintf(env->subject, "Re: %s", curenv->real_subj); } else if (!env->subject) - env->subject = safe_strdup(EmptySubject); + env->subject = mutt_str_strdup(EmptySubject); } void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv) @@ -730,7 +730,7 @@ void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv #ifdef USE_NNTP if (option(OPT_NEWS_SEND) && option(OPT_X_COMMENT_TO) && curenv->from) - env->x_comment_to = safe_strdup(mutt_get_name(curenv->from)); + env->x_comment_to = mutt_str_strdup(mutt_get_name(curenv->from)); #endif } @@ -799,8 +799,9 @@ static int envelope_defaults(struct Envelope *env, struct Context *ctx, if ((flags & SENDNEWS)) { /* in case followup set Newsgroups: with Followup-To: if it present */ - if (!env->newsgroups && (mutt_strcasecmp(curenv->followup_to, "poster") != 0)) - env->newsgroups = safe_strdup(curenv->followup_to); + if (!env->newsgroups && + (mutt_str_strcasecmp(curenv->followup_to, "poster") != 0)) + env->newsgroups = mutt_str_strdup(curenv->followup_to); } else #endif @@ -968,7 +969,7 @@ void mutt_set_followup_to(struct Envelope *e) if (option(OPT_NEWS_SEND)) { if (!e->followup_to && e->newsgroups && (strrchr(e->newsgroups, ','))) - e->followup_to = safe_strdup(e->newsgroups); + e->followup_to = mutt_str_strdup(e->newsgroups); return; } #endif @@ -1073,13 +1074,14 @@ struct Address *mutt_default_from(void) else if (option(OPT_USE_DOMAIN)) { adr = rfc822_new_address(); - adr->mailbox = mutt_mem_malloc(mutt_strlen(Username) + mutt_strlen(fqdn) + 2); + adr->mailbox = + mutt_mem_malloc(mutt_str_strlen(Username) + mutt_str_strlen(fqdn) + 2); sprintf(adr->mailbox, "%s@%s", NONULL(Username), NONULL(fqdn)); } else { adr = rfc822_new_address(); - adr->mailbox = safe_strdup(NONULL(Username)); + adr->mailbox = mutt_str_strdup(NONULL(Username)); } return adr; @@ -1365,9 +1367,9 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, if (flags & SENDPOSTPONED) { if (WithCrypto & APPLICATION_PGP) - pgp_signas = safe_strdup(PgpSignAs); + pgp_signas = mutt_str_strdup(PgpSignAs); if (WithCrypto & APPLICATION_SMIME) - smime_default_key = safe_strdup(SmimeDefaultKey); + smime_default_key = mutt_str_strdup(SmimeDefaultKey); } /* Delay expansion of aliases until absolutely necessary--shouldn't @@ -1436,9 +1438,9 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, pbody->next = msg->content; /* don't kill command-line attachments */ msg->content = pbody; - ctype = safe_strdup(ContentType); + ctype = mutt_str_strdup(ContentType); if (!ctype) - ctype = safe_strdup("text/plain"); + ctype = mutt_str_strdup("text/plain"); mutt_parse_content_type(ctype, msg->content); FREE(&ctype); msg->content->unlink = true; @@ -1449,12 +1451,12 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, { mutt_mktemp(buffer, sizeof(buffer)); tempfp = mutt_file_fopen(buffer, "w+"); - msg->content->filename = safe_strdup(buffer); + msg->content->filename = mutt_str_strdup(buffer); } else { tempfp = mutt_file_fopen(tempfile, "a+"); - msg->content->filename = safe_strdup(tempfile); + msg->content->filename = mutt_str_strdup(tempfile); } } else @@ -1531,7 +1533,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, #ifdef USE_NNTP if ((flags & SENDNEWS) && ctx && ctx->magic == MUTT_NNTP && !msg->env->newsgroups) - msg->env->newsgroups = safe_strdup(((struct NntpData *) ctx->data)->group); + msg->env->newsgroups = mutt_str_strdup(((struct NntpData *) ctx->data)->group); #endif if (!(flags & (SENDMAILX | SENDBATCH)) && @@ -1581,7 +1583,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, if (!(flags & SENDKEY)) { if (option(OPT_TEXT_FLOWED) && msg->content->type == TYPETEXT && - (mutt_strcasecmp(msg->content->subtype, "plain") == 0)) + (mutt_str_strcasecmp(msg->content->subtype, "plain") == 0)) mutt_set_parameter("format", "flowed", &msg->content->parameter); } @@ -1601,7 +1603,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, mutt_file_copy_stream(stdin, tempfp); if (option(OPT_SIG_ON_TOP) && !(flags & (SENDMAILX | SENDKEY | SENDBATCH)) && - Editor && (mutt_strcmp(Editor, "builtin") != 0)) + Editor && (mutt_str_strcmp(Editor, "builtin") != 0)) append_signature(tempfp); /* include replies/forwarded messages, unless we are given a template */ @@ -1610,7 +1612,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, goto cleanup; if (!option(OPT_SIG_ON_TOP) && !(flags & (SENDMAILX | SENDKEY | SENDBATCH)) && - Editor && (mutt_strcmp(Editor, "builtin") != 0)) + Editor && (mutt_str_strcmp(Editor, "builtin") != 0)) append_signature(tempfp); } @@ -1624,7 +1626,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, /* wait until now to set the real name portion of our return address so that $realname can be set in a send-hook */ if (msg->env->from && !msg->env->from->personal && !(flags & (SENDRESEND | SENDPOSTPONED))) - msg->env->from->personal = safe_strdup(RealName); + msg->env->from->personal = mutt_str_strdup(RealName); if (!((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY))) mutt_file_fclose(&tempfp); @@ -1661,7 +1663,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, if (!mutt_edit_attachment(msg->content)) goto cleanup; } - else if (!Editor || (mutt_strcmp("builtin", Editor) == 0)) + else if (!Editor || (mutt_str_strcmp("builtin", Editor) == 0)) mutt_builtin_editor(msg->content->filename, msg, cur); else if (option(OPT_EDIT_HEADERS)) { @@ -1687,10 +1689,10 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, * parameter will be present. */ if (option(OPT_TEXT_FLOWED) && msg->content->type == TYPETEXT && - (mutt_strcasecmp("plain", msg->content->subtype) == 0)) + (mutt_str_strcasecmp("plain", msg->content->subtype) == 0)) { char *p = mutt_get_parameter("format", msg->content->parameter); - if (mutt_strcasecmp("flowed", NONULL(p)) != 0) + if (mutt_str_strcasecmp("flowed", NONULL(p)) != 0) rfc3676_space_stuff(msg); } @@ -1870,7 +1872,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, if (is_signed) msg->security &= ~SIGN; - pgpkeylist = safe_strdup(encrypt_as); + pgpkeylist = mutt_str_strdup(encrypt_as); if (mutt_protect(msg, pgpkeylist) == -1) { if (is_signed) @@ -2057,7 +2059,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, fcc[0] = '\0'; #endif - if (*fcc && (mutt_strcmp("/dev/null", fcc) != 0)) + if (*fcc && (mutt_str_strcmp("/dev/null", fcc) != 0)) { struct Body *tmpbody = msg->content; struct Body *save_sig = NULL; @@ -2071,8 +2073,8 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, msg->content->type == TYPEMULTIPART) { if (WithCrypto && (msg->security & (ENCRYPT | SIGN)) && - ((mutt_strcmp(msg->content->subtype, "encrypted") == 0) || - (mutt_strcmp(msg->content->subtype, "signed") == 0))) + ((mutt_str_strcmp(msg->content->subtype, "encrypted") == 0) || + (mutt_str_strcmp(msg->content->subtype, "signed") == 0))) { if (clear_content->type == TYPEMULTIPART) { diff --git a/sendlib.c b/sendlib.c index 640e4870a..26223db3e 100644 --- a/sendlib.c +++ b/sendlib.c @@ -125,19 +125,19 @@ static void encode_quoted(FGETCONV *fc, FILE *fout, int istext) } /* Escape lines that begin with/only contain "the message separator". */ - if (linelen == 4 && (mutt_strncmp("From", line, 4) == 0)) + if (linelen == 4 && (mutt_str_strncmp("From", line, 4) == 0)) { - strfcpy(line, "=46rom", sizeof(line)); + mutt_str_strfcpy(line, "=46rom", sizeof(line)); linelen = 6; } - else if (linelen == 4 && (mutt_strncmp("from", line, 4) == 0)) + else if (linelen == 4 && (mutt_str_strncmp("from", line, 4) == 0)) { - strfcpy(line, "=66rom", sizeof(line)); + mutt_str_strfcpy(line, "=66rom", sizeof(line)); linelen = 6; } else if (linelen == 1 && line[0] == '.') { - strfcpy(line, "=2E", sizeof(line)); + mutt_str_strfcpy(line, "=2E", sizeof(line)); linelen = 3; } @@ -325,7 +325,7 @@ int mutt_write_mime_header(struct Body *a, FILE *f) if (a->parameter) { - len = 25 + mutt_strlen(a->subtype); /* approximate len. of content-type */ + len = 25 + mutt_str_strlen(a->subtype); /* approximate len. of content-type */ for (struct Parameter *p = a->parameter; p; p = p->next) { @@ -337,7 +337,7 @@ int mutt_write_mime_header(struct Body *a, FILE *f) fputc(';', f); buffer[0] = 0; - tmp = safe_strdup(p->value); + tmp = mutt_str_strdup(p->value); encode = rfc2231_encode_string(&tmp); rfc822_cat(buffer, sizeof(buffer), tmp, MimeSpecials); @@ -346,12 +346,12 @@ int mutt_write_mime_header(struct Body *a, FILE *f) * even when they aren't needed. */ - if ((mutt_strcasecmp(p->attribute, "boundary") == 0) && (strcmp(buffer, tmp) == 0)) + if ((mutt_str_strcasecmp(p->attribute, "boundary") == 0) && (strcmp(buffer, tmp) == 0)) snprintf(buffer, sizeof(buffer), "\"%s\"", tmp); FREE(&tmp); - tmplen = mutt_strlen(buffer) + mutt_strlen(p->attribute) + 1; + tmplen = mutt_str_strlen(buffer) + mutt_str_strlen(p->attribute) + 1; if (len + tmplen + 2 > 76) { @@ -398,7 +398,7 @@ int mutt_write_mime_header(struct Body *a, FILE *f) t = fn; buffer[0] = 0; - tmp = safe_strdup(t); + tmp = mutt_str_strdup(t); encode = rfc2231_encode_string(&tmp); rfc822_cat(buffer, sizeof(buffer), tmp, MimeSpecials); FREE(&tmp); @@ -444,7 +444,7 @@ int mutt_write_mime_body(struct Body *a, FILE *f) mutt_error(_("No boundary parameter found! [report this error]")); return -1; } - strfcpy(boundary, p, sizeof(boundary)); + mutt_str_strfcpy(boundary, p, sizeof(boundary)); for (struct Body *t = a->parts; t; t = t->next) { @@ -461,7 +461,7 @@ int mutt_write_mime_body(struct Body *a, FILE *f) /* This is pretty gross, but it's the best solution for now... */ if ((WithCrypto & APPLICATION_PGP) && a->type == TYPEAPPLICATION && - (mutt_strcmp(a->subtype, "pgp-encrypted") == 0)) + (mutt_str_strcmp(a->subtype, "pgp-encrypted") == 0)) { fputs("Version: 1\n", f); return 0; @@ -701,7 +701,7 @@ static size_t convert_file_to(FILE *file, const char *fromcode, int ncodes, for (int i = 0; i < ncodes; i++) { - if (mutt_strcasecmp(tocodes[i], "utf-8") != 0) + if (mutt_str_strcasecmp(tocodes[i], "utf-8") != 0) cd[i] = mutt_iconv_open(tocodes[i], "utf-8", 0); else { @@ -851,7 +851,7 @@ static size_t convert_file_from_to(FILE *file, const char *fromcodes, const char c1 = strchr(c, ':'); if (c1 == c) continue; - tcode[i] = mutt_substrdup(c, c1); + tcode[i] = mutt_str_substr_dup(c, c1); } ret = (size_t)(-1); @@ -863,7 +863,7 @@ static size_t convert_file_from_to(FILE *file, const char *fromcodes, const char c1 = strchr(c, ':'); if (c1 == c) continue; - fcode = mutt_substrdup(c, c1); + fcode = mutt_str_substr_dup(c, c1); ret = convert_file_to(file, fcode, ncodes, (const char **) tcode, &cn, info); if (ret != (size_t)(-1)) @@ -1006,7 +1006,7 @@ int mutt_lookup_mime_type(struct Body *att, const char *path) type = TYPEOTHER; cur_sze = 0; - szf = mutt_strlen(path); + szf = mutt_str_strlen(path); for (int count = 0; count < 4; count++) { @@ -1021,13 +1021,13 @@ int mutt_lookup_mime_type(struct Body *att, const char *path) /* * check default unix mimetypes location first */ - strfcpy(buf, "/etc/mime.types", sizeof(buf)); + mutt_str_strfcpy(buf, "/etc/mime.types", sizeof(buf)); break; case 1: - strfcpy(buf, SYSCONFDIR "/mime.types", sizeof(buf)); + mutt_str_strfcpy(buf, SYSCONFDIR "/mime.types", sizeof(buf)); break; case 2: - strfcpy(buf, PKGDATADIR "/mime.types", sizeof(buf)); + mutt_str_strfcpy(buf, PKGDATADIR "/mime.types", sizeof(buf)); break; case 3: snprintf(buf, sizeof(buf), "%s/.mime.types", NONULL(HomeDir)); @@ -1062,10 +1062,10 @@ int mutt_lookup_mime_type(struct Body *att, const char *path) /* cycle through the file extensions */ while ((p = strtok(p, " \t\n"))) { - sze = mutt_strlen(p); + sze = mutt_str_strlen(p); if ((sze > cur_sze) && (szf >= sze) && - ((mutt_strcasecmp(path + szf - sze, p) == 0) || - (mutt_strcasecmp(path + szf - sze, p) == 0)) && + ((mutt_str_strcasecmp(path + szf - sze, p) == 0) || + (mutt_str_strcasecmp(path + szf - sze, p) == 0)) && (szf == sze || path[szf - sze - 1] == '.')) { /* get the content-type */ @@ -1081,11 +1081,11 @@ int mutt_lookup_mime_type(struct Body *att, const char *path) for (q = p; *q && !ISSPACE(*q); q++) ; - mutt_substrcpy(subtype, p, q, sizeof(subtype)); + mutt_str_substr_cpy(subtype, p, q, sizeof(subtype)); type = mutt_check_mime_type(ct); if (type == TYPEOTHER) - strfcpy(xtype, ct, sizeof(xtype)); + mutt_str_strfcpy(xtype, ct, sizeof(xtype)); cur_sze = sze; } @@ -1151,7 +1151,7 @@ static void transform_to_7bit(struct Body *a, FILE *fpin) mutt_file_fclose(&s.fpout); FREE(&a->d_filename); a->d_filename = a->filename; - a->filename = safe_strdup(buff); + a->filename = mutt_str_strdup(buff); a->unlink = true; if (stat(a->filename, &sb) == -1) { @@ -1234,7 +1234,7 @@ cleanup: a->d_filename = a->filename; if (a->filename && a->unlink) unlink(a->filename); - a->filename = safe_strdup(temp); + a->filename = mutt_str_strdup(temp); a->unlink = true; if (stat(a->filename, &sb) == -1) { @@ -1256,7 +1256,7 @@ static void set_encoding(struct Body *b, struct Content *info) if (b->type == TYPETEXT) { char *chsname = mutt_get_body_charset(send_charset, sizeof(send_charset), b); - if ((info->lobin && (mutt_strncasecmp(chsname, "iso-2022", 8) != 0)) || + if ((info->lobin && (mutt_str_strncasecmp(chsname, "iso-2022", 8) != 0)) || info->linemax > 990 || (info->from && option(OPT_ENCODE_FROM))) b->encoding = ENCQUOTEDPRINTABLE; else if (info->hibin) @@ -1277,7 +1277,7 @@ static void set_encoding(struct Body *b, struct Content *info) b->encoding = ENC7BIT; } else if (b->type == TYPEAPPLICATION && - (mutt_strcasecmp(b->subtype, "pgp-keys") == 0)) + (mutt_str_strcasecmp(b->subtype, "pgp-keys") == 0)) b->encoding = ENC7BIT; else { @@ -1311,7 +1311,7 @@ char *mutt_get_body_charset(char *d, size_t dlen, struct Body *b) if (p) mutt_canonical_charset(d, dlen, NONULL(p)); else - strfcpy(d, "us-ascii", dlen); + mutt_str_strfcpy(d, "us-ascii", dlen); return d; } @@ -1369,8 +1369,8 @@ struct Body *mutt_make_message_attach(struct Context *ctx, struct Header *hdr, i body = mutt_new_body(); body->type = TYPEMESSAGE; - body->subtype = safe_strdup("rfc822"); - body->filename = safe_strdup(buffer); + body->subtype = mutt_str_strdup("rfc822"); + body->filename = mutt_str_strdup(buffer); body->unlink = true; body->use_disp = false; body->disposition = DISPINLINE; @@ -1471,7 +1471,7 @@ struct Body *mutt_make_file_attach(const char *path) struct Content *info = NULL; att = mutt_new_body(); - att->filename = safe_strdup(path); + att->filename = mutt_str_strdup(path); if (MimeTypeQueryCommand && *MimeTypeQueryCommand && option(OPT_MIME_TYPE_QUERY_FIRST)) run_mime_type_query(att); @@ -1503,12 +1503,12 @@ struct Body *mutt_make_file_attach(const char *path) * chars if this is really a binary file... */ att->type = TYPETEXT; - att->subtype = safe_strdup("plain"); + att->subtype = mutt_str_strdup("plain"); } else { att->type = TYPEAPPLICATION; - att->subtype = safe_strdup("octet-stream"); + att->subtype = mutt_str_strdup("octet-stream"); } } @@ -1546,7 +1546,8 @@ static bool check_boundary(const char *boundary, struct Body *b) if (b->next && check_boundary(boundary, b->next)) return true; - if ((p = mutt_get_parameter("boundary", b->parameter)) && (mutt_strcmp(p, boundary) == 0)) + if ((p = mutt_get_parameter("boundary", b->parameter)) && + (mutt_str_strcmp(p, boundary) == 0)) return true; return false; } @@ -1557,7 +1558,7 @@ struct Body *mutt_make_multipart(struct Body *b) new = mutt_new_body(); new->type = TYPEMULTIPART; - new->subtype = safe_strdup("mixed"); + new->subtype = mutt_str_strdup("mixed"); new->encoding = get_toplevel_encoding(b); do { @@ -1608,7 +1609,7 @@ void mutt_write_address_list(struct Address *adr, FILE *fp, int linelen, int dis adr->next = NULL; buf[0] = 0; rfc822_write_address(buf, sizeof(buf), adr, display); - len = mutt_strlen(buf); + len = mutt_str_strlen(buf); if (count && linelen + len > 74) { fputs("\n\t", fp); @@ -1726,7 +1727,7 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, if (tag && *tag && fprintf(fp, "%s%s: ", NONULL(pfx), tag) < 0) return -1; - col = mutt_strlen(tag) + (tag && *tag ? 2 : 0) + mutt_strlen(pfx); + col = mutt_str_strlen(tag) + (tag && *tag ? 2 : 0) + mutt_str_strlen(pfx); while (p && *p) { @@ -1734,7 +1735,7 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, /* find the next word and place it in `buf'. it may start with * whitespace we can fold before */ - next = find_word(p); + next = mutt_str_find_word(p); l = MIN(sizeof(buf) - 1, next - p); memcpy(buf, p, l); buf[l] = 0; @@ -1742,7 +1743,7 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, /* determine width: character cells for display, bytes for sending * (we get pure ascii only) */ w = mutt_mb_width(buf, col, display); - enc = (mutt_strncmp(buf, "=?", 2) == 0); + enc = (mutt_str_strncmp(buf, "=?", 2) == 0); mutt_debug(5, "mwoh: word=[%s], col=%d, w=%d, next=[0x0%x]\n", buf, col, w, *next); @@ -1751,7 +1752,7 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, * and encoded words */ if (!first && !enc && col && col + w >= wraplen) { - col = mutt_strlen(pfx); + col = mutt_str_strlen(pfx); fold = 1; if (fprintf(fp, "\n%s", NONULL(pfx)) <= 0) return -1; @@ -1838,13 +1839,13 @@ static int write_one_header(FILE *fp, int pfxw, int max, int wraplen, const char const char *start, const char *end, int flags) { char *tagbuf = NULL, *valbuf = NULL, *t = NULL; - int is_from = ((end - start) > 5 && (mutt_strncasecmp(start, "from ", 5) == 0)); + int is_from = ((end - start) > 5 && (mutt_str_strncasecmp(start, "from ", 5) == 0)); /* only pass through folding machinery if necessary for sending, never wrap From_ headers on sending */ if (!(flags & CH_DISPLAY) && (pfxw + max <= wraplen || is_from)) { - valbuf = mutt_substrdup(start, end); + valbuf = mutt_str_substr_dup(start, end); mutt_debug(4, "mwoh: buf[%s%s] short enough, " "max width = %d <= %d\n", NONULL(pfx), valbuf, max, wraplen); @@ -1864,7 +1865,7 @@ static int write_one_header(FILE *fp, int pfxw, int max, int wraplen, const char FREE(&valbuf); return 0; } - if (print_val(fp, pfx, valbuf, flags, mutt_strlen(pfx)) < 0) + if (print_val(fp, pfx, valbuf, flags, mutt_str_strlen(pfx)) < 0) { FREE(&valbuf); return -1; @@ -1882,21 +1883,21 @@ static int write_one_header(FILE *fp, int pfxw, int max, int wraplen, const char if (is_from) { tagbuf = NULL; - valbuf = mutt_substrdup(start, end); + valbuf = mutt_str_substr_dup(start, end); } else { - tagbuf = mutt_substrdup(start, t); + tagbuf = mutt_str_substr_dup(start, t); /* skip over the colon separating the header field name and value */ t++; /* skip over any leading whitespace (WSP, as defined in RFC5322) - * NOTE: skip_email_wsp() does the wrong thing here. + * NOTE: mutt_str_skip_email_wsp() does the wrong thing here. * See tickets 3609 and 3716. */ while (*t == ' ' || *t == '\t') t++; - valbuf = mutt_substrdup(t, end); + valbuf = mutt_str_substr_dup(t, end); } mutt_debug(4, "mwoh: buf[%s%s] too long, max width = %d > %d\n", NONULL(pfx), NONULL(valbuf), max, wraplen); @@ -1924,7 +1925,7 @@ int mutt_write_one_header(FILE *fp, const char *tag, const char *value, char *p = (char *) value, *last = NULL, *line = NULL; int max = 0, w, rc = -1; int pfxw = mutt_strwidth(pfx); - char *v = safe_strdup(value); + char *v = mutt_str_strdup(value); bool display = (flags & CH_DISPLAY); if (!display || option(OPT_WEED)) @@ -2149,7 +2150,7 @@ int mutt_write_rfc822_header(FILE *fp, struct Envelope *env, *p = '\0'; - p = skip_email_wsp(p + 1); + p = mutt_str_skip_email_wsp(p + 1); if (!*p) { *q = ':'; @@ -2157,7 +2158,7 @@ int mutt_write_rfc822_header(FILE *fp, struct Envelope *env, } /* check to see if the user has overridden the user-agent field */ - if (mutt_strncasecmp("user-agent", tmp->data, 10) == 0) + if (mutt_str_strncasecmp("user-agent", tmp->data, 10) == 0) { has_agent = true; if (privacy) @@ -2195,14 +2196,14 @@ static void encode_headers(struct ListHead *h) continue; i = p - np->data; - p = skip_email_wsp(p + 1); - tmp = safe_strdup(p); + p = mutt_str_skip_email_wsp(p + 1); + tmp = mutt_str_strdup(p); if (!tmp) continue; rfc2047_encode_string32(&tmp); - mutt_mem_realloc(&np->data, mutt_strlen(np->data) + 2 + mutt_strlen(tmp) + 1); + mutt_mem_realloc(&np->data, mutt_str_strlen(np->data) + 2 + mutt_str_strlen(tmp) + 1); sprintf(np->data + i, ": %s", NONULL(tmp)); @@ -2253,7 +2254,7 @@ static char *gen_msgid(void) snprintf(buf, sizeof(buf), "<%d%02d%02d%02d%02d%02d.%s@%s>", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, rndid, fqdn); - return (safe_strdup(buf)); + return (mutt_str_strdup(buf)); } static void alarm_handler(int sig) @@ -2289,7 +2290,7 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf char tmp[_POSIX_PATH_MAX]; mutt_mktemp(tmp, sizeof(tmp)); - *tempfile = safe_strdup(tmp); + *tempfile = mutt_str_strdup(tmp); } pid = fork(); @@ -2488,11 +2489,11 @@ int mutt_invoke_sendmail(struct Address *from, struct Address *to, struct Addres return i; } - s = safe_strdup(cmd); + s = mutt_str_strdup(cmd); } else #endif - s = safe_strdup(Sendmail); + s = mutt_str_strdup(Sendmail); /* ensure that $sendmail is set to avoid a crash. http://dev.mutt.org/trac/ticket/3548 */ if (!s) @@ -2510,13 +2511,13 @@ int mutt_invoke_sendmail(struct Address *from, struct Address *to, struct Addres if (i) { - if (mutt_strcmp(ps, "--") == 0) + if (mutt_str_strcmp(ps, "--") == 0) break; args[argslen++] = ps; } else { - path = safe_strdup(ps); + path = mutt_str_strdup(ps); ps = strrchr(ps, '/'); if (ps) ps++; @@ -2656,7 +2657,7 @@ void mutt_prepare_envelope(struct Envelope *env, int final) buffer[0] = 0; rfc822_cat(buffer, sizeof(buffer), "undisclosed-recipients", RFC822Specials); - env->to->mailbox = safe_strdup(buffer); + env->to->mailbox = mutt_str_strdup(buffer); } mutt_set_followup_to(env); @@ -2787,7 +2788,7 @@ int mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to) * upon message criteria. */ if (!from->personal) - from->personal = safe_strdup(RealName); + from->personal = mutt_str_strdup(RealName); if (fqdn) rfc822_qualify(from, fqdn); @@ -2838,7 +2839,7 @@ struct Address *mutt_remove_duplicates(struct Address *addr) for (tmp = top, dup = false; tmp && tmp != addr; tmp = tmp->next) { if (tmp->mailbox && addr->mailbox && - (mutt_strcasecmp(addr->mailbox, tmp->mailbox) == 0)) + (mutt_str_strcasecmp(addr->mailbox, tmp->mailbox) == 0)) { dup = true; break; @@ -2893,7 +2894,7 @@ int mutt_write_multiple_fcc(const char *path, struct Header *hdr, const char *ms char *tok = NULL; int status; - strfcpy(fcc_tok, path, sizeof(fcc_tok)); + mutt_str_strfcpy(fcc_tok, path, sizeof(fcc_tok)); tok = strtok(fcc_tok, ","); if (!tok) @@ -2912,7 +2913,7 @@ int mutt_write_multiple_fcc(const char *path, struct Header *hdr, const char *ms /* Only call mutt_expand_path iff tok has some data */ mutt_debug(1, "Fcc: additional mailbox token = '%s'\n", tok); - strfcpy(fcc_expanded, tok, sizeof(fcc_expanded)); + mutt_str_strfcpy(fcc_expanded, tok, sizeof(fcc_expanded)); mutt_expand_path(fcc_expanded, sizeof(fcc_expanded)); mutt_debug(1, " Additional mailbox expanded = '%s'\n", fcc_expanded); status = mutt_write_fcc(fcc_expanded, hdr, msgid, post, fcc, finalpath); @@ -3121,7 +3122,7 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid, if (mx_commit_message(msg, &f) != 0) r = -1; else if (finalpath) - *finalpath = safe_strdup(msg->commited_path); + *finalpath = mutt_str_strdup(msg->commited_path); mx_close_message(&f, &msg); mx_close_mailbox(&f, NULL); diff --git a/sidebar.c b/sidebar.c index 008658333..7c283a873 100644 --- a/sidebar.c +++ b/sidebar.c @@ -126,7 +126,7 @@ static const char *cb_format_str(char *dest, size_t destlen, size_t col, int col if (!b) return src; - int c = Context && (mutt_strcmp(Context->realpath, b->realpath) == 0); + int c = Context && (mutt_str_strcmp(Context->realpath, b->realpath) == 0); optional = flags & MUTT_FORMAT_OPTIONAL; @@ -250,14 +250,14 @@ static void make_sidebar_entry(char *buf, unsigned int buflen, int width, if (!buf || !box || !sbe) return; - strfcpy(sbe->box, box, sizeof(sbe->box)); + mutt_str_strfcpy(sbe->box, box, sizeof(sbe->box)); mutt_expando_format(buf, buflen, 0, width, NONULL(SidebarFormat), cb_format_str, (unsigned long) sbe, 0); /* Force string to be exactly the right width */ int w = mutt_strwidth(buf); - int s = mutt_strlen(buf); + int s = mutt_str_strlen(buf); width = MIN(buflen, width); if (w < width) { @@ -294,22 +294,22 @@ static int cb_qsort_sbe(const void *a, const void *b) { case SORT_COUNT: if (b2->msg_count == b1->msg_count) - result = mutt_strcoll(b1->path, b2->path); + result = mutt_str_strcoll(b1->path, b2->path); else result = (b2->msg_count - b1->msg_count); break; case SORT_UNREAD: if (b2->msg_unread == b1->msg_unread) - result = mutt_strcoll(b1->path, b2->path); + result = mutt_str_strcoll(b1->path, b2->path); else result = (b2->msg_unread - b1->msg_unread); break; case SORT_DESC: - result = mutt_strcmp(b1->desc, b2->desc); + result = mutt_str_strcmp(b1->desc, b2->desc); break; case SORT_FLAGGED: if (b2->msg_flagged == b1->msg_flagged) - result = mutt_strcoll(b1->path, b2->path); + result = mutt_str_strcoll(b1->path, b2->path); else result = (b2->msg_flagged - b1->msg_flagged); break; @@ -317,7 +317,7 @@ static int cb_qsort_sbe(const void *a, const void *b) { result = mutt_inbox_cmp(b1->path, b2->path); if (result == 0) - result = mutt_strcoll(b1->path, b2->path); + result = mutt_str_strcoll(b1->path, b2->path); break; } } @@ -365,7 +365,7 @@ static void update_entries_visibility(void) (sbe->buffy->msg_flagged > 0)) continue; - if (Context && (mutt_strcmp(sbe->buffy->realpath, Context->realpath) == 0)) + if (Context && (mutt_str_strcmp(sbe->buffy->realpath, Context->realpath) == 0)) /* Spool directory */ continue; @@ -826,7 +826,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) else if (b->msg_flagged > 0) SETCOLOR(MT_COLOR_FLAGGED); else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) && - (mutt_strcmp(b->path, SpoolFile) == 0)) + (mutt_str_strcmp(b->path, SpoolFile) == 0)) SETCOLOR(MT_COLOR_SB_SPOOLFILE); else { @@ -841,7 +841,8 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) col = div_width; mutt_window_move(MuttSidebarWindow, row, col); - if (Context && Context->realpath && (mutt_strcmp(b->realpath, Context->realpath) == 0)) + if (Context && Context->realpath && + (mutt_str_strcmp(b->realpath, Context->realpath) == 0)) { #ifdef USE_NOTMUCH if (b->magic == MUTT_NOTMUCH) @@ -856,15 +857,15 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) } /* compute length of Folder without trailing separator */ - size_t maildirlen = mutt_strlen(Folder); + size_t maildirlen = mutt_str_strlen(Folder); if (maildirlen && SidebarDelimChars && strchr(SidebarDelimChars, Folder[maildirlen - 1])) maildirlen--; /* check whether Folder is a prefix of the current folder's path */ bool maildir_is_prefix = false; - if ((mutt_strlen(b->path) > maildirlen) && - (mutt_strncmp(Folder, b->path, maildirlen) == 0) && SidebarDelimChars && - strchr(SidebarDelimChars, b->path[maildirlen])) + if ((mutt_str_strlen(b->path) > maildirlen) && + (mutt_str_strncmp(Folder, b->path, maildirlen) == 0) && + SidebarDelimChars && strchr(SidebarDelimChars, b->path[maildirlen])) maildir_is_prefix = true; /* calculate depth of current folder and generate its display name with indented spaces */ @@ -874,7 +875,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) { /* disregard a trailing separator, so strlen() - 2 */ sidebar_folder_name = b->path; - for (int i = mutt_strlen(sidebar_folder_name) - 2; i >= 0; i--) + for (int i = mutt_str_strlen(sidebar_folder_name) - 2; i >= 0; i--) { if (SidebarDelimChars && strchr(SidebarDelimChars, sidebar_folder_name[i])) { @@ -895,7 +896,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) const char *tmp_folder_name = NULL; int lastsep = 0; tmp_folder_name = b->path + maildirlen + 1; - int tmplen = (int) mutt_strlen(tmp_folder_name) - 1; + int tmplen = (int) mutt_str_strlen(tmp_folder_name) - 1; for (int i = 0; i < tmplen; i++) { if (SidebarDelimChars && strchr(SidebarDelimChars, tmp_folder_name[i])) @@ -908,13 +909,13 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) { if (option(OPT_SIDEBAR_SHORT_PATH)) tmp_folder_name += lastsep; /* basename */ - int sfn_len = mutt_strlen(tmp_folder_name) + - sidebar_folder_depth * mutt_strlen(SidebarIndentString) + 1; + int sfn_len = mutt_str_strlen(tmp_folder_name) + + sidebar_folder_depth * mutt_str_strlen(SidebarIndentString) + 1; sidebar_folder_name = mutt_mem_malloc(sfn_len); sidebar_folder_name[0] = 0; for (int i = 0; i < sidebar_folder_depth; i++) - safe_strcat(sidebar_folder_name, sfn_len, NONULL(SidebarIndentString)); - safe_strcat(sidebar_folder_name, sfn_len, tmp_folder_name); + mutt_str_strcat(sidebar_folder_name, sfn_len, NONULL(SidebarIndentString)); + mutt_str_strcat(sidebar_folder_name, sfn_len, tmp_folder_name); } } char str[STRING]; @@ -1037,7 +1038,7 @@ void mutt_sb_set_buffystats(const struct Context *ctx) for (; b; b = b->next) { - if (mutt_strcmp(b->realpath, ctx->realpath) == 0) + if (mutt_str_strcmp(b->realpath, ctx->realpath) == 0) { b->msg_unread = ctx->unread; b->msg_count = ctx->msgcount; @@ -1079,7 +1080,7 @@ void mutt_sb_set_open_buffy(void) for (int entry = 0; entry < EntryCount; entry++) { - if (mutt_strcmp(Entries[entry]->buffy->realpath, Context->realpath) == 0) + if (mutt_str_strcmp(Entries[entry]->buffy->realpath, Context->realpath) == 0) { OpnIndex = entry; HilIndex = entry; @@ -1121,7 +1122,7 @@ void mutt_sb_notify_mailbox(struct Buffy *b, int created) TopIndex = EntryCount; if (BotIndex < 0) BotIndex = EntryCount; - if ((OpnIndex < 0) && Context && (mutt_strcmp(b->realpath, Context->realpath) == 0)) + if ((OpnIndex < 0) && Context && (mutt_str_strcmp(b->realpath, Context->realpath) == 0)) OpnIndex = EntryCount; EntryCount++; diff --git a/smtp.c b/smtp.c index 60074275e..167ba7069 100644 --- a/smtp.c +++ b/smtp.c @@ -90,7 +90,7 @@ static bool valid_smtp_code(char *buf, size_t len, int *n) code[1] = buf[1]; code[2] = buf[2]; code[3] = 0; - if (mutt_atoi(code, n) < 0) + if (mutt_str_atoi(code, n) < 0) return false; return true; } @@ -115,19 +115,19 @@ static int smtp_get_resp(struct Connection *conn) return SMTP_ERR_READ; } - if (mutt_strncasecmp("8BITMIME", buf + 4, 8) == 0) + if (mutt_str_strncasecmp("8BITMIME", buf + 4, 8) == 0) mutt_bit_set(Capabilities, EIGHTBITMIME); - else if (mutt_strncasecmp("AUTH ", buf + 4, 5) == 0) + else if (mutt_str_strncasecmp("AUTH ", buf + 4, 5) == 0) { mutt_bit_set(Capabilities, AUTH); FREE(&AuthMechs); - AuthMechs = safe_strdup(buf + 9); + AuthMechs = mutt_str_strdup(buf + 9); } - else if (mutt_strncasecmp("DSN", buf + 4, 3) == 0) + else if (mutt_str_strncasecmp("DSN", buf + 4, 3) == 0) mutt_bit_set(Capabilities, DSN); - else if (mutt_strncasecmp("STARTTLS", buf + 4, 8) == 0) + else if (mutt_str_strncasecmp("STARTTLS", buf + 4, 8) == 0) mutt_bit_set(Capabilities, STARTTLS); - else if (mutt_strncasecmp("SMTPUTF8", buf + 4, 8) == 0) + else if (mutt_str_strncasecmp("SMTPUTF8", buf + 4, 8) == 0) mutt_bit_set(Capabilities, SMTPUTF8); if (!valid_smtp_code(buf, n, &n)) @@ -203,7 +203,7 @@ static int smtp_data(struct Connection *conn, const char *msgfile) while (fgets(buf, sizeof(buf) - 1, fp)) { - buflen = mutt_strlen(buf); + buflen = mutt_str_strlen(buf); term = buflen && buf[buflen - 1] == '\n'; if (term && (buflen == 1 || buf[buflen - 2] != '\r')) snprintf(buf + buflen - 1, sizeof(buf) - buflen + 1, "\r\n"); @@ -285,7 +285,7 @@ static int smtp_fill_account(struct Account *account) account->port = 0; account->type = MUTT_ACCT_TYPE_SMTP; - urlstr = safe_strdup(SmtpUrl); + urlstr = mutt_str_strdup(SmtpUrl); url_parse(&url, urlstr); if ((url.scheme != U_SMTP && url.scheme != U_SMTPS) || !url.host || mutt_account_fromurl(account, &url) < 0) @@ -394,15 +394,15 @@ static int smtp_auth_sasl(struct Connection *conn, const char *mechlist) snprintf(buf, bufsize, "AUTH %s", mech); if (len) { - safe_strcat(buf, bufsize, " "); - if (sasl_encode64(data, len, buf + mutt_strlen(buf), - bufsize - mutt_strlen(buf), &len) != SASL_OK) + mutt_str_strcat(buf, bufsize, " "); + if (sasl_encode64(data, len, buf + mutt_str_strlen(buf), + bufsize - mutt_str_strlen(buf), &len) != SASL_OK) { mutt_debug(1, "smtp_auth_sasl: error base64-encoding client response.\n"); goto fail; } } - safe_strcat(buf, bufsize, "\r\n"); + mutt_str_strcat(buf, bufsize, "\r\n"); do { @@ -444,7 +444,7 @@ static int smtp_auth_sasl(struct Connection *conn, const char *mechlist) goto fail; } } - strfcpy(buf + len, "\r\n", bufsize - len); + mutt_str_strfcpy(buf + len, "\r\n", bufsize - len); } while (rc == SMTP_READY && saslrc != SASL_FAIL); if (smtp_success(rc)) @@ -466,7 +466,7 @@ static int smtp_auth(struct Connection *conn) if (SmtpAuthenticators && *SmtpAuthenticators) { - char *methods = safe_strdup(SmtpAuthenticators); + char *methods = mutt_str_strdup(SmtpAuthenticators); char *method = NULL; char *delim = NULL; @@ -530,9 +530,9 @@ static int smtp_auth_plain(struct Connection *conn) /* Check if any elements in SmtpAuthenticators is "plain" */ for (method = delim = SmtpAuthenticators; - *delim && (delim = mutt_strchrnul(method, ':')); method = delim + 1) + *delim && (delim = mutt_str_strchrnul(method, ':')); method = delim + 1) { - if (mutt_strncasecmp(method, "plain", 5) == 0) + if (mutt_str_strncasecmp(method, "plain", 5) == 0) { /* Get username and password. Bail out of any cannot be retrieved. */ if ((mutt_account_getuser(&conn->account) < 0) || @@ -676,7 +676,7 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to, ret = snprintf(buf, sizeof(buf), "MAIL FROM:<%s>", envfrom); if (eightbit && mutt_bit_isset(Capabilities, EIGHTBITMIME)) { - safe_strncat(buf, sizeof(buf), " BODY=8BITMIME", 15); + mutt_str_strncat(buf, sizeof(buf), " BODY=8BITMIME", 15); ret += 14; } if (DsnReturn && mutt_bit_isset(Capabilities, DSN)) @@ -685,7 +685,7 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to, (address_uses_unicode(envfrom) || addresses_use_unicode(to) || addresses_use_unicode(cc) || addresses_use_unicode(bcc))) ret += snprintf(buf + ret, sizeof(buf) - ret, " SMTPUTF8"); - safe_strncat(buf, sizeof(buf), "\r\n", 3); + mutt_str_strncat(buf, sizeof(buf), "\r\n", 3); if (mutt_socket_write(conn, buf) == -1) { ret = SMTP_ERR_WRITE; diff --git a/sort.c b/sort.c index e51a4c6be..7a271c564 100644 --- a/sort.c +++ b/sort.c @@ -106,7 +106,7 @@ static int compare_subject(const void *a, const void *b) else if (!(*pb)->env->real_subj) rc = 1; else - rc = mutt_strcasecmp((*pa)->env->real_subj, (*pb)->env->real_subj); + rc = mutt_str_strcasecmp((*pa)->env->real_subj, (*pb)->env->real_subj); rc = perform_auxsort(rc, a, b); return (SORTCODE(rc)); } @@ -136,9 +136,9 @@ static int compare_to(const void *a, const void *b) const char *fb = NULL; int result; - strfcpy(fa, mutt_get_name((*ppa)->env->to), SHORT_STRING); + mutt_str_strfcpy(fa, mutt_get_name((*ppa)->env->to), SHORT_STRING); fb = mutt_get_name((*ppb)->env->to); - result = mutt_strncasecmp(fa, fb, SHORT_STRING); + result = mutt_str_strncasecmp(fa, fb, SHORT_STRING); result = perform_auxsort(result, a, b); return (SORTCODE(result)); } @@ -151,9 +151,9 @@ static int compare_from(const void *a, const void *b) const char *fb = NULL; int result; - strfcpy(fa, mutt_get_name((*ppa)->env->from), SHORT_STRING); + mutt_str_strfcpy(fa, mutt_get_name((*ppa)->env->from), SHORT_STRING); fb = mutt_get_name((*ppb)->env->from); - result = mutt_strncasecmp(fa, fb, SHORT_STRING); + result = mutt_str_strncasecmp(fa, fb, SHORT_STRING); result = perform_auxsort(result, a, b); return (SORTCODE(result)); } @@ -269,7 +269,7 @@ static int compare_label(const void *a, const void *b) } /* If both have a label, we just do a lexical compare. */ - result = mutt_strcasecmp((*ppa)->env->x_label, (*ppb)->env->x_label); + result = mutt_str_strcasecmp((*ppa)->env->x_label, (*ppb)->env->x_label); return (SORTCODE(result)); } diff --git a/state.c b/state.c index 4d80ce343..3809b109c 100644 --- a/state.c +++ b/state.c @@ -31,7 +31,7 @@ void state_mark_attach(struct State *s) { if (!s || !s->fpout) return; - if ((s->flags & MUTT_DISPLAY) && (mutt_strcmp(Pager, "builtin") == 0)) + if ((s->flags & MUTT_DISPLAY) && (mutt_str_strcmp(Pager, "builtin") == 0)) state_puts(AttachmentMarker, s); } diff --git a/status.c b/status.c index c5e29e4cd..fec9e5016 100644 --- a/status.c +++ b/status.c @@ -110,24 +110,24 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c #ifdef USE_NOTMUCH char *p = NULL; if (Context && Context->magic == MUTT_NOTMUCH && (p = nm_get_description(Context))) - strfcpy(tmp, p, sizeof(tmp)); + mutt_str_strfcpy(tmp, p, sizeof(tmp)); else #endif #ifdef USE_COMPRESSED if (Context && Context->compress_info && Context->realpath) { - strfcpy(tmp, Context->realpath, sizeof(tmp)); + mutt_str_strfcpy(tmp, Context->realpath, sizeof(tmp)); mutt_pretty_mailbox(tmp, sizeof(tmp)); } else #endif if (Context && Context->path) { - strfcpy(tmp, Context->path, sizeof(tmp)); + mutt_str_strfcpy(tmp, Context->path, sizeof(tmp)); mutt_pretty_mailbox(tmp, sizeof(tmp)); } else - strfcpy(tmp, _("(no mailbox)"), sizeof(tmp)); + mutt_str_strfcpy(tmp, _("(no mailbox)"), sizeof(tmp)); snprintf(fmt, sizeof(fmt), "%%%ss", prefix); snprintf(buf, buflen, fmt, tmp); diff --git a/thread.c b/thread.c index b177f6620..07c54677d 100644 --- a/thread.c +++ b/thread.c @@ -293,11 +293,11 @@ void mutt_draw_tree(struct Context *ctx) if (start_depth > 1) { strncpy(new_tree, pfx, (start_depth - 1) * width); - strfcpy(new_tree + (start_depth - 1) * width, arrow, - (1 + depth - start_depth) * width + 2); + mutt_str_strfcpy(new_tree + (start_depth - 1) * width, arrow, + (1 + depth - start_depth) * width + 2); } else - strfcpy(new_tree, arrow, 2 + depth * width); + mutt_str_strfcpy(new_tree, arrow, 2 + depth * width); tree->message->tree = new_tree; } } @@ -400,7 +400,7 @@ static void make_subject_list(struct ListHead *subjects, struct MuttThread *cur, struct ListNode *np; STAILQ_FOREACH(np, subjects, entries) { - rc = mutt_strcmp(env->real_subj, np->data); + rc = mutt_str_strcmp(env->real_subj, np->data); if (rc >= 0) break; } @@ -451,7 +451,7 @@ static struct MuttThread *find_subject(struct Context *ctx, struct MuttThread *c (last->message->received < tmp->message->received) : (last->message->date_sent < tmp->message->date_sent))) && tmp->message->env->real_subj && - (mutt_strcmp(np->data, tmp->message->env->real_subj) == 0)) + (mutt_str_strcmp(np->data, tmp->message->env->real_subj) == 0)) { last = tmp; /* best match so far */ } @@ -558,8 +558,8 @@ static void pseudo_threads(struct Context *ctx) * but only do this if they have the same real subject as the * parent, since otherwise they rightly belong to the message * we're attaching. */ - if (tmp == cur || (mutt_strcmp(tmp->message->env->real_subj, - parent->message->env->real_subj) == 0)) + if (tmp == cur || (mutt_str_strcmp(tmp->message->env->real_subj, + parent->message->env->real_subj) == 0)) { tmp->message->subject_changed = false; @@ -773,7 +773,7 @@ static void check_subjects(struct Context *ctx, int init) cur->subject_changed = true; else if (cur->env->real_subj && tmp->message->env->real_subj) cur->subject_changed = - (mutt_strcmp(cur->env->real_subj, tmp->message->env->real_subj) != 0) ? true : false; + (mutt_str_strcmp(cur->env->real_subj, tmp->message->env->real_subj) != 0) ? true : false; else cur->subject_changed = (cur->env->real_subj || tmp->message->env->real_subj) ? true : false; @@ -941,7 +941,7 @@ void mutt_sort_threads(struct Context *ctx, int init) ref = STAILQ_NEXT(ref, entries); else { - if (mutt_strcmp(ref->data, STAILQ_FIRST(&cur->env->references)->data) != 0) + if (mutt_str_strcmp(ref->data, STAILQ_FIRST(&cur->env->references)->data) != 0) ref = STAILQ_FIRST(&cur->env->references); else ref = STAILQ_NEXT(STAILQ_FIRST(&cur->env->references), entries); @@ -1418,7 +1418,7 @@ static void clean_references(struct MuttThread *brk, struct MuttThread *cur) for (ref = STAILQ_FIRST(&cur->message->env->references); p->message && ref; ref = STAILQ_NEXT(ref, entries)) { - if (mutt_strcasecmp(ref->data, p->message->env->message_id) == 0) + if (mutt_str_strcasecmp(ref->data, p->message->env->message_id) == 0) { done = true; break; @@ -1459,7 +1459,7 @@ static bool link_threads(struct Header *parent, struct Header *child, struct Con return false; mutt_break_thread(child); - mutt_list_insert_head(&child->env->in_reply_to, safe_strdup(parent->env->message_id)); + mutt_list_insert_head(&child->env->in_reply_to, mutt_str_strdup(parent->env->message_id)); mutt_set_flag(ctx, child, MUTT_TAG, 0); child->env->irt_changed = child->changed = true; diff --git a/url.c b/url.c index 6e2ad4ea6..bfd6ef877 100644 --- a/url.c +++ b/url.c @@ -86,7 +86,7 @@ enum UrlScheme url_check_scheme(const char *s) if ((size_t)(t - s) >= sizeof(sbuf) - 1) return U_UNKNOWN; - strfcpy(sbuf, s, t - s + 1); + mutt_str_strfcpy(sbuf, s, t - s + 1); for (t = sbuf; *t; t++) *t = tolower(*t); @@ -217,14 +217,14 @@ int url_parse(struct Url *u, char *src) { int num; *p++ = '\0'; - if (mutt_atoi(p, &num) < 0 || num < 0 || num > 0xffff) + if (mutt_str_atoi(p, &num) < 0 || num < 0 || num > 0xffff) goto err; u->port = (unsigned short) num; } else u->port = 0; - if (mutt_strlen(src) != 0) + if (mutt_str_strlen(src) != 0) { u->host = src; if (url_pct_decode(u->host) < 0) @@ -294,7 +294,7 @@ int url_tostring(struct Url *u, char *dest, size_t len, int flags) if (u->host) { if (!(flags & U_PATH)) - safe_strcat(dest, len, "//"); + mutt_str_strcat(dest, len, "//"); len -= (l = strlen(dest)); dest += l; @@ -331,7 +331,7 @@ int url_tostring(struct Url *u, char *dest, size_t len, int flags) } if (u->path) - safe_strcat(dest, len, u->path); + mutt_str_strcat(dest, len, u->path); return 0; } @@ -350,7 +350,7 @@ int url_parse_mailto(struct Envelope *e, char **body, const char *src) return -1; /* copy string for safe use of strtok() */ - tmp = safe_strdup(t + 1); + tmp = mutt_str_strdup(t + 1); if (!tmp) return -1; @@ -389,7 +389,7 @@ int url_parse_mailto(struct Envelope *e, char **body, const char *src) */ if (mutt_list_match(tag, &MailToAllow)) { - if (mutt_strcasecmp(tag, "body") == 0) + if (mutt_str_strcasecmp(tag, "body") == 0) { if (body) mutt_str_replace(body, value); @@ -397,11 +397,11 @@ int url_parse_mailto(struct Envelope *e, char **body, const char *src) else { char *scratch = NULL; - size_t taglen = mutt_strlen(tag); + size_t taglen = mutt_str_strlen(tag); safe_asprintf(&scratch, "%s: %s", tag, value); scratch[taglen] = 0; /* overwrite the colon as mutt_parse_rfc822_line expects */ - value = skip_email_wsp(&scratch[taglen + 1]); + value = mutt_str_skip_email_wsp(&scratch[taglen + 1]); mutt_parse_rfc822_line(e, NULL, scratch, value, 1, 0, 1); FREE(&scratch); } diff --git a/version.c b/version.c index e3a2f3044..163a4923d 100644 --- a/version.c +++ b/version.c @@ -467,14 +467,14 @@ bool feature_enabled(const char *name) return false; for (int i = 0; comp_opts_default[i].name; i++) { - if (mutt_strcmp(name, comp_opts_default[i].name) == 0) + if (mutt_str_strcmp(name, comp_opts_default[i].name) == 0) { return true; } } for (int i = 0; comp_opts[i].name; i++) { - if (mutt_strcmp(name, comp_opts[i].name) == 0) + if (mutt_str_strcmp(name, comp_opts[i].name) == 0) { return comp_opts[i].enabled; }