#endif
if (a1->flags & a2->flags & M_ACCT_USER)
- return (!mutt_strcmp (a1->user, a2->user));
+ return (!str_cmp (a1->user, a2->user));
if (a1->flags & M_ACCT_USER)
- return (!mutt_strcmp (a1->user, user));
+ return (!str_cmp (a1->user, user));
if (a2->flags & M_ACCT_USER)
- return (!mutt_strcmp (a2->user, user));
+ return (!str_cmp (a2->user, user));
return 1;
}
{
ALIAS *pa = *(ALIAS **) a;
ALIAS *pb = *(ALIAS **) b;
- int r = safe_strcasecmp (pa->name, pb->name);
+ int r = str_casecmp (pa->name, pb->name);
return (RSORT (r));
}
r = 1;
else if (pa->personal) {
if (pb->personal)
- r = safe_strcasecmp (pa->personal, pb->personal);
+ r = str_casecmp (pa->personal, pb->personal);
else
r = 1;
}
ALIAS *t = Aliases;
for (; t; t = t->next)
- if (!safe_strcasecmp (s, t->name))
+ if (!str_casecmp (s, t->name))
return (t->addr);
return (NULL); /* no such alias */
}
if (t) {
i = 0;
for (u = *expn; u; u = u->next) {
- if (mutt_strcmp (a->mailbox, u->data) == 0) { /* alias already found */
+ if (str_cmp (a->mailbox, u->data) == 0) { /* alias already found */
debug_print(1, ("loop in alias found for '%s'\n", a->mailbox));
i = 1;
break;
if (!i) {
u = safe_malloc (sizeof (LIST));
- u->data = safe_strdup (a->mailbox);
+ u->data = str_dup (a->mailbox);
u->next = *expn;
*expn = u;
w = rfc822_cpy_adr (t);
new = safe_calloc (1, sizeof (ALIAS));
new->self = new;
- new->name = safe_strdup (buf);
+ new->name = str_dup (buf);
mutt_addrlist_to_local (adr);
mutt_free_alias (&new);
return;
}
- new->addr->personal = safe_strdup (buf);
+ new->addr->personal = str_dup (buf);
buf[0] = 0;
rfc822_write_address (buf, sizeof (buf), new->addr, 1);
if (a->name && strstr (a->name, s) == a->name) {
if (!bestname[0]) /* init */
strfcpy (bestname, a->name,
- min (mutt_strlen (a->name) + 1, sizeof (bestname)));
+ min (str_len (a->name) + 1, sizeof (bestname)));
else {
for (i = 0; a->name[i] && a->name[i] == bestname[i]; i++);
bestname[i] = 0;
}
if (bestname[0] != 0) {
- if (mutt_strcmp (bestname, s) != 0) {
+ if (str_cmp (bestname, s) != 0) {
/* we are adding something to the completion */
- strfcpy (s, bestname, mutt_strlen (bestname) + 1);
+ strfcpy (s, bestname, str_len (bestname) + 1);
return 1;
}
int ascii_strcasecmp (const char *a, const char *b);
int ascii_strncasecmp (const char *a, const char *b, int n);
-#define ascii_strcmp(a,b) mutt_strcmp(a,b)
-#define ascii_strncmp(a,b,c) safe_strncmp(a,b,c)
+#define ascii_strcmp(a,b) str_cmp(a,b)
+#define ascii_strncmp(a,b,c) str_ncmp(a,b,c)
#endif
int lng;
if ((p = getenv ("MM_NOASK")) != NULL && *p) {
- if (mutt_strcmp (p, "1") == 0)
+ if (str_cmp (p, "1") == 0)
return (1);
strfcpy (tmp, p, sizeof (tmp));
}
}
else {
- lng = mutt_strlen (p);
- if (buf[lng] == '/' && safe_strncasecmp (buf, p, lng) == 0)
+ lng = str_len (p);
+ if (buf[lng] == '/' && str_ncasecmp (buf, p, lng) == 0)
return (1);
}
int i;
for (; t; t = t->next) {
- i = mutt_strlen (t->data) - 1;
+ i = str_len (t->data) - 1;
if ((i > 0 && t->data[i - 1] == '/' && t->data[i] == '*' &&
ascii_strncasecmp (type, t->data, i) == 0) ||
ascii_strcasecmp (type, t->data) == 0) {
}
for (; t; t = t->next) {
- i = mutt_strlen (t->data) - 1;
+ i = str_len (t->data) - 1;
if ((i > 0 && t->data[i - 1] == '/' && t->data[i] == '*' &&
ascii_strncasecmp (type, t->data, i) == 0) ||
ascii_strcasecmp (type, t->data) == 0)
strfcpy (command, entry->command, sizeof (command));
if (fp) {
- fname = safe_strdup (a->filename);
+ fname = str_dup (a->filename);
mutt_sanitize_filename (fname, 1);
}
else
if (rfc1524_expand_filename (entry->nametemplate, fname,
tempfile, sizeof (tempfile))) {
- if (fp == NULL && mutt_strcmp (tempfile, a->filename)) {
+ if (fp == NULL && str_cmp (tempfile, a->filename)) {
/* send case: the file is already there */
if (safe_symlink (a->filename, tempfile) == -1) {
if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES)
struct folder_file *pa = (struct folder_file *) a;
struct folder_file *pb = (struct folder_file *) b;
- int r = safe_strcoll (pa->name, pb->name);
+ int r = str_coll (pa->name, pb->name);
return ((BrowserSort & SORT_REVERSE) ? -r : r);
}
}
(state->entry)[state->entrylen].new = new;
- (state->entry)[state->entrylen].name = safe_strdup (name);
- (state->entry)[state->entrylen].desc = safe_strdup (name);
+ (state->entry)[state->entrylen].name = str_dup (name);
+ (state->entry)[state->entrylen].desc = str_dup (name);
#ifdef USE_IMAP
(state->entry)[state->entrylen].imap = 0;
#endif
if (!(data = (NNTP_DATA *) tmp->data))
continue;
if (prefix && *prefix && strncmp (prefix, data->group,
- mutt_strlen (prefix)) != 0)
+ str_len (prefix)) != 0)
continue;
if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
continue;
init_state (state, menu);
while ((de = readdir (dp)) != NULL) {
- if (mutt_strcmp (de->d_name, ".") == 0)
+ if (str_cmp (de->d_name, ".") == 0)
continue; /* we don't need . */
if (prefix && *prefix
- && safe_strncmp (prefix, de->d_name, mutt_strlen (prefix)) != 0)
+ && str_ncmp (prefix, de->d_name, str_len (prefix)) != 0)
continue;
if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
continue;
}
else {
#endif
- for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/'; i--);
+ for (i = str_len (f) - 1; i > 0 && f[i] != '/'; i--);
if (i > 0) {
if (f[0] == '/') {
if (i > sizeof (LastDir) - 1)
}
else {
getcwd (LastDir, sizeof (LastDir));
- safe_strcat (LastDir, sizeof (LastDir), "/");
- safe_strncat (LastDir, sizeof (LastDir), f, i);
+ str_cat (LastDir, sizeof (LastDir), "/");
+ str_ncat (LastDir, sizeof (LastDir), f, i);
}
}
else {
/* save the old directory */
strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
- if (mutt_strcmp (state.entry[menu->current].name, "..") == 0) {
- if (mutt_strcmp ("..", LastDir + mutt_strlen (LastDir) - 2) == 0)
+ if (str_cmp (state.entry[menu->current].name, "..") == 0) {
+ if (str_cmp ("..", LastDir + str_len (LastDir) - 2) == 0)
strcat (LastDir, "/.."); /* __STRCAT_CHECKED__ */
else {
char *p = strrchr (LastDir + 1, '/');
strfcpy (LastDir, state.entry[menu->current].name,
sizeof (LastDir));
/* tack on delimiter here */
- n = mutt_strlen (LastDir) + 1;
+ n = str_len (LastDir) + 1;
/* special case "" needs no delimiter */
url_parse_ciss (&url, state.entry[menu->current].name);
if (ff.tagged) {
mutt_concat_path (full, LastDir, ff.name, sizeof (full));
mutt_expand_path (full, sizeof (full));
- tfiles[j++] = safe_strdup (full);
+ tfiles[j++] = str_dup (full);
}
}
*files = tfiles;
*numfiles = 1;
tfiles = safe_calloc (*numfiles, sizeof (char *));
mutt_expand_path (f, flen);
- tfiles[0] = safe_strdup (f);
+ tfiles[0] = str_dup (f);
*files = tfiles;
}
}
#endif
{
/* add '/' at the end of the directory name if not already there */
- int len = mutt_strlen (LastDir);
+ int len = str_len (LastDir);
if (len && LastDir[len - 1] != '/' && sizeof (buf) > len)
buf[len] = '/';
mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
newsgroup_format_str, (unsigned long) &folder,
M_FORMAT_ARROWCURSOR);
- f->desc = safe_strdup (buffer); */
+ f->desc = str_dup (buffer); */
if (menu->current + 1 < menu->max)
menu->current++;
menu->redraw = REDRAW_MOTION_RESYNCH;
mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
newsgroup_format_str, (unsigned long) &folder,
M_FORMAT_ARROWCURSOR);
- f->desc = safe_strdup (buffer);
+ f->desc = str_dup (buffer);
} */
}
if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) {
* reads will be on block boundaries, which might increase efficiency. */
while ((pos -= bytes_read) >= 0) {
/* we save in the buffer at the end the first 7 chars from the last read */
- strncpy (buffer + BUFSIZ, buffer, 5 + 2); /* 2 == 2 * mutt_strlen(CRLF) */
+ strncpy (buffer + BUFSIZ, buffer, 5 + 2); /* 2 == 2 * str_len(CRLF) */
fseek (f, pos, SEEK_SET);
bytes_read = fread (buffer, sizeof (char), bytes_read, f);
if (bytes_read == -1)
return -1;
for (i = bytes_read; --i >= 0;)
- if (!safe_strncmp (buffer + i, "\n\nFrom ", mutt_strlen ("\n\nFrom "))) { /* found it - go to the beginning of the From */
+ if (!str_ncmp (buffer + i, "\n\nFrom ", str_len ("\n\nFrom "))) { /* found it - go to the beginning of the From */
fseek (f, pos + i + 2, SEEK_SET);
return 0;
}
}
/* here we are at the beginning of the file */
- if (!safe_strncmp ("From ", buffer, 5)) {
+ if (!str_ncmp ("From ", buffer, 5)) {
fseek (f, 0, 0);
return (0);
}
if (i < 0) {
tmp = safe_calloc (1, sizeof (BUFFY));
- tmp->path = safe_strdup (buf);
+ tmp->path = str_dup (buf);
tmp->magic = 0;
list_push_back (&Incoming, tmp);
i = Incoming->length-1;
pos = 0;
first = 1;
buffylist[0] = 0;
- pos += mutt_strlen (strncat (buffylist, _("New mail in "), sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
+ pos += str_len (strncat (buffylist, _("New mail in "), sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
if (Incoming) {
for (i = 0; i < Incoming->length; i++) {
tmp = (BUFFY*) Incoming->data[i];
strfcpy (path, tmp->path, sizeof (path));
mutt_pretty_mailbox (path);
- if (!first && pos + mutt_strlen (path) >= COLS - 7)
+ if (!first && pos + str_len (path) >= COLS - 7)
break;
if (!first)
- pos += mutt_strlen (strncat (buffylist + pos, ", ", sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
+ pos += str_len (strncat (buffylist + pos, ", ", sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
/* Prepend an asterisk to mailboxes not already notified */
if (!tmp->notified) {
- /* pos += mutt_strlen (strncat(buffylist + pos, "*", sizeof(buffylist)-1-pos)); __STRNCAT_CHECKED__ */
+ /* pos += str_len (strncat(buffylist + pos, "*", sizeof(buffylist)-1-pos)); __STRNCAT_CHECKED__ */
tmp->notified = 1;
BuffyNotify--;
}
- pos += mutt_strlen (strncat (buffylist + pos, path, sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
+ pos += str_len (strncat (buffylist + pos, path, sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
first = 0;
}
}
mutt_canonical_charset (buff2, sizeof (buff2), buff);
/* finally, set $charset */
- if (!(Charset = safe_strdup (buff2)))
- Charset = safe_strdup ("iso-8859-1");
+ if (!(Charset = str_dup (buff2)))
+ Charset = str_dup ("iso-8859-1");
}
#else
void mutt_set_langinfo_charset (void)
{
- Charset = safe_strdup ("iso-8859-1");
+ Charset = str_dup ("iso-8859-1");
}
#endif
for (i = 0; PreferredMIMENames[i].key; i++)
if (!ascii_strcasecmp (scratch, PreferredMIMENames[i].key) ||
- !safe_strcasecmp (scratch, PreferredMIMENames[i].key)) {
+ !str_casecmp (scratch, PreferredMIMENames[i].key)) {
strfcpy (dest, PreferredMIMENames[i].pref, dlen);
return;
}
for (t = inrepls; *t; t++) {
ICONV_CONST char *ib1 = *t;
- size_t ibl1 = mutt_strlen (*t);
+ size_t ibl1 = str_len (*t);
char *ob1 = ob;
size_t obl1 = obl;
outrepl = "?";
iconv (cd, 0, 0, &ob, &obl);
if (obl) {
- int n = mutt_strlen (outrepl);
+ int n = str_len (outrepl);
if (n > obl) {
outrepl = "?";
else
outrepl = "?";
- len = mutt_strlen (s);
+ len = str_len (s);
ib = s, ibl = len + 1;
obl = MB_LEN_MAX * ibl;
ob = buf = safe_malloc (obl + 1);
const char *c, *c1;
c = charset;
- if (!mutt_strlen (c))
+ if (!str_len (c))
return "us-ascii";
if (!(c1 = strchr (c, ':')))
return ((char*) charset);
char *s;
char *fromcode;
size_t m, n;
- size_t ulen = mutt_strlen (*ps);
+ size_t ulen = str_len (*ps);
size_t slen;
if (!u || !*u)
return 0;
c1 = strchr (c, ':');
- n = c1 ? c1 - c : mutt_strlen (c);
+ n = c1 ? c1 - c : str_len (c);
if (!n)
continue;
fromcode = safe_malloc (n + 1);
{
char *eptr;
- if (safe_strncasecmp (s, "bright", 6) == 0) {
+ if (str_ncasecmp (s, "bright", 6) == 0) {
*attr |= brite;
s += 6;
}
/* allow aliases for xterm color resources */
- if (safe_strncasecmp (s, "color", 5) == 0) {
+ if (str_ncasecmp (s, "color", 5) == 0) {
s += 5;
*col = strtol (s, &eptr, 10);
if (!*s || *eptr || *col < 0 ||
return (-1);
}
- if (safe_strncmp (buf->data, "index", 5) != 0) {
+ if (str_ncmp (buf->data, "index", 5) != 0) {
snprintf (err->data, err->dsize,
_("%s: command valid only for index object"),
parse_uncolor ? "uncolor" : "unmono");
do {
mutt_extract_token (buf, s, 0);
- if (!mutt_strcmp ("*", buf->data)) {
+ if (!str_cmp ("*", buf->data)) {
for (tmp = ColorIndexList; tmp;) {
if (!do_cache)
do_cache = 1;
else {
for (last = NULL, tmp = ColorIndexList; tmp;
last = tmp, tmp = tmp->next) {
- if (!mutt_strcmp (buf->data, tmp->pattern)) {
+ if (!str_cmp (buf->data, tmp->pattern)) {
if (!do_cache)
do_cache = 1;
debug_print (1, ("Freeing pattern \"%s\" from ColorIndexList\n", tmp->pattern));
while (tmp) {
if (sensitive) {
- if (mutt_strcmp (s, tmp->pattern) == 0)
+ if (str_cmp (s, tmp->pattern) == 0)
break;
}
else {
- if (safe_strcasecmp (s, tmp->pattern) == 0)
+ if (str_casecmp (s, tmp->pattern) == 0)
break;
}
tmp = tmp->next;
return (-1);
}
tmp->next = *top;
- tmp->pattern = safe_strdup (s);
+ tmp->pattern = str_dup (s);
#ifdef HAVE_COLOR
if (fg != -1 && bg != -1) {
tmp->fg = fg;
}
mutt_extract_token (buf, s, 0);
- if (!safe_strncmp (buf->data, "quoted", 6)) {
+ if (!str_ncmp (buf->data, "quoted", 6)) {
if (buf->data[6]) {
*ql = strtol (buf->data + 6, &eptr, 10);
if (*eptr || q_level < 0) {
}
}
- if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
+ if (!Pager || str_cmp (Pager, "builtin") == 0)
builtin = 1;
else {
mutt_make_string (buf, sizeof (buf), NONULL (PagerFmt), Context, cur);
mutt_format_string (prompt, sizeof (prompt),
0, COLS - extra_space, 0, 0,
prompt, sizeof (prompt), 0);
- safe_strcat (prompt, sizeof (prompt), "...?");
+ str_cat (prompt, sizeof (prompt), "...?");
}
else
- safe_strcat (prompt, sizeof (prompt), "?");
+ str_cat (prompt, sizeof (prompt), "?");
if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
rfc822_free_address (&adr);
/* This is an undocumented feature of ELM pointed out to me by Felix von
* Leitner <leitner@prz.fu-berlin.de>
*/
- if (mutt_strcmp (buf, ".") == 0)
+ if (str_cmp (buf, ".") == 0)
strfcpy (buf, LastSaveFolder, sizeof (buf));
else
strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder));
while (*c && *c != '\n')
c++;
c[0] = 0; /* strip EOL */
- if (!strncmp (buf, "#: ", 3) && !safe_strcasecmp (buf + 3, section))
+ if (!strncmp (buf, "#: ", 3) && !str_casecmp (buf + 3, section))
done++;
}
if (r != EOF && !done) {
done++;
break;
}
- else if (key && !strncmp (buf, key, mutt_strlen (key)) &&
- (!*key || buf[mutt_strlen (key)] == ' ')) {
+ else if (key && !strncmp (buf, key, str_len (key)) &&
+ (!*key || buf[str_len (key)] == ' ')) {
c = buf;
ext = 0;
while (*c && (*c != '\r') && (*c != '\n'))
size_t l;
for (p = b->parameter; p; p = p->next) {
- l = mutt_strlen (buf);
+ l = str_len (buf);
rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
* special case to handle when there is no filepart yet.
* find the first subscribed newsgroup
*/
- if ((len = mutt_strlen (filepart)) == 0) {
+ if ((len = str_len (filepart)) == 0) {
for (; l; l = l->next) {
NNTP_DATA *data = (NNTP_DATA *) l->data;
NNTP_DATA *data = (NNTP_DATA *) l->data;
if (data && data->subscribed &&
- safe_strncmp (data->group, filepart, len) == 0) {
+ str_ncmp (data->group, filepart, len) == 0) {
if (init) {
for (i = 0; filepart[i] && data->group[i]; i++) {
if (filepart[i] != data->group[i]) {
* special case to handle when there is no filepart yet. find the first
* file/directory which is not ``.'' or ``..''
*/
- if ((len = mutt_strlen (filepart)) == 0) {
+ if ((len = str_len (filepart)) == 0) {
while ((de = readdir (dirp)) != NULL) {
- if (mutt_strcmp (".", de->d_name) != 0
- && mutt_strcmp ("..", de->d_name) != 0) {
+ if (str_cmp (".", de->d_name) != 0
+ && str_cmp ("..", de->d_name) != 0) {
strfcpy (filepart, de->d_name, sizeof (filepart));
init++;
break;
}
while ((de = readdir (dirp)) != NULL) {
- if (safe_strncmp (de->d_name, filepart, len) == 0) {
+ if (str_ncmp (de->d_name, filepart, len) == 0) {
if (init) {
for (i = 0; filepart[i] && de->d_name[i]; i++) {
if (filepart[i] != de->d_name[i]) {
/* check to see if it is a directory */
if (dirpart[0]) {
strfcpy (buf, exp_dirpart, sizeof (buf));
- strfcpy (buf + mutt_strlen (buf), "/", sizeof (buf) - mutt_strlen (buf));
+ strfcpy (buf + str_len (buf), "/", sizeof (buf) - str_len (buf));
}
else
buf[0] = 0;
- strfcpy (buf + mutt_strlen (buf), filepart, sizeof (buf) - mutt_strlen (buf));
+ strfcpy (buf + str_len (buf), filepart, sizeof (buf) - str_len (buf));
if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR))
- strfcpy (filepart + mutt_strlen (filepart), "/",
- sizeof (filepart) - mutt_strlen (filepart));
+ strfcpy (filepart + str_len (filepart), "/",
+ sizeof (filepart) - str_len (filepart));
init = 1;
}
}
if (dirpart[0]) {
strfcpy (s, dirpart, slen);
- if (mutt_strcmp ("/", dirpart) != 0 && dirpart[0] != '='
+ if (str_cmp ("/", dirpart) != 0 && dirpart[0] != '='
&& dirpart[0] != '+')
- strfcpy (s + mutt_strlen (s), "/", slen - mutt_strlen (s));
- strfcpy (s + mutt_strlen (s), filepart, slen - mutt_strlen (s));
+ strfcpy (s + str_len (s), "/", slen - str_len (s));
+ strfcpy (s + str_len (s), filepart, slen - str_len (s));
}
else
strfcpy (s, filepart, slen);
if (t && t[0] == '0' && t[1] == '\0')
t = "<random>";
- if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
+ if (c + str_len (t) + 2 >= COLS - SidebarWidth)
break;
addstr (NONULL (t));
if (chain->next)
addstr (", ");
- c += mutt_strlen (t) + 2;
+ c += str_len (t) + 2;
}
}
#endif /* MIXMASTER */
&& buf[0]) {
FREE (&msg->env->newsgroups);
str_skip_trailws (buf);
- msg->env->newsgroups = safe_strdup (str_skip_initws (buf));
+ msg->env->newsgroups = str_dup (str_skip_initws (buf));
move (HDR_TO, HDR_XOFFSET);
clrtoeol ();
if (msg->env->newsgroups)
&& buf[0]) {
FREE (&msg->env->followup_to);
str_skip_trailws (buf);
- msg->env->followup_to = safe_strdup (str_skip_initws (buf));
+ msg->env->followup_to = str_dup (str_skip_initws (buf));
move (HDR_CC, HDR_XOFFSET);
clrtoeol ();
if (msg->env->followup_to)
if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0
&& buf[0]) {
FREE (&msg->env->x_comment_to);
- msg->env->x_comment_to = safe_strdup (buf);
+ msg->env->x_comment_to = str_dup (buf);
move (HDR_BCC, HDR_XOFFSET);
clrtoeol ();
if (msg->env->x_comment_to)
mutt_message_hook (NULL, msg, M_SEND2HOOK);
break;
case OP_COMPOSE_EDIT_MESSAGE:
- if (Editor && (mutt_strcmp ("builtin", Editor) != 0)
+ if (Editor && (str_cmp ("builtin", Editor) != 0)
&& !option (OPTEDITHDRS)) {
mutt_edit_file (Editor, msg->content->filename);
mutt_update_encoding (msg->content);
}
/* fall through */
case OP_COMPOSE_EDIT_HEADERS:
- if (mutt_strcmp ("builtin", Editor) != 0 &&
+ if (str_cmp ("builtin", Editor) != 0 &&
(op == OP_COMPOSE_EDIT_HEADERS ||
(op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS)))) {
char *tag = NULL, *err = NULL;
/* Uncompress to /tmp */
mutt_mktemp (tmppath);
- ctx->path = safe_malloc (mutt_strlen (tmppath) + 1);
+ ctx->path = safe_malloc (str_len (tmppath) + 1);
strcpy (ctx->path, tmppath);
}
mutt_FormatString (expanded, sizeof (expanded), cmd,
compresshook_format_str, (unsigned long) ctx, 0);
- return safe_strdup (expanded);
+ return str_dup (expanded);
}
int mutt_check_mailbox_compressed (CONTEXT * ctx)
/* Is it the begining of a header? */
if (nl && buf[0] != ' ' && buf[0] != '\t') {
ignore = 1;
- if (!from && safe_strncmp ("From ", buf, 5) == 0) {
+ if (!from && str_ncmp ("From ", buf, 5) == 0) {
if ((flags & CH_FROM) == 0)
continue;
from = 1;
if (!headers[x])
headers[x] = this_one;
else {
- safe_realloc (&headers[x], mutt_strlen (headers[x]) +
- mutt_strlen (this_one) + sizeof (char));
+ safe_realloc (&headers[x], str_len (headers[x]) +
+ str_len (this_one) + sizeof (char));
strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
FREE (&this_one);
}
ignore = 1;
this_is_from = 0;
- if (!from && safe_strncmp ("From ", buf, 5) == 0) {
+ if (!from && str_ncmp ("From ", buf, 5) == 0) {
if ((flags & CH_FROM) == 0)
continue;
this_is_from = from = 1;
/* Find x -- the array entry where this header is to be saved */
if (flags & CH_REORDER) {
for (t = HeaderOrderList, x = 0; (t); t = t->next, x++) {
- if (!ascii_strncasecmp (buf, t->data, mutt_strlen (t->data))) {
+ if (!ascii_strncasecmp (buf, t->data, str_len (t->data))) {
debug_print (2, ("Reorder: %s matches %s\n", t->data, buf));
break;
}
if (!ignore) {
debug_print (2, ("Reorder: x = %d; hdr_count = %d\n", x, hdr_count));
if (!this_one)
- this_one = safe_strdup (buf);
+ this_one = str_dup (buf);
else {
safe_realloc (&this_one,
- mutt_strlen (this_one) + mutt_strlen (buf) +
+ str_len (this_one) + str_len (buf) +
sizeof (char));
strcat (this_one, buf); /* __STRCAT_CHECKED__ */
}
if (!headers[x])
headers[x] = this_one;
else {
- safe_realloc (&headers[x], mutt_strlen (headers[x]) +
- mutt_strlen (this_one) + sizeof (char));
+ safe_realloc (&headers[x], str_len (headers[x]) +
+ str_len (this_one) + sizeof (char));
strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
FREE (&this_one);
}
char date[SHORT_STRING];
mutt_make_date (date, sizeof (date));
- date[5] = date[mutt_strlen (date) - 1] = '\"';
+ date[5] = date[str_len (date) - 1] = '\"';
/* Count the number of lines and bytes to be deleted */
fseek (fpin, body->offset, SEEK_SET);
new_lines = hdr->lines -
- count_delete_lines (fpin, body, &new_length, mutt_strlen (date));
+ count_delete_lines (fpin, body, &new_length, str_len (date));
/* Copy the headers */
if (mutt_copy_header (fpin, hdr, fpout,
int l, linelen, buflen, count;
- linelen = mutt_strlen (*h);
+ linelen = str_len (*h);
buflen = linelen + 3;
rfc822_write_address (buf, sizeof (buf), a, 0);
a->next = tmp;
- l = mutt_strlen (buf);
+ l = str_len (buf);
if (count && linelen + l > 74) {
strcpy (cbuf, "\n\t"); /* __STRCPY_CHECKED__ */
linelen = l + 8;
strcpy (c2buf, ","); /* __STRCPY_CHECKED__ */
}
- buflen += l + mutt_strlen (cbuf) + mutt_strlen (c2buf);
+ buflen += l + str_len (cbuf) + str_len (c2buf);
safe_realloc (h, buflen);
strcat (*h, cbuf); /* __STRCAT_CHECKED__ */
strcat (*h, buf); /* __STRCAT_CHECKED__ */
if (k->kobj && k->kobj->subkeys) {
s = k->kobj->subkeys->keyid;
- if ((!option (OPTPGPLONGIDS)) && (mutt_strlen (s) == 16))
+ if ((!option (OPTPGPLONGIDS)) && (str_len (s) == 16))
/* Return only the short keyID. */
s += 8;
}
rv |= CRYPT_KV_STRONGID;
if (addr->mailbox && u_addr->mailbox
- && safe_strcasecmp (addr->mailbox, u_addr->mailbox) == 0)
+ && str_casecmp (addr->mailbox, u_addr->mailbox) == 0)
rv |= CRYPT_KV_ADDR;
if (addr->personal && u_addr->personal
- && safe_strcasecmp (addr->personal, u_addr->personal) == 0)
+ && str_casecmp (addr->personal, u_addr->personal) == 0)
rv |= CRYPT_KV_STRING;
return rv;
}
if (ret_fp)
*ret_fp = fp;
- return safe_strdup (tempfile);
+ return str_dup (tempfile);
}
t = mutt_new_body ();
t->type = TYPEMULTIPART;
- t->subtype = safe_strdup ("signed");
+ t->subtype = str_dup ("signed");
t->encoding = ENC7BIT;
t->use_disp = 0;
t->disposition = DISPINLINE;
t = t->parts->next;
t->type = TYPEAPPLICATION;
if (use_smime) {
- t->subtype = safe_strdup ("pkcs7-signature");
+ t->subtype = str_dup ("pkcs7-signature");
mutt_set_parameter ("name", "smime.p7s", &t->parameter);
t->encoding = ENCBASE64;
t->use_disp = 1;
t->disposition = DISPATTACH;
- t->d_filename = safe_strdup ("smime.p7s");
+ t->d_filename = str_dup ("smime.p7s");
}
else {
- t->subtype = safe_strdup ("pgp-signature");
+ t->subtype = str_dup ("pgp-signature");
t->use_disp = 0;
t->disposition = DISPINLINE;
t->encoding = ENC7BIT;
t = mutt_new_body ();
t->type = TYPEMULTIPART;
- t->subtype = safe_strdup ("encrypted");
+ t->subtype = str_dup ("encrypted");
t->encoding = ENC7BIT;
t->use_disp = 0;
t->disposition = DISPINLINE;
t->parts = mutt_new_body ();
t->parts->type = TYPEAPPLICATION;
- t->parts->subtype = safe_strdup ("pgp-encrypted");
+ t->parts->subtype = str_dup ("pgp-encrypted");
t->parts->encoding = ENC7BIT;
t->parts->next = mutt_new_body ();
t->parts->next->type = TYPEAPPLICATION;
- t->parts->next->subtype = safe_strdup ("octet-stream");
+ t->parts->next->subtype = str_dup ("octet-stream");
t->parts->next->encoding = ENC7BIT;
t->parts->next->filename = outfile;
t->parts->next->use_disp = 1;
t->parts->next->disposition = DISPINLINE;
t->parts->next->unlink = 1; /* delete after sending the message */
- t->parts->next->d_filename = safe_strdup ("msg.asc"); /* non pgp/mime
+ t->parts->next->d_filename = str_dup ("msg.asc"); /* non pgp/mime
can save */
return t;
t = mutt_new_body ();
t->type = TYPEAPPLICATION;
- t->subtype = safe_strdup ("pkcs7-mime");
+ t->subtype = str_dup ("pkcs7-mime");
mutt_set_parameter ("name", "smime.p7m", &t->parameter);
mutt_set_parameter ("smime-type", "enveloped-data", &t->parameter);
t->encoding = ENCBASE64; /* The output of OpenSSL SHOULD be binary */
t->use_disp = 1;
t->disposition = DISPATTACH;
- t->d_filename = safe_strdup ("smime.p7m");
+ t->d_filename = str_dup ("smime.p7m");
t->filename = outfile;
t->unlink = 1; /*delete after sending the message */
t->parts = 0;
state_attach_puts (": ", s);
if (t0)
state_attach_puts (t0, s);
- if (t1 && !(t0 && !mutt_strcmp (t0, t1))) {
+ if (t1 && !(t0 && !str_cmp (t0, t1))) {
if (t0)
state_attach_puts (",", s);
state_attach_puts (t1, s);
return;
is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
- buf = safe_malloc (mutt_strlen (prefix) + mutt_strlen (s) * 4 + 2);
+ buf = safe_malloc (str_len (prefix) + str_len (s) * 4 + 2);
strcpy (buf, prefix); /* __STRCPY_CHECKED__ */
- p = buf + mutt_strlen (buf);
- if (is_pgp && mutt_strlen (s) == 40) { /* PGP v4 style formatted. */
+ p = buf + str_len (buf);
+ if (is_pgp && str_len (s) == 40) { /* PGP v4 style formatted. */
for (i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++) {
*p++ = s[0];
*p++ = s[1];
if (notation->value) {
state_attach_puts (notation->value, s);
if (!(*notation->value
- && (notation->value[mutt_strlen (notation->value) - 1] ==
+ && (notation->value[str_len (notation->value) - 1] ==
'\n')))
state_attach_puts ("\n", s);
}
}
while (fgets (buf, sizeof (buf), tfp)) {
- if (!safe_strncmp ("-----BEGIN PGP ", buf, 15)) {
- if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
+ if (!str_ncmp ("-----BEGIN PGP ", buf, 15)) {
+ if (!str_cmp ("MESSAGE-----\n", buf + 15))
enc = 1;
- else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
+ else if (!str_cmp ("SIGNED MESSAGE-----\n", buf + 15))
sgn = 1;
}
}
continue;
}
- if (!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n"))
+ if (!str_cmp (buf, "-----BEGIN PGP SIGNATURE-----\n"))
break;
if (armor_header) {
break;
offset = ftell (s->fpin);
- bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
+ bytes -= (offset - last_pos); /* don't rely on str_len(buf) */
last_pos = offset;
- if (!safe_strncmp ("-----BEGIN PGP ", buf, 15)) {
+ if (!str_ncmp ("-----BEGIN PGP ", buf, 15)) {
clearsign = 0;
start_pos = last_pos;
- if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
+ if (!str_cmp ("MESSAGE-----\n", buf + 15))
needpass = 1;
- else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15)) {
+ else if (!str_cmp ("SIGNED MESSAGE-----\n", buf + 15)) {
clearsign = 1;
needpass = 0;
}
else if (!option (OPTDONTHANDLEPGPKEYS) &&
- !mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15)) {
+ !str_cmp ("PUBLIC KEY BLOCK-----\n", buf + 15)) {
needpass = 0;
pgp_keyblock = 1;
}
/* Copy PGP material to an data container */
armored_data = create_gpgme_data ();
- gpgme_data_write (armored_data, buf, mutt_strlen (buf));
+ gpgme_data_write (armored_data, buf, str_len (buf));
while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL) {
offset = ftell (s->fpin);
- bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
+ bytes -= (offset - last_pos); /* don't rely on str_len(buf) */
last_pos = offset;
- gpgme_data_write (armored_data, buf, mutt_strlen (buf));
+ gpgme_data_write (armored_data, buf, str_len (buf));
- if ((needpass && !mutt_strcmp ("-----END PGP MESSAGE-----\n", buf))
+ if ((needpass && !str_cmp ("-----END PGP MESSAGE-----\n", buf))
|| (!needpass
- && (!mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf)
- || !mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",
+ && (!str_cmp ("-----END PGP SIGNATURE-----\n", buf)
+ || !str_cmp ("-----END PGP PUBLIC KEY BLOCK-----\n",
buf))))
break;
}
crypt_key_t **t = (crypt_key_t **) b;
int r;
- if ((r = safe_strcasecmp ((*s)->uid, (*t)->uid)))
+ if ((r = str_casecmp ((*s)->uid, (*t)->uid)))
return r > 0;
else
- return safe_strcasecmp (crypt_keyid (*s), crypt_keyid (*t)) > 0;
+ return str_casecmp (crypt_keyid (*s), crypt_keyid (*t)) > 0;
}
static int crypt_compare_address (const void *a, const void *b)
crypt_key_t **t = (crypt_key_t **) b;
int r;
- if ((r = safe_strcasecmp (crypt_keyid (*s), crypt_keyid (*t))))
+ if ((r = str_casecmp (crypt_keyid (*s), crypt_keyid (*t))))
return r > 0;
else
- return safe_strcasecmp ((*s)->uid, (*t)->uid) > 0;
+ return str_casecmp ((*s)->uid, (*t)->uid) > 0;
}
static int crypt_compare_keyid (const void *a, const void *b)
if (ts < tt)
return 0;
- return safe_strcasecmp ((*s)->uid, (*t)->uid) > 0;
+ return str_casecmp ((*s)->uid, (*t)->uid) > 0;
}
static int crypt_compare_date (const void *a, const void *b)
if (ts < tt)
return 0;
- if ((r = safe_strcasecmp ((*s)->uid, (*t)->uid)))
+ if ((r = str_casecmp ((*s)->uid, (*t)->uid)))
return r > 0;
- return (safe_strcasecmp (crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0;
+ return (str_casecmp (crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0;
}
static int crypt_compare_trust (const void *a, const void *b)
int any = 0;
for (; dn->key; dn++) {
- if (!mutt_strcmp (dn->key, key)) {
+ if (!str_cmp (dn->key, key)) {
if (any)
fputs (" + ", fp);
- print_utf8 (fp, dn->value, mutt_strlen (dn->value));
+ print_utf8 (fp, dn->value, str_len (dn->value));
any = 1;
}
}
/* now print the rest without any specific ordering */
for (; dn->key; dn++) {
for (i = 0; stdpart[i]; i++) {
- if (!mutt_strcmp (dn->key, stdpart[i]))
+ if (!str_cmp (dn->key, stdpart[i]))
break;
}
if (!stdpart[i]) {
putc (' ', fp);
}
if (is_pgp)
- print_utf8 (fp, s, mutt_strlen (s));
+ print_utf8 (fp, s, str_len (s));
else
parse_and_print_user_id (fp, s);
putc ('\n', fp);
if (key->subkeys) {
s = key->subkeys->fpr;
fputs (_("Fingerprint: "), fp);
- if (is_pgp && mutt_strlen (s) == 40) {
+ if (is_pgp && str_len (s) == 40) {
for (i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++) {
putc (*s, fp);
putc (s[1], fp);
s = subkey->keyid;
putc ('\n', fp);
- if (mutt_strlen (s) == 16)
+ if (str_len (s) == 16)
s += 8; /* display only the short keyID */
fprintf (fp, "Subkey ....: 0x%s", s);
if (subkey->revoked) {
k = key->kobj;
gpgme_key_ref (k);
- while ((s = k->chain_id) && k->subkeys && mutt_strcmp (s, k->subkeys->fpr)) {
+ while ((s = k->chain_id) && k->subkeys && str_cmp (s, k->subkeys->fpr)) {
putc ('\n', fp);
err = gpgme_op_keylist_start (listctx, s, 0);
gpgme_key_release (k);
patarr = safe_calloc (n + 1, sizeof *patarr);
for (l = hints, n = 0; l; l = l->next) {
if (l->data && *l->data)
- patarr[n++] = safe_strdup (l->data);
+ patarr[n++] = str_dup (l->data);
}
patarr[n] = NULL;
err = gpgme_op_keylist_ext_start (ctx, (const char **) patarr, secret, 0);
char *scratch;
char *t;
- if ((scratch = safe_strdup (str)) == NULL)
+ if ((scratch = str_dup (str)) == NULL)
return hints;
for (t = strtok (scratch, " ,.:\"()<>\n"); t;
t = strtok (NULL, " ,.:\"()<>\n")) {
- if (mutt_strlen (t) > 3)
+ if (str_len (t) > 3)
hints = mutt_add_list (hints, t);
}
match = 0;
debug_print (5, ("matching \"%s\" against " "key %s, \"%s\":\n", p, crypt_keyid (k), k->uid));
- if (!*p || !safe_strcasecmp (p, crypt_keyid (k))
- || (!safe_strncasecmp (p, "0x", 2)
- && !safe_strcasecmp (p + 2, crypt_keyid (k)))
+ if (!*p || !str_casecmp (p, crypt_keyid (k))
+ || (!str_ncasecmp (p, "0x", 2)
+ && !str_casecmp (p + 2, crypt_keyid (k)))
|| (option (OPTPGPLONGIDS)
- && !safe_strncasecmp (p, "0x", 2)
- && !safe_strcasecmp (p + 2, crypt_keyid (k) + 8))
+ && !str_ncasecmp (p, "0x", 2)
+ && !str_casecmp (p + 2, crypt_keyid (k) + 8))
|| str_isstr (k->uid, p)) {
crypt_key_t *tmp;
if (whatfor) {
for (l = id_defaults; l; l = l->next)
- if (!safe_strcasecmp (whatfor, l->what)) {
+ if (!str_casecmp (whatfor, l->what)) {
strfcpy (resp, NONULL (l->dflt), sizeof (resp));
break;
}
l = safe_malloc (sizeof (struct crypt_cache));
l->next = id_defaults;
id_defaults = l;
- l->what = safe_strdup (whatfor);
- l->dflt = safe_strdup (resp);
+ l->what = str_dup (whatfor);
+ l->dflt = str_dup (resp);
}
}
*r_application &= ~APPLICATION_SMIME;
#endif
- keylist_size += mutt_strlen (s) + 4 + 1;
+ keylist_size += str_len (s) + 4 + 1;
safe_realloc (&keylist, keylist_size);
sprintf (keylist + keylist_used, "%s0x%s%s", /* __SPRINTF_CHECKED__ */
keylist_used ? " " : "", s, forced_valid ? "!" : "");
}
- keylist_used = mutt_strlen (keylist);
+ keylist_used = str_len (keylist);
crypt_free_key (&key);
rfc822_free_address (&addr);
int sender_length = 0;
int uid_length = 0;
- sender_length = mutt_strlen (sender->mailbox);
+ sender_length = str_len (sender->mailbox);
for (uid = key->uids; uid && ret; uid = uid->next) {
- uid_length = mutt_strlen (uid->email);
+ uid_length = str_len (uid->email);
if (1 && (uid->email[0] == '<')
&& (uid->email[uid_length - 1] == '>')
&& (uid_length == sender_length + 2)
/* no .p7c, .p10 support yet. */
- len = mutt_strlen (t) - 4;
+ len = str_len (t) - 4;
if (len > 0 && *(t + len) == '.') {
len++;
if (!ascii_strcasecmp ((t + len), "p7m"))
convert_to_7bit (a->parts);
}
else if (a->type == TYPEMESSAGE &&
- safe_strcasecmp (a->subtype, "delivery-status")) {
+ str_casecmp (a->subtype, "delivery-status")) {
if (a->encoding != ENC7BIT)
mutt_message_to_7bit (a, NULL);
}
/* consistency check */
if (!(a && a->next && a->next->type == protocol_major &&
- !safe_strcasecmp (a->next->subtype, protocol_minor))) {
+ !str_casecmp (a->next->subtype, protocol_minor))) {
state_attach_puts (_("[-- Error: "
"Inconsistent multipart/signed structure! --]\n\n"),
s);
if ((WithCrypto & APPLICATION_PGP)
&& protocol_major == TYPEAPPLICATION
- && !safe_strcasecmp (protocol_minor, "pgp-signature"));
+ && !str_casecmp (protocol_minor, "pgp-signature"));
else if ((WithCrypto & APPLICATION_SMIME)
&& protocol_major == TYPEAPPLICATION
- && !(safe_strcasecmp (protocol_minor, "x-pkcs7-signature")
- && safe_strcasecmp (protocol_minor, "pkcs7-signature")));
+ && !(str_casecmp (protocol_minor, "x-pkcs7-signature")
+ && str_casecmp (protocol_minor, "pkcs7-signature")));
else if (protocol_major == TYPEMULTIPART
- && !safe_strcasecmp (protocol_minor, "mixed"));
+ && !str_casecmp (protocol_minor, "mixed"));
else {
state_printf (s, _("[-- Error: "
"Unknown multipart/signed protocol %s! --]\n\n"),
for (i = 0; i < sigcnt; i++) {
if ((WithCrypto & APPLICATION_PGP)
&& signatures[i]->type == TYPEAPPLICATION
- && !safe_strcasecmp (signatures[i]->subtype, "pgp-signature")) {
+ && !str_casecmp (signatures[i]->subtype, "pgp-signature")) {
if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0)
goodsig = 0;
if ((WithCrypto & APPLICATION_SMIME)
&& signatures[i]->type == TYPEAPPLICATION
&&
- (!safe_strcasecmp (signatures[i]->subtype, "x-pkcs7-signature")
- || !safe_strcasecmp (signatures[i]->subtype,
+ (!str_casecmp (signatures[i]->subtype, "x-pkcs7-signature")
+ || !str_casecmp (signatures[i]->subtype,
"pkcs7-signature"))) {
if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0)
goodsig = 0;
answer_string = safe_malloc (COLS + 1);
snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no,
def == M_YES ? no : yes);
- answer_string_len = mutt_strlen (answer_string);
+ answer_string_len = str_len (answer_string);
printw ("%.*s%s", COLS - answer_string_len, msg, answer_string);
FREE (&answer_string);
{
int rc;
- if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
+ if (!Pager || str_cmp (Pager, "builtin") == 0)
rc = mutt_pager (banner, tempfile, do_color, info);
else {
char cmd[STRING];
*redraw = REDRAW_FULL;
}
else {
- char *pc = safe_malloc (mutt_strlen (prompt) + 3);
+ char *pc = safe_malloc (str_len (prompt) + 3);
sprintf (pc, "%s: ", prompt); /* __SPRINTF_CHECKED__ */
mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0);
}
else if (ch.ch <= '9' && ch.ch > '0') {
choice = ch.ch - '0';
- if (choice <= mutt_strlen (letters))
+ if (choice <= str_len (letters))
break;
}
}
}
mutt_format_string (dest, destlen, min_width, max_width,
- right_justify, ' ', s, mutt_strlen (s), arboreal);
+ right_justify, ' ', s, str_len (s), arboreal);
}
void mutt_format_s (char *dest,
wchar_t wc;
int w;
size_t k;
- size_t len = mutt_strlen (s);
+ size_t len = str_len (s);
mbstate_t mbstate;
memset (&mbstate, 0, sizeof (mbstate));
}
/*
- * mutt_strwidth is like mutt_strlen except that it returns the width
+ * mutt_strwidth is like str_len except that it returns the width
* refering to the number of characters cells.
*/
if (!s)
return 0;
- n = mutt_strlen (s);
+ n = str_len (s);
memset (&mbstate, 0, sizeof (mbstate));
for (w = 0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k) {
unset_option (OPTHIDEREAD);
}
FREE (&Context->pattern);
- Context->pattern = safe_strdup (buf);
+ Context->pattern = str_dup (buf);
}
if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
sleep (2);
}
else if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
- safe_strcasecmp (CURHDR->env->followup_to, "poster") ||
+ str_casecmp (CURHDR->env->followup_to, "poster") ||
query_quadoption (OPT_FOLLOWUPTOPOSTER,
_("Reply by mail as poster prefers?")) !=
M_YES) {
Style Guide
-----------
-- global functions should have the prefix "mutt_". All
- other functions should be declared "static".
+- global functions outside the library directory should have the prefix
+ "mutt_". All other functions should be declared "static". All global
+ functions defined within the library directory should have the the
+ prefix according to their source file, i.e. "str_" for everything in
+ lib/str.[ch] etc.
- avoid global vars where possible. If one is required,
try to contain it to a single source file and declare it
in ELM and PINE is the tremendous duplication of code...
Help keep Mutt small!
-- when adding new options, make the old behaviour the
- default.
+- When adding new options, make the old behaviour the default. Also,
+ add them to UPGRADING in the top-level source directory.
- try to keep Mutt-ng as portable as possible.
-- do not use C++-style comments (i.e. "// Comment")
-
Documentation
-------------
#define check_flags(a) if (a & DL_FL_ACTIONS) usage (argv[0])
-size_t mutt_strlen (const char* s) {
+size_t str_len (const char* s) {
return (s ? strlen (s) : 0);
}
dirname = ".";
}
- if (mutt_strlen (basename) + 1 > l)
+ if (str_len (basename) + 1 > l)
return -1;
strfcpy (bn, basename, l);
tmp[sizeof (tmp) - 1] = 0;
if (prefix) {
strfcpy (tmp, NONULL (Prefix), sizeof (tmp));
- tmplen = mutt_strlen (tmp);
+ tmplen = str_len (tmp);
p = tmp + tmplen;
tmplen = sizeof (tmp) - tmplen;
}
while (bytes > 0) {
if (fgets (p, tmplen - 1, f) == NULL)
break;
- bytes -= mutt_strlen (p);
+ bytes -= str_len (p);
if (*bufmax == *buflen)
safe_realloc (&buf, sizeof (char *) * (*bufmax += 25));
- buf[(*buflen)++] = safe_strdup (tmp);
+ buf[(*buflen)++] = str_dup (tmp);
}
if (buf && *bufmax == *buflen) { /* Do not smash memory past buf */
safe_realloc (&buf, sizeof (char *) * (++*bufmax));
if (*bufmax == *buflen)
safe_realloc (&buf, sizeof (char *) * (*bufmax += 25));
- buf[(*buflen)++] = safe_strdup (tmp);
+ buf[(*buflen)++] = str_dup (tmp);
bytes = Context->hdrs[n]->content->length;
if (inc_hdrs) {
if (*bufmax == *buflen)
safe_realloc (&buf, sizeof (char *) * (*bufmax += 25));
- buf[(*buflen)++] = safe_strdup ("\n");
+ buf[(*buflen)++] = str_dup ("\n");
}
else
printw (_("%d: invalid message number.\n"), n);
if (EscChar && tmp[0] == EscChar[0] && tmp[1] != EscChar[0]) {
/* remove trailing whitespace from the line */
- p = tmp + mutt_strlen (tmp) - 1;
+ p = tmp + str_len (tmp) - 1;
while (p >= tmp && ISSPACE (*p))
*p-- = 0;
if (Context) {
if (!*p && cur) {
/* include the current message */
- p = tmp + mutt_strlen (tmp) + 1;
- snprintf (tmp + mutt_strlen (tmp),
- sizeof (tmp) - mutt_strlen (tmp), " %d",
+ p = tmp + str_len (tmp) + 1;
+ snprintf (tmp + str_len (tmp),
+ sizeof (tmp) - str_len (tmp), " %d",
cur->msgno + 1);
}
buf = be_include_messages (p, buf, &bufmax, &buflen,
if (buflen) {
buflen--;
strfcpy (tmp, buf[buflen], sizeof (tmp));
- tmp[mutt_strlen (tmp) - 1] = 0;
+ tmp[str_len (tmp) - 1] = 0;
FREE (&buf[buflen]);
buf[buflen] = NULL;
continue;
break;
}
}
- else if (mutt_strcmp (".", tmp) == 0)
+ else if (str_cmp (".", tmp) == 0)
done = 1;
else {
- safe_strcat (tmp, sizeof (tmp), "\n");
+ str_cat (tmp, sizeof (tmp), "\n");
if (buflen == bufmax)
safe_realloc (&buf, sizeof (char *) * (bufmax += 25));
- buf[buflen++] = safe_strdup (tmp[1] == '~' ? tmp + 1 : tmp);
+ buf[buflen++] = str_dup (tmp[1] == '~' ? tmp + 1 : tmp);
}
tmp[0] = 0;
goto bye;
} else if (flags & M_COMMAND) {
my_wcstombs (buf, buflen, state->wbuf, state->curpos);
- i = mutt_strlen (buf);
+ i = str_len (buf);
if (i && buf[i - 1] == '=' &&
mutt_var_value_complete (buf, buflen, i))
state->tabs = 0;
*numfiles = 1;
tfiles = safe_calloc (*numfiles, sizeof (char *));
mutt_expand_path (buf, buflen);
- tfiles[0] = safe_strdup (buf);
+ tfiles[0] = str_dup (buf);
*files = tfiles;
}
rv = 0;
int i;
for (i = 0; i < 12; i++)
- if (safe_strncasecmp (s, Months[i], 3) == 0)
+ if (str_ncasecmp (s, Months[i], 3) == 0)
return (i);
return (-1); /* error */
}
{
int i;
- if ((mutt_strlen (s) < 3) || !*(s + 3) || !ISSPACE (*(s + 3)))
+ if ((str_len (s) < 3) || !*(s + 3) || !ISSPACE (*(s + 3)))
return 0;
for (i = 0; i < 7; i++)
- if (safe_strncasecmp (s, Weekdays[i], 3) == 0)
+ if (str_ncasecmp (s, Weekdays[i], 3) == 0)
return 1;
return 0;
}
if (path)
*path = 0;
- if (safe_strncmp ("From ", s, 5) != 0)
+ if (str_ncmp ("From ", s, 5) != 0)
return 0;
s = next_word (s); /* skip over the From part. */
p = tmp;
while (ISSPACE (*p))
p++;
- if (safe_strncmp ("domain", p, 6) == 0
- || safe_strncmp ("search", p, 6) == 0) {
+ if (str_ncmp ("domain", p, 6) == 0
+ || str_ncmp ("search", p, 6) == 0) {
p += 6;
for (q = strtok (p, " \t\n"); q; q = strtok (NULL, " \t\n"))
memcpy (uid, buf, ob - buf);
uid[ob - buf] = '\0';
}
- else if (ob - buf == n && (buf[n] = 0, mutt_strlen (buf) < n))
+ else if (ob - buf == n && (buf[n] = 0, str_len (buf) < n))
memcpy (uid, buf, n);
}
FREE (&buf);
{
debug_print (2, ("record type: %s\n", p));
- if (!mutt_strcmp (p, "pub"));
- else if (!mutt_strcmp (p, "sub"))
+ if (!str_cmp (p, "pub"));
+ else if (!str_cmp (p, "sub"))
*is_subkey = 1;
- else if (!mutt_strcmp (p, "sec"));
- else if (!mutt_strcmp (p, "ssb"))
+ else if (!str_cmp (p, "sec"));
+ else if (!str_cmp (p, "ssb"))
*is_subkey = 1;
- else if (!mutt_strcmp (p, "uid"))
+ else if (!str_cmp (p, "uid"))
is_uid = 1;
else
return NULL;
uid = safe_calloc (sizeof (pgp_uid_t), 1);
fix_uid (p);
- uid->addr = safe_strdup (p);
+ uid->addr = str_dup (p);
uid->trust = trust;
uid->flags |= flags;
uid->parent = k;
if (fgets (line, MIN ((ssize_t) sizeof (line), len + 1), s->fpin) == NULL)
break;
- linelen = mutt_strlen (line);
+ linelen = str_len (line);
len -= linelen;
/*
while (len > 0) {
if ((fgets (tmps, sizeof (tmps), s->fpin)) == NULL)
return;
- len -= mutt_strlen (tmps);
- if ((!safe_strncmp (tmps, "begin", 5)) && ISSPACE (tmps[5]))
+ len -= str_len (tmps);
+ if ((!str_ncmp (tmps, "begin", 5)) && ISSPACE (tmps[5]))
break;
}
while (len > 0) {
if ((fgets (tmps, sizeof (tmps), s->fpin)) == NULL)
return;
- len -= mutt_strlen (tmps);
- if (!safe_strncmp (tmps, "end", 3))
+ len -= str_len (tmps);
+ if (!str_ncmp (tmps, "end", 3))
break;
pt = tmps;
linelen = decode_byte (*pt);
stte->indent_len = 0;
if (stte->s->prefix) {
state_puts (stte->s->prefix, stte->s);
- stte->indent_len += mutt_strlen (stte->s->prefix);
+ stte->indent_len += str_len (stte->s->prefix);
}
if (stte->tag_level[RICH_EXCERPT]) {
while (x) {
if (stte->s->prefix) {
state_puts (stte->s->prefix, stte->s);
- stte->indent_len += mutt_strlen (stte->s->prefix);
+ stte->indent_len += str_len (stte->s->prefix);
}
else {
state_puts ("> ", stte->s);
- stte->indent_len += mutt_strlen ("> ");
+ stte->indent_len += str_len ("> ");
}
x--;
}
{
char *c;
- if (stte->buff_len < stte->buff_used + mutt_strlen (s)) {
+ if (stte->buff_len < stte->buff_used + str_len (s)) {
stte->buff_len += LONG_STRING;
safe_realloc (&stte->buffer, stte->buff_len + 1);
}
if (s->prefix) {
state_puts (s->prefix, s);
- stte.indent_len += mutt_strlen (s->prefix);
+ stte.indent_len += str_len (s->prefix);
}
while (state != DONE) {
{
int width;
char *pos, *oldpos;
- int len = mutt_strlen (line);
+ int len = str_len (line);
int i;
if (MaxLineLength > 0) {
/* fprintf(stderr,"print_flowed_line will print `%s' with ql = %d\n",line,ql); */
- if (mutt_strlen (line) == 0) {
+ if (str_len (line) == 0) {
if (option (OPTQUOTEEMPTY)) {
if (s->prefix)
state_puts(s->prefix,s);
while (bytes > 0 && fgets (buf, sizeof (buf), s->fpin)) {
- bytes -= mutt_strlen (buf);
+ bytes -= str_len (buf);
newql = get_quote_level (buf);
if ((t = strrchr (buf, '\n')) || (t = strrchr (buf, '\r'))) {
*t = '\0';
- if (mutt_strlen (curline) > 0 && curline[mutt_strlen (curline) - 1] == ' '
+ if (str_len (curline) > 0 && curline[str_len (curline) - 1] == ' '
&& newql == quotelevel
&& strcmp (curline + quotelevel, "-- ") != 0) {
if (buf[newql] == ' ')
- curline[mutt_strlen (curline) - 1] = '\0';
+ curline[str_len (curline) - 1] = '\0';
- curline = realloc (curline, curline_len + mutt_strlen (buf));
+ curline = realloc (curline, curline_len + str_len (buf));
if (curline_len == 1)
*curline = '\0';
- curline_len += mutt_strlen (buf);
- safe_strncat (curline, curline_len, buf + newql,
- mutt_strlen (buf + newql));
+ curline_len += str_len (buf);
+ str_ncat (curline, curline_len, buf + newql,
+ str_len (buf + newql));
}
else {
if (first_line) {
}
FREE (&curline);
curline_len = 1;
- curline = realloc (curline, curline_len + mutt_strlen (buf));
+ curline = realloc (curline, curline_len + str_len (buf));
if (curline_len == 1)
*curline = '\0';
- curline_len += mutt_strlen (buf);
- safe_strncat (curline, curline_len, buf, mutt_strlen (buf));
+ curline_len += str_len (buf);
+ str_ncat (curline, curline_len, buf, str_len (buf));
quotelevel = newql;
}
}
/* in case there's no line end it's likely the last line
* so append to current (if any) */
if (buf[newql] == ' ')
- curline[mutt_strlen (curline) - 1] = '\0';
- curline = realloc (curline, curline_len + mutt_strlen (buf));
+ curline[str_len (curline) - 1] = '\0';
+ curline = realloc (curline, curline_len + str_len (buf));
if (curline_len == 1)
*curline = '\0';
- curline_len += mutt_strlen (buf);
- safe_strncat (curline, curline_len, buf + newql,
- mutt_strlen (buf + newql));
+ curline_len += str_len (buf);
+ str_ncat (curline, curline_len, buf + newql,
+ str_len (buf + newql));
break;
}
}
}
else {
wild = 1;
- btlen = mutt_strlen (t->data);
+ btlen = str_len (t->data);
}
if (a && a->parts)
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
rfc1524_mailcap_lookup (a, type, entry, M_AUTOVIEW);
- fname = safe_strdup (a->filename);
+ fname = str_dup (a->filename);
mutt_sanitize_filename (fname, 1);
rfc1524_expand_filename (entry->nametemplate, fname, tempfile,
sizeof (tempfile));
handler = mutt_signed_handler;
}
else if ((WithCrypto & APPLICATION_PGP)
- && safe_strcasecmp ("encrypted", b->subtype) == 0) {
+ && str_casecmp ("encrypted", b->subtype) == 0) {
p = mutt_get_parameter ("protocol", b->parameter);
if (!p)
int r;
for (tmp = table->table[h], last = NULL; tmp; last = tmp, tmp = tmp->next) {
- r = mutt_strcmp (tmp->key, key);
+ r = str_cmp (tmp->key, key);
if (r == 0) {
FREE (&ptr);
return (-1);
struct hash_elem *ptr = table->table[hash];
for (; ptr; ptr = ptr->next) {
- if (mutt_strcmp (key, ptr->key) == 0)
+ if (str_cmp (key, ptr->key) == 0)
return (ptr->data);
}
return NULL;
struct hash_elem **last = &table->table[hash];
while (ptr) {
- if ((data == ptr->data || !data) && mutt_strcmp (ptr->key, key) == 0) {
+ if ((data == ptr->data || !data) && str_cmp (ptr->key, key) == 0) {
*last = ptr->next;
if (destroy)
destroy (ptr->data);
return d;
}
- size = mutt_strlen (c) + 1;
+ size = str_len (c) + 1;
d = dump_int (size, d, off);
lazy_realloc (&d, *off + size);
memcpy (d + *off, c, size);
crc = crc32 (crc, (unsigned char const *)
"sithglan@stud.uni-erlangen.de[sithglan]|hcache.c|20041108231548|29613",
- mutt_strlen
+ str_len
("sithglan@stud.uni-erlangen.de[sithglan]|hcache.c|20041108231548|29613"));
#if HAVE_LANGINFO_CODESET
- crc = crc32 (crc, (unsigned char const *) Charset, mutt_strlen (Charset));
+ crc = crc32 (crc, (unsigned char const *) Charset, str_len (Charset));
crc =
crc32 (crc, (unsigned char const *) "HAVE_LANGINFO_CODESET",
- mutt_strlen ("HAVE_LANGINFO_CODESET"));
+ str_len ("HAVE_LANGINFO_CODESET"));
#endif
#ifdef USE_POP
crc =
- crc32 (crc, (unsigned char const *) "USE_POP", mutt_strlen ("USE_POP"));
+ crc32 (crc, (unsigned char const *) "USE_POP", str_len ("USE_POP"));
#endif
#ifdef MIXMASTER
crc =
crc32 (crc, (unsigned char const *) "MIXMASTER",
- mutt_strlen ("MIXMASTER"));
+ str_len ("MIXMASTER"));
#endif
#ifdef USE_IMAP
crc =
- crc32 (crc, (unsigned char const *) "USE_IMAP", mutt_strlen ("USE_IMAP"));
+ crc32 (crc, (unsigned char const *) "USE_IMAP", str_len ("USE_IMAP"));
#endif
#ifdef USE_NNTP
crc =
- crc32 (crc, (unsigned char const *) "USE_NNTP", mutt_strlen ("USE_NNTP"));
+ crc32 (crc, (unsigned char const *) "USE_NNTP", str_len ("USE_NNTP"));
#endif
return crc;
}
}
MD5Init (&md5);
- MD5Update (&md5, (unsigned char *) folder, mutt_strlen (folder));
+ MD5Update (&md5, (unsigned char *) folder, str_len (folder));
MD5Final (md5sum, &md5);
ret = snprintf (mutt_hcache_per_folder_path, _POSIX_PATH_MAX,
/* this is needed for maildir style mailboxes */
if (oh) {
h->old = (*oh)->old;
- h->path = safe_strdup ((*oh)->path);
+ h->path = str_dup ((*oh)->path);
mutt_free_header (oh);
}
struct header_cache *h = safe_calloc(1, sizeof (HEADER_CACHE));
int flags = VL_OWRITER | VL_OCREAT;
h->db = NULL;
- h->folder = safe_strdup(folder);
+ h->folder = str_dup(folder);
h->crc = generate_crc32();
if (!path || path[0] == '\0')
return NULL;
strncpy(path, h->folder, sizeof (path));
- safe_strcat(path, sizeof (path), filename);
+ str_cat(path, sizeof (path), filename);
ksize = strlen(h->folder) + keylen(path + strlen(h->folder));
return -1;
strncpy(path, h->folder, sizeof (path));
- safe_strcat(path, sizeof (path), filename);
+ str_cat(path, sizeof (path), filename);
ksize = strlen(h->folder) + keylen(path + strlen(h->folder));
return -1;
strncpy(path, h->folder, sizeof (path));
- safe_strcat(path, sizeof (path), filename);
+ str_cat(path, sizeof (path), filename);
ksize = strlen(h->folder) + keylen(path + strlen(h->folder));
int pagesize =
atoi (HeaderCachePageSize) ? atoi (HeaderCachePageSize) : 16384;
h->db = NULL;
- h->folder = safe_strdup (folder);
+ h->folder = str_dup (folder);
h->crc = generate_crc32 ();
if (!path || path[0] == '\0') {
}
strncpy (path, h->folder, sizeof (path));
- strncat (path, filename, sizeof (path) - mutt_strlen (path));
+ strncat (path, filename, sizeof (path) - str_len (path));
key.dptr = path;
key.dsize = keylen (path);
}
strncpy (path, h->folder, sizeof (path));
- strncat (path, filename, sizeof (path) - mutt_strlen (path));
+ strncat (path, filename, sizeof (path) - str_len (path));
key.dptr = path;
key.dsize = keylen (path);
}
strncpy (path, h->folder, sizeof (path));
- strncat (path, filename, sizeof (path) - mutt_strlen (path));
+ strncat (path, filename, sizeof (path) - str_len (path));
key.dptr = path;
key.dsize = keylen (path);
snprintf (dest, destlen, fmt,
(Tochars
&& ((i = mutt_user_is_recipient (hdr))) <
- mutt_strlen (Tochars)) ? Tochars[i] : ' ');
+ str_len (Tochars)) ? Tochars[i] : ' ');
break;
case 'u':
((i =
mutt_user_is_recipient
(hdr)) <
- mutt_strlen (Tochars)) ?
+ str_len (Tochars)) ?
Tochars[i] : ' ')));
mutt_format_s (dest, destlen, prefix, buf2);
break;
&& (hdr->thread->parent && hdr->thread->parent->message
&& hdr->thread->parent->message->env->x_label))
htmp = hdr->thread->parent->message;
- if (htmp && safe_strcasecmp (hdr->env->x_label,
+ if (htmp && str_casecmp (hdr->env->x_label,
htmp->env->x_label) == 0)
i = 0;
}
strfcpy (path, p, sizeof (path));
mutt_expand_path (path, sizeof (path));
if ((body = mutt_make_file_attach (path))) {
- body->description = safe_strdup (q);
+ body->description = str_dup (q);
for (parts = msg->content; parts->next; parts = parts->next);
parts->next = body;
}
buflen -= 2;
}
mutt_make_help (pbuf, buflen, _(items[i].name), menu, items[i].value);
- len = mutt_strlen (pbuf);
+ len = str_len (pbuf);
pbuf += len;
buflen -= len;
}
wchar_t wc;
int w;
size_t k;
- size_t len = mutt_strlen (*macro);
+ size_t len = str_len (*macro);
mbstate_t mbstate1, mbstate2;
memset (&mbstate1, 0, sizeof (mbstate1));
else {
col_a = COLS > 83 ? (COLS - 32) >> 2 : 12;
col_b = COLS > 49 ? (COLS - 10) >> 1 : 19;
- col = pad (f, mutt_strlen (t1), col_a);
+ col = pad (f, str_len (t1), col_a);
}
if (ismacro > 0) {
- if (!mutt_strcmp (Pager, "builtin"))
+ if (!str_cmp (Pager, "builtin"))
fputs ("_\010", f);
fputs ("M ", f);
col += 2;
if (!split) {
col += print_macro (f, col_b - col - 4, &t2);
- if (mutt_strlen (t2) > col_b - col)
+ if (str_len (t2) > col_b - col)
t2 = "...";
}
}
SKIPWS (t3);
/* FIXME: this is completely wrong */
- if ((n = mutt_strlen (t3)) > COLS - col) {
+ if ((n = str_len (t3)) > COLS - col) {
n = COLS - col;
for (col_a = n; col_a > 0 && t3[col_a] != ' '; col_a--);
if (col_a)
print_macro (f, n, &t3);
if (*t3) {
- if (mutt_strcmp (Pager, "builtin")) {
+ if (str_cmp (Pager, "builtin")) {
fputc ('\n', f);
n = 0;
}
prev = h->last - 1;
if (prev < 0)
prev = HistSize - 1;
- if (!h->hist[prev] || mutt_strcmp (h->hist[prev], s) != 0) {
+ if (!h->hist[prev] || str_cmp (h->hist[prev], s) != 0) {
str_replace (&h->hist[h->last++], s);
if (h->last > HistSize - 1)
h->last = 0;
_mutt_expand_path (path, sizeof (path), 1);
FREE (&pattern.data);
memset (&pattern, 0, sizeof (pattern));
- pattern.data = safe_strdup (path);
+ pattern.data = str_dup (path);
}
#ifdef USE_COMPRESSED
else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK)) {
mutt_check_simple (tmp, sizeof (tmp), DefaultHook);
FREE (&pattern.data);
memset (&pattern, 0, sizeof (pattern));
- pattern.data = safe_strdup (tmp);
+ pattern.data = str_dup (tmp);
}
if (data & (M_MBOXHOOK | M_SAVEHOOK | M_FCCHOOK)) {
mutt_expand_path (path, sizeof (path));
FREE (&command.data);
memset (&command, 0, sizeof (command));
- command.data = safe_strdup (path);
+ command.data = str_dup (path);
}
/* check to make sure that a matching hook doesn't already exist */
for (ptr = Hooks; ptr; ptr = ptr->next) {
if (ptr->type == data &&
- ptr->rx.not == not && !mutt_strcmp (pattern.data, ptr->rx.pattern)) {
+ ptr->rx.not == not && !str_cmp (pattern.data, ptr->rx.pattern)) {
if (data &
(M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK |
M_ACCOUNTHOOK | M_REPLYHOOK)) {
/* these hooks allow multiple commands with the same
* pattern, so if we've already seen this pattern/command pair, just
* ignore it instead of creating a duplicate */
- if (!mutt_strcmp (ptr->command, command.data)) {
+ if (!str_cmp (ptr->command, command.data)) {
FREE (&command.data);
FREE (&pattern.data);
return 0;
{
while (MoreArgs (s)) {
mutt_extract_token (buf, s, 0);
- if (mutt_strcmp ("*", buf->data) == 0) {
+ if (str_cmp ("*", buf->data) == 0) {
if (current_hook_type) {
snprintf (err->data, err->dsize,
_("unhook: Can't do unhook * from within a hook."));
if (ImapAuthenticators && *ImapAuthenticators) {
/* Try user-specified list of authentication methods */
- methods = safe_strdup (ImapAuthenticators);
+ methods = str_dup (ImapAuthenticators);
for (method = methods; method; method = delim) {
delim = strchr (method, ':');
*/
mutt_to_base64 ((unsigned char *) ibuf, (unsigned char *) obuf,
- mutt_strlen (obuf), sizeof (ibuf) - 2);
- safe_strcat (ibuf, sizeof (ibuf), "\r\n");
+ str_len (obuf), sizeof (ibuf) - 2);
+ str_cat (ibuf, sizeof (ibuf), "\r\n");
mutt_socket_write (idata->conn, ibuf);
do
unsigned int secret_len, chal_len;
int i;
- secret_len = mutt_strlen (password);
- chal_len = mutt_strlen (challenge);
+ secret_len = str_len (password);
+ chal_len = str_len (challenge);
/* passwords longer than MD5_BLOCK_LEN bytes are substituted with their MD5
* digests */
/* get an IMAP service ticket for the server */
snprintf (buf1, sizeof (buf1), "imap@%s", idata->conn->account.host);
request_buf.value = buf1;
- request_buf.length = mutt_strlen (buf1) + 1;
+ request_buf.length = str_len (buf1) + 1;
maj_stat = gss_import_name (&min_stat, &request_buf, gss_nt_service_name,
&target_name);
if (maj_stat != GSS_S_COMPLETE) {
mutt_to_base64 ((unsigned char *) buf1, send_token.value, send_token.length,
sizeof (buf1) - 2);
gss_release_buffer (&min_stat, &send_token);
- safe_strcat (buf1, sizeof (buf1), "\r\n");
+ str_cat (buf1, sizeof (buf1), "\r\n");
mutt_socket_write (idata->conn, buf1);
while (maj_stat == GSS_S_CONTINUE_NEEDED) {
mutt_to_base64 ((unsigned char *) buf1, send_token.value,
send_token.length, sizeof (buf1) - 2);
gss_release_buffer (&min_stat, &send_token);
- safe_strcat (buf1, sizeof (buf1), "\r\n");
+ str_cat (buf1, sizeof (buf1), "\r\n");
mutt_socket_write (idata->conn, buf1);
}
/* server decides if principal can log in as user */
strncpy (buf1 + 4, idata->conn->account.user, sizeof (buf1) - 4);
request_buf.value = buf1;
- request_buf.length = 4 + mutt_strlen (idata->conn->account.user) + 1;
+ request_buf.length = 4 + str_len (idata->conn->account.user) + 1;
maj_stat = gss_wrap (&min_stat, context, 0, GSS_C_QOP_DEFAULT, &request_buf,
&cflags, &send_token);
if (maj_stat != GSS_S_COMPLETE) {
mutt_to_base64 ((unsigned char *) buf1, send_token.value, send_token.length,
sizeof (buf1) - 2);
debug_print (2, ("Requesting authorisation as %s\n", idata->conn->account.user));
- safe_strcat (buf1, sizeof (buf1), "\r\n");
+ str_cat (buf1, sizeof (buf1), "\r\n");
mutt_socket_write (idata->conn, buf1);
/* Joy of victory or agony of defeat? */
if (irc == IMAP_CMD_RESPOND) {
#ifdef USE_SASL2
if (sasl_decode64
- (idata->cmd.buf + 2, mutt_strlen (idata->cmd.buf + 2), buf,
+ (idata->cmd.buf + 2, str_len (idata->cmd.buf + 2), buf,
LONG_STRING - 1,
#else
- if (sasl_decode64 (idata->cmd.buf + 2, mutt_strlen (idata->cmd.buf + 2), buf,
+ if (sasl_decode64 (idata->cmd.buf + 2, str_len (idata->cmd.buf + 2), buf,
#endif
&len) != SASL_OK) {
debug_print (1, ("error base64-decoding server response.\n"));
if (!mx.mbox) {
home_namespace = 1;
mbox[0] = '\0'; /* Do not replace "" with "INBOX" here */
- mx.mbox = safe_strdup (ImapHomeNamespace);
+ mx.mbox = str_dup (ImapHomeNamespace);
if (mutt_bit_isset (idata->capabilities, NAMESPACE)) {
mutt_message _("Getting namespaces...");
imap_unquote_string (buf); /* As kludgy as it gets */
mbox[sizeof (mbox) - 1] = '\0';
strncpy (mbox, buf, sizeof (mbox) - 1);
- n = mutt_strlen (mbox);
+ n = str_len (mbox);
debug_print (3, ("mbox: %s\n", mbox));
imap_unmunge_mbox_name (cur_folder);
if (!noinferiors && cur_folder[0] &&
- (n = mutt_strlen (mbox)) < LONG_STRING - 1) {
+ (n = str_len (mbox)) < LONG_STRING - 1) {
mbox[n++] = idata->delim;
mbox[n] = '\0';
}
if (!home_namespace)
showparents = 1;
imap_qualify_path (buf, sizeof (buf), &mx, mbox);
- state->folder = safe_strdup (buf);
+ state->folder = str_dup (buf);
n--;
}
ctmp = mbox[n];
mbox[n] = '\0';
imap_qualify_path (buf, sizeof (buf), &mx, mbox);
- state->folder = safe_strdup (buf);
+ state->folder = str_dup (buf);
}
mbox[n] = ctmp;
}
imap_add_folder (idata->delim, relpath, 1, 0, state, 1);
if (!state->folder) {
imap_qualify_path (buf, sizeof (buf), &mx, relpath);
- state->folder = safe_strdup (buf);
+ state->folder = str_dup (buf);
}
}
}
/* no namespace, no folder: set folder to host only */
if (!state->folder) {
imap_qualify_path (buf, sizeof (buf), &mx, NULL);
- state->folder = safe_strdup (buf);
+ state->folder = str_dup (buf);
}
if (home_namespace && mbox[0] != '\0') {
strfcpy (buf, NONULL (mx.mbox), sizeof (buf));
/* append a delimiter if necessary */
- n = mutt_strlen (buf);
+ n = str_len (buf);
if (n && (n < sizeof (buf) - 1) && (buf[n - 1] != idata->delim)) {
buf[n++] = idata->delim;
buf[n] = '\0';
if (mutt_get_field (_("Create mailbox: "), buf, sizeof (buf), M_FILE) < 0)
goto fail;
- if (!mutt_strlen (buf)) {
+ if (!str_len (buf)) {
mutt_error (_("Mailbox must have a name."));
mutt_sleep (1);
goto fail;
if (mutt_get_field (buf, newname, sizeof (newname), M_FILE) < 0)
goto fail;
- if (!mutt_strlen (newname)) {
+ if (!str_len (newname)) {
mutt_error (_("Mailbox must have a name."));
mutt_sleep (1);
goto fail;
if (isparent)
noselect = 1;
/* prune current folder from output */
- if (isparent || safe_strncmp (name, mx.mbox, mutt_strlen (name)))
+ if (isparent || str_ncmp (name, mx.mbox, str_len (name)))
imap_add_folder (idata->delim, name, noselect, noinferiors, state,
isparent);
}
if (isparent)
strfcpy (relpath, "../", sizeof (relpath));
/* strip current folder from target, to render a relative path */
- else if (!safe_strncmp (mx.mbox, folder, mutt_strlen (mx.mbox)))
- strfcpy (relpath, folder + mutt_strlen (mx.mbox), sizeof (relpath));
+ else if (!str_ncmp (mx.mbox, folder, str_len (mx.mbox)))
+ strfcpy (relpath, folder + str_len (mx.mbox), sizeof (relpath));
else
strfcpy (relpath, folder, sizeof (relpath));
}
imap_qualify_path (tmp, sizeof (tmp), &mx, folder);
- (state->entry)[state->entrylen].name = safe_strdup (tmp);
+ (state->entry)[state->entrylen].name = str_dup (tmp);
/* mark desc with delim in browser if it can have subfolders */
- if (!isparent && !noinferiors && mutt_strlen (relpath) < sizeof (relpath) - 1) {
- relpath[mutt_strlen (relpath) + 1] = '\0';
- relpath[mutt_strlen (relpath)] = delim;
+ if (!isparent && !noinferiors && str_len (relpath) < sizeof (relpath) - 1) {
+ relpath[str_len (relpath) + 1] = '\0';
+ relpath[str_len (relpath)] = delim;
}
- (state->entry)[state->entrylen].desc = safe_strdup (relpath);
+ (state->entry)[state->entrylen].desc = str_dup (relpath);
(state->entry)[state->entrylen].imap = 1;
/* delimiter at the root is useless. */
static int compare_names (struct folder_file *a, struct folder_file *b)
{
- return mutt_strcmp (a->name, b->name);
+ return str_cmp (a->name, b->name);
}
static int browse_get_namespace (IMAP_DATA * idata, char *nsbuf, int nsblen,
cmd_make_sequence (idata);
/* seq, space, cmd, \r\n\0 */
- outlen = mutt_strlen (idata->cmd.seq) + mutt_strlen (cmd) + 4;
+ outlen = str_len (idata->cmd.seq) + str_len (cmd) + 4;
out = (char *) safe_malloc (outlen);
snprintf (out, outlen, "%s %s\r\n", idata->cmd.seq, cmd);
/* create sequence for command */
cmd_make_sequence (idata);
/* seq, space, cmd, \r\n\0 */
- outlen = mutt_strlen (idata->cmd.seq) + mutt_strlen (cmd) + 4;
+ outlen = str_len (idata->cmd.seq) + str_len (cmd) + 4;
out = (char *) safe_malloc (outlen);
snprintf (out, outlen, "%s %s\r\n", idata->cmd.seq, cmd);
s = imap_next_word (s);
FREE (&idata->capstr);
- idata->capstr = safe_strdup (s);
+ idata->capstr = str_dup (s);
memset (idata->capabilities, 0, sizeof (idata->capabilities));
/* Clean up path and replace the one in the ctx */
imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
FREE (&(idata->mailbox));
- idata->mailbox = safe_strdup (buf);
+ idata->mailbox = str_dup (buf);
imap_qualify_path (buf, sizeof (buf), &mx, idata->mailbox);
FREE (&(ctx->path));
- ctx->path = safe_strdup (buf);
+ ctx->path = str_dup (buf);
idata->ctx = ctx;
{
if (mutt_bit_isset (idata->rights, aclbit))
if (flag)
- safe_strcat (flags, flsize, str);
+ str_cat (flags, flsize, str);
}
/* imap_make_msg_set: make an IMAP4rev1 UID message set out of a set of
* command on a mailbox that you have selected
*/
- if (mutt_strcmp (mbox_unquoted, idata->mailbox) == 0
+ if (str_cmp (mbox_unquoted, idata->mailbox) == 0
|| (ascii_strcasecmp (mbox_unquoted, "INBOX") == 0
- && safe_strcasecmp (mbox_unquoted, idata->mailbox) == 0)) {
+ && str_casecmp (mbox_unquoted, idata->mailbox) == 0)) {
strfcpy (buf, "NOOP", sizeof (buf));
}
else if (mutt_bit_isset (idata->capabilities, IMAP4REV1) ||
/* The mailbox name may or may not be quoted here. We could try to
* munge the server response and compare with quoted (or vise versa)
* but it is probably more efficient to just strncmp against both. */
- if (safe_strncmp (mbox_unquoted, s, mutt_strlen (mbox_unquoted)) == 0
- || safe_strncmp (mbox, s, mutt_strlen (mbox)) == 0) {
+ if (str_ncmp (mbox_unquoted, s, str_len (mbox_unquoted)) == 0
+ || str_ncmp (mbox, s, str_len (mbox)) == 0) {
s = imap_next_word (s);
s = imap_next_word (s);
if (isdigit ((unsigned char) *s)) {
int matchlen;
int i = 0;
- matchlen = mutt_strlen (dest);
+ matchlen = str_len (dest);
if (list_empty (Incoming))
return (-1);
for (i = 0; i < Incoming->length; i++) {
mailbox = (BUFFY*) Incoming->data[i];
- if (!safe_strncmp (dest, mailbox->path, matchlen)) {
+ if (!str_ncmp (dest, mailbox->path, matchlen)) {
if (rc) {
strfcpy (dest, mailbox->path, len);
rc = 0;
url.user = NULL;
url.path = NULL;
url_ciss_tostring (&url, urlstr, sizeof (urlstr), 0);
- if (!safe_strncmp (dest, urlstr, matchlen)) {
+ if (!str_ncmp (dest, urlstr, matchlen)) {
if (rc) {
strfcpy (dest, urlstr, len);
rc = 0;
/* if the folder isn't selectable, append delimiter to force browse
* to enter it on second tab. */
if (noselect) {
- clen = mutt_strlen (list_word);
+ clen = str_len (list_word);
list_word[clen++] = delim;
list_word[clen] = '\0';
}
/* copy in first word */
if (!completions) {
strfcpy (completion, list_word, sizeof (completion));
- matchlen = mutt_strlen (completion);
+ matchlen = str_len (completion);
completions++;
continue;
}
cache->uid = HEADER_DATA (h)->uid;
mutt_mktemp (path);
- cache->path = safe_strdup (path);
+ cache->path = str_dup (path);
if (!(msg->fp = safe_fopen (path, "w+"))) {
FREE (&cache->path);
return -1;
while (keywords) {
if (msg_has_flag (mailbox_flags, keywords->data)) {
- safe_strcat (s, slen, keywords->data);
- safe_strcat (s, slen, " ");
+ str_cat (s, slen, keywords->data);
+ str_cat (s, slen, " ");
}
keywords = keywords->next;
}
#if USE_HCACHE
static size_t imap_hcache_keylen (const char *fn)
{
- return mutt_strlen (fn);
+ return str_len (fn);
}
/* msg_fetch_header: import IMAP FETCH response into an IMAP_HEADER.
flag_list = flag_list->next;
while (flag_list) {
- if (!ascii_strncasecmp (flag_list->data, flag, mutt_strlen (flag_list->data)))
+ if (!ascii_strncasecmp (flag_list->data, flag, str_len (flag_list->data)))
return 1;
flag_list = flag_list->next;
mutt_perror (tmp);
return (-1);
}
- msg->path = safe_strdup (tmp);
+ msg->path = str_dup (tmp);
return 0;
}
void imap_utf7_encode (char **s)
{
if (Charset) {
- char *t = safe_strdup (*s);
+ char *t = str_dup (*s);
if (!mutt_convert_string (&t, Charset, "UTF-8", 0))
- utf8_to_utf7 (t, mutt_strlen (t), s, 0);
+ utf8_to_utf7 (t, str_len (t), s, 0);
FREE (&t);
}
}
void imap_utf7_decode (char **s)
{
if (Charset) {
- char *t = utf7_to_utf8 (*s, mutt_strlen (*s), 0, 0);
+ char *t = utf7_to_utf8 (*s, str_len (*s), 0, 0);
if (t && !mutt_convert_string (&t, "UTF-8", Charset, 0)) {
FREE (s);
mx->account.port = ImapPort;
mx->account.type = M_ACCT_TYPE_IMAP;
- c = safe_strdup (path);
+ c = str_dup (path);
url_parse_ciss (&url, c);
if (!(url.scheme == U_IMAP || url.scheme == U_IMAPS) ||
return -1;
}
- mx->mbox = safe_strdup (url.path);
+ mx->mbox = str_dup (url.path);
if (url.scheme == U_IMAPS)
mx->account.flags |= M_ACCT_SSL;
if (imap_parse_path (path, &target) < 0)
return;
- tlen = mutt_strlen (target.mbox);
+ tlen = str_len (target.mbox);
/* check whether we can do '=' substitution */
if (mx_get_magic (Maildir) == M_IMAP && !imap_parse_path (Maildir, &home)) {
- hlen = mutt_strlen (home.mbox);
+ hlen = str_len (home.mbox);
if (tlen && mutt_account_match (&home.account, &target.account) &&
- !safe_strncmp (home.mbox, target.mbox, hlen)) {
+ !str_ncmp (home.mbox, target.mbox, hlen)) {
if (!hlen)
home_match = 1;
else
{
char *buf;
- buf = safe_strdup (src);
+ buf = str_dup (src);
imap_utf7_encode (&buf);
imap_quote_string (dest, dlen, buf);
imap_unquote_string (s);
- buf = safe_strdup (s);
+ buf = str_dup (s);
if (buf) {
imap_utf7_decode (&buf);
- strncpy (s, buf, mutt_strlen (s));
+ strncpy (s, buf, str_len (s));
}
FREE (&buf);
/* for synonym warning reports: adds synonym to end of list */
static void syn_add (int n, int o) {
syn_t* tmp = safe_malloc (sizeof (syn_t));
- tmp->f = safe_strdup (CurRCFile);
+ tmp->f = str_dup (CurRCFile);
tmp->l = CurRCLine;
tmp->n = n;
tmp->o = o;
int i;
for (i = 0; MuttVars[i].option; i++)
- if (mutt_strcmp (s, MuttVars[i].option) == 0) {
+ if (str_cmp (s, MuttVars[i].option) == 0) {
if (MuttVars[i].type == DT_SYN)
syn_add (mutt_option_index ((char *) MuttVars[i].data), i);
return (MuttVars[i].type ==
FREE (&expn.data);
}
else if (expn.data) {
- expnlen = mutt_strlen (expn.data);
- tok->dsize = expnlen + mutt_strlen (tok->dptr) + 1;
+ expnlen = str_len (expn.data);
+ tok->dsize = expnlen + str_len (tok->dptr) + 1;
ptr = safe_malloc (tok->dsize);
memcpy (ptr, expn.data, expnlen);
strcpy (ptr + expnlen, tok->dptr); /* __STRCPY_CHECKED__ */
if (!*list || last) {
t = (LIST *) safe_calloc (1, sizeof (LIST));
- t->data = safe_strdup (str);
+ t->data = str_dup (str);
if (last) {
last->next = t;
last = last->next;
}
/* Now t is the SPAM_LIST* that we want to modify. It is prepared. */
- t->template = safe_strdup (templ);
+ t->template = str_dup (templ);
/* Find highest match number in template string */
t->nmatch = 0;
spam = *list;
if (!spam)
return 0;
- if (spam->rx && !mutt_strcmp (spam->rx->pattern, pat)) {
+ if (spam->rx && !str_cmp (spam->rx->pattern, pat)) {
*list = spam->next;
rx_free (&spam->rx);
FREE(&spam->template);
prev = spam;
for (spam = prev->next; spam;) {
- if (!mutt_strcmp (spam->rx->pattern, pat)) {
+ if (!str_cmp (spam->rx->pattern, pat)) {
prev->next = spam->next;
rx_free (&spam->rx);
FREE(spam->template);
{
LIST *p, *last = NULL;
- if (mutt_strcmp ("*", str) == 0)
+ if (str_cmp ("*", str) == 0)
mutt_free_list (l); /* ``unCMD *'' means delete all current entries */
else {
p = *l;
{
int i = 0;
- if (mutt_strcmp ("*", str) == 0) {
+ if (str_cmp ("*", str) == 0) {
list_del (l, (list_del_t*) rx_free);
return (0);
}
continue;
for (j = 0; b[j].name; j++)
- if (!ascii_strncasecmp (tmp->data, b[j].name, mutt_strlen (tmp->data))
- && (mutt_strlen (b[j].name) == mutt_strlen (tmp->data))) {
+ if (!ascii_strncasecmp (tmp->data, b[j].name, str_len (tmp->data))
+ && (str_len (b[j].name) == str_len (tmp->data))) {
res = 1;
break;
}
char *p = NULL;
i = 0;
- j = mutt_strlen (tmp->data);
+ j = str_len (tmp->data);
/* need at least input of 'feature_X' */
if (j >= 7) {
p = tmp->data + 7;
j -= 7;
while (Features[i].name) {
- if (mutt_strlen (Features[i].name) == j &&
+ if (str_len (Features[i].name) == j &&
ascii_strncasecmp (Features[i].name, p, j)) {
res = 1;
break;
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&Alternates, buf->data);
- if (mutt_strcmp (buf->data, "*") &&
+ if (str_cmp (buf->data, "*") &&
add_to_rx_list (&UnAlternates, buf->data, REG_ICASE, err) != 0)
return -1;
/* nospam only ever has one parameter. */
/* "*" is a special case. */
- if (!mutt_strcmp (buf->data, "*")) {
+ if (!str_cmp (buf->data, "*")) {
mutt_free_spam_list (&SpamList);
list_del (&NoSpamList, (list_del_t*) rx_free);
return 0;
/*
* Check for deletion of entire list
*/
- if (mutt_strcmp (buf->data, "*") == 0) {
+ if (str_cmp (buf->data, "*") == 0) {
mutt_free_list ((LIST **) data);
break;
}
remove_from_rx_list (&SubscribedLists, buf->data);
remove_from_rx_list (&MailLists, buf->data);
- if (mutt_strcmp (buf->data, "*") &&
+ if (str_cmp (buf->data, "*") &&
add_to_rx_list (&UnMailLists, buf->data, REG_ICASE, err) != 0)
return -1;
}
mutt_extract_token (buf, s, 0);
remove_from_rx_list (&SubscribedLists, buf->data);
- if (mutt_strcmp (buf->data, "*") &&
+ if (str_cmp (buf->data, "*") &&
add_to_rx_list (&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
return -1;
}
do {
mutt_extract_token (buf, s, 0);
- if (mutt_strcmp ("*", buf->data) == 0) {
+ if (str_cmp ("*", buf->data) == 0) {
if (CurrentMenu == MENU_ALIAS) {
for (tmp = Aliases; tmp; tmp = tmp->next)
tmp->del = 1;
}
else
for (tmp = Aliases; tmp; tmp = tmp->next) {
- if (safe_strcasecmp (buf->data, tmp->name) == 0) {
+ if (str_casecmp (buf->data, tmp->name) == 0) {
if (CurrentMenu == MENU_ALIAS) {
tmp->del = 1;
set_option (OPTFORCEREDRAWINDEX);
/* check to see if an alias with this name already exists */
for (; tmp; tmp = tmp->next) {
- if (!safe_strcasecmp (tmp->name, buf->data))
+ if (!str_casecmp (tmp->name, buf->data))
break;
last = tmp;
}
/* create a new alias */
tmp = (ALIAS *) safe_calloc (1, sizeof (ALIAS));
tmp->self = tmp;
- tmp->name = safe_strdup (buf->data);
+ tmp->name = str_dup (buf->data);
/* give the main addressbook code a chance */
if (CurrentMenu == MENU_ALIAS)
set_option (OPTMENUCALLER);
do {
mutt_extract_token (buf, s, 0);
- if (mutt_strcmp ("*", buf->data) == 0)
+ if (str_cmp ("*", buf->data) == 0)
mutt_free_list (&UserHeader);
else {
tmp = UserHeader;
last = NULL;
- l = mutt_strlen (buf->data);
+ l = str_len (buf->data);
if (buf->data[l - 1] == ':')
l--;
{
int i, flags = 0;
- if (safe_strncmp ("reverse-", s, 8) == 0) {
+ if (str_ncmp ("reverse-", s, 8) == 0) {
s += 8;
flags = SORT_REVERSE;
}
- if (safe_strncmp ("last-", s, 5) == 0) {
+ if (str_ncmp ("last-", s, 5) == 0) {
s += 5;
flags |= SORT_LAST;
}
switch (p->type & DT_MASK) {
case DT_STR:
if (!p->init && *((char **) p->data))
- p->init = (unsigned long) safe_strdup (*((char **) p->data));
+ p->init = (unsigned long) str_dup (*((char **) p->data));
break;
case DT_PATH:
if (!p->init && *((char **) p->data)) {
- char *cp = safe_strdup (*((char **) p->data));
+ char *cp = str_dup (*((char **) p->data));
/* mutt_pretty_mailbox (cp); */
p->init = (unsigned long) cp;
*tmp = '\0';
rfc822_write_address (tmp, sizeof (tmp), *((ADDRESS **) p->data), 0);
- p->init = (unsigned long) safe_strdup (tmp);
+ p->init = (unsigned long) str_dup (tmp);
}
break;
case DT_RX:
rx_t* pp = (rx_t*) p->data;
if (!p->init && pp->pattern)
- p->init = (unsigned long) safe_strdup (pp->pattern);
+ p->init = (unsigned long) str_dup (pp->pattern);
break;
}
}
char *s = (char *) p->init;
pp->rx = safe_calloc (1, sizeof (regex_t));
- if (mutt_strcmp (p->option, "mask") != 0)
+ if (str_cmp (p->option, "mask") != 0)
flags |= mutt_which_case ((const char *) p->init);
- if (mutt_strcmp (p->option, "mask") == 0 && *s == '!') {
+ if (str_cmp (p->option, "mask") == 0 && *s == '!') {
s++;
pp->not = 1;
}
query = 1;
s->dptr++;
}
- else if (safe_strncmp ("no", s->dptr, 2) == 0) {
+ else if (str_ncmp ("no", s->dptr, 2) == 0) {
s->dptr += 2;
unset = !unset;
}
- else if (safe_strncmp ("inv", s->dptr, 3) == 0) {
+ else if (str_ncmp ("inv", s->dptr, 3) == 0) {
s->dptr += 3;
inv = !inv;
}
mutt_extract_token (tmp, s, M_TOKEN_EQUAL);
if ((idx = mutt_option_index (tmp->data)) == -1 &&
- !(reset && !mutt_strcmp ("all", tmp->data))) {
+ !(reset && !str_cmp ("all", tmp->data))) {
snprintf (err->data, err->dsize, _("%s: unknown variable"), tmp->data);
return (-1);
}
return (-1);
}
- if (!mutt_strcmp ("all", tmp->data)) {
+ if (!str_cmp ("all", tmp->data)) {
for (idx = 0; MuttVars[idx].option; idx++)
mutt_restore_default (&MuttVars[idx]);
return 0;
if (DTYPE (MuttVars[idx].type) == DT_PATH) {
strfcpy (scratch, tmp->data, sizeof (scratch));
mutt_expand_path (scratch, sizeof (scratch));
- *((char **) MuttVars[idx].data) = safe_strdup (scratch);
+ *((char **) MuttVars[idx].data) = str_dup (scratch);
}
else if (DTYPE (MuttVars[idx].type) == DT_STR) {
- *((char **) MuttVars[idx].data) = safe_strdup (tmp->data);
- if (mutt_strcmp (MuttVars[idx].option, "charset") == 0)
+ *((char **) MuttVars[idx].data) = str_dup (tmp->data);
+ if (str_cmp (MuttVars[idx].option, "charset") == 0)
mutt_set_charset (Charset);
}
else {
}
if (option (OPTATTACHMSG)
- && !mutt_strcmp (MuttVars[idx].option, "reply_regexp")) {
+ && !str_cmp (MuttVars[idx].option, "reply_regexp")) {
snprintf (err->data, err->dsize,
"Operation not permitted when in attach-message mode.");
r = -1;
/* copy the value of the string */
mutt_extract_token (tmp, s, 0);
- if (!ptr->pattern || mutt_strcmp (ptr->pattern, tmp->data) != 0) {
+ if (!ptr->pattern || str_cmp (ptr->pattern, tmp->data) != 0) {
int not = 0;
/* $mask is case-sensitive */
- if (mutt_strcmp (MuttVars[idx].option, "mask") != 0)
+ if (str_cmp (MuttVars[idx].option, "mask") != 0)
flags |= mutt_which_case (tmp->data);
p = tmp->data;
- if (mutt_strcmp (MuttVars[idx].option, "mask") == 0) {
+ if (str_cmp (MuttVars[idx].option, "mask") == 0) {
if (*p == '!') {
not = 1;
p++;
FREE (&ptr->rx);
}
- ptr->pattern = safe_strdup (tmp->data);
+ ptr->pattern = str_dup (tmp->data);
ptr->rx = rx;
ptr->not = not;
/* $reply_regexp and $alterantes require special treatment */
if (Context && Context->msgcount &&
- mutt_strcmp (MuttVars[idx].option, "reply_regexp") == 0) {
+ str_cmp (MuttVars[idx].option, "reply_regexp") == 0) {
regmatch_t pmatch[1];
int i;
*ptr = (short) val;
/* these ones need a sanity check */
- if (mutt_strcmp (MuttVars[idx].option, "history") == 0) {
+ if (str_cmp (MuttVars[idx].option, "history") == 0) {
if (*ptr < 0)
*ptr = 0;
mutt_init_history ();
}
- else if (mutt_strcmp (MuttVars[idx].option, "pager_index_lines") == 0) {
+ else if (str_cmp (MuttVars[idx].option, "pager_index_lines") == 0) {
if (*ptr < 0)
*ptr = 0;
}
CurRCLine++;
conv = ConfigCharset && (*ConfigCharset) && Charset;
if (conv) {
- currentline = safe_strdup (linebuf);
+ currentline = str_dup (linebuf);
if (!currentline)
continue;
mutt_convert_string (¤tline, ConfigCharset, Charset, 0);
memset (&expn, 0, sizeof (expn));
expn.data = expn.dptr = line;
- expn.dsize = mutt_strlen (line);
+ expn.dsize = str_len (line);
*err->data = 0;
}
mutt_extract_token (token, &expn, 0);
for (i = 0; Commands[i].name; i++) {
- if (!mutt_strcmp (token->data, Commands[i].name)) {
+ if (!str_cmp (token->data, Commands[i].name)) {
if (Commands[i].func (token, &expn, Commands[i].data, err) != 0)
goto finish;
break;
/* return the completed command */
strncpy (buffer, Completed, len - spaces);
}
- else if (!safe_strncmp (buffer, "set", 3)
- || !safe_strncmp (buffer, "unset", 5)
- || !safe_strncmp (buffer, "reset", 5)
- || !safe_strncmp (buffer, "toggle", 6)) { /* complete variables */
+ else if (!str_ncmp (buffer, "set", 3)
+ || !str_ncmp (buffer, "unset", 5)
+ || !str_ncmp (buffer, "reset", 5)
+ || !str_ncmp (buffer, "toggle", 6)) { /* complete variables */
char *prefixes[] = { "no", "inv", "?", "&", 0 };
pt++;
/* loop through all the possible prefixes (no, inv, ...) */
- if (!safe_strncmp (buffer, "set", 3)) {
+ if (!str_ncmp (buffer, "set", 3)) {
for (num = 0; prefixes[num]; num++) {
- if (!safe_strncmp (pt, prefixes[num], mutt_strlen (prefixes[num]))) {
- pt += mutt_strlen (prefixes[num]);
+ if (!str_ncmp (pt, prefixes[num], str_len (prefixes[num]))) {
+ pt += str_len (prefixes[num]);
break;
}
}
strncpy (pt, Completed, buffer + len - pt - spaces);
}
- else if (!safe_strncmp (buffer, "exec", 4)) {
+ else if (!str_ncmp (buffer, "exec", 4)) {
struct binding_t *menu = km_get_table (CurrentMenu);
if (!menu && CurrentMenu != MENU_PAGER)
if (*pt == '=') /* abort if no var before the '=' */
return 0;
- if (safe_strncmp (buffer, "set", 3) == 0) {
+ if (str_ncmp (buffer, "set", 3) == 0) {
int idx;
strfcpy (var, pt, sizeof (var));
/* ignore the trailing '=' when comparing */
- var[mutt_strlen (var) - 1] = 0;
+ var[str_len (var) - 1] = 0;
if ((idx = mutt_option_index (var)) == -1)
return 0; /* no such variable. */
else {
/* on one of the systems I use, getcwd() does not return the same prefix
as is listed in the passwd file */
if ((p = getenv ("HOME")))
- Homedir = safe_strdup (p);
+ Homedir = str_dup (p);
/* Get some information about the user */
if ((pw = getpwuid (getuid ()))) {
char rnbuf[STRING];
- Username = safe_strdup (pw->pw_name);
+ Username = str_dup (pw->pw_name);
if (!Homedir)
- Homedir = safe_strdup (pw->pw_dir);
+ Homedir = str_dup (pw->pw_dir);
- Realname = safe_strdup (mutt_gecos_name (rnbuf, sizeof (rnbuf), pw));
- Shell = safe_strdup (pw->pw_shell);
+ Realname = str_dup (mutt_gecos_name (rnbuf, sizeof (rnbuf), pw));
+ Shell = str_dup (pw->pw_shell);
}
else {
if (!Homedir) {
exit (1);
}
if ((p = getenv ("USER")))
- Username = safe_strdup (p);
+ Username = str_dup (p);
else {
mutt_endwin (NULL);
fputs (_("unable to determine username"), stderr);
exit (1);
}
- Shell = safe_strdup ((p = getenv ("SHELL")) ? p : "/bin/sh");
+ Shell = str_dup ((p = getenv ("SHELL")) ? p : "/bin/sh");
}
debug_start(Homedir);
strfcpy (buffer, p, sizeof (buffer)); /* save the domain for below */
}
else
- Hostname = safe_strdup (utsname.nodename);
+ Hostname = str_dup (utsname.nodename);
#ifndef DOMAIN
#define DOMAIN buffer
if (!p && getdnsdomainname (buffer, sizeof (buffer)) == -1)
- Fqdn = safe_strdup ("@");
+ Fqdn = str_dup ("@");
else
#endif /* DOMAIN */
if (*DOMAIN != '@') {
- Fqdn = safe_malloc (mutt_strlen (DOMAIN) + mutt_strlen (Hostname) + 2);
+ Fqdn = safe_malloc (str_len (DOMAIN) + str_len (Hostname) + 2);
sprintf (Fqdn, "%s.%s", NONULL (Hostname), DOMAIN); /* __SPRINTF_CHECKED__ */
}
else
- Fqdn = safe_strdup (NONULL (Hostname));
+ Fqdn = str_dup (NONULL (Hostname));
#ifdef USE_NNTP
{
&& (*i != '\n'))
i++;
*i = '\0';
- NewsServer = safe_strdup (p);
+ NewsServer = str_dup (p);
fclose (f);
}
}
if ((p = getenv ("NNTPSERVER")))
- NewsServer = safe_strdup (p);
+ NewsServer = str_dup (p);
#endif
if ((p = getenv ("MAIL")))
- Spoolfile = safe_strdup (p);
+ Spoolfile = str_dup (p);
else if ((p = getenv ("MAILDIR")))
- Spoolfile = safe_strdup (p);
+ Spoolfile = str_dup (p);
else {
#ifdef HOMESPOOL
mutt_concat_path (buffer, NONULL (Homedir), MAILPATH, sizeof (buffer));
#else
mutt_concat_path (buffer, MAILPATH, NONULL (Username), sizeof (buffer));
#endif
- Spoolfile = safe_strdup (buffer);
+ Spoolfile = str_dup (buffer);
}
if ((p = getenv ("MAILCAPS")))
- MailcapPath = safe_strdup (p);
+ MailcapPath = str_dup (p);
else {
/* Default search path from RFC1524 */
MailcapPath =
- safe_strdup ("~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR
+ str_dup ("~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR
"/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap");
}
- Tempdir = safe_strdup ((p = getenv ("TMPDIR")) ? p : "/tmp");
+ Tempdir = str_dup ((p = getenv ("TMPDIR")) ? p : "/tmp");
p = getenv ("VISUAL");
if (!p) {
if (!p)
p = "vi";
}
- Editor = safe_strdup (p);
- Visual = safe_strdup (p);
+ Editor = str_dup (p);
+ Visual = str_dup (p);
if ((p = getenv ("REPLYTO")) != NULL) {
BUFFER buf, token;
memset (&buf, 0, sizeof (buf));
buf.data = buf.dptr = buffer;
- buf.dsize = mutt_strlen (buffer);
+ buf.dsize = str_len (buffer);
memset (&token, 0, sizeof (token));
parse_my_hdr (&token, &buf, 0, &err);
NONULL (Homedir));
default_rc = 1;
- Muttrc = safe_strdup (buffer);
+ Muttrc = str_dup (buffer);
}
else {
strfcpy (buffer, Muttrc, sizeof (buffer));
FREE (&Muttrc);
mutt_expand_path (buffer, sizeof (buffer));
- Muttrc = safe_strdup (buffer);
+ Muttrc = str_dup (buffer);
}
FREE (&AliasFile);
- AliasFile = safe_strdup (NONULL (Muttrc));
+ AliasFile = str_dup (NONULL (Muttrc));
/* Process the global rc file if it exists and the user hasn't explicity
requested not to via "-n". */
}
static int opt_cmp (const void* a, const void* b) {
- return (mutt_strcmp ((*(struct option_t**) a)->option,
+ return (str_cmp ((*(struct option_t**) a)->option,
(*(struct option_t**) b)->option));
}
map = allocKeys (len, buf);
map->op = op;
- map->macro = safe_strdup (macro);
- map->descr = safe_strdup (descr);
+ map->macro = str_dup (macro);
+ map->descr = str_dup (descr);
tmp = Keymaps[menu];
for (i = 0; bindings[i].name; i++) {
if (!ascii_strncasecmp (start, bindings[i].name, len) &&
- mutt_strlen (bindings[i].name) == len)
+ str_len (bindings[i].name) == len)
return bindings[i].op;
}
static void push_string (char *s)
{
- char *pp, *p = s + mutt_strlen (s) - 1;
+ char *pp, *p = s + str_len (s) - 1;
size_t l;
int i, op = OP_NULL;
FOREVER {
strfcpy (s, km_keyname (map->keys[p]), len);
- len -= (l = mutt_strlen (s));
+ len -= (l = str_len (s));
if (++p >= map->len || !len)
return (1);
int i;
for (i = 0; bindings[i].name; i++)
- if (mutt_strcmp (func, bindings[i].name) == 0) {
+ if (str_cmp (func, bindings[i].name) == 0) {
km_bindkey (key, menu, bindings[i].op);
return (0);
}
}
else {
if (MoreArgs (s)) {
- seq = safe_strdup (buf->data);
+ seq = str_dup (buf->data);
mutt_extract_token (buf, s, M_TOKEN_CONDENSE);
if (MoreArgs (s)) {
&& CurrentMenu != MENU_PAGER)
bindings = OpGeneric;
- ops[nops] = get_op (bindings, function, mutt_strlen (function));
+ ops[nops] = get_op (bindings, function, str_len (function));
if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER)
- ops[nops] = get_op (OpGeneric, function, mutt_strlen (function));
+ ops[nops] = get_op (OpGeneric, function, str_len (function));
if (ops[nops] == OP_NULL) {
mutt_flushinp ();
char abs_oldpath[_POSIX_PATH_MAX];
if ((getcwd (abs_oldpath, sizeof abs_oldpath) == NULL) ||
- (mutt_strlen (abs_oldpath) + 1 + mutt_strlen (oldpath) + 1 >
+ (str_len (abs_oldpath) + 1 + str_len (oldpath) + 1 >
sizeof abs_oldpath))
return -1;
{
const char *fmt = "%s/%s";
- if (!*fname || (*dir && dir[mutt_strlen (dir) - 1] == '/'))
+ if (!*fname || (*dir && dir[str_len (dir) - 1] == '/'))
fmt = "%s%s";
snprintf (d, l, fmt, dir, fname);
rx_t *rx_compile (const char *s, int flags) {
rx_t *pp = safe_calloc (1, sizeof (rx_t));
- pp->pattern = safe_strdup (s);
+ pp->pattern = str_dup (s);
pp->rx = safe_calloc (1, sizeof (regex_t));
if (REGCOMP(pp->rx, NONULL (s), flags) != 0)
rx_free (&pp);
}
int rx_compare (const rx_t* r1, const rx_t* r2) {
- return (mutt_strcmp (r1->pattern, r2->pattern));
+ return (str_cmp (r1->pattern, r2->pattern));
}
int rx_list_match (list2_t* l, const char* pat) {
if (!pat || !*pat || list_empty(l))
return (-1);
for (i = 0; i < l->length; i++)
- if (mutt_strcmp (((rx_t*) l->data[i])->pattern, pat) == 0)
+ if (str_cmp (((rx_t*) l->data[i])->pattern, pat) == 0)
return (i);
return (-1);
}
#include "mem.h"
-char *safe_strdup (const char *s)
+char *str_dup (const char *s)
{
char *p;
size_t l;
if (!s || !*s)
return 0;
- l = mutt_strlen (s) + 1;
+ l = str_len (s) + 1;
p = (char *) safe_malloc (l);
memcpy (p, s, l);
return (p);
}
-char *safe_strcat (char *d, size_t l, const char *s)
+char *str_cat (char *d, size_t l, const char *s)
{
char *p = d;
return p;
}
-char *safe_strncat (char *d, size_t l, const char *s, size_t sl)
+char *str_ncat (char *d, size_t l, const char *s, size_t sl)
{
char *p = d;
return p;
}
-int mutt_strcmp (const char *a, const char *b)
+int str_cmp (const char *a, const char *b)
{
return strcmp (NONULL (a), NONULL (b));
}
-int safe_strcasecmp (const char *a, const char *b)
+int str_casecmp (const char *a, const char *b)
{
return strcasecmp (NONULL (a), NONULL (b));
}
-int safe_strncmp (const char *a, const char *b, size_t l)
+int str_ncmp (const char *a, const char *b, size_t l)
{
return strncmp (NONULL (a), NONULL (b), l);
}
-int safe_strncasecmp (const char *a, const char *b, size_t l)
+int str_ncasecmp (const char *a, const char *b, size_t l)
{
return strncasecmp (NONULL (a), NONULL (b), l);
}
-size_t mutt_strlen (const char *a)
+size_t str_len (const char *a)
{
return a ? strlen (a) : 0;
}
-int safe_strcoll (const char *a, const char *b)
+int str_coll (const char *a, const char *b)
{
return strcoll (NONULL (a), NONULL (b));
}
void str_replace (char **p, const char *s)
{
FREE (p);
- *p = safe_strdup (s);
+ *p = str_dup (s);
}
void str_adjust (char **p)
{
if (!p || !*p)
return;
- safe_realloc (p, mutt_strlen (*p) + 1);
+ safe_realloc (p, str_len (*p) + 1);
}
/* convert all characters in the string to lowercase */
if (end)
len = end - begin;
else
- len = mutt_strlen (begin);
+ len = str_len (begin);
p = safe_malloc (len + 1);
memcpy (p, begin, len);
}
int str_eq (const char* s1, const char* s2) {
- int l = mutt_strlen (s1);
+ int l = str_len (s1);
- if (l != mutt_strlen (s2))
+ if (l != str_len (s2))
return (0);
- return (safe_strncmp (s1, s2, l) == 0);
+ return (str_ncmp (s1, s2, l) == 0);
}
char* str_skip_initws (char* s) {
void str_skip_trailws (char *s) {
char *p;
- for (p = s + mutt_strlen (s) - 1; p >= s && ISSPACE (*p); p--)
+ for (p = s + str_len (s) - 1; p >= s && ISSPACE (*p); p--)
*p = 0;
}
* It's licensed under the GNU General Public License,
* please see the file GPL in the top level source directory.
*/
-
#ifndef _LIB_STR_H
#define _LIB_STR_H
* safety wrappers/replacements
* (mostly only difference: safely handle NULL strings)
*/
-char *safe_strdup (const char*);
-char *safe_strcat (char*, size_t, const char*);
-char *safe_strncat (char*, size_t, const char*, size_t);
-int mutt_strcmp (const char*, const char*);
-int safe_strcasecmp (const char*, const char*);
-int safe_strncmp (const char*, const char*, size_t);
-int safe_strncasecmp (const char*, const char*, size_t);
-int safe_strcoll (const char*, const char*);
-size_t mutt_strlen (const char*);
+char *str_dup (const char*);
+char *str_cat (char*, size_t, const char*);
+char *str_ncat (char*, size_t, const char*, size_t);
+int str_cmp (const char*, const char*);
+int str_casecmp (const char*, const char*);
+int str_ncmp (const char*, const char*, size_t);
+int str_ncasecmp (const char*, const char*, size_t);
+int str_coll (const char*, const char*);
+size_t str_len (const char*);
/*
* tools
}
if (subject)
- msg->env->subject = safe_strdup (subject);
+ msg->env->subject = str_dup (subject);
if (includeFile)
infile = includeFile;
if (infile || bodytext) {
if (infile) {
- if (mutt_strcmp ("-", infile) == 0)
+ if (str_cmp ("-", infile) == 0)
fin = stdin;
else {
char path[_POSIX_PATH_MAX];
fin = NULL;
mutt_mktemp (buf);
- tempfile = safe_strdup (buf);
+ tempfile = str_dup (buf);
if (draftFile)
msg->env = mutt_read_rfc822_header (fin, NULL, 1, 0);
if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
break;
- if (mutt_strcmp (buf, MMDF_SEP) == 0) {
+ if (str_cmp (buf, MMDF_SEP) == 0) {
loc = ftell (ctx->fp);
count++;
if (0 < tmploc && tmploc < ctx->size) {
if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL ||
- mutt_strcmp (MMDF_SEP, buf) != 0) {
+ str_cmp (MMDF_SEP, buf) != 0) {
if (fseek (ctx->fp, loc, SEEK_SET) != 0)
debug_print (1, ("fseek() failed\n"));
hdr->content->length = -1;
if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
break;
lines++;
- } while (mutt_strcmp (buf, MMDF_SEP) != 0);
+ } while (str_cmp (buf, MMDF_SEP) != 0);
hdr->lines = lines;
hdr->content->length = loc - hdr->content->offset;
*/
if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
fgets (buf, sizeof (buf), ctx->fp) == NULL ||
- safe_strncmp ("From ", buf, 5) != 0) {
+ str_ncmp ("From ", buf, 5) != 0) {
debug_print (1, ("bad content-length in message %d (cl=%ld)\n",
curhdr->index, curhdr->content->length));
debug_print (1, ("LINE: %s\n", buf));
if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
debug_print (1, ("fseek() failed\n"));
if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL) {
- if ((ctx->magic == M_MBOX && safe_strncmp ("From ", buffer, 5) == 0)
- || (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buffer) == 0)) {
+ if ((ctx->magic == M_MBOX && str_ncmp ("From ", buffer, 5) == 0)
+ || (ctx->magic == M_MMDF && str_cmp (MMDF_SEP, buffer) == 0)) {
if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
debug_print (1, ("fseek() failed\n"));
if (ctx->magic == M_MBOX)
if (fseek (ctx->fp, offset, SEEK_SET) != 0 || /* seek the append location */
/* do a sanity check to make sure the mailbox looks ok */
fgets (buf, sizeof (buf), ctx->fp) == NULL ||
- (ctx->magic == M_MBOX && safe_strncmp ("From ", buf, 5) != 0) ||
- (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buf) != 0)) {
+ (ctx->magic == M_MBOX && str_ncmp ("From ", buf, 5) != 0) ||
+ (ctx->magic == M_MMDF && str_cmp (MMDF_SEP, buf) != 0)) {
debug_print (1, ("message not in expected position.\n"));
debug_print (1, ("LINE: %s\n", buf));
i = -1;
struct utimbuf times;
#endif
fgets (tmp, sizeof (tmp), f);
- if (safe_strncmp ("From ", tmp, 5) == 0)
+ if (str_ncmp ("From ", tmp, 5) == 0)
magic = M_MBOX;
- else if (mutt_strcmp (MMDF_SEP, tmp) == 0)
+ else if (str_cmp (MMDF_SEP, tmp) == 0)
magic = M_MMDF;
safe_fclose (&f);
#ifndef BUFFY_SIZE
{
wchar_t wc;
size_t k;
- size_t n = mutt_strlen ((char *) s);
+ size_t n = str_len ((char *) s);
mbstate_t mbstate;
memset (&mbstate, 0, sizeof (mbstate));
cols = COLS - shift - SidebarWidth;
else
cols = COLS - shift;
- mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, mutt_strlen (s), 1);
+ mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, str_len (s), 1);
tmpbuf[n - 1] = 0;
snprintf (s, n, "%s", tmpbuf); /* overkill */
FREE (&tmpbuf);
if (!(t = strtok (buff, " \t:")))
continue;
- if (!mutt_strcmp (t, MhUnseen))
+ if (!str_cmp (t, MhUnseen))
f = MH_SEQ_UNSEEN;
- else if (!mutt_strcmp (t, MhFlagged))
+ else if (!str_cmp (t, MhFlagged))
f = MH_SEQ_FLAGGED;
- else if (!mutt_strcmp (t, MhReplied))
+ else if (!str_cmp (t, MhReplied))
f = MH_SEQ_REPLIED;
else /* unknown sequence */
continue;
}
}
else {
- *tgt = safe_strdup (path);
+ *tgt = str_dup (path);
break;
}
}
/* first, copy unknown sequences */
if ((ofp = fopen (sequences, "r"))) {
while ((buff = mutt_read_line (buff, &s, ofp, &l))) {
- if (!safe_strncmp (buff, seq_unseen, mutt_strlen (seq_unseen)))
+ if (!str_ncmp (buff, seq_unseen, str_len (seq_unseen)))
continue;
- if (!safe_strncmp (buff, seq_flagged, mutt_strlen (seq_flagged)))
+ if (!str_ncmp (buff, seq_flagged, str_len (seq_flagged)))
continue;
- if (!safe_strncmp (buff, seq_replied, mutt_strlen (seq_replied)))
+ if (!str_ncmp (buff, seq_replied, str_len (seq_replied)))
continue;
fprintf (nfp, "%s\n", buff);
snprintf (sequences, sizeof (sequences), "%s/.mh_sequences", ctx->path);
if ((ofp = fopen (sequences, "r"))) {
while ((buff = mutt_read_line (buff, &sz, ofp, &line))) {
- if (unseen && !strncmp (buff, seq_unseen, mutt_strlen (seq_unseen))) {
+ if (unseen && !strncmp (buff, seq_unseen, str_len (seq_unseen))) {
fprintf (nfp, "%s %d\n", buff, n);
unseen_done = 1;
}
else if (flagged
- && !strncmp (buff, seq_flagged, mutt_strlen (seq_flagged))) {
+ && !strncmp (buff, seq_flagged, str_len (seq_flagged))) {
fprintf (nfp, "%s %d\n", buff, n);
flagged_done = 1;
}
else if (replied
- && !strncmp (buff, seq_replied, mutt_strlen (seq_replied))) {
+ && !strncmp (buff, seq_replied, str_len (seq_replied))) {
fprintf (nfp, "%s %d\n", buff, n);
replied_done = 1;
}
h->read = 0;
h->replied = 0;
- if ((p = strrchr (path, ':')) != NULL && safe_strncmp (p + 1, "2,", 2) == 0) {
+ if ((p = strrchr (path, ':')) != NULL && str_ncmp (p + 1, "2,", 2) == 0) {
p += 3;
str_replace (&h->maildir_flags, p);
if (subdir) {
snprintf (buf, sizeof (buf), "%s/%s", subdir, fname);
- h->path = safe_strdup (buf);
+ h->path = str_dup (buf);
}
else
- h->path = safe_strdup (fname);
+ h->path = str_dup (fname);
entry = safe_calloc (sizeof (struct maildir), 1);
entry->h = h;
if (subdir) {
snprintf (buf, sizeof (buf), "%s/%s", ctx->path, subdir);
- is_old = (mutt_strcmp ("cur", subdir) == 0);
+ is_old = (str_cmp ("cur", subdir) == 0);
}
else
strfcpy (buf, ctx->path, sizeof (buf));
{
const char *p = strchr (fn, ':');
- return p ? (size_t) (p - fn) : mutt_strlen (fn);
+ return p ? (size_t) (p - fn) : str_len (fn);
}
#endif
hdr->read ? "S" : "", hdr->deleted ? "T" : "",
NONULL (hdr->maildir_flags));
if (hdr->maildir_flags)
- qsort (tmp, mutt_strlen (tmp), 1, ch_compar);
+ qsort (tmp, str_len (tmp), 1, ch_compar);
snprintf (dest, destlen, ":2,%s", tmp);
}
}
}
else {
debug_print (2, ("success.\n"));
- msg->path = safe_strdup (path);
+ msg->path = str_dup (path);
break;
}
}
snprintf (fullpath, sizeof (fullpath), "%s/%s", ctx->path, partpath);
snprintf (oldpath, sizeof (oldpath), "%s/%s", ctx->path, h->path);
- if (mutt_strcmp (fullpath, oldpath) == 0) {
+ if (str_cmp (fullpath, oldpath) == 0) {
/* message hasn't really changed */
return 0;
}
for (p = md; p; p = p->next) {
maildir_canon_filename (buf, p->h->path, sizeof (buf));
- p->canon_fname = safe_strdup (buf);
+ p->canon_fname = str_dup (buf);
hash_insert (fnames, p->canon_fname, p, 0);
}
/* check to see if the message has moved to a different
* subdirectory. If so, update the associated filename.
*/
- if (mutt_strcmp (ctx->hdrs[i]->path, p->h->path))
+ if (str_cmp (ctx->hdrs[i]->path, p->h->path))
str_replace (&ctx->hdrs[i]->path, p->h->path);
/* if the user hasn't modified the flags on this message, update
while ((de = readdir (dp))) {
maildir_canon_filename (tunique, de->d_name, sizeof (tunique));
- if (!mutt_strcmp (tunique, unique)) {
+ if (!str_cmp (tunique, unique)) {
snprintf (fname, sizeof (fname), "%s/%s/%s", folder, subfolder,
de->d_name);
fp = fopen (fname, "r"); /* __FOPEN_CHECKED__ */
int mutt_idna_to_local (const char *in, char **out, int flags)
{
- *out = safe_strdup (in);
+ *out = str_dup (in);
return 1;
}
int mutt_local_to_idna (const char *in, char **out)
{
- *out = safe_strdup (in);
+ *out = str_dup (in);
return 0;
}
if ((flags & MI_MAY_BE_IRREVERSIBLE) == 0) {
int irrev = 0;
char *t2 = NULL;
- char *tmp = safe_strdup (*out);
+ char *tmp = str_dup (*out);
if (mutt_convert_string (&tmp, Charset, "utf-8", M_ICONV_HOOK_FROM) == -1)
irrev = 1;
notrans:
FREE (out);
- *out = safe_strdup (in);
+ *out = str_dup (in);
return 1;
}
int mutt_local_to_idna (const char *in, char **out)
{
int rv = 0;
- char *tmp = safe_strdup (in);
+ char *tmp = str_dup (in);
*out = NULL;
FREE (&tmp);
if (rv < 0) {
FREE (out);
- *out = safe_strdup (in);
+ *out = str_dup (in);
}
return rv;
}
return -1;
*user = safe_calloc ((p - mbx + 1), sizeof (mbx[0]));
strfcpy (*user, mbx, (p - mbx + 1));
- *domain = safe_strdup (p + 1);
+ *domain = str_dup (p + 1);
return 0;
}
if (mutt_local_to_idna (domain, &tmp) < 0) {
e = 1;
if (err)
- *err = safe_strdup (domain);
+ *err = str_dup (domain);
}
else {
- safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2);
+ safe_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2);
sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
}
continue;
if (mutt_idna_to_local (domain, &tmp, 0) == 0) {
- safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2);
+ safe_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2);
sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
}
return a->mailbox;
}
- safe_realloc (&buff, mutt_strlen (tmp) + mutt_strlen (user) + 2);
+ safe_realloc (&buff, str_len (tmp) + str_len (user) + 2);
sprintf (buff, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
FREE (&tmp);
FREE (&user);
/* Create hostname:port string and tell libesmtp */
/* len = SmtpHost len + colon + max port (65536 => 5 chars) + terminator */
- hostportlen = mutt_strlen (SmtpHost) + 7;
+ hostportlen = str_len (SmtpHost) + 7;
hostportstr = safe_malloc (hostportlen);
snprintf (hostportstr, hostportlen, "%s:%d", SmtpHost, SmtpPort);
if (!smtp_set_server (session, hostportstr))
if (ret)
return getnameinfo_err (ret);
- if (outlen < mutt_strlen (hbuf) + mutt_strlen (pbuf) + 2)
+ if (outlen < str_len (hbuf) + str_len (pbuf) + 2)
return SASL_BUFOVER;
snprintf (out, outlen, "%s;%s", hbuf, pbuf);
if (mutt_get_field (prompt, resp, sizeof (resp), 0))
return SASL_FAIL;
- interaction->len = mutt_strlen (resp) + 1;
+ interaction->len = str_len (resp) + 1;
interaction->result = safe_malloc (interaction->len);
memcpy ((char*) interaction->result, resp, interaction->len);
}
if (len)
- *len = mutt_strlen (*result);
+ *len = str_len (*result);
return SASL_OK;
}
if (mutt_account_getpass (account))
return SASL_FAIL;
- len = mutt_strlen (account->pass);
+ len = str_len (account->pass);
*psecret = (sasl_secret_t *) safe_malloc (sizeof (sasl_secret_t) + len);
(*psecret)->len = len;
return -1;
}
- len = mutt_strlen (buf);
+ len = str_len (buf);
if ((rc = conn->conn_write (conn, buf, len)) < 0) {
debug_print (1, ("error writing, closing socket\n"));
mutt_socket_close (conn);
debug_print (dbg, ("< %s\n", buf));
- /* number of bytes read, not mutt_strlen */
+ /* number of bytes read, not str_len */
return i + 1;
}
int rc;
int save_errno;
- if (mutt_strlen (Preconnect)) {
+ if (str_len (Preconnect)) {
debug_print (2, ("Executing preconnect: %s\n", Preconnect));
rc = mutt_system (Preconnect);
debug_print (2, ("Preconnect result: %d\n", rc));
c = strstr (line, ndx);
if (c) {
- c += mutt_strlen (ndx);
+ c += str_len (ndx);
c2 = strchr (c, '/');
if (c2)
*c2 = '\0';
char ch[8];
snprintf (ch, 8, "%02X%s", md[j], (j % 2 ? " " : ""));
- safe_strcat (s, l, ch);
+ str_cat (s, l, ch);
}
}
}
helpstr[0] = '\0';
mutt_make_help (buf, sizeof (buf), _("Exit "), MENU_GENERIC, OP_EXIT);
- safe_strcat (helpstr, sizeof (helpstr), buf);
+ str_cat (helpstr, sizeof (helpstr), buf);
mutt_make_help (buf, sizeof (buf), _("Help"), MENU_GENERIC, OP_HELP);
- safe_strcat (helpstr, sizeof (helpstr), buf);
+ str_cat (helpstr, sizeof (helpstr), buf);
menu->help = helpstr;
done = 0;
if (regexec (&preg, linestr, 3, pmatch, 0) == 0) {
linestr[pmatch[1].rm_eo] = '\0';
linestr[pmatch[2].rm_eo] = '\0';
- if (mutt_strcmp (linestr + pmatch[1].rm_so, hostname) == 0 &&
- mutt_strcmp (linestr + pmatch[2].rm_so, buf) == 0) {
+ if (str_cmp (linestr + pmatch[1].rm_so, hostname) == 0 &&
+ str_cmp (linestr + pmatch[2].rm_so, buf) == 0) {
regfree (&preg);
FREE(&linestr);
fclose (fp);
mktemp (s);
if (period != NULL) {
*period = '.';
- sl = mutt_strlen (s);
+ sl = str_len (s);
strfcpy (s + sl, period, l - sl);
}
}
b->parts = NULL;
b->next = NULL;
- b->filename = safe_strdup (tmp);
+ b->filename = str_dup (tmp);
b->use_disp = use_disp;
b->unlink = 1;
if (mutt_is_text_part (b))
b->noconv = 1;
- b->xtype = safe_strdup (b->xtype);
- b->subtype = safe_strdup (b->subtype);
- b->form_name = safe_strdup (b->form_name);
- b->filename = safe_strdup (b->filename);
- b->d_filename = safe_strdup (b->d_filename);
- b->description = safe_strdup (b->description);
+ b->xtype = str_dup (b->xtype);
+ b->subtype = str_dup (b->subtype);
+ b->form_name = str_dup (b->form_name);
+ b->filename = str_dup (b->filename);
+ b->d_filename = str_dup (b->d_filename);
+ b->description = str_dup (b->description);
/*
* we don't seem to need the HEADER structure currently.
for (par = b->parameter, ppar = &b->parameter; par;
ppar = &(*ppar)->next, par = par->next) {
*ppar = mutt_new_parameter ();
- (*ppar)->attribute = safe_strdup (par->attribute);
- (*ppar)->value = safe_strdup (par->value);
+ (*ppar)->attribute = str_dup (par->attribute);
+ (*ppar)->value = str_dup (par->value);
}
mutt_stamp_attachment (b);
}
LIST *mutt_add_list (LIST * head, const char *data) {
- size_t len = mutt_strlen (data);
+ size_t len = str_len (data);
return (mutt_add_list_n (head, data, len ? len + 1 : 0));
}
int mutt_matches_ignore (const char *s, LIST * t)
{
for (; t; t = t->next) {
- if (!ascii_strncasecmp (s, t->data, mutt_strlen (t->data))
+ if (!ascii_strncasecmp (s, t->data, str_len (t->data))
|| *t->data == '*')
return 1;
}
#ifdef USE_IMAP
/* if folder = imap[s]://host/: don't append slash */
if (imap_is_magic (NONULL (Maildir), NULL) == M_IMAP &&
- Maildir[mutt_strlen (Maildir) - 1] == '/')
+ Maildir[str_len (Maildir) - 1] == '/')
strfcpy (p, NONULL (Maildir), sizeof (p));
else
#endif
else
strfcpy (dest, pw->pw_gecos, destlen);
- pwnl = mutt_strlen (pw->pw_name);
+ pwnl = str_len (pw->pw_name);
for (idx = 0; dest[idx]; idx++) {
if (dest[idx] == '&') {
}
q = mutt_new_parameter ();
- q->attribute = safe_strdup (attribute);
- q->value = safe_strdup (value);
+ q->attribute = str_dup (attribute);
+ q->value = str_dup (value);
q->next = *p;
*p = q;
}
}
*q = 0;
- if (safe_strncmp (s, Maildir, (len = mutt_strlen (Maildir))) == 0 &&
+ if (str_ncmp (s, Maildir, (len = str_len (Maildir))) == 0 &&
s[len] == '/') {
*s++ = '=';
- memmove (s, s + len, mutt_strlen (s + len) + 1);
+ memmove (s, s + len, str_len (s + len) + 1);
}
- else if (safe_strncmp (s, Homedir, (len = mutt_strlen (Homedir))) == 0 &&
+ else if (str_ncmp (s, Homedir, (len = str_len (Homedir))) == 0 &&
s[len] == '/') {
*s++ = '~';
- memmove (s, s + len - 1, mutt_strlen (s + len - 1) + 1);
+ memmove (s, s + len - 1, str_len (s + len - 1) + 1);
}
}
size_t slen;
int found = 0;
- slen = mutt_strlen (src);
+ slen = str_len (src);
destlen--;
for (p = fmt, d = dest; destlen && *p; p++) {
*d = '\0';
if (!found && destlen > 0) {
- safe_strcat (dest, destlen, " ");
- safe_strcat (dest, destlen, src);
+ str_cat (dest, destlen, " ");
+ str_cat (dest, destlen, src);
}
}
ret++;
s++;
}
- return (mutt_strlen (p));
+ return (str_len (p));
}
void mutt_FormatString (char *dest, /* output buffer */
if (count > col) {
count -= col; /* how many columns left on this line */
mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
- wid = mutt_strlen (buf);
+ wid = str_len (buf);
if (count > wid) {
count -= wid; /* how many chars to pad */
memset (wptr, ch, count);
*p = '_';
}
- if ((len = mutt_strlen (buf)) + wlen > destlen)
+ if ((len = str_len (buf)) + wlen > destlen)
len = (destlen - wlen > 0) ? (destlen - wlen) : 0;
memcpy (wptr, buf, len);
FILE *f;
struct stat s;
- int len = mutt_strlen (path);
+ int len = str_len (path);
if (path[len - 1] == '|') {
/* read from a pipe */
- char *s = safe_strdup (path);
+ char *s = str_dup (path);
s[len - 1] = 0;
mutt_endwin (NULL);
if (magic > 0 && !mx_access (s, W_OK)) {
if (option (OPTCONFIRMAPPEND) &&
- (!TrashPath || (mutt_strcmp (s, TrashPath) != 0))) {
+ (!TrashPath || (str_cmp (s, TrashPath) != 0))) {
/* if we're appending to the trash, there's no point in asking */
snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
if (s->flags & M_PENDINGPREFIX) {
int i;
- i = mutt_strlen (Quotebuf);
+ i = str_len (Quotebuf);
Quotebuf[i++] = c;
Quotebuf[i] = '\0';
if (i == sizeof (Quotebuf) - 1 || c == '\n') {
void state_mark_attach (STATE * s)
{
- if ((s->flags & M_DISPLAY) && !mutt_strcmp (Pager, "builtin"))
+ if ((s->flags & M_DISPLAY) && !str_cmp (Pager, "builtin"))
state_puts (AttachmentMarker, s);
}
return NULL;
b = mutt_buffer_init (b);
- b->data = safe_strdup (seed);
- b->dsize = mutt_strlen (seed);
+ b->data = str_dup (seed);
+ b->dsize = str_len (seed);
b->dptr = (char *) b->data + b->dsize;
return b;
}
void mutt_buffer_addstr (BUFFER * buf, const char *s)
{
- mutt_buffer_add (buf, s, mutt_strlen (s));
+ mutt_buffer_add (buf, s, str_len (s));
}
void mutt_buffer_addch (BUFFER * buf, char c)
int mutt_cmp_addr (const ADDRESS * a, const ADDRESS * b)
{
while (a && b) {
- if (mutt_strcmp (a->mailbox, b->mailbox) ||
- mutt_strcmp (a->personal, b->personal))
+ if (str_cmp (a->mailbox, b->mailbox) ||
+ str_cmp (a->personal, b->personal))
return (0);
a = a->next;
int mutt_cmp_list (const LIST * a, const LIST * b)
{
while (a && b) {
- if (mutt_strcmp (a->data, b->data))
+ if (str_cmp (a->data, b->data))
return (0);
a = a->next;
int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2)
{
if (e1 && e2) {
- if (mutt_strcmp (e1->message_id, e2->message_id) ||
- mutt_strcmp (e1->subject, e2->subject) ||
+ if (str_cmp (e1->message_id, e2->message_id) ||
+ str_cmp (e1->subject, e2->subject) ||
!mutt_cmp_list (e1->references, e2->references) ||
!mutt_cmp_addr (e1->from, e2->from) ||
!mutt_cmp_addr (e1->sender, e2->sender) ||
int mutt_cmp_param (const PARAMETER * p1, const PARAMETER * p2)
{
while (p1 && p2) {
- if (mutt_strcmp (p1->attribute, p2->attribute) ||
- mutt_strcmp (p1->value, p2->value))
+ if (str_cmp (p1->attribute, p2->attribute) ||
+ str_cmp (p1->value, p2->value))
return (0);
p1 = p1->next;
{
if (b1->type != b2->type ||
b1->encoding != b2->encoding ||
- mutt_strcmp (b1->subtype, b2->subtype) ||
- mutt_strcmp (b1->description, b2->description) ||
+ str_cmp (b1->subtype, b2->subtype) ||
+ str_cmp (b1->description, b2->description) ||
!mutt_cmp_param (b1->parameter, b2->parameter) ||
b1->length != b2->length)
return (0);
#define MX_COMMAND(idx,cmd) ((mx_t*) MailboxFormats->data[idx])->cmd
#define MX_IDX(idx) (idx >= 0 && idx < MailboxFormats->length)
-#define mutt_is_spool(s) (mutt_strcmp (Spoolfile, s) == 0)
+#define mutt_is_spool(s) (str_cmp (Spoolfile, s) == 0)
#ifdef USE_DOTLOCK
/* parameters:
int mx_get_magic (const char *path) {
int i = 0;
- if (mutt_strlen (path) == 0)
+ if (str_len (path) == 0)
return (-1);
if ((i = mx_get_idx (path)) >= 0)
return (MX_COMMAND(i,type));
if (!ctx)
ctx = safe_malloc (sizeof (CONTEXT));
memset (ctx, 0, sizeof (CONTEXT));
- ctx->path = safe_strdup (path);
+ ctx->path = str_dup (path);
ctx->msgnotreadyet = -1;
ctx->collapsed = 0;
strfcpy (group, line, len);
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, group)) == NULL) {
data =
- (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + mutt_strlen (group) + 1);
+ (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1);
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, group);
data->nserv = news;
return 0;
rewind (index);
while (fgets (buf, sizeof (buf), index)) {
- buf[mutt_strlen (buf) - 1] = 0; /* strip ending '\n' */
- if (!safe_strncmp (buf, "#: ", 3) &&
- !safe_strcasecmp (buf + 3, news->conn->account.host))
+ buf[str_len (buf) - 1] = 0; /* strip ending '\n' */
+ if (!str_ncmp (buf, "#: ", 3) &&
+ !str_casecmp (buf + 3, news->conn->account.host))
break;
}
while (fgets (buf, sizeof (buf), index)) {
if (!*cp)
continue;
cp[0] = 0;
- if (!mutt_strcmp (buf, "#:"))
+ if (!str_cmp (buf, "#:"))
break;
sscanf (cp + 1, "%s %d %d", file, &l, &m);
- if (!mutt_strcmp (buf, "ALL")) {
- news->cache = safe_strdup (file);
+ if (!str_cmp (buf, "ALL")) {
+ news->cache = str_dup (file);
news->newgroups_time = m;
}
else if (news->newsgroups) {
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, buf)) == NULL) {
data =
(NNTP_DATA *) safe_calloc (1,
- sizeof (NNTP_DATA) + mutt_strlen (buf) + 1);
+ sizeof (NNTP_DATA) + str_len (buf) + 1);
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, buf);
data->nserv = news;
hash_insert (news->newsgroups, data->group, data, 0);
nntp_add_to_list (news, data);
}
- data->cache = safe_strdup (file);
+ data->cache = str_dup (file);
t = 0;
if (!data->firstMessage || data->lastMessage < m)
t = 1;
acct->port = NNTP_PORT;
acct->type = M_ACCT_TYPE_NNTP;
- c = safe_strdup (server);
+ c = str_dup (server);
url_parse_ciss (&url, c);
if (url.scheme == U_NNTP || url.scheme == U_NNTPS) {
{
ciss_url_t url;
- url.path = safe_strdup (line);
+ url.path = str_dup (line);
mutt_account_tourl (acct, &url);
url_ciss_tostring (&url, line, len, 0);
FREE (&url.path);
return NULL;
}
- buf = p = safe_calloc (mutt_strlen (server) + 10, sizeof (char));
+ buf = p = safe_calloc (str_len (server) + 10, sizeof (char));
if (url_check_scheme (server) == U_UNKNOWN) {
strcpy (buf, "nntp://");
p = strchr (buf, '\0');
/* New newsserver */
serv = safe_calloc (1, sizeof (NNTP_SERVER));
serv->conn = conn;
- serv->newsrc = safe_strdup (file);
+ serv->newsrc = str_dup (file);
serv->newsgroups = hash_create (1009);
slurp_newsrc (serv); /* load .newsrc */
nntp_parse_cacheindex (serv); /* load .index */
line = *buf + (*pline - line);
}
strcpy (line, data->group);
- len -= mutt_strlen (line) + 1;
- line += mutt_strlen (line);
+ len -= str_len (line) + 1;
+ line += str_len (line);
*line++ = data->subscribed ? ':' : '!';
*line++ = ' ';
*line = '\0';
continue;
nntp_create_newsrc_line (data, &buf, &line, &llen);
debug_print (2, ("Added to newsrc: %s\n", line));
- line += mutt_strlen (line);
+ line += str_len (line);
}
/* newrc being fully rewritten */
if (news->newsrc &&
return fp;
nntp_cache_expand (buf, "cache-XXXXXX");
- pc = buf + mutt_strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
+ pc = buf + str_len (buf) - 12; /* positioning to "cache-XXXXXX" */
if ((fd = mkstemp (buf)) == -1)
return NULL;
strcpy (s, pc); /* generated name */
else {
strfcpy (buf, news->conn->account.host, sizeof (buf));
f = mutt_mkname (buf);
- news->cache = safe_strdup (buf);
+ news->cache = str_dup (buf);
nntp_cache_expand (file, buf);
}
if (!f)
((NNTP_DATA *) ctx->data)->nserv->conn->account.host,
((NNTP_DATA *) ctx->data)->group);
f = mutt_mkname (buf);
- ((NNTP_DATA *) ctx->data)->cache = safe_strdup (buf);
+ ((NNTP_DATA *) ctx->data)->cache = str_dup (buf);
nntp_cache_expand (file, buf);
}
if (!f)
return NULL;
if (!(data = (NNTP_DATA *) hash_find (news->newsgroups, group))) {
data =
- (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + mutt_strlen (group) + 1);
+ (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1);
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, group);
data->nserv = news;
if (data && data->subscribed && data->unread) {
if (Context && Context->magic == M_NNTP &&
- !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group)) {
+ !str_cmp (data->group, ((NNTP_DATA *) Context->data)->group)) {
unsigned int i, unread = 0;
for (i = 0; i < Context->msgcount; i++)
return -1;
}
- if (safe_strncmp ("281", buf, 3)) {
+ if (str_ncmp ("281", buf, 3)) {
conn->account.flags = flags;
mutt_error _("Login failed.");
if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
return nntp_connect_error (serv);
- if (!safe_strncmp ("200", buf, 3))
+ if (!str_ncmp ("200", buf, 3))
mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
- else if (!safe_strncmp ("201", buf, 3))
+ else if (!str_ncmp ("201", buf, 3))
mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
else {
mutt_socket_close (conn);
if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
return nntp_connect_error (serv);
- if (!(conn->account.flags & M_ACCT_USER) && safe_strncmp ("480", buf, 3)) {
+ if (!(conn->account.flags & M_ACCT_USER) && str_ncmp ("480", buf, 3)) {
serv->status = NNTP_OK;
return 0;
}
mutt_socket_write (conn, "LISTGROUP\r\n");
if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
return (nntp_connect_error (serv));
- if (safe_strncmp ("500", buf, 3))
+ if (str_ncmp ("500", buf, 3))
serv->hasLISTGROUP = 1;
mutt_socket_write (conn, "XOVER\r\n");
if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
return nntp_connect_error (serv);
- if (safe_strncmp ("500", buf, 3))
+ if (str_ncmp ("500", buf, 3))
serv->hasXOVER = 1;
mutt_socket_write (conn, "XPAT\r\n");
if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
return nntp_connect_error (serv);
- if (safe_strncmp ("500", buf, 3))
+ if (str_ncmp ("500", buf, 3))
serv->hasXPAT = 1;
mutt_socket_write (conn, "XGTITLE +\r\n");
if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
return nntp_connect_error (serv);
- if (safe_strncmp ("500", buf, 3))
+ if (str_ncmp ("500", buf, 3))
serv->hasXGTITLE = 1;
- if (!safe_strncmp ("282", buf, 3)) {
+ if (!str_ncmp ("282", buf, 3)) {
do {
if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
return nntp_connect_error (serv);
if (*line)
done = FALSE;
}
- else if ((!safe_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
+ else if ((!str_ncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
return -1;
} while (!done);
strfcpy (inbuf + lenbuf, p, sizeof (buf));
if (chunk >= sizeof (buf)) {
- lenbuf += mutt_strlen (p);
+ lenbuf += str_len (p);
}
else {
line++;
*colon = '\0';
colon++;
nntp_get_status (ctx, h, p, atoi (colon));
- if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
+ if (h && h->article_num == 0 && str_cmp (group, b) == 0)
h->article_num = atoi (colon);
}
}
d++;
debug_print (2, ("group: %s, desc: %s\n", line, d));
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
- mutt_strcmp (d, data->desc)) {
+ str_cmp (d, data->desc)) {
FREE (&data->desc);
- data->desc = safe_strdup (d);
+ data->desc = str_dup (d);
}
return 0;
#undef news
int x, done = 0;
hdr->env = mutt_new_envelope ();
- hdr->env->newsgroups = safe_strdup (nntp_data->group);
+ hdr->env->newsgroups = str_dup (nntp_data->group);
hdr->content = mutt_new_body ();
hdr->content->type = TYPETEXT;
- hdr->content->subtype = safe_strdup ("plain");
+ hdr->content->subtype = str_dup ("plain");
hdr->content->encoding = ENC7BIT;
hdr->content->disposition = DISPINLINE;
hdr->content->length = -1;
nntp_get_status (ctx, hdr, NULL, hdr->article_num);
break;
case 1:
- hdr->env->subject = safe_strdup (b);
+ hdr->env->subject = str_dup (b);
/* Now we need to do the things which would normally be done in
* mutt_read_rfc822_header() */
if (hdr->env->subject) {
break;
case 4:
FREE (&hdr->env->message_id);
- hdr->env->message_id = safe_strdup (b);
+ hdr->env->message_id = str_dup (b);
break;
case 5:
mutt_free_list (&hdr->env->references);
if (!hdr->read)
FREE (&hdr->env->xref);
b = b + 6; /* skips the "Xref: " */
- hdr->env->xref = safe_strdup (b);
+ hdr->env->xref = str_dup (b);
nntp_parse_xref (ctx, nntp_data->group, b, hdr);
}
if (!*p)
/* create NNTP-specific state struct if nof found in list */
if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL) {
- nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + mutt_strlen (buf) + 1);
+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + str_len (buf) + 1);
nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
strcpy (nntp_data->group, buf);
hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
return -1;
}
- if (safe_strncmp ("211", buf, 3)) {
+ if (str_ncmp ("211", buf, 3)) {
LIST *l = serv->list;
/* GROUP command failed */
- if (!safe_strncmp ("411", buf, 3)) {
+ if (!str_ncmp ("411", buf, 3)) {
mutt_error (_("Newsgroup %s not found on server %s"),
nntp_data->group, serv->conn->account.host);
cache->index = ctx->hdrs[msgno]->index;
mutt_mktemp (path);
- cache->path = safe_strdup (path);
+ cache->path = str_dup (path);
if (!(msg->fp = safe_fopen (path, "w+"))) {
FREE (&cache->path);
return -1;
buf[0] = '.';
buf[1] = '\0';
while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL) {
- len = mutt_strlen (buf);
+ len = str_len (buf);
if (buf[len - 1] == '\n') {
buf[len - 1] = '\r';
buf[len] = '\n';
}
fclose (f);
- if (buf[mutt_strlen (buf) - 1] != '\n')
+ if (buf[str_len (buf) - 1] != '\n')
mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", M_SOCK_LOG_HDR);
mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", M_SOCK_LOG_HDR);
if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0) {
#endif
return -1;
}
- if (safe_strncmp ("211", buf, 3)) {
+ if (str_ncmp ("211", buf, 3)) {
buf[0] = 0;
if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) {
#ifdef DEBUG
return -1;
}
}
- if (!safe_strncmp ("211", buf, 3)) {
+ if (!str_ncmp ("211", buf, 3)) {
int first;
int last;
return 0;
if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL) {
n++;
- nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + mutt_strlen (group) + 1);
+ nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + str_len (group) + 1);
nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
strcpy (nntp_data->group, group);
nntp_data->nserv = s;
if (nntp_data->desc)
FREE (&nntp_data->desc);
if (*desc)
- nntp_data->desc = safe_strdup (desc);
+ nntp_data->desc = str_dup (desc);
if (nntp_data->rc || nntp_data->lastCached)
mutt_newsgroup_stat (nntp_data);
else if (nntp_data->lastMessage &&
if (length <= q_list->length) {
/* case 1: check the top level nodes */
- if (safe_strncmp (qptr, q_list->prefix, length) == 0) {
+ if (str_ncmp (qptr, q_list->prefix, length) == 0) {
if (length == q_list->length)
return q_list; /* same prefix: return the current class */
/* tmp != NULL means we already found a shorter prefix at case 1 */
if (tmp == NULL
- && safe_strncmp (qptr, q_list->prefix, q_list->length) == 0) {
+ && str_ncmp (qptr, q_list->prefix, q_list->length) == 0) {
/* ok, it's a subclass somewhere on this branch */
ptr = q_list;
while (q_list) {
if (length <= q_list->length) {
- if (safe_strncmp (tail_qptr, (q_list->prefix) + offset, tail_lng)
+ if (str_ncmp (tail_qptr, (q_list->prefix) + offset, tail_lng)
== 0) {
/* same prefix: return the current class */
if (length == q_list->length)
else {
/* longer than the current prefix: try subclassing it */
if (tmp == NULL
- && safe_strncmp (tail_qptr, (q_list->prefix) + offset,
+ && str_ncmp (tail_qptr, (q_list->prefix) + offset,
q_list->length - offset) == 0) {
/* still a subclass: go down one level */
ptr = q_list;
}
}
}
- else if (safe_strncmp ("\033[0m", raw, 4) == 0) /* a little hack... */
+ else if (str_ncmp ("\033[0m", raw, 4) == 0) /* a little hack... */
lineInfo[n].type = MT_COLOR_NORMAL;
#if 0
- else if (safe_strncmp ("[-- ", buf, 4) == 0)
+ else if (str_ncmp ("[-- ", buf, 4) == 0)
lineInfo[n].type = MT_COLOR_ATTACHMENT;
#else
else if (check_attachment_marker ((char *) raw) == 0)
lineInfo[n].type = MT_COLOR_ATTACHMENT;
#endif
- else if (mutt_strcmp ("-- \n", buf) == 0
- || mutt_strcmp ("-- \r\n", buf) == 0) {
+ else if (str_cmp ("-- \n", buf) == 0
+ || str_cmp ("-- \r\n", buf) == 0) {
i = n + 1;
lineInfo[n].type = MT_COLOR_SIGNATURE;
else
followup_to = extra->hdr->env->followup_to;
- if (!followup_to || safe_strcasecmp (followup_to, "poster") ||
+ if (!followup_to || str_casecmp (followup_to, "poster") ||
query_quadoption (OPT_FOLLOWUPTOPOSTER,
_("Reply by mail as poster prefers?")) != M_YES) {
if (extra->ctx && extra->ctx->magic == M_NNTP
return (line);
}
- buf += mutt_strlen (buf) - 1;
+ buf += str_len (buf) - 1;
if (*buf == '\n') {
/* we did get a full line. remove trailing space */
while (ISSPACE (*buf))
new = NULL;
if (*s == '<') {
- n = mutt_strlen (s);
+ n = str_len (s);
if (s[n - 1] != '>') {
o = s;
s = NULL;
continue;
}
- new = safe_strdup (s);
+ new = str_dup (s);
}
else if (o) {
- m = mutt_strlen (s);
+ m = str_len (s);
if (s[m - 1] == '>') {
new = safe_malloc (sizeof (char) * (n + m + 1));
strcpy (new, o); /* __STRCPY_CHECKED__ */
buffer[i] = 0;
}
- new->value = safe_strdup (buffer);
+ new->value = str_dup (buffer);
debug_print (2, ("`%s' = `%s'\n", new->attribute ? new->attribute : "",
new->value ? new->value : ""));
* let that take precedence, and don't set it here */
if ((pc = mutt_get_parameter ("name", ct->parameter)) != 0
&& !ct->filename)
- ct->filename = safe_strdup (pc);
+ ct->filename = str_dup (pc);
#ifdef SUN_ATTACHMENT
/* this is deep and utter perversion */
*subtype++ = '\0';
for (pc = subtype; *pc && !ISSPACE (*pc) && *pc != ';'; pc++);
*pc = '\0';
- ct->subtype = safe_strdup (subtype);
+ ct->subtype = str_dup (subtype);
}
/* Finally, get the major type */
#ifdef SUN_ATTACHMENT
if (ascii_strcasecmp ("x-sun-attachment", s) == 0)
- ct->subtype = safe_strdup ("x-sun-attachment");
+ ct->subtype = str_dup ("x-sun-attachment");
#endif
if (ct->type == TYPEOTHER) {
- ct->xtype = safe_strdup (s);
+ ct->xtype = str_dup (s);
}
if (ct->subtype == NULL) {
* field, so we can attempt to convert the type to BODY here.
*/
if (ct->type == TYPETEXT)
- ct->subtype = safe_strdup ("plain");
+ ct->subtype = str_dup ("plain");
else if (ct->type == TYPEAUDIO)
- ct->subtype = safe_strdup ("basic");
+ ct->subtype = str_dup ("basic");
else if (ct->type == TYPEMESSAGE)
- ct->subtype = safe_strdup ("rfc822");
+ ct->subtype = str_dup ("rfc822");
else if (ct->type == TYPEOTHER) {
char buffer[SHORT_STRING];
ct->type = TYPEAPPLICATION;
snprintf (buffer, sizeof (buffer), "x-%s", s);
- ct->subtype = safe_strdup (buffer);
+ ct->subtype = str_dup (buffer);
}
else
- ct->subtype = safe_strdup ("x-unknown");
+ ct->subtype = str_dup ("x-unknown");
}
/* Default character set for text types. */
(parms = parse_parameters (s)))) != 0)
str_replace (&ct->filename, s);
if ((s = mutt_get_parameter ("name", parms)) != 0)
- ct->form_name = safe_strdup (s);
+ ct->form_name = str_dup (s);
mutt_free_parameter (&parms);
}
}
}
p->offset = ftell (fp); /* Mark the start of the real data */
if (p->type == TYPETEXT && !p->subtype)
- p->subtype = safe_strdup ("plain");
+ p->subtype = str_dup ("plain");
else if (p->type == TYPEMESSAGE && !p->subtype)
- p->subtype = safe_strdup ("rfc822");
+ p->subtype = str_dup ("rfc822");
FREE (&line);
return (NULL);
}
- blen = mutt_strlen (boundary);
+ blen = str_len (boundary);
while (ftell (fp) < end_off && fgets (buffer, LONG_STRING, fp) != NULL) {
- len = mutt_strlen (buffer);
+ len = str_len (buffer);
crlf = (len > 1 && buffer[len - 2] == '\r') ? 1 : 0;
if (buffer[0] == '-' && buffer[1] == '-' &&
- safe_strncmp (buffer + 2, boundary, blen) == 0) {
+ str_ncmp (buffer + 2, boundary, blen) == 0) {
if (last) {
last->length = ftell (fp) - last->offset - len - 1 - crlf;
if (last->parts && last->parts->length == 0)
buffer[i] = 0;
/* Check for the end boundary */
- if (mutt_strcmp (buffer + blen + 2, "--") == 0) {
+ if (str_cmp (buffer + blen + 2, "--") == 0) {
final = 1;
break; /* done parsing */
}
* bothered me for _years_ */
if (!e->from) {
e->from = rfc822_new_address ();
- e->from->personal = safe_strdup (line + 6);
+ e->from->personal = str_dup (line + 6);
}
matched = 1;
}
#ifdef USE_NNTP
- else if (!safe_strcasecmp (line + 1, "ollowup-to")) {
+ else if (!str_casecmp (line + 1, "ollowup-to")) {
if (!e->followup_to) {
str_skip_trailws (p);
- e->followup_to = safe_strdup (str_skip_initws (p));
+ e->followup_to = str_dup (str_skip_initws (p));
}
matched = 1;
}
#ifdef USE_NNTP
case 'n':
- if (!safe_strcasecmp (line + 1, "ewsgroups")) {
+ if (!str_casecmp (line + 1, "ewsgroups")) {
FREE (&e->newsgroups);
str_skip_trailws (p);
- e->newsgroups = safe_strdup (str_skip_initws (p));
+ e->newsgroups = str_dup (str_skip_initws (p));
matched = 1;
}
break;
case 'o':
/* field `Organization:' saves only for pager! */
- if (!safe_strcasecmp (line + 1, "rganization")) {
- if (!e->organization && safe_strcasecmp (p, "unknown"))
- e->organization = safe_strdup (p);
+ if (!str_casecmp (line + 1, "rganization")) {
+ if (!e->organization && str_casecmp (p, "unknown"))
+ e->organization = str_dup (p);
}
break;
case 's':
if (!ascii_strcasecmp (line + 1, "ubject")) {
if (!e->subject)
- e->subject = safe_strdup (p);
+ e->subject = str_dup (p);
matched = 1;
}
else if (!ascii_strcasecmp (line + 1, "ender")) {
}
else if ((!ascii_strcasecmp ("upersedes", line + 1) ||
!ascii_strcasecmp ("upercedes", line + 1)) && hdr)
- e->supersedes = safe_strdup (p);
+ e->supersedes = str_dup (p);
break;
case 't':
matched = 1;
}
else if (ascii_strcasecmp (line + 1, "-label") == 0) {
- e->x_label = safe_strdup (p);
+ e->x_label = str_dup (p);
matched = 1;
}
#ifdef USE_NNTP
- else if (!safe_strcasecmp (line + 1, "-comment-to")) {
+ else if (!str_casecmp (line + 1, "-comment-to")) {
if (!e->x_comment_to)
- e->x_comment_to = safe_strdup (p);
+ e->x_comment_to = str_dup (p);
matched = 1;
}
- else if (!safe_strcasecmp (line + 1, "ref")) {
+ else if (!str_casecmp (line + 1, "ref")) {
if (!e->xref)
- e->xref = safe_strdup (p);
+ e->xref = str_dup (p);
matched = 1;
}
#endif
/* Keep track of the user-defined headers */
if (!matched && user_hdrs) {
/* restore the original line */
- line[mutt_strlen (line)] = ':';
+ line[str_len (line)] = ':';
if (weed && option (OPTWEED) && mutt_matches_ignore (line, Ignore)
&& !mutt_matches_ignore (line, UnIgnore))
}
else
last = e->userhdrs = mutt_new_list ();
- last->data = safe_strdup (line);
+ last->data = str_dup (line);
if (do_2047)
rfc2047_decode (&last->data);
}
/* set the defaults from RFC1521 */
hdr->content->type = TYPETEXT;
- hdr->content->subtype = safe_strdup ("plain");
+ hdr->content->subtype = str_dup ("plain");
hdr->content->encoding = ENC7BIT;
hdr->content->length = -1;
time_t t;
/* some bogus MTAs will quote the original "From " line */
- if (safe_strncmp (">From ", line, 6) == 0)
+ if (str_ncmp (">From ", line, 6) == 0)
continue; /* just ignore */
else if (is_from (line, return_path, sizeof (return_path), &t)) {
/* MH somtimes has the From_ line in the middle of the header! */
match = 1;
break;
}
- lng -= mutt_strlen (buf);
+ lng -= str_len (buf);
}
mx_close_message (&msg);
memset (&ps, 0, sizeof (ps));
ps.dptr = s;
- ps.dsize = mutt_strlen (s);
+ ps.dsize = str_len (s);
while (*ps.dptr) {
SKIPWS (ps.dptr);
if (!strchr (s, '~')) { /* yup, so spoof a real request */
/* convert old tokens into the new format */
- if (ascii_strcasecmp ("all", s) == 0 || !mutt_strcmp ("^", s) || !mutt_strcmp (".", s)) /* ~A is more efficient */
+ if (ascii_strcasecmp ("all", s) == 0 || !str_cmp ("^", s) || !str_cmp (".", s)) /* ~A is more efficient */
strfcpy (s, "~A", len);
else if (ascii_strcasecmp ("del", s) == 0)
strfcpy (s, "~D", len);
mutt_message _("Compiling search pattern...");
- simple = safe_strdup (buf);
+ simple = str_dup (buf);
mutt_check_simple (buf, sizeof (buf), NONULL (SimpleSearch));
err.data = error;
}
#endif
}
- else if (safe_strncmp (buf, "~A", 2) != 0) {
+ else if (str_ncmp (buf, "~A", 2) != 0) {
Context->pattern = simple;
simple = NULL; /* don't clobber it */
Context->limit_pattern = mutt_pattern_comp (buf, M_FULL_MSG, &err);
strfcpy (temp, buf, sizeof (temp));
mutt_check_simple (temp, sizeof (temp), NONULL (SimpleSearch));
- if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn)) {
+ if (!SearchPattern || str_cmp (temp, LastSearchExpn)) {
set_option (OPTSEARCHINVALID);
strfcpy (LastSearch, buf, sizeof (LastSearch));
mutt_message _("Compiling search pattern...");
continue;
}
- if (mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n") == 0)
+ if (str_cmp (buf, "-----BEGIN PGP SIGNATURE-----\n") == 0)
break;
if (armor_header) {
break;
offset = ftell (s->fpin);
- bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
+ bytes -= (offset - last_pos); /* don't rely on str_len(buf) */
last_pos = offset;
- if (safe_strncmp ("-----BEGIN PGP ", buf, 15) == 0) {
+ if (str_ncmp ("-----BEGIN PGP ", buf, 15) == 0) {
clearsign = 0;
start_pos = last_pos;
- if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
+ if (str_cmp ("MESSAGE-----\n", buf + 15) == 0)
needpass = 1;
- else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0) {
+ else if (str_cmp ("SIGNED MESSAGE-----\n", buf + 15) == 0) {
clearsign = 1;
needpass = 0;
}
else if (!option (OPTDONTHANDLEPGPKEYS) &&
- mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) {
+ str_cmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) {
needpass = 0;
pgp_keyblock = 1;
}
fputs (buf, tmpfp);
while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL) {
offset = ftell (s->fpin);
- bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
+ bytes -= (offset - last_pos); /* don't rely on str_len(buf) */
last_pos = offset;
fputs (buf, tmpfp);
if ((needpass
- && mutt_strcmp ("-----END PGP MESSAGE-----\n", buf) == 0)
+ && str_cmp ("-----END PGP MESSAGE-----\n", buf) == 0)
|| (!needpass
- && (mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf) == 0
- || mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",
+ && (str_cmp ("-----END PGP SIGNATURE-----\n", buf) == 0
+ || str_cmp ("-----END PGP PUBLIC KEY BLOCK-----\n",
buf) == 0)))
break;
}
}
while (fgets (buf, sizeof (buf), tfp)) {
- if (safe_strncmp ("-----BEGIN PGP ", buf, 15) == 0) {
- if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
+ if (str_ncmp ("-----BEGIN PGP ", buf, 15) == 0) {
+ if (str_cmp ("MESSAGE-----\n", buf + 15) == 0)
enc = 1;
- else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
+ else if (str_cmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
sgn = 1;
- else if (mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
+ else if (str_cmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
key = 1;
}
}
* read_mime_header has a hard time parsing the message.
*/
while (fgets (buf, sizeof (buf) - 1, pgpout) != NULL) {
- len = mutt_strlen (buf);
+ len = str_len (buf);
if (len > 1 && buf[len - 2] == '\r')
strcpy (buf + len - 2, "\n"); /* __STRCPY_CHECKED__ */
fputs (buf, fpout);
* recommended for future releases of PGP.
*/
while (fgets (buffer, sizeof (buffer) - 1, pgpout) != NULL) {
- if (mutt_strcmp ("-----BEGIN PGP MESSAGE-----\n", buffer) == 0)
+ if (str_cmp ("-----BEGIN PGP MESSAGE-----\n", buffer) == 0)
fputs ("-----BEGIN PGP SIGNATURE-----\n", fp);
- else if (mutt_strcmp ("-----END PGP MESSAGE-----\n", buffer) == 0)
+ else if (str_cmp ("-----END PGP MESSAGE-----\n", buffer) == 0)
fputs ("-----END PGP SIGNATURE-----\n", fp);
else
fputs (buffer, fp);
t = mutt_new_body ();
t->type = TYPEMULTIPART;
- t->subtype = safe_strdup ("signed");
+ t->subtype = str_dup ("signed");
t->encoding = ENC7BIT;
t->use_disp = 0;
t->disposition = DISPINLINE;
t->parts->next = mutt_new_body ();
t = t->parts->next;
t->type = TYPEAPPLICATION;
- t->subtype = safe_strdup ("pgp-signature");
- t->filename = safe_strdup (sigfile);
+ t->subtype = str_dup ("pgp-signature");
+ t->filename = str_dup (sigfile);
t->use_disp = 0;
t->disposition = DISPINLINE;
t->encoding = ENC7BIT;
/* or should we require the "0x"? */
if (strncmp (s, "0x", 2) == 0)
s += 2;
- if (mutt_strlen (s) % 8)
+ if (str_len (s) % 8)
return 0;
while (*s)
if (strchr ("0123456789ABCDEFabcdef", *s++) == NULL)
keyID = pgp_keyid (key);
bypass_selection:
- keylist_size += mutt_strlen (keyID) + 4;
+ keylist_size += str_len (keyID) + 4;
safe_realloc (&keylist, keylist_size);
sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
keyID);
- keylist_used = mutt_strlen (keylist);
+ keylist_used = str_len (keylist);
pgp_free_key (&key);
rfc822_free_address (&addr);
t = mutt_new_body ();
t->type = TYPEMULTIPART;
- t->subtype = safe_strdup ("encrypted");
+ t->subtype = str_dup ("encrypted");
t->encoding = ENC7BIT;
t->use_disp = 0;
t->disposition = DISPINLINE;
t->parts = mutt_new_body ();
t->parts->type = TYPEAPPLICATION;
- t->parts->subtype = safe_strdup ("pgp-encrypted");
+ t->parts->subtype = str_dup ("pgp-encrypted");
t->parts->encoding = ENC7BIT;
t->parts->next = mutt_new_body ();
t->parts->next->type = TYPEAPPLICATION;
- t->parts->next->subtype = safe_strdup ("octet-stream");
+ t->parts->next->subtype = str_dup ("octet-stream");
t->parts->next->encoding = ENC7BIT;
- t->parts->next->filename = safe_strdup (tempfile);
+ t->parts->next->filename = str_dup (tempfile);
t->parts->next->use_disp = 1;
t->parts->next->disposition = DISPINLINE;
t->parts->next->unlink = 1; /* delete after sending the message */
- t->parts->next->d_filename = safe_strdup ("msg.asc"); /* non pgp/mime can save */
+ t->parts->next->d_filename = str_dup ("msg.asc"); /* non pgp/mime can save */
return (t);
}
b->encoding = ENC7BIT;
b->type = TYPETEXT;
- b->subtype = safe_strdup ("plain");
+ b->subtype = str_dup ("plain");
mutt_set_parameter ("x-action",
flags & ENCRYPT ? "pgp-encrypted" : "pgp-signed",
&b->parameter);
mutt_set_parameter ("charset", send_charset, &b->parameter);
- b->filename = safe_strdup (pgpoutfile);
+ b->filename = str_dup (pgpoutfile);
#if 0
/* The following is intended to give a clue to some completely brain-dead
* "mail environments" which are typically used by large corporations.
*/
- b->d_filename = safe_strdup ("msg.pgp");
+ b->d_filename = str_dup ("msg.pgp");
b->use_disp = 1;
#endif
pgp_uid_t **s = (pgp_uid_t **) a;
pgp_uid_t **t = (pgp_uid_t **) b;
- if ((r = safe_strcasecmp ((*s)->addr, (*t)->addr)))
+ if ((r = str_casecmp ((*s)->addr, (*t)->addr)))
return r > 0;
else
- return (safe_strcasecmp (_pgp_keyid ((*s)->parent),
+ return (str_casecmp (_pgp_keyid ((*s)->parent),
_pgp_keyid ((*t)->parent)) > 0);
}
pgp_uid_t **s = (pgp_uid_t **) a;
pgp_uid_t **t = (pgp_uid_t **) b;
- if ((r = safe_strcasecmp (_pgp_keyid ((*s)->parent),
+ if ((r = str_casecmp (_pgp_keyid ((*s)->parent),
_pgp_keyid ((*t)->parent))))
return r > 0;
else
- return (safe_strcasecmp ((*s)->addr, (*t)->addr)) > 0;
+ return (str_casecmp ((*s)->addr, (*t)->addr)) > 0;
}
static int pgp_compare_keyid (const void *a, const void *b)
if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time)))
return r > 0;
- return (safe_strcasecmp ((*s)->addr, (*t)->addr)) > 0;
+ return (str_casecmp ((*s)->addr, (*t)->addr)) > 0;
}
static int pgp_compare_date (const void *a, const void *b)
return r < 0;
if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time)))
return r < 0;
- if ((r = safe_strcasecmp ((*s)->addr, (*t)->addr)))
+ if ((r = str_casecmp ((*s)->addr, (*t)->addr)))
return r > 0;
- return (safe_strcasecmp (_pgp_keyid ((*s)->parent),
+ return (str_casecmp (_pgp_keyid ((*s)->parent),
_pgp_keyid ((*t)->parent))) > 0;
}
rv |= PGP_KV_STRONGID;
if (addr->mailbox && u_addr->mailbox
- && safe_strcasecmp (addr->mailbox, u_addr->mailbox) == 0)
+ && str_casecmp (addr->mailbox, u_addr->mailbox) == 0)
rv |= PGP_KV_ADDR;
if (addr->personal && u_addr->personal
- && safe_strcasecmp (addr->personal, u_addr->personal) == 0)
+ && str_casecmp (addr->personal, u_addr->personal) == 0)
rv |= PGP_KV_STRING;
return rv;
if (whatfor) {
for (l = id_defaults; l; l = l->next)
- if (!safe_strcasecmp (whatfor, l->what)) {
+ if (!str_casecmp (whatfor, l->what)) {
strfcpy (resp, NONULL (l->dflt), sizeof (resp));
break;
}
l = safe_malloc (sizeof (struct pgp_cache));
l->next = id_defaults;
id_defaults = l;
- l->what = safe_strdup (whatfor);
- l->dflt = safe_strdup (resp);
+ l->what = str_dup (whatfor);
+ l->dflt = str_dup (resp);
}
}
fclose (devnull);
att = mutt_new_body ();
- att->filename = safe_strdup (tempf);
+ att->filename = str_dup (tempf);
att->unlink = 1;
att->use_disp = 0;
att->type = TYPEAPPLICATION;
- att->subtype = safe_strdup ("pgp-keys");
+ att->subtype = str_dup ("pgp-keys");
snprintf (buff, sizeof (buff), _("PGP Key %s."), tmp);
- att->description = safe_strdup (buff);
+ att->description = str_dup (buff);
mutt_update_encoding (att);
stat (tempf, &sb);
char *scratch;
char *t;
- if ((scratch = safe_strdup (str)) == NULL)
+ if ((scratch = str_dup (str)) == NULL)
return hints;
for (t = strtok (scratch, " ,.:\"()<>\n"); t;
t = strtok (NULL, " ,.:\"()<>\n")) {
- if (mutt_strlen (t) > 3)
+ if (str_len (t) > 3)
hints = mutt_add_list (hints, t);
}
for (a = k->address; a; a = a->next) {
debug_print (5, ("matching \"%s\" against key %s, \"%s\":\n", p, pgp_keyid (k), a->addr));
- if (!*p || safe_strcasecmp (p, pgp_keyid (k)) == 0
- || (!safe_strncasecmp (p, "0x", 2)
- && !safe_strcasecmp (p + 2, pgp_keyid (k)))
- || (option (OPTPGPLONGIDS) && !safe_strncasecmp (p, "0x", 2)
- && !safe_strcasecmp (p + 2, k->keyid + 8))
+ if (!*p || str_casecmp (p, pgp_keyid (k)) == 0
+ || (!str_ncasecmp (p, "0x", 2)
+ && !str_casecmp (p + 2, pgp_keyid (k)))
+ || (option (OPTPGPLONGIDS) && !str_ncasecmp (p, "0x", 2)
+ && !str_casecmp (p + 2, k->keyid + 8))
|| str_isstr (a->addr, p)) {
debug_print (5, ("match.\n"));
match = 1;
*lp = safe_calloc (1, sizeof (pgp_uid_t));
(*lp)->trust = up->trust;
(*lp)->flags = up->flags;
- (*lp)->addr = safe_strdup (up->addr);
+ (*lp)->addr = str_dup (up->addr);
(*lp)->parent = parent;
lp = &(*lp)->next;
}
return;
}
- if ((end = ftell (in) - mutt_strlen (line)) < start) {
+ if ((end = ftell (in) - str_len (line)) < start) {
debug_print (1, ("end < start???\n"));
return;
}
"%08lX", id);
}
- p->keyid = safe_strdup ((char *) scratch);
+ p->keyid = str_dup ((char *) scratch);
return p;
id);
}
- p->keyid = safe_strdup ((char *) scratch);
+ p->keyid = str_dup ((char *) scratch);
return p;
}
char *error_buf;
size_t error_buf_len;
- error_buf_len = sizeof ("fopen: ") - 1 + mutt_strlen (ringfile) + 1;
+ error_buf_len = sizeof ("fopen: ") - 1 + str_len (ringfile) + 1;
error_buf = safe_malloc (error_buf_len);
snprintf (error_buf, error_buf_len, "fopen: %s", ringfile);
perror (error_buf);
sscanf (line, "%d %s", &index, line);
for (i = 0; i < ctx->msgcount; i++)
- if (!mutt_strcmp (line, ctx->hdrs[i]->data))
+ if (!str_cmp (line, ctx->hdrs[i]->data))
break;
if (i == ctx->msgcount) {
ctx->msgcount++;
ctx->hdrs[i] = mutt_new_header ();
- ctx->hdrs[i]->data = safe_strdup (line);
+ ctx->hdrs[i]->data = str_dup (line);
}
else if (ctx->hdrs[i]->index != index - 1)
pop_data->clear_cache = 1;
return -1;
FREE (&ctx->path);
- ctx->path = safe_strdup (buf);
+ ctx->path = str_dup (buf);
pop_data = safe_calloc (1, sizeof (POP_DATA));
pop_data->conn = conn;
* portion of the headers, those required for the main display.
*/
cache->index = h->index;
- cache->path = safe_strdup (path);
+ cache->path = str_dup (path);
rewind (msg->fp);
uidl = h->data;
mutt_free_envelope (&h->env);
break;
#ifdef USE_SASL2
- if (!safe_strncmp (inbuf, "+ ", 2)
+ if (!str_ncmp (inbuf, "+ ", 2)
&& sasl_decode64 (inbuf, strlen (inbuf), buf, LONG_STRING - 1,
&len) != SASL_OK)
#else
- if (!safe_strncmp (inbuf, "+ ", 2)
+ if (!str_ncmp (inbuf, "+ ", 2)
&& sasl_decode64 (inbuf, strlen (inbuf), buf, &len) != SASL_OK)
#endif
{
if (rc != SASL_OK)
goto bail;
- if (!safe_strncmp (inbuf, "+OK", 3)) {
+ if (!str_ncmp (inbuf, "+OK", 3)) {
mutt_sasl_setup_conn (pop_data->conn, saslconn);
return POP_A_SUCCESS;
}
sasl_dispose (&saslconn);
/* terminate SASL sessoin if the last responce is not +OK nor -ERR */
- if (!safe_strncmp (inbuf, "+ ", 2)) {
+ if (!str_ncmp (inbuf, "+ ", 2)) {
snprintf (buf, sizeof (buf), "*\r\n");
if (pop_query (pop_data, buf, sizeof (buf)) == PQ_NOT_CONNECTED)
return POP_A_SOCKET;
if ((p1 = strchr (buf, '<')) && (p2 = strchr (p1, '>'))) {
p2[1] = '\0';
- pop_data->timestamp = safe_strdup (p1);
+ pop_data->timestamp = str_dup (p1);
}
}
if (PopAuthenticators && *PopAuthenticators) {
/* Try user-specified list of authentication methods */
- methods = safe_strdup (PopAuthenticators);
+ methods = str_dup (PopAuthenticators);
method = methods;
while (method) {
acct->port = POP_PORT;
acct->type = M_ACCT_TYPE_POP;
- c = safe_strdup (path);
+ c = str_dup (path);
url_parse_ciss (&url, c);
if (url.scheme == U_POP || url.scheme == U_POPS) {
t = strchr (pop_data->err_msg, '\0');
c = msg;
- if (!safe_strncmp (msg, "-ERR ", 5)) {
+ if (!str_ncmp (msg, "-ERR ", 5)) {
c2 = msg + 5;
SKIPWS (c2);
FREE (&pop_data->auth_list);
c = line + 4;
SKIPWS (c);
- pop_data->auth_list = safe_strdup (c);
+ pop_data->auth_list = str_dup (c);
}
else if (!ascii_strncasecmp (line, "STLS", 4))
pop_data->status = POP_CONNECTED;
- if (safe_strncmp (buf, "+OK", 3)) {
+ if (str_ncmp (buf, "+OK", 3)) {
*pop_data->err_msg = '\0';
pop_error (pop_data, buf);
mutt_error ("%s", pop_data->err_msg);
pop_data->status = POP_DISCONNECTED;
return PQ_NOT_CONNECTED;
}
- if (!safe_strncmp (buf, "+OK", 3))
+ if (!str_ncmp (buf, "+OK", 3))
return PQ_OK;
pop_error (pop_data, buf);
sscanf (line, "%u %s", &index, line);
for (i = 0; i < ctx->msgcount; i++) {
- if (!mutt_strcmp (ctx->hdrs[i]->data, line)) {
+ if (!str_cmp (ctx->hdrs[i]->data, line)) {
ctx->hdrs[i]->refno = index;
break;
}
tmp = next;
}
else if ((WithCrypto & APPLICATION_PGP)
- && (safe_strncmp ("Pgp:", tmp->data, 4) == 0 /* this is generated
+ && (str_ncmp ("Pgp:", tmp->data, 4) == 0 /* this is generated
* by old mutt versions
*/
- || safe_strncmp ("X-Mutt-PGP:", tmp->data, 11) == 0)) {
+ || str_ncmp ("X-Mutt-PGP:", tmp->data, 11) == 0)) {
hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1);
hdr->security |= APPLICATION_PGP;
tmp = next;
}
else if ((WithCrypto & APPLICATION_SMIME)
- && safe_strncmp ("X-Mutt-SMIME:", tmp->data, 13) == 0) {
+ && str_ncmp ("X-Mutt-SMIME:", tmp->data, 13) == 0) {
hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1);
hdr->security |= APPLICATION_SMIME;
}
#ifdef MIXMASTER
- else if (safe_strncmp ("X-Mutt-Mix:", tmp->data, 11) == 0) {
+ else if (str_ncmp ("X-Mutt-Mix:", tmp->data, 11) == 0) {
char *t;
mutt_free_list (&hdr->chain);
file[0] = '\0';
if (b->filename) {
strfcpy (file, b->filename, sizeof (file));
- b->d_filename = safe_strdup (b->filename);
+ b->d_filename = str_dup (b->filename);
}
else {
/* avoid Content-Disposition: header with temporary filename */
tmp = rfc822_cpy_adr (r->addr);
if (!tmp->next && !tmp->personal)
- tmp->personal = safe_strdup (r->name);
+ tmp->personal = str_dup (r->name);
mutt_addrlist_to_idna (tmp, NULL);
return tmp;
l = mutt_strwidth (p);
if (l > FirstColumn)
FirstColumn = l;
- cur->name = safe_strdup (p);
+ cur->name = str_dup (p);
p = strtok (NULL, "\t\n");
if (p) {
- cur->other = safe_strdup (p);
+ cur->other = str_dup (p);
}
}
}
mutt_format_string (buf2, sizeof (buf2),
FirstColumn + 2, FirstColumn + 2,
0, ' ', table[num].data->name,
- mutt_strlen (table[num].data->name), 0);
+ str_len (table[num].data->name), 0);
snprintf (s, slen, " %c %3d %s %-*.*s %s",
table[num].tagged ? '*' : ' ',
mutt_addrlist_to_local (tmpa);
tagged = 1;
rfc822_write_address (buf, buflen, tmpa, 0);
- curpos = mutt_strlen (buf);
+ curpos = str_len (buf);
rfc822_free_address (&tmpa);
}
else if (curpos + 2 < buflen) {
strcat (buf, ", "); /* __STRCAT_CHECKED__ */
rfc822_write_address ((char *) buf + curpos + 1,
buflen - curpos - 1, tmpa, 0);
- curpos = mutt_strlen (buf);
+ curpos = str_len (buf);
rfc822_free_address (&tmpa);
}
}
}
if (idx[x]->tree) {
- if (mutt_strcmp (idx[x]->tree, buf) != 0)
+ if (str_cmp (idx[x]->tree, buf) != 0)
str_replace (&idx[x]->tree, buf);
}
else
- idx[x]->tree = safe_strdup (buf);
+ idx[x]->tree = str_dup (buf);
if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
s = buf + 2 * (idx[x]->level - 1);
CHECK_ATTACH;
if (!idx[menu->current]->content->hdr->env->followup_to ||
- safe_strcasecmp (idx[menu->current]->content->hdr->env->followup_to,
+ str_casecmp (idx[menu->current]->content->hdr->env->followup_to,
"poster")
|| query_quadoption (OPT_FOLLOWUPTOPOSTER,
_("Reply by mail as poster prefers?")) !=
mutt_format_string (prompt, sizeof (prompt) - 4,
0, COLS - extra_space, 0, 0,
prompt, sizeof (prompt), 0);
- safe_strcat (prompt, sizeof (prompt), "...?");
+ str_cat (prompt, sizeof (prompt), "...?");
}
else
- safe_strcat (prompt, sizeof (prompt), "?");
+ str_cat (prompt, sizeof (prompt), "?");
if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
rfc822_free_address (&adr);
if ((flags & SENDNEWS)) {
/* in case followup set Newsgroups: with Followup-To: if it present */
if (!env->newsgroups && curenv &&
- safe_strcasecmp (curenv->followup_to, "poster"))
- env->newsgroups = safe_strdup (curenv->followup_to);
+ str_casecmp (curenv->followup_to, "poster"))
+ env->newsgroups = str_dup (curenv->followup_to);
}
else
#endif
/* first, generate the "random" remailer */
p = mix_new_remailer ();
- p->shortname = safe_strdup ("<random>");
+ p->shortname = str_dup ("<random>");
mix_add_entry (&type2_list, p, &slots, &used);
while (fgets (line, sizeof (line), fp)) {
if (!(t = strtok (line, " \t\n")))
goto problem;
- p->shortname = safe_strdup (t);
+ p->shortname = str_dup (t);
if (!(t = strtok (NULL, " \t\n")))
goto problem;
- p->addr = safe_strdup (t);
+ p->addr = str_dup (t);
if (!(t = strtok (NULL, " \t\n")))
goto problem;
if (!(t = strtok (NULL, " \t\n")))
goto problem;
- p->ver = safe_strdup (t);
+ p->ver = str_dup (t);
if (!(t = strtok (NULL, " \t\n")))
goto problem;
if (i) {
c =
- coords[i - 1].c + mutt_strlen (type2_list[chain->ch[i - 1]]->shortname) + 2;
+ coords[i - 1].c + str_len (type2_list[chain->ch[i - 1]]->shortname) + 2;
r = coords[i - 1].r;
}
else {
for (; i < chain->cl; i++) {
oc = c;
- c += mutt_strlen (type2_list[chain->ch[i]]->shortname) + 2;
+ c += str_len (type2_list[chain->ch[i]]->shortname) + 2;
if (c >= COLS) {
oc = c = MIX_HOFFSET;
if (chain->cl >= MAXMIXES)
return -1;
- if (!mutt_strcmp (s, "0") || !ascii_strcasecmp (s, "<random>")) {
+ if (!str_cmp (s, "0") || !ascii_strcasecmp (s, "<random>")) {
chain->ch[chain->cl++] = 0;
return 0;
}
/* check type */
ch = get_field (buf);
if (ascii_strcasecmp (buf, type) && (ascii_strncasecmp (buf, type, btlen) || (buf[btlen] != 0 && /* implicit wild */
- mutt_strcmp (buf + btlen, "/*")))) /* wildsubtype */
+ str_cmp (buf + btlen, "/*")))) /* wildsubtype */
continue;
/* next field is the viewcommand */
field = ch;
ch = get_field (ch);
if (entry)
- entry->command = safe_strdup (field);
+ entry->command = str_dup (field);
/* parse the optional fields */
found = TRUE;
if (get_field_text (field + 4, &test_command, type, filename, line)
&& test_command) {
- len = mutt_strlen (test_command) + STRING;
+ len = str_len (test_command) + STRING;
safe_realloc (&test_command, len);
rfc1524_expand_command (a, a->filename, type, test_command, len);
if (mutt_system (test_command)) {
rmatch = 1;
- for (r = 0, j = mutt_strlen (oldfile) - 1, k =
- mutt_strlen (nametemplate) - 1;
+ for (r = 0, j = str_len (oldfile) - 1, k =
+ str_len (nametemplate) - 1;
j >= (lmatch ? i : 0) && k >= i + 2; j--, k--) {
if (nametemplate[k] != oldfile[j]) {
rmatch = 0;
#endif
#define ENCWORD_LEN_MAX 75
-#define ENCWORD_LEN_MIN 9 /* mutt_strlen ("=?.?.?.?=") */
+#define ENCWORD_LEN_MIN 9 /* str_len ("=?.?.?.?=") */
#define HSPACE(x) ((x) == '\0' || (x) == ' ' || (x) == '\t')
q = strchr (p, ':');
- n = q ? q - p : mutt_strlen (p);
+ n = q ? q - p : str_len (p);
if (!n ||
/* Assume that we never need more than 12 characters of
char *s0 = s;
memcpy (s, "=?", 2), s += 2;
- memcpy (s, tocode, mutt_strlen (tocode)), s += mutt_strlen (tocode);
+ memcpy (s, tocode, str_len (tocode)), s += str_len (tocode);
memcpy (s, "?B?", 3), s += 3;
for (;;) {
if (!dlen)
char *s0 = s;
memcpy (s, "=?", 2), s += 2;
- memcpy (s, tocode, mutt_strlen (tocode)), s += mutt_strlen (tocode);
+ memcpy (s, tocode, str_len (tocode)), s += str_len (tocode);
memcpy (s, "?Q?", 3), s += 3;
while (dlen--) {
unsigned char c = *d++;
if (fromcode) {
cd = mutt_iconv_open (tocode, fromcode, 0);
assert (cd != (iconv_t) (-1));
- ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - mutt_strlen (tocode);
+ ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - str_len (tocode);
if (iconv (cd, &ib, &ibl, &ob, &obl) == (size_t) (-1) ||
iconv (cd, 0, 0, &ob, &obl) == (size_t) (-1)) {
assert (errno == E2BIG);
iconv_close (cd);
}
else {
- if (dlen > sizeof (buf1) - mutt_strlen (tocode))
- return sizeof (buf1) - mutt_strlen (tocode) + 1;
+ if (dlen > sizeof (buf1) - str_len (tocode))
+ return sizeof (buf1) - str_len (tocode) + 1;
memcpy (buf1, d, dlen);
ob = buf1 + dlen;
}
++count;
}
- len = ENCWORD_LEN_MIN - 2 + mutt_strlen (tocode);
+ len = ENCWORD_LEN_MIN - 2 + str_len (tocode);
len_b = len + (((ob - buf1) + 2) / 3) * 4;
len_q = len + (ob - buf1) + 2 * count;
if (fromcode) {
cd = mutt_iconv_open (tocode, fromcode, 0);
assert (cd != (iconv_t) (-1));
- ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - mutt_strlen (tocode);
+ ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - str_len (tocode);
n1 = iconv (cd, &ib, &ibl, &ob, &obl);
n2 = iconv (cd, 0, 0, &ob, &obl);
assert (n1 != (size_t) (-1) && n2 != (size_t) (-1));
/* Add to output buffer. */
#define LINEBREAK "\n\t"
- if (bufpos + wlen + mutt_strlen (LINEBREAK) > buflen) {
- buflen = bufpos + wlen + mutt_strlen (LINEBREAK);
+ if (bufpos + wlen + str_len (LINEBREAK) > buflen) {
+ buflen = bufpos + wlen + str_len (LINEBREAK);
safe_realloc (&buf, buflen);
}
r = encode_block (buf + bufpos, t, n, icode, tocode, encoder);
assert (r == wlen);
bufpos += wlen;
- memcpy (buf + bufpos, LINEBREAK, mutt_strlen (LINEBREAK));
- bufpos += mutt_strlen (LINEBREAK);
+ memcpy (buf + bufpos, LINEBREAK, str_len (LINEBREAK));
+ bufpos += str_len (LINEBREAK);
#undef LINEBREAK
col = 1;
if (!charsets || !*charsets)
charsets = "UTF-8";
- rfc2047_encode (*pd, mutt_strlen (*pd), col,
+ rfc2047_encode (*pd, str_len (*pd), col,
Charset, charsets, &e, &elen,
encode_specials ? RFC822Specials : NULL);
void rfc2047_encode_adrlist (ADDRESS * addr, const char *tag)
{
ADDRESS *ptr = addr;
- int col = tag ? mutt_strlen (tag) + 2 : 32;
+ int col = tag ? str_len (tag) + 2 : 32;
while (ptr) {
if (ptr->personal)
int enc = 0, count = 0;
char *charset = NULL;
- pd = d0 = safe_malloc (mutt_strlen (s));
+ pd = d0 = safe_malloc (str_len (s));
for (pp = s; (pp1 = strchr (pp, '?')); pp = pp1 + 1) {
count++;
if (!s || !*s)
return;
- dlen = 4 * mutt_strlen (s); /* should be enough */
+ dlen = 4 * str_len (s); /* should be enough */
d = d0 = safe_malloc (dlen + 1);
while (*s && dlen > 0) {
if (!(p = find_encoded_word (s, &q))) {
/* no encoded words */
if (!option (OPTSTRICTMIME)) {
- n = mutt_strlen (s);
+ n = str_len (s);
if (found_encoded && (m = lwslen (s, n)) != 0) {
if (m != n)
*d = ' ', d++, dlen--;
t = safe_malloc (n + 1);
strfcpy (t, s, n + 1);
if (mutt_convert_nonmime_string (&t) == 0) {
- tlen = mutt_strlen (t);
+ tlen = str_len (t);
strncpy (d, t, tlen);
d += tlen;
}
rfc2047_decode_word (d, p, dlen);
found_encoded = 1;
s = q;
- n = mutt_strlen (d);
+ n = str_len (d);
dlen -= n;
d += n;
}
q = p;
p = p->next;
- c = mutt_strcmp (par->value, q->value);
+ c = str_cmp (par->value, q->value);
if ((c > 0) || (c == 0 && par->index >= q->index))
break;
}
if (encoded && par->encoded)
rfc2231_decode_one (par->value, valp);
- vl = mutt_strlen (par->value);
+ vl = str_len (par->value);
safe_realloc (&value, l + vl + 1);
strcpy (value + l, par->value); /* __STRCPY_CHECKED__ */
rfc2231_free_parameter (&par);
if ((par = q))
valp = par->value;
- } while (par && !mutt_strcmp (par->attribute, attribute));
+ } while (par && !str_cmp (par->attribute, attribute));
if (value) {
if (encoded)
mutt_convert_string (&value, charset, Charset, M_ICONV_HOOK_FROM);
*head = mutt_new_parameter ();
- (*head)->attribute = safe_strdup (attribute);
+ (*head)->attribute = str_dup (attribute);
(*head)->value = value;
head = &(*head)->next;
}
if (!Charset || !SendCharset ||
!(charset = mutt_choose_charset (Charset, SendCharset,
- *pd, mutt_strlen (*pd), &d, &dlen))) {
- charset = safe_strdup (Charset ? Charset : "unknown-8bit");
+ *pd, str_len (*pd), &d, &dlen))) {
+ charset = str_dup (Charset ? Charset : "unknown-8bit");
d = *pd;
- dlen = mutt_strlen (d);
+ dlen = str_len (d);
}
if (!mutt_is_us_ascii (charset))
++ext;
if (encode) {
- e = safe_malloc (dlen + 2 * ext + mutt_strlen (charset) + 3);
+ e = safe_malloc (dlen + 2 * ext + str_len (charset) + 3);
sprintf (e, "%s''", charset); /* __SPRINTF_CHECKED__ */
- t = e + mutt_strlen (e);
+ t = e + str_len (e);
for (s = d, slen = dlen; slen; s++, slen--)
if (*s < 0x20 || *s >= 0x7f ||
strchr (MimeSpecials, *s) || strchr ("*'%", *s)) {
}
terminate_string (token, *tokenlen, tokenmax);
- addr->mailbox = safe_strdup (token);
+ addr->mailbox = str_dup (token);
if (*commentlen && !addr->personal) {
terminate_string (comment, *commentlen, commentmax);
- addr->personal = safe_strdup (comment);
+ addr->personal = str_dup (comment);
}
return s;
}
if (!addr->mailbox)
- addr->mailbox = safe_strdup ("@");
+ addr->mailbox = str_dup ("@");
s++;
return s;
}
else if (commentlen && last && !last->personal) {
terminate_buffer (comment, commentlen);
- last->personal = safe_strdup (comment);
+ last->personal = str_dup (comment);
}
commentlen = 0;
else if (*s == ':') {
cur = rfc822_new_address ();
terminate_buffer (phrase, phraselen);
- cur->mailbox = safe_strdup (phrase);
+ cur->mailbox = str_dup (phrase);
cur->group = 1;
if (last)
}
else if (commentlen && last && !last->personal) {
terminate_buffer (comment, commentlen);
- last->personal = safe_strdup (comment);
+ last->personal = str_dup (comment);
}
/* add group terminator */
FREE (&cur->personal);
/* if we get something like "Michael R. Elkins" remove the quotes */
rfc822_dequote_comment (phrase);
- cur->personal = safe_strdup (phrase);
+ cur->personal = str_dup (phrase);
}
if ((ps =
parse_route_addr (s + 1, comment, &commentlen,
}
else if (commentlen && last && !last->personal) {
terminate_buffer (comment, commentlen);
- last->personal = safe_strdup (comment);
+ last->personal = str_dup (comment);
}
return top;
for (; addr; addr = addr->next)
if (!addr->group && addr->mailbox && strchr (addr->mailbox, '@') == NULL) {
- p = safe_malloc (mutt_strlen (addr->mailbox) + mutt_strlen (host) + 2);
+ p = safe_malloc (str_len (addr->mailbox) + str_len (host) + 2);
sprintf (p, "%s@%s", addr->mailbox, host); /* __SPRINTF_CHECKED__ */
FREE (&addr->mailbox);
addr->mailbox = p;
if (!buflen)
goto done;
strfcpy (pbuf, addr->personal, buflen);
- len = mutt_strlen (pbuf);
+ len = str_len (pbuf);
pbuf += len;
buflen -= len;
}
goto done;
if (ascii_strcmp (addr->mailbox, "@") && !display) {
strfcpy (pbuf, addr->mailbox, buflen);
- len = mutt_strlen (pbuf);
+ len = str_len (pbuf);
}
else if (ascii_strcmp (addr->mailbox, "@") && display) {
strfcpy (pbuf, mutt_addr_for_display (addr), buflen);
- len = mutt_strlen (pbuf);
+ len = str_len (pbuf);
}
else {
*pbuf = '\0';
int display)
{
char *pbuf = buf;
- size_t len = mutt_strlen (buf);
+ size_t len = str_len (buf);
buflen--; /* save room for the terminal nul */
/* this should be safe since we always have at least 1 char passed into
the above call, which means `pbuf' should always be nul terminated */
- len = mutt_strlen (pbuf);
+ len = str_len (pbuf);
pbuf += len;
buflen -= len;
{
ADDRESS *p = rfc822_new_address ();
- p->personal = safe_strdup (addr->personal);
- p->mailbox = safe_strdup (addr->mailbox);
+ p->personal = str_dup (addr->personal);
+ p->mailbox = str_dup (addr->mailbox);
p->group = addr->group;
return p;
}
/* look for an existing entry and update the value, else add it to the end
of the list */
for (ptr = Score, last = NULL; ptr; last = ptr, ptr = ptr->next)
- if (mutt_strcmp (pattern, ptr->str) == 0)
+ if (str_cmp (pattern, ptr->str) == 0)
break;
if (!ptr) {
if ((pat = mutt_pattern_comp (pattern, 0, err)) == NULL) {
while (MoreArgs (s)) {
mutt_extract_token (buf, s, 0);
- if (!mutt_strcmp ("*", buf->data)) {
+ if (!str_cmp ("*", buf->data)) {
for (tmp = Score; tmp;) {
last = tmp;
tmp = tmp->next;
}
else {
for (tmp = Score; tmp; last = tmp, tmp = tmp->next) {
- if (!mutt_strcmp (buf->data, tmp->str)) {
+ if (!str_cmp (buf->data, tmp->str)) {
if (last)
last->next = tmp->next;
else
if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0)
return (-1);
FREE (&en->newsgroups);
- en->newsgroups = safe_strdup (buf);
+ en->newsgroups = str_dup (buf);
if (en->followup_to)
strfcpy (buf, en->followup_to, sizeof (buf));
&& mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
return (-1);
FREE (&en->followup_to);
- en->followup_to = safe_strdup (buf);
+ en->followup_to = str_dup (buf);
if (en->x_comment_to)
strfcpy (buf, en->x_comment_to, sizeof (buf));
&& mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
return (-1);
FREE (&en->x_comment_to);
- en->x_comment_to = safe_strdup (buf);
+ en->x_comment_to = str_dup (buf);
}
else
#endif
char *nntp_get_header (const char *s)
{
SKIPWS (s);
- return safe_strdup (s);
+ return str_dup (s);
}
#endif
}
else
last = env->userhdrs = mutt_new_list ();
- last->data = safe_strdup (uh->data);
+ last->data = str_dup (uh->data);
}
}
}
for (; p; p = p->next) {
t = (LIST *) safe_malloc (sizeof (LIST));
- t->data = safe_strdup (p->data);
+ t->data = str_dup (p->data);
t->next = NULL;
if (l) {
r->next = t;
if (e->message_id) {
t = mutt_new_list ();
- t->data = safe_strdup (e->message_id);
+ t->data = str_dup (e->message_id);
t->next = l;
l = t;
}
*/
if (curenv->real_subj) {
FREE (&env->subject);
- env->subject = safe_malloc (mutt_strlen (curenv->real_subj) + 5);
+ env->subject = safe_malloc (str_len (curenv->real_subj) + 5);
sprintf (env->subject, "Re: %s", curenv->real_subj); /* __SPRINTF_CHECKED__ */
}
else if (!env->subject)
- env->subject = safe_strdup ("Re: your mail");
+ env->subject = str_dup ("Re: your mail");
#ifdef USE_NNTP
if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
- env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
+ env->x_comment_to = str_dup (mutt_get_name (curenv->from));
#endif
}
if (curenv->message_id) {
*q = mutt_new_list ();
- (*q)->data = safe_strdup (curenv->message_id);
+ (*q)->data = str_dup (curenv->message_id);
}
if (pp)
if ((flags & SENDNEWS)) {
/* in case followup set Newsgroups: with Followup-To: if it present */
if (!env->newsgroups && curenv &&
- safe_strcasecmp (curenv->followup_to, "poster"))
- env->newsgroups = safe_strdup (curenv->followup_to);
+ str_casecmp (curenv->followup_to, "poster"))
+ env->newsgroups = str_dup (curenv->followup_to);
}
else
#endif
#ifdef USE_NNTP
if (option (OPTNEWSSEND)) {
if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
- e->followup_to = safe_strdup (e->newsgroups);
+ e->followup_to = str_dup (e->newsgroups);
return;
}
#endif
if (!option (OPTREVREAL))
FREE (&tmp->personal);
if (!tmp->personal)
- tmp->personal = safe_strdup (Realname);
+ tmp->personal = str_dup (Realname);
}
return (tmp);
}
else if (option (OPTUSEDOMAIN)) {
adr = rfc822_new_address ();
adr->mailbox =
- safe_malloc (mutt_strlen (Username) + mutt_strlen (fqdn) + 2);
+ safe_malloc (str_len (Username) + str_len (fqdn) + 2);
sprintf (adr->mailbox, "%s@%s", NONULL (Username), NONULL (fqdn)); /* __SPRINTF_CHECKED__ */
}
else {
adr = rfc822_new_address ();
- adr->mailbox = safe_strdup (NONULL (Username));
+ adr->mailbox = str_dup (NONULL (Username));
}
return (adr);
if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED))
- signas = safe_strdup (PgpSignAs);
+ signas = str_dup (PgpSignAs);
/* Delay expansion of aliases until absolutely necessary--shouldn't
* be necessary unless we are prompting the user or about to execute a
if (!tempfile) {
mutt_mktemp (buffer);
tempfp = safe_fopen (buffer, "w+");
- msg->content->filename = safe_strdup (buffer);
+ msg->content->filename = str_dup (buffer);
}
else {
tempfp = safe_fopen (tempfile, "a+");
- msg->content->filename = safe_strdup (tempfile);
+ msg->content->filename = str_dup (tempfile);
}
if (!tempfp) {
#ifdef USE_NNTP
if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP
&& !msg->env->newsgroups)
- msg->env->newsgroups = safe_strdup (((NNTP_DATA *) ctx->data)->group);
+ msg->env->newsgroups = str_dup (((NNTP_DATA *) ctx->data)->group);
#endif
if (!(flags & SENDMAILX) &&
if (option (OPTSIGONTOP)
&& (!(flags & (SENDMAILX | SENDKEY)) && Editor
- && mutt_strcmp (Editor, "builtin") != 0))
+ && str_cmp (Editor, "builtin") != 0))
append_signature (tempfp);
/* include replies/forwarded messages, unless we are given a template */
if (!option (OPTSIGONTOP)
&& (!(flags & (SENDMAILX | SENDKEY)) && Editor
- && mutt_strcmp (Editor, "builtin") != 0))
+ && str_cmp (Editor, "builtin") != 0))
append_signature (tempfp);
/*
that $realname can be set in a send-hook */
if (msg->env->from && !msg->env->from->personal
&& !(flags & (SENDRESEND | SENDPOSTPONED)))
- msg->env->from->personal = safe_strdup (Realname);
+ msg->env->from->personal = str_dup (Realname);
if (!((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY)))
safe_fclose (&tempfp);
/* If the this isn't a text message, look for a mailcap edit command */
if (mutt_needs_mailcap (msg->content))
mutt_edit_attachment (msg->content);
- else if (!Editor || mutt_strcmp ("builtin", Editor) == 0)
+ else if (!Editor || str_cmp ("builtin", Editor) == 0)
mutt_builtin_editor (msg->content->filename, msg, cur);
else if (option (OPTEDITHDRS)) {
mutt_env_to_local (msg->env);
fcc[0] = '\0';
#endif
- if (*fcc && mutt_strcmp ("/dev/null", fcc) != 0) {
+ if (*fcc && str_cmp ("/dev/null", fcc) != 0) {
BODY *tmpbody = msg->content;
BODY *save_sig = NULL;
BODY *save_parts = NULL;
/* check to see if the user wants copies of all attachments */
if (!option (OPTFCCATTACH) && msg->content->type == TYPEMULTIPART) {
if (WithCrypto
- && (mutt_strcmp (msg->content->subtype, "encrypted") == 0 ||
- mutt_strcmp (msg->content->subtype, "signed") == 0)) {
+ && (str_cmp (msg->content->subtype, "encrypted") == 0 ||
+ str_cmp (msg->content->subtype, "signed") == 0)) {
if (clear_content->type == TYPEMULTIPART) {
if (!(msg->security & ENCRYPT) && (msg->security & SIGN)) {
/* save initial signature and attachments */
}
/* Escape lines that begin with/only contain "the message separator". */
- if (linelen == 4 && !safe_strncmp ("From", line, 4)) {
+ if (linelen == 4 && !str_ncmp ("From", line, 4)) {
strfcpy (line, "=46rom", sizeof (line));
linelen = 6;
}
- else if (linelen == 4 && !safe_strncmp ("from", line, 4)) {
+ else if (linelen == 4 && !str_ncmp ("from", line, 4)) {
strfcpy (line, "=66rom", sizeof (line));
linelen = 6;
}
fprintf (f, "Content-Type: %s/%s", TYPE (a), a->subtype);
if (a->parameter) {
- len = 25 + mutt_strlen (a->subtype); /* approximate len. of content-type */
+ len = 25 + str_len (a->subtype); /* approximate len. of content-type */
for (p = a->parameter; p; p = p->next) {
char *tmp;
fputc (';', f);
buffer[0] = 0;
- tmp = safe_strdup (p->value);
+ tmp = str_dup (p->value);
encode = rfc2231_encode_string (&tmp);
rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials);
FREE (&tmp);
- tmplen = mutt_strlen (buffer) + mutt_strlen (p->attribute) + 1;
+ tmplen = str_len (buffer) + str_len (p->attribute) + 1;
if (len + tmplen + 2 > 76) {
fputs ("\n\t", f);
t = fn;
buffer[0] = 0;
- tmp = safe_strdup (t);
+ tmp = str_dup (t);
encode = rfc2231_encode_string (&tmp);
rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials);
FREE (&tmp);
/* This is pretty gross, but it's the best solution for now... */
if ((WithCrypto & APPLICATION_PGP)
&& a->type == TYPEAPPLICATION
- && mutt_strcmp (a->subtype, "pgp-encrypted") == 0) {
+ && str_cmp (a->subtype, "pgp-encrypted") == 0) {
fputs ("Version: 1\n", f);
return 0;
}
type = TYPEOTHER;
cur_sze = 0;
- szf = mutt_strlen (path);
+ szf = str_len (path);
for (count = 0; count < 3; count++) {
/*
/* cycle through the file extensions */
while ((p = strtok (p, " \t\n"))) {
- sze = mutt_strlen (p);
+ sze = str_len (p);
if ((sze > cur_sze) && (szf >= sze) &&
- (safe_strcasecmp (path + szf - sze, p) == 0
+ (str_casecmp (path + szf - sze, p) == 0
|| ascii_strcasecmp (path + szf - sze, p) == 0) && (szf == sze
|| path[szf
-
a->d_filename = a->filename;
if (a->filename && a->unlink)
unlink (a->filename);
- a->filename = safe_strdup (temp);
+ a->filename = str_dup (temp);
a->unlink = 1;
if (stat (a->filename, &sb) == -1) {
mutt_perror ("stat");
mutt_decode_attachment (a, &s);
fclose (s.fpout);
a->d_filename = a->filename;
- a->filename = safe_strdup (buff);
+ a->filename = str_dup (buff);
a->unlink = 1;
if (stat (a->filename, &sb) == -1) {
mutt_perror ("stat");
body = mutt_new_body ();
body->type = TYPEMESSAGE;
- body->subtype = safe_strdup ("rfc822");
- body->filename = safe_strdup (buffer);
+ body->subtype = str_dup ("rfc822");
+ body->filename = str_dup (buffer);
body->unlink = 1;
body->use_disp = 0;
body->disposition = DISPINLINE;
CONTENT *info;
att = mutt_new_body ();
- att->filename = safe_strdup (path);
+ att->filename = str_dup (path);
/* Attempt to determine the appropriate content-type based on the filename
* suffix.
mutt_lookup_mime_type (buf, sizeof (buf), xbuf, sizeof (xbuf),
path)) != TYPEOTHER || *xbuf != '\0') {
att->type = n;
- att->subtype = safe_strdup (buf);
- att->xtype = safe_strdup (xbuf);
+ att->subtype = str_dup (buf);
+ att->xtype = str_dup (xbuf);
}
#else
* chars if this is really a binary file...
*/
att->type = TYPETEXT;
- att->subtype = safe_strdup ("plain");
+ att->subtype = str_dup ("plain");
}
else {
att->type = TYPEAPPLICATION;
- att->subtype = safe_strdup ("octet-stream");
+ att->subtype = str_dup ("octet-stream");
}
}
new = mutt_new_body ();
new->type = TYPEMULTIPART;
- new->subtype = safe_strdup ("mixed");
+ new->subtype = str_dup ("mixed");
new->encoding = get_toplevel_encoding (b);
mutt_generate_boundary (&new->parameter);
new->use_disp = 0;
adr->next = NULL;
buf[0] = 0;
rfc822_write_address (buf, sizeof (buf), adr, display);
- len = mutt_strlen (buf);
+ len = str_len (buf);
if (count && linelen + len > 74) {
fputs ("\n\t", fp);
linelen = len + 8; /* tab is usually about 8 spaces... */
i = p - h->data;
++p;
SKIPWS (p);
- tmp = safe_strdup (p);
+ tmp = str_dup (p);
if (!tmp)
continue;
rfc2047_encode_string (&tmp);
safe_realloc (&h->data,
- mutt_strlen (h->data) + 2 + mutt_strlen (tmp) + 1);
+ str_len (h->data) + 2 + str_len (tmp) + 1);
sprintf (h->data + i, ": %s", NONULL (tmp)); /* __SPRINTF_CHECKED__ */
return;
case 'd':
snprintf (tmp, sizeof (tmp), "%02d", tm->tm_mday);
- safe_strncat (buf, len, tmp, 2);
+ str_ncat (buf, len, tmp, 2);
break;
case 'h':
snprintf (tmp, sizeof (tmp), "%02d", tm->tm_hour);
- safe_strncat (buf, len, tmp, 2);
+ str_ncat (buf, len, tmp, 2);
break;
case 'm':
snprintf (tmp, sizeof (tmp), "%02d", tm->tm_mon + 1);
- safe_strncat (buf, len, tmp, 2);
+ str_ncat (buf, len, tmp, 2);
break;
case 'M':
snprintf (tmp, sizeof (tmp), "%02d", tm->tm_min);
- safe_strncat (buf, len, tmp, 2);
+ str_ncat (buf, len, tmp, 2);
break;
case 'O':
snprintf (tmp, sizeof (tmp), "%lo", (unsigned long) now);
- safe_strncat (buf, len, tmp, mutt_strlen (tmp));
+ str_ncat (buf, len, tmp, str_len (tmp));
break;
case 'p':
snprintf (tmp, sizeof (tmp), "%u", (unsigned int) getpid ());
- safe_strncat (buf, len, tmp, mutt_strlen (tmp));
+ str_ncat (buf, len, tmp, str_len (tmp));
break;
case 'P':
snprintf (tmp, sizeof (tmp), "%c", MsgIdPfx);
MsgIdPfx = (MsgIdPfx == 'Z') ? 'A' : MsgIdPfx + 1;
- safe_strncat (buf, len, tmp, 1);
+ str_ncat (buf, len, tmp, 1);
break;
case 'r':
snprintf (tmp, sizeof (tmp), "%u", (unsigned int) rand ());
- safe_strncat (buf, len, tmp, mutt_strlen (tmp));
+ str_ncat (buf, len, tmp, str_len (tmp));
break;
case 'R':
snprintf (tmp, sizeof (tmp), "%x", (unsigned int) rand ());
- safe_strncat (buf, len, tmp, mutt_strlen (tmp));
+ str_ncat (buf, len, tmp, str_len (tmp));
break;
case 's':
snprintf (tmp, sizeof (tmp), "%02d", tm->tm_sec);
- safe_strncat (buf, len, tmp, 2);
+ str_ncat (buf, len, tmp, 2);
break;
case 'T':
snprintf (tmp, sizeof (tmp), "%u", (unsigned int) now);
- safe_strncat (buf, len, tmp, mutt_strlen (tmp));
+ str_ncat (buf, len, tmp, str_len (tmp));
break;
case 'X':
snprintf (tmp, sizeof (tmp), "%x", (unsigned int) now);
- safe_strncat (buf, len, tmp, mutt_strlen (tmp));
+ str_ncat (buf, len, tmp, str_len (tmp));
break;
case 'Y':
snprintf (tmp, sizeof (tmp), "%04d", tm->tm_year + 1900); /* this will break in the year 10000 ;-) */
- safe_strncat (buf, len, tmp, 4);
+ str_ncat (buf, len, tmp, 4);
break;
case '%':
- safe_strncat (buf, len, "%", 1);
+ str_ncat (buf, len, "%", 1);
break;
default:
- safe_strncat (buf, len, ".", 1); /* invalid formats are replaced by '.' */
+ str_ncat (buf, len, ".", 1); /* invalid formats are replaced by '.' */
} /* switch */
++fmt;
}
char c;
c = mutt_normalized_char (*fmt); /* @todo: filter out invalid characters */
- safe_strncat (buf, len, &c, 1);
+ str_ncat (buf, len, &c, 1);
}
}
}
if (!(fqdn = mutt_fqdn (0)))
fqdn = NONULL (Hostname);
- localpart_length = sizeof (buf) - mutt_strlen (fqdn) - 4; /* the 4 characters are '<', '@', '>' and '\0' */
+ localpart_length = sizeof (buf) - str_len (fqdn) - 4; /* the 4 characters are '<', '@', '>' and '\0' */
mutt_gen_localpart (localpart, localpart_length, MsgIdFormat);
snprintf (buf, sizeof (buf), "<%s@%s>", localpart, fqdn);
- return (safe_strdup (buf));
+ return (str_dup (buf));
}
static RETSIGTYPE alarm_handler (int sig)
char tmp[_POSIX_PATH_MAX];
mutt_mktemp (tmp);
- *tempfile = safe_strdup (tmp);
+ *tempfile = str_dup (tmp);
}
if ((pid = fork ()) == 0) {
return i;
}
- s = safe_strdup (cmd);
+ s = str_dup (cmd);
}
else
#endif
- s = safe_strdup (Sendmail);
+ s = str_dup (Sendmail);
ps = s;
i = 0;
if (i)
args[argslen++] = ps;
else {
- path = safe_strdup (ps);
+ path = str_dup (ps);
ps = strrchr (ps, '/');
if (ps)
ps++;
string. */
char *mutt_append_string (char *a, const char *b)
{
- size_t la = mutt_strlen (a);
+ size_t la = str_len (a);
- safe_realloc (&a, la + mutt_strlen (b) + 1);
+ safe_realloc (&a, la + str_len (b) + 1);
strcpy (a + la, b); /* __STRCPY_CHECKED__ */
return (a);
}
char *r, *pr;
size_t rlen;
- rlen = mutt_strlen (s) + 3;
+ rlen = str_len (s) + 3;
pr = r = (char *) safe_malloc (rlen);
*pr++ = '"';
while (*s) {
rfc822_cat (buffer, sizeof (buffer), "undisclosed-recipients",
RFC822Specials);
- env->to->mailbox = safe_strdup (buffer);
+ env->to->mailbox = str_dup (buffer);
}
mutt_set_followup_to (env);
{
int dots = 0;
char *last_dot = NULL;
- int i, j, len = mutt_strlen (box);
+ int i, j, len = str_len (box);
char *new_box;
if (!SidebarBoundary || !*SidebarBoundary)
- return (safe_strdup (box));
+ return (str_dup (box));
for (i = 0; i < len; ++i) {
if (strchr (SidebarBoundary, box[i])) {
if (strchr (SidebarBoundary, box[i])) {
new_box[j++] = box[i];
new_box[j] = 0;
- if (&box[i + 1] != last_dot || j + mutt_strlen (last_dot) > maxlen) {
+ if (&box[i + 1] != last_dot || j + str_len (last_dot) > maxlen) {
new_box[j++] = box[i + 1];
new_box[j] = 0;
} else {
}
return new_box;
}
- return safe_strdup (box);
+ return str_dup (box);
}
static const char* sidebar_number_format (char* dest, size_t destlen, char op,
int shortened = 0, lencnt = 0;
char no[SHORT_STRING], entry[SHORT_STRING];
#if USE_IMAP
- int l = mutt_strlen (ImapHomeNamespace);
+ int l = str_len (ImapHomeNamespace);
#endif
if (SidebarWidth > COLS)
mutt_FormatString (no, len, NONULL (SidebarNumberFormat),
sidebar_number_format, idx, M_FORMAT_OPTIONAL);
- lencnt = mutt_strlen (no);
+ lencnt = str_len (no);
memset (&entry, ' ', sizeof (entry));
#if USE_IMAP
- if (l > 0 && safe_strncmp (box, ImapHomeNamespace, l) == 0 &&
- mutt_strlen (box) > l)
+ if (l > 0 && str_ncmp (box, ImapHomeNamespace, l) == 0 &&
+ str_len (box) > l)
box += l + 1;
else
#endif
box = basename (box);
- if (option (OPTSHORTENHIERARCHY) && mutt_strlen (box) > len-lencnt-1) {
+ if (option (OPTSHORTENHIERARCHY) && str_len (box) > len-lencnt-1) {
box = shortened_hierarchy (box, len-lencnt-1);
shortened = 1;
}
snprintf (entry, len-lencnt, "%s", box);
- entry[mutt_strlen (entry)] = ' ';
+ entry[str_len (entry)] = ' ';
strncpy (entry + (len - lencnt), no, lencnt);
addnstr (entry, len);
int lines = option (OPTHELP) ? 1 : 0, draw_devider = 1, i = 0;
BUFFY *tmp;
- short delim_len = mutt_strlen (SidebarDelim);
+ short delim_len = str_len (SidebarDelim);
char blank[SHORT_STRING];
/* initialize first time */
}
if (SidebarWidth > 0 && option (OPTMBOXPANE)
- && mutt_strlen (SidebarDelim) >= SidebarWidth) {
+ && str_len (SidebarDelim) >= SidebarWidth) {
mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
sleep (2);
unset_option (OPTMBOXPANE);
move (lines, SidebarWidth - delim_len);
if (option (OPTASCIICHARS))
addstr (NONULL (SidebarDelim));
- else if (!option (OPTASCIICHARS) && !mutt_strcmp (SidebarDelim, "|"))
+ else if (!option (OPTASCIICHARS) && !str_cmp (SidebarDelim, "|"))
addch (ACS_VLINE);
- else if ((Charset_is_utf8) && !mutt_strcmp (SidebarDelim, "|"))
+ else if ((Charset_is_utf8) && !str_cmp (SidebarDelim, "|"))
addstr ("\342\224\202");
else
addstr (NONULL (SidebarDelim));
if (!mailbox && !query)
return (NULL);
- addr_len = mailbox ? mutt_strlen (mailbox) : 0;
- query_len = query ? mutt_strlen (query) : 0;
+ addr_len = mailbox ? str_len (mailbox) : 0;
+ query_len = query ? str_len (query) : 0;
*key = '\0';
}
while (fgets (buf, sizeof (buf) - 1, fp) != NULL)
- if (mailbox && !(safe_strncasecmp (mailbox, buf, addr_len))) {
+ if (mailbox && !(str_ncasecmp (mailbox, buf, addr_len))) {
numFields = sscanf (buf,
MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " "
MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " "
/* query = label: return certificate. */
if (numFields >= 3 &&
- !(safe_strncasecmp (query, fields[2], query_len))) {
+ !(str_ncasecmp (query, fields[2], query_len))) {
ask = 0;
strfcpy (key, fields[1], sizeof (key));
}
/* query = certificate: return intermediate certificate. */
else if (numFields >= 4 &&
- !(safe_strncasecmp (query, fields[1], query_len))) {
+ !(str_ncasecmp (query, fields[1], query_len))) {
ask = 0;
strfcpy (key, fields[3], sizeof (key));
}
}
- /* Note: safe_strdup ("") returns NULL. */
- return safe_strdup (key);
+ /* Note: str_dup ("") returns NULL. */
+ return str_dup (key);
}
if (k) {
/* the key used last time. */
if (*SmimeKeyToUse &&
- !safe_strcasecmp (k, SmimeKeyToUse + mutt_strlen (SmimeKeys) + 1)) {
+ !str_casecmp (k, SmimeKeyToUse + str_len (SmimeKeys) + 1)) {
FREE (&k);
return;
}
snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
NONULL (SmimeCertificates), k);
- if (safe_strcasecmp (k, SmimeDefaultKey))
+ if (str_casecmp (k, SmimeDefaultKey))
smime_void_passphrase ();
FREE (&k);
}
if (*SmimeKeyToUse) {
- if (!safe_strcasecmp (SmimeDefaultKey,
- SmimeKeyToUse + mutt_strlen (SmimeKeys) + 1))
+ if (!str_casecmp (SmimeDefaultKey,
+ SmimeKeyToUse + str_len (SmimeKeys) + 1))
return;
smime_void_passphrase ();
return NULL;
}
- keylist_size += mutt_strlen (keyID) + 2;
+ keylist_size += str_len (keyID) + 2;
safe_realloc (&keylist, keylist_size);
sprintf (keylist + keylist_used, "%s\n", keyID); /* __SPRINTF_CHECKED__ */
- keylist_used = mutt_strlen (keylist);
+ keylist_used = str_len (keylist);
rfc822_free_address (&addr);
while ((fgets (email, sizeof (email), fpout))) {
- *(email + mutt_strlen (email) - 1) = '\0';
- if (safe_strncasecmp (email, mailbox, mutt_strlen (mailbox)) == 0)
+ *(email + str_len (email) - 1) = '\0';
+ if (str_ncasecmp (email, mailbox, str_len (mailbox)) == 0)
ret = 1;
ret = ret < 0 ? 0 : ret;
rewind (fpout);
while ((fgets (email, sizeof (email), fpout))) {
- *(email + mutt_strlen (email) - 1) = '\0';
- (*buffer)[count] = safe_calloc (1, mutt_strlen (email) + 1);
- strncpy ((*buffer)[count], email, mutt_strlen (email));
+ *(email + str_len (email) - 1) = '\0';
+ (*buffer)[count] = safe_calloc (1, str_len (email) + 1);
+ strncpy ((*buffer)[count], email, str_len (email));
count++;
}
}
fclose (fpout);
fclose (fperr);
- return safe_strdup (certfile);
+ return str_dup (certfile);
}
static char *smime_extract_signer_certificate (char *infile)
fclose (fpout);
fclose (fperr);
- return safe_strdup (certfile);
+ return str_dup (certfile);
}
*certfile = '\0';
while (1) {
- int off = mutt_strlen (certfile);
+ int off = str_len (certfile);
while (*++cert_end && *cert_end != '\n');
if (!*cert_end)
t = mutt_new_body ();
t->type = TYPEAPPLICATION;
- t->subtype = safe_strdup ("x-pkcs7-mime");
+ t->subtype = str_dup ("x-pkcs7-mime");
mutt_set_parameter ("name", "smime.p7m", &t->parameter);
mutt_set_parameter ("smime-type", "enveloped-data", &t->parameter);
t->encoding = ENCBASE64; /* The output of OpenSSL SHOULD be binary */
t->use_disp = 1;
t->disposition = DISPATTACH;
- t->d_filename = safe_strdup ("smime.p7m");
- t->filename = safe_strdup (tempfile);
+ t->d_filename = str_dup ("smime.p7m");
+ t->filename = str_dup (tempfile);
t->unlink = 1; /*delete after sending the message */
t->parts = 0;
t->next = 0;
t = mutt_new_body ();
t->type = TYPEMULTIPART;
- t->subtype = safe_strdup ("signed");
+ t->subtype = str_dup ("signed");
t->encoding = ENC7BIT;
t->use_disp = 0;
t->disposition = DISPINLINE;
t->parts->next = mutt_new_body ();
t = t->parts->next;
t->type = TYPEAPPLICATION;
- t->subtype = safe_strdup ("x-pkcs7-signature");
- t->filename = safe_strdup (signedfile);
- t->d_filename = safe_strdup ("smime.p7s");
+ t->subtype = str_dup ("x-pkcs7-signature");
+ t->filename = str_dup (signedfile);
+ t->d_filename = str_dup ("smime.p7s");
t->use_disp = 1;
t->disposition = DISPATTACH;
t->encoding = ENCBASE64;
rewind (smimeerr);
line = mutt_read_line (line, &linelen, smimeerr, &lineno);
- if (linelen && !safe_strcasecmp (line, "verification successful"))
+ if (linelen && !str_casecmp (line, "verification successful"))
badsig = 0;
FREE (&line);
}
}
while (fgets (buf, sizeof (buf) - 1, smimeout) != NULL) {
- len = mutt_strlen (buf);
+ len = str_len (buf);
if (len > 1 && buf[len - 2] == '\r') {
buf[len - 2] = '\n';
buf[len - 1] = '\0';
rewind (smimeerr);
line = mutt_read_line (line, &linelen, smimeerr, &lineno);
- if (linelen && !safe_strcasecmp (line, "verification successful"))
+ if (linelen && !str_casecmp (line, "verification successful"))
m->goodsig = 1;
FREE (&line);
}
case 4: /* sign (a)s */
if ((p = smime_ask_for_key (_("Sign as: "), NULL, 0))) {
- p[mutt_strlen (p) - 1] = '\0';
+ p[str_len (p) - 1] = '\0';
str_replace (&SmimeDefaultKey, p);
msg->security |= SIGN;
value = "<NULL>";
}
- for (strln = 0; value[strln]; ++strln); /* mutt_strlen */
+ for (strln = 0; value[strln]; ++strln); /* str_len */
padlen = min - strln;
if (padlen < 0)
padlen = 0;
{
str[0] = 0;
dopr (str, count, fmt, args);
- return (mutt_strlen (str));
+ return (str_len (str));
}
#endif /* !HAVE_VSNPRINTF */
(void) vsnprintf (str, count, fmt, ap);
VA_END;
- return (mutt_strlen (str));
+ return (str_len (str));
}
#ifdef TEST_SNPRINTF
for (y = 0; fp_nums[y] != 0; y++) {
snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]);
sprintf (buf2, fp_fmt[x], fp_nums[y]);
- if (mutt_strcmp (buf1, buf2)) {
+ if (str_cmp (buf1, buf2)) {
printf ("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", /* __SPRINTF_CHECKED__ */
fp_fmt[x], buf1, buf2);
fail++;
for (y = 0; int_nums[y] != 0; y++) {
snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]);
sprintf (buf2, int_fmt[x], int_nums[y]);
- if (mutt_strcmp (buf1, buf2)) {
+ if (str_cmp (buf1, buf2)) {
printf ("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", /* __SPRINTF_CHECKED__ */
int_fmt[x], buf1, buf2);
fail++;
else if (!(*pb)->env->real_subj)
rc = 1;
else
- rc = safe_strcasecmp ((*pa)->env->real_subj, (*pb)->env->real_subj);
+ rc = str_casecmp ((*pa)->env->real_subj, (*pb)->env->real_subj);
AUXSORT (rc, a, b);
return (SORTCODE (rc));
}
strncpy (fb, mutt_get_name ((*ppb)->env->to), sizeof (fb));
fb[sizeof (fb) - 1] = '\0';
- result = safe_strcasecmp (fa, fb);
+ result = str_casecmp (fa, fb);
AUXSORT (result, a, b);
return (SORTCODE (result));
}
strncpy (fb, mutt_get_name ((*ppb)->env->from), sizeof (fb));
fb[sizeof (fb) - 1] = '\0';
- result = safe_strcasecmp (fa, fb);
+ result = str_casecmp (fa, fb);
AUXSORT (result, a, b);
return (SORTCODE (result));
}
/* If either aptr or bptr is equal to data, there is no numeric */
/* value for that spam attribute. In this case, compare lexically. */
if ((aptr == (*ppa)->env->spam->data) || (bptr == (*ppb)->env->spam->data))
- return (SORTCODE (mutt_strcmp (aptr, bptr)));
+ return (SORTCODE (str_cmp (aptr, bptr)));
/* Otherwise, we have numeric value for both attrs. If these values */
/* are equal, then we first fall back upon string comparison, then */
/* upon auxiliary sort. */
if (result == 0) {
- result = mutt_strcmp (aptr, bptr);
+ result = str_cmp (aptr, bptr);
if (result == 0)
AUXSORT (result, a, b);
}
if (!StChars)
buf[0] = 0;
- else if (i >= mutt_strlen (StChars))
+ else if (i >= str_len (StChars))
buf[0] = StChars[0];
else
buf[0] = StChars[i];
if (s == NULL)
return NULL;
- if ((d = malloc (mutt_strlen (s) + 1)) == NULL) /* __MEM_CHECKED__ */
+ if ((d = malloc (str_len (s) + 1)) == NULL) /* __MEM_CHECKED__ */
return NULL;
- memcpy (d, s, mutt_strlen (s) + 1);
+ memcpy (d, s, str_len (s) + 1);
return d;
}
((env->real_subj != env->subject) || (!option (OPTSORTRE)))) {
for (curlist = subjects, oldlist = NULL;
curlist; oldlist = curlist, curlist = curlist->next) {
- rc = mutt_strcmp (env->real_subj, curlist->data);
+ rc = str_cmp (env->real_subj, curlist->data);
if (rc >= 0)
break;
}
(last->message->received < tmp->message->received) :
(last->message->date_sent < tmp->message->date_sent))) &&
tmp->message->env->real_subj &&
- mutt_strcmp (subjects->data, tmp->message->env->real_subj) == 0)
+ str_cmp (subjects->data, tmp->message->env->real_subj) == 0)
last = tmp; /* best match so far */
}
* parent, since otherwise they rightly belong to the message
* we're attaching. */
if (tmp == cur
- || !mutt_strcmp (tmp->message->env->real_subj,
+ || !str_cmp (tmp->message->env->real_subj,
parent->message->env->real_subj)) {
tmp->message->subject_changed = 0;
if (!tmp)
cur->subject_changed = 1;
else if (cur->env->real_subj && tmp->message->env->real_subj)
- cur->subject_changed = mutt_strcmp (cur->env->real_subj,
+ cur->subject_changed = str_cmp (cur->env->real_subj,
tmp->message->env->
real_subj) ? 1 : 0;
else
if (!cur->env->references)
ref = ref->next;
else {
- if (mutt_strcmp (ref->data, cur->env->references->data))
+ if (str_cmp (ref->data, cur->env->references->data))
ref = cur->env->references;
else
ref = cur->env->references->next;
for (p = brk; !done && p; p = p->parent)
for (ref = cur->message->env->references; p->message && ref;
ref = ref->next)
- if (!safe_strcasecmp (ref->data, p->message->env->message_id)) {
+ if (!str_casecmp (ref->data, p->message->env->message_id)) {
done = 1;
break;
}
mutt_break_thread (child);
child->env->in_reply_to = mutt_new_list ();
- child->env->in_reply_to->data = safe_strdup (parent->env->message_id);
+ child->env->in_reply_to->data = str_dup (parent->env->message_id);
mutt_set_flag (ctx, child, M_TAG, 0);
snprintf (dest, len, "%s:", mutt_getnamebyvalue (ciss->scheme, UrlMap));
if (ciss->host) {
- safe_strcat (dest, len, "//");
- len -= (l = mutt_strlen (dest));
+ str_cat (dest, len, "//");
+ len -= (l = str_len (dest));
dest += l;
if (ciss->user) {
else
snprintf (dest, len, "%s@", ciss->user);
- len -= (l = mutt_strlen (dest));
+ len -= (l = str_len (dest));
dest += l;
}
}
if (ciss->path)
- safe_strcat (dest, len, ciss->path);
+ str_cat (dest, len, ciss->path);
return 0;
}
if (!(t = strchr (src, ':')))
return -1;
- if ((tmp = safe_strdup (t + 1)) == NULL)
+ if ((tmp = str_dup (t + 1)) == NULL)
return -1;
if ((headers = strchr (tmp, '?')))
}
else {
#define SAFEPFX (option (OPTSTRICTMAILTO) ? "" : "X-Mailto-")
- taglen = mutt_strlen (tag) + mutt_strlen (SAFEPFX);
+ taglen = str_len (tag) + str_len (SAFEPFX);
/* mutt_parse_rfc822_line makes some assumptions */
snprintf (scratch, sizeof (scratch), "%s%s: %s", SAFEPFX, tag, value);
#undef SAVEPFX