projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add more encoding arrays
[apps/madmutt.git]
/
crypt-gpgme.c
diff --git
a/crypt-gpgme.c
b/crypt-gpgme.c
index
af921cd
..
dfd2645
100644
(file)
--- a/
crypt-gpgme.c
+++ b/
crypt-gpgme.c
@@
-20,16
+20,18
@@
#include <lib-lib/mem.h>
#include <lib-lib/str.h>
#include <lib-lib/mem.h>
#include <lib-lib/str.h>
+#include <lib-lib/ascii.h>
#include <lib-lib/macros.h>
#include <lib-lib/macros.h>
+#include <lib-lib/file.h>
+
+#include <lib-mime/mime.h>
#include "mutt.h"
#include "mutt_crypt.h"
#include "mutt_menu.h"
#include "mutt_curses.h"
#include "mutt.h"
#include "mutt_crypt.h"
#include "mutt_menu.h"
#include "mutt_curses.h"
-#include "ascii.h"
#include "handler.h"
#include "enter.h"
#include "handler.h"
#include "enter.h"
-#include "mime.h"
#include "copy.h"
#include "pager.h"
#include "recvattach.h"
#include "copy.h"
#include "pager.h"
#include "recvattach.h"
@@
-298,11
+300,11
@@
static int crypt_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr,
rv |= CRYPT_KV_STRONGID;
if (addr->mailbox && u_addr->mailbox
rv |= CRYPT_KV_STRONGID;
if (addr->mailbox && u_addr->mailbox
- &&
str_casecmp
(addr->mailbox, u_addr->mailbox) == 0)
+ &&
m_strcasecmp
(addr->mailbox, u_addr->mailbox) == 0)
rv |= CRYPT_KV_ADDR;
if (addr->personal && u_addr->personal
rv |= CRYPT_KV_ADDR;
if (addr->personal && u_addr->personal
- &&
str_casecmp
(addr->personal, u_addr->personal) == 0)
+ &&
m_strcasecmp
(addr->personal, u_addr->personal) == 0)
rv |= CRYPT_KV_STRING;
return rv;
rv |= CRYPT_KV_STRING;
return rv;
@@
-686,8
+688,7
@@
static int get_micalg (gpgme_ctx_t ctx, char *buf, size_t buflen)
if (result) {
algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo);
if (algorithm_name) {
if (result) {
algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo);
if (algorithm_name) {
- strncpy (buf, algorithm_name, buflen - 1);
- buf[buflen - 1] = 0;
+ m_strcpy(buf, buflen, algorithm_name);
}
}
}
}
@@
-1006,7
+1007,7
@@
static int show_sig_summary (unsigned long sum,
state_attach_puts (": ", s);
if (t0)
state_attach_puts (t0, s);
state_attach_puts (": ", s);
if (t0)
state_attach_puts (t0, s);
- if (t1 && !(t0 && !
str_cmp
(t0, t1))) {
+ if (t1 && !(t0 && !
m_strcmp
(t0, t1))) {
if (t0)
state_attach_puts (",", s);
state_attach_puts (t1, s);
if (t0)
state_attach_puts (",", s);
state_attach_puts (t1, s);
@@
-1488,7
+1489,7
@@
int pgp_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur)
b = b->parts->next;
b = b->parts->next;
-
memset (&s, 0, sizeof (s)
);
+
p_clear(&s, 1
);
s.fpin = fpin;
mutt_mktemp (tempfile);
if (!(*fpout = safe_fopen (tempfile, "w+"))) {
s.fpin = fpin;
mutt_mktemp (tempfile);
if (!(*fpout = safe_fopen (tempfile, "w+"))) {
@@
-1532,7
+1533,7
@@
int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b,
saved_b_type = b->type;
saved_b_offset = b->offset;
saved_b_length = b->length;
saved_b_type = b->type;
saved_b_offset = b->offset;
saved_b_length = b->length;
-
memset (&s, 0, sizeof (s)
);
+
p_clear(&s, 1
);
s.fpin = fpin;
fseeko (s.fpin, b->offset, 0);
mutt_mktemp (tempfile);
s.fpin = fpin;
fseeko (s.fpin, b->offset, 0);
mutt_mktemp (tempfile);
@@
-1549,7
+1550,7
@@
int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b,
b->offset = 0;
rewind (tmpfp);
b->offset = 0;
rewind (tmpfp);
-
memset (&s, 0, sizeof (s)
);
+
p_clear(&s, 1
);
s.fpin = tmpfp;
s.fpout = 0;
mutt_mktemp (tempfile);
s.fpin = tmpfp;
s.fpout = 0;
mutt_mktemp (tempfile);
@@
-1584,7
+1585,7
@@
int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b,
saved_b_type = bb->type;
saved_b_offset = bb->offset;
saved_b_length = bb->length;
saved_b_type = bb->type;
saved_b_offset = bb->offset;
saved_b_length = bb->length;
-
memset (&s, 0, sizeof (s)
);
+
p_clear(&s, 1
);
s.fpin = *fpout;
fseeko (s.fpin, bb->offset, 0);
mutt_mktemp (tempfile);
s.fpin = *fpout;
fseeko (s.fpin, bb->offset, 0);
mutt_mktemp (tempfile);
@@
-1602,7
+1603,7
@@
int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b,
rewind (tmpfp);
fclose (*fpout);
rewind (tmpfp);
fclose (*fpout);
-
memset (&s, 0, sizeof (s)
);
+
p_clear(&s, 1
);
s.fpin = tmpfp;
s.fpout = 0;
mutt_mktemp (tempfile);
s.fpin = tmpfp;
s.fpout = 0;
mutt_mktemp (tempfile);
@@
-1659,10
+1660,10
@@
static int pgp_check_traditional_one_body (FILE * fp, BODY * b,
}
while (fgets (buf, sizeof (buf), tfp)) {
}
while (fgets (buf, sizeof (buf), tfp)) {
- if (!
str_ncmp
("-----BEGIN PGP ", buf, 15)) {
- if (!
str_cmp
("MESSAGE-----\n", buf + 15))
+ if (!
m_strncmp
("-----BEGIN PGP ", buf, 15)) {
+ if (!
m_strcmp
("MESSAGE-----\n", buf + 15))
enc = 1;
enc = 1;
- else if (!
str_cmp
("SIGNED MESSAGE-----\n", buf + 15))
+ else if (!
m_strcmp
("SIGNED MESSAGE-----\n", buf + 15))
sgn = 1;
}
}
sgn = 1;
}
}
@@
-1741,7
+1742,7
@@
static void copy_clearsigned (gpgme_data_t data, STATE * s, char *charset)
continue;
}
continue;
}
- if (!
str_cmp
(buf, "-----BEGIN PGP SIGNATURE-----\n"))
+ if (!
m_strcmp
(buf, "-----BEGIN PGP SIGNATURE-----\n"))
break;
if (armor_header) {
break;
if (armor_header) {
@@
-1789,7
+1790,7
@@
int pgp_gpgme_application_handler (BODY * m, STATE * s)
but we know that this may only be text thus we assume Latin-1
here. */
if (!mutt_get_body_charset (body_charset, sizeof (body_charset), m))
but we know that this may only be text thus we assume Latin-1
here. */
if (!mutt_get_body_charset (body_charset, sizeof (body_charset), m))
-
strfcpy (body_charset, "iso-8859-1", sizeof body_charset
);
+
m_strcpy(body_charset, sizeof(body_charset), "iso-8859-1"
);
fseeko (s->fpin, m->offset, 0);
last_pos = m->offset;
fseeko (s->fpin, m->offset, 0);
last_pos = m->offset;
@@
-1802,18
+1803,18
@@
int pgp_gpgme_application_handler (BODY * m, STATE * s)
bytes -= (offset - last_pos); /* don't rely on m_strlen(buf) */
last_pos = offset;
bytes -= (offset - last_pos); /* don't rely on m_strlen(buf) */
last_pos = offset;
- if (!
str_ncmp
("-----BEGIN PGP ", buf, 15)) {
+ if (!
m_strncmp
("-----BEGIN PGP ", buf, 15)) {
clearsign = 0;
start_pos = last_pos;
clearsign = 0;
start_pos = last_pos;
- if (!
str_cmp
("MESSAGE-----\n", buf + 15))
+ if (!
m_strcmp
("MESSAGE-----\n", buf + 15))
needpass = 1;
needpass = 1;
- else if (!
str_cmp
("SIGNED MESSAGE-----\n", buf + 15)) {
+ else if (!
m_strcmp
("SIGNED MESSAGE-----\n", buf + 15)) {
clearsign = 1;
needpass = 0;
}
else if (!option (OPTDONTHANDLEPGPKEYS) &&
clearsign = 1;
needpass = 0;
}
else if (!option (OPTDONTHANDLEPGPKEYS) &&
- !
str_cmp
("PUBLIC KEY BLOCK-----\n", buf + 15)) {
+ !
m_strcmp
("PUBLIC KEY BLOCK-----\n", buf + 15)) {
needpass = 0;
pgp_keyblock = 1;
}
needpass = 0;
pgp_keyblock = 1;
}
@@
-1837,10
+1838,10
@@
int pgp_gpgme_application_handler (BODY * m, STATE * s)
gpgme_data_write (armored_data, buf, m_strlen(buf));
gpgme_data_write (armored_data, buf, m_strlen(buf));
- if ((needpass && !
str_cmp
("-----END PGP MESSAGE-----\n", buf))
+ if ((needpass && !
m_strcmp
("-----END PGP MESSAGE-----\n", buf))
|| (!needpass
|| (!needpass
- && (!
str_cmp
("-----END PGP SIGNATURE-----\n", buf)
- || !
str_cmp
("-----END PGP PUBLIC KEY BLOCK-----\n",
+ && (!
m_strcmp
("-----END PGP SIGNATURE-----\n", buf)
+ || !
m_strcmp
("-----END PGP PUBLIC KEY BLOCK-----\n",
buf))))
break;
}
buf))))
break;
}
@@
-2370,10
+2371,10
@@
static int _crypt_compare_address (const void *a, const void *b)
crypt_key_t **t = (crypt_key_t **) b;
int r;
crypt_key_t **t = (crypt_key_t **) b;
int r;
- if ((r =
str_casecmp
((*s)->uid, (*t)->uid)))
+ if ((r =
m_strcasecmp
((*s)->uid, (*t)->uid)))
return r > 0;
else
return r > 0;
else
- return
str_casecmp
(crypt_keyid (*s), crypt_keyid (*t)) > 0;
+ return
m_strcasecmp
(crypt_keyid (*s), crypt_keyid (*t)) > 0;
}
static int crypt_compare_address (const void *a, const void *b)
}
static int crypt_compare_address (const void *a, const void *b)
@@
-2390,10
+2391,10
@@
static int _crypt_compare_keyid (const void *a, const void *b)
crypt_key_t **t = (crypt_key_t **) b;
int r;
crypt_key_t **t = (crypt_key_t **) b;
int r;
- if ((r =
str_casecmp
(crypt_keyid (*s), crypt_keyid (*t))))
+ if ((r =
m_strcasecmp
(crypt_keyid (*s), crypt_keyid (*t))))
return r > 0;
else
return r > 0;
else
- return
str_casecmp
((*s)->uid, (*t)->uid) > 0;
+ return
m_strcasecmp
((*s)->uid, (*t)->uid) > 0;
}
static int crypt_compare_keyid (const void *a, const void *b)
}
static int crypt_compare_keyid (const void *a, const void *b)
@@
-2419,7
+2420,7
@@
static int _crypt_compare_date (const void *a, const void *b)
if (ts < tt)
return 0;
if (ts < tt)
return 0;
- return
str_casecmp
((*s)->uid, (*t)->uid) > 0;
+ return
m_strcasecmp
((*s)->uid, (*t)->uid) > 0;
}
static int crypt_compare_date (const void *a, const void *b)
}
static int crypt_compare_date (const void *a, const void *b)
@@
-2464,9
+2465,9
@@
static int _crypt_compare_trust (const void *a, const void *b)
if (ts < tt)
return 0;
if (ts < tt)
return 0;
- if ((r =
str_casecmp
((*s)->uid, (*t)->uid)))
+ if ((r =
m_strcasecmp
((*s)->uid, (*t)->uid)))
return r > 0;
return r > 0;
- return (
str_casecmp
(crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0;
+ return (
m_strcasecmp
(crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0;
}
static int crypt_compare_trust (const void *a, const void *b)
}
static int crypt_compare_trust (const void *a, const void *b)
@@
-2482,7
+2483,7
@@
static int print_dn_part (FILE * fp, struct dn_array_s *dn, const char *key)
int any = 0;
for (; dn->key; dn++) {
int any = 0;
for (; dn->key; dn++) {
- if (!
str_cmp
(dn->key, key)) {
+ if (!
m_strcmp
(dn->key, key)) {
if (any)
fputs (" + ", fp);
print_utf8 (fp, dn->value, m_strlen(dn->value));
if (any)
fputs (" + ", fp);
print_utf8 (fp, dn->value, m_strlen(dn->value));
@@
-2508,7
+2509,7
@@
static void print_dn_parts (FILE * fp, struct dn_array_s *dn)
/* now print the rest without any specific ordering */
for (; dn->key; dn++) {
for (i = 0; stdpart[i]; i++) {
/* now print the rest without any specific ordering */
for (; dn->key; dn++) {
for (i = 0; stdpart[i]; i++) {
- if (!
str_cmp
(dn->key, stdpart[i]))
+ if (!
m_strcmp
(dn->key, stdpart[i]))
break;
}
if (!stdpart[i]) {
break;
}
if (!stdpart[i]) {
@@
-2981,7
+2982,7
@@
static void verify_key (crypt_key_t * key)
k = key->kobj;
gpgme_key_ref (k);
k = key->kobj;
gpgme_key_ref (k);
- while ((s = k->chain_id) && k->subkeys &&
str_cmp
(s, k->subkeys->fpr)) {
+ while ((s = k->chain_id) && k->subkeys &&
m_strcmp
(s, k->subkeys->fpr)) {
putc ('\n', fp);
err = gpgme_op_keylist_start (listctx, s, 0);
gpgme_key_release (k);
putc ('\n', fp);
err = gpgme_op_keylist_start (listctx, s, 0);
gpgme_key_release (k);
@@
-3221,7
+3222,7
@@
static LIST *crypt_add_string_to_hints (LIST * hints, const char *str)
for (t = strtok (scratch, " ,.:\"()<>\n"); t;
t = strtok (NULL, " ,.:\"()<>\n")) {
if (m_strlen(t) > 3)
for (t = strtok (scratch, " ,.:\"()<>\n"); t;
t = strtok (NULL, " ,.:\"()<>\n")) {
if (m_strlen(t) > 3)
- hints = mutt_add_list
(hints, t);
+ hints = mutt_add_list(hints, t);
}
p_delete(&scratch);
}
p_delete(&scratch);
@@
-3569,12
+3570,12
@@
static crypt_key_t *crypt_getkeybystr (char *p, short abilities,
match = 0;
debug_print (5, ("matching \"%s\" against " "key %s, \"%s\":\n", p, crypt_keyid (k), k->uid));
match = 0;
debug_print (5, ("matching \"%s\" against " "key %s, \"%s\":\n", p, crypt_keyid (k), k->uid));
- if (!*p || !
str_casecmp
(p, crypt_keyid (k))
- || (!
str_ncasecmp
(p, "0x", 2)
- && !
str_casecmp
(p + 2, crypt_keyid (k)))
+ if (!*p || !
m_strcasecmp
(p, crypt_keyid (k))
+ || (!
m_strncasecmp
(p, "0x", 2)
+ && !
m_strcasecmp
(p + 2, crypt_keyid (k)))
|| (option (OPTPGPLONGIDS)
|| (option (OPTPGPLONGIDS)
- && !
str_ncasecmp
(p, "0x", 2)
- && !
str_casecmp
(p + 2, crypt_keyid (k) + 8))
+ && !
m_strncasecmp
(p, "0x", 2)
+ && !
m_strcasecmp
(p + 2, crypt_keyid (k) + 8))
|| str_isstr (k->uid, p)) {
crypt_key_t *tmp;
|| str_isstr (k->uid, p)) {
crypt_key_t *tmp;
@@
-3621,8
+3622,8
@@
static crypt_key_t *crypt_ask_for_key (char *tag,
if (whatfor) {
for (l = id_defaults; l; l = l->next)
if (whatfor) {
for (l = id_defaults; l; l = l->next)
- if (!
str_casecmp
(whatfor, l->what)) {
-
strfcpy (resp, NONULL (l->dflt), sizeof (resp
));
+ if (!
m_strcasecmp
(whatfor, l->what)) {
+
m_strcpy(resp, sizeof(resp), NONULL(l->dflt
));
break;
}
}
break;
}
}