*/
struct Group *mutt_pattern_group(const char *pat)
{
- struct Group *g = NULL;
-
if (!pat)
return 0;
- g = mutt_hash_find(Groups, pat);
+ struct Group *g = mutt_hash_find(Groups, pat);
if (!g)
{
mutt_debug(LL_DEBUG2, "Creating group %s\n", pat);
*/
static int group_remove_addrlist(struct Group *g, struct Address *a)
{
- struct Address *p = NULL;
-
- if (!g)
- return -1;
- if (!a)
+ if (!g || !a)
return -1;
- for (p = a; p; p = p->next)
+ for (struct Address *p = a; p; p = p->next)
mutt_addr_remove_from_list(&g->as, p->mailbox);
return 0;
*/
void mutt_alias_add_reverse(struct Alias *t)
{
- struct Address *ap = NULL;
if (!t)
return;
* by all callers, but added here mostly as documentation. */
mutt_addrlist_to_intl(t->addr, NULL);
- for (ap = t->addr; ap; ap = ap->next)
+ for (struct Address *ap = t->addr; ap; ap = ap->next)
{
if (!ap->group && ap->mailbox)
mutt_hash_insert(ReverseAliases, ap->mailbox, ap);
*/
void mutt_alias_delete_reverse(struct Alias *t)
{
- struct Address *ap = NULL;
if (!t)
return;
* match the hash entries. */
mutt_addrlist_to_intl(t->addr, NULL);
- for (ap = t->addr; ap; ap = ap->next)
+ for (struct Address *ap = t->addr; ap; ap = ap->next)
{
if (!ap->group && ap->mailbox)
mutt_hash_delete(ReverseAliases, ap->mailbox, ap);
*/
bool mutt_addr_is_user(struct Address *addr)
{
- const char *fqdn = NULL;
-
/* NULL address is assumed to be the user. */
if (!addr)
{
mutt_debug(5, "#2 yes, %s = %s @ %s\n", addr->mailbox, Username, ShortHostname);
return true;
}
- fqdn = mutt_fqdn(false);
+ const char *fqdn = mutt_fqdn(false);
if (string_is_address(addr->mailbox, Username, fqdn))
{
mutt_debug(5, "#3 yes, %s = %s @ %s\n", addr->mailbox, Username, NONULL(fqdn));
*/
static int execute_command(struct Mailbox *m, const char *command, const char *progress)
{
- int rc = 1;
- char sys_cmd[STR_COMMAND];
-
if (!m || !command || !progress)
return 0;
if (!m->quiet)
- {
mutt_message(progress, m->realpath);
- }
+
+ int rc = 1;
+ char sys_cmd[STR_COMMAND];
mutt_sig_block();
endwin();
struct HashElem **list = mutt_mem_calloc(1024, sizeof(struct HashElem *));
size_t index = 0;
- struct HashWalkState walk;
- memset(&walk, 0, sizeof(walk));
-
+ struct HashWalkState walk = { 0 };
struct HashElem *he = NULL;
+
while ((he = mutt_hash_walk(cs->hash, &walk)))
{
list[index++] = he;
*/
static int mutt_sasl_cb_authname(void *context, int id, const char **result, unsigned int *len)
{
- struct ConnAccount *account = context;
-
if (!result)
return SASL_FAIL;
+ struct ConnAccount *account = context;
+
*result = NULL;
if (len)
*len = 0;
*/
static int ssl_load_certificates(SSL_CTX *ctx)
{
- FILE *fp = NULL;
- X509 *cert = NULL;
- X509_STORE *store = NULL;
int rc = 1;
- char buf[256];
mutt_debug(LL_DEBUG2, "loading trusted certificates\n");
- store = SSL_CTX_get_cert_store(ctx);
+ X509_STORE *store = SSL_CTX_get_cert_store(ctx);
if (!store)
{
store = X509_STORE_new();
SSL_CTX_set_cert_store(ctx, store);
}
- fp = fopen(C_CertificateFile, "rt");
+ FILE *fp = fopen(C_CertificateFile, "rt");
if (!fp)
return 0;
+ X509 *cert = NULL;
while (NULL != PEM_read_X509(fp, &cert, NULL, NULL))
{
if ((X509_cmp_current_time(X509_get0_notBefore(cert)) >= 0) ||
(X509_cmp_current_time(X509_get0_notAfter(cert)) <= 0))
{
+ char buf[256];
mutt_debug(LL_DEBUG2, "filtering expired cert: %s\n",
X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)));
}
*/
static int add_entropy(const char *file)
{
- struct stat st;
- int n = -1;
-
if (!file)
return 0;
+ struct stat st;
+ int n = -1;
+
if (stat(file, &st) == -1)
return (errno == ENOENT) ? 0 : -1;
*/
static void ssl_dprint_err_stack(void)
{
- BIO *bio = NULL;
- char *buf = NULL;
- long buflen;
- char *output = NULL;
-
- bio = BIO_new(BIO_s_mem());
+ BIO *bio = BIO_new(BIO_s_mem());
if (!bio)
return;
ERR_print_errors(bio);
- buflen = BIO_get_mem_data(bio, &buf);
+
+ char *buf = NULL;
+ long buflen = BIO_get_mem_data(bio, &buf);
if (buflen > 0)
{
- output = mutt_mem_malloc(buflen + 1);
+ char *output = mutt_mem_malloc(buflen + 1);
memcpy(output, buf, buflen);
output[buflen] = '\0';
mutt_debug(LL_DEBUG1, "SSL error stack: %s\n", output);
static int ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
{
char buf[256];
- const char *host = NULL;
- size_t len;
- int pos;
- X509 *cert = NULL;
- SSL *ssl = NULL;
- bool skip_mode;
- ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
+ SSL *ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
if (!ssl)
{
mutt_debug(LL_DEBUG1,
"failed to retrieve SSL structure from X509_STORE_CTX\n");
return false;
}
- host = SSL_get_ex_data(ssl, HostExDataIndex);
+ const char *host = SSL_get_ex_data(ssl, HostExDataIndex);
if (!host)
{
mutt_debug(LL_DEBUG1, "failed to retrieve hostname from SSL structure\n");
* $ssl_verify_partial_chains option.
* In this case, all following certificates need to be treated as non-verified
* until one is actually verified. */
- skip_mode = (SSL_get_ex_data(ssl, SkipModeExDataIndex));
+ bool skip_mode = (SSL_get_ex_data(ssl, SkipModeExDataIndex));
- cert = X509_STORE_CTX_get_current_cert(ctx);
- pos = X509_STORE_CTX_get_error_depth(ctx);
- len = sk_X509_num(X509_STORE_CTX_get0_chain(ctx));
+ X509 *cert = X509_STORE_CTX_get_current_cert(ctx);
+ int pos = X509_STORE_CTX_get_error_depth(ctx);
+ size_t len = sk_X509_num(X509_STORE_CTX_get0_chain(ctx));
mutt_debug(LL_DEBUG1, "checking cert chain entry %s (preverify: %d skipmode: %d)\n",
X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)),
*/
static gnutls_certificate_status_t tls_verify_peers(gnutls_session_t tlsstate)
{
- int verify_ret;
- unsigned int status;
-
- verify_ret = gnutls_certificate_verify_peers2(tlsstate, &status);
- if (!verify_ret)
+ unsigned int status = 0;
+ int verify_ret = gnutls_certificate_verify_peers2(tlsstate, &status);
+ if (verify_ret == 0)
return status;
if (status == GNUTLS_E_NO_CERTIFICATE_FOUND)
const gnutls_datum_t *cert_list = NULL;
unsigned int cert_list_size = 0;
gnutls_certificate_status_t certstat;
- int certerr, preauthrc, savedcert, rc = 0;
+ int certerr, savedcert, rc = 0;
int rcpeer = -1; /* the result of tls_check_preauth() on the peer's EE cert */
if (gnutls_auth_get_type(state) != GNUTLS_CRD_CERTIFICATE)
/* tls_verify_peers doesn't check hostname or expiration, so walk
* from most specific to least checking these. If we see a saved certificate,
* its status short-circuits the remaining checks. */
- preauthrc = 0;
+ int preauthrc = 0;
for (int i = 0; i < cert_list_size; i++)
{
rc = tls_check_preauth(&cert_list[i], certstat, conn->account.host, i,
static int tls_socket_read(struct Connection *conn, char *buf, size_t count)
{
struct TlsSockData *data = conn->sockdata;
- int rc;
-
if (!data)
{
mutt_error(_("Error: no TLS socket open"));
return -1;
}
+ int rc;
do
{
rc = gnutls_record_recv(data->state, buf, count);
*/
int mutt_strwidth(const char *s)
{
+ if (!s)
+ return 0;
+
wchar_t wc;
int w;
- size_t k, n;
+ size_t k;
mbstate_t mbstate;
- if (!s)
- return 0;
-
- n = mutt_str_strlen(s);
+ size_t n = mutt_str_strlen(s);
memset(&mbstate, 0, sizeof(mbstate));
for (w = 0; n && (k = mbrtowc(&wc, s, n, &mbstate)); s += k, n -= k)
*/
void mutt_auto_subscribe(const char *mailto)
{
- struct Envelope *lpenv;
-
if (!AutoSubscribeCache)
AutoSubscribeCache = mutt_hash_new(200, MUTT_HASH_STRCASECMP | MUTT_HASH_STRDUP_KEYS);
mutt_hash_insert(AutoSubscribeCache, mailto, AutoSubscribeCache);
- lpenv = mutt_env_new(); /* parsed envelope from the List-Post mailto: URL */
+ struct Envelope *lpenv = mutt_env_new(); /* parsed envelope from the List-Post mailto: URL */
if ((mutt_parse_mailto(lpenv, NULL, mailto) != -1) && lpenv->to && lpenv->to->mailbox &&
!mutt_regexlist_match(&UnSubscribedLists, lpenv->to->mailbox) &&
!mutt_regexlist_match(&UnMailLists, lpenv->to->mailbox) &&
!mutt_regexlist_match(&UnSubscribedLists, lpenv->to->mailbox))
{
- struct Buffer err;
- char errbuf[256];
- memset(&err, 0, sizeof(err));
- err.data = errbuf;
- err.dsize = sizeof(errbuf);
+ struct Buffer *err = mutt_buffer_pool_get();
/* mutt_regexlist_add() detects duplicates, so it is safe to
* try to add here without any checks. */
- mutt_regexlist_add(&MailLists, lpenv->to->mailbox, REG_ICASE, &err);
- mutt_regexlist_add(&SubscribedLists, lpenv->to->mailbox, REG_ICASE, &err);
+ mutt_regexlist_add(&MailLists, lpenv->to->mailbox, REG_ICASE, err);
+ mutt_regexlist_add(&SubscribedLists, lpenv->to->mailbox, REG_ICASE, err);
+ mutt_buffer_pool_release(&err);
}
mutt_env_free(&lpenv);
*/
void rfc2231_decode_parameters(struct ParameterList *p)
{
+ if (!p)
+ return;
+
struct Rfc2231Parameter *conthead = NULL;
struct Rfc2231Parameter *conttmp = NULL;
bool encoded;
int index;
bool dirty = false; /* set when we may have created empty parameters. */
- if (!p)
- return;
purge_empty_parameters(p);
*/
int url_pct_decode(char *s)
{
- char *d = NULL;
-
if (!s)
return -1;
+ char *d = NULL;
+
for (d = s; *s; s++)
{
if (*s == '%')
if (!m || !el || STAILQ_EMPTY(el))
return -1;
- int i, flag;
+ int flag;
struct Event event;
mutt_window_mvprintw(MuttMessageWindow, 0, 0,
{
event = mutt_getch();
} while (event.ch == -2);
- i = event.ch;
+ int i = event.ch;
if (i < 0)
{
mutt_window_clearline(MuttMessageWindow, 0);
{
if (cd != (iconv_t)(-1))
{
- ob = bufo, obl = sizeof(bufo);
+ ob = bufo;
+ obl = sizeof(bufo);
iconv(cd, NULL, NULL, &ob, &obl);
if (ob != bufo)
state_prefix_put(bufo, ob - bufo, s);
ibl = *l;
while (true)
{
- ob = bufo, obl = sizeof(bufo);
+ ob = bufo;
+ obl = sizeof(bufo);
mutt_ch_iconv(cd, &ib, &ibl, &ob, &obl, 0, "?", NULL);
if (ob == bufo)
break;
*/
static bool is_mmnoask(const char *buf)
{
- char *p = NULL;
- char tmp[1024], *q = NULL;
-
const char *val = mutt_str_getenv("MM_NOASK");
if (!val)
return false;
+ char *p = NULL;
+ char tmp[1024], *q = NULL;
+
if (mutt_str_strcmp(val, "1") == 0)
return true;
*/
static void *hcache_bdb_fetch(void *vctx, const char *key, size_t keylen)
{
- DBT dkey;
- DBT data;
-
if (!vctx)
return NULL;
+ DBT dkey;
+ DBT data;
+
struct HcacheDbCtx *ctx = vctx;
dbt_init(&dkey, (void *) key, keylen);
*/
static int hcache_bdb_store(void *vctx, const char *key, size_t keylen, void *data, size_t dlen)
{
- DBT dkey;
- DBT databuf;
-
if (!vctx)
return -1;
+ DBT dkey;
+ DBT databuf;
+
struct HcacheDbCtx *ctx = vctx;
dbt_init(&dkey, (void *) key, keylen);
*/
static int hcache_bdb_delete(void *vctx, const char *key, size_t keylen)
{
- DBT dkey;
-
if (!vctx)
return -1;
+ DBT dkey;
+
struct HcacheDbCtx *ctx = vctx;
dbt_init(&dkey, (void *) key, keylen);
*/
static void *hcache_gdbm_fetch(void *ctx, const char *key, size_t keylen)
{
- datum dkey;
- datum data;
-
if (!ctx)
return NULL;
+ datum dkey;
+ datum data;
+
GDBM_FILE db = ctx;
dkey.dptr = (char *) key;
*/
static int hcache_gdbm_store(void *ctx, const char *key, size_t keylen, void *data, size_t dlen)
{
- datum dkey;
- datum databuf;
-
if (!ctx)
return -1;
+ datum dkey;
+ datum databuf;
+
GDBM_FILE db = ctx;
dkey.dptr = (char *) key;
*/
static int hcache_gdbm_delete(void *ctx, const char *key, size_t keylen)
{
- datum dkey;
-
if (!ctx)
return -1;
+ datum dkey;
+
GDBM_FILE db = ctx;
dkey.dptr = (char *) key;
*/
static void *hcache_lmdb_fetch(void *vctx, const char *key, size_t keylen)
{
- MDB_val dkey;
- MDB_val data;
- int rc;
-
if (!vctx)
return NULL;
+ MDB_val dkey;
+ MDB_val data;
+
struct HcacheLmdbCtx *ctx = vctx;
dkey.mv_data = (void *) key;
dkey.mv_size = keylen;
data.mv_data = NULL;
data.mv_size = 0;
- rc = mdb_get_r_txn(ctx);
+ int rc = mdb_get_r_txn(ctx);
if (rc != MDB_SUCCESS)
{
ctx->txn = NULL;
*/
static int hcache_lmdb_store(void *vctx, const char *key, size_t keylen, void *data, size_t dlen)
{
- MDB_val dkey;
- MDB_val databuf;
- int rc;
-
if (!vctx)
return -1;
+ MDB_val dkey;
+ MDB_val databuf;
+
struct HcacheLmdbCtx *ctx = vctx;
dkey.mv_data = (void *) key;
dkey.mv_size = keylen;
databuf.mv_data = data;
databuf.mv_size = dlen;
- rc = mdb_get_w_txn(ctx);
+ int rc = mdb_get_w_txn(ctx);
if (rc != MDB_SUCCESS)
{
mutt_debug(LL_DEBUG2, "mdb_get_w_txn: %s\n", mdb_strerror(rc));
*/
static int hcache_lmdb_delete(void *vctx, const char *key, size_t keylen)
{
- MDB_val dkey;
- int rc;
-
if (!vctx)
return -1;
+ MDB_val dkey;
+
struct HcacheLmdbCtx *ctx = vctx;
dkey.mv_data = (void *) key;
dkey.mv_size = keylen;
- rc = mdb_get_w_txn(ctx);
+ int rc = mdb_get_w_txn(ctx);
if (rc != MDB_SUCCESS)
{
mutt_debug(LL_DEBUG2, "mdb_get_w_txn: %s\n", mdb_strerror(rc));
*/
static void *hcache_tokyocabinet_fetch(void *ctx, const char *key, size_t keylen)
{
- int sp;
-
if (!ctx)
return NULL;
+ int sp = 0;
TCBDB *db = ctx;
return tcbdbget(db, key, keylen, &sp);
}
{
int col;
int col_b;
- bool split;
fputs(t1, fp);
/* don't try to press string into one line with less than 40 characters. */
- split = (MuttIndexWindow->cols < 40);
+ bool split = (MuttIndexWindow->cols < 40);
if (split)
{
col = 0;
if (map->op == OP_MACRO)
{
- if (!map->desc)
- format_line(fp, -1, buf, "macro", map->macro);
- else
+ if (map->desc)
format_line(fp, 1, buf, map->macro, map->desc);
+ else
+ format_line(fp, -1, buf, "macro", map->macro);
}
else
{
}
/* dump the mailbox flags we've found */
- if (C_DebugLevel > 2)
+ if (C_DebugLevel > LL_DEBUG2)
{
if (STAILQ_EMPTY(&mdata->flags))
mutt_debug(LL_DEBUG3, "No folder flags found\n");
if (imap_edata_get(e)->flags_remote)
{
cmd = mutt_buffer_new();
- if (!cmd)
- {
- mutt_debug(LL_DEBUG1, "unable to allocate buffer\n");
- return -1;
- }
cmd->dptr = cmd->data;
mutt_buffer_addstr(cmd, "UID STORE ");
mutt_buffer_addstr(cmd, uid);
if (buf)
{
cmd = mutt_buffer_new();
- if (!cmd)
- {
- mutt_debug(LL_DEBUG1, "fail to remove old flags\n");
- return -1;
- }
cmd->dptr = cmd->data;
mutt_buffer_addstr(cmd, "UID STORE ");
mutt_buffer_addstr(cmd, uid);
*/
static int msg_parse_fetch(struct ImapHeader *h, char *s)
{
+ if (!s)
+ return -1;
+
char tmp[128];
char *ptmp = NULL;
size_t plen = 0;
- if (!s)
- return -1;
-
while (*s)
{
SKIPWS(s);
*/
static int msg_fetch_header(struct Mailbox *m, struct ImapHeader *ih, char *buf, FILE *fp)
{
- unsigned int bytes;
int rc = -1; /* default now is that string isn't FETCH response */
- int parse_rc;
struct ImapAccountData *adata = imap_adata_get(m);
/* FIXME: current implementation - call msg_parse_fetch - if it returns -2,
* read header lines and call it again. Silly. */
- parse_rc = msg_parse_fetch(ih, buf);
- if (!parse_rc)
+ int parse_rc = msg_parse_fetch(ih, buf);
+ if (parse_rc == 0)
return 0;
if ((parse_rc != -2) || !fp)
return rc;
+ unsigned int bytes = 0;
if (imap_get_literal_count(buf, &bytes) == 0)
{
imap_read_literal(fp, adata, bytes, NULL);
return NULL;
struct ImapHeader newh = { 0 };
- struct ImapEmailData old_edata;
- bool readonly;
- int local_changes;
-
- local_changes = e->changed;
+ struct ImapEmailData old_edata = { 0 };
+ int local_changes = e->changed;
struct ImapEmailData *edata = e->edata;
newh.edata = edata;
- memcpy(&old_edata, edata, sizeof(old_edata));
-
mutt_debug(LL_DEBUG2, "parsing FLAGS\n");
s = msg_parse_flags(&newh, s);
if (!s)
* read-write even if it's read-only, so *server* updates of
* flags can be processed by mutt_set_flag. mailbox->changed must
* be restored afterwards */
- readonly = m->readonly;
+ bool readonly = m->readonly;
m->readonly = false;
/* This is redundant with the following two checks. Removing:
*/
struct Email *imap_hcache_get(struct ImapMboxData *mdata, unsigned int uid)
{
- char key[16];
- void *uv = NULL;
- struct Email *e = NULL;
-
if (!mdata->hcache)
return NULL;
+ char key[16];
+ struct Email *e = NULL;
+
sprintf(key, "/%u", uid);
- uv = mutt_hcache_fetch(mdata->hcache, key, mutt_str_strlen(key));
+ void *uv = mutt_hcache_fetch(mdata->hcache, key, mutt_str_strlen(key));
if (uv)
{
if (*(unsigned int *) uv == mdata->uid_validity)
*/
int imap_hcache_put(struct ImapMboxData *mdata, struct Email *e)
{
- char key[16];
-
if (!mdata->hcache)
return -1;
+ char key[16];
+
sprintf(key, "/%u", imap_edata_get(e)->uid);
return mutt_hcache_store(mdata->hcache, key, mutt_str_strlen(key), e, mdata->uid_validity);
}
*/
int imap_hcache_del(struct ImapMboxData *mdata, unsigned int uid)
{
- char key[16];
-
if (!mdata->hcache)
return -1;
+ char key[16];
+
sprintf(key, "/%u", uid);
return mutt_hcache_delete(mdata->hcache, key, mutt_str_strlen(key));
}
*/
void mutt_set_header_color(struct Mailbox *m, struct Email *e)
{
- struct ColorLine *color = NULL;
- struct PatternCache cache = { 0 };
-
if (!e)
return;
+ struct ColorLine *color = NULL;
+ struct PatternCache cache = { 0 };
+
STAILQ_FOREACH(color, &ColorIndexList, entries)
{
if (mutt_pattern_exec(SLIST_FIRST(color->color_pattern),
char *currentline = NULL;
char rcfile[PATH_MAX];
size_t buflen;
- size_t rcfilelen;
- bool ispipe;
pid_t pid;
mutt_str_strfcpy(rcfile, rcfile_path, sizeof(rcfile));
- rcfilelen = mutt_str_strlen(rcfile);
+ size_t rcfilelen = mutt_str_strlen(rcfile);
if (rcfilelen == 0)
return -1;
- ispipe = rcfile[rcfilelen - 1] == '|';
+ bool ispipe = rcfile[rcfilelen - 1] == '|';
if (!ispipe)
{
mutt_grouplist_add_addrlist(&gc, tmp->addr);
mutt_alias_add_reverse(tmp);
- if (C_DebugLevel > 2)
+ if (C_DebugLevel > LL_DEBUG4)
{
/* A group is terminated with an empty address, so check a->mailbox */
for (struct Address *a = tmp->addr; a && a->mailbox; a = a->next)
{
- if (!a->group)
- mutt_debug(5, " %s\n", a->mailbox);
- else
+ if (a->group)
mutt_debug(5, " Group %s\n", a->mailbox);
+ else
+ mutt_debug(5, " %s\n", a->mailbox);
}
}
mutt_grouplist_destroy(&gc);
*/
int km_expand_key(char *s, size_t len, struct Keymap *map)
{
- int p = 0;
-
if (!map)
return 0;
+ int p = 0;
+
while (true)
{
mutt_str_strfcpy(s, km_keyname(map->keys[p]), len);
struct Email *maildir_parse_stream(enum MailboxType magic, FILE *fp,
const char *fname, bool is_old, struct Email *e)
{
- struct stat st;
-
if (!e)
e = mutt_email_new();
e->env = mutt_rfc822_read_header(fp, e, false, false);
+ struct stat st;
fstat(fileno(fp), &st);
if (!e->received)
*/
static void monitor_delete(struct Monitor *monitor)
{
- struct Monitor **ptr = &Monitor;
-
if (!monitor)
return;
+ struct Monitor **ptr = &Monitor;
+
while (true)
{
if (!*ptr)
*/
struct Buffer *mutt_buffer_from(const char *seed)
{
- struct Buffer *b = NULL;
-
if (!seed)
return NULL;
- b = mutt_buffer_new();
+ struct Buffer *b = mutt_buffer_new();
b->data = mutt_str_strdup(seed);
b->dsize = mutt_str_strlen(seed);
b->dptr = (char *) b->data + b->dsize;
for (const char *c = C_AssumedCharset; c; c = c1 ? c1 + 1 : 0)
{
char *u = *ps;
- char *s = NULL;
- char *fromcode = NULL;
- size_t n;
size_t ulen = mutt_str_strlen(*ps);
if (!u || !*u)
return 0;
c1 = strchr(c, ':');
- n = c1 ? c1 - c : mutt_str_strlen(c);
- if (!n)
+ size_t n = c1 ? c1 - c : mutt_str_strlen(c);
+ if (n == 0)
return 0;
- fromcode = mutt_mem_malloc(n + 1);
+ char *fromcode = mutt_mem_malloc(n + 1);
mutt_str_strfcpy(fromcode, c, n + 1);
- s = mutt_str_substr_dup(u, u + ulen);
+ char *s = mutt_str_substr_dup(u, u + ulen);
int m = mutt_ch_convert_string(&s, fromcode, C_Charset, 0);
FREE(&fromcode);
FREE(&s);
*/
bool mutt_ch_check_charset(const char *cs, bool strict)
{
- iconv_t cd;
-
if (mutt_ch_is_utf8(cs))
return true;
}
}
- cd = mutt_ch_iconv_open(cs, cs, 0);
+ iconv_t cd = mutt_ch_iconv_open(cs, cs, 0);
if (cd != (iconv_t)(-1))
{
iconv_close(cd);
for (const char *p = charsets; p; p = q ? q + 1 : 0)
{
- char *s = NULL, *t = NULL;
- size_t slen, n;
-
q = strchr(p, ':');
- n = q ? q - p : strlen(p);
- if (!n)
+ size_t n = q ? q - p : strlen(p);
+ if (n == 0)
continue;
- t = mutt_mem_malloc(n + 1);
+ char *t = mutt_mem_malloc(n + 1);
memcpy(t, p, n);
t[n] = '\0';
- s = mutt_str_substr_dup(u, u + ulen);
+ char *s = mutt_str_substr_dup(u, u + ulen);
const int rc = d ? mutt_ch_convert_string(&s, fromcode, t, 0) :
mutt_ch_check(s, ulen, fromcode, t);
if (rc)
FREE(&s);
continue;
}
- slen = mutt_str_strlen(s);
+ size_t slen = mutt_str_strlen(s);
if (!tocode || (n < bestn))
{
{
int count = 0;
int hour, min, sec;
- struct tm tm;
+ struct tm tm = { 0 };
int i;
int tz_offset = 0;
int zhours = 0;
t = scratch;
t = mutt_str_skip_email_wsp(t);
- memset(&tm, 0, sizeof(tm));
-
while ((t = strtok(t, " \t")))
{
switch (count)
{
char **envp = EnvList;
char work[1024];
- int count;
/* Look for current slot to overwrite */
- count = 0;
+ int count = 0;
while (envp && *envp)
{
size_t len = mutt_str_startswith(*envp, name, CASE_MATCH);
const bool is_regular_file = (lstat(s, &sb) == 0) && S_ISREG(sb.st_mode);
if (!is_regular_file)
- {
return;
- }
const int fd = open(s, O_RDWR | O_NOFOLLOW);
if (fd < 0)
*/
size_t mutt_file_quote_filename(const char *filename, char *buf, size_t buflen)
{
- size_t j = 0;
-
if (!filename)
{
*buf = '\0';
return 0;
}
+ size_t j = 0;
+
/* leave some space for the trailing characters. */
buflen -= 6;
*/
int mutt_file_unlock(int fd)
{
- struct flock unlockit = { F_UNLCK, 0, 0, 0, 0 };
+ struct flock unlockit;
memset(&unlockit, 0, sizeof(struct flock));
unlockit.l_type = F_UNLCK;
*/
static struct HashElem *union_hash_find_elem(const struct Hash *table, union HashKey key)
{
- int hash;
- struct HashElem *ptr = NULL;
-
if (!table)
return NULL;
- hash = table->gen_hash(key, table->nelem);
- ptr = table->table[hash];
+ int hash = table->gen_hash(key, table->nelem);
+ struct HashElem *ptr = table->table[hash];
for (; ptr; ptr = ptr->next)
{
if (table->cmp_key(key, ptr->key) == 0)
*/
static void union_hash_delete(struct Hash *table, union HashKey key, const void *data)
{
- int hash;
- struct HashElem *ptr, **last;
-
if (!table)
return;
- hash = table->gen_hash(key, table->nelem);
- ptr = table->table[hash];
- last = &table->table[hash];
+ int hash = table->gen_hash(key, table->nelem);
+ struct HashElem *ptr = table->table[hash];
+ struct HashElem **last = &table->table[hash];
while (ptr)
{
*/
struct HashElem *mutt_hash_find_bucket(const struct Hash *table, const char *strkey)
{
- union HashKey key;
- int hash;
-
if (!table)
return NULL;
+ union HashKey key;
+
key.strkey = strkey;
- hash = table->gen_hash(key, table->nelem);
+ int hash = table->gen_hash(key, table->nelem);
return table->table[hash];
}
*/
static void remove_history_dups(enum HistoryClass hclass, const char *str)
{
- int source, dest, old_last;
struct History *h = get_history(hclass);
if (!h)
return; /* disabled */
/* Remove dups from 0..last-1 compacting up. */
- source = 0;
- dest = 0;
+ int source = 0;
+ int dest = 0;
while (source < h->last)
{
if (mutt_str_strcmp(h->hist[source], str) == 0)
/* Move 'last' entry up. */
h->hist[dest] = h->hist[source];
- old_last = h->last;
+ int old_last = h->last;
h->last = dest;
/* Fill in moved entries with NULL */
*/
int mutt_hist_search(const char *search_buf, enum HistoryClass hclass, char **matches)
{
- int match_count = 0, cur;
-
struct History *h = get_history(hclass);
if (!h)
return 0;
- cur = h->last;
+ int match_count = 0;
+ int cur = h->last;
do
{
cur--;
*/
char *mutt_path_escape(const char *src)
{
+ if (!src)
+ return NULL;
+
static char dest[STR_COMMAND];
char *destp = dest;
int destsize = 0;
- if (!src)
- return NULL;
-
while (*src && (destsize < sizeof(dest) - 1))
{
if (*src != '\'')
*/
static int count_body_parts(struct Body *body, int flags)
{
- int count = 0;
-
if (!body)
return 0;
+ int count = 0;
+
for (struct Body *bp = body; bp; bp = bp->next)
{
/* Initial disposition is to count and not to recurse this part. */
struct Email *cur = NULL;
int i, oldsort, using_refs = 0;
- struct MuttThread *thread = NULL, *new = NULL, *tmp = NULL, top;
- memset(&top, 0, sizeof(top));
+ struct MuttThread *thread = NULL, *new = NULL, *tmp = NULL;
+ struct MuttThread top = { 0 };
struct ListNode *ref = NULL;
/* Set C_Sort to the secondary method to support the set sort_aux=reverse-*
MuttStatusWindow->col_offset = 0;
memcpy(MuttHelpWindow, MuttStatusWindow, sizeof(struct MuttWindow));
- if (!C_Help)
- MuttHelpWindow->rows = 0;
- else
+ if (C_Help)
MuttHelpWindow->row_offset = C_StatusOnTop ? LINES - 2 : 0;
+ else
+ MuttHelpWindow->rows = 0;
memcpy(MuttMessageWindow, MuttStatusWindow, sizeof(struct MuttWindow));
MuttMessageWindow->row_offset = LINES - 1;
*/
int crypt_write_signed(struct Body *a, struct State *s, const char *tempfile)
{
- FILE *fp = NULL;
- bool hadcr;
- size_t bytes;
-
if (!WithCrypto)
return -1;
- fp = mutt_file_fopen(tempfile, "w");
+ FILE *fp = mutt_file_fopen(tempfile, "w");
if (!fp)
{
mutt_perror(tempfile);
}
fseeko(s->fp_in, a->hdr_offset, SEEK_SET);
- bytes = a->length + a->offset - a->hdr_offset;
- hadcr = false;
+ size_t bytes = a->length + a->offset - a->hdr_offset;
+ bool hadcr = false;
while (bytes > 0)
{
const int c = fgetc(s->fp_in);
*/
void crypt_extract_keys_from_messages(struct EmailList *el)
{
- char tempfname[PATH_MAX], *mbox = NULL;
- struct Address *tmp = NULL;
-
if (!WithCrypto)
return;
+ char tempfname[PATH_MAX];
+ struct Address *tmp = NULL;
+
mutt_mktemp(tempfname, sizeof(tempfname));
FILE *fp_out = mutt_file_fopen(tempfname, "w");
if (!fp_out)
tmp = mutt_expand_aliases(e->env->from);
else if (e->env->sender)
tmp = mutt_expand_aliases(e->env->sender);
- mbox = tmp ? tmp->mailbox : NULL;
+ char *mbox = tmp ? tmp->mailbox : NULL;
if (mbox)
{
mutt_endwin();
*/
int crypt_get_keys(struct Email *msg, char **keylist, bool oppenc_mode)
{
+ if (!WithCrypto)
+ return 0;
+
struct Address *addrlist = NULL, *last = NULL;
const char *fqdn = mutt_fqdn(true);
char *self_encrypt = NULL;
/* Do a quick check to make sure that we can find all of the encryption
* keys if the user has requested this service. */
- if (!WithCrypto)
- return 0;
-
if (WithCrypto & APPLICATION_PGP)
OptPgpCheckTrust = true;
*/
void crypt_opportunistic_encrypt(struct Email *msg)
{
- char *pgpkeylist = NULL;
-
if (!WithCrypto)
return;
if (!(C_CryptOpportunisticEncrypt && (msg->security & SEC_OPPENCRYPT)))
return;
+ char *pgpkeylist = NULL;
+
crypt_get_keys(msg, &pgpkeylist, 1);
if (pgpkeylist)
{
*/
int mutt_signed_handler(struct Body *a, struct State *s)
{
+ if (!WithCrypto)
+ return -1;
+
bool inconsistent = false;
struct Body *b = a;
struct Body **signatures = NULL;
int sigcnt = 0;
int rc = 0;
- if (!WithCrypto)
- return -1;
-
a = a->parts;
SecurityFlags signed_type = mutt_is_multipart_signed(b);
if (signed_type == SEC_NO_FLAGS)
*/
static void crypt_free_key(struct CryptKeyInfo **keylist)
{
- struct CryptKeyInfo *k = NULL;
-
if (!keylist)
return;
+ struct CryptKeyInfo *k = NULL;
+
while (*keylist)
{
k = *keylist;
*/
static bool have_gpg_version(const char *version)
{
- static char *engine_version;
+ static char *engine_version = NULL;
if (!engine_version)
{
*/
static gpgme_data_t file_to_data_object(FILE *fp, long offset, size_t length)
{
- int err = 0;
gpgme_data_t data;
- err = gpgme_data_new_from_filepart(&data, NULL, fp, offset, length);
+ int err = gpgme_data_new_from_filepart(&data, NULL, fp, offset, length);
if (err != 0)
{
mutt_error(_("error allocating data object: %s"), gpgme_strerror(err));
*/
static int data_object_to_stream(gpgme_data_t data, FILE *fp)
{
- int err;
char buf[4096];
ssize_t nread;
- err = ((gpgme_data_seek(data, 0, SEEK_SET) == -1) ? gpgme_error_from_errno(errno) : 0);
+ int err = ((gpgme_data_seek(data, 0, SEEK_SET) == -1) ? gpgme_error_from_errno(errno) : 0);
if (err != 0)
{
mutt_error(_("error rewinding data object: %s"), gpgme_strerror(err));
*/
static char *data_object_to_tempfile(gpgme_data_t data, FILE **fp_ret)
{
- int err;
char tempf[PATH_MAX];
ssize_t nread = 0;
return NULL;
}
- err = ((gpgme_data_seek(data, 0, SEEK_SET) == -1) ? gpgme_error_from_errno(errno) : 0);
+ int err = ((gpgme_data_seek(data, 0, SEEK_SET) == -1) ? gpgme_error_from_errno(errno) : 0);
if (err == 0)
{
char buf[4096];
*/
static void show_fingerprint(gpgme_key_t key, struct State *state)
{
- const char *s = NULL;
- char *buf = NULL, *p = NULL;
- const char *prefix = _("Fingerprint: ");
-
if (!key)
return;
- s = key->subkeys ? key->subkeys->fpr : NULL;
+
+ const char *prefix = _("Fingerprint: ");
+
+ const char *s = key->subkeys ? key->subkeys->fpr : NULL;
if (!s)
return;
bool is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
- buf = mutt_mem_malloc(strlen(prefix) + strlen(s) * 4 + 2);
+ char *buf = mutt_mem_malloc(strlen(prefix) + strlen(s) * 4 + 2);
strcpy(buf, prefix);
- p = buf + strlen(buf);
+ char *p = buf + strlen(buf);
if (is_pgp && (strlen(s) == 40))
{ /* PGP v4 style formatted. */
for (int i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++)
{
int badsig = -1;
int anywarn = 0;
- int err;
gpgme_ctx_t ctx;
gpgme_data_t signature, message;
if (is_smime)
gpgme_data_set_encoding(signature, GPGME_DATA_ENCODING_BASE64);
- err = gpgme_data_new_from_file(&message, tempfile, 1);
+ int err = gpgme_data_new_from_file(&message, tempfile, 1);
if (err != 0)
{
gpgme_data_release(signature);
static void pgp_dearmor(FILE *fp_in, FILE *fp_out)
{
char line[8192];
- LOFF_T start;
- LOFF_T end;
char *r = NULL;
struct State state = { 0 };
}
/* actual data starts here */
- start = ftello(fp_in);
+ LOFF_T start = ftello(fp_in);
if (start < 0)
return;
return;
}
- end = ftello(fp_in) - strlen(line);
+ LOFF_T end = ftello(fp_in) - strlen(line);
if (end < start)
{
mutt_debug(LL_DEBUG1, "end < start???\n");
*/
static void smime_free_key(struct SmimeKey **keylist)
{
- struct SmimeKey *key = NULL;
-
if (!keylist)
return;
+ struct SmimeKey *key = NULL;
+
while (*keylist)
{
key = *keylist;
*/
static struct SmimeKey *smime_copy_key(struct SmimeKey *key)
{
- struct SmimeKey *copy = NULL;
-
if (!key)
return NULL;
+ struct SmimeKey *copy = NULL;
+
copy = mutt_mem_calloc(1, sizeof(struct SmimeKey));
copy->email = mutt_str_strdup(key->email);
copy->hash = mutt_str_strdup(key->hash);
static struct SmimeKey *smime_get_key_by_addr(char *mailbox, KeyFlags abilities,
bool public, bool may_ask)
{
+ if (!mailbox)
+ return NULL;
+
struct SmimeKey *results = NULL, *result = NULL;
struct SmimeKey *matches = NULL;
struct SmimeKey **matches_end = &matches;
struct SmimeKey *trusted_match = NULL;
struct SmimeKey *valid_match = NULL;
struct SmimeKey *return_key = NULL;
-
- if (!mailbox)
- return NULL;
bool multi_trusted_matches = false;
results = smime_get_candidates(mailbox, public);
*/
static struct SmimeKey *smime_get_key_by_str(char *str, KeyFlags abilities, bool public)
{
+ if (!str)
+ return NULL;
+
struct SmimeKey *results = NULL, *result = NULL;
struct SmimeKey *matches = NULL;
struct SmimeKey **matches_end = &matches;
struct SmimeKey *match = NULL;
struct SmimeKey *return_key = NULL;
- if (!str)
- return NULL;
-
results = smime_get_candidates(str, public);
for (result = results; result; result = result->next)
{
for (unsigned int i = 0; i < adata->groups_num; i++)
{
struct NntpMboxData *mdata = adata->groups_list[i];
-
if (!mdata)
continue;
*/
int nntp_newsrc_update(struct NntpAccountData *adata)
{
- char *buf = NULL;
- size_t buflen, off;
- int rc = -1;
-
if (!adata)
return -1;
- buflen = 10240;
- buf = mutt_mem_calloc(1, buflen);
- off = 0;
+ int rc = -1;
+
+ size_t buflen = 10240;
+ char *buf = mutt_mem_calloc(1, buflen);
+ size_t off = 0;
/* we will generate full newsrc here */
for (unsigned int i = 0; i < adata->groups_num; i++)
*/
int nntp_active_save_cache(struct NntpAccountData *adata)
{
- char file[PATH_MAX];
- char *buf = NULL;
- size_t buflen, off;
- int rc;
-
if (!adata->cacheable)
return 0;
- buflen = 10240;
- buf = mutt_mem_calloc(1, buflen);
+ size_t buflen = 10240;
+ char *buf = mutt_mem_calloc(1, buflen);
snprintf(buf, buflen, "%lu\n", (unsigned long) adata->newgroups_time);
- off = strlen(buf);
+ size_t off = strlen(buf);
for (unsigned int i = 0; i < adata->groups_num; i++)
{
off += strlen(buf + off);
}
+ char file[PATH_MAX];
cache_expand(file, sizeof(file), &adata->conn->account, ".active");
mutt_debug(LL_DEBUG1, "Updating %s\n", file);
- rc = update_file(file, buf);
+ int rc = update_file(file, buf);
FREE(&buf);
return rc;
}
*/
void nntp_hcache_update(struct NntpMboxData *mdata, header_cache_t *hc)
{
+ if (!hc)
+ return;
+
char buf[16];
bool old = false;
- void *hdata = NULL;
anum_t first = 0, last = 0;
- if (!hc)
- return;
-
/* fetch previous values of first and last */
- hdata = mutt_hcache_fetch_raw(hc, "index", 5);
+ void *hdata = mutt_hcache_fetch_raw(hc, "index", 5);
if (hdata)
{
mutt_debug(LL_DEBUG2, "mutt_hcache_fetch index: %s\n", (char *) hdata);
*/
struct NntpMboxData *mutt_newsgroup_subscribe(struct NntpAccountData *adata, char *group)
{
- struct NntpMboxData *mdata = NULL;
-
if (!adata || !adata->groups_hash || !group || !*group)
return NULL;
- mdata = mdata_find(adata, group);
+ struct NntpMboxData *mdata = mdata_find(adata, group);
mdata->subscribed = true;
if (!mdata->newsrc_ent)
{
*/
struct NntpMboxData *mutt_newsgroup_unsubscribe(struct NntpAccountData *adata, char *group)
{
- struct NntpMboxData *mdata = NULL;
-
if (!adata || !adata->groups_hash || !group || !*group)
return NULL;
- mdata = mutt_hash_find(adata->groups_hash, group);
+ struct NntpMboxData *mdata = mutt_hash_find(adata->groups_hash, group);
if (!mdata)
return NULL;
struct NntpMboxData *mutt_newsgroup_catchup(struct Mailbox *m,
struct NntpAccountData *adata, char *group)
{
- struct NntpMboxData *mdata = NULL;
-
if (!adata || !adata->groups_hash || !group || !*group)
return NULL;
- mdata = mutt_hash_find(adata->groups_hash, group);
+ struct NntpMboxData *mdata = mutt_hash_find(adata->groups_hash, group);
if (!mdata)
return NULL;
struct NntpMboxData *mutt_newsgroup_uncatchup(struct Mailbox *m,
struct NntpAccountData *adata, char *group)
{
- struct NntpMboxData *mdata = NULL;
-
if (!adata || !adata->groups_hash || !group || !*group)
return NULL;
- mdata = mutt_hash_find(adata->groups_hash, group);
+ struct NntpMboxData *mdata = mutt_hash_find(adata->groups_hash, group);
if (!mdata)
return NULL;
off += strlen(adata->overview_fmt + off);
if (cont == 0)
{
- char *colon = NULL;
-
if (adata->overview_fmt[b] == ':')
{
memmove(adata->overview_fmt + b, adata->overview_fmt + b + 1, off - b - 1);
adata->overview_fmt[off - 1] = ':';
}
- colon = strchr(adata->overview_fmt + b, ':');
+ char *colon = strchr(adata->overview_fmt + b, ':');
if (!colon)
adata->overview_fmt[off++] = ':';
else if (strcmp(colon + 1, "full") != 0)
*/
static int fetch_description(char *line, void *data)
{
- struct NntpAccountData *adata = data;
- struct NntpMboxData *mdata = NULL;
- char *desc = NULL;
-
if (!line)
return 0;
- desc = strpbrk(line, " \t");
+ struct NntpAccountData *adata = data;
+
+ char *desc = strpbrk(line, " \t");
if (desc)
{
*desc++ = '\0';
else
desc = strchr(line, '\0');
- mdata = mutt_hash_find(adata->groups_hash, line);
+ struct NntpMboxData *mdata = mutt_hash_find(adata->groups_hash, line);
if (mdata && (mutt_str_strcmp(desc, mdata->desc) != 0))
{
mutt_str_replace(&mdata->desc, desc);
{
struct NntpMboxData mdata;
char buf[1024];
- struct tm tm;
- memset(&tm, 0, sizeof(tm));
+ struct tm tm = { 0 };
mdata.adata = adata;
mdata.group = NULL;
static void append_message(header_cache_t *h, struct Mailbox *m,
notmuch_query_t *q, notmuch_message_t *msg, bool dedup)
{
- char *newpath = NULL;
- struct Email *e = NULL;
-
struct NmMboxData *mdata = nm_mdata_get(m);
if (!mdata)
return;
+ char *newpath = NULL;
+ struct Email *e = NULL;
+
/* deduplicate */
if (dedup && get_mutt_email(m, msg))
{
* @param err Buffer for error messages
* @retval true If the pattern was read successfully
*/
-typedef bool pattern_eat_t(struct Pattern *pat, int flags, struct Buffer *s, struct Buffer *err);
+typedef bool pattern_eat_t(struct Pattern *pat, int flags, struct Buffer *s,
+ struct Buffer *err);
/**
* struct PatternFlags - Mapping between user character and internal constant
*/
static int scan_range_num(struct Buffer *s, regmatch_t pmatch[], int group, int kind)
{
- int num;
- unsigned char c;
-
- num = (int) strtol(&s->dptr[pmatch[group].rm_so], NULL, 0);
- c = (unsigned char) (s->dptr[pmatch[group].rm_eo - 1]);
+ int num = (int) strtol(&s->dptr[pmatch[group].rm_so], NULL, 0);
+ unsigned char c = (unsigned char) (s->dptr[pmatch[group].rm_eo - 1]);
if (toupper(c) == 'K')
num *= KILO;
else if (toupper(c) == 'M')
*/
static int scan_range_slot(struct Buffer *s, regmatch_t pmatch[], int grp, int side, int kind)
{
- unsigned char c;
-
/* This means the left or right subpattern was empty, e.g. ",." */
if ((pmatch[grp].rm_so == -1) || (pmatch[grp].rm_so == pmatch[grp].rm_eo))
{
return Context->mailbox->msg_count;
}
/* We have something, so determine what */
- c = (unsigned char) (s->dptr[pmatch[grp].rm_so]);
+ unsigned char c = (unsigned char) (s->dptr[pmatch[grp].rm_so]);
switch (c)
{
case RANGE_CIRCUM:
*/
static void order_range(struct Pattern *pat)
{
- int num;
-
if (pat->min <= pat->max)
return;
- num = pat->min;
+ int num = pat->min;
pat->min = pat->max;
pat->max = num;
}
struct Mailbox *m, struct MuttThread *t,
int left, int up, int right, int down)
{
- int a;
- struct Email *e = NULL;
-
if (!t)
return 0;
- e = t->message;
+
+ int a;
+ struct Email *e = t->message;
if (e)
if (mutt_pattern_exec(SLIST_FIRST(pat), flags, m, e, NULL))
return 1;
int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags,
struct Mailbox *m, struct Email *e, struct PatternCache *cache)
{
- int result;
- int *cache_entry = NULL;
-
switch (pat->op)
{
case MUTT_PAT_AND:
return pat->not^match_addrlist(pat, (flags & MUTT_MATCH_FULL_ADDRESS), 2,
e->env->to, e->env->cc);
case MUTT_PAT_LIST: /* known list, subscribed or not */
+ {
if (!e->env)
return 0;
+
+ int result;
if (cache)
{
- cache_entry = pat->alladdr ? &cache->list_all : &cache->list_one;
+ int *cache_entry = pat->alladdr ? &cache->list_all : &cache->list_one;
if (!is_pattern_cache_set(*cache_entry))
{
set_pattern_cache_value(
else
result = mutt_is_list_cc(pat->alladdr, e->env->to, e->env->cc);
return pat->not^result;
+ }
case MUTT_PAT_SUBSCRIBED_LIST:
+ {
if (!e->env)
return 0;
+
+ int result;
if (cache)
{
- cache_entry = pat->alladdr ? &cache->sub_all : &cache->sub_one;
+ int *cache_entry = pat->alladdr ? &cache->sub_all : &cache->sub_one;
if (!is_pattern_cache_set(*cache_entry))
{
set_pattern_cache_value(
else
result = mutt_is_list_recipient(pat->alladdr, e->env->to, e->env->cc);
return pat->not^result;
+ }
case MUTT_PAT_PERSONAL_RECIP:
+ {
if (!e->env)
return 0;
+
+ int result;
if (cache)
{
- cache_entry = pat->alladdr ? &cache->pers_recip_all : &cache->pers_recip_one;
+ int *cache_entry = pat->alladdr ? &cache->pers_recip_all : &cache->pers_recip_one;
if (!is_pattern_cache_set(*cache_entry))
{
set_pattern_cache_value(cache_entry,
else
result = match_user(pat->alladdr, e->env->to, e->env->cc);
return pat->not^result;
+ }
case MUTT_PAT_PERSONAL_FROM:
+ {
if (!e->env)
return 0;
+
+ int result;
if (cache)
{
- cache_entry = pat->alladdr ? &cache->pers_from_all : &cache->pers_from_one;
+ int *cache_entry = pat->alladdr ? &cache->pers_from_all : &cache->pers_from_one;
if (!is_pattern_cache_set(*cache_entry))
set_pattern_cache_value(cache_entry, match_user(pat->alladdr, e->env->from, NULL));
result = get_pattern_cache_value(*cache_entry);
else
result = match_user(pat->alladdr, e->env->from, NULL);
return pat->not^result;
+ }
case MUTT_PAT_COLLAPSED:
return pat->not^(e->collapsed && e->num_hidden > 1);
case MUTT_PAT_CRYPT_SIGN:
*/
static struct MuttThread *top_of_thread(struct Email *e)
{
- struct MuttThread *t = NULL;
-
if (!e)
return NULL;
- t = e->thread;
+ struct MuttThread *t = e->thread;
while (t && t->parent)
t = t->parent;
*/
bool mutt_limit_current_thread(struct Email *e)
{
- struct MuttThread *me = NULL;
-
if (!e)
return false;
- me = top_of_thread(e);
+ struct MuttThread *me = top_of_thread(e);
if (!me)
return false;
*/
int mutt_pattern_func(int op, char *prompt)
{
- struct PatternHead *pat = NULL;
- char buf[1024] = "", *simple = NULL;
+ char buf[1024] = "";
struct Buffer err;
- int rc = -1, padding;
+ int rc = -1;
struct Progress progress;
mutt_str_strfcpy(buf, Context->pattern, sizeof(buf));
mutt_message(_("Compiling search pattern..."));
- simple = mutt_str_strdup(buf);
+ char *simple = mutt_str_strdup(buf);
mutt_check_simple(buf, sizeof(buf), NONULL(C_SimpleSearch));
mutt_buffer_init(&err);
err.dsize = 256;
err.data = mutt_mem_malloc(err.dsize);
- pat = mutt_pattern_comp(buf, MUTT_FULL_MSG, &err);
+ struct PatternHead *pat = mutt_pattern_comp(buf, MUTT_FULL_MSG, &err);
if (!pat)
{
mutt_error("%s", err.data);
Context->mailbox->vcount = 0;
Context->vsize = 0;
Context->collapsed = false;
- padding = mx_msg_padding_size(Context->mailbox);
+ int padding = mx_msg_padding_size(Context->mailbox);
for (int i = 0; i < Context->mailbox->msg_count; i++)
{
char inbuf[1024];
const char *mech = NULL;
const char *pc = NULL;
- unsigned int len = 0, olen = 0, client_start;
+ unsigned int len = 0, olen = 0;
if (mutt_account_getpass(&adata->conn->account) || !adata->conn->account.pass[0])
return POP_A_FAILURE;
/* About client_start: If sasl_client_start() returns data via pc/olen,
* the client is expected to send this first (after the AUTH string is sent).
* sasl_client_start() may in fact return SASL_OK in this case. */
- client_start = olen;
+ unsigned int client_start = olen;
mutt_message(_("Authenticating (SASL)..."));
void mutt_progress_init(struct Progress *progress, const char *msg,
unsigned short flags, unsigned short inc, size_t size)
{
- struct timeval tv = { 0, 0 };
-
if (!progress)
return;
if (OptNoCurses)
return;
+ struct timeval tv = { 0, 0 };
+
memset(progress, 0, sizeof(struct Progress));
progress->inc = inc;
progress->flags = flags;
if (C_ForwardQuote)
{
- if (!C_TextFlowed)
+ if (C_TextFlowed)
+ mutt_str_strfcpy(prefix, ">", sizeof(prefix));
+ else
{
mutt_make_string(prefix, sizeof(prefix), NONULL(C_IndentString), Context,
Context->mailbox, e_parent);
}
- else
- mutt_str_strfcpy(prefix, ">", sizeof(prefix));
}
include_header(C_ForwardQuote, fp_parent, e_parent, fp_tmp, prefix);
*/
static struct Remailer **mix_type2_list(size_t *l)
{
- FILE *fp = NULL;
- pid_t mm_pid;
+ if (!l)
+ return NULL;
+ FILE *fp = NULL;
char cmd[STR_COMMAND];
char line[8192];
char *t = NULL;
struct Remailer **type2_list = NULL, *p = NULL;
size_t slots = 0, used = 0;
- if (!l)
- return NULL;
-
int fd_null = open("/dev/null", O_RDWR);
if (fd_null == -1)
return NULL;
snprintf(cmd, sizeof(cmd), "%s -T", C_Mixmaster);
- mm_pid = mutt_create_filter_fd(cmd, NULL, &fp, NULL, fd_null, -1, fd_null);
+ pid_t mm_pid = mutt_create_filter_fd(cmd, NULL, &fp, NULL, fd_null, -1, fd_null);
if (mm_pid == -1)
{
close(fd_null);
static void mix_screen_coordinates(struct Remailer **type2_list, struct Coord **coordsp,
struct MixChain *chain, int i)
{
- short c, r;
-
if (!chain->cl)
return;
+ short c, r;
+
mutt_mem_realloc(coordsp, sizeof(struct Coord) * chain->cl);
struct Coord *coords = *coordsp;
*/
static char *get_field(char *s)
{
- char *ch = NULL;
-
if (!s)
return NULL;
+ char *ch = NULL;
+
while ((ch = strpbrk(s, ";\\")))
{
if (*ch == '\\')
if (fp_tmp)
{
- char line_buf[1024];
- int lines = 0;
-
mutt_write_mime_body(e->content, fp_tmp);
/* make sure the last line ends with a newline. Emacs doesn't ensure this
}
/* count the number of lines */
+ int lines = 0;
+ char line_buf[1024];
rewind(fp_tmp);
while (fgets(line_buf, sizeof(line_buf), fp_tmp))
lines++;
*/
static int smtp_helo(struct Connection *conn, bool esmtp)
{
- char buf[1024];
- const char *fqdn = NULL;
-
Capabilities = 0;
if (!esmtp)
#endif
}
- fqdn = mutt_fqdn(false);
+ const char *fqdn = mutt_fqdn(false);
if (!fqdn)
fqdn = NONULL(ShortHostname);
+ char buf[1024];
snprintf(buf, sizeof(buf), "%s %s\r\n", esmtp ? "EHLO" : "HELO", fqdn);
/* XXX there should probably be a wrapper in mutt_socket.c that
* repeatedly calls conn->write until all data is sent. This