}
if (check_alias_name(new->name, NULL, 0))
- mutt_file_quote_filename(buf, sizeof(buf), new->name);
+ mutt_file_quote_filename(new->name, buf, sizeof(buf));
else
mutt_str_strfcpy(buf, new->name, sizeof(buf));
recode_buf(buf, sizeof(buf));
{
len = snprintf(buf, buflen, "%s ", cmd);
}
- len += mutt_b64_encode(buf + len, tmp, tmplen, buflen - len);
+ len += mutt_b64_encode(tmp, tmplen, buf + len, buflen - len);
return len;
}
size_t ret;
size_t in_len = MIN(3, buflen);
- ret = mutt_b64_encode(encoded, buf, in_len, sizeof(encoded));
+ ret = mutt_b64_encode(buf, in_len, encoded, sizeof(encoded));
for (size_t i = 0; i < ret; i++)
*str++ = encoded[i];
{
const int olen = 3 * len / 4 + 1;
char *out = mutt_mem_malloc(olen);
- int dlen = mutt_b64_decode(out, it, olen);
+ int dlen = mutt_b64_decode(it, out, olen);
if (dlen == -1)
{
FREE(&out);
goto bail;
}
- len = mutt_b64_decode(obuf, idata->buf + 2, sizeof(obuf));
+ len = mutt_b64_decode(idata->buf + 2, obuf, sizeof(obuf));
if (len == -1)
{
mutt_debug(1, "Error decoding base64 response.\n");
/* ibuf must be long enough to store the base64 encoding of obuf,
* plus the additional debris */
- mutt_b64_encode(ibuf, obuf, strlen(obuf), sizeof(ibuf) - 2);
+ mutt_b64_encode(obuf, strlen(obuf), ibuf, sizeof(ibuf) - 2);
mutt_str_strcat(ibuf, sizeof(ibuf), "\r\n");
mutt_socket_send(idata->conn, ibuf);
/* now start the security context initialisation loop... */
mutt_debug(2, "Sending credentials\n");
- mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
+ mutt_b64_encode(send_token.value, send_token.length, buf1, sizeof(buf1) - 2);
gss_release_buffer(&min_stat, &send_token);
mutt_str_strcat(buf1, sizeof(buf1), "\r\n");
mutt_socket_send(idata->conn, buf1);
goto bail;
}
- request_buf.length = mutt_b64_decode(buf2, idata->buf + 2, sizeof(buf2));
+ request_buf.length = mutt_b64_decode(idata->buf + 2, buf2, sizeof(buf2));
request_buf.value = buf2;
sec_token = &request_buf;
goto err_abort_cmd;
}
- mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
+ mutt_b64_encode(send_token.value, send_token.length, buf1, sizeof(buf1) - 2);
gss_release_buffer(&min_stat, &send_token);
mutt_str_strcat(buf1, sizeof(buf1), "\r\n");
mutt_socket_send(idata->conn, buf1);
mutt_debug(1, "#2 Error receiving server response.\n");
goto bail;
}
- request_buf.length = mutt_b64_decode(buf2, idata->buf + 2, sizeof(buf2));
+ request_buf.length = mutt_b64_decode(idata->buf + 2, buf2, sizeof(buf2));
request_buf.value = buf2;
maj_stat = gss_unwrap(&min_stat, context, &request_buf, &send_token, &cflags, &quality);
goto err_abort_cmd;
}
- mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2);
+ mutt_b64_encode(send_token.value, send_token.length, buf1, sizeof(buf1) - 2);
mutt_debug(2, "Requesting authorisation as %s\n", idata->conn->account.user);
mutt_str_strcat(buf1, sizeof(buf1), "\r\n");
mutt_socket_send(idata->conn, buf1);
int imap_wait_keepalive(pid_t pid);
void imap_keepalive(void);
-void imap_get_parent_path(char *output, const char *path, size_t olen);
+void imap_get_parent_path(const char *path, char *buf, size_t buflen);
void imap_clean_path(char *path, size_t plen);
#endif /* _IMAP_IMAP_H */
void imap_munge_mbox_name(struct ImapData *idata, char *dest, size_t dlen, const char *src);
void imap_unmunge_mbox_name(struct ImapData *idata, char *s);
int imap_account_match(const struct Account *a1, const struct Account *a2);
-void imap_get_parent(char *output, const char *mbox, size_t olen, char delim);
+void imap_get_parent(const char *mbox, char delim, char *buf, size_t buflen);
/* utf7.c */
void imap_utf_encode(struct ImapData *idata, char **s);
/**
* imap_get_parent - Get an IMAP folder's parent
- * @param output Buffer for the result
* @param mbox Mailbox whose parent is to be determined
- * @param olen Length of the buffer
* @param delim Path delimiter
+ * @param buf Buffer for the result
+ * @param buflen Length of the buffer
*/
-void imap_get_parent(char *output, const char *mbox, size_t olen, char delim)
+void imap_get_parent(const char *mbox, char delim, char *buf, size_t buflen)
{
int n;
/* Make a copy of the mailbox name, but only if the pointers are different */
- if (mbox != output)
- mutt_str_strfcpy(output, mbox, olen);
+ if (mbox != buf)
+ mutt_str_strfcpy(buf, mbox, buflen);
- n = mutt_str_strlen(output);
+ n = mutt_str_strlen(buf);
/* Let's go backwards until the next delimiter
*
- * If output[n] is a '/', the first n-- will allow us
- * to ignore it. If it isn't, then output looks like
+ * If buf[n] is a '/', the first n-- will allow us
+ * to ignore it. If it isn't, then buf looks like
* "/aaaaa/bbbb". There is at least one "b", so we can't skip
* the "/" after the 'a's.
*
- * If output == '/', then n-- => n == 0, so the loop ends
+ * If buf == '/', then n-- => n == 0, so the loop ends
* immediately
*/
- for (n--; n >= 0 && output[n] != delim; n--)
+ for (n--; n >= 0 && buf[n] != delim; n--)
;
/* We stopped before the beginning. There is a trailing
if (n > 0)
{
/* Strip the trailing delimiter. */
- output[n] = '\0';
+ buf[n] = '\0';
}
else
{
- output[0] = (n == 0) ? delim : '\0';
+ buf[0] = (n == 0) ? delim : '\0';
}
}
/**
* imap_get_parent_path - Get the path of the parent folder
- * @param output Buffer for the result
* @param path Mailbox whose parent is to be determined
- * @param olen Length of the buffer
+ * @param buf Buffer for the result
+ * @param buflen Length of the buffer
*
- * Provided an imap path, returns in output the parent directory if
+ * Provided an imap path, returns in buf the parent directory if
* existent. Else returns the same path.
*/
-void imap_get_parent_path(char *output, const char *path, size_t olen)
+void imap_get_parent_path(const char *path, char *buf, size_t buflen)
{
struct ImapMbox mx;
struct ImapData *idata = NULL;
if (imap_parse_path(path, &mx) < 0)
{
- mutt_str_strfcpy(output, path, olen);
+ mutt_str_strfcpy(buf, path, buflen);
return;
}
idata = imap_conn_find(&mx.account, MUTT_IMAP_CONN_NONEW);
if (!idata)
{
- mutt_str_strfcpy(output, path, olen);
+ mutt_str_strfcpy(buf, path, buflen);
return;
}
imap_fix_path(idata, mx.mbox, mbox, sizeof(mbox));
/* Gets the parent mbox in mbox */
- imap_get_parent(mbox, mbox, sizeof(mbox), idata->delim);
+ imap_get_parent(mbox, idata->delim, mbox, sizeof(mbox));
/* Returns a fully qualified IMAP url */
- imap_qualify_path(output, olen, &mx, mbox);
+ imap_qualify_path(buf, buflen, &mx, mbox);
FREE(&mx.mbox);
}
mutt_extract_token(path, s, 0);
#ifdef USE_NOTMUCH
if (mx_is_notmuch(path->data))
- nm_normalize_uri(buf, path->data, sizeof(buf));
+ nm_normalize_uri(path->data, buf, sizeof(buf));
else
#endif
mutt_str_strfcpy(buf, path->data, sizeof(buf));
#ifdef USE_NOTMUCH
if (mx_is_notmuch(path->data))
{
- nm_normalize_uri(buf, path->data, sizeof(buf));
+ nm_normalize_uri(path->data, buf, sizeof(buf));
}
else
#endif
/**
* maildir_canon_filename - Generate the canonical filename for a Maildir folder
- * @param dest Buffer for the result
- * @param src Buffer containing source filename
- * @param l Length of dest buffer
- * @retval ptr Dest buffer
+ * @param src Buffer containing source filename
+ * @param buf Buffer for the result
+ * @param buflen Length of buf buffer
+ * @retval ptr Buf buffer
*/
-static char *maildir_canon_filename(char *dest, const char *src, size_t l)
+static char *maildir_canon_filename(const char *src, char *buf, size_t buflen)
{
char *t = strrchr(src, '/');
if (t)
src = t + 1;
- mutt_str_strfcpy(dest, src, l);
- char *u = strrchr(dest, ':');
+ mutt_str_strfcpy(buf, src, buflen);
+ char *u = strrchr(buf, ':');
if (u)
*u = '\0';
- return dest;
+ return buf;
}
/**
for (p = md; p; p = p->next)
{
- maildir_canon_filename(buf, p->h->path, sizeof(buf));
+ maildir_canon_filename(p->h->path, buf, sizeof(buf));
p->canon_fname = mutt_str_strdup(buf);
mutt_hash_insert(fnames, p->canon_fname, p);
}
for (int i = 0; i < ctx->msgcount; i++)
{
ctx->hdrs[i]->active = false;
- maildir_canon_filename(buf, ctx->hdrs[i]->path, sizeof(buf));
+ maildir_canon_filename(ctx->hdrs[i]->path, buf, sizeof(buf));
p = mutt_hash_find(fnames, buf);
if (p && p->h)
{
while ((de = readdir(dp)))
{
- maildir_canon_filename(tunique, de->d_name, sizeof(tunique));
+ maildir_canon_filename(de->d_name, tunique, sizeof(tunique));
if (mutt_str_strcmp(tunique, unique) == 0)
{
static unsigned int new_hits = 0, cur_hits = 0; /* simple dynamic optimization */
- maildir_canon_filename(unique, msg, sizeof(unique));
+ maildir_canon_filename(msg, unique, sizeof(unique));
FILE *fp = md_open_find_message(folder, unique, new_hits > cur_hits ? "new" : "cur", newname);
if (fp || (errno != ENOENT))
/**
* mutt_b64_encode - Convert raw bytes to null-terminated base64 string
- * @param out Output buffer for the base64 encoded string
- * @param cin Input buffer for the raw bytes
- * @param len Length of the input buffer
- * @param olen Length of the output buffer
+ * @param in Input buffer for the raw bytes
+ * @param inlen Length of the input buffer
+ * @param out Output buffer for the base64 encoded string
+ * @param outlen Length of the output buffer
* @retval num Length of the string written to the output buffer
*
* This function performs base64 encoding. The resulting string is guaranteed
* to be null-terminated. The number of characters up to the terminating
- * null-byte is returned (equivalent to calling strlen() on the output buffer
+ * NUL-byte is returned (equivalent to calling strlen() on the output buffer
* after this function returns).
*/
-size_t mutt_b64_encode(char *out, const char *cin, size_t len, size_t olen)
+size_t mutt_b64_encode(const char *in, size_t inlen, char *out, size_t outlen)
{
unsigned char *begin = (unsigned char *) out;
- const unsigned char *in = (const unsigned char *) cin;
+ const unsigned char *inu = (const unsigned char *) in;
- while ((len >= 3) && (olen > 10))
+ while ((inlen >= 3) && (outlen > 10))
{
- *out++ = B64Chars[in[0] >> 2];
- *out++ = B64Chars[((in[0] << 4) & 0x30) | (in[1] >> 4)];
- *out++ = B64Chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
- *out++ = B64Chars[in[2] & 0x3f];
- olen -= 4;
- len -= 3;
- in += 3;
+ *out++ = B64Chars[inu[0] >> 2];
+ *out++ = B64Chars[((inu[0] << 4) & 0x30) | (inu[1] >> 4)];
+ *out++ = B64Chars[((inu[1] << 2) & 0x3c) | (inu[2] >> 6)];
+ *out++ = B64Chars[inu[2] & 0x3f];
+ outlen -= 4;
+ inlen -= 3;
+ inu += 3;
}
/* clean up remainder */
- if ((len > 0) && (olen > 4))
+ if ((inlen > 0) && (outlen > 4))
{
unsigned char fragment;
- *out++ = B64Chars[in[0] >> 2];
- fragment = (in[0] << 4) & 0x30;
- if (len > 1)
- fragment |= in[1] >> 4;
+ *out++ = B64Chars[inu[0] >> 2];
+ fragment = (inu[0] << 4) & 0x30;
+ if (inlen > 1)
+ fragment |= inu[1] >> 4;
*out++ = B64Chars[fragment];
- *out++ = (len < 2) ? '=' : B64Chars[(in[1] << 2) & 0x3c];
+ *out++ = (inlen < 2) ? '=' : B64Chars[(inu[1] << 2) & 0x3c];
*out++ = '=';
}
*out = '\0';
/**
* mutt_b64_decode - Convert null-terminated base64 string to raw bytes
- * @param out Output buffer for the raw bytes
* @param in Input buffer for the null-terminated base64-encoded string
+ * @param out Output buffer for the raw bytes
* @param olen Length of the output buffer
* @retval num Success, bytes written
* @retval -1 Error
* null-terminated. If the input buffer contains invalid base64 characters,
* this function returns -1.
*/
-int mutt_b64_decode(char *out, const char *in, size_t olen)
+int mutt_b64_decode(const char *in, char *out, size_t olen)
{
int len = 0;
unsigned char digit4;
#define base64val(c) Index64[(unsigned int) (c)]
-int mutt_b64_decode(char *out, const char *in, size_t olen);
-size_t mutt_b64_encode(char *out, const char *cin, size_t len, size_t olen);
+int mutt_b64_decode(const char *in, char *out, size_t olen);
+size_t mutt_b64_encode(const char *in, size_t inlen, char *out, size_t outlen);
#endif /* _MUTT_BASE64_H */
/**
* mutt_file_quote_filename - Quote a filename to survive the shell's quoting rules
- * @param d Buffer for the result
- * @param l Length of buffer
- * @param f String to convert
+ * @param filename String to convert
+ * @param buf Buffer for the result
+ * @param buflen Length of buffer
* @retval num Bytes written to the buffer
*
* From the Unix programming FAQ by way of Liviu.
*/
-size_t mutt_file_quote_filename(char *d, size_t l, const char *f)
+size_t mutt_file_quote_filename(const char *filename, char *buf, size_t buflen)
{
size_t j = 0;
- if (!f)
+ if (!filename)
{
- *d = '\0';
+ *buf = '\0';
return 0;
}
/* leave some space for the trailing characters. */
- l -= 6;
+ buflen -= 6;
- d[j++] = '\'';
+ buf[j++] = '\'';
- for (size_t i = 0; (j < l) && f[i]; i++)
+ for (size_t i = 0; (j < buflen) && filename[i]; i++)
{
- if ((f[i] == '\'') || (f[i] == '`'))
+ if ((filename[i] == '\'') || (filename[i] == '`'))
{
- d[j++] = '\'';
- d[j++] = '\\';
- d[j++] = f[i];
- d[j++] = '\'';
+ buf[j++] = '\'';
+ buf[j++] = '\\';
+ buf[j++] = filename[i];
+ buf[j++] = '\'';
}
else
- d[j++] = f[i];
+ buf[j++] = filename[i];
}
- d[j++] = '\'';
- d[j] = '\0';
+ buf[j++] = '\'';
+ buf[j] = '\0';
return j;
}
{
char tmp[PATH_MAX];
- mutt_file_quote_filename(tmp, sizeof(tmp), src);
+ mutt_file_quote_filename(src, tmp, sizeof(tmp));
mutt_file_expand_fmt(dest, destlen, fmt, tmp);
}
FILE * mutt_file_mkstemp_full(const char *file, int line, const char *func);
#define mutt_file_mkstemp() mutt_file_mkstemp_full(__FILE__, __LINE__, __func__)
int mutt_file_open(const char *path, int flags);
-size_t mutt_file_quote_filename(char *d, size_t l, const char *f);
+size_t mutt_file_quote_filename(const char *filename, char *buf, size_t buflen);
char * mutt_file_read_keyword(const char *file, char *buf, size_t buflen);
char * mutt_file_read_line(char *s, size_t *size, FILE *fp, int *line, int flags);
int mutt_file_rename(char *oldfile, char *newfile);
{
#ifdef USE_IMAP
if (mx_is_imap(path))
- imap_get_parent_path(buf, path, buflen);
+ imap_get_parent_path(path, buf, buflen);
else
#endif
#ifdef USE_NOTMUCH
char cmd[HUGE_STRING];
struct PgpCommandContext cctx = { 0 };
- mutt_file_quote_filename(tmp_fname, sizeof(tmp_fname), fname);
+ mutt_file_quote_filename(fname, tmp_fname, sizeof(tmp_fname));
cctx.fname = tmp_fname;
if (PgpSignAs && *PgpSignAs)
cctx.signas = PgpSignAs;
*tmp = '\0';
mutt_addrlist_to_local(addr);
mutt_addr_write_single(tmp, sizeof(tmp), addr, false);
- mutt_file_quote_filename(buf, sizeof(buf), tmp);
+ mutt_file_quote_filename(tmp, buf, sizeof(buf));
addr->personal = personal;
struct ListNode *np = NULL;
STAILQ_FOREACH(np, hints, entries)
{
- mutt_file_quote_filename(quoted, sizeof(quoted), (char *) np->data);
+ mutt_file_quote_filename((char *) np->data, quoted, sizeof(quoted));
snprintf(tmpuids, sizeof(tmpuids), "%s %s", uids, quoted);
strcpy(uids, tmpuids);
}
mutt_str_strfcpy(path, SmimeCaLocation, sizeof(path));
mutt_expand_path(path, sizeof(path));
- mutt_file_quote_filename(buf1, sizeof(buf1), path);
+ mutt_file_quote_filename(path, buf1, sizeof(buf1));
if (stat(path, &sb) != 0 || !S_ISDIR(sb.st_mode))
snprintf(buf2, sizeof(buf2), "-CAfile %s", buf1);
/**
* rename_maildir_filename - Rename a Maildir file
- * @param old Old path
- * @param newpath Buffer for new path
- * @param newsz Length of buffer
- * @param h Email Header
+ * @param old Old path
+ * @param buf Buffer for new path
+ * @param buflen Length of buffer
+ * @param h Email Header
* @retval 0 Success, renamed
* @retval 1 Success, no change
* @retval -1 Failure
*/
-static int rename_maildir_filename(const char *old, char *newpath, size_t newsz,
+static int rename_maildir_filename(const char *old, char *buf, size_t buflen,
struct Header *h)
{
char filename[PATH_MAX];
/* compose new flags */
maildir_flags(suffix, sizeof(suffix), h);
- snprintf(newpath, newsz, "%s/%s/%s%s", folder,
+ snprintf(buf, buflen, "%s/%s/%s%s", folder,
(h->read || h->old) ? "cur" : "new", filename, suffix);
- if (strcmp(old, newpath) == 0)
+ if (strcmp(old, buf) == 0)
return 1;
- if (rename(old, newpath) != 0)
+ if (rename(old, buf) != 0)
{
- mutt_debug(1, "nm: rename(2) failed %s -> %s\n", old, newpath);
+ mutt_debug(1, "nm: rename(2) failed %s -> %s\n", old, buf);
return -1;
}
/**
* nm_normalize_uri - takes a notmuch URI, parses it and reformat it in a canonical way
- * @param new_uri allocated string receiving the reformatted URI
- * @param orig_uri original URI to be parsed
- * @param new_uri_sz size of the allocated new_uri string
- * @retval true if new_uri contains a normalized version of the query
- * @retval false if orig_uri contains an invalid query
+ * @param uri Original URI to be parsed
+ * @param buf Buffer for the reformatted URI
+ * @param buflen Size of the buffer
+ * @retval true if buf contains a normalized version of the query
+ * @retval false if uri contains an invalid query
*
* This function aims at making notmuch searches URI representations deterministic,
* so that when comparing two equivalent searches they will be the same. It works
* It's aimed to be used by mailbox when parsing the virtual_mailboxes to make the
* parsed user written search strings comparable to the internally generated ones.
*/
-bool nm_normalize_uri(char *new_uri, const char *orig_uri, size_t new_uri_sz)
+bool nm_normalize_uri(const char *uri, char *buf, size_t buflen)
{
- mutt_debug(2, "(%s)\n", orig_uri);
- char buf[PATH_MAX];
+ mutt_debug(2, "(%s)\n", uri);
+ char tmp[PATH_MAX];
int rc = -1;
struct Context tmp_ctx = { 0 };
- struct NmCtxData *tmp_ctxdata = new_ctxdata(orig_uri);
+ struct NmCtxData *tmp_ctxdata = new_ctxdata(uri);
if (!tmp_ctxdata)
return false;
mutt_debug(2, "#2 () -> db_query: %s\n", tmp_ctxdata->db_query);
- mutt_str_strfcpy(buf, tmp_ctxdata->db_query, sizeof(buf));
+ mutt_str_strfcpy(tmp, tmp_ctxdata->db_query, sizeof(tmp));
- if (!nm_uri_from_query(&tmp_ctx, buf, sizeof(buf)))
+ if (!nm_uri_from_query(&tmp_ctx, tmp, sizeof(tmp)))
goto gone;
- strncpy(new_uri, buf, new_uri_sz);
+ strncpy(buf, tmp, buflen);
- mutt_debug(2, "#3 (%s) -> %s\n", orig_uri, new_uri);
+ mutt_debug(2, "#3 (%s) -> %s\n", uri, buf);
rc = 0;
gone:
FREE(&tmp_ctxdata);
if (rc < 0)
{
- mutt_error(_("failed to parse notmuch uri: %s"), orig_uri);
+ mutt_error(_("failed to parse notmuch uri: %s"), uri);
mutt_debug(2, "() -> error\n");
return false;
}
char *nm_header_get_folder(struct Header *h);
int nm_update_filename(struct Context *ctx, const char *old, const char *new, struct Header *h);
-bool nm_normalize_uri(char *new_uri, const char *orig_uri, size_t new_uri_sz);
+bool nm_normalize_uri(const char *uri, char *buf, size_t buflen);
char *nm_uri_from_query(struct Context *ctx, char *buf, size_t buflen);
bool nm_message_is_still_queried(struct Context *ctx, struct Header *hdr);
STAILQ_FOREACH(np, chain, entries)
{
mutt_str_strfcpy(tmp, cmd, sizeof(tmp));
- mutt_file_quote_filename(cd_quoted, sizeof(cd_quoted), np->data);
+ mutt_file_quote_filename(np->data, cd_quoted, sizeof(cd_quoted));
snprintf(cmd, sizeof(cmd), "%s%s%s", tmp,
(np == STAILQ_FIRST(chain)) ? " -l " : ",", cd_quoted);
}
if (MailcapSanitize)
mutt_file_sanitize_filename(pvalue, false);
- y += mutt_file_quote_filename(buf + y, sizeof(buf) - y, pvalue);
+ y += mutt_file_quote_filename(pvalue, buf + y, sizeof(buf) - y);
}
else if (command[x] == 's' && filename)
{
- y += mutt_file_quote_filename(buf + y, sizeof(buf) - y, filename);
+ y += mutt_file_quote_filename(filename, buf + y, sizeof(buf) - y);
needspipe = false;
}
else if (command[x] == 't')
{
- y += mutt_file_quote_filename(buf + y, sizeof(buf) - y, type2);
+ y += mutt_file_quote_filename(type2, buf + y, sizeof(buf) - y);
}
x++;
}
/* ret should always be equal to 4 here, because ctx->size
* is a value between 1 and 3 (included), but let's not hardcode it
* and prefer the return value of the function */
- ret = mutt_b64_encode(encoded, ctx->buffer, ctx->size, sizeof(encoded));
+ ret = mutt_b64_encode(ctx->buffer, ctx->size, encoded, sizeof(encoded));
for (size_t i = 0; i < ret; i++)
{
fputc(encoded[i], fout);
void test_base64_encode(void)
{
char buffer[16];
- size_t len = mutt_b64_encode(buffer, clear, sizeof(clear) - 1, sizeof(buffer));
+ size_t len = mutt_b64_encode(clear, sizeof(clear) - 1, buffer, sizeof(buffer));
if (!TEST_CHECK(len == sizeof(encoded) - 1))
{
TEST_MSG("Expected: %zu", sizeof(encoded) - 1);
void test_base64_decode(void)
{
char buffer[16];
- int len = mutt_b64_decode(buffer, encoded, sizeof(buffer));
+ int len = mutt_b64_decode(encoded, buffer, sizeof(buffer));
if (!TEST_CHECK(len == sizeof(clear) - 1))
{
TEST_MSG("Expected: %zu", sizeof(clear) - 1);
int declen;
/* Encoding a zero-length string should fail */
- enclen = mutt_b64_encode(out1, in, 0, 32);
+ enclen = mutt_b64_encode(in, 0, out1, 32);
if (!TEST_CHECK(enclen == 0))
{
TEST_MSG("Expected: %zu", 0);
/* Decoding a zero-length string should fail, too */
out1[0] = '\0';
- declen = mutt_b64_decode(out2, out1, sizeof(out2));
+ declen = mutt_b64_decode(out1, out2, sizeof(out2));
if (!TEST_CHECK(declen == -1))
{
TEST_MSG("Expected: %zu", -1);
/* Encode one to eight bytes, check the lengths of the returned string */
for (size_t i = 1; i <= 8; ++i)
{
- enclen = mutt_b64_encode(out1, in, i, 32);
+ enclen = mutt_b64_encode(in, i, out1, 32);
size_t exp = ((i + 2) / 3) << 2;
if (!TEST_CHECK(enclen == exp))
{
TEST_MSG("Expected: %zu", exp);
TEST_MSG("Actual : %zu", enclen);
}
- declen = mutt_b64_decode(out2, out1, sizeof(out2));
+ declen = mutt_b64_decode(out1, out2, sizeof(out2));
if (!TEST_CHECK(declen == i))
{
TEST_MSG("Expected: %zu", i);