]> granicus.if.org Git - neomutt/commitdiff
unify buf,buflen, with reordering
authorRichard Russon <rich@flatcap.org>
Sun, 19 Aug 2018 01:46:07 +0000 (02:46 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 19 Aug 2018 12:44:18 +0000 (13:44 +0100)
23 files changed:
alias.c
conn/sasl_plain.c
email/rfc2047.c
imap/auth_cram.c
imap/auth_gss.c
imap/imap.h
imap/imap_private.h
imap/util.c
mailbox.c
maildir/mh.c
mutt/base64.c
mutt/base64.h
mutt/file.c
mutt/file.h
muttlib.c
ncrypt/pgpinvoke.c
ncrypt/smime.c
notmuch/mutt_notmuch.c
notmuch/mutt_notmuch.h
remailer.c
rfc1524.c
sendlib.c
test/base64.c

diff --git a/alias.c b/alias.c
index 1ab40fb1d2ea715dcd1c5b7a29c30f0595e32a54..3438d6a52bf0fda43a11c95e073e9be9e0f23127 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -489,7 +489,7 @@ retry_name:
     }
 
     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));
index acbfa732529e5ab4725db6151fb825a59e068385..90b9b671e1dc1fb079e47ef3f8e11eecba04f994 100644 (file)
@@ -67,6 +67,6 @@ size_t mutt_sasl_plain_msg(char *buf, size_t buflen, const char *cmd,
   {
     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;
 }
index 43b21b83a7f0c9ab7432f7de70d7265dedcc4c69..7b4a1c7b94a2f05e93e6caf5ad9ca8cf5b27a83a 100644 (file)
@@ -78,7 +78,7 @@ static size_t b_encoder(char *str, const char *buf, size_t buflen, const char *t
     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];
 
@@ -397,7 +397,7 @@ static char *decode_word(const char *s, size_t len, enum ContentEncoding enc)
   {
     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);
index 2566f12f597c8ee007513dcacdce29dd04e8fde9..176fddf6faa3e315884f411dcde3829d47fe975e 100644 (file)
@@ -131,7 +131,7 @@ enum ImapAuthRes imap_auth_cram_md5(struct ImapData *idata, const char *method)
     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");
@@ -160,7 +160,7 @@ enum ImapAuthRes imap_auth_cram_md5(struct ImapData *idata, const char *method)
 
   /* 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);
 
index 3dfd9dc42a02985248aa560ad30a0efbafa55e7f..b7f138dc384d64169aeb9c0b4308e27159d3c7e2 100644 (file)
@@ -180,7 +180,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method)
 
   /* 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);
@@ -199,7 +199,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method)
       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;
 
@@ -216,7 +216,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method)
 
       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);
@@ -234,7 +234,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method)
     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);
@@ -282,7 +282,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method)
     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);
index 135dae2fb71bbfaa2a453ca74e09aecabca4eb03..fc047fc2232452999bea91d1d9ce4442f3602690 100644 (file)
@@ -115,7 +115,7 @@ void imap_pretty_mailbox(char *path);
 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 */
index d15f99dac7a7d1118d9c516e3ca8fef6b79a6e82..8f68e971fa231713b32124cee7b1654184bc2001 100644 (file)
@@ -332,7 +332,7 @@ void imap_unquote_string(char *s);
 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);
index e665983be177074e320df735a48893ce3953c65e..689b9f19396fd963c282e1e8d3c11ca329812f18 100644 (file)
@@ -101,32 +101,32 @@ int imap_expand_path(char *buf, size_t buflen)
 
 /**
  * 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
@@ -135,24 +135,24 @@ void imap_get_parent(char *output, const char *mbox, size_t olen, char delim)
   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;
@@ -160,14 +160,14 @@ void imap_get_parent_path(char *output, const char *path, size_t olen)
 
   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;
   }
 
@@ -175,10 +175,10 @@ void imap_get_parent_path(char *output, const char *path, size_t olen)
   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);
 }
 
index 8fbe1a1fe002cda4b1d9fd391886e7419b7e9bc9..365e2acde073a15b5c3b8f44e3d31f5303be6279 100644 (file)
--- a/mailbox.c
+++ b/mailbox.c
@@ -624,7 +624,7 @@ int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s,
     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));
@@ -725,7 +725,7 @@ int mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s,
 #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
index 3042b0dcf1671c9a60dae74601f1291059a6c58e..7fa01119ad7930eb94772f2cd27e000e7cc3149b 100644 (file)
@@ -2252,23 +2252,23 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno)
 
 /**
  * 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;
 }
 
 /**
@@ -2370,7 +2370,7 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint)
 
   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);
   }
@@ -2379,7 +2379,7 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint)
   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)
     {
@@ -2737,7 +2737,7 @@ static FILE *md_open_find_message(const char *folder, const char *unique,
 
   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)
     {
@@ -2770,7 +2770,7 @@ FILE *maildir_open_find_message(const char *folder, const char *msg, char **newn
 
   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))
index 5ee67e32c6ea83b4867120a93d1fa434e116e214..e4ef8780cbb7054ca8e27bf8ed646a60b44d0e11 100644 (file)
@@ -71,44 +71,44 @@ const int Index64[128] = {
 
 /**
  * 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';
@@ -117,8 +117,8 @@ size_t mutt_b64_encode(char *out, const char *cin, size_t len, size_t olen)
 
 /**
  * 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
@@ -127,7 +127,7 @@ size_t mutt_b64_encode(char *out, const char *cin, size_t len, size_t olen)
  * 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;
index d6dc45edba48842c7f05fcd1da0e94f9953b7767..d2a6ed7999a371148df16cc2da049326297a30ac 100644 (file)
@@ -27,7 +27,7 @@ extern const int Index64[];
 
 #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 */
