#include "pager.h"
#include "sort.h"
+#include "lib/mem.h"
+#include "lib/intl.h"
+#include "lib/str.h"
+#include "lib/debug.h"
+
#include <sys/wait.h>
#include <string.h>
#include <stdlib.h>
* General helper functions.
*/
-/* return true when S pints to a didgit or letter. */
+/* return true when S points to a didgit or letter. */
static int digit_or_letter (const unsigned char *s)
{
- return ((*s >= '0' && *s < '9')
+ return ((*s >= '0' && *s <= '9')
|| (*s >= 'A' && *s <= 'Z')
|| (*s >= 'a' && *s <= 'z'));
}
rv |= CRYPT_KV_STRONGID;
if (addr->mailbox && u_addr->mailbox
- && mutt_strcasecmp (addr->mailbox, u_addr->mailbox) == 0)
+ && safe_strcasecmp (addr->mailbox, u_addr->mailbox) == 0)
rv |= CRYPT_KV_ADDR;
if (addr->personal && u_addr->personal
- && mutt_strcasecmp (addr->personal, u_addr->personal) == 0)
+ && safe_strcasecmp (addr->personal, u_addr->personal) == 0)
rv |= CRYPT_KV_STRING;
return rv;
state_attach_puts (": ", s);
if (t0)
state_attach_puts (t0, s);
- if (t1 && !(t0 && !strcmp (t0, t1))) {
+ if (t1 && !(t0 && !mutt_strcmp (t0, t1))) {
if (t0)
state_attach_puts (",", s);
state_attach_puts (t1, s);
gpgme_release (ctx);
state_attach_puts (_("[-- End signature information --]\n\n"), s);
- dprint (1, (debugfile, "verify_one: returning %d.\n", badsig));
+ debug_print (1, ("returning %d.\n", badsig));
return badsig ? 1 : anywarn ? 2 : 0;
}
}
while (fgets (buf, sizeof (buf), tfp)) {
- if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15)) {
+ if (!safe_strncmp ("-----BEGIN PGP ", buf, 15)) {
if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
enc = 1;
else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
char body_charset[STRING]; /* Only used for clearsigned messages. */
- dprint (2, (debugfile, "Entering pgp_application_pgp handler\n"));
+ debug_print (2, ("Entering pgp_application_pgp handler\n"));
/* For clearsigned messages we won't be able to get a character set
but we know that this may only be text thus we assume Latin-1
bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
last_pos = offset;
- if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15)) {
+ if (!safe_strncmp ("-----BEGIN PGP ", buf, 15)) {
clearsign = 0;
start_pos = last_pos;
" of PGP message! --]\n\n"), s);
return;
}
- dprint (2, (debugfile, "Leaving pgp_application_pgp handler\n"));
+ debug_print (2, ("Leaving pgp_application_pgp handler\n"));
}
/*
BODY *orig_body = a;
int is_signed;
- dprint (2, (debugfile, "Entering pgp_encrypted handler\n"));
+ debug_print (2, ("Entering pgp_encrypted handler\n"));
a = a->parts;
if (!a || a->type != TYPEAPPLICATION || !a->subtype
|| ascii_strcasecmp ("pgp-encrypted", a->subtype)
fclose (fpout);
mutt_unlink (tempfile);
- dprint (2, (debugfile, "Leaving pgp_encrypted handler\n"));
+ debug_print (2, ("Leaving pgp_encrypted handler\n"));
}
/* Support for application/smime */
int is_signed;
- dprint (2, (debugfile, "Entering smime_encrypted handler\n"));
+ debug_print (2, ("Entering smime_encrypted handler\n"));
a->warnsig = 0;
mutt_mktemp (tempfile);
fclose (fpout);
mutt_unlink (tempfile);
- dprint (2, (debugfile, "Leaving smime_encrypted handler\n"));
+ debug_print (2, ("Leaving smime_encrypted handler\n"));
}
crypt_key_t **t = (crypt_key_t **) b;
int r;
- if ((r = mutt_strcasecmp ((*s)->uid, (*t)->uid)))
+ if ((r = safe_strcasecmp ((*s)->uid, (*t)->uid)))
return r > 0;
else
- return mutt_strcasecmp (crypt_keyid (*s), crypt_keyid (*t)) > 0;
+ return safe_strcasecmp (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 = mutt_strcasecmp (crypt_keyid (*s), crypt_keyid (*t))))
+ if ((r = safe_strcasecmp (crypt_keyid (*s), crypt_keyid (*t))))
return r > 0;
else
- return mutt_strcasecmp ((*s)->uid, (*t)->uid) > 0;
+ return safe_strcasecmp ((*s)->uid, (*t)->uid) > 0;
}
static int crypt_compare_keyid (const void *a, const void *b)
if (ts < tt)
return 0;
- return mutt_strcasecmp ((*s)->uid, (*t)->uid) > 0;
+ return safe_strcasecmp ((*s)->uid, (*t)->uid) > 0;
}
static int crypt_compare_date (const void *a, const void *b)
if (ts < tt)
return 0;
- if ((r = mutt_strcasecmp ((*s)->uid, (*t)->uid)))
+ if ((r = safe_strcasecmp ((*s)->uid, (*t)->uid)))
return r > 0;
- return (mutt_strcasecmp (crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0;
+ return (safe_strcasecmp (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 (!strcmp (dn->key, key)) {
+ if (!mutt_strcmp (dn->key, key)) {
if (any)
fputs (" + ", fp);
print_utf8 (fp, dn->value, mutt_strlen (dn->value));
/* now print the rest without any specific ordering */
for (; dn->key; dn++) {
for (i = 0; stdpart[i]; i++) {
- if (!strcmp (dn->key, stdpart[i]))
+ if (!mutt_strcmp (dn->key, stdpart[i]))
break;
}
if (!stdpart[i]) {
mutt_mktemp (tempfile);
if (!(fp = safe_fopen (tempfile, "w"))) {
- mutt_perror _("Can't create temporary file");
+ mutt_perror (_("Can't create temporary file"));
return;
}
k = key->kobj;
gpgme_key_ref (k);
- while ((s = k->chain_id) && k->subkeys && strcmp (s, k->subkeys->fpr)) {
+ while ((s = k->chain_id) && k->subkeys && mutt_strcmp (s, k->subkeys->fpr)) {
putc ('\n', fp);
err = gpgme_op_keylist_start (listctx, s, 0);
gpgme_key_release (k);
if (!keys)
return NULL;
- dprint (5, (debugfile, "crypt_getkeybyaddr: looking for %s <%s>.",
- a->personal, a->mailbox));
+ debug_print (5, ("looking for %s <%s>.\n", a->personal, a->mailbox));
for (k = keys; k; k = k->next) {
- dprint (5, (debugfile, " looking at key: %s `%.15s'\n",
- crypt_keyid (k), k->uid));
+ debug_print (5, (" looking at key: %s `%.15s'\n", crypt_keyid (k), k->uid));
if (abilities && !(k->flags & abilities)) {
- dprint (5, (debugfile, " insufficient abilities: Has %x, want %x\n",
- k->flags, abilities));
+ debug_print (5, (" insufficient abilities: Has %x, want %x\n", k->flags, abilities));
continue;
}
continue;
match = 0;
- dprint (5, (debugfile, "crypt_getkeybystr: matching \"%s\" against "
- "key %s, \"%s\": ", p, crypt_keyid (k), k->uid));
+ debug_print (5, ("matching \"%s\" against " "key %s, \"%s\":\n", p, crypt_keyid (k), k->uid));
- if (!*p || !mutt_strcasecmp (p, crypt_keyid (k))
- || (!mutt_strncasecmp (p, "0x", 2)
- && !mutt_strcasecmp (p + 2, crypt_keyid (k)))
+ if (!*p || !safe_strcasecmp (p, crypt_keyid (k))
+ || (!safe_strncasecmp (p, "0x", 2)
+ && !safe_strcasecmp (p + 2, crypt_keyid (k)))
|| (option (OPTPGPLONGIDS)
- && !mutt_strncasecmp (p, "0x", 2)
- && !mutt_strcasecmp (p + 2, crypt_keyid (k) + 8))
- || mutt_stristr (k->uid, p)) {
+ && !safe_strncasecmp (p, "0x", 2)
+ && !safe_strcasecmp (p + 2, crypt_keyid (k) + 8))
+ || str_isstr (k->uid, p)) {
crypt_key_t *tmp;
- dprint (5, (debugfile, "match.\n"));
+ debug_print (5, ("match.\n"));
*matches_endp = tmp = crypt_copy_key (k);
matches_endp = &tmp->next;
if (whatfor) {
for (l = id_defaults; l; l = l->next)
- if (!mutt_strcasecmp (whatfor, l->what)) {
+ if (!safe_strcasecmp (whatfor, l->what)) {
strfcpy (resp, NONULL (l->dflt), sizeof (resp));
break;
}
if (whatfor) {
if (l)
- mutt_str_replace (&l->dflt, resp);
+ str_replace (&l->dflt, resp);
else {
l = safe_malloc (sizeof (struct crypt_cache));
l->next = id_defaults;
is_smime ? APPLICATION_SMIME :
APPLICATION_PGP, NULL))) {
snprintf (input_signas, sizeof (input_signas), "0x%s", crypt_keyid (p));
- mutt_str_replace (is_smime ? &SmimeDefaultKey : &PgpSignAs,
+ str_replace (is_smime ? &SmimeDefaultKey : &PgpSignAs,
input_signas);
crypt_free_key (&p);