int mutt_write_mime_header(struct Body *a, FILE *f)
{
- char buffer[STRING];
- char *t = NULL;
- char *fn = NULL;
- size_t len;
- int tmplen;
- int encode;
-
fprintf(f, "Content-Type: %s/%s", TYPE(a), a->subtype);
if (!TAILQ_EMPTY(&a->parameter))
{
- len = 25 + mutt_str_strlen(a->subtype); /* approximate len. of content-type */
+ size_t len = 25 + mutt_str_strlen(a->subtype); /* approximate len. of content-type */
struct Parameter *np;
TAILQ_FOREACH(np, &a->parameter, entries)
fputc(';', f);
+ char buffer[STRING];
buffer[0] = 0;
tmp = mutt_str_strdup(np->value);
- encode = rfc2231_encode_string(&tmp);
+ const int encode = rfc2231_encode_string(&tmp);
mutt_addr_cat(buffer, sizeof(buffer), tmp, MimeSpecials);
/* Dirty hack to make messages readable by Outlook Express
FREE(&tmp);
- tmplen = mutt_str_strlen(buffer) + mutt_str_strlen(np->attribute) + 1;
+ const int tmplen = mutt_str_strlen(buffer) + mutt_str_strlen(np->attribute) + 1;
if (len + tmplen + 2 > 76)
{
if (a->use_disp)
{
- fn = a->d_filename;
+ char *fn = a->d_filename;
if (!fn)
fn = a->filename;
char *tmp = NULL;
/* Strip off the leading path... */
- t = strrchr(fn, '/');
+ char *t = strrchr(fn, '/');
if (t)
t++;
else
t = fn;
+ char buffer[STRING];
buffer[0] = 0;
tmp = mutt_str_strdup(t);
- encode = rfc2231_encode_string(&tmp);
+ const int encode = rfc2231_encode_string(&tmp);
mutt_addr_cat(buffer, sizeof(buffer), tmp, MimeSpecials);
FREE(&tmp);
fprintf(f, "; filename%s=%s", encode ? "*" : "", buffer);
int mutt_write_mime_body(struct Body *a, FILE *f)
{
- char *p, boundary[SHORT_STRING];
- char send_charset[SHORT_STRING];
FILE *fpin = NULL;
struct FgetConv *fc = NULL;
if (a->type == TYPEMULTIPART)
{
/* First, find the boundary to use */
- p = mutt_param_get(&a->parameter, "boundary");
+ const char *p = mutt_param_get(&a->parameter, "boundary");
if (!p)
{
mutt_debug(1, "no boundary parameter found!\n");
mutt_error(_("No boundary parameter found! [report this error]"));
return -1;
}
+ char boundary[SHORT_STRING];
mutt_str_strfcpy(boundary, p, sizeof(boundary));
for (struct Body *t = a->parts; t; t = t->next)
}
if (a->type == TYPETEXT && (!a->noconv))
+ {
+ char send_charset[SHORT_STRING];
fc = mutt_ch_fgetconv_open(
fpin, a->charset, mutt_get_body_charset(send_charset, sizeof(send_charset), a), 0);
+ }
else
fc = mutt_ch_fgetconv_open(fpin, 0, 0, 0);
static size_t convert_file_to(FILE *file, const char *fromcode, int ncodes,
const char **tocodes, int *tocode, struct Content *info)
{
- iconv_t cd1, *cd = NULL;
char bufi[256], bufu[512], bufo[4 * sizeof(bufi)];
- const char *ib = NULL, *ub = NULL;
- char *ob = NULL;
- size_t ibl, obl, ubl, ubl1, n, ret;
- struct Content *infos = NULL;
- struct ContentState *states = NULL;
- size_t *score = NULL;
-
- cd1 = mutt_ch_iconv_open("utf-8", fromcode, 0);
+ size_t ret;
+
+ const iconv_t cd1 = mutt_ch_iconv_open("utf-8", fromcode, 0);
if (cd1 == (iconv_t)(-1))
return -1;
- cd = mutt_mem_calloc(ncodes, sizeof(iconv_t));
- score = mutt_mem_calloc(ncodes, sizeof(size_t));
- states = mutt_mem_calloc(ncodes, sizeof(struct ContentState));
- infos = mutt_mem_calloc(ncodes, sizeof(struct Content));
+ iconv_t *cd = mutt_mem_calloc(ncodes, sizeof(iconv_t));
+ size_t *score = mutt_mem_calloc(ncodes, sizeof(size_t));
+ struct ContentState *states = mutt_mem_calloc(ncodes, sizeof(struct ContentState));
+ struct Content *infos = mutt_mem_calloc(ncodes, sizeof(struct Content));
for (int i = 0; i < ncodes; i++)
{
}
rewind(file);
- ibl = 0;
+ size_t ibl = 0;
while (true)
{
/* Try to fill input buffer */
- n = fread(bufi + ibl, 1, sizeof(bufi) - ibl, file);
+ size_t n = fread(bufi + ibl, 1, sizeof(bufi) - ibl, file);
ibl += n;
/* Convert to UTF-8 */
- ib = bufi;
- ob = bufu;
- obl = sizeof(bufu);
+ const char *ib = bufi;
+ char *ob = bufu;
+ size_t obl = sizeof(bufu);
n = iconv(cd1, (ICONV_CONST char **) (ibl ? &ib : 0), &ibl, &ob, &obl);
assert(n == (size_t)(-1) || !n);
if (n == (size_t)(-1) && ((errno != EINVAL && errno != E2BIG) || ib == bufi))
ret = (size_t)(-1);
break;
}
- ubl1 = ob - bufu;
+ const size_t ubl1 = ob - bufu;
/* Convert from UTF-8 */
for (int i = 0; i < ncodes; i++)
{
if (cd[i] != (iconv_t)(-1) && score[i] != (size_t)(-1))
{
- ub = bufu;
- ubl = ubl1;
+ const char *ub = bufu;
+ size_t ubl = ubl1;
ob = bufo;
obl = sizeof(bufo);
n = iconv(cd[i], (ICONV_CONST char **) ((ibl || ubl) ? &ub : 0), &ubl, &ob, &obl);
char *fromcode = NULL;
char *tocode = NULL;
char buffer[100];
- char chsbuf[STRING];
size_t r;
struct stat sb;
{
if (!chs)
{
+ char chsbuf[STRING];
mutt_ch_canonical_charset(chsbuf, sizeof(chsbuf), tocode);
mutt_param_set(&b->parameter, "charset", chsbuf);
}
*/
static void set_encoding(struct Body *b, struct Content *info)
{
- char send_charset[SHORT_STRING];
-
if (b->type == TYPETEXT)
{
+ char send_charset[SHORT_STRING];
char *chsname = mutt_get_body_charset(send_charset, sizeof(send_charset), b);
if ((info->lobin && (mutt_str_strncasecmp(chsname, "iso-2022", 8) != 0)) ||
info->linemax > 990 || (info->from && EncodeFrom))
struct Address *tmp = NULL;
char buf[LONG_STRING];
int count = 0;
- size_t len;
while (addr)
{
addr->next = NULL;
buf[0] = 0;
mutt_addr_write(buf, sizeof(buf), addr, display);
- len = mutt_str_strlen(buf);
+ size_t len = mutt_str_strlen(buf);
if (count && linelen + len > 74)
{
fputs("\n\t", fp);
static int fold_one_header(FILE *fp, const char *tag, const char *value,
const char *pfx, int wraplen, int flags)
{
- const char *p = value, *next = NULL, *sp = NULL;
+ const char *p = value;
char buf[HUGE_STRING] = "";
- int first = 1, enc, col = 0, w, l = 0, fold;
- bool display = (flags & CH_DISPLAY);
+ int first = 1, col = 0, l = 0;
+ const bool display = (flags & CH_DISPLAY);
mutt_debug(4, "pfx=[%s], tag=[%s], flags=%d value=[%s]\n", pfx, tag, flags, NONULL(value));
while (p && *p)
{
- fold = 0;
+ int fold = 0;
/* find the next word and place it in `buf'. it may start with
* whitespace we can fold before */
- next = mutt_str_find_word(p);
+ const char *next = mutt_str_find_word(p);
l = MIN(sizeof(buf) - 1, next - p);
memcpy(buf, p, l);
buf[l] = 0;
/* determine width: character cells for display, bytes for sending
* (we get pure ascii only) */
- w = mutt_mb_width(buf, col, display);
- enc = (mutt_str_strncmp(buf, "=?", 2) == 0);
+ const int w = mutt_mb_width(buf, col, display);
+ const int enc = (mutt_str_strncmp(buf, "=?", 2) == 0);
mutt_debug(5, "word=[%s], col=%d, w=%d, next=[0x0%x]\n", buf, col, w, *next);
* current line width
* XXX this covers ASCII space only, for display we probably
* XXX want something like iswspace() here */
- sp = next;
+ const char *sp = next;
while (*sp && (*sp == ' ' || *sp == '\t'))
sp++;
if (*sp == '\n')
char **args = NULL;
size_t argslen = 0, argsmax = 0;
char **extra_args = NULL;
- size_t extra_argslen = 0, extra_argsmax = 0;
int i;
#ifdef USE_NNTP
if (!OPT_NEWS_SEND)
{
#endif
+ size_t extra_argslen = 0;
/* If Sendmail contained a "--", we save the recipients to append to
* args after other possible options added below. */
if (ps)
{
ps = NULL;
+ size_t extra_argsmax = 0;
while ((ps = strtok(ps, " ")))
{
if (extra_argslen == extra_argsmax)
*/
void mutt_prepare_envelope(struct Envelope *env, int final)
{
- char buffer[LONG_STRING];
-
if (final)
{
if (env->bcc && !(env->to || env->cc))
env->to->group = 1;
env->to->next = mutt_addr_new();
+ char buffer[LONG_STRING];
buffer[0] = 0;
mutt_addr_cat(buffer, sizeof(buffer), "undisclosed-recipients", AddressSpecials);
{
int rc = 0;
FILE *f = NULL;
- char date[SHORT_STRING], tempfile[_POSIX_PATH_MAX];
+ char tempfile[_POSIX_PATH_MAX];
struct Message *msg = NULL;
if (!h)
f = mutt_file_fopen(tempfile, "w");
if (f)
{
+ char date[SHORT_STRING];
int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
char *msgid_str = NULL;