From 238b70e39b78f585c586bd51aef41988b3cc73d1 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 30 Oct 2006 23:55:24 +0100 Subject: [PATCH] exit strfcpy, only use m_strcpy. add m_strisempty that checks !s || !*s Signed-off-by: Pierre Habouzit --- account.c | 267 +++++++++++++++++++++++----------------------- alias.c | 24 ++--- attach.c | 30 +++--- browser.c | 58 +++++----- buffy.c | 6 +- charset.c | 10 +- color.c | 24 ++--- commands.c | 14 +-- complete.c | 52 ++++----- compose.c | 29 +++-- copy.c | 2 +- crypt-gpgme.c | 4 +- crypt.c | 2 +- curs_main.c | 8 +- dotlock.c | 20 ++-- edit.c | 6 +- getdomain.c | 2 +- handler.c | 2 +- hdrline.c | 18 ++-- headers.c | 4 +- hook.c | 18 ++-- imap/auth_cram.c | 4 +- imap/auth_sasl.c | 2 +- imap/browse.c | 12 +-- imap/command.c | 2 +- imap/imap.c | 16 +-- imap/util.c | 2 +- init.c | 47 ++++---- keymap.c | 18 ++-- lib-lib/str.h | 4 + lib/str.h | 1 - main.c | 8 +- menu.c | 2 +- mh.c | 22 ++-- mutt_ssl.c | 14 +-- mutt_ssl_gnutls.c | 32 +++--- muttlib.c | 50 ++++----- mx.c | 7 +- nntp/newsrc.c | 10 +- nntp/nntp.c | 10 +- pager.c | 8 +- parse.c | 4 +- pattern.c | 30 +++--- pgpkey.c | 2 +- pgppubring.c | 4 +- pop/pop.c | 10 +- pop/pop_auth.c | 2 +- pop/pop_lib.c | 18 ++-- postpone.c | 4 +- recvattach.c | 12 +-- recvcmd.c | 12 +-- remailer.c | 2 +- rfc1524.c | 14 +-- rfc2047.c | 2 +- rfc2231.c | 4 +- rfc822.c | 10 +- score.c | 4 +- send.c | 8 +- sendlib.c | 18 ++-- smime.c | 10 +- status.c | 16 +-- thread.c | 6 +- url.c | 4 +- 63 files changed, 530 insertions(+), 537 deletions(-) diff --git a/account.c b/account.c index 8d8a847..92cacbb 100644 --- a/account.c +++ b/account.c @@ -27,68 +27,67 @@ /* mutt_account_match: compare account info (host/port/user/login) */ int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * a2) { - const char* user = NONULL (Username); - const char* login = NONULL (Username); + const char* user = NONULL (Username); + const char* login = NONULL (Username); - if (a1->type != a2->type) - return 0; - if (ascii_strcasecmp (a1->host, a2->host)) - return 0; - if (a1->port != a2->port) - return 0; + if (a1->type != a2->type) + return 0; + if (ascii_strcasecmp (a1->host, a2->host)) + return 0; + if (a1->port != a2->port) + return 0; #ifdef USE_IMAP - if (a1->type == M_ACCT_TYPE_IMAP) { - if (ImapUser && (ImapUser[0] != '\0')) - user = ImapUser; - if (ImapLogin && (ImapLogin[0] != '\0')) - login = ImapLogin; - } + if (a1->type == M_ACCT_TYPE_IMAP) { + if (ImapUser && (ImapUser[0] != '\0')) + user = ImapUser; + if (ImapLogin && (ImapLogin[0] != '\0')) + login = ImapLogin; + } #endif #ifdef USE_POP - if (a1->type == M_ACCT_TYPE_POP && PopUser) - user = PopUser; + if (a1->type == M_ACCT_TYPE_POP && PopUser) + user = PopUser; #endif #ifdef USE_NNTP - if (a1->type == M_ACCT_TYPE_NNTP && NntpUser) - user = NntpUser; + if (a1->type == M_ACCT_TYPE_NNTP && NntpUser) + user = NntpUser; #endif - if (a1->flags & a2->flags & M_ACCT_USER) - return (!m_strcmp(a1->user, a2->user)); - if (a1->flags & M_ACCT_USER) - return (!m_strcmp(a1->user, user)); - if (a2->flags & M_ACCT_USER) - return (!m_strcmp(a2->user, user)); + if (a1->flags & a2->flags & M_ACCT_USER) + return (!m_strcmp(a1->user, a2->user)); + if (a1->flags & M_ACCT_USER) + return (!m_strcmp(a1->user, user)); + if (a2->flags & M_ACCT_USER) + return (!m_strcmp(a2->user, user)); - return 1; + return 1; } /* mutt_account_fromurl: fill account with information from url. */ -int mutt_account_fromurl (ACCOUNT * account, ciss_url_t * url) +int mutt_account_fromurl(ACCOUNT *account, ciss_url_t *url) { - /* must be present */ - if (url->host) - strfcpy (account->host, url->host, sizeof (account->host)); - else - return -1; - - if (url->user) { - strfcpy (account->user, url->user, sizeof (account->user)); - account->flags |= M_ACCT_USER; - } - if (url->pass) { - strfcpy (account->pass, url->pass, sizeof (account->pass)); - account->flags |= M_ACCT_PASS; - } - if (url->port) { - account->port = url->port; - account->flags |= M_ACCT_PORT; - } + /* must be present */ + if (!url->host) + return -1; + m_strcpy(account->host, sizeof(account->host), url->host); + + if (url->user) { + m_strcpy(account->user, sizeof(account->user), url->user); + account->flags |= M_ACCT_USER; + } + if (url->pass) { + m_strcpy(account->pass, sizeof(account->pass), url->pass); + account->flags |= M_ACCT_PASS; + } + if (url->port) { + account->port = url->port; + account->flags |= M_ACCT_PORT; + } - return 0; + return 0; } /* mutt_account_tourl: fill URL with info from account. The URL information @@ -97,141 +96,141 @@ int mutt_account_fromurl (ACCOUNT * account, ciss_url_t * url) * a while). */ void mutt_account_tourl (ACCOUNT * account, ciss_url_t * url) { - url->scheme = U_UNKNOWN; - url->user = NULL; - url->pass = NULL; - url->port = 0; + url->scheme = U_UNKNOWN; + url->user = NULL; + url->pass = NULL; + url->port = 0; #ifdef USE_IMAP - if (account->type == M_ACCT_TYPE_IMAP) { - if (account->flags & M_ACCT_SSL) - url->scheme = U_IMAPS; - else - url->scheme = U_IMAP; - } + if (account->type == M_ACCT_TYPE_IMAP) { + if (account->flags & M_ACCT_SSL) + url->scheme = U_IMAPS; + else + url->scheme = U_IMAP; + } #endif #ifdef USE_POP - if (account->type == M_ACCT_TYPE_POP) { - if (account->flags & M_ACCT_SSL) - url->scheme = U_POPS; - else - url->scheme = U_POP; - } + if (account->type == M_ACCT_TYPE_POP) { + if (account->flags & M_ACCT_SSL) + url->scheme = U_POPS; + else + url->scheme = U_POP; + } #endif #ifdef USE_NNTP - if (account->type == M_ACCT_TYPE_NNTP) { - if (account->flags & M_ACCT_SSL) - url->scheme = U_NNTPS; - else - url->scheme = U_NNTP; - } + if (account->type == M_ACCT_TYPE_NNTP) { + if (account->flags & M_ACCT_SSL) + url->scheme = U_NNTPS; + else + url->scheme = U_NNTP; + } #endif - url->host = account->host; - if (account->flags & M_ACCT_PORT) - url->port = account->port; - if (account->flags & M_ACCT_USER) - url->user = account->user; - if (account->flags & M_ACCT_PASS) - url->pass = account->pass; + url->host = account->host; + if (account->flags & M_ACCT_PORT) + url->port = account->port; + if (account->flags & M_ACCT_USER) + url->user = account->user; + if (account->flags & M_ACCT_PASS) + url->pass = account->pass; } /* mutt_account_getuser: retrieve username into ACCOUNT, if necessary */ int mutt_account_getuser (ACCOUNT * account) { - char prompt[SHORT_STRING]; + char prompt[SHORT_STRING]; - /* already set */ - if (account->flags & M_ACCT_USER) - return 0; + /* already set */ + if (account->flags & M_ACCT_USER) + return 0; #ifdef USE_IMAP - else if ((account->type == M_ACCT_TYPE_IMAP) && m_strlen(ImapUser)) - strfcpy (account->user, ImapUser, sizeof (account->user)); + else if ((account->type == M_ACCT_TYPE_IMAP) && !m_strisempty(ImapUser)) + m_strcpy(account->user, sizeof(account->user), ImapUser); #endif #ifdef USE_POP - else if ((account->type == M_ACCT_TYPE_POP) && m_strlen(PopUser)) - strfcpy (account->user, PopUser, sizeof (account->user)); + else if ((account->type == M_ACCT_TYPE_POP) && !m_strisempty(PopUser)) + m_strcpy(account->user, sizeof(account->user), PopUser); #endif #ifdef USE_NNTP - else if ((account->type == M_ACCT_TYPE_NNTP) && m_strlen(NntpUser)) - strfcpy (account->user, NntpUser, sizeof (account->user)); + else if ((account->type == M_ACCT_TYPE_NNTP) && !m_strisempty(NntpUser)) + m_strcpy(account->user, sizeof(account->user), NntpUser); #endif - /* prompt (defaults to unix username), copy into account->user */ - else { - snprintf (prompt, sizeof (prompt), _("Username at %s: "), account->host); - strfcpy (account->user, NONULL(Username), sizeof (account->user)); - if (mutt_get_field_unbuffered (prompt, account->user, - sizeof (account->user), 0)) - return -1; - } - - account->flags |= M_ACCT_USER; - - return 0; + /* prompt (defaults to unix username), copy into account->user */ + else { + snprintf(prompt, sizeof(prompt), _("Username at %s: "), account->host); + m_strcpy(account->user, sizeof(account->user), NONULL(Username)); + if (mutt_get_field_unbuffered(prompt, account->user, + sizeof(account->user), 0)) + return -1; + } + + account->flags |= M_ACCT_USER; + + return 0; } int mutt_account_getlogin (ACCOUNT* account) { - /* already set */ - if (account->flags & M_ACCT_LOGIN) - return 0; + /* already set */ + if (account->flags & M_ACCT_LOGIN) + return 0; #ifdef USE_IMAP - else if (account->type == M_ACCT_TYPE_IMAP) - { - if (ImapLogin && (ImapLogin[0] != '\0')) { - strfcpy (account->login, ImapLogin, sizeof (account->login)); - account->flags |= M_ACCT_LOGIN; + else if (account->type == M_ACCT_TYPE_IMAP) + { + if (!m_strisempty(ImapLogin)) { + m_strcpy(account->login, sizeof(account->login), ImapLogin); + account->flags |= M_ACCT_LOGIN; + } } - } #endif - if (!(account->flags & M_ACCT_LOGIN)) { - mutt_account_getuser (account); - strfcpy (account->login, account->user, sizeof (account->login)); - } + if (!(account->flags & M_ACCT_LOGIN)) { + mutt_account_getuser (account); + m_strcpy(account->login, sizeof(account->login), account->user); + } - account->flags |= M_ACCT_LOGIN; + account->flags |= M_ACCT_LOGIN; - return 0; + return 0; } /* mutt_account_getpass: fetch password into ACCOUNT, if neccessary */ int mutt_account_getpass (ACCOUNT * account) { - char prompt[SHORT_STRING]; + char prompt[SHORT_STRING]; - if (account->flags & M_ACCT_PASS) - return 0; + if (account->flags & M_ACCT_PASS) + return 0; #ifdef USE_IMAP - else if ((account->type == M_ACCT_TYPE_IMAP) && m_strlen(ImapPass)) - strfcpy (account->pass, ImapPass, sizeof (account->pass)); + else if ((account->type == M_ACCT_TYPE_IMAP) && !m_strisempty(ImapPass)) + m_strcpy(account->pass, sizeof(account->pass), ImapPass); #endif #ifdef USE_POP - else if ((account->type == M_ACCT_TYPE_POP) && m_strlen(PopPass)) - strfcpy (account->pass, PopPass, sizeof (account->pass)); + else if ((account->type == M_ACCT_TYPE_POP) && !m_strisempty(PopPass)) + m_strcpy(account->pass, sizeof(account->pass), PopPass); #endif #ifdef USE_NNTP - else if ((account->type == M_ACCT_TYPE_NNTP) && m_strlen(NntpPass)) - strfcpy (account->pass, NntpPass, sizeof (account->pass)); + else if ((account->type == M_ACCT_TYPE_NNTP) && !m_strisempty(NntpPass)) + m_strcpy(account->pass, sizeof(account->pass), NntpPass); #endif - else { - snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "), - account->flags & M_ACCT_LOGIN ? account->login : account->user, - account->host); - account->pass[0] = '\0'; - if (mutt_get_field_unbuffered (prompt, account->pass, - sizeof (account->pass), M_PASS)) - return -1; - } - - account->flags |= M_ACCT_PASS; - - return 0; + else { + snprintf(prompt, sizeof(prompt), _("Password for %s@%s: "), + account->flags & M_ACCT_LOGIN ? account->login : account->user, + account->host); + account->pass[0] = '\0'; + if (mutt_get_field_unbuffered(prompt, account->pass, + sizeof(account->pass), M_PASS)) + return -1; + } + + account->flags |= M_ACCT_PASS; + + return 0; } void mutt_account_unsetpass (ACCOUNT * account) { - account->flags &= !M_ACCT_PASS; + account->flags &= !M_ACCT_PASS; } diff --git a/alias.c b/alias.c index efed62d..b43689b 100644 --- a/alias.c +++ b/alias.c @@ -223,7 +223,7 @@ void mutt_create_alias (ENVELOPE * cur, ADDRESS * iadr) } if (adr && adr->mailbox) { - strfcpy (buf, adr->mailbox, sizeof (buf)); + m_strcpy(buf, sizeof(buf), adr->mailbox); if ((pc = strchr (buf, '@'))) *pc = 0; } @@ -249,7 +249,7 @@ retry_name: switch (mutt_yesorno (_("Warning: This alias name may not work. Fix it?"), M_YES)) { case M_YES: - strfcpy (buf, fixed, sizeof (buf)); + m_strcpy(buf, sizeof(buf), fixed); goto retry_name; case -1: return; @@ -263,7 +263,7 @@ retry_name: mutt_addrlist_to_local (adr); if (adr) - strfcpy (buf, adr->mailbox, sizeof (buf)); + m_strcpy(buf, sizeof(buf), adr->mailbox); else buf[0] = 0; @@ -285,8 +285,8 @@ retry_name: } while (new->addr == NULL); - if (adr && adr->personal && !mutt_is_mail_list (adr)) - strfcpy (buf, adr->personal, sizeof (buf)); + if (adr && adr->personal && !mutt_is_mail_list(adr)) + m_strcpy(buf, sizeof(buf), adr->personal); else buf[0] = 0; @@ -312,15 +312,15 @@ retry_name: else Aliases = new; - strfcpy (buf, NONULL (AliasFile), sizeof (buf)); + m_strcpy(buf, sizeof(buf), NONULL(AliasFile)); if (mutt_get_field (_("Save to file: "), buf, sizeof (buf), M_FILE) != 0) return; mutt_expand_path (buf, sizeof (buf)); if ((rc = safe_fopen (buf, "a"))) { if (mutt_check_alias_name (new->name, NULL)) - mutt_quote_filename (buf, sizeof (buf), new->name); + mutt_quote_filename(buf, sizeof(buf), new->name); else - strfcpy (buf, new->name, sizeof (buf)); + m_strcpy(buf, sizeof(buf), new->name); fprintf (rc, "alias %s ", buf); buf[0] = 0; rfc822_write_address (buf, sizeof (buf), new->addr, 0); @@ -409,8 +409,8 @@ int mutt_alias_complete (char *s, size_t buflen) while (a) { if (a->name && strstr (a->name, s) == a->name) { if (!bestname[0]) /* init */ - strfcpy (bestname, a->name, - min (m_strlen(a->name) + 1, sizeof (bestname))); + m_strcpy(bestname, MIN(m_strlen(a->name) + 1, sizeof(bestname)), + a->name); else { for (i = 0; a->name[i] && a->name[i] == bestname[i]; i++); bestname[i] = 0; @@ -422,7 +422,7 @@ int mutt_alias_complete (char *s, size_t buflen) if (bestname[0] != 0) { if (m_strcmp(bestname, s) != 0) { /* we are adding something to the completion */ - strfcpy (s, bestname, m_strlen(bestname) + 1); + m_strcpy(s, m_strlen(bestname) + 1, bestname); return 1; } @@ -448,7 +448,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); + m_strcpy(s, buflen, bestname); /* free the alias list */ while (a_list) { diff --git a/attach.c b/attach.c index 9e3bbb9..4afb1fb 100644 --- a/attach.c +++ b/attach.c @@ -98,9 +98,9 @@ int mutt_compose_attachment (BODY * a) if (entry->composecommand || entry->composetypecommand) { if (entry->composetypecommand) - strfcpy (command, entry->composetypecommand, sizeof (command)); + m_strcpy(command, sizeof(command), entry->composetypecommand); else - strfcpy (command, entry->composecommand, sizeof (command)); + m_strcpy(command, sizeof(command), entry->composecommand); if (rfc1524_expand_filename (entry->nametemplate, a->filename, newfile, sizeof (newfile))) { debug_print (1, ("oldfile: %s\t newfile: %s\n", a->filename, newfile)); @@ -113,7 +113,7 @@ int mutt_compose_attachment (BODY * a) unlink_newfile = 1; } else - strfcpy (newfile, a->filename, sizeof (newfile)); + m_strcpy(newfile, sizeof(newfile), a->filename); if (rfc1524_expand_command (a, newfile, type, command, sizeof (command))) { @@ -221,7 +221,7 @@ int mutt_edit_attachment (BODY * a) if (rfc1524_mailcap_lookup (a, type, entry, M_EDIT)) { if (entry->editcommand) { - strfcpy (command, entry->editcommand, sizeof (command)); + m_strcpy(command, sizeof(command), entry->editcommand); if (rfc1524_expand_filename (entry->nametemplate, a->filename, newfile, sizeof (newfile))) { debug_print (1, ("oldfile: %s\t newfile: %s\n", a->filename, newfile)); @@ -234,7 +234,7 @@ int mutt_edit_attachment (BODY * a) unlink_newfile = 1; } else - strfcpy (newfile, a->filename, sizeof (newfile)); + m_strcpy(newfile, sizeof(newfile), a->filename); if (rfc1524_expand_command (a, newfile, type, command, sizeof (command))) { @@ -283,7 +283,7 @@ static int is_mmnoask (const char *buf) if (m_strcmp(p, "1") == 0) return (1); - strfcpy (tmp, p, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), p); p = tmp; while ((p = strtok (p, ",")) != NULL) { @@ -425,7 +425,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, goto return_error; } - strfcpy (command, entry->command, sizeof (command)); + m_strcpy(command, sizeof(command), entry->command); if (fp) { fname = m_strdup(a->filename); @@ -441,7 +441,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, if (safe_symlink (a->filename, tempfile) == -1) { if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) == M_YES) - strfcpy (tempfile, a->filename, sizeof (tempfile)); + m_strcpy(tempfile, sizeof(tempfile), a->filename); else goto return_error; } @@ -450,7 +450,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, } } else if (fp == NULL) /* send case */ - strfcpy (tempfile, a->filename, sizeof (tempfile)); + m_strcpy(tempfile, sizeof(tempfile), a->filename); if (fp) { /* recv case: we need to save the attachment to a file */ @@ -467,7 +467,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, if (use_pager) { if (fp && !use_mailcap && a->filename) { /* recv case */ - strfcpy (pagerfile, a->filename, sizeof (pagerfile)); + m_strcpy(pagerfile, sizeof(pagerfile), a->filename); mutt_adv_mktemp (NULL, pagerfile, sizeof (pagerfile)); } else @@ -555,7 +555,7 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, } if (a->description) - strfcpy (descrip, a->description, sizeof (descrip)); + m_strcpy(descrip, sizeof(descrip), a->description); else if (a->filename) snprintf (descrip, sizeof (descrip), "---Attachment: %s : %s", a->filename, type); @@ -907,7 +907,7 @@ int mutt_print_attachment (FILE * fp, BODY * a) rfc1524_free_entry (&entry); return 0; } - strfcpy (newfile, a->filename, sizeof (newfile)); + m_strcpy(newfile, sizeof(newfile), a->filename); } else unlink_newfile = 1; @@ -918,9 +918,9 @@ int mutt_print_attachment (FILE * fp, BODY * a) if (fp) mutt_save_attachment (fp, a, newfile, 0, NULL); - strfcpy (command, entry->printcommand, sizeof (command)); - piped = - rfc1524_expand_command (a, newfile, type, command, sizeof (command)); + m_strcpy(command, sizeof(command), entry->printcommand); + piped = rfc1524_expand_command(a, newfile, type, command, + sizeof(command)); mutt_endwin (NULL); diff --git a/browser.c b/browser.c index 763a5be..c46c89e 100644 --- a/browser.c +++ b/browser.c @@ -623,7 +623,7 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) (!S_ISLNK (s.st_mode))) continue; - strfcpy (buffer, NONULL (tmp->path), sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), NONULL(tmp->path)); mutt_pretty_mailbox (buffer); add_folder (menu, state, buffer, &s, NULL, tmp->new); @@ -688,9 +688,9 @@ static void init_menu (struct browser_state *state, MUTTMENU * menu, else #endif if (buffy) - snprintf (title, titlelen, _("Mailboxes [%d]"), buffy_check (0)); + snprintf(title, titlelen, _("Mailboxes [%d]"), buffy_check(0)); else { - strfcpy (path, LastDir, sizeof (path)); + m_strcpy(path, sizeof(path), LastDir); mutt_pretty_mailbox (path); #ifdef USE_IMAP if (state->imap_browse && option (OPTIMAPLSUB)) @@ -742,12 +742,12 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, p_clear(&state, 1); if (!folder) - strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup)); + m_strcpy(LastDirBackup, sizeof(LastDirBackup), LastDir); #ifdef USE_NNTP if (option (OPTNEWS)) { if (*f) - strfcpy (prefix, f, sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), f); else { LIST *list; @@ -772,7 +772,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; if (!imap_browse (f, &state)) - strfcpy (LastDir, state.folder, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), state.folder); } else { #endif @@ -796,9 +796,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } if (i <= 0 && f[0] != '/') - strfcpy (prefix, f, sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), f); else - strfcpy (prefix, f + i + 1, sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), f + i + 1); killPrefix = 1; #ifdef USE_IMAP } @@ -808,7 +808,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (!folder) getcwd (LastDir, sizeof (LastDir)); else if (!LastDir[0]) - strfcpy (LastDir, NONULL (Maildir), sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), NONULL(Maildir)); #ifdef USE_IMAP if (!buffy && imap_is_magic (LastDir, NULL) == M_IMAP) { @@ -869,12 +869,12 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, ) { /* make sure this isn't a MH or maildir mailbox */ if (buffy) { - strfcpy (buf, state.entry[menu->current].name, sizeof (buf)); + m_strcpy(buf, sizeof(buf), state.entry[menu->current].name); mutt_expand_path (buf, sizeof (buf)); } #ifdef USE_IMAP else if (state.imap_browse) { - strfcpy (buf, state.entry[menu->current].name, sizeof (buf)); + m_strcpy(buf, sizeof(buf), state.entry[menu->current].name); } #endif else @@ -889,7 +889,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, char OldLastDir[_POSIX_PATH_MAX]; /* save the old directory */ - strfcpy (OldLastDir, LastDir, sizeof (OldLastDir)); + m_strcpy(OldLastDir, sizeof(OldLastDir), LastDir); if (m_strcmp(state.entry[menu->current].name, "..") == 0) { if (m_strcmp("..", LastDir + m_strlen(LastDir) - 2) == 0) @@ -908,8 +908,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } } else if (buffy) { - strfcpy (LastDir, state.entry[menu->current].name, - sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), + state.entry[menu->current].name); mutt_expand_path (LastDir, sizeof (LastDir)); } #ifdef USE_IMAP @@ -917,8 +917,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int n; ciss_url_t url; - strfcpy (LastDir, state.entry[menu->current].name, - sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), + state.entry[menu->current].name); /* tack on delimiter here */ n = m_strlen(LastDir) + 1; @@ -937,7 +937,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, mutt_concat_path(tmp, sizeof(tmp), LastDir, state.entry[menu->current].name); - strfcpy (LastDir, tmp, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), tmp); } destroy_state (&state); @@ -958,9 +958,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, #endif if (examine_directory (menu, &state, LastDir, prefix) == -1) { /* try to restore the old values */ - strfcpy (LastDir, OldLastDir, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), OldLastDir); if (examine_directory (menu, &state, LastDir, prefix) == -1) { - strfcpy (LastDir, NONULL (Homedir), sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), NONULL(Homedir)); goto bail; } } @@ -977,12 +977,12 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (buffy) #endif { - strfcpy (f, state.entry[menu->current].name, flen); + m_strcpy(f, flen, state.entry[menu->current].name); mutt_expand_path (f, flen); } #ifdef USE_IMAP else if (state.imap_browse) - strfcpy (f, state.entry[menu->current].name, flen); + m_strcpy(f, flen, state.entry[menu->current].name); #endif else mutt_concat_path(f, flen, LastDir, state.entry[menu->current].name); @@ -1122,7 +1122,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, break; #endif - strfcpy (buf, LastDir, sizeof (buf)); + m_strcpy(buf, sizeof(buf), LastDir); #ifdef USE_IMAP if (!state.imap_browse) #endif @@ -1140,7 +1140,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, mutt_expand_path (buf, sizeof (buf)); #ifdef USE_IMAP if (imap_is_magic (buf, NULL) == M_IMAP) { - strfcpy (LastDir, buf, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), buf); destroy_state (&state); init_state (&state, NULL); state.imap_browse = 1; @@ -1157,7 +1157,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (S_ISDIR (st.st_mode)) { destroy_state (&state); if (examine_directory (menu, &state, buf, prefix) == 0) - strfcpy (LastDir, buf, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), buf); else { mutt_error _("Error scanning directory."); @@ -1181,7 +1181,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, case OP_ENTER_MASK: - strfcpy (buf, NONULL (Mask.pattern), sizeof (buf)); + m_strcpy(buf, sizeof(buf), NONULL(Mask.pattern)); if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) { regex_t *rx = p_new(regex_t, 1); char *s = buf; @@ -1190,7 +1190,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, buffy = 0; /* assume that the user wants to see everything */ if (!buf[0]) - strfcpy (buf, ".", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "."); SKIPWS (s); if (*s == '!') { s++; @@ -1322,7 +1322,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, snprintf (buf, sizeof (buf), "%s/", LastDir); if (mutt_get_field (_("New file name: "), buf, sizeof (buf), M_FILE) == 0) { - strfcpy (f, buf, flen); + m_strcpy(f, flen, buf); destroy_state (&state); mutt_menuDestroy (&menu); goto bail; @@ -1339,7 +1339,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, #ifdef USE_IMAP if (state.entry[menu->current].selectable) { - strfcpy (f, state.entry[menu->current].name, flen); + m_strcpy(f, flen, state.entry[menu->current].name); destroy_state (&state); mutt_menuDestroy (&menu); goto bail; @@ -1544,6 +1544,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, bail: if (!folder) - strfcpy (LastDir, LastDirBackup, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), LastDirBackup); } diff --git a/buffy.c b/buffy.c index 68b9165..96ae2fa 100644 --- a/buffy.c +++ b/buffy.c @@ -198,7 +198,7 @@ int buffy_parse_mailboxes (BUFFER * path, BUFFER * s, unsigned long data, while (MoreArgs (s)) { mutt_extract_token (path, s, 0); - strfcpy (buf, path->data, sizeof (buf)); + m_strcpy(buf, sizeof(buf), path->data); if (data == M_UNMAILBOXES && str_eq (buf, "*")) { list_del (&Incoming, (list_del_t*) buffy_free); @@ -519,7 +519,7 @@ int buffy_list (void) if (tmp->new <= 0 || (have_unnotified && tmp->notified)) continue; - strfcpy (path, tmp->path, sizeof (path)); + m_strcpy(path, sizeof(path), tmp->path); mutt_pretty_mailbox (path); if (!first && pos + m_strlen(path) >= COLS - 7) @@ -600,7 +600,7 @@ void buffy_next (char *s, size_t slen) * reported new mail */ buffy_check (0); } else { - strfcpy (s, ((BUFFY*) Incoming->data[c])->path, slen); + m_strcpy(s, slen, ((BUFFY*)Incoming->data[c])->path); mutt_pretty_mailbox (s); } } diff --git a/charset.c b/charset.c index b50ca2c..761be88 100644 --- a/charset.c +++ b/charset.c @@ -193,7 +193,7 @@ void mutt_set_langinfo_charset (void) char buff[LONG_STRING]; char buff2[LONG_STRING]; - strfcpy (buff, nl_langinfo (CODESET), sizeof (buff)); + m_strcpy(buff, sizeof(buff), nl_langinfo(CODESET)); mutt_canonical_charset (buff2, sizeof (buff2), buff); /* finally, set $charset */ @@ -226,16 +226,16 @@ void mutt_canonical_charset (char *dest, size_t dlen, const char *name) else if (!ascii_strncasecmp (name, "iso8859-", 8)) snprintf (scratch, sizeof (scratch), "iso_8859-%s", name + 8); else - strfcpy (scratch, NONULL (name), sizeof (scratch)); + m_strcpy(scratch, sizeof(scratch), NONULL(name)); for (i = 0; PreferredMIMENames[i].key; i++) if (!ascii_strcasecmp (scratch, PreferredMIMENames[i].key) || !m_strcasecmp(scratch, PreferredMIMENames[i].key)) { - strfcpy (dest, PreferredMIMENames[i].pref, dlen); + m_strcpy(dest, dlen, PreferredMIMENames[i].pref); return; } - strfcpy (dest, scratch, dlen); + m_strcpy(dest, dlen, scratch); /* for cosmetics' sake, transform to lowercase. */ for (p = dest; *p; p++) @@ -546,7 +546,7 @@ const char *mutt_get_first_charset (const char *charset) return "us-ascii"; if (!(c1 = strchr (c, ':'))) return ((char*) charset); - strfcpy (fcharset, c, c1 - c + 1); + m_strcpy(fcharset, c1 - c + 1, c); return fcharset; } diff --git a/color.c b/color.c index 1e81ecb..a28c513 100644 --- a/color.c +++ b/color.c @@ -162,21 +162,21 @@ static char *get_color_name (char *dest, size_t destlen, int val) switch (val) { case COLOR_YELLOW: - strfcpy (dest, missing[0], destlen); + m_strcpy(dest, destlen, missing[0]); return dest; case COLOR_WHITE: - strfcpy (dest, missing[1], destlen); + m_strcpy(dest, destlen, missing[1]); return dest; case COLOR_DEFAULT: - strfcpy (dest, missing[2], destlen); + m_strcpy(dest, destlen, missing[2]); return dest; } for (i = 0; Colors[i].name; i++) { if (Colors[i].value == val) { - strfcpy (dest, Colors[i].name, destlen); + m_strcpy(dest, destlen, Colors[i].name); return dest; } } @@ -490,7 +490,7 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive, if (is_index) { int i; - strfcpy (buf, NONULL (s), sizeof (buf)); + m_strcpy(buf, sizeof(buf), NONULL(s)); mutt_check_simple (buf, sizeof (buf), NONULL (SimpleSearch)); if ((tmp->color_pattern = mutt_pattern_comp (buf, M_FULL_MSG, err)) == NULL) { @@ -532,7 +532,7 @@ parse_object (BUFFER * buf, BUFFER * s, int *o, int *ql, BUFFER * err) char *eptr; if (!MoreArgs (s)) { - strfcpy (err->data, _("Missing arguments."), err->dsize); + m_strcpy(err->data, err->dsize, _("Missing arguments.")); return -1; } @@ -568,7 +568,7 @@ parse_color_pair (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr, BUFFER * err) { if (!MoreArgs (s)) { - strfcpy (err->data, _("color: too few arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("color: too few arguments")); return (-1); } @@ -578,7 +578,7 @@ parse_color_pair (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr, return (-1); if (!MoreArgs (s)) { - strfcpy (err->data, _("color: too few arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("color: too few arguments")); return (-1); } @@ -603,7 +603,7 @@ parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr, *bg = -1; if (!MoreArgs (s)) { - strfcpy (err->data, _("mono: too few arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("mono: too few arguments")); return (-1); } @@ -661,7 +661,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX) { if (!MoreArgs (s)) { - strfcpy (err->data, _("too few arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("too few arguments")); return (-1); } @@ -669,7 +669,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, } if (MoreArgs (s)) { - strfcpy (err->data, _("too many arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("too many arguments")); return (-1); } @@ -685,7 +685,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, /* delay use_default_colors() until needed, since it initializes things */ && (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT) && use_default_colors () != OK) { - strfcpy (err->data, _("default colors not supported"), err->dsize); + m_strcpy(err->data, err->dsize, _("default colors not supported")); return (-1); } # endif /* HAVE_USE_DEFAULT_COLORS */ diff --git a/commands.c b/commands.c index aae6e61..3a53ac7 100644 --- a/commands.c +++ b/commands.c @@ -250,9 +250,9 @@ void ci_bounce_message (HEADER * h, int *redraw) int rc; if (h) - strfcpy (prompt, _("Bounce message to: "), sizeof (prompt)); + m_strcpy(prompt, sizeof(prompt), _("Bounce message to: ")); else - strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt)); + m_strcpy(prompt, sizeof(prompt), _("Bounce tagged messages to: ")); rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS); @@ -555,7 +555,7 @@ void mutt_shell_escape (void) buf[0] = 0; if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) { if (!buf[0] && Shell) - strfcpy (buf, Shell, sizeof (buf)); + m_strcpy(buf, sizeof(buf), Shell); if (buf[0]) { CLEARLINE (LINES - 1); mutt_endwin (NULL); @@ -750,9 +750,9 @@ int mutt_save_message (HEADER * h, int delete, * Leitner */ if (m_strcmp(buf, ".") == 0) - strfcpy (buf, LastSaveFolder, sizeof (buf)); + m_strcpy(buf, sizeof(buf), LastSaveFolder); else - strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder)); + m_strcpy(LastSaveFolder, sizeof(LastSaveFolder), buf); mutt_expand_path (buf, sizeof (buf)); @@ -850,10 +850,10 @@ void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp) short type_changed = 0; cp = mutt_get_parameter ("charset", b->parameter); - strfcpy (charset, NONULL (cp), sizeof (charset)); + m_strcpy(charset, sizeof(charset), NONULL(cp)); snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype); - strfcpy (obuf, buf, sizeof (obuf)); + m_strcpy(obuf, sizeof(obuf), buf); if (b->parameter) { size_t l; diff --git a/complete.c b/complete.c index 679a839..bd2bb05 100644 --- a/complete.c +++ b/complete.c @@ -55,7 +55,7 @@ int mutt_complete (char *s, size_t slen) if (option (OPTNEWS)) { LIST *l = CurrentNewsSrv->list; - strfcpy (filepart, s, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), s); /* * special case to handle when there is no filepart yet. @@ -66,7 +66,7 @@ int mutt_complete (char *s, size_t slen) NNTP_DATA *data = (NNTP_DATA *) l->data; if (data && data->subscribed) { - strfcpy (filepart, data->group, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), data->group); init++; l = l->next; break; @@ -89,7 +89,7 @@ int mutt_complete (char *s, size_t slen) filepart[i] = 0; } else { - strfcpy (filepart, data->group, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), data->group); init = 1; } } @@ -108,7 +108,7 @@ int mutt_complete (char *s, size_t slen) mutt_concat_path(imap_path, sizeof(imap_path), q, s + 1); } else - strfcpy (imap_path, s, sizeof (imap_path)); + m_strcpy(imap_path, sizeof(imap_path), s); if (mx_get_magic (imap_path) == M_IMAP) return imap_complete (s, slen, imap_path); @@ -118,30 +118,30 @@ int mutt_complete (char *s, size_t slen) dirpart[0] = *s; dirpart[1] = 0; if (*s == '!') - strfcpy (exp_dirpart, NONULL (Spoolfile), sizeof (exp_dirpart)); + m_strcpy(exp_dirpart, sizeof(exp_dirpart), NONULL(Spoolfile)); else - strfcpy (exp_dirpart, NONULL (Maildir), sizeof (exp_dirpart)); + m_strcpy(exp_dirpart, sizeof(exp_dirpart), NONULL(Maildir)); if ((p = strrchr (s, '/'))) { char buf[_POSIX_PATH_MAX]; *p++ = 0; mutt_concat_path(buf, sizeof(buf), exp_dirpart, s + 1); - strfcpy (exp_dirpart, buf, sizeof (exp_dirpart)); + m_strcpy(exp_dirpart, sizeof(exp_dirpart), buf); snprintf (buf, sizeof (buf), "%s%s/", dirpart, s + 1); - strfcpy (dirpart, buf, sizeof (dirpart)); - strfcpy (filepart, p, sizeof (filepart)); + m_strcpy(dirpart, sizeof(dirpart), buf); + m_strcpy(filepart, sizeof(filepart), p); } else - strfcpy (filepart, s + 1, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), s + 1); dirp = opendir (exp_dirpart); } else { if ((p = strrchr (s, '/'))) { if (p == s) { /* absolute path */ p = s + 1; - strfcpy (dirpart, "/", sizeof (dirpart)); + m_strcpy(dirpart, sizeof(dirpart), "/"); exp_dirpart[0] = 0; - strfcpy (filepart, p, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), p); dirp = opendir (dirpart); } else { @@ -150,8 +150,8 @@ int mutt_complete (char *s, size_t slen) memcpy(dirpart, s, len); dirpart[len] = 0; p++; - strfcpy (filepart, p, sizeof (filepart)); - strfcpy (exp_dirpart, dirpart, sizeof (exp_dirpart)); + m_strcpy(filepart, sizeof(filepart), p); + m_strcpy(exp_dirpart, sizeof(exp_dirpart), dirpart); mutt_expand_path (exp_dirpart, sizeof (exp_dirpart)); dirp = opendir (exp_dirpart); } @@ -159,7 +159,7 @@ int mutt_complete (char *s, size_t slen) else { /* no directory name, so assume current directory. */ dirpart[0] = 0; - strfcpy (filepart, s, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), s); dirp = opendir ("."); } } @@ -177,7 +177,7 @@ int mutt_complete (char *s, size_t slen) while ((de = readdir (dirp)) != NULL) { if (m_strcmp(".", de->d_name) != 0 && m_strcmp("..", de->d_name) != 0) { - strfcpy (filepart, de->d_name, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), de->d_name); init++; break; } @@ -199,19 +199,19 @@ int mutt_complete (char *s, size_t slen) char buf[_POSIX_PATH_MAX]; struct stat st; - strfcpy (filepart, de->d_name, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), de->d_name); /* check to see if it is a directory */ if (dirpart[0]) { - strfcpy (buf, exp_dirpart, sizeof (buf)); - strfcpy (buf + m_strlen(buf), "/", sizeof (buf) - m_strlen(buf)); + m_strcpy(buf, sizeof(buf), exp_dirpart); + m_strcpy(buf + m_strlen(buf), sizeof(buf) - m_strlen(buf), "/"); } else buf[0] = 0; - strfcpy (buf + m_strlen(buf), filepart, sizeof (buf) - m_strlen(buf)); + m_strcpy(buf + m_strlen(buf), sizeof(buf) - m_strlen(buf), filepart); if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR)) - strfcpy (filepart + m_strlen(filepart), "/", - sizeof (filepart) - m_strlen(filepart)); + m_strcpy(filepart + m_strlen(filepart), + sizeof(filepart) - m_strlen(filepart), "/"); init = 1; } } @@ -219,14 +219,14 @@ int mutt_complete (char *s, size_t slen) closedir (dirp); if (dirpart[0]) { - strfcpy (s, dirpart, slen); + m_strcpy(s, slen, dirpart); if (m_strcmp("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') - strfcpy (s + m_strlen(s), "/", slen - m_strlen(s)); - strfcpy (s + m_strlen(s), filepart, slen - m_strlen(s)); + m_strcpy(s + m_strlen(s), slen - m_strlen(s), "/"); + m_strcpy(s + m_strlen(s), slen - m_strlen(s), filepart); } else - strfcpy (s, filepart, slen); + m_strcpy(s, slen, filepart); return (init ? 0 : -1); } diff --git a/compose.c b/compose.c index a0eb9ac..6ecac7f 100644 --- a/compose.c +++ b/compose.c @@ -243,7 +243,7 @@ static int check_attachments (ATTACHPTR ** idx, short idxlen) char pretty[_POSIX_PATH_MAX], msg[_POSIX_PATH_MAX + SHORT_STRING]; for (i = 0; i < idxlen; i++) { - strfcpy (pretty, idx[i]->content->filename, sizeof (pretty)); + m_strcpy(pretty, sizeof(pretty), idx[i]->content->filename); if (stat (idx[i]->content->filename, &st) != 0) { mutt_pretty_mailbox (pretty); mutt_error (_("%s [#%d] no longer exists!"), pretty, i + 1); @@ -615,7 +615,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ case OP_COMPOSE_EDIT_NEWSGROUPS: if (news) { if (msg->env->newsgroups) - strfcpy (buf, msg->env->newsgroups, sizeof (buf)); + m_strcpy(buf, sizeof(buf), msg->env->newsgroups); else buf[0] = 0; if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 @@ -635,7 +635,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ if (news) { buf[0] = 0; if (msg->env->followup_to) - strfcpy (buf, msg->env->followup_to, sizeof (buf)); + m_strcpy(buf, sizeof(buf), msg->env->followup_to); if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0]) { p_delete(&msg->env->followup_to); @@ -653,7 +653,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ if (news && option (OPTXCOMMENTTO)) { buf[0] = 0; if (msg->env->x_comment_to) - strfcpy (buf, msg->env->x_comment_to, sizeof (buf)); + m_strcpy(buf, sizeof(buf), msg->env->x_comment_to); if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0]) { p_delete(&msg->env->x_comment_to); @@ -668,7 +668,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ #endif case OP_COMPOSE_EDIT_SUBJECT: if (msg->env->subject) - strfcpy (buf, msg->env->subject, sizeof (buf)); + m_strcpy(buf, sizeof(buf), msg->env->subject); else buf[0] = 0; if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) { @@ -685,9 +685,9 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_FCC: - strfcpy (buf, fcc, sizeof (buf)); + m_strcpy(buf, sizeof(buf), fcc); if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0) { - strfcpy (fcc, buf, _POSIX_PATH_MAX); + m_strcpy(fcc, _POSIX_PATH_MAX, buf); mutt_pretty_mailbox (fcc); move (HDR_FCC, HDR_XOFFSET + SW); mutt_paddstr (W, fcc); @@ -851,7 +851,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP)) #endif { - strfcpy (fname, NONULL (Context->path), sizeof (fname)); + m_strcpy(fname, sizeof(fname), NONULL(Context->path)); mutt_pretty_mailbox (fname); } @@ -997,9 +997,8 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ case OP_COMPOSE_EDIT_DESCRIPTION: CHECK_COUNT; - strfcpy (buf, - idx[menu->current]->content->description ? - idx[menu->current]->content->description : "", sizeof (buf)); + m_strcpy(buf, sizeof(buf), + NONULL(idx[menu->current]->content->description)); /* header names should not be translated */ if (mutt_get_field ("Description: ", buf, sizeof (buf), 0) == 0) { str_replace (&idx[menu->current]->content->description, buf); @@ -1049,8 +1048,8 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ case OP_COMPOSE_EDIT_ENCODING: CHECK_COUNT; - strfcpy (buf, ENCODING (idx[menu->current]->content->encoding), - sizeof (buf)); + m_strcpy(buf, sizeof(buf), + ENCODING(idx[menu->current]->content->encoding)); if (mutt_get_field ("Content-Transfer-Encoding: ", buf, sizeof (buf), 0) == 0 && buf[0]) { if ((i = mutt_check_encoding (buf)) != ENCOTHER && i != ENCUUENCODED) { @@ -1137,7 +1136,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ case OP_COMPOSE_RENAME_FILE: CHECK_COUNT; - strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname)); + m_strcpy(fname, sizeof(fname), idx[menu->current]->content->filename); mutt_pretty_mailbox (fname); if (mutt_get_field (_("Rename to: "), fname, sizeof (fname), M_FILE) == 0 && fname[0]) { @@ -1327,7 +1326,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ fname[0] = '\0'; if (Context) { - strfcpy (fname, NONULL (Context->path), sizeof (fname)); + m_strcpy(fname, sizeof(fname), NONULL(Context->path)); mutt_pretty_mailbox (fname); } if (idxlen) diff --git a/copy.c b/copy.c index 2b86aad..27cf073 100644 --- a/copy.c +++ b/copy.c @@ -521,7 +521,7 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body, if (flags & M_CM_PREFIX) { if (option (OPTTEXTFLOWED)) - strfcpy (prefix, ">", sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), ">"); else _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context, hdr, 0); diff --git a/crypt-gpgme.c b/crypt-gpgme.c index c8cfd19..e920128 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -1789,7 +1789,7 @@ int pgp_gpgme_application_handler (BODY * m, 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); + m_strcpy(body_charset, sizeof(body_charset), "iso-8859-1"); fseeko (s->fpin, m->offset, 0); last_pos = m->offset; @@ -3622,7 +3622,7 @@ static crypt_key_t *crypt_ask_for_key (char *tag, for (l = id_defaults; l; l = l->next) if (!m_strcasecmp(whatfor, l->what)) { - strfcpy (resp, NONULL (l->dflt), sizeof (resp)); + m_strcpy(resp, sizeof(resp), NONULL(l->dflt)); break; } } diff --git a/crypt.c b/crypt.c index c1225ac..b10ed05 100644 --- a/crypt.c +++ b/crypt.c @@ -750,7 +750,7 @@ int mutt_signed_handler (BODY * a, STATE * s) if ((protocol_minor = strchr (protocol, '/'))) protocol_minor++; - strfcpy (major, protocol, sizeof (major)); + m_strcpy(major, sizeof(major), protocol); if ((t = strchr (major, '/'))) *t = '\0'; diff --git a/curs_main.c b/curs_main.c index 88ec80e..18822d4 100644 --- a/curs_main.c +++ b/curs_main.c @@ -767,7 +767,7 @@ int mutt_index_menu (void) break; } - strfcpy (buf, ref->data, sizeof (buf)); + m_strcpy(buf, sizeof(buf), ref->data); } if (!Context->id_hash) Context->id_hash = mutt_make_id_hash (Context); @@ -813,7 +813,7 @@ int mutt_index_menu (void) if (!Context->id_hash) Context->id_hash = mutt_make_id_hash (Context); - strfcpy (buf, CURHDR->env->message_id, sizeof (buf)); + m_strcpy(buf, sizeof(buf), CURHDR->env->message_id); if (op == OP_RECONSTRUCT_THREAD) { LIST *ref = CURHDR->env->references; @@ -822,7 +822,7 @@ int mutt_index_menu (void) nntp_check_msgid (Context, ref->data); /* the last msgid in References is the root message */ if (!ref->next) - strfcpy (buf, ref->data, sizeof (buf)); + m_strcpy(buf, sizeof(buf), ref->data); ref = ref->next; } } @@ -960,7 +960,7 @@ int mutt_index_menu (void) set_option (OPTHIDEREAD); } else { - strfcpy (buf, Context->pattern + 8, sizeof (buf)); + m_strcpy(buf, sizeof(buf), Context->pattern + 8); if (!*buf || strncmp (buf, ".*", 2) == 0) snprintf (buf, sizeof (buf), "~A"); unset_option (OPTHIDEREAD); diff --git a/dotlock.c b/dotlock.c index 9df9848..6870553 100644 --- a/dotlock.c +++ b/dotlock.c @@ -55,8 +55,6 @@ # define LONG_STRING 1024 # define MAXLOCKATTEMPT 5 -# define strfcpy(A,B,C) m_strcpy(A,C,B) - # ifdef USE_SETGID # ifdef HAVE_SETEGID @@ -85,6 +83,8 @@ extern int snprintf (char *, size_t, const char *, ...); #endif /* DL_STANDALONE */ +#include + static int DotlockFlags; static int Retry = MAXLOCKATTEMPT; @@ -126,10 +126,6 @@ static int dotlock_lock (const char *); #define check_flags(a) if (a & DL_FL_ACTIONS) usage (argv[0]) -size_t m_strlen(const char* s) { - return (s ? strlen (s) : 0); -} - int main (int argc, char **argv) { int i; @@ -456,7 +452,7 @@ static int dotlock_prepare (char *bn, size_t l, const char *f, int _fd) if (m_strlen(basename) + 1 > l) return -1; - strfcpy (bn, basename, l); + m_strcpy(bn, l, basename); if (chdir (dirname) == -1) return -1; @@ -499,19 +495,19 @@ dotlock_expand_link (char *newpath, const char *path, const char *link) /* link is full path */ if (*link == '/') { - strfcpy (newpath, link, _POSIX_PATH_MAX); + m_strcpy(newpath, _POSIX_PATH_MAX, link); return; } if ((lb = strrchr (path, '/')) == NULL) { /* no path in link */ - strfcpy (newpath, link, _POSIX_PATH_MAX); + m_strcpy(newpath, _POSIX_PATH_MAX, link); return; } len = lb - path + 1; memcpy (newpath, path, len); - strfcpy (newpath + len, link, _POSIX_PATH_MAX - len); + m_strcpy(newpath + len, _POSIX_PATH_MAX - len, link); } @@ -547,14 +543,14 @@ static int dotlock_deference_symlink (char *d, size_t l, const char *path) linkfile[len] = '\0'; dotlock_expand_link (linkpath, pathptr, linkfile); - strfcpy (realpath, linkpath, sizeof (realpath)); + m_strcpy(realpath, sizeof(realpath), linkpath); pathptr = realpath; } else break; } - strfcpy (d, pathptr, l); + m_strcpy(d, l, pathptr); return 0; } diff --git a/edit.c b/edit.c index 37b46f2..893732e 100644 --- a/edit.c +++ b/edit.c @@ -66,7 +66,7 @@ static char **be_snarf_data (FILE * f, char **buf, int *bufmax, int *buflen, tmp[sizeof (tmp) - 1] = 0; if (prefix) { - strfcpy (tmp, NONULL (Prefix), sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), NONULL(Prefix)); tmplen = m_strlen(tmp); p = tmp + tmplen; tmplen = sizeof (tmp) - tmplen; @@ -247,7 +247,7 @@ static void be_edit_header (ENVELOPE * e, int force) if (!e->subject || force) { addstr ("Subject: "); - strfcpy (tmp, e->subject ? e->subject : "", sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), NONULL(e->subject)); if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 9, 0) == 0) str_replace (&e->subject, tmp); addch ('\n'); @@ -392,7 +392,7 @@ int mutt_builtin_editor (const char *path, HEADER * msg, HEADER * cur) case 'u': if (buflen) { buflen--; - strfcpy (tmp, buf[buflen], sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), buf[buflen]); tmp[m_strlen(tmp) - 1] = 0; p_delete(&buf[buflen]); buf[buflen] = NULL; diff --git a/getdomain.c b/getdomain.c index d58bb69..204a693 100644 --- a/getdomain.c +++ b/getdomain.c @@ -64,7 +64,7 @@ int getdnsdomainname (char *s, size_t l) if (q) { strip_trailing_dot (q); - strfcpy (s, q, l); + m_strcpy(s, l, q); safe_fclose (&f); return 0; } diff --git a/handler.c b/handler.c index 4abb301..1ed6c23 100644 --- a/handler.c +++ b/handler.c @@ -1104,7 +1104,7 @@ static int autoview_handler (BODY * a, STATE * s) p_delete(&fname); if (entry->command) { - strfcpy (command, entry->command, sizeof (command)); + m_strcpy(command, sizeof(command), entry->command); /* rfc1524_expand_command returns 0 if the file is required */ piped = diff --git a/hdrline.c b/hdrline.c index eaf38a7..91d469a 100644 --- a/hdrline.c +++ b/hdrline.c @@ -106,7 +106,7 @@ static void make_from (ENVELOPE * hdr, char *buf, size_t len, int do_lists) else if (me && hdr->cc) snprintf (buf, len, "Cc %s", mutt_get_name (hdr->cc)); else if (hdr->from) - strfcpy (buf, mutt_get_name (hdr->from), len); + m_strcpy(buf, len, mutt_get_name(hdr->from)); else *buf = 0; } @@ -130,7 +130,7 @@ static void make_from_addr (ENVELOPE * hdr, char *buf, size_t len, else if (me && hdr->cc) snprintf (buf, len, "%s", hdr->cc->mailbox); else if (hdr->from) - strfcpy (buf, hdr->from->mailbox, len); + m_strcpy(buf, len, hdr->from->mailbox); else *buf = 0; } @@ -266,7 +266,7 @@ static const char *hdr_format_str (char *dest, !first_mailing_list (dest, destlen, hdr->env->cc)) dest[0] = 0; if (dest[0]) { - strfcpy (buf2, dest, sizeof (buf2)); + m_strcpy(buf2, sizeof(buf2), dest); mutt_format_s (dest, destlen, prefix, buf2); break; } @@ -275,13 +275,13 @@ static const char *hdr_format_str (char *dest, case 'b': if (ctx) { if ((p = strrchr (ctx->path, '/'))) - strfcpy (dest, p + 1, destlen); + m_strcpy(dest, destlen, p + 1); else - strfcpy (dest, ctx->path, destlen); + m_strcpy(dest, destlen, ctx->path); } else - strfcpy (dest, "(null)", destlen); - strfcpy (buf2, dest, sizeof (buf2)); + m_strcpy(dest, destlen, "(null)"); + m_strcpy(buf2, sizeof(buf2), dest); mutt_format_s (dest, destlen, prefix, buf2); break; @@ -487,7 +487,7 @@ static const char *hdr_format_str (char *dest, snprintf (dest, destlen, fmt, ctx->msgcount); } else - strfcpy (dest, "(null)", destlen); + m_strcpy(dest, destlen, "(null)"); break; case 'n': @@ -595,7 +595,7 @@ static const char *hdr_format_str (char *dest, case 'u': if (hdr->env->from && hdr->env->from->mailbox) { - strfcpy (buf2, mutt_addr_for_display (hdr->env->from), sizeof (buf2)); + m_strcpy(buf2, sizeof(buf2), mutt_addr_for_display(hdr->env->from)); if ((p = strpbrk (buf2, "%@"))) *p = 0; } diff --git a/headers.c b/headers.c index 3f64694..abd9b0f 100644 --- a/headers.c +++ b/headers.c @@ -132,7 +132,7 @@ void mutt_edit_headers (const char *editor, p = cur->data + 4; SKIPWS (p); if (*p) { - strfcpy (fcc, p, fcclen); + m_strcpy(fcc, fcclen, p); mutt_pretty_mailbox (fcc); } keep = 0; @@ -150,7 +150,7 @@ void mutt_edit_headers (const char *editor, SKIPWS (q); } else - strfcpy (path, p, sizeof (path)); + m_strcpy(path, sizeof(path), p); mutt_expand_path (path, sizeof (path)); if ((body = mutt_make_file_attach (path))) { body->description = m_strdup(q); diff --git a/hook.c b/hook.c index 6432787..fcb6a22 100644 --- a/hook.c +++ b/hook.c @@ -69,7 +69,7 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, mutt_extract_token (&pattern, s, 0); if (!MoreArgs (s)) { - strfcpy (err->data, _("too few arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("too few arguments")); goto error; } @@ -79,17 +79,17 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, M_ACCOUNTHOOK | M_REPLYHOOK)) ? M_TOKEN_SPACE : 0); if (!command.data) { - strfcpy (err->data, _("too few arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("too few arguments")); goto error; } if (MoreArgs (s)) { - strfcpy (err->data, _("too many arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("too many arguments")); goto error; } if (data & (M_FOLDERHOOK | M_MBOXHOOK)) { - strfcpy (path, pattern.data, sizeof (path)); + m_strcpy(path, sizeof(path), pattern.data); _mutt_expand_path (path, sizeof (path), 1); p_delete(&pattern.data); p_clear(&pattern, 1); @@ -98,7 +98,7 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, #ifdef USE_COMPRESSED else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK)) { if (mutt_test_compress_command (command.data)) { - strfcpy (err->data, _("bad formatted command string"), err->dsize); + m_strcpy(err->data, err->dsize, _("bad formatted command string")); return (-1); } } @@ -108,7 +108,7 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, ) { char tmp[HUGE_STRING]; - strfcpy (tmp, pattern.data, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), pattern.data); mutt_check_simple (tmp, sizeof (tmp), DefaultHook); p_delete(&pattern.data); p_clear(&pattern, 1); @@ -116,7 +116,7 @@ int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data, } if (data & (M_MBOXHOOK | M_SAVEHOOK | M_FCCHOOK)) { - strfcpy (path, command.data, sizeof (path)); + m_strcpy(path, sizeof(path), command.data); mutt_expand_path (path, sizeof (path)); p_delete(&command.data); p_clear(&command, 1); @@ -410,10 +410,10 @@ void mutt_select_fcc (char *path, size_t pathlen, HEADER * hdr) mutt_safe_path (buf, sizeof (buf), adr); mutt_concat_path(path, pathlen, NONULL(Maildir), buf); if (!option (OPTFORCENAME) && mx_access (path, W_OK) != 0) - strfcpy (path, NONULL (Outbox), pathlen); + m_strcpy(path, pathlen, NONULL(Outbox)); } else - strfcpy (path, NONULL (Outbox), pathlen); + m_strcpy(path, pathlen, NONULL(Outbox)); } mutt_pretty_mailbox (path); } diff --git a/imap/auth_cram.c b/imap/auth_cram.c index ba2f42e..14772b0 100644 --- a/imap/auth_cram.c +++ b/imap/auth_cram.c @@ -143,11 +143,11 @@ static void hmac_md5 (const char *password, char *challenge, MD5Init (&ctx); MD5Update (&ctx, (unsigned char *) password, secret_len); MD5Final (hash_passwd, &ctx); - strfcpy ((char *) secret, (char *) hash_passwd, MD5_DIGEST_LEN); + m_strcpy((char *)secret, MD5_DIGEST_LEN, (char *)hash_passwd); secret_len = MD5_DIGEST_LEN; } else - strfcpy ((char *) secret, password, sizeof (secret)); + m_strcpy((char *)secret, sizeof(secret), password); p_clear(ipad, 1); p_clear(opad, 1); diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index 4d5495f..4d9df26 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -141,7 +141,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method) } if (irc == IMAP_CMD_RESPOND) { - strfcpy (buf + olen, "\r\n", sizeof (buf) - olen); + m_strcpy(buf + olen, sizeof(buf) - olen, "\r\n"); mutt_socket_write (idata->conn, buf); } diff --git a/imap/browse.c b/imap/browse.c index 9025dab..a983c94 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -73,8 +73,8 @@ int imap_browse (char *path, struct browser_state *state) save_lsub = option (OPTIMAPCHECKSUBSCRIBED); unset_option (OPTIMAPCHECKSUBSCRIBED); - strfcpy (list_cmd, option (OPTIMAPLSUB) ? "LSUB" : "LIST", - sizeof (list_cmd)); + m_strcpy(list_cmd, sizeof(list_cmd), + option(OPTIMAPLSUB) ? "LSUB" : "LIST"); if (!(idata = imap_conn_find (&(mx.account), 0))) goto fail; @@ -259,7 +259,7 @@ int imap_mailbox_create (const char *folder) goto fail; } - strfcpy (buf, NONULL (mx.mbox), sizeof (buf)); + m_strcpy(buf, sizeof(buf), NONULL(mx.mbox)); /* append a delimiter if necessary */ n = m_strlen(buf); @@ -399,12 +399,12 @@ static void imap_add_folder (char delim, char *folder, int noselect, /* render superiors as unix-standard ".." */ if (isparent) - strfcpy (relpath, "../", sizeof (relpath)); + m_strcpy(relpath, sizeof(relpath), "../"); /* strip current folder from target, to render a relative path */ else if (!m_strncmp(mx.mbox, folder, m_strlen(mx.mbox))) - strfcpy (relpath, folder + m_strlen(mx.mbox), sizeof (relpath)); + m_strcpy(relpath, sizeof(relpath), folder + m_strlen(mx.mbox)); else - strfcpy (relpath, folder, sizeof (relpath)); + m_strcpy(relpath, sizeof(relpath), folder); /* 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 diff --git a/imap/command.c b/imap/command.c index 915e3f1..15aa019 100644 --- a/imap/command.c +++ b/imap/command.c @@ -569,7 +569,7 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s) { imap_unmunge_mbox_name (s); debug_print (2, ("Subscribing to %s\n", s)); - strfcpy (buf, "mailboxes \"", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "mailboxes \""); mutt_account_tourl (&idata->conn->account, &url); url.path = s; if (!m_strcmp(url.user, ImapUser)) diff --git a/imap/imap.c b/imap/imap.c index 44d3eee..cb100ce 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1176,7 +1176,7 @@ int imap_mailbox_check (char *path, int new) p_delete(&mx.mbox); imap_munge_mbox_name (mbox, sizeof (mbox), buf); - strfcpy (mbox_unquoted, buf, sizeof (mbox_unquoted)); + m_strcpy(mbox_unquoted, sizeof(mbox_unquoted), buf); /* The draft IMAP implementor's guide warns againts using the STATUS * command on a mailbox that you have selected @@ -1185,7 +1185,7 @@ int imap_mailbox_check (char *path, int new) if (m_strcmp(mbox_unquoted, idata->mailbox) == 0 || (ascii_strcasecmp (mbox_unquoted, "INBOX") == 0 && m_strcasecmp(mbox_unquoted, idata->mailbox) == 0)) { - strfcpy (buf, "NOOP", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "NOOP"); } else if (mutt_bit_isset (idata->capabilities, IMAP4REV1) || mutt_bit_isset (idata->capabilities, STATUS)) { @@ -1516,7 +1516,7 @@ static int imap_complete_hosts (char *dest, size_t len) { mailbox = (BUFFY*) Incoming->data[i]; if (!m_strncmp(dest, mailbox->path, matchlen)) { if (rc) { - strfcpy (dest, mailbox->path, len); + m_strcpy(dest, len, mailbox->path); rc = 0; } else longest_common_prefix (dest, mailbox->path, matchlen, len); @@ -1537,7 +1537,7 @@ static int imap_complete_hosts (char *dest, size_t len) { url_ciss_tostring (&url, urlstr, sizeof (urlstr), 0); if (!m_strncmp(dest, urlstr, matchlen)) { if (rc) { - strfcpy (dest, urlstr, len); + m_strcpy(dest, len, urlstr); rc = 0; } else longest_common_prefix (dest, urlstr, matchlen, len); @@ -1563,7 +1563,7 @@ int imap_complete (char *dest, size_t dlen, char *path) { IMAP_MBOX mx; if (imap_parse_path (path, &mx) || !mx.mbox) { - strfcpy (dest, path, dlen); + m_strcpy(dest, dlen, path); return imap_complete_hosts (dest, dlen); } @@ -1571,7 +1571,7 @@ int imap_complete (char *dest, size_t dlen, char *path) { * known mailboxes/hooks/etc */ if (!(idata = imap_conn_find (&(mx.account), M_IMAP_CONN_NONEW))) { p_delete(&mx.mbox); - strfcpy (dest, path, dlen); + m_strcpy(dest, dlen, path); return imap_complete_hosts (dest, dlen); } conn = idata->conn; @@ -1590,7 +1590,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)); + m_strcpy(completion, sizeof(completion), NONULL(mx.mbox)); do { if (imap_parse_list_response (idata, &list_word, &noselect, &noinferiors, &delim)) @@ -1609,7 +1609,7 @@ int imap_complete (char *dest, size_t dlen, char *path) { } /* copy in first word */ if (!completions) { - strfcpy (completion, list_word, sizeof (completion)); + m_strcpy(completion, sizeof(completion), list_word); matchlen = m_strlen(completion); completions++; continue; diff --git a/imap/util.c b/imap/util.c index 5ca2fad..4bef04b 100644 --- a/imap/util.c +++ b/imap/util.c @@ -219,7 +219,7 @@ char *imap_fix_path (IMAP_DATA * idata, char *mailbox, char *path, int x = 0; if (!mailbox || !*mailbox) { - strfcpy (path, "INBOX", plen); + m_strcpy(path, plen, "INBOX"); return path; } diff --git a/init.c b/init.c index ef3f3d0..4b4daa3 100644 --- a/init.c +++ b/init.c @@ -313,7 +313,7 @@ static int path_from_string (struct option_t* dst, const char* val, } path[0] = '\0'; - strfcpy (path, val, sizeof(path)); + m_strcpy(path, sizeof(path), val); mutt_expand_path (path, sizeof(path)); str_replace ((char **) dst->data, path); return (1); @@ -980,9 +980,9 @@ static int parse_spam_list (BUFFER * buf, BUFFER * s, unsigned long data, /* Insist on at least one parameter */ if (!MoreArgs (s)) { if (data == M_SPAM) - strfcpy (err->data, _("spam: no matching pattern"), err->dsize); + m_strcpy(err->data, err->dsize, _("spam: no matching pattern")); else - strfcpy (err->data, _("nospam: no matching pattern"), err->dsize); + m_strcpy(err->data, err->dsize, _("nospam: no matching pattern")); return -1; } @@ -1034,7 +1034,7 @@ static int parse_spam_list (BUFFER * buf, BUFFER * s, unsigned long data, } /* This should not happen. */ - strfcpy (err->data, "This is no good at all.", err->dsize); + m_strcpy(err->data, err->dsize, "This is no good at all."); return -1; } @@ -1233,7 +1233,7 @@ static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER mutt_extract_token(buf, s, 0); if (!buf->data || *buf->data == '\0') { - strfcpy(err->data, _("attachments: no disposition"), err->dsize); + m_strcpy(err->data, err->dsize, _("attachments: no disposition")); return -1; } @@ -1270,7 +1270,7 @@ static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER else listp = &InlineExclude; } else { - strfcpy(err->data, _("attachments: invalid disposition"), err->dsize); + m_strcpy(err->data, err->dsize, _("attachments: invalid disposition")); return -1; } @@ -1283,7 +1283,7 @@ static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFF mutt_extract_token(buf, s, 0); if (!buf->data || *buf->data == '\0') { - strfcpy(err->data, _("unattachments: no disposition"), err->dsize); + m_strcpy(err->data, err->dsize, _("unattachments: no disposition")); return -1; } @@ -1306,7 +1306,7 @@ static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFF listp = &InlineExclude; } else { - strfcpy(err->data, _("unattachments: invalid disposition"), err->dsize); + m_strcpy(err->data, err->dsize, _("unattachments: invalid disposition")); return -1; } @@ -1414,7 +1414,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s, unsigned long data, char *estr = NULL; if (!MoreArgs (s)) { - strfcpy (err->data, _("alias: no address"), err->dsize); + m_strcpy(err->data, err->dsize, _("alias: no address")); return (-1); } @@ -1526,7 +1526,7 @@ static int parse_my_hdr (BUFFER * buf, BUFFER * s, unsigned long data, mutt_extract_token (buf, s, M_TOKEN_SPACE | M_TOKEN_QUOTE); if ((p = strpbrk (buf->data, ": \t")) == NULL || *p != ':') { - strfcpy (err->data, _("invalid header field"), err->dsize); + m_strcpy(err->data, err->dsize, _("invalid header field")); return (-1); } keylen = p - buf->data + 1; @@ -2143,7 +2143,7 @@ static int parse_source (BUFFER * tmp, BUFFER * s, unsigned long data, return (-1); } - strfcpy (path, tmp->data, sizeof(path)); + m_strcpy(path, sizeof(path), tmp->data); mutt_expand_path (path, sizeof(path)); rc += source_rc (path, err); @@ -2230,7 +2230,7 @@ static void candidate (char *dest, char *try, const char *src, int len) if (strstr (src, try) == src) { Matches[Num_matched++] = src; if (dest[0] == 0) - strfcpy (dest, src, len); + m_strcpy(dest, len, src); else { for (l = 0; src[l] && src[l] == dest[l]; l++); dest[l] = 0; @@ -2255,7 +2255,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) /* first TAB. Collect all the matches */ if (numtabs == 1) { Num_matched = 0; - strfcpy (User_typed, pt, sizeof(User_typed)); + m_strcpy(User_typed, sizeof(User_typed), pt); p_clear(Matches, sizeof(Matches)); p_clear(Completed, sizeof(Completed)); for (num = 0; Commands[num].name; num++) @@ -2304,7 +2304,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) /* first TAB. Collect all the matches */ if (numtabs == 1) { Num_matched = 0; - strfcpy (User_typed, pt, sizeof(User_typed)); + m_strcpy(User_typed, sizeof(User_typed), pt); p_clear(Matches, sizeof(Matches)); p_clear(Completed, sizeof(Completed)); for (num = 0; MuttVars[num].option; num++) @@ -2342,7 +2342,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) /* first TAB. Collect all the matches */ if (numtabs == 1) { Num_matched = 0; - strfcpy (User_typed, pt, sizeof(User_typed)); + m_strcpy(User_typed, sizeof(User_typed), pt); p_clear(Matches, sizeof(Matches)); p_clear(Completed, sizeof(Completed)); for (num = 0; menu[num].name; num++) @@ -2402,7 +2402,7 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) return 0; if (m_strncmp(buffer, "set", 3) == 0) { - strfcpy (var, pt, sizeof(var)); + m_strcpy(var, sizeof(var), pt); /* ignore the trailing '=' when comparing */ var[m_strlen(var) - 1] = 0; if (!(option = hash_find (ConfigOptions, var))) @@ -2418,7 +2418,7 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) if ((DTYPE (option->type) == DT_STR) || (DTYPE (option->type) == DT_PATH) || (DTYPE (option->type) == DT_RX)) { - strfcpy (tmp, NONULL (*((char **) option->data)), sizeof(tmp)); + m_strcpy(tmp, sizeof(tmp), NONULL(*((char **)option->data))); if (DTYPE (option->type) == DT_PATH) mutt_pretty_mailbox (tmp); } @@ -2427,7 +2427,7 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) *((ADDRESS **) option->data), 0); } else if (DTYPE (option->type) == DT_QUAD) - strfcpy (tmp, vals[quadoption (option->data)], sizeof(tmp)); + m_strcpy(tmp, sizeof(tmp), vals[quadoption(option->data)]); else if (DTYPE (option->type) == DT_NUM) snprintf (tmp, sizeof(tmp), "%d", (*((short *) option->data))); else if (DTYPE (option->type) == DT_SORT) { @@ -2474,11 +2474,10 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) default: p = "unknown"; } - strfcpy (tmp, p, sizeof(tmp)); + m_strcpy(tmp, sizeof(tmp), p); } else if (DTYPE (option->type) == DT_BOOL) - strfcpy (tmp, option (option->data) ? "yes" : "no", - sizeof(tmp)); + m_strcpy(tmp, sizeof(tmp), option(option->data) ? "yes" : "no"); else return 0; @@ -2489,7 +2488,7 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) } *d = '\0'; - strfcpy (tmp, pt, sizeof(tmp)); + m_strcpy(tmp, sizeof(tmp), pt); snprintf (pt, dlen, "%s\"%s\"", tmp, tmp2); return 1; @@ -2640,7 +2639,7 @@ void mutt_init (int skip_sys_rc, LIST * commands) if ((p = strchr (utsname.nodename, '.'))) { Hostname = str_substrdup (utsname.nodename, p); p++; - strfcpy (buffer, p, sizeof(buffer)); /* save the domain for below */ + m_strcpy(buffer, sizeof(buffer), p); /* save the domain for below */ } else Hostname = m_strdup(utsname.nodename); @@ -2793,7 +2792,7 @@ void mutt_init (int skip_sys_rc, LIST * commands) Muttrc = m_strdup(buffer); } else { - strfcpy (buffer, Muttrc, sizeof(buffer)); + m_strcpy(buffer, sizeof(buffer), Muttrc); p_delete(&Muttrc); mutt_expand_path (buffer, sizeof(buffer)); Muttrc = m_strdup(buffer); diff --git a/keymap.c b/keymap.c index 0c450f7..bc577b7 100644 --- a/keymap.c +++ b/keymap.c @@ -144,7 +144,7 @@ static int parsekeys (const char *str, keycode_t * d, int max) char c; char *s, *t; - strfcpy (buff, str, sizeof (buff)); + m_strcpy(buff, sizeof(buff), str); s = buff; while (*s && len) { @@ -492,7 +492,7 @@ int km_expand_key (char *s, size_t len, struct keymap_t *map) return (0); for (;;) { - strfcpy (s, km_keyname (map->keys[p]), len); + m_strcpy(s, len, km_keyname(map->keys[p])); len -= (l = m_strlen(s)); if (++p >= map->len || !len) @@ -661,7 +661,7 @@ int mutt_parse_push (BUFFER * buf, BUFFER * s, unsigned long data, mutt_extract_token (buf, s, M_TOKEN_CONDENSE); if (MoreArgs (s)) { - strfcpy (err->data, _("push: too many arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("push: too many arguments")); r = -1; } else @@ -703,13 +703,13 @@ static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus, mutt_extract_token (&buf, s, 0); if (!*buf.data) { - strfcpy (err->data, _("null key sequence"), err->dsize); + m_strcpy(err->data, err->dsize, _("null key sequence")); } else if (MoreArgs (s)) return (buf.data); } else { - strfcpy (err->data, _("too few arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("too few arguments")); } error: p_delete(&buf.data); @@ -788,7 +788,7 @@ int mutt_parse_bind (BUFFER * buf, BUFFER * s, unsigned long data, /* function to execute */ mutt_extract_token (buf, s, 0); if (MoreArgs (s)) { - strfcpy (err->data, _("bind: too many arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("bind: too many arguments")); r = -1; } else if (ascii_strcasecmp ("noop", buf->data) == 0) { @@ -833,7 +833,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data, mutt_extract_token (buf, s, M_TOKEN_CONDENSE); /* make sure the macro sequence is not an empty string */ if (!*buf->data) { - strfcpy (err->data, _("macro: empty key sequence"), err->dsize); + m_strcpy(err->data, err->dsize, _("macro: empty key sequence")); } else { if (MoreArgs (s)) { @@ -841,7 +841,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data, mutt_extract_token (buf, s, M_TOKEN_CONDENSE); if (MoreArgs (s)) { - strfcpy (err->data, _("macro: too many arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("macro: too many arguments")); } else { for (i = 0; i < nummenus; ++i) { @@ -873,7 +873,7 @@ int mutt_parse_exec (BUFFER * buf, BUFFER * s, unsigned long data, char *function; if (!MoreArgs (s)) { - strfcpy (err->data, _("exec: no arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("exec: no arguments")); return (-1); } diff --git a/lib-lib/str.h b/lib-lib/str.h index 7dc15d6..e319f2a 100644 --- a/lib-lib/str.h +++ b/lib-lib/str.h @@ -27,6 +27,10 @@ #define NONULL(x) (x?x:"") +static inline int m_strisempty(const char *s) { + return !s || !*s; +} + static inline ssize_t m_strlen(const char *s) { return s ? strlen(s) : 0; } diff --git a/lib/str.h b/lib/str.h index 8a480c3..140a4ba 100644 --- a/lib/str.h +++ b/lib/str.h @@ -30,7 +30,6 @@ # define ISSPACE(c) isspace((unsigned char)c) # define ISBLANK(c) (c == ' ' || c == '\t') -# define strfcpy(A,B,C) m_strcpy(A,C,B) /* this macro must check for *c == 0 since isspace(0) has * unreliable behavior on some systems */ # define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++; diff --git a/main.c b/main.c index 3435941..0a199b1 100644 --- a/main.c +++ b/main.c @@ -632,7 +632,7 @@ int main (int argc, char **argv) break; case 'f': - strfcpy (folder, optarg, sizeof (folder)); + m_strcpy(folder, sizeof(folder), optarg); explicit_folder = 1; break; @@ -817,7 +817,7 @@ int main (int argc, char **argv) char fpath[_POSIX_PATH_MAX]; char msg[STRING]; - strfcpy (fpath, Maildir, sizeof (fpath)); + m_strcpy(fpath, sizeof(fpath), Maildir); mutt_expand_path (fpath, sizeof (fpath)); #ifdef USE_IMAP /* we're not connected yet - skip mail folder creation */ @@ -886,7 +886,7 @@ int main (int argc, char **argv) else { char path[_POSIX_PATH_MAX]; - strfcpy (path, infile, sizeof (path)); + m_strcpy(path, sizeof(path), infile); mutt_expand_path (path, sizeof (path)); if ((fin = fopen (path, "r")) == NULL) { if (!option (OPTNOCURSES)) @@ -993,7 +993,7 @@ int main (int argc, char **argv) } if (!folder[0]) - strfcpy (folder, NONULL (Spoolfile), sizeof (folder)); + m_strcpy(folder, sizeof(folder), NONULL(Spoolfile)); #ifdef USE_NNTP if (option (OPTNEWS)) { diff --git a/menu.c b/menu.c index 42f411c..91abff1 100644 --- a/menu.c +++ b/menu.c @@ -682,7 +682,7 @@ static int menu_search (MUTTMENU * menu, int op) char buf[SHORT_STRING]; if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE) { - strfcpy (buf, menu->searchBuf ? menu->searchBuf : "", sizeof (buf)); + m_strcpy(buf, sizeof(buf), NONULL(menu->searchBuf)); if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") : _("Reverse search for: "), buf, sizeof (buf), M_CLEAR) != 0 || !buf[0]) diff --git a/mh.c b/mh.c index da270a2..09a2fb3 100644 --- a/mh.c +++ b/mh.c @@ -550,7 +550,7 @@ static void maildir_update_mtime (CONTEXT * ctx) if (stat (buf, &st) == 0) ctx->mtime_cur = st.st_mtime; - strfcpy (buf, ctx->path, sizeof (buf)); + m_strcpy(buf, sizeof(buf), ctx->path); } if (stat (buf, &st) == 0) @@ -690,7 +690,7 @@ static int maildir_parse_dir (CONTEXT * ctx, struct maildir ***last, is_old = (m_strcmp("cur", subdir) == 0); } else - strfcpy (buf, ctx->path, sizeof (buf)); + m_strcpy(buf, sizeof(buf), ctx->path); if ((dirp = opendir (buf)) == NULL) return -1; @@ -1044,9 +1044,9 @@ static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr *suffix = '\0'; if (hdr && (hdr->read || hdr->old)) - strfcpy (subdir, "cur", sizeof (subdir)); + m_strcpy(subdir, sizeof(subdir), "cur"); else - strfcpy (subdir, "new", sizeof (subdir)); + m_strcpy(subdir, sizeof(subdir), "new"); for (;;) { snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%u_%d.%s%s", @@ -1115,11 +1115,11 @@ static int maildir_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr) /* extract the subdir */ s = strrchr (msg->path, '/') + 1; - strfcpy (subdir, s, 4); + m_strcpy(subdir, sizeof(subdir), s); /* extract the flags */ if ((s = strchr (s, ':'))) - strfcpy (suffix, s, sizeof (suffix)); + m_strcpy(suffix, sizeof(suffix), s); else suffix[0] = '\0'; @@ -1266,8 +1266,8 @@ static int mh_rewrite_message (CONTEXT * ctx, int msgno) if ((rc = mutt_copy_message (dest->fp, ctx, h, M_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN)) == 0) { - snprintf (oldpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path); - strfcpy (partpath, h->path, _POSIX_PATH_MAX); + snprintf (oldpath, sizeof(oldpath), "%s/%s", ctx->path, h->path); + m_strcpy(partpath, sizeof(partpath), h->path); if (ctx->magic == M_MAILDIR) rc = maildir_commit_message (dest, ctx, h); @@ -1352,7 +1352,7 @@ static int maildir_sync_message (CONTEXT * ctx, int msgno) return (-1); } p++; - strfcpy (newpath, p, sizeof (newpath)); + m_strcpy(newpath, sizeof(newpath), p); /* kill the previous flags */ if ((p = strchr (newpath, ':')) != NULL) @@ -1482,7 +1482,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); + m_strcpy(dest, l, src); if ((u = strrchr (dest, ':'))) *u = '\0'; @@ -1708,7 +1708,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint, int unused) if (!option (OPTCHECKNEW)) return 0; - strfcpy (buf, ctx->path, sizeof (buf)); + m_strcpy(buf, sizeof(buf), ctx->path); if (stat (buf, &st) == -1) return -1; diff --git a/mutt_ssl.c b/mutt_ssl.c index aeed464..2354cd9 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -412,7 +412,7 @@ static char *x509_get_part (char *line, const char *ndx) static char ret[SHORT_STRING]; char *c, *c2; - strfcpy (ret, _("Unknown"), sizeof (ret)); + m_strcpy(ret, sizeof(ret), _("Unknown")); c = strstr (line, ndx); if (c) { @@ -420,7 +420,7 @@ static char *x509_get_part (char *line, const char *ndx) c2 = strchr (c, '/'); if (c2) *c2 = '\0'; - strfcpy (ret, c, sizeof (ret)); + m_strcpy(ret, sizeof(ret), c); if (c2) *c2 = '/'; } @@ -452,7 +452,7 @@ static char *asn1time_to_string (ASN1_UTCTIME * tm) static char buf[64]; BIO *bio; - strfcpy (buf, _("[invalid date]"), sizeof (buf)); + m_strcpy(buf, sizeof(buf), _("[invalid date]")); bio = BIO_new (BIO_s_mem ()); if (bio) { @@ -588,8 +588,8 @@ static int ssl_check_certificate (sslsockdata * data) menu->dialog[i] = p_new(char, SHORT_STRING); row = 0; - strfcpy (menu->dialog[row], _("This certificate belongs to:"), - SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("This certificate belongs to:")); row++; name = X509_NAME_oneline (X509_get_subject_name (data->cert), buf, sizeof (buf)); @@ -599,8 +599,8 @@ static int ssl_check_certificate (sslsockdata * data) } row++; - strfcpy (menu->dialog[row], _("This certificate was issued by:"), - SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("This certificate was issued by:")); row++; name = X509_NAME_oneline (X509_get_issuer_name (data->cert), buf, sizeof (buf)); diff --git a/mutt_ssl_gnutls.c b/mutt_ssl_gnutls.c index 2b44e26..61a2da8 100644 --- a/mutt_ssl_gnutls.c +++ b/mutt_ssl_gnutls.c @@ -382,7 +382,7 @@ static char *tls_make_date (time_t t, char *s, size_t len) 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); + m_strcpy(s, len, _("[invalid date]")); return (s); } @@ -592,8 +592,8 @@ static int tls_check_certificate (CONNECTION * conn) menu->dialog[i] = p_new(char, SHORT_STRING); row = 0; - strfcpy (menu->dialog[row], _("This certificate belongs to:"), - SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("This certificate belongs to:")); row++; buflen = sizeof (dn_common_name); @@ -637,8 +637,8 @@ static int tls_check_certificate (CONNECTION * conn) dn_province, dn_country); row++; - strfcpy (menu->dialog[row], _("This certificate was issued by:"), - SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("This certificate was issued by:")); row++; buflen = sizeof (dn_common_name); @@ -704,30 +704,28 @@ static int tls_check_certificate (CONNECTION * conn) if (certerr_notyetvalid) { row++; - strfcpy (menu->dialog[row], - _("WARNING: Server certificate is not yet valid"), SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("WARNING: Server certificate is not yet valid")); } if (certerr_expired) { row++; - strfcpy (menu->dialog[row], _("WARNING: Server certificate has expired"), - SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("WARNING: Server certificate has expired")); } if (certerr_revoked) { row++; - strfcpy (menu->dialog[row], - _("WARNING: Server certificate has been revoked"), SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("WARNING: Server certificate has been revoked")); } if (certerr_hostname) { row++; - strfcpy (menu->dialog[row], - _("WARNING: Server hostname does not match certificate"), - SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("WARNING: Server hostname does not match certificate")); } if (certerr_signernotca) { row++; - strfcpy (menu->dialog[row], - _("WARNING: Signer of server certificate is not a CA"), - SHORT_STRING); + m_strcpy(menu->dialog[row], SHORT_STRING, + _("WARNING: Signer of server certificate is not a CA")); } menu->title = _("TLS/SSL Certificate check"); diff --git a/muttlib.c b/muttlib.c index f2137a8..6146d4e 100644 --- a/muttlib.c +++ b/muttlib.c @@ -77,14 +77,14 @@ void mutt_adv_mktemp (const char* dir, char *s, size_t l) size_t sl; struct stat sb; - strfcpy (buf, dir && *dir ? dir : NONULL (Tempdir), sizeof (buf)); + m_strcpy(buf, sizeof(buf), m_strisempty(dir) ? NONULL(Tempdir) : dir); mutt_expand_path (buf, sizeof (buf)); if (s[0] == '\0') { snprintf (s, l, "%s/muttXXXXXX", buf); mktemp (s); } else { - strfcpy (tmp, s, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), s); mutt_sanitize_filename (tmp, 1); snprintf (s, l, "%s/%s", buf, tmp); if (lstat (s, &sb) == -1 && errno == ENOENT) @@ -96,7 +96,7 @@ void mutt_adv_mktemp (const char* dir, char *s, size_t l) if (period != NULL) { *period = '.'; sl = m_strlen(s); - strfcpy (s + sl, period, l - sl); + m_strcpy(s + sl, l - sl, period); } } } @@ -114,7 +114,7 @@ int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src) if (src->filename) { use_disp = 1; - strfcpy (tmp, src->filename, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), src->filename); } else { use_disp = 0; @@ -269,19 +269,19 @@ void mutt_expand_link (char *newpath, const char *path, const char *lnk) /* lnk is full path */ if (*lnk == '/') { - strfcpy (newpath, lnk, _POSIX_PATH_MAX); + m_strcpy(newpath, _POSIX_PATH_MAX, lnk); return; } if ((lb = strrchr (path, '/')) == NULL) { /* no path in lnk */ - strfcpy (newpath, lnk, _POSIX_PATH_MAX); + m_strcpy(newpath, _POSIX_PATH_MAX, lnk); return; } len = lb - path + 1; memcpy (newpath, path, len); - strfcpy (newpath + len, lnk, _POSIX_PATH_MAX - len); + m_strcpy(newpath + len, _POSIX_PATH_MAX - len, lnk); } char *mutt_expand_path (char *s, size_t slen) @@ -307,7 +307,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) case '~': { if (*(s + 1) == '/' || *(s + 1) == 0) { - strfcpy (p, NONULL (Homedir), sizeof (p)); + m_strcpy(p, sizeof(p), NONULL(Homedir)); tail = s + 1; } else { @@ -317,7 +317,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) *t = 0; if ((pw = getpwnam (s + 1))) { - strfcpy (p, pw->pw_dir, sizeof (p)); + m_strcpy(p, sizeof(p), pw->pw_dir); if (t) { *t = '/'; tail = t; @@ -343,7 +343,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) /* if folder = imap[s]://host/: don't append slash */ if (imap_is_magic (NONULL (Maildir), NULL) == M_IMAP && Maildir[m_strlen(Maildir) - 1] == '/') - strfcpy (p, NONULL (Maildir), sizeof (p)); + m_strcpy(p, sizeof(p), NONULL(Maildir)); else #endif snprintf (p, sizeof (p), "%s/", NONULL (Maildir)); @@ -377,14 +377,14 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) case '>': { - strfcpy (p, NONULL (Inbox), sizeof (p)); + m_strcpy(p, sizeof(p), NONULL(Inbox)); tail = s + 1; } break; case '<': { - strfcpy (p, NONULL (Outbox), sizeof (p)); + m_strcpy(p, sizeof(p), NONULL(Outbox)); tail = s + 1; } break; @@ -392,11 +392,11 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) case '!': { if (*(s + 1) == '!') { - strfcpy (p, NONULL (LastFolder), sizeof (p)); + m_strcpy(p, sizeof(p), NONULL(LastFolder)); tail = s + 2; } else { - strfcpy (p, NONULL (Spoolfile), sizeof (p)); + m_strcpy(p, sizeof(p), NONULL(Spoolfile)); tail = s + 1; } } @@ -404,14 +404,14 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) case '-': { - strfcpy (p, NONULL (LastFolder), sizeof (p)); + m_strcpy(p, sizeof(p), NONULL(LastFolder)); tail = s + 1; } break; case '^': { - strfcpy (p, NONULL (CurrentFolder), sizeof (p)); + m_strcpy(p, sizeof(p), NONULL(CurrentFolder)); tail = s + 1; } break; @@ -430,7 +430,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) else snprintf (tmp, sizeof (tmp), "%s%s", p, tail); - strfcpy (s, tmp, slen); + m_strcpy(s, slen, tmp); } while (recurse); @@ -459,13 +459,13 @@ char *mutt_gecos_name (char *dest, size_t destlen, struct passwd *pw) if (GecosMask.rx) { if (regexec (GecosMask.rx, 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)); + m_strcpy(dest, MIN(pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen), + pw->pw_gecos + pat_match[0].rm_so); } else if ((p = strchr (pw->pw_gecos, ','))) - strfcpy (dest, pw->pw_gecos, MIN (destlen, p - pw->pw_gecos + 1)); + m_strcpy(dest, MIN(destlen, p - pw->pw_gecos + 1), pw->pw_gecos); else - strfcpy (dest, pw->pw_gecos, destlen); + m_strcpy(dest, destlen, pw->pw_gecos); pwnl = m_strlen(pw->pw_name); @@ -738,7 +738,7 @@ void mutt_pretty_mailbox (char *s) void mutt_pretty_size (char *s, size_t len, long n) { if (n == 0) - strfcpy (s, "0K", len); + m_strcpy(s, len, "0K"); 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 */ @@ -783,7 +783,7 @@ void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt, break; case 's': found = 1; - strfcpy (d, src, destlen + 1); + m_strcpy(d, destlen + 1, src); d += destlen > slen ? slen : destlen; destlen -= destlen > slen ? slen : destlen; p++; @@ -818,7 +818,7 @@ int mutt_check_overwrite (const char *attname, const char *path, char tmp[_POSIX_PATH_MAX]; struct stat st; - strfcpy (fname, path, flen); + m_strcpy(fname, flen, path); if (access (fname, F_OK) != 0) return 0; if (stat (fname, &st) != 0) @@ -882,7 +882,7 @@ int mutt_check_overwrite (const char *attname, const char *path, void mutt_save_path (char *d, size_t dsize, ADDRESS * a) { if (a && a->mailbox) { - strfcpy (d, a->mailbox, dsize); + m_strcpy(d, dsize, a->mailbox); if (!option (OPTSAVEADDRESS)) { char *p; diff --git a/mx.c b/mx.c index 370bb9f..5348821 100644 --- a/mx.c +++ b/mx.c @@ -745,10 +745,10 @@ static int _mx_close_mailbox (CONTEXT * ctx, int *index_hint) if ((p = mutt_find_hook (M_MBOXHOOK, ctx->path))) { isSpool = 1; - strfcpy (mbox, p, sizeof (mbox)); + m_strcpy(mbox, sizeof(mbox), p); } else { - strfcpy (mbox, NONULL (Inbox), sizeof (mbox)); + m_strcpy(mbox, sizeof(mbox), NONULL(Inbox)); isSpool = mutt_is_spool (ctx->path) && !mutt_is_spool (mbox); } mutt_expand_path (mbox, sizeof (mbox)); @@ -1009,8 +1009,7 @@ static int _mx_sync_mailbox (CONTEXT * ctx, int *index_hint) 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)); + m_strcpy(tmp, sizeof(tmp), _("Use 'toggle-write' to re-enable write!")); mutt_error (_("Mailbox is marked unwritable. %s"), tmp); return -1; diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 66ff3f2..94585e7 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -74,7 +74,7 @@ static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line) len = p + 1 - line; if (len > sizeof (group)) len = sizeof (group); - strfcpy (group, line, len); + m_strcpy(group, len, line); if ((data = (NNTP_DATA *) hash_find (news->newsgroups, group)) == NULL) { data = xmalloc(sizeof(NNTP_DATA) + m_strlen(group) + 1); data->group = (char *) data + sizeof (NNTP_DATA); @@ -184,7 +184,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) if (!NewsCacheDir || !*NewsCacheDir) return 0; - strfcpy (dir, NewsCacheDir, sizeof (dir)); + m_strcpy(dir, sizeof(dir), NewsCacheDir); mutt_expand_path (dir, sizeof (dir)); if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0) { @@ -299,7 +299,7 @@ int nntp_parse_url (const char *server, ACCOUNT * acct, *group = '\0'; if (url.path) - strfcpy (group, url.path, group_len); + m_strcpy(group, group_len, url.path); ret = mutt_account_fromurl (acct, &url); } @@ -810,7 +810,7 @@ static int nntp_update_cacheindex (NNTP_SERVER * serv, NNTP_DATA * data) data->firstMessage, data->lastLoaded); } else { - strfcpy (file, serv->cache, sizeof (file)); + m_strcpy(file, sizeof(file), serv->cache); snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int) serv->newgroups_time); } @@ -856,7 +856,7 @@ int nntp_save_cache_index (NNTP_SERVER * news) f = safe_fopen (file, "w"); } else { - strfcpy (buf, news->conn->account.host, sizeof (buf)); + m_strcpy(buf, sizeof(buf), news->conn->account.host); f = mutt_mkname (buf); news->cache = m_strdup(buf); nntp_cache_expand (file, buf); diff --git a/nntp/nntp.c b/nntp/nntp.c index ca3e51e..5ad2719 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -311,7 +311,7 @@ static int mutt_nntp_query (NNTP_DATA * data, char *line, size_t linelen) return -1; } while (!done); - strfcpy (line, buf, linelen); + m_strcpy(line, linelen, buf); return 0; } @@ -338,7 +338,7 @@ static int mutt_nntp_fetch (NNTP_DATA * nntp_data, const char *query, char *msg, int ret; do { - strfcpy (buf, query, sizeof (buf)); + m_strcpy(buf, sizeof(buf), query); if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) return -1; if (buf[0] == '5') @@ -366,7 +366,7 @@ static int mutt_nntp_fetch (NNTP_DATA * nntp_data, const char *query, char *msg, p++; } - strfcpy (inbuf + lenbuf, p, sizeof (buf)); + m_strcpy(inbuf + lenbuf, sizeof(buf), p); pos += chunk; if (chunk >= sizeof (buf)) { @@ -1039,7 +1039,7 @@ int nntp_post (const char *msg) return -1; } - strfcpy (buf, "POST\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "POST\r\n"); if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) { mutt_error (_("Can't post article. Connection to %s lost."), nntp_data->nserv->conn->account.host); @@ -1431,7 +1431,7 @@ int nntp_get_active (NNTP_SERVER * serv) return -1; } - strfcpy (msg, _("Loading descriptions..."), sizeof (msg)); + m_strcpy(msg, sizeof(msg), _("Loading descriptions...")); mutt_message (msg); nntp_get_desc (&nntp_data, "*", msg, NULL); diff --git a/pager.c b/pager.c index ad57de7..78b75ca 100644 --- a/pager.c +++ b/pager.c @@ -1471,7 +1471,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) mutt_compile_help (helpstr, sizeof (helpstr), MENU_PAGER, PagerHelp); if (IsHeader (extra)) { - strfcpy (tmphelp, helpstr, sizeof (tmphelp)); + m_strcpy(tmphelp, sizeof(tmphelp), helpstr); mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER, #ifdef USE_NNTP (Context @@ -1481,7 +1481,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer); } if (!InHelp) { - strfcpy (tmphelp, helpstr, sizeof (tmphelp)); + m_strcpy(tmphelp, sizeof(tmphelp), helpstr); mutt_make_help (buffer, sizeof (buffer), _("Help"), MENU_PAGER, OP_HELP); snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer); } @@ -1889,7 +1889,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) case OP_SEARCH: case OP_SEARCH_REVERSE: - strfcpy (buffer, searchbuf, sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), searchbuf); if (mutt_get_field ((SearchBack ? _("Reverse search: ") : _("Search: ")), buffer, sizeof (buffer), M_CLEAR) != 0) @@ -1910,7 +1910,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) if (!buffer[0]) break; - strfcpy (searchbuf, buffer, sizeof (searchbuf)); + m_strcpy(searchbuf, sizeof(searchbuf), buffer); /* leave SearchBack alone if ch == OP_SEARCH_NEXT */ if (ch == OP_SEARCH) diff --git a/parse.c b/parse.c index 5f737b7..c010636 100644 --- a/parse.c +++ b/parse.c @@ -796,7 +796,7 @@ time_t mutt_parse_date (const char *s, HEADER * h) * the date format imposes a natural limit. */ - strfcpy (scratch, s, sizeof (scratch)); + m_strcpy(scratch, sizeof(scratch), s); /* kill the day of the week, if it exists. */ if ((t = strchr (scratch, ','))) @@ -1415,7 +1415,7 @@ ADDRESS *mutt_parse_adrlist (ADDRESS * p, const char *s) char tmp[HUGE_STRING]; char *r; - strfcpy (tmp, s, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), s); r = tmp; while ((r = strtok (r, " \t")) != NULL) { p = rfc822_parse_adrlist (p, r); diff --git a/pattern.c b/pattern.c index e4d7caa..a02e96e 100644 --- a/pattern.c +++ b/pattern.c @@ -540,7 +540,7 @@ static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err) p_clear(&buffer, 1); if (mutt_extract_token (&buffer, s, M_TOKEN_COMMENT | M_TOKEN_PATTERN) != 0 || !buffer.data) { - strfcpy (err->data, _("error in expression"), err->dsize); + m_strcpy(err->data, err->dsize, _("error in expression")); return (-1); } @@ -842,7 +842,7 @@ pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err) } } if (!curlist) { - strfcpy (err->data, _("empty pattern"), err->dsize); + m_strcpy(err->data, err->dsize, _("empty pattern")); return NULL; } if (curlist->next) { @@ -1172,23 +1172,23 @@ void mutt_check_simple (char *s, size_t len, const char *simple) if (!strchr (s, '~') && !strchr (s, '=')) { /* yup, so spoof a real request */ /* convert old tokens into the new format */ if (ascii_strcasecmp ("all", s) == 0 || !m_strcmp("^", s) || !m_strcmp(".", s)) /* ~A is more efficient */ - strfcpy (s, "~A", len); + m_strcpy(s, len, "~A"); else if (ascii_strcasecmp ("del", s) == 0) - strfcpy (s, "~D", len); + m_strcpy(s, len, "~D"); else if (ascii_strcasecmp ("flag", s) == 0) - strfcpy (s, "~F", len); + m_strcpy(s, len, "~F"); else if (ascii_strcasecmp ("new", s) == 0) - strfcpy (s, "~N", len); + m_strcpy(s, len, "~N"); else if (ascii_strcasecmp ("old", s) == 0) - strfcpy (s, "~O", len); + m_strcpy(s, len, "~O"); else if (ascii_strcasecmp ("repl", s) == 0) - strfcpy (s, "~Q", len); + m_strcpy(s, len, "~Q"); else if (ascii_strcasecmp ("read", s) == 0) - strfcpy (s, "~R", len); + m_strcpy(s, len, "~R"); else if (ascii_strcasecmp ("tag", s) == 0) - strfcpy (s, "~T", len); + m_strcpy(s, len, "~T"); else if (ascii_strcasecmp ("unread", s) == 0) - strfcpy (s, "~U", len); + m_strcpy(s, len, "~U"); else { quote_simple (tmp, sizeof (tmp), s); mutt_expand_fmt (s, len, simple, tmp); @@ -1203,7 +1203,7 @@ int mutt_pattern_func (int op, char *prompt) BUFFER err; int i; - strfcpy (buf, NONULL (Context->pattern), sizeof (buf)); + m_strcpy(buf, sizeof(buf), NONULL(Context->pattern)); if (prompt || op != M_LIMIT) if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0]) return (-1); @@ -1311,7 +1311,7 @@ int mutt_search_command (int cur, int op) HEADER *h; if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE) { - strfcpy (buf, LastSearch, sizeof (buf)); + m_strcpy(buf, sizeof(buf), LastSearch); if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") : _("Reverse search for: "), buf, sizeof (buf), M_CLEAR | M_PATTERN) != 0 || !buf[0]) @@ -1324,12 +1324,12 @@ 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)); + m_strcpy(temp, sizeof(temp), buf); mutt_check_simple (temp, sizeof (temp), NONULL (SimpleSearch)); if (!SearchPattern || m_strcmp(temp, LastSearchExpn)) { set_option (OPTSEARCHINVALID); - strfcpy (LastSearch, buf, sizeof (LastSearch)); + m_strcpy(LastSearch, sizeof(LastSearch), buf); mutt_message _("Compiling search pattern..."); mutt_pattern_free (&SearchPattern); diff --git a/pgpkey.c b/pgpkey.c index 2411ee9..a4689ab 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -648,7 +648,7 @@ pgp_key_t pgp_ask_for_key (char *tag, char *whatfor, for (l = id_defaults; l; l = l->next) if (!m_strcasecmp(whatfor, l->what)) { - strfcpy (resp, NONULL (l->dflt), sizeof (resp)); + m_strcpy(resp, sizeof(resp), NONULL(l->dflt)); break; } } diff --git a/pgppubring.c b/pgppubring.c index 6d3fc5c..da1e4cd 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -125,10 +125,10 @@ int main (int argc, char *const argv[]) } if (_kring) - strfcpy (kring, _kring, sizeof (kring)); + m_strcpy(kring, sizeof(kring), _kring); else { if ((env_pgppath = getenv ("PGPPATH"))) - strfcpy (pgppath, env_pgppath, sizeof (pgppath)); + m_strcpy(pgppath, sizeof(pgppath), env_pgppath); else if ((env_home = getenv ("HOME"))) snprintf (pgppath, sizeof (pgppath), "%s/.pgp", env_home); else { diff --git a/pop/pop.c b/pop/pop.c index 365b772..bba466f 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -455,7 +455,7 @@ pop_query_status pop_sync_mailbox (CONTEXT * ctx, int unused, int *index_hint) } if (ret == PQ_OK) { - strfcpy (buf, "QUIT\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "QUIT\r\n"); ret = pop_query (pop_data, buf, sizeof (buf)); } @@ -558,7 +558,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)); + m_strcpy(buffer, sizeof(buffer), "STAT\r\n"); ret = pop_query (pop_data, buffer, sizeof (buffer)); if (ret == PQ_NOT_CONNECTED) goto fail; @@ -571,7 +571,7 @@ void pop_fetch_mail (void) /* only get unread messages */ if (msgs > 0 && option (OPTPOPLAST)) { - strfcpy (buffer, "LAST\r\n", sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), "LAST\r\n"); ret = pop_query (pop_data, buffer, sizeof (buffer)); if (ret == PQ_NOT_CONNECTED) goto fail; @@ -640,14 +640,14 @@ void pop_fetch_mail (void) if (rset) { /* make sure no messages get deleted */ - strfcpy (buffer, "RSET\r\n", sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), "RSET\r\n"); if (pop_query (pop_data, buffer, sizeof (buffer)) == PQ_NOT_CONNECTED) goto fail; } finish: /* exit gracefully */ - strfcpy (buffer, "QUIT\r\n", sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), "QUIT\r\n"); if (pop_query (pop_data, buffer, sizeof (buffer)) == PQ_NOT_CONNECTED) goto fail; mutt_socket_close (conn); diff --git a/pop/pop_auth.c b/pop/pop_auth.c index 2c4deb2..fdea7c3 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -82,7 +82,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) /* looping protocol */ for (;;) { - strfcpy (buf + olen, "\r\n", sizeof (buf) - olen); + m_strcpy(buf + olen, sizeof(buf) - olen, "\r\n"); mutt_socket_write (pop_data->conn, buf); if (mutt_socket_readln (inbuf, sizeof (inbuf), pop_data->conn) < 0) { sasl_dispose (&saslconn); diff --git a/pop/pop_lib.c b/pop/pop_lib.c index d32bf37..763dffc 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -75,7 +75,7 @@ void pop_error (POP_DATA * pop_data, char *msg) c = c2; } - strfcpy (t, c, sizeof (pop_data->err_msg) - strlen (pop_data->err_msg)); + m_strcpy(t, sizeof(pop_data->err_msg) - strlen(pop_data->err_msg), c); str_skip_trailws (pop_data->err_msg); } @@ -153,7 +153,7 @@ static pop_query_status pop_capabilities (POP_DATA * pop_data, int mode) /* Execute CAPA command */ if (mode == 0 || pop_data->cmd_capa != CMD_NOT_AVAILABLE) { - strfcpy (buf, "CAPA\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "CAPA\r\n"); switch (pop_fetch_data (pop_data, buf, NULL, fetch_capa, pop_data)) { case PQ_OK: { @@ -177,7 +177,7 @@ static pop_query_status pop_capabilities (POP_DATA * pop_data, int mode) pop_data->cmd_uidl = CMD_UNKNOWN; pop_data->cmd_top = CMD_UNKNOWN; - strfcpy (buf, "AUTH\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "AUTH\r\n"); if (pop_fetch_data (pop_data, buf, NULL, fetch_auth, pop_data) == PQ_NOT_CONNECTED) return PQ_NOT_CONNECTED; } @@ -276,7 +276,7 @@ pop_query_status pop_open_connection (POP_DATA * pop_data) pop_data->use_stls = 2; } if (pop_data->use_stls == 2) { - strfcpy (buf, "STLS\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "STLS\r\n"); ret = pop_query (pop_data, buf, sizeof (buf)); if (ret == PQ_NOT_CONNECTED) goto err_conn; @@ -330,7 +330,7 @@ pop_query_status pop_open_connection (POP_DATA * pop_data) } /* get total size of mailbox */ - strfcpy (buf, "STAT\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "STAT\r\n"); ret = pop_query (pop_data, buf, sizeof (buf)); if (ret == PQ_NOT_CONNECTED) goto err_conn; @@ -363,12 +363,12 @@ void pop_logout (CONTEXT * ctx) mutt_message _("Closing connection to POP server..."); if (ctx->readonly) { - strfcpy (buf, "RSET\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "RSET\r\n"); ret = pop_query (pop_data, buf, sizeof (buf)); } if (ret != PQ_NOT_CONNECTED) { - strfcpy (buf, "QUIT\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "QUIT\r\n"); pop_query (pop_data, buf, sizeof (buf)); } @@ -438,7 +438,7 @@ pop_query_status pop_fetch_data (POP_DATA * pop_data, const char *query, progres long pos = 0; size_t lenbuf = 0; - strfcpy (buf, query, sizeof (buf)); + m_strcpy(buf, sizeof(buf), query); ret = pop_query (pop_data, buf, sizeof (buf)); if (ret != PQ_OK) return ret; @@ -462,7 +462,7 @@ pop_query_status pop_fetch_data (POP_DATA * pop_data, const char *query, progres p++; } - strfcpy(inbuf + lenbuf, p, sizeof(buf)); + m_strcpy(inbuf + lenbuf,sizeof(buf), p); pos += chunk; if (chunk >= sizeof (buf)) { diff --git a/postpone.c b/postpone.c index 8d020d2..d37f043 100644 --- a/postpone.c +++ b/postpone.c @@ -320,7 +320,7 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, else if (ascii_strncasecmp ("X-Mutt-Fcc:", tmp->data, 11) == 0) { p = tmp->data + 11; SKIPWS (p); - strfcpy (fcc, p, fcclen); + m_strcpy(fcc, fcclen, p); mutt_pretty_mailbox (fcc); /* remove the X-Mutt-Fcc: header field */ @@ -611,7 +611,7 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr, file[0] = '\0'; if (b->filename) { - strfcpy (file, b->filename, sizeof (file)); + m_strcpy(file, sizeof(file), b->filename); b->d_filename = m_strdup(b->filename); } else { diff --git a/recvattach.c b/recvattach.c index 157e93e..cc093f5 100644 --- a/recvattach.c +++ b/recvattach.c @@ -262,7 +262,7 @@ const char *mutt_attach_fmt (char *dest, if (aptr->content->filename && *aptr->content->filename == '/') { char path[_POSIX_PATH_MAX]; - strfcpy (path, aptr->content->filename, sizeof (path)); + m_strcpy(path, sizeof(path), aptr->content->filename); mutt_pretty_mailbox (path); mutt_format_s (dest, destlen, prefix, path); } @@ -412,7 +412,7 @@ static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr, mutt_concat_path(buf, sizeof(buf), *directory, mutt_basename(body->filename)); else - strfcpy (buf, body->filename, sizeof (buf)); + m_strcpy(buf, sizeof(buf), body->filename); } else if (body->hdr && body->encoding != ENCBASE64 && @@ -434,7 +434,7 @@ static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr, char tmpbuf[_POSIX_PATH_MAX]; snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf); - strfcpy (buf, tmpbuf, sizeof (buf)); + m_strcpy(buf, sizeof(buf), tmpbuf); ret = mutt_get_field (_("Save to file: ") , buf, sizeof (buf), M_FILE); if ((ret != 0) || (!buf[0])) @@ -442,7 +442,7 @@ static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr, } else { mutt_extract_path (buf, path); - strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder)); + m_strcpy(LastSaveFolder, sizeof(LastSaveFolder), path); } prompt = NULL; @@ -464,7 +464,7 @@ static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr, } else if (rc == -1) return -1; - strfcpy (tfile, buf, sizeof (tfile)); + m_strcpy(tfile, sizeof(tfile), buf); } else { if ((rc = @@ -511,7 +511,7 @@ void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr, if (!buf[0]) { int append = 0; - strfcpy (buf, NONULL (top->filename), sizeof (buf)); + m_strcpy(buf, sizeof(buf), NONULL(top->filename)); if (mutt_get_field (_("Save to file: "), buf, sizeof (buf), M_FILE | M_CLEAR) != 0 || !buf[0]) return; diff --git a/recvcmd.c b/recvcmd.c index dff5aee..5e159ce 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -136,9 +136,9 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr, p = (cur || count_tagged (idx, idxlen) == 1); if (p) - strfcpy (prompt, _("Bounce message to: "), sizeof (prompt)); + m_strcpy(prompt, sizeof(prompt), _("Bounce message to: ")); else - strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt)); + m_strcpy(prompt, sizeof(prompt), _("Bounce tagged messages to: ")); buf[0] = '\0'; if (mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS) @@ -316,12 +316,12 @@ static void include_header (int quote, FILE * ifp, if (quote) { if (_prefix) - strfcpy (prefix, _prefix, sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), _prefix); else if (!option (OPTTEXTFLOWED)) _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context, hdr, 0); else - strfcpy (prefix, ">", sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), ">"); chflags |= CH_PREFIX; } @@ -406,7 +406,7 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr, _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context, parent, 0); else - strfcpy (prefix, ">", sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), ">"); } include_header (option (OPTFORWQUOTE), fp, parent, tmpfp, prefix); @@ -838,7 +838,7 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr, _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context, parent, 0); else - strfcpy (prefix, ">", sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), ">"); st.prefix = prefix; st.flags = M_CHARCONV; diff --git a/remailer.c b/remailer.c index 428e1ba..ffa19a3 100644 --- a/remailer.c +++ b/remailer.c @@ -722,7 +722,7 @@ int mix_send_message (LIST * chain, const char *tempfile) snprintf (cmd, sizeof (cmd), "cat %s | %s -m ", tempfile, Mixmaster); for (i = 0; chain; chain = chain->next, i = 1) { - strfcpy (tmp, cmd, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), cmd); mutt_quote_filename (cd_quoted, sizeof (cd_quoted), (char *) chain->data); snprintf (cmd, sizeof (cmd), "%s%s%s", tmp, i ? "," : " -l ", cd_quoted); } diff --git a/rfc1524.c b/rfc1524.c index 882f583..5a843f8 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -63,7 +63,7 @@ int rfc1524_expand_command (BODY * a, char *filename, char *_type, char buf[LONG_STRING]; char type[LONG_STRING]; - strfcpy (type, _type, sizeof (type)); + m_strcpy(type, sizeof(type), _type); if (option (OPTMAILCAPSANITIZE)) mutt_sanitize_filename (type, 0); @@ -87,7 +87,7 @@ int rfc1524_expand_command (BODY * a, char *filename, char *_type, param[z] = '\0'; _pvalue = mutt_get_parameter (param, a->parameter); - strfcpy (pvalue, NONULL (_pvalue), sizeof (pvalue)); + m_strcpy(pvalue, sizeof(pvalue), NONULL(_pvalue)); if (option (OPTMAILCAPSANITIZE)) mutt_sanitize_filename (pvalue, 0); @@ -106,7 +106,7 @@ int rfc1524_expand_command (BODY * a, char *filename, char *_type, buf[y++] = command[x++]; } buf[y] = '\0'; - strfcpy (command, buf, clen); + m_strcpy(command, clen, buf); return needspipe; } @@ -407,7 +407,7 @@ static void strnfcpy (char *d, char *s, size_t siz, size_t len) { if (len > siz) len = siz - 1; - strfcpy (d, s, len); + m_strcpy(d, len, s); } int rfc1524_expand_filename (char *nametemplate, @@ -432,7 +432,7 @@ int rfc1524_expand_filename (char *nametemplate, if (!nametemplate) { if (oldfile) - strfcpy (newfile, oldfile, nflen); + m_strcpy(newfile, nflen, oldfile); } else if (!oldfile) { mutt_expand_fmt (newfile, nflen, nametemplate, "mutt"); @@ -499,13 +499,13 @@ int rfc1524_expand_filename (char *nametemplate, if (rmatch) *right = 0; else - strfcpy (right, nametemplate + i + 2, sizeof (right)); + m_strcpy(right, sizeof(right), nametemplate + i + 2); snprintf (newfile, nflen, "%s%s%s", left, oldfile, right); } else { /* no "%s" in the name template. */ - strfcpy (newfile, nametemplate, nflen); + m_strcpy(newfile, nflen, nametemplate); } } diff --git a/rfc2047.c b/rfc2047.c index 3769fef..0b35cf7 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -619,7 +619,7 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) if (charset) mutt_convert_string (&d0, charset, Charset, M_ICONV_HOOK_FROM); - strfcpy (d, d0, len); + m_strcpy(d, len, d0); p_delete(&charset); p_delete(&d0); return (0); diff --git a/rfc2231.c b/rfc2231.c index 93058dd..0f9a2f5 100644 --- a/rfc2231.c +++ b/rfc2231.c @@ -187,7 +187,7 @@ static char *rfc2231_get_charset (char *value, char *charset, size_t chslen) } *t = '\0'; - strfcpy (charset, value, chslen); + m_strcpy(charset, chslen, value); if ((u = strchr (t + 1, '\''))) return u + 1; @@ -259,7 +259,7 @@ static void rfc2231_join_continuations (PARAMETER ** head, value = NULL; l = 0; - strfcpy (attribute, par->attribute, sizeof (attribute)); + m_strcpy(attribute, sizeof(attribute), par->attribute); if ((encoded = par->encoded)) valp = rfc2231_get_charset (par->value, charset, sizeof (charset)); diff --git a/rfc822.c b/rfc822.c index f0d9b00..cbe5ba4 100644 --- a/rfc822.c +++ b/rfc822.c @@ -473,10 +473,10 @@ rfc822_cat (char *buf, size_t buflen, const char *value, const char *specials) } *pc++ = '"'; *pc = 0; - strfcpy (buf, tmp, buflen); + m_strcpy(buf, buflen, tmp); } else - strfcpy (buf, value, buflen); + m_strcpy(buf, buflen, value); } void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS * addr, @@ -517,7 +517,7 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS * addr, else { if (!buflen) goto done; - strfcpy (pbuf, addr->personal, buflen); + m_strcpy(pbuf, buflen, addr->personal); len = m_strlen(pbuf); pbuf += len; buflen -= len; @@ -540,11 +540,11 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS * addr, if (!buflen) goto done; if (ascii_strcmp (addr->mailbox, "@") && !display) { - strfcpy (pbuf, addr->mailbox, buflen); + m_strcpy(pbuf, buflen, addr->mailbox); len = m_strlen(pbuf); } else if (ascii_strcmp (addr->mailbox, "@") && display) { - strfcpy (pbuf, mutt_addr_for_display (addr), buflen); + m_strcpy(pbuf, buflen, mutt_addr_for_display(addr)); len = m_strlen(pbuf); } else { diff --git a/score.c b/score.c index 24cad59..aae4e0a 100644 --- a/score.c +++ b/score.c @@ -64,7 +64,7 @@ int mutt_parse_score (BUFFER * buf, BUFFER * s, unsigned long data, mutt_extract_token (buf, s, 0); if (!MoreArgs (s)) { - strfcpy (err->data, _("score: too few arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("score: too few arguments")); return (-1); } pattern = buf->data; @@ -72,7 +72,7 @@ int mutt_parse_score (BUFFER * buf, BUFFER * s, unsigned long data, mutt_extract_token (buf, s, 0); if (MoreArgs (s)) { p_delete(&pattern); - strfcpy (err->data, _("score: too many arguments"), err->dsize); + m_strcpy(err->data, err->dsize, _("score: too many arguments")); return (-1); } diff --git a/send.c b/send.c index 4bf3b74..c827e7e 100644 --- a/send.c +++ b/send.c @@ -214,7 +214,7 @@ static int edit_envelope (ENVELOPE * en, int flags) #ifdef USE_NNTP if (option (OPTNEWSSEND)) { if (en->newsgroups) - strfcpy (buf, en->newsgroups, sizeof (buf)); + m_strcpy(buf, sizeof(buf), en->newsgroups); else buf[0] = 0; if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0) @@ -223,7 +223,7 @@ static int edit_envelope (ENVELOPE * en, int flags) en->newsgroups = m_strdup(buf); if (en->followup_to) - strfcpy (buf, en->followup_to, sizeof (buf)); + m_strcpy(buf, sizeof(buf), en->followup_to); else buf[0] = 0; if (option (OPTASKFOLLOWUP) @@ -233,7 +233,7 @@ static int edit_envelope (ENVELOPE * en, int flags) en->followup_to = m_strdup(buf); if (en->x_comment_to) - strfcpy (buf, en->x_comment_to, sizeof (buf)); + m_strcpy(buf, sizeof(buf), en->x_comment_to); else buf[0] = 0; if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) @@ -257,7 +257,7 @@ static int edit_envelope (ENVELOPE * en, int flags) if (option (OPTFASTREPLY)) return (0); else - strfcpy (buf, en->subject, sizeof (buf)); + m_strcpy(buf, sizeof(buf), en->subject); } else { char *p; diff --git a/sendlib.c b/sendlib.c index add4d74..1daf044 100644 --- a/sendlib.c +++ b/sendlib.c @@ -122,15 +122,15 @@ static void encode_quoted (FGETCONV * fc, FILE * fout, int istext) /* Escape lines that begin with/only contain "the message separator". */ if (linelen == 4 && !m_strncmp("From", line, 4)) { - strfcpy (line, "=46rom", sizeof (line)); + m_strcpy(line, sizeof(line), "=46rom"); linelen = 6; } else if (linelen == 4 && !m_strncmp("from", line, 4)) { - strfcpy (line, "=66rom", sizeof (line)); + m_strcpy(line, sizeof(line), "=66rom"); linelen = 6; } else if (linelen == 1 && line[0] == '.') { - strfcpy (line, "=2E", sizeof (line)); + m_strcpy(line, sizeof(line), "=2E"); linelen = 3; } @@ -396,7 +396,7 @@ int mutt_write_mime_body (BODY * a, FILE * f) return (-1); } - strfcpy (boundary, p, sizeof (boundary)); + m_strcpy(boundary, sizeof(boundary), p); for (t = a->parts; t; t = t->next) { fprintf (f, "\n--%s\n", boundary); @@ -904,13 +904,13 @@ int mutt_lookup_mime_type (BODY * att, const char *path) snprintf (buf, sizeof (buf), "%s/.mime.types", NONULL (Homedir)); break; case 1: - strfcpy (buf, SYSCONFDIR "/muttng-mime.types", sizeof (buf)); + m_strcpy(buf, sizeof(buf), SYSCONFDIR "/muttng-mime.types"); break; case 2: - strfcpy (buf, PKGDATADIR "/mime.types", sizeof (buf)); + m_strcpy(buf, sizeof(buf), PKGDATADIR "/mime.types"); break; case 3: - strfcpy (buf, SYSCONFDIR "/mime.types", sizeof (buf)); + m_strcpy(buf, sizeof(buf), SYSCONFDIR "/mime.types"); break; default: debug_print (1, ("Internal error, count = %d.\n", count)); @@ -958,7 +958,7 @@ int mutt_lookup_mime_type (BODY * att, const char *path) str_substrcpy (subtype, p, q, sizeof (subtype)); if ((type = mutt_check_mime_type (ct)) == TYPEOTHER) - strfcpy (xtype, ct, sizeof (xtype)); + m_strcpy(xtype, sizeof(xtype), ct); cur_sze = sze; } @@ -1162,7 +1162,7 @@ char *mutt_get_body_charset (char *d, size_t dlen, BODY * b) if (p) mutt_canonical_charset (d, dlen, NONULL (p)); else - strfcpy (d, "us-ascii", dlen); + m_strcpy(d, dlen, "us-ascii"); return d; } diff --git a/smime.c b/smime.c index 6a2486d..a5d2fbc 100644 --- a/smime.c +++ b/smime.c @@ -148,7 +148,7 @@ static const char *_mutt_fmt_smime_command (char *dest, char buf1[LONG_STRING], buf2[LONG_STRING]; struct stat sb; - strfcpy (path, NONULL (SmimeCALocation), sizeof (path)); + m_strcpy(path, sizeof(path), NONULL(SmimeCALocation)); mutt_expand_path (path, sizeof (path)); mutt_quote_filename (buf1, sizeof (buf1), path); @@ -553,7 +553,7 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, continue; } else if (choice == M_YES) { - strfcpy (key, fields[1], sizeof (key)); + m_strcpy(key, sizeof(key), fields[1]); ask = 0; break; } @@ -561,7 +561,7 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, else { if (public) key_trust_level = *fields[4]; - strfcpy (key, fields[1], sizeof (key)); + m_strcpy(key, sizeof(key), fields[1]); } found = 1; } @@ -577,13 +577,13 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, if (numFields >= 3 && !(m_strncasecmp(query, fields[2], query_len))) { ask = 0; - strfcpy (key, fields[1], sizeof (key)); + m_strcpy(key, sizeof(key), fields[1]); } /* query = certificate: return intermediate certificate. */ else if (numFields >= 4 && !(m_strncasecmp(query, fields[1], query_len))) { ask = 0; - strfcpy (key, fields[3], sizeof (key)); + m_strcpy(key, sizeof(key), fields[3]); } } diff --git a/status.c b/status.c index bab4295..86de939 100644 --- a/status.c +++ b/status.c @@ -84,20 +84,20 @@ static const char *status_format_str (char *buf, size_t buflen, char op, #ifdef USE_COMPRESSED if (Context && Context->compressinfo && Context->realpath) { if ((p = strrchr (Context->realpath, '/'))) - strfcpy (tmp, p + 1, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), p + 1); else - strfcpy (tmp, Context->realpath, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), Context->realpath); } else #endif if (Context && Context->path) { if ((p = strrchr (Context->path, '/'))) - strfcpy (tmp, p + 1, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), p + 1); else - strfcpy (tmp, Context->path, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), Context->path); } else - strfcpy (tmp, _("no mailbox"), sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), _("no mailbox")); snprintf (buf, buflen, fmt, tmp); break; @@ -119,17 +119,17 @@ static const char *status_format_str (char *buf, size_t buflen, char op, snprintf (fmt, sizeof (fmt), "%%%ss", prefix); #ifdef USE_COMPRESSED if (Context && Context->compressinfo && Context->realpath) { - strfcpy (tmp, Context->realpath, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), Context->realpath); mutt_pretty_mailbox (tmp); } else #endif if (Context && Context->path) { - strfcpy (tmp, Context->path, sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), Context->path); mutt_pretty_mailbox (tmp); } else - strfcpy (tmp, _("(no mailbox)"), sizeof (tmp)); + m_strcpy(tmp, sizeof(tmp), _("(no mailbox)")); snprintf (buf, buflen, fmt, tmp); break; diff --git a/thread.c b/thread.c index 6d2b649..ee923b1 100644 --- a/thread.c +++ b/thread.c @@ -244,11 +244,11 @@ void mutt_draw_tree (CONTEXT * ctx) new_tree = p_new(char, (2 + depth * width)); if (start_depth > 1) { memcpy(new_tree, pfx, (start_depth - 1) * width); - strfcpy (new_tree + (start_depth - 1) * width, - arrow, (1 + depth - start_depth) * width + 2); + m_strcpy(new_tree + (start_depth - 1) * width, + (1 + depth - start_depth) * width + 2, arrow); } else - strfcpy (new_tree, arrow, 2 + depth * width); + m_strcpy(new_tree, 2 + depth * width, arrow); tree->message->tree = new_tree; } } diff --git a/url.c b/url.c index 8a00cdd..c889b2e 100644 --- a/url.c +++ b/url.c @@ -73,7 +73,7 @@ url_scheme_t url_check_scheme (const char *s) if ((t - s) + 1 >= sizeof (sbuf)) return U_UNKNOWN; - strfcpy (sbuf, s, t - s + 1); + m_strcpy(sbuf, t - s + 1, s); for (t = sbuf; *t; t++) *t = ascii_tolower (*t); @@ -90,7 +90,7 @@ int url_parse_file (char *d, const char *src, size_t dl) else if (!ascii_strncasecmp (src, "file://", 7)) /* we don't support remote files */ return -1; else - strfcpy (d, src + 5, dl); + m_strcpy(d, dl, src + 5); url_pct_decode (d); return 0; -- 2.20.1