* If you're supplying inrepls, the source charset should be stateless;
* if you're supplying an outrepl, the target charset should be.
*/
-size_t mutt_iconv(iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft,
- ICONV_CONST char **inrepls, const char *outrepl)
+size_t mutt_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
+ size_t *outbytesleft, const char **inrepls, const char *outrepl)
{
size_t rc = 0, ret1;
- ICONV_CONST char *ib = *inbuf;
+ const char *ib = *inbuf;
size_t ibl = *inbytesleft;
char *ob = *outbuf;
size_t obl = *outbytesleft;
while (true)
{
- ret1 = iconv(cd, &ib, &ibl, &ob, &obl);
+ ret1 = iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl);
if (ret1 != (size_t) -1)
rc += ret1;
if (ibl && obl && errno == EILSEQ)
if (inrepls)
{
/* Try replacing the input */
- ICONV_CONST char **t = NULL;
+ const char **t = NULL;
for (t = inrepls; *t; t++)
{
- ICONV_CONST char *ib1 = *t;
+ const char *ib1 = *t;
size_t ibl1 = strlen(*t);
char *ob1 = ob;
size_t obl1 = obl;
- iconv(cd, &ib1, &ibl1, &ob1, &obl1);
+ iconv(cd, (ICONV_CONST char **) &ib1, &ibl1, &ob1, &obl1);
if (!ibl1)
{
ib++;
/* Replace the output */
if (!outrepl)
outrepl = "?";
- iconv(cd, 0, 0, &ob, &obl);
+ iconv(cd, NULL, NULL, &ob, &obl);
if (obl)
{
int n = strlen(outrepl);
ob += n;
obl -= n;
rc++;
- iconv(cd, 0, 0, 0, 0); /* for good measure */
+ iconv(cd, NULL, NULL, NULL, NULL); /* for good measure */
continue;
}
}
int mutt_convert_string(char **ps, const char *from, const char *to, int flags)
{
iconv_t cd;
- ICONV_CONST char *repls[] = { "\357\277\275", "?", 0 };
+ const char *repls[] = { "\357\277\275", "?", 0 };
char *s = *ps;
if (!s || !*s)
if (to && from && (cd = mutt_iconv_open(to, from, flags)) != (iconv_t) -1)
{
int len;
- ICONV_CONST char *ib = NULL;
+ const char *ib = NULL;
char *buf = NULL, *ob = NULL;
size_t ibl, obl;
- ICONV_CONST char **inrepls = NULL;
+ const char **inrepls = NULL;
char *outrepl = NULL;
if (mutt_is_utf8(to))
char *ob;
char *ib;
size_t ibl;
- ICONV_CONST char **inrepls;
+ const char **inrepls;
};
/**
{
struct FgetConv *fc = NULL;
iconv_t cd = (iconv_t) -1;
- static ICONV_CONST char *repls[] = { "\357\277\275", "?", 0 };
+ static const char *repls[] = { "\357\277\275", "?", 0 };
if (from && to)
cd = mutt_iconv_open(to, from, flags);
if (fc->ibl)
{
size_t obl = sizeof(fc->bufo);
- mutt_iconv(fc->cd, (ICONV_CONST char **) &fc->ib, &fc->ibl, &fc->ob, &obl,
- fc->inrepls, 0);
+ mutt_iconv(fc->cd, (const char **) &fc->ib, &fc->ibl, &fc->ob, &obl, fc->inrepls, 0);
if (fc->p < fc->ob)
return (unsigned char) *(fc->p)++;
}
int mutt_convert_string(char **ps, const char *from, const char *to, int flags);
iconv_t mutt_iconv_open(const char *tocode, const char *fromcode, int flags);
-size_t mutt_iconv(iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft,
- ICONV_CONST char **inrepls, const char *outrepl);
+size_t mutt_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
+ size_t *outbytesleft, const char **inrepls, const char *outrepl);
typedef void *FGETCONV;
static void convert_to_state(iconv_t cd, char *bufi, size_t *l, struct State *s)
{
char bufo[BUFO_SIZE];
- ICONV_CONST char *ib = NULL;
+ const char *ib = NULL;
char *ob = NULL;
size_t ibl, obl;
if (cd != (iconv_t)(-1))
{
ob = bufo, obl = sizeof(bufo);
- iconv(cd, 0, 0, &ob, &obl);
+ iconv(cd, NULL, NULL, &ob, &obl);
if (ob != bufo)
state_prefix_put(bufo, ob - bufo, s);
}
{
int n = s - uid + 1; /* chars available in original buffer */
char *buf = NULL;
- ICONV_CONST char *ib = NULL;
+ const char *ib = NULL;
char *ob = NULL;
size_t ibl, obl;
ibl = d - uid + 1;
ob = buf;
obl = n;
- iconv(cd, &ib, &ibl, &ob, &obl);
+ iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl);
if (!ibl)
{
if (ob - buf < n)
extern char RFC822Specials[];
-typedef size_t (*encoder_t)(char *s, ICONV_CONST char *d, size_t dlen, const char *tocode);
+typedef size_t (*encoder_t)(char *s, const char *d, size_t dlen, const char *tocode);
-static size_t convert_string(ICONV_CONST char *f, size_t flen, const char *from,
+static size_t convert_string(const char *f, size_t flen, const char *from,
const char *to, char **t, size_t *tlen)
{
iconv_t cd;
return (size_t)(-1);
obl = 4 * flen + 1;
ob = buf = mutt_mem_malloc(obl);
- n = iconv(cd, &f, &flen, &ob, &obl);
- if (n == (size_t)(-1) || iconv(cd, 0, 0, &ob, &obl) == (size_t)(-1))
+ n = iconv(cd, (ICONV_CONST char **) &f, &flen, &ob, &obl);
+ if (n == (size_t)(-1) || iconv(cd, NULL, NULL, &ob, &obl) == (size_t)(-1))
{
e = errno;
FREE(&buf);
return tocode;
}
-static size_t b_encoder(char *s, ICONV_CONST char *d, size_t dlen, const char *tocode)
+static size_t b_encoder(char *s, const char *d, size_t dlen, const char *tocode)
{
char *s0 = s;
return s - s0;
}
-static size_t q_encoder(char *s, ICONV_CONST char *d, size_t dlen, const char *tocode)
+static size_t q_encoder(char *s, const char *d, size_t dlen, const char *tocode)
{
static const char hex[] = "0123456789ABCDEF";
char *s0 = s;
}
/**
- * try_block - Attempt to convert a block ot text
+ * try_block - Attempt to convert a block of text
* @param d String to convert
* @param dlen Length of string
* @param fromcode Original encoding
* tocode, unless fromcode is 0, in which case the data is assumed to
* be already in tocode, which should be 8-bit and stateless.
*/
-static size_t try_block(ICONV_CONST char *d, size_t dlen, const char *fromcode,
+static size_t try_block(const char *d, size_t dlen, const char *fromcode,
const char *tocode, encoder_t *encoder, size_t *wlen)
{
char buf1[ENCWORD_LEN_MAX - ENCWORD_LEN_MIN + 1];
iconv_t cd;
- ICONV_CONST char *ib = NULL;
+ const char *ib = NULL;
char *ob = NULL;
size_t ibl, obl;
int count, len, len_b, len_q;
ibl = dlen;
ob = buf1;
obl = sizeof(buf1) - strlen(tocode);
- if (iconv(cd, &ib, &ibl, &ob, &obl) == (size_t)(-1) ||
- iconv(cd, 0, 0, &ob, &obl) == (size_t)(-1))
+ if (iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl) == (size_t)(-1) ||
+ iconv(cd, NULL, NULL, &ob, &obl) == (size_t)(-1))
{
assert(errno == E2BIG);
iconv_close(cd);
{
char buf1[ENCWORD_LEN_MAX - ENCWORD_LEN_MIN + 1];
iconv_t cd;
- ICONV_CONST char *ib = NULL;
+ const char *ib = NULL;
char *ob = NULL;
size_t ibl, obl, n1, n2;
ibl = dlen;
ob = buf1;
obl = sizeof(buf1) - strlen(tocode);
- n1 = iconv(cd, &ib, &ibl, &ob, &obl);
- n2 = iconv(cd, 0, 0, &ob, &obl);
+ n1 = iconv(cd, (ICONV_CONST char **) &ib, &ibl, &ob, &obl);
+ n2 = iconv(cd, NULL, NULL, &ob, &obl);
assert(n1 != (size_t)(-1) && n2 != (size_t)(-1));
iconv_close(cd);
return (*encoder)(s, buf1, ob - buf1, tocode);
* The input data is assumed to be a single line starting at column col;
* if col is non-zero, the preceding character was a space.
*/
-static int rfc2047_encode(ICONV_CONST char *d, size_t dlen, int col, const char *fromcode,
+static int rfc2047_encode(const char *d, size_t dlen, int col, const char *fromcode,
const char *charsets, char **e, size_t *elen, char *specials)
{
int rc = 0;
{
iconv_t cd1, *cd = NULL;
char bufi[256], bufu[512], bufo[4 * sizeof(bufi)];
- ICONV_CONST char *ib = NULL, *ub = NULL;
+ const char *ib = NULL, *ub = NULL;
char *ob = NULL;
size_t ibl, obl, ubl, ubl1, n, ret;
struct Content *infos = NULL;
ib = bufi;
ob = bufu;
obl = sizeof(bufu);
- n = iconv(cd1, ibl ? &ib : 0, &ibl, &ob, &obl);
+ 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))
{
ubl = ubl1;
ob = bufo;
obl = sizeof(bufo);
- n = iconv(cd[i], (ibl || ubl) ? &ub : 0, &ubl, &ob, &obl);
+ n = iconv(cd[i], (ICONV_CONST char **) ((ibl || ubl) ? &ub : 0), &ubl, &ob, &obl);
if (n == (size_t)(-1))
{
assert(errno == E2BIG || (BUGGY_ICONV && (errno == EILSEQ || errno == ENOENT)));