static void init_menu(struct BrowserState *state, struct Menu *menu,
char *title, size_t titlelen, bool buffy)
{
- char path[_POSIX_PATH_MAX];
-
menu->max = state->entrylen;
if (menu->current >= menu->max)
}
else
{
+ char path[_POSIX_PATH_MAX];
menu->is_mailbox_list = 0;
mutt_str_strfcpy(path, LastDir, sizeof(path));
mutt_pretty_mailbox(path, sizeof(path));
}
else
{
- struct Body *b = NULL;
char buf2[_POSIX_PATH_MAX];
mutt_file_concat_path(buf2, LastDir, state.entry[menu->current].name,
sizeof(buf2));
- b = mutt_make_file_attach(buf2);
+ struct Body *b = mutt_make_file_attach(buf2);
if (b)
{
mutt_view_attachment(NULL, b, MUTT_REGULAR, NULL, NULL);
static struct Buffy *buffy_new(const char *path)
{
- struct Buffy *buffy = NULL;
char rp[PATH_MAX] = "";
- char *r = NULL;
- buffy = mutt_mem_calloc(1, sizeof(struct Buffy));
+ struct Buffy *buffy = mutt_mem_calloc(1, sizeof(struct Buffy));
mutt_str_strfcpy(buffy->path, path, sizeof(buffy->path));
- r = realpath(path, rp);
+ char *r = realpath(path, rp);
mutt_str_strfcpy(buffy->realpath, r ? rp : path, sizeof(buffy->realpath));
buffy->next = NULL;
buffy->magic = 0;
void mutt_buffy_setnotified(const char *path)
{
- struct Buffy *buffy = NULL;
-
- buffy = buffy_get(path);
+ struct Buffy *buffy = buffy_get(path);
if (!buffy)
return;
void mutt_free_color(int fg, int bg)
{
- struct ColorList *p = NULL, *q = NULL;
+ struct ColorList *q = NULL;
- p = ColorList;
+ struct ColorList *p = ColorList;
while (p)
{
if (p->fg == fg && p->bg == bg)
{
char *pfx = NULL;
char buf[SHORT_STRING];
- struct Address *addr = NULL;
-
- addr = mutt_get_address(env, &pfx);
+ struct Address *addr = mutt_get_address(env, &pfx);
if (!addr)
return;
char buf[LONG_STRING];
char obuf[LONG_STRING];
char tmp[STRING];
-
char charset[STRING];
- char *cp = NULL;
short charset_changed = 0;
short type_changed = 0;
short structure_changed = 0;
- cp = mutt_param_get(&b->parameter, "charset");
+ char *cp = mutt_param_get(&b->parameter, "charset");
mutt_str_strfcpy(charset, NONULL(cp), sizeof(charset));
snprintf(buf, sizeof(buf), "%s/%s", TYPE(b), b->subtype);
static int check_traditional_pgp(struct Header *h, int *redraw)
{
- struct Message *msg = NULL;
int rc = 0;
h->security |= PGP_TRADITIONAL_CHECKED;
mutt_parse_mime_message(Context, h);
- msg = mx_open_message(Context, h->msgno);
+ struct Message *msg = mx_open_message(Context, h->msgno);
if (!msg)
return 0;
if (crypt_pgp_check_traditional(msg->fp, h->content, 0))
char helpstr[LONG_STRING];
char buf[LONG_STRING];
char fname[_POSIX_PATH_MAX];
- struct Menu *menu = NULL;
- struct AttachCtx *actx = NULL;
struct AttachPtr *new = NULL;
int i, close = 0;
int r = -1; /* return value */
rd.msg = msg;
rd.fcc = fcc;
- menu = mutt_menu_new(MENU_COMPOSE);
+ struct Menu *menu = mutt_menu_new(MENU_COMPOSE);
menu->offset = HDR_ATTACH;
menu->make_entry = snd_entry;
menu->tag = mutt_tag_attach;
menu->redraw_data = &rd;
mutt_menu_push_current(menu);
- actx = mutt_mem_calloc(sizeof(struct AttachCtx), 1);
+ struct AttachCtx *actx = mutt_mem_calloc(sizeof(struct AttachCtx), 1);
actx->hdr = msg;
mutt_update_compose_menu(actx, menu, 1);
case OP_COMPOSE_ATTACH_FILE:
{
- char *prompt = NULL, **files = NULL;
- int error, numfiles;
-
+ char *prompt = _("Attach file");
+ int numfiles = 0;
+ char **files = NULL;
fname[0] = 0;
- prompt = _("Attach file");
- numfiles = 0;
- files = NULL;
if (mutt_enter_fname_full(prompt, fname, sizeof(fname), 0, 1, &files,
&numfiles, MUTT_SEL_MULTI) == -1 ||
*fname == '\0')
break;
- error = 0;
+ int error = 0;
if (numfiles > 1)
mutt_message(_("Attaching selected files..."));
for (i = 0; i < numfiles; i++)
case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
#endif
{
- char *prompt = NULL;
-
+ char *prompt = _("Open mailbox to attach message from");
fname[0] = 0;
- prompt = _("Open mailbox to attach message from");
#ifdef USE_NNTP
OPT_NEWS = false;
return -1;
char tmppath[_POSIX_PATH_MAX];
- FILE *tmpfp = NULL;
/* Setup the right paths */
FREE(&ctx->realpath);
mutt_mktemp(tmppath, sizeof(tmppath));
ctx->path = mutt_str_strdup(tmppath);
- tmpfp = mutt_file_fopen(ctx->path, "w");
+ FILE *tmpfp = mutt_file_fopen(ctx->path, "w");
if (!tmpfp)
return -1;
*/
static sasl_callback_t *mutt_sasl_get_callbacks(struct Account *account)
{
- sasl_callback_t *callback = NULL;
-
- callback = MuttSaslCallbacks;
+ sasl_callback_t *callback = MuttSaslCallbacks;
callback->id = SASL_CB_USER;
callback->proc = (int (*)(void)) mutt_sasl_cb_authname;
*/
static int mutt_sasl_conn_open(struct Connection *conn)
{
- struct SaslData *sasldata = NULL;
- int rc;
-
- sasldata = (struct SaslData *) conn->sockdata;
+ struct SaslData *sasldata = (struct SaslData *) conn->sockdata;
conn->sockdata = sasldata->sockdata;
- rc = (sasldata->msasl_open)(conn);
+ int rc = (sasldata->msasl_open)(conn);
conn->sockdata = sasldata;
return rc;
*/
static int mutt_sasl_conn_close(struct Connection *conn)
{
- struct SaslData *sasldata = NULL;
- int rc;
-
- sasldata = (struct SaslData *) conn->sockdata;
+ struct SaslData *sasldata = (struct SaslData *) conn->sockdata;
/* restore connection's underlying methods */
conn->sockdata = sasldata->sockdata;
FREE(&sasldata);
/* call underlying close */
- rc = (conn->conn_close)(conn);
+ int rc = (conn->conn_close)(conn);
return rc;
}
*/
static int mutt_sasl_conn_read(struct Connection *conn, char *buf, size_t len)
{
- struct SaslData *sasldata = NULL;
int rc;
-
unsigned int olen;
- sasldata = (struct SaslData *) conn->sockdata;
+ struct SaslData *sasldata = (struct SaslData *) conn->sockdata;
/* if we still have data in our read buffer, copy it into buf */
if (sasldata->blen > sasldata->bpos)
*/
static int mutt_sasl_conn_write(struct Connection *conn, const char *buf, size_t len)
{
- struct SaslData *sasldata = NULL;
int rc;
-
const char *pbuf = NULL;
unsigned int olen, plen;
- sasldata = (struct SaslData *) conn->sockdata;
+ struct SaslData *sasldata = (struct SaslData *) conn->sockdata;
conn->sockdata = sasldata->sockdata;
/* encode data, if necessary */
*/
struct Connection *socket_new_conn(void)
{
- struct Connection *conn = NULL;
-
- conn = mutt_mem_calloc(1, sizeof(struct Connection));
+ struct Connection *conn = mutt_mem_calloc(1, sizeof(struct Connection));
conn->fd = -1;
return conn;
*/
static int tls_check_stored_hostname(const gnutls_datum_t *cert, const char *hostname)
{
- FILE *fp = NULL;
char *linestr = NULL;
- size_t linestrsize;
+ size_t linestrsize = 0;
int linenum = 0;
regex_t preg;
regmatch_t pmatch[3];
/* try checking against names stored in stored certs file */
- fp = fopen(CertificateFile, "r");
+ FILE *fp = fopen(CertificateFile, "r");
if (fp)
{
if (REGCOMP(&preg, "^#H ([a-zA-Z0-9_\\.-]+) ([0-9A-F]{4}( [0-9A-F]{4}){7})[ \t]*$",
static void tls_get_client_cert(struct Connection *conn)
{
struct TlsSockData *data = conn->sockdata;
- const gnutls_datum_t *crtdata = NULL;
gnutls_x509_crt_t clientcrt;
char *dn = NULL;
char *cn = NULL;
size_t dnlen;
/* get our cert CN if we have one */
- crtdata = gnutls_certificate_get_ours(data->state);
+ const gnutls_datum_t *crtdata = gnutls_certificate_get_ours(data->state);
if (!crtdata)
return;
static int tls_set_priority(struct TlsSockData *data)
{
size_t nproto = 4;
- char *priority = NULL;
size_t priority_size;
- int err;
priority_size = SHORT_STRING + mutt_str_strlen(SslCiphers);
- priority = mutt_mem_malloc(priority_size);
+ char *priority = mutt_mem_malloc(priority_size);
priority[0] = 0;
if (SslCiphers)
return -1;
}
- err = gnutls_priority_set_direct(data->state, priority, NULL);
+ int err = gnutls_priority_set_direct(data->state, priority, NULL);
if (err < 0)
{
mutt_error("gnutls_priority_set_direct(%s): %s", priority, gnutls_strerror(err));
*/
static int tls_negotiate(struct Connection *conn)
{
- struct TlsSockData *data = NULL;
- int err;
-
- data = mutt_mem_calloc(1, sizeof(struct TlsSockData));
+ struct TlsSockData *data = mutt_mem_calloc(1, sizeof(struct TlsSockData));
conn->sockdata = data;
- err = gnutls_certificate_allocate_credentials(&data->xcred);
+ int err = gnutls_certificate_allocate_credentials(&data->xcred);
if (err < 0)
{
FREE(&conn->sockdata);
*/
static int tunnel_socket_open(struct Connection *conn)
{
- struct TunnelData *tunnel = NULL;
- int pid;
- int rc;
int pin[2], pout[2];
- tunnel = mutt_mem_malloc(sizeof(struct TunnelData));
+ struct TunnelData *tunnel = mutt_mem_malloc(sizeof(struct TunnelData));
conn->sockdata = tunnel;
mutt_message(_("Connecting with \"%s\"..."), Tunnel);
- rc = pipe(pin);
+ int rc = pipe(pin);
if (rc == -1)
{
mutt_perror("pipe");
}
mutt_sig_block_system();
- pid = fork();
+ int pid = fork();
if (pid == 0)
{
mutt_sig_unblock_system(0);
int mutt_copy_message_ctx(FILE *fpout, struct Context *src, struct Header *hdr,
int flags, int chflags)
{
- struct Message *msg = NULL;
- int r;
-
- msg = mx_open_message(src, hdr->msgno);
+ struct Message *msg = mx_open_message(src, hdr->msgno);
if (!msg)
return -1;
if (!hdr->content)
return -1;
- r = mutt_copy_message_fp(fpout, msg->fp, hdr, flags, chflags);
+ int r = mutt_copy_message_fp(fpout, msg->fp, hdr, flags, chflags);
if ((r == 0) && (ferror(fpout) || feof(fpout)))
{
mutt_debug(1, "failed to detect EOF!\n");
int mutt_append_message(struct Context *dest, struct Context *src,
struct Header *hdr, int cmflags, int chflags)
{
- struct Message *msg = NULL;
- int r;
-
- msg = mx_open_message(src, hdr->msgno);
+ struct Message *msg = mx_open_message(src, hdr->msgno);
if (!msg)
return -1;
- r = append_message(dest, msg->fp, src, hdr, cmflags, chflags);
+ int r = append_message(dest, msg->fp, src, hdr, cmflags, chflags);
mx_close_message(src, &msg);
return r;
}
void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width,
int justify, char pad_char, const char *s, size_t n, int arboreal)
{
- char *p = NULL;
wchar_t wc;
int w;
size_t k, k2;
memset(&mbstate1, 0, sizeof(mbstate1));
memset(&mbstate2, 0, sizeof(mbstate2));
buflen--;
- p = buf;
+ char *p = buf;
for (; n && (k = mbrtowc(&wc, s, n, &mbstate1)); s += k, n -= k)
{
if (k == (size_t)(-1) || k == (size_t)(-2))
if (Context)
{
- int check;
char *new_last_folder = NULL;
#ifdef USE_COMPRESSED
new_last_folder = mutt_str_strdup(Context->path);
*oldcount = Context ? Context->msgcount : 0;
- check = mx_close_mailbox(Context, index_hint);
+ int check = mx_close_mailbox(Context, index_hint);
if (check != 0)
{
if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED)
int newcount = -1;
int oldcount = -1;
int rc = -1;
- struct Menu *menu = NULL;
char *cp = NULL; /* temporary variable. */
int index_hint; /* used to restore cursor position */
bool do_buffy_notify = true;
int close = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
int attach_msg = OPT_ATTACH_MSG;
- menu = mutt_menu_new(MENU_MAIN);
+ struct Menu *menu = mutt_menu_new(MENU_MAIN);
menu->make_entry = index_make_entry;
menu->color = index_color;
menu->current = ci_first_message();
static char **be_snarf_file(const char *path, char **buf, int *max, int *len, int verbose)
{
- FILE *f = NULL;
char tmp[LONG_STRING];
struct stat sb;
- f = fopen(path, "r");
+ FILE *f = fopen(path, "r");
if (f)
{
fstat(fileno(f), &sb);
static int be_barf_file(const char *path, char **buf, int buflen)
{
- FILE *f = NULL;
-
- f = fopen(path, "w");
+ FILE *f = fopen(path, "w");
if (!f)
{
addstr(strerror(errno));
static int is_mmnoask(const char *buf)
{
char *p = NULL;
- const char *val = NULL;
char tmp[LONG_STRING], *q = NULL;
- val = mutt_str_getenv("MM_NOASK");
+ const char *val = mutt_str_getenv("MM_NOASK");
if (val)
{
if (mutt_str_strcmp(val, "1") == 0)
struct ListNode *np;
STAILQ_FOREACH(np, &AlternativeOrderList, entries)
{
- char *c = NULL;
int btlen; /* length of basetype */
bool wild; /* do we have a wildcard to match all subtypes? */
- c = strchr(np->data, '/');
+ char *c = strchr(np->data, '/');
if (c)
{
wild = (c[1] == '*' && c[2] == 0);
static int external_body_handler(struct Body *b, struct State *s)
{
- const char *access_type = NULL;
- const char *expiration = NULL;
- time_t expire;
-
- access_type = mutt_param_get(&b->parameter, "access-type");
+ const char *access_type = mutt_param_get(&b->parameter, "access-type");
if (!access_type)
{
if (s->flags & MUTT_DISPLAY)
return -1;
}
- expiration = mutt_param_get(&b->parameter, "expiration");
+ const char *expiration = mutt_param_get(&b->parameter, "expiration");
+ time_t expire;
if (expiration)
expire = mutt_date_parse_date(expiration, NULL);
else
static int valid_pgp_encrypted_handler(struct Body *b, struct State *s)
{
- int rc;
- struct Body *octetstream = NULL;
-
- octetstream = b->parts->next;
- rc = crypt_pgp_encrypted_handler(octetstream, s);
+ struct Body *octetstream = b->parts->next;
+ int rc = crypt_pgp_encrypted_handler(octetstream, s);
b->goodsig |= octetstream->goodsig;
return rc;
static int malformed_pgp_encrypted_handler(struct Body *b, struct State *s)
{
- int rc;
- struct Body *octetstream = NULL;
-
- octetstream = b->parts->next->next;
+ struct Body *octetstream = b->parts->next->next;
/* exchange encodes the octet-stream, so re-run it through the decoder */
- rc = run_decode_and_handler(octetstream, s, crypt_pgp_encrypted_handler, 0);
+ int rc = run_decode_and_handler(octetstream, s, crypt_pgp_encrypted_handler, 0);
b->goodsig |= octetstream->goodsig;
return rc;
static void *hcache_dump(header_cache_t *h, struct Header *header, int *off,
unsigned int uidvalidity)
{
- unsigned char *d = NULL;
struct Header nh;
bool convert = !CharsetIsUtf8;
*off = 0;
- d = lazy_malloc(sizeof(union Validate));
+ unsigned char *d = lazy_malloc(sizeof(union Validate));
if (uidvalidity == 0)
{
static char *get_foldername(const char *folder)
{
- char *p = NULL;
-
/* if the folder is local, canonify the path to avoid
* to ensure equivalent paths share the hcache */
- p = mutt_mem_malloc(PATH_MAX + 1);
+ char *p = mutt_mem_malloc(PATH_MAX + 1);
if (!realpath(folder, p))
mutt_str_replace(&p, folder);
void *mutt_hcache_fetch(header_cache_t *h, const char *key, size_t keylen)
{
- void *data = NULL;
-
- data = mutt_hcache_fetch_raw(h, key, keylen);
+ void *data = mutt_hcache_fetch_raw(h, key, keylen);
if (!data)
{
return NULL;
unsigned long data, enum FormatFlag flags)
{
struct HdrFormatInfo *hfi = (struct HdrFormatInfo *) data;
- struct Header *hdr = NULL, *htmp = NULL;
- struct Context *ctx = NULL;
char fmt[SHORT_STRING], tmp[LONG_STRING], *p, *tags = NULL;
char *wch = NULL;
int i;
int is_index = (flags & MUTT_FORMAT_INDEX);
size_t colorlen;
- hdr = hfi->hdr;
- ctx = hfi->ctx;
+ struct Header *hdr = hfi->hdr;
+ struct Context *ctx = hfi->ctx;
if (!hdr || !hdr->env)
return src;
if (hdr->env->x_label)
{
i = 1; /* reduce reuse recycle */
- htmp = NULL;
+ struct Header *htmp = NULL;
if (flags & MUTT_FORMAT_TREE && (hdr->thread->prev && hdr->thread->prev->message &&
hdr->thread->prev->message->env->x_label))
{
char path[_POSIX_PATH_MAX]; /* tempfile used to edit headers + body */
char buffer[LONG_STRING];
const char *p = NULL;
- FILE *ifp = NULL, *ofp = NULL;
int i;
struct Envelope *n = NULL;
time_t mtime;
struct stat st;
mutt_mktemp(path, sizeof(path));
- ofp = mutt_file_fopen(path, "w");
+ FILE *ofp = mutt_file_fopen(path, "w");
if (!ofp)
{
mutt_perror(path);
fputc('\n', ofp); /* tie off the header. */
/* now copy the body of the message. */
- ifp = fopen(body, "r");
+ FILE *ifp = fopen(body, "r");
if (!ifp)
{
mutt_perror(body);
static void label_ref_dec(struct Context *ctx, char *label)
{
- struct HashElem *elem = NULL;
- uintptr_t count;
-
- elem = mutt_hash_find_elem(ctx->label_hash, label);
+ struct HashElem *elem = mutt_hash_find_elem(ctx->label_hash, label);
if (!elem)
return;
- count = (uintptr_t) elem->data;
+ uintptr_t count = (uintptr_t) elem->data;
if (count <= 1)
{
mutt_hash_delete(ctx->label_hash, label, NULL);
static void label_ref_inc(struct Context *ctx, char *label)
{
- struct HashElem *elem = NULL;
uintptr_t count;
- elem = mutt_hash_find_elem(ctx->label_hash, label);
+ struct HashElem *elem = mutt_hash_find_elem(ctx->label_hash, label);
if (!elem)
{
count = 1;
{
char t[_POSIX_PATH_MAX];
char buf[SHORT_STRING];
- const char *desc = NULL;
FILE *f = NULL;
- const struct Binding *funcs = NULL;
mutt_mktemp(t, sizeof(t));
- funcs = km_get_table(menu);
- desc = mutt_map_get_name(menu, Menus);
+ const struct Binding *funcs = km_get_table(menu);
+ const char *desc = mutt_map_get_name(menu, Menus);
if (!desc)
desc = _("<UNKNOWN>");
*/
static int dup_hash_dec(struct Hash *dup_hash, char *str)
{
- struct HashElem *elem = NULL;
- uintptr_t count;
-
- elem = mutt_hash_find_elem(dup_hash, str);
+ struct HashElem *elem = mutt_hash_find_elem(dup_hash, str);
if (!elem)
return -1;
- count = (uintptr_t) elem->data;
+ uintptr_t count = (uintptr_t) elem->data;
if (count <= 1)
{
mutt_hash_delete(dup_hash, str, NULL);
*/
static int dup_hash_inc(struct Hash *dup_hash, char *str)
{
- struct HashElem *elem = NULL;
uintptr_t count;
- elem = mutt_hash_find_elem(dup_hash, str);
+ struct HashElem *elem = mutt_hash_find_elem(dup_hash, str);
if (!elem)
{
count = 1;
static void shrink_histfile(void)
{
char tmpfname[_POSIX_PATH_MAX];
- FILE *f = NULL, *tmp = NULL;
+ FILE *tmp = NULL;
int n[HC_LAST] = { 0 };
int line, hclass, read;
char *linebuf = NULL, *p = NULL;
bool regen_file = false;
struct Hash *dup_hashes[HC_LAST] = { 0 };
- f = fopen(HistoryFile, "r");
+ FILE *f = fopen(HistoryFile, "r");
if (!f)
return;
*/
void mutt_hist_read_file(void)
{
- FILE *f = NULL;
int line = 0, hclass, read;
char *linebuf = NULL, *p = NULL;
size_t buflen;
- f = fopen(HistoryFile, "r");
+ FILE *f = fopen(HistoryFile, "r");
if (!f)
return;
*/
static void cmd_parse_capability(struct ImapData *idata, char *s)
{
- char *bracket = NULL;
-
mutt_debug(3, "Handling CAPABILITY\n");
s = imap_next_word(s);
- bracket = strchr(s, ']');
+ char *bracket = strchr(s, ']');
if (bracket)
*bracket = '\0';
FREE(&idata->capstr);
*/
static void cmd_parse_status(struct ImapData *idata, char *s)
{
- char *mailbox = NULL;
char *value = NULL;
struct Buffy *inc = NULL;
struct ImapMbox mx;
short new = 0;
short new_msg_count = 0;
- mailbox = imap_next_word(s);
+ char *mailbox = imap_next_word(s);
/* We need a real tokenizer. */
if (imap_get_literal_count(mailbox, &litlen) == 0)
*/
static int cmd_handle_untagged(struct ImapData *idata)
{
- char *s = NULL;
- char *pn = NULL;
unsigned int count = 0;
-
- s = imap_next_word(idata->buf);
- pn = imap_next_word(s);
+ char *s = imap_next_word(idata->buf);
+ char *pn = imap_next_word(s);
if ((idata->state >= IMAP_SELECTED) && isdigit((unsigned char) *s))
{
{
struct Header **hdrs = NULL;
short oldsort;
- struct Buffer *cmd = NULL;
int pos;
int rc;
int count = 0;
- cmd = mutt_buffer_new();
+ struct Buffer *cmd = mutt_buffer_new();
if (!cmd)
{
mutt_debug(1, "unable to allocate buffer\n");
*/
int imap_fast_trash(struct Context *ctx, char *dest)
{
- struct ImapData *idata = NULL;
char mbox[LONG_STRING];
char mmbox[LONG_STRING];
char prompt[LONG_STRING];
struct Buffer *sync_cmd = NULL;
int err_continue = MUTT_NO;
- idata = ctx->data;
+ struct ImapData *idata = ctx->data;
if (imap_parse_path(dest, &mx))
{
if (rc == IMAP_CMD_NO)
{
- char *s = NULL;
- s = imap_next_word(idata->buf); /* skip seq */
- s = imap_next_word(s); /* Skip response */
+ char *s = imap_next_word(idata->buf); /* skip seq */
+ s = imap_next_word(s); /* Skip response */
mutt_error("%s", s);
goto fail;
}
*/
static int imap_close_mailbox(struct Context *ctx)
{
- struct ImapData *idata = NULL;
-
- idata = ctx->data;
+ struct ImapData *idata = ctx->data;
/* Check to see if the mailbox is actually open */
if (!idata)
return 0;
*/
int imap_sync_mailbox(struct Context *ctx, int expunge)
{
- struct ImapData *idata = NULL;
struct Context *appendctx = NULL;
struct Header *h = NULL;
struct Header **hdrs = NULL;
int oldsort;
int rc;
- idata = ctx->data;
+ struct ImapData *idata = ctx->data;
if (idata->state < IMAP_SELECTED)
{
*/
static int imap_commit_message_tags(struct Context *ctx, struct Header *h, char *tags)
{
- struct ImapData *idata = NULL;
struct Buffer *cmd = NULL;
char uid[11];
- idata = ctx->data;
+ struct ImapData *idata = ctx->data;
if (*tags == '\0')
tags = NULL;
*/
static void update_context(struct ImapData *idata, int oldmsgcount)
{
- struct Context *ctx = NULL;
struct Header *h = NULL;
- ctx = idata->ctx;
+ struct Context *ctx = idata->ctx;
if (!idata->uid_hash)
idata->uid_hash = mutt_hash_int_create(MAX(6 * ctx->msgcount / 5, 30), 0);
*/
static int msg_fetch_header(struct Context *ctx, struct ImapHeader *h, char *buf, FILE *fp)
{
- struct ImapData *idata = NULL;
unsigned int bytes;
int rc = -1; /* default now is that string isn't FETCH response */
int parse_rc;
- idata = ctx->data;
+ struct ImapData *idata = ctx->data;
if (buf[0] != '*')
return rc;
*/
int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned int msn_end)
{
- struct Context *ctx = NULL;
char *hdrreq = NULL;
FILE *fp = NULL;
char tempfile[_POSIX_PATH_MAX];
unsigned int uidnext = 0;
#endif /* USE_HCACHE */
- ctx = idata->ctx;
+ struct Context *ctx = idata->ctx;
if (mutt_bit_isset(idata->capabilities, IMAP4REV1))
{
while (msn_begin <= msn_end && fetch_msn_end < msn_end)
{
- char *cmd = NULL;
- struct Buffer *b = NULL;
-
- b = mutt_buffer_new();
+ struct Buffer *b = mutt_buffer_new();
if (evalhc)
{
/* In case there are holes in the header cache. */
mutt_buffer_printf(b, "%u:%u", msn_begin, msn_end);
fetch_msn_end = msn_end;
+ char *cmd = NULL;
safe_asprintf(&cmd, "FETCH %s (UID FLAGS INTERNALDATE RFC822.SIZE %s)", b->data, hdrreq);
imap_cmd_start(idata, cmd);
FREE(&cmd);
*/
int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno)
{
- struct ImapData *idata = NULL;
- struct Header *h = NULL;
struct Envelope *newenv = NULL;
char buf[LONG_STRING];
char path[_POSIX_PATH_MAX];
bool fetched = false;
int output_progress;
- idata = ctx->data;
- h = ctx->hdrs[msgno];
+ struct ImapData *idata = ctx->data;
+ struct Header *h = ctx->hdrs[msgno];
msg->fp = msg_cache_get(idata, h);
if (msg->fp)
*/
int imap_append_message(struct Context *ctx, struct Message *msg)
{
- struct ImapData *idata = NULL;
FILE *fp = NULL;
char buf[LONG_STRING];
char mbox[LONG_STRING];
struct ImapMbox mx;
int rc;
- idata = ctx->data;
+ struct ImapData *idata = ctx->data;
if (imap_parse_path(ctx->path, &mx))
return -1;
if (rc != IMAP_CMD_RESPOND)
{
- char *pc = NULL;
-
mutt_debug(1, "#1 command failed: %s\n", idata->buf);
- pc = idata->buf + SEQLEN;
+ char *pc = idata->buf + SEQLEN;
SKIPWS(pc);
pc = imap_next_word(pc);
mutt_error("%s", pc);
if (!imap_code(idata->buf))
{
- char *pc = NULL;
-
mutt_debug(1, "#2 command failed: %s\n", idata->buf);
- pc = idata->buf + SEQLEN;
+ char *pc = idata->buf + SEQLEN;
SKIPWS(pc);
pc = imap_next_word(pc);
mutt_error("%s", pc);
*/
int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, int delete)
{
- struct ImapData *idata = NULL;
struct Buffer cmd, sync_cmd;
char mbox[LONG_STRING];
char mmbox[LONG_STRING];
int err_continue = MUTT_NO;
int triedcreate = 0;
- idata = ctx->data;
+ struct ImapData *idata = ctx->data;
if (imap_parse_path(dest, &mx))
{
struct Context *ctx = idata->ctx;
struct ImapHeader newh;
struct ImapHeaderData old_hd;
- struct ImapHeaderData *hd = NULL;
bool readonly;
int local_changes;
local_changes = h->changed;
memset(&newh, 0, sizeof(newh));
- hd = h->data;
+ struct ImapHeaderData *hd = h->data;
newh.data = hd;
memcpy(&old_hd, hd, sizeof(old_hd));
*/
static char *utf7_to_utf8(const char *u7, size_t u7len, char **u8, size_t *u8len)
{
- char *buf = NULL, *p = NULL;
int b, ch, k;
- p = buf = mutt_mem_malloc(u7len + u7len / 8 + 1);
+ char *buf = mutt_mem_malloc(u7len + u7len / 8 + 1);
+ char *p = buf;
for (; u7len; u7++, u7len--)
{
*/
static char *utf8_to_utf7(const char *u8, size_t u8len, char **u7, size_t *u7len)
{
- char *buf = NULL, *p = NULL;
int ch;
int n, b = 0, k = 0;
bool base64 = false;
* In the worst case we convert 2 chars to 7 chars. For example:
* "\x10&\x10&..." -> "&ABA-&-&ABA-&-...".
*/
- p = buf = mutt_mem_malloc((u8len / 2) * 7 + 6);
+ char *buf = mutt_mem_malloc((u8len / 2) * 7 + 6);
+ char *p = buf;
while (u8len)
{
void imap_quote_string(char *dest, size_t dlen, const char *src)
{
static const char quote[] = "\"\\";
- char *pt = NULL;
- const char *s = NULL;
-
- pt = dest;
- s = src;
+ char *pt = dest;
+ const char *s = src;
*pt++ = '"';
/* save room for trailing quote-char */
*/
void imap_munge_mbox_name(struct ImapData *idata, char *dest, size_t dlen, const char *src)
{
- char *buf = NULL;
-
- buf = mutt_str_strdup(src);
+ char *buf = mutt_str_strdup(src);
imap_utf_encode(idata, &buf);
imap_quote_string(dest, dlen, buf);
*/
void imap_unmunge_mbox_name(struct ImapData *idata, char *s)
{
- char *buf = NULL;
-
imap_unquote_string(s);
- buf = mutt_str_strdup(s);
+ char *buf = mutt_str_strdup(s);
if (buf)
{
imap_utf_decode(idata, &buf);
static struct MbTable *parse_mbtable(const char *s)
{
- struct MbTable *t = NULL;
size_t slen, k;
mbstate_t mbstate;
char *d = NULL;
- t = mutt_mem_calloc(1, sizeof(struct MbTable));
+ struct MbTable *t = mutt_mem_calloc(1, sizeof(struct MbTable));
slen = mutt_str_strlen(s);
if (slen == 0)
return t;
{
struct ListNode *n = NULL;
size_t keylen;
- char *p = NULL;
mutt_extract_token(buf, s, MUTT_TOKEN_SPACE | MUTT_TOKEN_QUOTE);
- p = strpbrk(buf->data, ": \t");
+ char *p = strpbrk(buf->data, ": \t");
if (!p || (*p != ':'))
{
mutt_str_strfcpy(err->data, _("invalid header field"), err->dsize);
int mutt_init(int skip_sys_rc, struct ListHead *commands)
{
- const char *p = NULL;
char buffer[LONG_STRING];
int need_pause = 0;
struct Buffer err;
snprintf(AttachmentMarker, sizeof(AttachmentMarker), "\033]9;%" PRIu64 "\a",
mutt_rand64());
- p = mutt_str_getenv("MAIL");
+ const char *p = mutt_str_getenv("MAIL");
if (p)
SpoolFile = mutt_str_strdup(p);
else if ((p = mutt_str_getenv("MAILDIR")))
static struct Keymap *alloc_keys(size_t len, keycode_t *keys)
{
- struct Keymap *p = NULL;
-
- p = mutt_mem_calloc(1, sizeof(struct Keymap));
+ struct Keymap *p = mutt_mem_calloc(1, sizeof(struct Keymap));
p->len = len;
p->keys = mutt_mem_malloc(len * sizeof(keycode_t));
memcpy(p->keys, keys, len * sizeof(keycode_t));
size_t len = max;
char buf[SHORT_STRING];
char c;
- char *s = NULL, *t = NULL;
+ char *t = NULL;
mutt_str_strfcpy(buf, str, sizeof(buf));
- s = buf;
+ char *s = buf;
while (*s && len)
{
int km_bind_err(char *s, int menu, int op, char *macro, char *descr, struct Buffer *err)
{
int retval = 0;
- struct Keymap *map = NULL, *tmp = NULL, *last = NULL, *next = NULL;
+ struct Keymap *last = NULL, *next = NULL;
keycode_t buf[MAX_SEQ];
- size_t len;
size_t pos = 0, lastpos = 0;
- len = parsekeys(s, buf, MAX_SEQ);
+ size_t len = parsekeys(s, buf, MAX_SEQ);
- map = alloc_keys(len, buf);
+ struct Keymap *map = alloc_keys(len, buf);
map->op = op;
map->macro = mutt_str_strdup(macro);
map->descr = mutt_str_strdup(descr);
- tmp = Keymaps[menu];
+ struct Keymap *tmp = Keymaps[menu];
while (tmp)
{
struct Keymap *map = Keymaps[menu];
int pos = 0;
int n = 0;
- int i;
if (!map)
return (retry_generic(menu, NULL, 0, 0));
while (true)
{
- i = Timeout > 0 ? Timeout : 60;
+ int i = Timeout > 0 ? Timeout : 60;
#ifdef USE_IMAP
/* keepalive may need to run more frequently than Timeout allows */
if (ImapKeepalive)
static const char *km_keyname(int c)
{
static char buf[10];
- const char *p = NULL;
- p = mutt_map_get_name(c, KeyNames);
+ const char *p = mutt_map_get_name(c, KeyNames);
if (p)
return p;
void km_error_key(int menu)
{
char buf[SHORT_STRING];
- struct Keymap *key = NULL;
int p, op;
- key = km_find_func(menu, OP_HELP);
+ struct Keymap *key = km_find_func(menu, OP_HELP);
if (!key && (menu != MENU_EDITOR) && (menu != MENU_PAGER))
key = km_find_func(MENU_GENERIC, OP_HELP);
if (!key)
{
struct Buffer buf;
int i = 0;
- char *p = NULL, *q = NULL;
+ char *q = NULL;
mutt_buffer_init(&buf);
/* menu name */
mutt_extract_token(&buf, s, 0);
- p = buf.data;
+ char *p = buf.data;
if (MoreArgs(s))
{
while (i < maxmenus)
struct Buffer *err)
{
const struct Binding *bindings = NULL;
- char *key = NULL;
int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = 0, nummenus;
- key = parse_keymap(menu, s, mutt_array_size(menu), &nummenus, err, true);
+ char *key = parse_keymap(menu, s, mutt_array_size(menu), &nummenus, err, true);
if (!key)
return -1;
{
int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = -1, nummenus;
char *seq = NULL;
- char *key = NULL;
- key = parse_keymap(menu, s, mutt_array_size(menu), &nummenus, err, false);
+ char *key = parse_keymap(menu, s, mutt_array_size(menu), &nummenus, err, false);
if (!key)
return -1;
static int get_user_info(void)
{
- const char *p = NULL;
-
- p = mutt_str_getenv("HOME");
+ const char *p = mutt_str_getenv("HOME");
if (p)
HomeDir = mutt_str_strdup(p);
*/
if (draft_file)
{
- struct Header *context_hdr = NULL;
struct Envelope *opts_env = msg->env;
struct stat st;
/* Set up a "context" header with just enough information so that
* mutt_prepare_template() can parse the message in fin.
*/
- context_hdr = mutt_header_new();
+ struct Header *context_hdr = mutt_header_new();
context_hdr->offset = 0;
context_hdr->content = mutt_body_new();
if (fstat(fileno(fin), &st) != 0)
void mutt_menu_set_current_redraw(int redraw)
{
- struct Menu *current_menu = NULL;
-
- current_menu = get_current_menu();
+ struct Menu *current_menu = get_current_menu();
if (current_menu)
current_menu->redraw |= redraw;
}
void mutt_menu_set_current_redraw_full(void)
{
- struct Menu *current_menu = NULL;
-
- current_menu = get_current_menu();
+ struct Menu *current_menu = get_current_menu();
if (current_menu)
current_menu->redraw = REDRAW_FULL;
}
void mutt_menu_current_redraw()
{
- struct Menu *current_menu = NULL;
-
- current_menu = get_current_menu();
+ struct Menu *current_menu = get_current_menu();
if (current_menu)
{
if (menu_redraw(current_menu) == OP_REDRAW)
static int mh_read_token(char *t, int *first, int *last)
{
- char *p = NULL;
- p = strchr(t, '-');
+ char *p = strchr(t, '-');
if (p)
{
*p++ = '\0';
static int mh_read_sequences(struct MhSequences *mhs, const char *path)
{
- FILE *fp = NULL;
int line = 1;
char *buf = NULL;
char *t = NULL;
char pathname[_POSIX_PATH_MAX];
snprintf(pathname, sizeof(pathname), "%s/.mh_sequences", path);
- fp = fopen(pathname, "r");
+ FILE *fp = fopen(pathname, "r");
if (!fp)
return 0; /* yes, ask callers to silently ignore the error */
void maildir_parse_flags(struct Header *h, const char *path)
{
- char *p = NULL, *q = NULL;
+ char *q = NULL;
h->flagged = false;
h->read = false;
h->replied = false;
- p = strrchr(path, ':');
+ char *p = strrchr(path, ':');
if (p && (mutt_str_strncmp(p + 1, "2,", 2) == 0))
{
p += 3;
struct Header *maildir_parse_message(int magic, const char *fname, bool is_old,
struct Header *h)
{
- FILE *f = NULL;
-
- f = fopen(fname, "r");
+ FILE *f = fopen(fname, "r");
if (f)
{
h = maildir_parse_stream(magic, f, fname, is_old, h);
static struct Maildir *maildir_ins_sort(struct Maildir *list,
int (*cmp)(struct Maildir *, struct Maildir *))
{
- struct Maildir *tmp = NULL, *last = NULL, *ret = NULL, *back = NULL;
+ struct Maildir *tmp = NULL, *last = NULL, *back = NULL;
- ret = list;
+ struct Maildir *ret = list;
list = list->next;
ret->next = NULL;
int count;
int sort = 0;
#ifdef USE_HCACHE
- header_cache_t *hc = NULL;
- void *data = NULL;
const char *key = NULL;
size_t keylen;
- struct timeval *when = NULL;
struct stat lastchanged;
int ret;
#endif
#ifdef USE_HCACHE
- hc = mutt_hcache_open(HeaderCache, ctx->path, NULL);
+ header_cache_t *hc = mutt_hcache_open(HeaderCache, ctx->path, NULL);
#endif
for (p = *md, count = 0; p; p = p->next, count++)
key = p->h->path + 3;
keylen = maildir_hcache_keylen(key);
}
- data = mutt_hcache_fetch(hc, key, keylen);
- when = (struct timeval *) data;
+ void *data = mutt_hcache_fetch(hc, key, keylen);
+ struct timeval *when = (struct timeval *) data;
if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec)
{
static int mh_rewrite_message(struct Context *ctx, int msgno)
{
struct Header *h = ctx->hdrs[msgno];
- struct Message *dest = NULL;
-
- int rc;
bool restore = true;
long old_body_offset = h->content->offset;
long old_body_length = h->content->length;
long old_hdr_lines = h->lines;
- dest = mx_open_new_message(ctx, h, 0);
+ struct Message *dest = mx_open_new_message(ctx, h, 0);
if (!dest)
return -1;
- rc = mutt_copy_message_ctx(dest->fp, ctx, h, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN);
+ int rc = mutt_copy_message_ctx(dest->fp, ctx, h, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN);
if (rc == 0)
{
char oldpath[_POSIX_PATH_MAX];
char fullpath[_POSIX_PATH_MAX];
char oldpath[_POSIX_PATH_MAX];
char suffix[16];
- char *p = NULL;
- p = strrchr(h->path, '/');
+ char *p = strrchr(h->path, '/');
if (!p)
{
mutt_debug(1, "%s: unable to find subdir!\n", h->path);
static char *maildir_canon_filename(char *dest, const char *src, size_t l)
{
- char *t = NULL, *u = NULL;
-
- t = strrchr(src, '/');
+ char *t = strrchr(src, '/');
if (t)
src = t + 1;
mutt_str_strfcpy(dest, src, l);
- u = strrchr(dest, ':');
+ char *u = strrchr(dest, ':');
if (u)
*u = '\0';
char tunique[_POSIX_PATH_MAX];
char fname[LONG_STRING];
- DIR *dp = NULL;
struct dirent *de = NULL;
FILE *fp = NULL;
snprintf(dir, sizeof(dir), "%s/%s", folder, subfolder);
- dp = opendir(dir);
+ DIR *dp = opendir(dir);
if (!dp)
{
errno = ENOENT;
FILE *maildir_open_find_message(const char *folder, const char *msg, char **newname)
{
char unique[_POSIX_PATH_MAX];
- FILE *fp = NULL;
static unsigned int new_hits = 0, cur_hits = 0; /* simple dynamic optimization */
maildir_canon_filename(unique, msg, sizeof(unique));
- fp = md_open_find_message(folder, unique, new_hits > cur_hits ? "new" : "cur", newname);
+ FILE *fp = md_open_find_message(folder, unique, new_hits > cur_hits ? "new" : "cur", newname);
if (fp || (errno != ENOENT))
{
if (new_hits < UINT_MAX && cur_hits < UINT_MAX)
*/
int mh_check_empty(const char *path)
{
- DIR *dp = NULL;
struct dirent *de = NULL;
int r = 1; /* assume empty until we find a message */
- dp = opendir(path);
+ DIR *dp = opendir(path);
if (!dp)
return -1;
while ((de = readdir(dp)))
return;
FREE(&(*a)->personal);
FREE(&(*a)->mailbox);
- FREE(&(*a));
+ FREE(a);
}
/**
*/
int mutt_addr_remove_from_list(struct Address **a, const char *mailbox)
{
- struct Address *p = NULL, *last = NULL, *t = NULL;
int rc = -1;
- p = *a;
- last = NULL;
+ struct Address *p = *a;
+ struct Address *last = NULL;
while (p)
{
if (mutt_str_strcasecmp(mailbox, p->mailbox) == 0)
last->next = p->next;
else
(*a) = p->next;
- t = p;
+ struct Address *t = p;
p = p->next;
free_address(&t);
rc = 0;
const char *ps = NULL;
char comment[LONG_STRING], phrase[LONG_STRING];
size_t phraselen = 0, commentlen = 0;
- struct Address *cur = NULL, *last = NULL;
+ struct Address *cur = NULL;
AddressError = 0;
- last = top;
+ struct Address *last = top;
while (last && last->next)
last = last->next;
*/
struct Address *mutt_addr_parse_list2(struct Address *p, const char *s)
{
- const char *q = NULL;
-
/* check for a simple whitespace separated list of addresses */
- q = strpbrk(s, "\"<>():;,\\");
+ const char *q = strpbrk(s, "\"<>():;,\\");
if (!q)
{
char tmp[HUGE_STRING];
- char *r = NULL;
mutt_str_strfcpy(tmp, s, sizeof(tmp));
- r = tmp;
+ char *r = tmp;
while ((r = strtok(r, " \t")) != NULL)
{
p = mutt_addr_parse_list(p, r);
if (buflen == 0)
goto done;
*pbuf++ = ';';
- buflen--;
}
done:
/* no need to check for length here since we already save space at the
*/
struct Buffer *mutt_buffer_new(void)
{
- struct Buffer *b = NULL;
-
- b = mutt_mem_malloc(sizeof(struct Buffer));
+ struct Buffer *b = mutt_mem_malloc(sizeof(struct Buffer));
mutt_buffer_init(b);
*/
void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name)
{
- char *p = NULL, *ext = NULL;
char in[LONG_STRING], scratch[LONG_STRING];
mutt_str_strfcpy(in, name, sizeof(in));
- ext = strchr(in, '/');
+ char *ext = strchr(in, '/');
if (ext)
*ext++ = '\0';
mutt_str_strfcpy(buf, scratch, buflen);
/* for cosmetics' sake, transform to lowercase. */
- for (p = buf; *p; p++)
+ for (char *p = buf; *p; p++)
*p = tolower(*p);
out:
{
struct FgetConv *fc = NULL;
iconv_t cd = (iconv_t) -1;
- static const char *repls[] = { "\357\277\275", "?", 0 };
if (from && to)
cd = mutt_ch_iconv_open(to, from, flags);
if (cd != (iconv_t) -1)
{
+ static const char *repls[] = { "\357\277\275", "?", 0 };
+
fc = mutt_mem_malloc(sizeof(struct FgetConv));
fc->p = fc->ob = fc->bufo;
fc->ib = fc->bufi;
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
{
int count = 0;
- char *t = NULL;
int hour, min, sec;
struct tm tm;
int i;
mutt_str_strfcpy(scratch, s, sizeof(scratch));
/* kill the day of the week, if it exists. */
- t = strchr(scratch, ',');
+ char *t = strchr(scratch, ',');
if (t)
t++;
else
}
else
{
- struct Tz *tz = NULL;
-
/* This is safe to do: A pointer to a struct equals a pointer to its first element */
- tz = bsearch(ptz, TimeZones, mutt_array_size(TimeZones), sizeof(struct Tz),
- (int (*)(const void *, const void *)) mutt_str_strcasecmp);
+ struct Tz *tz =
+ bsearch(ptz, TimeZones, mutt_array_size(TimeZones), sizeof(struct Tz),
+ (int (*)(const void *, const void *)) mutt_str_strcasecmp);
if (tz)
{
*/
int mutt_file_rmtree(const char *path)
{
- DIR *dirp = NULL;
struct dirent *de = NULL;
char cur[LONG_STRING];
struct stat statbuf;
int rc = 0;
- dirp = opendir(path);
+ DIR *dirp = opendir(path);
if (!dirp)
{
mutt_debug(1, "error opening directory %s\n", path);
*/
char *mutt_file_read_keyword(const char *file, char *buffer, size_t buflen)
{
- FILE *fp = NULL;
- char *start = NULL;
-
- fp = mutt_file_fopen(file, "r");
+ FILE *fp = mutt_file_fopen(file, "r");
if (!fp)
return NULL;
return NULL;
SKIPWS(buffer);
- start = buffer;
+ char *start = buffer;
while (*buffer && !isspace(*buffer))
buffer++;
static struct HashElem *union_hash_insert(struct Hash *table, union HashKey key,
int type, void *data)
{
- struct HashElem *ptr = NULL;
- unsigned int h;
-
- ptr = mutt_mem_malloc(sizeof(struct HashElem));
- h = table->gen_hash(key, table->nelem);
+ struct HashElem *ptr = mutt_mem_malloc(sizeof(struct HashElem));
+ unsigned int h = table->gen_hash(key, table->nelem);
ptr->key = key;
ptr->data = data;
ptr->type = type;
*/
char *mutt_idna_intl_to_local(const char *user, const char *domain, int flags)
{
- char *local_user = NULL, *local_domain = NULL, *mailbox = NULL;
+ char *mailbox = NULL;
char *reversed_user = NULL, *reversed_domain = NULL;
char *tmp = NULL;
-#ifdef HAVE_LIBIDN
- bool is_idn_encoded = false;
-#endif /* HAVE_LIBIDN */
- local_user = mutt_str_strdup(user);
- local_domain = mutt_str_strdup(domain);
+ char *local_user = mutt_str_strdup(user);
+ char *local_domain = mutt_str_strdup(domain);
#ifdef HAVE_LIBIDN
- is_idn_encoded = check_idn(local_domain);
+ bool is_idn_encoded = check_idn(local_domain);
if (is_idn_encoded && IdnDecode)
{
if (idna_to_unicode_8z8z(local_domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
*/
char *mutt_idna_local_to_intl(const char *user, const char *domain)
{
- char *intl_user = NULL, *intl_domain = NULL;
char *mailbox = NULL;
char *tmp = NULL;
- intl_user = mutt_str_strdup(user);
- intl_domain = mutt_str_strdup(domain);
+ char *intl_user = mutt_str_strdup(user);
+ char *intl_domain = mutt_str_strdup(domain);
/* we don't want charset-hook effects, so we set flags to 0 */
if (mutt_ch_convert_string(&intl_user, Charset, "utf-8", 0) == -1)
wchar_t wc;
mbstate_t st;
size_t k;
- wchar_t *wbuf = NULL;
- size_t wbuflen;
-
- wbuf = *pwbuf;
- wbuflen = *pwbuflen;
+ wchar_t *wbuf = *pwbuf;
+ size_t wbuflen = *pwbuflen;
while (*buf)
{
*/
int mutt_mb_filter_unprintable(char **s)
{
- struct Buffer *b = NULL;
wchar_t wc;
size_t k, k2;
char scratch[MB_LEN_MAX + 1];
char *p = *s;
mbstate_t mbstate1, mbstate2;
- b = mutt_buffer_new();
+ struct Buffer *b = mutt_buffer_new();
if (!b)
return -1;
memset(&mbstate1, 0, sizeof(mbstate1));
*/
int mutt_replacelist_remove(struct ReplaceList **rl, const char *pat)
{
- struct ReplaceList *cur = NULL, *prev = NULL;
- int nremoved = 0;
-
/* Being first is a special case. */
- cur = *rl;
+ struct ReplaceList *cur = *rl;
if (!cur)
return 0;
if (cur->regex && (mutt_str_strcmp(cur->regex->pattern, pat) == 0))
return 1;
}
- prev = cur;
+ int nremoved = 0;
+ struct ReplaceList *prev = cur;
for (cur = prev->next; cur;)
{
if (mutt_str_strcmp(cur->regex->pattern, pat) == 0)
int rc = 0;
char *buf = NULL;
size_t bufpos, buflen;
- char *u = NULL, *t0 = NULL, *t1 = NULL, *t = NULL;
+ char *t0 = NULL, *t1 = NULL, *t = NULL;
char *s0 = NULL, *s1 = NULL;
size_t ulen, r, wlen = 0;
encoder_t encoder = NULL;
char *icode = "utf-8";
/* Try to convert to UTF-8. */
- u = mutt_str_substr_dup(d, d + dlen);
+ char *u = mutt_str_substr_dup(d, d + dlen);
if (mutt_ch_convert_string(&u, fromcode, icode, 0))
{
rc = 1;
const char *p = s + n - 1;
size_t len = n;
- if (n <= 0)
+ if (n == 0)
return 0;
if (strchr("\r\n", *p)) /* LWS doesn't end with CRLF */
{
long num = lua_tointeger(l, -1);
opt.var = (void *) num;
- if ((num != MUTT_YES) && (num != MUTT_NO) &&
- (num != MUTT_ASKYES) && (num != MUTT_ASKNO))
+ if ((num != MUTT_YES) && (num != MUTT_NO) && (num != MUTT_ASKYES) && (num != MUTT_ASKNO))
{
luaL_error(l,
"Invalid opt for quad option %s (one of "
static int update_message_path(struct Header *h, const char *path)
{
struct NmHdrData *data = h->data;
- char *p = NULL;
mutt_debug(2, "nm: path update requested path=%s, (%s)\n", path, data->virtual_id);
- p = strrchr(path, '/');
+ char *p = strrchr(path, '/');
if (p && ((p - path) > 3) &&
((strncmp(p - 3, "cur", 3) == 0) || (strncmp(p - 3, "new", 3) == 0) ||
(strncmp(p - 3, "tmp", 3) == 0)))
char filename[_POSIX_PATH_MAX];
char suffix[_POSIX_PATH_MAX];
char folder[_POSIX_PATH_MAX];
- char *p = NULL;
mutt_str_strfcpy(folder, old, sizeof(folder));
- p = strrchr(folder, '/');
+ char *p = strrchr(folder, '/');
if (p)
{
*p = '\0';
bool nm_message_is_still_queried(struct Context *ctx, struct Header *hdr)
{
- char *orig_str = NULL;
char *new_str = NULL;
struct NmCtxData *data = get_ctxdata(ctx);
- notmuch_database_t *db = NULL;
- notmuch_query_t *q = NULL;
bool result = false;
- db = get_db(data, false);
- orig_str = get_query_string(data, true);
+ notmuch_database_t *db = get_db(data, false);
+ char *orig_str = get_query_string(data, true);
if (!db || !orig_str)
return false;
mutt_debug(2, "nm: checking if message is still queried: %s\n", new_str);
- q = notmuch_query_create(db, new_str);
+ notmuch_query_t *q = notmuch_query_create(db, new_str);
switch (data->query_type)
{
*/
struct Connection *mutt_conn_find(const struct Connection *start, const struct Account *account)
{
- struct Connection *conn = NULL;
struct Url url;
char hook[LONG_STRING];
url_tostring(&url, hook, sizeof(hook), 0);
mutt_account_hook(hook);
- conn = start ? TAILQ_NEXT(start, entries) : TAILQ_FIRST(&Connections);
+ struct Connection *conn = start ? TAILQ_NEXT(start, entries) : TAILQ_FIRST(&Connections);
while (conn)
{
if (mutt_account_match(account, &(conn->account)))
case '@':
{
- struct Header *h = NULL;
- struct Address *alias = NULL;
-
- alias = mutt_alias_lookup(s + 1);
+ struct Address *alias = mutt_alias_lookup(s + 1);
if (alias)
{
- h = mutt_header_new();
+ struct Header *h = mutt_header_new();
h->env = mutt_env_new();
h->env->from = h->env->to = alias;
mutt_default_save(p, sizeof(p), h);
mutt_str_strfcpy(d, a->mailbox, dsize);
if (!SaveAddress)
{
- char *p = NULL;
-
- p = strpbrk(d, "%@");
+ char *p = strpbrk(d, "%@");
if (p)
*p = 0;
}
char prefix[SHORT_STRING], tmp[LONG_STRING], *cp = NULL, *wptr = buf, ch;
char if_str[SHORT_STRING], else_str[SHORT_STRING];
size_t wlen, count, len, wid;
- pid_t pid;
FILE *filter = NULL;
char *recycler = NULL;
/* n-off is the number of backslashes. */
if (off > 0 && ((n - off) % 2) == 0)
{
- struct Buffer *srcbuf = NULL, *word = NULL, *command = NULL;
char srccopy[LONG_STRING];
int i = 0;
srccopy[n - 1] = '\0';
/* prepare BUFFERs */
- srcbuf = mutt_buffer_from(srccopy);
+ struct Buffer *srcbuf = mutt_buffer_from(srccopy);
srcbuf->dptr = srcbuf->data;
- word = mutt_buffer_new();
- command = mutt_buffer_new();
+ struct Buffer *word = mutt_buffer_new();
+ struct Buffer *command = mutt_buffer_new();
/* Iterate expansions across successive arguments */
do
col -= wlen; /* reset to passed in value */
wptr = buf; /* reset write ptr */
- pid = mutt_create_filter(command->data, NULL, &filter, NULL);
+ pid_t pid = mutt_create_filter(command->data, NULL, &filter, NULL);
if (pid != -1)
{
int rc;
int mx_close_mailbox(struct Context *ctx, int *index_hint)
{
int i, move_messages = 0, purge = 1, read_msgs = 0;
- int check;
struct Context f;
char mbox[_POSIX_PATH_MAX];
char buf[SHORT_STRING];
/* allow IMAP to preserve the deleted flag across sessions */
if (ctx->magic == MUTT_IMAP)
{
- check = imap_sync_mailbox(ctx, purge);
+ int check = imap_sync_mailbox(ctx, purge);
if (check != 0)
{
ctx->closing = false;
if (ctx->changed || ctx->deleted)
{
- check = sync_mailbox(ctx, index_hint);
+ int check = sync_mailbox(ctx, index_hint);
if (check != 0)
{
ctx->closing = false;
const char **ppl, const char **pps)
{
const char *ps = NULL, *pl = NULL, *phint = NULL;
- char *pfcopy = NULL, *pf = NULL, *s1 = NULL, *s2 = NULL;
+ char *pfcopy = NULL, *s1 = NULL, *s2 = NULL;
char c;
int isid;
size_t hexdigits;
* if an ID was found and to simplify logic in the key loop's inner
* condition of the caller. */
- pf = mutt_str_skip_whitespace(p);
+ char *pf = mutt_str_skip_whitespace(p);
if (mutt_str_strncasecmp(pf, "0x", 2) == 0)
pf += 2;
*/
static void print_utf8(FILE *fp, const char *buf, size_t len)
{
- char *tstr = NULL;
-
- tstr = mutt_mem_malloc(len + 1);
+ char *tstr = mutt_mem_malloc(len + 1);
memcpy(tstr, buf, len);
tstr[len] = 0;
static gpgme_data_t body_to_data_object(struct Body *a, int convert)
{
char tempfile[_POSIX_PATH_MAX];
- FILE *fptmp = NULL;
int err = 0;
gpgme_data_t data;
mutt_mktemp(tempfile, sizeof(tempfile));
- fptmp = mutt_file_fopen(tempfile, "w+");
+ FILE *fptmp = mutt_file_fopen(tempfile, "w+");
if (!fptmp)
{
mutt_perror(tempfile);
*/
struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, int sign)
{
- char *outfile = NULL;
- struct Body *t = NULL;
- gpgme_key_t *rset = NULL;
- gpgme_data_t plaintext;
-
- rset = create_recipient_set(keylist, GPGME_PROTOCOL_OpenPGP);
+ gpgme_key_t *rset = create_recipient_set(keylist, GPGME_PROTOCOL_OpenPGP);
if (!rset)
return NULL;
if (sign)
convert_to_7bit(a);
- plaintext = body_to_data_object(a, 0);
+ gpgme_data_t plaintext = body_to_data_object(a, 0);
if (!plaintext)
{
free_recipient_set(&rset);
return NULL;
}
- outfile = encrypt_gpgme_object(plaintext, rset, 0, sign);
+ char *outfile = encrypt_gpgme_object(plaintext, rset, 0, sign);
gpgme_data_release(plaintext);
free_recipient_set(&rset);
if (!outfile)
return NULL;
- t = mutt_body_new();
+ struct Body *t = mutt_body_new();
t->type = TYPEMULTIPART;
t->subtype = mutt_str_strdup("encrypted");
t->encoding = ENC7BIT;
*/
struct Body *smime_gpgme_build_smime_entity(struct Body *a, char *keylist)
{
- char *outfile = NULL;
- struct Body *t = NULL;
- gpgme_key_t *rset = NULL;
- gpgme_data_t plaintext;
-
- rset = create_recipient_set(keylist, GPGME_PROTOCOL_CMS);
+ gpgme_key_t *rset = create_recipient_set(keylist, GPGME_PROTOCOL_CMS);
if (!rset)
return NULL;
* clients depend on this for signed+encrypted messages: they do not
* convert line endings between decrypting and checking the
* signature. See #3904. */
- plaintext = body_to_data_object(a, 1);
+ gpgme_data_t plaintext = body_to_data_object(a, 1);
if (!plaintext)
{
free_recipient_set(&rset);
return NULL;
}
- outfile = encrypt_gpgme_object(plaintext, rset, 1, 0);
+ char *outfile = encrypt_gpgme_object(plaintext, rset, 1, 0);
gpgme_data_release(plaintext);
free_recipient_set(&rset);
if (!outfile)
return NULL;
- t = mutt_body_new();
+ struct Body *t = mutt_body_new();
t->type = TYPEAPPLICATION;
t->subtype = mutt_str_strdup("pkcs7-mime");
mutt_param_set(&t->parameter, "name", "smime.p7m");
*/
static void show_one_sig_validity(gpgme_ctx_t ctx, int idx, struct State *s)
{
- gpgme_verify_result_t result = NULL;
gpgme_signature_t sig = NULL;
const char *txt = NULL;
- result = gpgme_op_verify_result(ctx);
+ gpgme_verify_result_t result = gpgme_op_verify_result(ctx);
if (result)
for (sig = result->signatures; sig && (idx > 0); sig = sig->next, idx--)
;
void pgp_gpgme_invoke_import(const char *fname)
{
gpgme_data_t keydata;
- gpgme_error_t err;
- FILE *in = NULL;
FILE *out = NULL;
- in = mutt_file_fopen(fname, "r");
+ FILE *in = mutt_file_fopen(fname, "r");
if (!in)
return;
/* Note that the stream, "in", needs to be kept open while the keydata
* is used.
*/
- err = gpgme_data_new_from_stream(&keydata, in);
+ gpgme_error_t err = gpgme_data_new_from_stream(&keydata, in);
if (err != GPG_ERR_NO_ERROR)
{
mutt_file_fclose(&in);
{
char buf[HUGE_STRING];
bool complete, armor_header;
- struct FgetConv *fc = NULL;
- char *fname = NULL;
FILE *fp = NULL;
- fname = data_object_to_tempfile(data, NULL, &fp);
+ char *fname = data_object_to_tempfile(data, NULL, &fp);
if (!fname)
{
mutt_file_fclose(&fp);
* be a wrong label, so we want the ability to do corrections via
* charset-hooks. Therefore we set flags to MUTT_ICONV_HOOK_FROM.
*/
- fc = mutt_ch_fgetconv_open(fp, charset, Charset, MUTT_ICONV_HOOK_FROM);
+ struct FgetConv *fc = mutt_ch_fgetconv_open(fp, charset, Charset, MUTT_ICONV_HOOK_FROM);
for (complete = true, armor_header = true; mutt_ch_fgetconvs(buf, sizeof(buf), fc) != NULL;
complete = (strchr(buf, '\n') != NULL))
bool pgp_keyblock = false;
bool clearsign = false;
long bytes;
- LOFF_T last_pos, offset;
+ LOFF_T last_pos;
char buf[HUGE_STRING];
FILE *pgpout = NULL;
if (fgets(buf, sizeof(buf), s->fpin) == NULL)
break;
- offset = ftello(s->fpin);
+ LOFF_T offset = ftello(s->fpin);
bytes -= (offset - last_pos); /* don't rely on mutt_str_strlen(buf) */
last_pos = offset;
}
else if (pgpout)
{
- struct FgetConv *fc = NULL;
int c;
rewind(pgpout);
- fc = mutt_ch_fgetconv_open(pgpout, "utf-8", Charset, 0);
+ struct FgetConv *fc = mutt_ch_fgetconv_open(pgpout, "utf-8", Charset, 0);
while ((c = mutt_ch_fgetconv(fc)) != EOF)
{
state_putc(c, s);
int pgp_gpgme_encrypted_handler(struct Body *a, struct State *s)
{
char tempfile[_POSIX_PATH_MAX];
- FILE *fpout = NULL;
- struct Body *tattach = NULL;
int is_signed;
int rc = 0;
mutt_debug(2, "Entering handler\n");
mutt_mktemp(tempfile, sizeof(tempfile));
- fpout = mutt_file_fopen(tempfile, "w+");
+ FILE *fpout = mutt_file_fopen(tempfile, "w+");
if (!fpout)
{
if (s->flags & MUTT_DISPLAY)
return -1;
}
- tattach = decrypt_part(a, s, fpout, 0, &is_signed);
+ struct Body *tattach = decrypt_part(a, s, fpout, 0, &is_signed);
if (tattach)
{
tattach->goodsig = is_signed > 0;
int smime_gpgme_application_handler(struct Body *a, struct State *s)
{
char tempfile[_POSIX_PATH_MAX];
- FILE *fpout = NULL;
- struct Body *tattach = NULL;
int is_signed;
int rc = 0;
a->warnsig = false;
mutt_mktemp(tempfile, sizeof(tempfile));
- fpout = mutt_file_fopen(tempfile, "w+");
+ FILE *fpout = mutt_file_fopen(tempfile, "w+");
if (!fpout)
{
if (s->flags & MUTT_DISPLAY)
return -1;
}
- tattach = decrypt_part(a, s, fpout, 1, &is_signed);
+ struct Body *tattach = decrypt_part(a, s, fpout, 1, &is_signed);
if (tattach)
{
tattach->goodsig = is_signed > 0;
unsigned long data, enum FormatFlag flags)
{
char fmt[SHORT_STRING];
- struct CryptEntry *entry = NULL;
- struct CryptKeyInfo *key = NULL;
int kflags = 0;
int optional = (flags & MUTT_FORMAT_OPTIONAL);
const char *s = NULL;
- entry = (struct CryptEntry *) data;
- key = entry->key;
+ struct CryptEntry *entry = (struct CryptEntry *) data;
+ struct CryptKeyInfo *key = entry->key;
/* if (isupper ((unsigned char) op)) */
/* key = pkey; */
case '[':
{
- const char *cp = NULL;
- char buf2[SHORT_STRING], *p = NULL;
+ char buf2[SHORT_STRING];
int do_locales;
struct tm *tm = NULL;
size_t len;
- p = buf;
+ char *p = buf;
- cp = src;
+ const char *cp = src;
if (*cp == '!')
{
do_locales = 0;
if (arrayidx >= arraysize)
{
/* neomutt lacks a real mutt_mem_realloc - so we need to copy */
- struct DnArray *a2 = NULL;
-
arraysize += 5;
- a2 = mutt_mem_malloc((arraysize + 1) * sizeof(*array));
+ struct DnArray *a2 = mutt_mem_malloc((arraysize + 1) * sizeof(*array));
for (int i = 0; i < arrayidx; i++)
{
a2[i].key = array[i].key;
*/
static void verify_key(struct CryptKeyInfo *key)
{
- FILE *fp = NULL;
char cmd[LONG_STRING], tempfile[_POSIX_PATH_MAX];
const char *s = NULL;
gpgme_ctx_t listctx = NULL;
int maxdepth = 100;
mutt_mktemp(tempfile, sizeof(tempfile));
- fp = mutt_file_fopen(tempfile, "w");
+ FILE *fp = mutt_file_fopen(tempfile, "w");
if (!fp)
{
mutt_perror(_("Can't create temporary file"));
static struct CryptKeyInfo *get_candidates(struct ListHead *hints, unsigned int app, int secret)
{
struct CryptKeyInfo *db = NULL, *k = NULL, **kend = NULL;
- char *pattern = NULL;
gpgme_error_t err;
gpgme_ctx_t ctx;
gpgme_key_t key;
int idx;
gpgme_user_id_t uid = NULL;
- pattern = list_to_pattern(hints);
+ char *pattern = list_to_pattern(hints);
if (!pattern)
return NULL;
*/
static void crypt_add_string_to_hints(struct ListHead *hints, const char *str)
{
- char *scratch = NULL;
- char *t = NULL;
-
- scratch = mutt_str_strdup(str);
+ char *scratch = mutt_str_strdup(str);
if (!scratch)
return;
- for (t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n"))
+ for (char *t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n"))
{
if (strlen(t) > 3)
mutt_list_insert_tail(hints, mutt_str_strdup(t));
unsigned int app, int *forced_valid)
{
int keymax;
- struct CryptKeyInfo **key_table = NULL;
- struct Menu *menu = NULL;
int i;
bool done = false;
char helpstr[LONG_STRING], buf[LONG_STRING];
/* build the key table */
keymax = i = 0;
- key_table = NULL;
+ struct CryptKeyInfo **key_table = NULL;
for (k = keys; k; k = k->next)
{
if (!PgpShowUnusable && (k->flags & KEYFLAG_CANTUSE))
mutt_make_help(buf, sizeof(buf), _("Help"), menu_to_use, OP_HELP);
strcat(helpstr, buf);
- menu = mutt_menu_new(menu_to_use);
+ struct Menu *menu = mutt_menu_new(menu_to_use);
menu->max = i;
menu->make_entry = crypt_entry;
menu->help = helpstr;
unsigned int app, int *forced_valid)
{
struct ListHead hints = STAILQ_HEAD_INITIALIZER(hints);
- struct CryptKeyInfo *keys = NULL;
struct CryptKeyInfo *matches = NULL;
struct CryptKeyInfo **matches_endp = &matches;
struct CryptKeyInfo *k = NULL;
- const char *ps = NULL, *pl = NULL, *pfcopy = NULL, *phint = NULL;
+ const char *ps = NULL, *pl = NULL, *phint = NULL;
mutt_message(_("Looking for keys matching \"%s\"..."), p);
*forced_valid = 0;
- pfcopy = crypt_get_fingerprint_or_id(p, &phint, &pl, &ps);
+ const char *pfcopy = crypt_get_fingerprint_or_id(p, &phint, &pl, &ps);
crypt_add_string_to_hints(&hints, phint);
- keys = get_candidates(&hints, app, (abilities & KEYFLAG_CANSIGN));
+ struct CryptKeyInfo *keys = get_candidates(&hints, app, (abilities & KEYFLAG_CANSIGN));
mutt_list_free(&hints);
if (!keys)
#ifdef HAVE_GPGME_OP_EXPORT_KEYS
struct Body *pgp_gpgme_make_key_attachment(char *tempf)
{
- struct CryptKeyInfo *key = NULL;
gpgme_ctx_t context = NULL;
gpgme_key_t export_keys[2];
gpgme_data_t keydata = NULL;
OPT_PGP_CHECK_TRUST = false;
- key = crypt_ask_for_key(_("Please enter the key ID: "), NULL, 0, APPLICATION_PGP, NULL);
+ struct CryptKeyInfo *key = crypt_ask_for_key(_("Please enter the key ID: "), NULL, 0, APPLICATION_PGP, NULL);
if (!key)
goto bail;
export_keys[0] = key->kobj;
if (chs && (cd = mutt_ch_iconv_open(chs, "utf-8", 0)) != (iconv_t) -1)
{
int n = s - uid + 1; /* chars available in original buffer */
- char *buf = NULL;
- const char *ib = NULL;
- char *ob = NULL;
- size_t ibl, obl;
-
- buf = mutt_mem_malloc(n + 1);
- ib = uid;
- ibl = d - uid + 1;
- ob = buf;
- obl = n;
+
+ char *buf = mutt_mem_malloc(n + 1);
+ const char *ib = uid;
+ size_t ibl = d - uid + 1;
+ char *ob = buf;
+ size_t obl = n;
iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl);
if (!ibl)
{
*/
char *pgp_fpr_or_lkeyid(struct PgpKeyInfo *k)
{
- char *fingerprint = NULL;
-
- fingerprint = pgp_fingerprint(k);
+ char *fingerprint = pgp_fingerprint(k);
return fingerprint ? fingerprint : pgp_long_keyid(k);
}
char buf[HUGE_STRING];
bool complete, armor_header;
- struct FgetConv *fc = NULL;
-
rewind(fpin);
/* fromcode comes from the MIME Content-Type charset label. It might
* be a wrong label, so we want the ability to do corrections via
* charset-hooks. Therefore we set flags to MUTT_ICONV_HOOK_FROM.
*/
- fc = mutt_ch_fgetconv_open(fpin, charset, Charset, MUTT_ICONV_HOOK_FROM);
+ struct FgetConv *fc = mutt_ch_fgetconv_open(fpin, charset, Charset, MUTT_ICONV_HOOK_FROM);
for (complete = true, armor_header = true; mutt_ch_fgetconvs(buf, sizeof(buf), fc) != NULL;
complete = (strchr(buf, '\n') != NULL))
int pgp_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile)
{
char sigfile[_POSIX_PATH_MAX], pgperrfile[_POSIX_PATH_MAX];
- FILE *fp = NULL, *pgpout = NULL, *pgperr = NULL;
+ FILE *pgpout = NULL, *pgperr = NULL;
pid_t thepid;
int badsig = -1;
snprintf(sigfile, sizeof(sigfile), "%s.asc", tempfile);
- fp = mutt_file_fopen(sigfile, "w");
+ FILE *fp = mutt_file_fopen(sigfile, "w");
if (!fp)
{
mutt_perror(sigfile);
static void pgp_extract_keys_from_attachment(FILE *fp, struct Body *top)
{
struct State s;
- FILE *tempfp = NULL;
char tempfname[_POSIX_PATH_MAX];
mutt_mktemp(tempfname, sizeof(tempfname));
- tempfp = mutt_file_fopen(tempfname, "w");
+ FILE *tempfp = mutt_file_fopen(tempfname, "w");
if (!tempfp)
{
mutt_perror(tempfname);
return NULL;
char buf[LONG_STRING];
- FILE *pgpin = NULL, *pgpout = NULL, *pgperr = NULL, *pgptmp = NULL;
+ FILE *pgpin = NULL, *pgpout = NULL, *pgptmp = NULL;
struct stat info;
struct Body *tattach = NULL;
char pgperrfile[_POSIX_PATH_MAX];
int rv;
mutt_mktemp(pgperrfile, sizeof(pgperrfile));
- pgperr = mutt_file_fopen(pgperrfile, "w+");
+ FILE *pgperr = mutt_file_fopen(pgperrfile, "w+");
if (!pgperr)
{
mutt_perror(pgperrfile);
int pgp_encrypted_handler(struct Body *a, struct State *s)
{
char tempfile[_POSIX_PATH_MAX];
- FILE *fpout = NULL, *fpin = NULL;
+ FILE *fpin = NULL;
struct Body *tattach = NULL;
int rc = 0;
mutt_mktemp(tempfile, sizeof(tempfile));
- fpout = mutt_file_fopen(tempfile, "w+");
+ FILE *fpout = mutt_file_fopen(tempfile, "w+");
if (!fpout)
{
if (s->flags & MUTT_DISPLAY)
struct Body *t = NULL;
char buffer[LONG_STRING];
char sigfile[_POSIX_PATH_MAX], signedfile[_POSIX_PATH_MAX];
- FILE *pgpin = NULL, *pgpout = NULL, *pgperr = NULL, *fp = NULL, *sfp = NULL;
+ FILE *pgpin = NULL, *pgpout = NULL, *pgperr = NULL, *sfp = NULL;
bool err = false;
bool empty = true;
pid_t thepid;
convert_to_7bit(a); /* Signed data _must_ be in 7-bit format. */
mutt_mktemp(sigfile, sizeof(sigfile));
- fp = mutt_file_fopen(sigfile, "w");
+ FILE *fp = mutt_file_fopen(sigfile, "w");
if (!fp)
{
return NULL;
char buf[LONG_STRING];
char tempfile[_POSIX_PATH_MAX], pgperrfile[_POSIX_PATH_MAX];
char pgpinfile[_POSIX_PATH_MAX];
- FILE *pgpin = NULL, *pgperr = NULL, *fpout = NULL, *fptmp = NULL;
+ FILE *pgpin = NULL, *pgperr = NULL, *fptmp = NULL;
struct Body *t = NULL;
int err = 0;
int empty = 0;
pid_t thepid;
mutt_mktemp(tempfile, sizeof(tempfile));
- fpout = mutt_file_fopen(tempfile, "w+");
+ FILE *fpout = mutt_file_fopen(tempfile, "w+");
if (!fpout)
{
mutt_perror(tempfile);
unsigned long data, enum FormatFlag flags)
{
char fmt[SHORT_STRING];
- struct PgpEntry *entry = NULL;
- struct PgpUid *uid = NULL;
- struct PgpKeyInfo *key = NULL, *pkey = NULL;
int kflags = 0;
int optional = (flags & MUTT_FORMAT_OPTIONAL);
- entry = (struct PgpEntry *) data;
- uid = entry->uid;
- key = uid->parent;
- pkey = pgp_principal_key(key);
+ struct PgpEntry *entry = (struct PgpEntry *) data;
+ struct PgpUid *uid = entry->uid;
+ struct PgpKeyInfo *key = uid->parent;
+ struct PgpKeyInfo *pkey = pgp_principal_key(key);
if (isupper((unsigned char) op))
key = pkey;
case '[':
{
- const char *cp = NULL;
- char buf2[SHORT_STRING], *p = NULL;
+ char buf2[SHORT_STRING];
int do_locales;
struct tm *tm = NULL;
size_t len;
- p = buf;
+ char *p = buf;
- cp = src;
+ const char *cp = src;
if (*cp == '!')
{
do_locales = 0;
FILE *devnull = NULL;
struct stat sb;
pid_t thepid;
- struct PgpKeyInfo *key = NULL;
OPT_PGP_CHECK_TRUST = false;
- key = pgp_ask_for_key(_("Please enter the key ID: "), NULL, 0, PGP_PUBRING);
+ struct PgpKeyInfo *key = pgp_ask_for_key(_("Please enter the key ID: "), NULL, 0, PGP_PUBRING);
if (!key)
return NULL;
static void pgp_add_string_to_hints(struct ListHead *hints, const char *str)
{
- char *scratch = NULL;
- char *t = NULL;
-
- scratch = mutt_str_strdup(str);
+ char *scratch = mutt_str_strdup(str);
if (!scratch)
return;
- for (t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n"))
+ for (char *t = strtok(scratch, " ,.:\"()<>\n"); t; t = strtok(NULL, " ,.:\"()<>\n"))
{
if (strlen(t) > 3)
mutt_list_insert_tail(hints, mutt_str_strdup(t));
static short pgp_find_hash(const char *fname)
{
- FILE *in = NULL;
- FILE *out = NULL;
-
char tempfile[_POSIX_PATH_MAX];
-
- unsigned char *p = NULL;
size_t l;
-
short rc = -1;
mutt_mktemp(tempfile, sizeof(tempfile));
- out = mutt_file_fopen(tempfile, "w+");
+ FILE *out = mutt_file_fopen(tempfile, "w+");
if (!out)
{
mutt_perror(tempfile);
}
unlink(tempfile);
- in = fopen(fname, "r");
+ FILE *in = fopen(fname, "r");
if (!in)
{
mutt_perror(fname);
pgp_dearmor(in, out);
rewind(out);
- p = pgp_read_packet(out, &l);
+ unsigned char *p = pgp_read_packet(out, &l);
if (p)
{
rc = pgp_mic_from_packet(p, l);
{
if (*used + material >= plen)
{
- unsigned char *p = NULL;
- size_t nplen;
+ size_t nplen = *used + material + CHUNKSIZE;
- nplen = *used + material + CHUNKSIZE;
-
- p = realloc(pbuf, nplen);
+ unsigned char *p = realloc(pbuf, nplen);
if (!p)
{
perror("realloc");
static struct SmimeKey *smime_parse_key(char *buf)
{
- struct SmimeKey *key = NULL;
char *pend = NULL, *p = NULL;
int field = 0;
- key = mutt_mem_calloc(1, sizeof(struct SmimeKey));
+ struct SmimeKey *key = mutt_mem_calloc(1, sizeof(struct SmimeKey));
for (p = buf; p; p = pend)
{
static struct SmimeKey *smime_get_candidates(char *search, short public)
{
char index_file[_POSIX_PATH_MAX];
- FILE *fp = NULL;
char buf[LONG_STRING];
- struct SmimeKey *key = NULL, *results = NULL, **results_end = NULL;
-
- results = NULL;
- results_end = &results;
+ struct SmimeKey *key = NULL, *results = NULL;
+ struct SmimeKey **results_end = &results;
snprintf(index_file, sizeof(index_file), "%s/.index",
public ? NONULL(SmimeCertificates) : NONULL(SmimeKeys));
- fp = mutt_file_fopen(index_file, "r");
+ FILE *fp = mutt_file_fopen(index_file, "r");
if (!fp)
{
mutt_perror(index_file);
*/
static struct SmimeKey *smime_get_key_by_hash(char *hash, short public)
{
- struct SmimeKey *results = NULL, *result = NULL;
struct SmimeKey *match = NULL;
-
- results = smime_get_candidates(hash, public);
- for (result = results; result; result = result->next)
+ struct SmimeKey *results = smime_get_candidates(hash, public);
+ for (struct SmimeKey *result = results; result; result = result->next)
{
if (mutt_str_strcasecmp(hash, result->hash) == 0)
{
*/
static void getkeys(char *mailbox)
{
- struct SmimeKey *key = NULL;
char *k = NULL;
- key = smime_get_key_by_addr(mailbox, KEYFLAG_CANENCRYPT, 0, 1);
+ struct SmimeKey *key = smime_get_key_by_addr(mailbox, KEYFLAG_CANENCRYPT, 0, 1);
if (!key)
{
static int smime_handle_cert_email(char *certificate, char *mailbox, int copy,
char ***buffer, int *num)
{
- FILE *fpout = NULL, *fperr = NULL;
char tmpfname[_POSIX_PATH_MAX];
char email[STRING];
int rc = -1, count = 0;
size_t len = 0;
mutt_mktemp(tmpfname, sizeof(tmpfname));
- fperr = mutt_file_fopen(tmpfname, "w+");
+ FILE *fperr = mutt_file_fopen(tmpfname, "w+");
if (!fperr)
{
mutt_perror(tmpfname);
mutt_file_unlink(tmpfname);
mutt_mktemp(tmpfname, sizeof(tmpfname));
- fpout = mutt_file_fopen(tmpfname, "w+");
+ FILE *fpout = mutt_file_fopen(tmpfname, "w+");
if (!fpout)
{
mutt_file_fclose(&fperr);
static char *smime_extract_certificate(char *infile)
{
- FILE *fpout = NULL, *fperr = NULL;
char pk7out[_POSIX_PATH_MAX], certfile[_POSIX_PATH_MAX];
char tmpfname[_POSIX_PATH_MAX];
pid_t thepid;
int empty;
mutt_mktemp(tmpfname, sizeof(tmpfname));
- fperr = mutt_file_fopen(tmpfname, "w+");
+ FILE *fperr = mutt_file_fopen(tmpfname, "w+");
if (!fperr)
{
mutt_perror(tmpfname);
mutt_file_unlink(tmpfname);
mutt_mktemp(pk7out, sizeof(pk7out));
- fpout = mutt_file_fopen(pk7out, "w+");
+ FILE *fpout = mutt_file_fopen(pk7out, "w+");
if (!fpout)
{
mutt_file_fclose(&fperr);
static char *smime_extract_signer_certificate(char *infile)
{
- FILE *fpout = NULL, *fperr = NULL;
char certfile[_POSIX_PATH_MAX];
char tmpfname[_POSIX_PATH_MAX];
pid_t thepid;
int empty;
mutt_mktemp(tmpfname, sizeof(tmpfname));
- fperr = mutt_file_fopen(tmpfname, "w+");
+ FILE *fperr = mutt_file_fopen(tmpfname, "w+");
if (!fperr)
{
mutt_perror(tmpfname);
mutt_file_unlink(tmpfname);
mutt_mktemp(certfile, sizeof(certfile));
- fpout = mutt_file_fopen(certfile, "w+");
+ FILE *fpout = mutt_file_fopen(certfile, "w+");
if (!fpout)
{
mutt_file_fclose(&fperr);
void smime_invoke_import(char *infile, char *mailbox)
{
char tmpfname[_POSIX_PATH_MAX], *certfile = NULL, buf[STRING];
- FILE *smimein = NULL, *fpout = NULL, *fperr = NULL;
- pid_t thepid = -1;
+ FILE *smimein = NULL;
mutt_mktemp(tmpfname, sizeof(tmpfname));
- fperr = mutt_file_fopen(tmpfname, "w+");
+ FILE *fperr = mutt_file_fopen(tmpfname, "w+");
if (!fperr)
{
mutt_perror(tmpfname);
mutt_file_unlink(tmpfname);
mutt_mktemp(tmpfname, sizeof(tmpfname));
- fpout = mutt_file_fopen(tmpfname, "w+");
+ FILE *fpout = mutt_file_fopen(tmpfname, "w+");
if (!fpout)
{
mutt_file_fclose(&fperr);
{
mutt_endwin();
- thepid = smime_invoke(&smimein, NULL, NULL, -1, fileno(fpout), fileno(fperr), certfile,
+ pid_t thepid = smime_invoke(&smimein, NULL, NULL, -1, fileno(fpout), fileno(fperr), certfile,
NULL, NULL, NULL, NULL, NULL, NULL, SmimeImportCertCommand);
if (thepid == -1)
{
int smime_verify_sender(struct Header *h)
{
char *mbox = NULL, *certfile = NULL, tempfname[_POSIX_PATH_MAX];
- FILE *fpout = NULL;
int retval = 1;
mutt_mktemp(tempfname, sizeof(tempfname));
- fpout = mutt_file_fopen(tempfname, "w");
+ FILE *fpout = mutt_file_fopen(tempfname, "w");
if (!fpout)
{
mutt_perror(tempfname);
char tempfile[_POSIX_PATH_MAX], smimeerrfile[_POSIX_PATH_MAX];
char smimeinfile[_POSIX_PATH_MAX];
char *cert_start, *cert_end;
- FILE *smimein = NULL, *smimeerr = NULL, *fpout = NULL, *fptmp = NULL;
- struct Body *t = NULL;
+ FILE *smimein = NULL;
int err = 0, empty, off;
pid_t thepid;
mutt_mktemp(tempfile, sizeof(tempfile));
- fpout = mutt_file_fopen(tempfile, "w+");
+ FILE *fpout = mutt_file_fopen(tempfile, "w+");
if (!fpout)
{
mutt_perror(tempfile);
}
mutt_mktemp(smimeerrfile, sizeof(smimeerrfile));
- smimeerr = mutt_file_fopen(smimeerrfile, "w+");
+ FILE *smimeerr = mutt_file_fopen(smimeerrfile, "w+");
if (!smimeerr)
{
mutt_perror(smimeerrfile);
mutt_file_unlink(smimeerrfile);
mutt_mktemp(smimeinfile, sizeof(smimeinfile));
- fptmp = mutt_file_fopen(smimeinfile, "w+");
+ FILE *fptmp = mutt_file_fopen(smimeinfile, "w+");
if (!fptmp)
{
mutt_perror(smimeinfile);
return NULL;
}
- t = mutt_body_new();
+ struct Body *t = mutt_body_new();
t->type = TYPEAPPLICATION;
t->subtype = mutt_str_strdup("x-pkcs7-mime");
mutt_param_set(&t->parameter, "name", "smime.p7m");
struct Body *smime_sign_message(struct Body *a)
{
- struct Body *t = NULL;
char buffer[LONG_STRING];
char signedfile[_POSIX_PATH_MAX], filetosign[_POSIX_PATH_MAX];
FILE *smimein = NULL, *smimeout = NULL, *smimeerr = NULL, *sfp = NULL;
int err = 0;
int empty = 0;
pid_t thepid;
- char *signas = NULL;
- struct SmimeKey *signas_key = NULL;
char *intermediates = NULL;
- char *micalg = NULL;
- signas = (SmimeSignAs && *SmimeSignAs) ? SmimeSignAs : SmimeDefaultKey;
+ char *signas = (SmimeSignAs && *SmimeSignAs) ? SmimeSignAs : SmimeDefaultKey;
if (!signas || !*signas)
{
mutt_error(_("Can't sign: No key specified. Use Sign As."));
snprintf(SmimeCertToUse, sizeof(SmimeCertToUse), "%s/%s",
NONULL(SmimeCertificates), signas);
- signas_key = smime_get_key_by_hash(signas, 1);
+ struct SmimeKey *signas_key = smime_get_key_by_hash(signas, 1);
if ((!signas_key) || (!mutt_str_strcmp("?", signas_key->issuer)))
intermediates = signas; /* so openssl won't complain in any case */
else
return NULL; /* fatal error while signing */
}
- t = mutt_body_new();
+ struct Body *t = mutt_body_new();
t->type = TYPEMULTIPART;
t->subtype = mutt_str_strdup("signed");
t->encoding = ENC7BIT;
mutt_generate_boundary(&t->parameter);
- micalg = openssl_md_to_smime_micalg(SmimeSignDigestAlg);
+ char *micalg = openssl_md_to_smime_micalg(SmimeSignDigestAlg);
mutt_param_set(&t->parameter, "micalg", micalg);
FREE(&micalg);
int smime_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile)
{
char signedfile[_POSIX_PATH_MAX], smimeerrfile[_POSIX_PATH_MAX];
- FILE *fp = NULL, *smimeout = NULL, *smimeerr = NULL;
+ FILE *smimeout = NULL;
pid_t thepid;
int badsig = -1;
LOFF_T tmpoffset = 0;
size_t tmplength = 0;
int orig_type = sigbdy->type;
- char *save_prefix = NULL;
snprintf(signedfile, sizeof(signedfile), "%s.sig", tempfile);
/* decode to a tempfile, saving the original destination */
- fp = s->fpout;
+ FILE *fp = s->fpout;
s->fpout = mutt_file_fopen(signedfile, "w");
if (!s->fpout)
{
/* if we are decoding binary bodies, we don't want to prefix each
* line with the prefix or else the data will get corrupted.
*/
- save_prefix = s->prefix;
+ char *save_prefix = s->prefix;
s->prefix = NULL;
mutt_decode_attachment(sigbdy, s);
sigbdy->type = orig_type;
mutt_mktemp(smimeerrfile, sizeof(smimeerrfile));
- smimeerr = mutt_file_fopen(smimeerrfile, "w+");
+ FILE *smimeerr = mutt_file_fopen(smimeerrfile, "w+");
if (!smimeerr)
{
mutt_perror(smimeerrfile);
line = mutt_mem_malloc(sb.st_size + 1);
while (sb.st_size && fgets(line, sb.st_size + 1, nserv->newsrc_fp))
{
- char *b = NULL, *h = NULL, *p = NULL;
+ char *b = NULL, *h = NULL;
unsigned int j = 1;
bool subs = false;
- struct NntpData *nntp_data = NULL;
/* find end of newsgroup name */
- p = strpbrk(line, ":!");
+ char *p = strpbrk(line, ":!");
if (!p)
continue;
*p++ = '\0';
/* get newsgroup data */
- nntp_data = nntp_data_find(nserv, line);
+ struct NntpData *nntp_data = nntp_data_find(nserv, line);
FREE(&nntp_data->newsrc_ent);
/* count number of entries */
char buf[HUGE_STRING];
char file[_POSIX_PATH_MAX];
time_t t;
- FILE *fp = NULL;
cache_expand(file, sizeof(file), &nserv->conn->account, ".active");
mutt_debug(1, "Parsing %s\n", file);
- fp = mutt_file_fopen(file, "r");
+ FILE *fp = mutt_file_fopen(file, "r");
if (!fp)
return -1;
*/
static int get_description(struct NntpData *nntp_data, char *wildmat, char *msg)
{
- struct NntpServer *nserv = NULL;
char buf[STRING];
char *cmd = NULL;
- int rc;
/* get newsgroup description, if possible */
- nserv = nntp_data->nserv;
+ struct NntpServer *nserv = nntp_data->nserv;
if (!wildmat)
wildmat = nntp_data->group;
if (nserv->hasLIST_NEWSGROUPS)
return 0;
snprintf(buf, sizeof(buf), "%s %s\r\n", cmd, wildmat);
- rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), msg, fetch_description, nserv);
+ int rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), msg, fetch_description, nserv);
if (rc > 0)
{
mutt_error("%s: %s", cmd, buf);
static void nntp_parse_xref(struct Context *ctx, struct Header *hdr)
{
struct NntpData *nntp_data = ctx->data;
- char *buf = NULL, *p = NULL;
- buf = p = mutt_str_strdup(hdr->env->xref);
+ char *buf = mutt_str_strdup(hdr->env->xref);
+ char *p = buf;
while (p)
{
- char *grp = NULL, *colon = NULL;
anum_t anum;
/* skip to next word */
p += strspn(p, " \t");
- grp = p;
+ char *grp = p;
/* skip to end of word */
p = strpbrk(p, " \t");
*p++ = '\0';
/* find colon */
- colon = strchr(grp, ':');
+ char *colon = strchr(grp, ':');
if (!colon)
continue;
*colon++ = '\0';
#ifdef USE_HCACHE
if (fc->hc)
{
- void *hdata = NULL;
char buf[16];
/* try to replace with header from cache */
snprintf(buf, sizeof(buf), "%d", anum);
- hdata = mutt_hcache_fetch(fc->hc, buf, strlen(buf));
+ void *hdata = mutt_hcache_fetch(fc->hc, buf, strlen(buf));
if (hdata)
{
mutt_debug(2, "mutt_hcache_fetch %s\n", buf);
/* fetch header from server */
else
{
- FILE *fp = NULL;
char tempfile[_POSIX_PATH_MAX];
mutt_mktemp(tempfile, sizeof(tempfile));
- fp = mutt_file_fopen(tempfile, "w+");
+ FILE *fp = mutt_file_fopen(tempfile, "w+");
if (!fp)
{
mutt_perror(tempfile);
/* .newsrc has been externally modified */
if (nserv->newsrc_modified)
{
- anum_t anum;
#ifdef USE_HCACHE
unsigned char *messages = NULL;
char buf[16];
/* update flags according to .newsrc */
int j = 0;
+ anum_t anum;
for (int i = 0; i < ctx->msgcount; i++)
{
bool flagged = false;
int nntp_check_msgid(struct Context *ctx, const char *msgid)
{
struct NntpData *nntp_data = ctx->data;
- struct Header *hdr = NULL;
- FILE *fp = NULL;
char tempfile[_POSIX_PATH_MAX];
char buf[LONG_STRING];
- int rc;
mutt_mktemp(tempfile, sizeof(tempfile));
- fp = mutt_file_fopen(tempfile, "w+");
+ FILE *fp = mutt_file_fopen(tempfile, "w+");
if (!fp)
{
mutt_perror(tempfile);
}
snprintf(buf, sizeof(buf), "HEAD %s\r\n", msgid);
- rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_tempfile, fp);
+ int rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_tempfile, fp);
if (rc)
{
mutt_file_fclose(&fp);
/* parse header */
if (ctx->msgcount == ctx->hdrmax)
mx_alloc_memory(ctx);
- hdr = ctx->hdrs[ctx->msgcount] = mutt_header_new();
+ struct Header *hdr = ctx->hdrs[ctx->msgcount] = mutt_header_new();
hdr->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData));
hdr->env = mutt_rfc822_read_header(fp, hdr, 0, 0);
mutt_file_fclose(&fp);
static void shift_class_colors(struct QClass *quote_list,
struct QClass *new_class, int index, int *q_level)
{
- struct QClass *q_list = NULL;
-
- q_list = quote_list;
+ struct QClass *q_list = quote_list;
new_class->index = -1;
while (q_list)
void mutt_parse_content_type(char *s, struct Body *ct)
{
- char *pc = NULL;
- char *subtype = NULL;
-
FREE(&ct->subtype);
mutt_param_free(&ct->parameter);
/* First extract any existing parameters */
- pc = strchr(s, ';');
+ char *pc = strchr(s, ';');
if (pc)
{
*pc++ = 0;
}
/* Now get the subtype */
- subtype = strchr(s, '/');
+ char *subtype = strchr(s, '/');
if (subtype)
{
*subtype++ = '\0';
*/
struct Body *mutt_rfc822_parse_message(FILE *fp, struct Body *parent)
{
- struct Body *msg = NULL;
-
parent->hdr = mutt_header_new();
parent->hdr->offset = ftello(fp);
parent->hdr->env = mutt_rfc822_read_header(fp, parent->hdr, 0, 0);
- msg = parent->hdr->content;
+ struct Body *msg = parent->hdr->content;
/* ignore the length given in the content-length since it could be wrong
and we already have the info to calculate the correct length */
struct Buffer buf;
char errmsg[STRING];
int r;
- char *pexpr = NULL;
mutt_buffer_init(&buf);
- pexpr = s->dptr;
+ char *pexpr = s->dptr;
if (mutt_extract_token(&buf, s, MUTT_TOKEN_PATTERN | MUTT_TOKEN_COMMENT) != 0 || !buf.data)
{
snprintf(err->data, err->dsize, _("Error in expression: %s"), pexpr);
{
struct Buffer buffer;
struct tm min, max;
- char *pexpr = NULL;
mutt_buffer_init(&buffer);
- pexpr = s->dptr;
+ char *pexpr = s->dptr;
if (mutt_extract_token(&buffer, s, MUTT_TOKEN_COMMENT | MUTT_TOKEN_PATTERN) != 0 ||
!buffer.data)
{
static bool is_context_available(struct Buffer *s, regmatch_t pmatch[],
int kind, struct Buffer *err)
{
- char *context_loc = NULL;
const char *context_req_chars[] = {
[RANGE_K_REL] = ".0123456789",
[RANGE_K_ABS] = ".",
/* First decide if we're going to need the context at all.
* Relative patterns need it iff they contain a dot or a number.
* Absolute patterns only need it if they contain a dot. */
- context_loc = strpbrk(s->dptr + pmatch[0].rm_so, context_req_chars[kind]);
+ char *context_loc = strpbrk(s->dptr + pmatch[0].rm_so, context_req_chars[kind]);
if (!context_loc || (context_loc >= &s->dptr[pmatch[0].rm_eo]))
return true;
static char *binary_fingerprint_to_string(unsigned char *buf, size_t length)
{
- char *fingerprint = NULL, *pf = NULL;
-
- pf = fingerprint = mutt_mem_malloc((length * 2) + 1);
+ char *fingerprint = mutt_mem_malloc((length * 2) + 1);
+ char *pf = fingerprint;
for (size_t i = 0; i < length; i++)
{
static struct PgpKeyInfo *pgp_parse_pgp3_key(unsigned char *buf, size_t l)
{
- struct PgpKeyInfo *p = NULL;
unsigned char alg;
unsigned char digest[SHA_DIGEST_LENGTH];
unsigned char scratch[LONG_STRING];
short len;
size_t j;
- p = pgp_new_keyinfo();
+ struct PgpKeyInfo *p = pgp_new_keyinfo();
j = 2;
for (i = 0; i < 4; i++)
FILE *rfp = fopen(ringfile, "r");
if (!rfp)
{
- char *error_buf = NULL;
- size_t error_buf_len;
-
- error_buf_len = sizeof("fopen: ") - 1 + strlen(ringfile) + 1;
- error_buf = mutt_mem_malloc(error_buf_len);
+ size_t error_buf_len = sizeof("fopen: ") - 1 + strlen(ringfile) + 1;
+ char *error_buf = mutt_mem_malloc(error_buf_len);
snprintf(error_buf, error_buf_len, "fopen: %s", ringfile);
perror(error_buf);
FREE(&error_buf);
if (pgpring_string_matches_hint(tmp, hints, nhints))
{
- struct PgpKeyInfo *p = NULL;
-
fsetpos(rfp, &keypos);
/* Not bailing out here would lead us into an endless loop. */
- p = pgp_parse_keyblock(rfp);
+ struct PgpKeyInfo *p = pgp_parse_keyblock(rfp);
if (!p)
err = 1;
*/
static int pop_read_header(struct PopData *pop_data, struct Header *h)
{
- FILE *f = NULL;
int rc, index;
size_t length;
char buf[LONG_STRING];
char tempfile[_POSIX_PATH_MAX];
mutt_mktemp(tempfile, sizeof(tempfile));
- f = mutt_file_fopen(tempfile, "w+");
+ FILE *f = mutt_file_fopen(tempfile, "w+");
if (!f)
{
mutt_perror(tempfile);
static int msg_cache_check(const char *id, struct BodyCache *bcache, void *data)
{
- struct Context *ctx = NULL;
- struct PopData *pop_data = NULL;
-
- ctx = (struct Context *) data;
+ struct Context *ctx = (struct Context *) data;
if (!ctx)
return -1;
- pop_data = (struct PopData *) ctx->data;
+ struct PopData *pop_data = (struct PopData *) ctx->data;
if (!pop_data)
return -1;
int pop_parse_path(const char *path, struct Account *acct)
{
struct Url url;
- char *c = NULL;
- struct servent *service = NULL;
/* Defaults */
acct->flags = 0;
acct->type = MUTT_ACCT_TYPE_POP;
acct->port = 0;
- c = mutt_str_strdup(path);
+ char *c = mutt_str_strdup(path);
url_parse(&url, c);
if ((url.scheme != U_POP && url.scheme != U_POPS) || !url.host ||
if (url.scheme == U_POPS)
acct->flags |= MUTT_ACCT_SSL;
- service = getservbyname(url.scheme == U_POP ? "pop3" : "pop3s", "tcp");
+ struct servent *service = getservbyname(url.scheme == U_POP ? "pop3" : "pop3s", "tcp");
if (!acct->port)
{
if (service)
*/
static void pop_error(struct PopData *pop_data, char *msg)
{
- char *t = NULL, *c = NULL, *c2 = NULL;
-
- t = strchr(pop_data->err_msg, '\0');
- c = msg;
+ char *t = strchr(pop_data->err_msg, '\0');
+ char *c = msg;
if (mutt_str_strncmp(msg, "-ERR ", 5) == 0)
{
- c2 = mutt_str_skip_email_wsp(msg + 5);
+ char *c2 = mutt_str_skip_email_wsp(msg + 5);
if (*c2)
c = c2;
case OP_QUERY:
if (mutt_get_field(_("Query: "), buf, buflen, 0) == 0 && buf[0])
{
- struct Query *newresults = NULL;
-
- newresults = run_query(buf, 0);
+ struct Query *newresults = run_query(buf, 0);
menu->redraw = REDRAW_FULL;
if (newresults)
{
struct State state;
char buf[SHORT_STRING];
- pid_t thepid;
if (fp)
filter = false; /* sanity check: we can't filter in the recv case yet */
if (!filter && !AttachSplit)
{
mutt_endwin();
- thepid = mutt_create_filter(buf, &state.fpout, NULL, NULL);
+ pid_t thepid = mutt_create_filter(buf, &state.fpout, NULL, NULL);
pipe_attachment_list(buf, actx, fp, tag, top, filter, &state);
mutt_file_fclose(&state.fpout);
if (mutt_wait_filter(thepid) != 0 || WaitKey)
{
struct State state = { 0 };
- pid_t thepid;
if (query_quadoption(Print, tag ? _("Print tagged attachment(s)?") :
_("Print attachment?")) != MUTT_YES)
return;
if (!can_print(actx, top, tag))
return;
mutt_endwin();
- thepid = mutt_create_filter(NONULL(PrintCommand), &state.fpout, NULL, NULL);
+ pid_t thepid = mutt_create_filter(NONULL(PrintCommand), &state.fpout, NULL, NULL);
print_attachment_list(actx, fp, tag, top, &state);
mutt_file_fclose(&state.fpout);
if (mutt_wait_filter(thepid) != 0 || WaitKey)
void mutt_view_attachments(struct Header *hdr)
{
char helpstr[LONG_STRING];
- struct Menu *menu = NULL;
struct Body *cur = NULL;
- struct Message *msg = NULL;
- struct AttachCtx *actx = NULL;
int flags = 0;
int op = OP_NULL;
mutt_message_hook(Context, hdr, MUTT_MESSAGEHOOK);
- msg = mx_open_message(Context, hdr->msgno);
+ struct Message *msg = mx_open_message(Context, hdr->msgno);
if (!msg)
return;
- menu = mutt_menu_new(MENU_ATTACH);
+ struct Menu *menu = mutt_menu_new(MENU_ATTACH);
menu->title = _("Attachments");
menu->make_entry = attach_entry;
menu->tag = mutt_tag_attach;
menu->help = mutt_compile_help(helpstr, sizeof(helpstr), MENU_ATTACH, AttachHelp);
mutt_menu_push_current(menu);
- actx = mutt_mem_calloc(sizeof(struct AttachCtx), 1);
+ struct AttachCtx *actx = mutt_mem_calloc(sizeof(struct AttachCtx), 1);
actx->hdr = hdr;
actx->root_fp = msg->fp;
mutt_update_recvattach_menu(actx, menu, 1);
{
bool mime_fwd_all = false;
bool mime_fwd_any = true;
- struct AttachPtr *parent = NULL;
struct Header *parent_hdr = NULL;
FILE *parent_fp = NULL;
- struct Header *tmphdr = NULL;
- struct Body **last = NULL;
char tmpbody[_POSIX_PATH_MAX];
- FILE *tmpfp = NULL;
-
char prefix[STRING];
-
int rc = 0;
-
struct State st;
/*
* putting the following lines into an if block.
*/
- parent = find_parent(actx, cur, nattach);
+ struct AttachPtr *parent = find_parent(actx, cur, nattach);
if (parent)
{
parent_hdr = parent->content->hdr;
parent_fp = actx->root_fp;
}
- tmphdr = mutt_header_new();
+ struct Header *tmphdr = mutt_header_new();
tmphdr->env = mutt_env_new();
mutt_make_forward_subject(tmphdr->env, Context, parent_hdr);
mutt_mktemp(tmpbody, sizeof(tmpbody));
- tmpfp = mutt_file_fopen(tmpbody, "w");
+ FILE *tmpfp = mutt_file_fopen(tmpbody, "w");
if (!tmpfp)
{
mutt_error(_("Can't open temporary file %s."), tmpbody);
st.fpout = tmpfp;
/* where do we append new MIME parts? */
- last = &tmphdr->content;
+ struct Body **last = &tmphdr->content;
if (cur)
{
void mix_make_chain(struct ListHead *chainhead)
{
- struct MixChain *chain = NULL;
int c_cur = 0, c_old = 0;
bool c_redraw = true;
-
- struct Remailer **type2_list = NULL;
size_t ttll = 0;
struct Coord *coords = NULL;
char *t = NULL;
- type2_list = mix_type2_list(&ttll);
+ struct Remailer **type2_list = mix_type2_list(&ttll);
if (!type2_list)
{
mutt_error(_("Can't get mixmaster's type2.list!"));
return;
}
- chain = mutt_mem_calloc(1, sizeof(struct MixChain));
+ struct MixChain *chain = mutt_mem_calloc(1, sizeof(struct MixChain));
struct ListNode *p;
STAILQ_FOREACH(p, chainhead, entries)
struct Rfc1524MailcapEntry *entry, int opt)
{
char *buf = NULL;
- char *ch = NULL;
int found = false;
int line = 0;
*/
/* find length of basetype */
- ch = strchr(type, '/');
+ char *ch = strchr(type, '/');
if (!ch)
return false;
const int btlen = ch - type;
static char *rfc2231_get_charset(char *value, char *charset, size_t chslen)
{
- char *t = NULL, *u = NULL;
-
- t = strchr(value, '\'');
+ char *t = strchr(value, '\'');
if (!t)
{
charset[0] = '\0';
*t = '\0';
mutt_str_strfcpy(charset, value, chslen);
- u = strchr(t + 1, '\'');
+ char *u = strchr(t + 1, '\'');
if (u)
return u + 1;
else
*/
int rfc3676_handler(struct Body *a, struct State *s)
{
- char *buf = NULL, *t = NULL;
+ char *buf = NULL;
unsigned int quotelevel = 0;
int delsp = 0;
size_t sz = 0;
memset(&fst, 0, sizeof(fst));
/* respect DelSp of RFC3676 only with f=f parts */
- t = mutt_param_get(&a->parameter, "delsp");
+ char *t = mutt_param_get(&a->parameter, "delsp");
if (t)
{
delsp = mutt_str_strlen(t) == 3 && (mutt_str_strncasecmp(t, "yes", 3) == 0);
*/
struct Address *mutt_remove_xrefs(struct Address *a, struct Address *b)
{
- struct Address *top = NULL, *p = NULL, *prev = NULL;
+ struct Address *p = NULL, *prev = NULL;
- top = b;
+ struct Address *top = b;
while (b)
{
for (p = a; p; p = p->next)
static int send_message(struct Header *msg)
{
char tempfile[_POSIX_PATH_MAX];
- FILE *tempfp = NULL;
int i;
#ifdef USE_SMTP
short old_write_bcc;
/* Write out the message in MIME form. */
mutt_mktemp(tempfile, sizeof(tempfile));
- tempfp = mutt_file_fopen(tempfile, "w");
+ FILE *tempfp = mutt_file_fopen(tempfile, "w");
if (!tempfp)
return -1;
static void fix_end_of_file(const char *data)
{
- FILE *fp = NULL;
-
- fp = mutt_file_fopen(data, "a+");
+ FILE *fp = mutt_file_fopen(data, "a+");
if (!fp)
return;
if (fseek(fp, -1, SEEK_END) >= 0)
static bool search_attach_keyword(char *filename)
{
/* Search for the regex in AbortNoattachRegex within a file */
- if (!AbortNoattachRegex || !AbortNoattachRegex->regex || !QuoteRegex || !QuoteRegex->regex)
+ if (!AbortNoattachRegex || !AbortNoattachRegex->regex || !QuoteRegex ||
+ !QuoteRegex->regex)
return false;
FILE *attf = mutt_file_fopen(filename, "r");
#ifdef USE_NNTP
if (!(flags & SENDNEWS))
#endif
- if (!mutt_addr_has_recips(msg->env->to) && !mutt_addr_has_recips(msg->env->cc) &&
- !mutt_addr_has_recips(msg->env->bcc))
+ if ((mutt_addr_has_recips(msg->env->to) == 0) &&
+ (mutt_addr_has_recips(msg->env->cc) == 0) &&
+ (mutt_addr_has_recips(msg->env->bcc) == 0))
{
if (!(flags & SENDBATCH))
{
}
#endif
- if (!(flags & SENDBATCH) &&
- (AbortNoattach != MUTT_NO) && !msg->content->next &&
- (msg->content->type == TYPETEXT) &&
- (mutt_str_strcasecmp (msg->content->subtype, "plain") == 0) &&
+ if (!(flags & SENDBATCH) && (AbortNoattach != MUTT_NO) &&
+ !msg->content->next && (msg->content->type == TYPETEXT) &&
+ (mutt_str_strcasecmp(msg->content->subtype, "plain") == 0) &&
search_attach_keyword(msg->content->filename) &&
query_quadoption(AbortNoattach, _("No attachments, cancel sending?")) != MUTT_NO)
{
/* if the abort is automatic, print an error message */
if (AbortNoattach == MUTT_YES)
{
- mutt_error(_(
- "Message contains text matching \"$abort_noattach_regex\". Not sending."));
+ mutt_error(_("Message contains text matching "
+ "\"$abort_noattach_regex\". Not sending."));
}
goto main_loop;
}
struct Body *mutt_make_file_attach(const char *path)
{
- struct Body *att = NULL;
- struct Content *info = NULL;
-
- att = mutt_body_new();
+ struct Body *att = mutt_body_new();
att->filename = mutt_str_strdup(path);
if (MimeTypeQueryCommand && *MimeTypeQueryCommand && MimeTypeQueryFirst)
run_mime_type_query(att);
}
- info = mutt_get_content_info(path, att);
+ struct Content *info = mutt_get_content_info(path, att);
if (!info)
{
mutt_body_free(&att);
struct Body *mutt_make_multipart(struct Body *b)
{
- struct Body *new = NULL;
-
- new = mutt_body_new();
+ struct Body *new = mutt_body_new();
new->type = TYPEMULTIPART;
new->subtype = mutt_str_strdup("mixed");
new->encoding = get_toplevel_encoding(b);
{
char buf[SHORT_STRING];
time_t now;
- struct tm *tm = NULL;
- const char *fqdn = NULL;
unsigned char rndid[MUTT_RANDTAG_LEN + 1];
mutt_rand_base32(rndid, sizeof(rndid) - 1);
rndid[MUTT_RANDTAG_LEN] = 0;
now = time(NULL);
- tm = gmtime(&now);
- fqdn = mutt_fqdn(0);
+ struct tm *tm = gmtime(&now);
+ const char *fqdn = mutt_fqdn(0);
if (!fqdn)
fqdn = NONULL(ShortHostname);
static int send_msg(const char *path, char **args, const char *msg, char **tempfile)
{
sigset_t set;
- int fd, st;
- pid_t pid, ppid;
+ int st;
mutt_sig_block_system();
*tempfile = mutt_str_strdup(tmp);
}
- pid = fork();
+ pid_t pid = fork();
if (pid == 0)
{
struct sigaction act, oldalrm;
/* save parent's ID before setsid() */
- ppid = getppid();
+ pid_t ppid = getppid();
/* we want the delivery to continue even after the main process dies,
* so we put ourselves into another session right away
/* next we close all open files */
close(0);
#ifdef OPEN_MAX
- for (fd = tempfile ? 1 : 3; fd < OPEN_MAX; fd++)
+ for (int fd = tempfile ? 1 : 3; fd < OPEN_MAX; fd++)
close(fd);
#elif defined(_POSIX_OPEN_MAX)
- for (fd = tempfile ? 1 : 3; fd < _POSIX_OPEN_MAX; fd++)
+ for (int fd = tempfile ? 1 : 3; fd < _POSIX_OPEN_MAX; fd++)
close(fd);
#else
if (tempfile)
{
if (i != S_BKG)
{
- const char *e = NULL;
-
- e = mutt_str_sysexit(i);
+ const char *e = mutt_str_sysexit(i);
mutt_error(_("Error sending message, child exited %d (%s)."), i, NONULL(e));
if (childout)
{
int mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to)
{
- struct Address *from = NULL, *resent_to = NULL;
const char *fqdn = mutt_fqdn(1);
char resent_from[STRING];
int ret;
char *err = NULL;
resent_from[0] = '\0';
- from = mutt_default_from();
+ struct Address *from = mutt_default_from();
/*
* mutt_default_from() does not use $realname if the real name is not set
* function is called, since the user receives confirmation of the address
* list being bounced to.
*/
- resent_to = mutt_addr_copy_list(to, false);
+ struct Address *resent_to = mutt_addr_copy_list(to, false);
rfc2047_encode_addrlist(resent_to, "Resent-To");
ret = bounce_message(fp, h, resent_to, resent_from, from);
{
char fcc_tok[_POSIX_PATH_MAX];
char fcc_expanded[_POSIX_PATH_MAX];
- char *tok = NULL;
- int status;
mutt_str_strfcpy(fcc_tok, path, sizeof(fcc_tok));
- tok = strtok(fcc_tok, ",");
+ char *tok = strtok(fcc_tok, ",");
if (!tok)
return -1;
mutt_debug(1, "Fcc: initial mailbox = '%s'\n", tok);
/* mutt_expand_path already called above for the first token */
- status = mutt_write_fcc(tok, hdr, msgid, post, fcc, finalpath);
+ int status = mutt_write_fcc(tok, hdr, msgid, post, fcc, finalpath);
if (status != 0)
return status;
}
else if (maildir_is_prefix && SidebarFolderIndent)
{
- const char *tmp_folder_name = NULL;
int lastsep = 0;
- tmp_folder_name = b->path + maildirlen + 1;
+ const char *tmp_folder_name = b->path + maildirlen + 1;
int tmplen = (int) mutt_str_strlen(tmp_folder_name) - 1;
for (int i = 0; i < tmplen; i++)
{
static int smtp_data(struct Connection *conn, const char *msgfile)
{
char buf[1024];
- FILE *fp = NULL;
struct Progress progress;
struct stat st;
int r, term = 0;
size_t buflen = 0;
- fp = fopen(msgfile, "r");
+ FILE *fp = fopen(msgfile, "r");
if (!fp)
{
mutt_error(_("SMTP session failed: unable to open %s"), msgfile);
struct Header **ppa = (struct Header **) a;
struct Header **ppb = (struct Header **) b;
char fa[SHORT_STRING];
- const char *fb = NULL;
- int result;
mutt_str_strfcpy(fa, mutt_get_name((*ppa)->env->to), SHORT_STRING);
- fb = mutt_get_name((*ppb)->env->to);
- result = mutt_str_strncasecmp(fa, fb, SHORT_STRING);
+ const char *fb = mutt_get_name((*ppb)->env->to);
+ int result = mutt_str_strncasecmp(fa, fb, SHORT_STRING);
result = perform_auxsort(result, a, b);
return (SORTCODE(result));
}
struct Header **ppa = (struct Header **) a;
struct Header **ppb = (struct Header **) b;
char fa[SHORT_STRING];
- const char *fb = NULL;
- int result;
mutt_str_strfcpy(fa, mutt_get_name((*ppa)->env->from), SHORT_STRING);
- fb = mutt_get_name((*ppb)->env->from);
- result = mutt_str_strncasecmp(fa, fb, SHORT_STRING);
+ const char *fb = mutt_get_name((*ppb)->env->from);
+ int result = mutt_str_strncasecmp(fa, fb, SHORT_STRING);
result = perform_auxsort(result, a, b);
return (SORTCODE(result));
}
static struct Hash *make_subj_hash(struct Context *ctx)
{
- struct Header *hdr = NULL;
- struct Hash *hash = NULL;
-
- hash = mutt_hash_create(ctx->msgcount * 2, MUTT_HASH_ALLOW_DUPS);
+ struct Hash *hash = mutt_hash_create(ctx->msgcount * 2, MUTT_HASH_ALLOW_DUPS);
for (int i = 0; i < ctx->msgcount; i++)
{
- hdr = ctx->hdrs[i];
+ struct Header *hdr = ctx->hdrs[i];
if (hdr->env->real_subj)
mutt_hash_insert(hash, hdr->env->real_subj, hdr);
}
struct Hash *mutt_make_id_hash(struct Context *ctx)
{
- struct Header *hdr = NULL;
- struct Hash *hash = NULL;
-
- hash = mutt_hash_create(ctx->msgcount * 2, 0);
+ struct Hash *hash = mutt_hash_create(ctx->msgcount * 2, 0);
for (int i = 0; i < ctx->msgcount; i++)
{
- hdr = ctx->hdrs[i];
+ struct Header *hdr = ctx->hdrs[i];
if (hdr->env->message_id)
mutt_hash_insert(hash, hdr->env->message_id, hdr);
}
int url_parse_mailto(struct Envelope *e, char **body, const char *src)
{
- char *t = NULL, *p = NULL;
- char *tmp = NULL;
- char *headers = NULL;
+ char *p = NULL;
char *tag = NULL, *value = NULL;
int rc = -1;
- t = strchr(src, ':');
+ char *t = strchr(src, ':');
if (!t)
return -1;
/* copy string for safe use of strtok() */
- tmp = mutt_str_strdup(t + 1);
+ char *tmp = mutt_str_strdup(t + 1);
if (!tmp)
return -1;
- headers = strchr(tmp, '?');
+ char *headers = strchr(tmp, '?');
if (headers)
*headers++ = '\0';
if (!s)
return NULL;
- char *p = NULL;
-
- p = &s[strlen(s)];
+ char *p = &s[strlen(s)];
if (p == s)
return s;
p--;