index 94cacb0acdf837a76bbac33e077d83d7d8e86a2e..34bc013952ebed05d6b1b6ded01a06f0d75845a9 100644 (file)
@@ -660,43 +660,43 @@ char *mutt_file_read_line(char *s, size_t *size, FILE *fp, int *line, int flags)
 
 /**
  * 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;
 }
@@ -1250,7 +1250,7 @@ void mutt_file_expand_fmt_quote(char *dest, size_t destlen, const char *fmt, con
 {
   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);
 }
 
index 8f5dba3f3008b06ef5fdee23e1bba34ee1bce583..85fab0f397c5f805b01a35bcbb2ac2d4c9acc8e1 100644 (file)
@@ -54,7 +54,7 @@ int         mutt_file_mkdir(const char *path, mode_t mode);
 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);
index 2c3c0889c72465a25b1f3856f01a1961ff8e2396..e6be323ec924b06dd0bbe41f4e0069af746be57b 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -1514,7 +1514,7 @@ void mutt_get_parent_path(char *path, char *buf, size_t buflen)
 {
 #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
index b195fd0a6f7772ddfb1a42f81c4de95adafef95b..1a3dbadfbadfc7d0b63fd2b19e531742fa95752a 100644 (file)
@@ -402,7 +402,7 @@ void pgp_class_invoke_import(const char *fname)
   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;
@@ -437,7 +437,7 @@ void pgp_class_invoke_getkeys(struct Address *addr)
   *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;
 
@@ -533,7 +533,7 @@ pid_t pgp_invoke_list_keys(FILE **pgpin, FILE **pgpout, FILE **pgperr,
   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);
   }
index 4f74c35b9fe85ac17fb2c43a6d81bc9ca715861e..028365005e18d834b5a438a328847ba2b2ea61a8 100644 (file)
@@ -229,7 +229,7 @@ static const char *fmt_smime_command(char *buf, size_t buflen, size_t col, int c
 
         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);
index 50754f933ef8c510297dc5068941e30645a1c345..a216745f91a6b3c67cdeb781d9c01aa3387012fe 100644 (file)
@@ -1520,15 +1520,15 @@ static int update_header_flags(struct Context *ctx, struct Header *hdr, const ch
 
 /**
  * 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];
@@ -1560,15 +1560,15 @@ static int rename_maildir_filename(const char *old, char *newpath, size_t newsz,
   /* 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;
   }
 
@@ -1943,11 +1943,11 @@ char *nm_uri_from_query(struct Context *ctx, char *buf, size_t buflen)
 
 /**
  * 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
@@ -1957,14 +1957,14 @@ char *nm_uri_from_query(struct Context *ctx, char *buf, size_t buflen)
  * 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;
@@ -1979,14 +1979,14 @@ bool nm_normalize_uri(char *new_uri, const char *orig_uri, size_t new_uri_sz)
 
   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:
@@ -1995,7 +1995,7 @@ 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;
   }
index f43faa70cbab77c84b866bd348b02796daff9431..56f79c2aaa48fc2d4e83d361bb4b9d56745ade3c 100644 (file)
@@ -55,7 +55,7 @@ int nm_read_entire_thread(struct Context *ctx, struct Header *h);
 
 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);
 
index 06e9819580c03d10363befb3f48789fa4de8df54..a07caba9bbdb1f0735110755874cffd7a0afb172 100644 (file)
@@ -830,7 +830,7 @@ int mix_send_message(struct ListHead *chain, const char *tempfile)
   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);
   }
index 3a9b0b5d299ddb4f0381d0d8509b82afa888a4da..2ed57ec1f7969fd7696d1c472510ca2fd8cf3955 100644 (file)
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -108,16 +108,16 @@ int rfc1524_expand_command(struct Body *a, char *filename, char *type, char *com
         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++;
     }
index bf642b98e670858f3f40a9d68a95f96c5f8f31b0..840a00926a01ad074923def90323964ad1102d4c 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -269,7 +269,7 @@ static void b64_flush(struct B64Context *ctx, FILE *fout)
   /* 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);
index f8b77dbc7e3090713e3b86e7c60003e06540b7bf..4b0b47f5948b654fc9937578c8e9708c83ac08a0 100644 (file)
@@ -11,7 +11,7 @@ static const char encoded[] = "SGVsbG8=";
 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);
@@ -27,7 +27,7 @@ void test_base64_encode(void)
 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);
@@ -50,7 +50,7 @@ void test_base64_lengths(void)
   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);
@@ -59,7 +59,7 @@ void test_base64_lengths(void)
 
   /* 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);
@@ -69,14 +69,14 @@ void test_base64_lengths(void)
   /* 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);