Skip to content

Commit

Permalink
charset: rename encode_mimebody to b64encode_mimebody
Browse files Browse the repository at this point in the history
This aligns the function name with qpencode_mimebody.

Signed-off-by: Robert Stepanek <rsto@fastmailteam.com>
  • Loading branch information
rsto committed Apr 2, 2024
1 parent d3024a7 commit fc2a1f7
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cunit/charset.testc
Original file line number Diff line number Diff line change
Expand Up @@ -1548,15 +1548,15 @@ static void test_encode_mimebody(void)
size_t wantlen = strlen(want); \
size_t preflight_outlen = 0xffee; \
int preflight_outlines = 0x1234; \
char *preflight_retval = charset_encode_mimebody(NULL, inlen, NULL, \
char *preflight_retval = charset_b64encode_mimebody(NULL, inlen, NULL, \
&preflight_outlen, &preflight_outlines, wrap); \
CU_ASSERT_PTR_NULL(preflight_retval); \
CU_ASSERT_EQUAL(wantlen, preflight_outlen); \
CU_ASSERT_EQUAL(wantlines, preflight_outlines); \
char *retval = malloc(preflight_outlen); \
size_t encode_outlen = 0x1234; \
int encode_outlines = 0xffee; \
char *encode_retval = charset_encode_mimebody(in, inlen, \
char *encode_retval = charset_b64encode_mimebody(in, inlen, \
retval, &encode_outlen, &encode_outlines, wrap); \
CU_ASSERT_PTR_EQUAL(retval, encode_retval); \
CU_ASSERT_EQUAL(wantlen, encode_outlen); \
Expand Down
4 changes: 2 additions & 2 deletions cunit/xsha1.testc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ static void _checksha(const char *text, size_t len, const char *expect)

// test charset version - encoded
size_t len64 = 0;
charset_encode_mimebody(NULL, len, NULL, &len64, NULL, 1 /* wrap */);
charset_b64encode_mimebody(NULL, len, NULL, &len64, NULL, 1 /* wrap */);
if (len64) {
char *encbuf = xmalloc(len64);
size_t outlen = 0;
memset(dest, 0, sizeof(dest));
memset(hexstr, 0, sizeof(hexstr));
charset_encode_mimebody(text, len, encbuf, &len64, NULL, 1 /* wrap */);
charset_b64encode_mimebody(text, len, encbuf, &len64, NULL, 1 /* wrap */);
charset_decode_sha1(dest, &outlen, encbuf, len64, ENCODING_BASE64);
bin_to_hex(dest, SHA1_DIGEST_LENGTH, hexstr, BH_LOWER);
CU_ASSERT_STRING_EQUAL(expect, hexstr);
Expand Down
4 changes: 2 additions & 2 deletions imap/http_caldav_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,10 @@ static int imip_send_sendmail(const char *userid, icalcomponent *ical, const cha
buf_appendcstr(&msgbuf, "Content-Transfer-Encoding: base64\r\n");
buf_appendcstr(&msgbuf, "\r\n");

charset_encode_mimebody(NULL, strlen(ical_str), NULL, &outlen,
charset_b64encode_mimebody(NULL, strlen(ical_str), NULL, &outlen,
NULL, 1 /* wrap */);
buf_ensure(&tmpbuf, outlen);
charset_encode_mimebody(ical_str, strlen(ical_str),
charset_b64encode_mimebody(ical_str, strlen(ical_str),
(char *) buf_base(&tmpbuf), &outlen,
NULL, 1 /* wrap */);
buf_appendmap(&msgbuf, buf_base(&tmpbuf), outlen);
Expand Down
8 changes: 4 additions & 4 deletions imap/jmap_contact.c
Original file line number Diff line number Diff line change
Expand Up @@ -3570,11 +3570,11 @@ static int _blob_to_card(struct jmap_req *req,

/* Pre-flight base64 encoder to determine length */
size_t len64 = 0;
charset_encode_mimebody(NULL, len, NULL, &len64, NULL, 0 /* no wrap */);
charset_b64encode_mimebody(NULL, len, NULL, &len64, NULL, 0 /* no wrap */);

/* Now encode the blob */
encbuf = xzmalloc(len64+1);
charset_encode_mimebody(base, len, encbuf, &len64, NULL, 0 /* no wrap */);
charset_b64encode_mimebody(base, len, encbuf, &len64, NULL, 0 /* no wrap */);
base = encbuf;

/* (Re)write vCard property */
Expand Down Expand Up @@ -9926,12 +9926,12 @@ static vcardproperty *_jsresource_to_vcard(struct jmap_parser *parser, json_t *o

/* Pre-flight base64 encoder to determine length */
size_t len64 = 0;
charset_encode_mimebody(NULL, len, NULL,
charset_b64encode_mimebody(NULL, len, NULL,
&len64, NULL, 0 /* no wrap */);

/* Now encode the blob */
buf_ensure(&buf, len64+1);
charset_encode_mimebody(base, len,
charset_b64encode_mimebody(base, len,
(char *) buf_base(&buf) + buf_len(&buf),
&len64, NULL, 0 /* no wrap */);
buf_truncate(&buf, buf_len(&buf) + len64);
Expand Down
10 changes: 5 additions & 5 deletions imap/jmap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ static int jmap_blob_get(jmap_req_t *req)
if (want_base64) {
if (len) {
size_t len64 = 0;
charset_encode_mimebody(NULL, len, NULL, &len64, NULL, 0 /* no wrap */);
charset_b64encode_mimebody(NULL, len, NULL, &len64, NULL, 0 /* no wrap */);
char *encbuf = xzmalloc(len64+1);
charset_encode_mimebody(base, len, encbuf, &len64, NULL, 0 /* no wrap */);
charset_b64encode_mimebody(base, len, encbuf, &len64, NULL, 0 /* no wrap */);
json_object_set_new(item, "data:asBase64", json_stringn(encbuf, len64));
free(encbuf);
}
Expand All @@ -639,7 +639,7 @@ static int jmap_blob_get(jmap_req_t *req)
md5((unsigned char *)base, len, data);
size_t len64 = 24;
char output[24];
charset_encode_mimebody((char *)data, 16, output, &len64, NULL, 0 /* no wrap */);
charset_b64encode_mimebody((char *)data, 16, output, &len64, NULL, 0 /* no wrap */);
json_object_set_new(item, "digest:md5", json_stringn(output, 24));
}

Expand All @@ -649,7 +649,7 @@ static int jmap_blob_get(jmap_req_t *req)
xsha1((unsigned char *)base, len, data);
size_t len64 = 28;
char output[28];
charset_encode_mimebody((char *)data, 20, output, &len64, NULL, 0 /* no wrap */);
charset_b64encode_mimebody((char *)data, 20, output, &len64, NULL, 0 /* no wrap */);
json_object_set_new(item, "digest:sha", json_stringn(output, 28));
}

Expand All @@ -660,7 +660,7 @@ static int jmap_blob_get(jmap_req_t *req)
xsha256((unsigned char *)base, len, data);
size_t len64 = 44;
char output[44];
charset_encode_mimebody((char *)data, 32, output, &len64, NULL, 0 /* no wrap */);
charset_b64encode_mimebody((char *)data, 32, output, &len64, NULL, 0 /* no wrap */);
json_object_set_new(item, "digest:sha-256", json_stringn(output, 44));
}

Expand Down
4 changes: 2 additions & 2 deletions imap/jmap_mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -10529,11 +10529,11 @@ static void _emailpart_blob_to_mime(jmap_req_t *req,
encoding = "BASE64";
size_t len64 = 0;
/* Pre-flight encoder to determine length */
charset_encode_mimebody(NULL, content_size, NULL, &len64, NULL, 1 /* wrap */);
charset_b64encode_mimebody(NULL, content_size, NULL, &len64, NULL, 1 /* wrap */);
if (len64) {
/* Now encode the body */
encbuf = xmalloc(len64);
charset_encode_mimebody(content, content_size, encbuf, &len64, NULL, 1 /* wrap */);
charset_b64encode_mimebody(content, content_size, encbuf, &len64, NULL, 1 /* wrap */);
}
content = encbuf;
content_size = len64;
Expand Down
4 changes: 2 additions & 2 deletions imap/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ static void message_parse_content(struct msg *msg, struct body *body,
int b64_lines, delta;

/* Determine encoded size */
charset_encode_mimebody(NULL, body->content_size, NULL,
charset_b64encode_mimebody(NULL, body->content_size, NULL,
&b64_size, NULL, 1 /* wrap */);

delta = b64_size - body->content_size;
Expand All @@ -1968,7 +1968,7 @@ static void message_parse_content(struct msg *msg, struct body *body,
msg->len - s_offset);

/* Encode content into buffer at current position */
charset_encode_mimebody(msg->base + s_offset + delta,
charset_b64encode_mimebody(msg->base + s_offset + delta,
body->content_size,
(char*) msg->base + s_offset,
NULL, &b64_lines, 1 /* wrap */);
Expand Down
6 changes: 3 additions & 3 deletions lib/charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -3782,9 +3782,9 @@ EXPORTED const char *charset_decode_mimebody(const char *msg_base, size_t len, i
static const char base_64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

EXPORTED char *charset_encode_mimebody(const char *msg_base, size_t len,
char *retval, size_t *outlen,
int *outlines, int wrap)
EXPORTED char *charset_b64encode_mimebody(const char *msg_base, size_t len,
char *retval, size_t *outlen,
int *outlines, int wrap)
{
const unsigned char *s;
unsigned char s0, s1, s2;
Expand Down
6 changes: 3 additions & 3 deletions lib/charset.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ extern int charset_searchfile(const char *substr, comp_pat *pat,
extern const char *charset_decode_mimebody(const char *msg_base, size_t len,
int encoding, char **retval,
size_t *outlen);
extern char *charset_encode_mimebody(const char *msg_base, size_t len,
char *retval, size_t *outlen,
int *outlines, int wrap);
extern char *charset_b64encode_mimebody(const char *msg_base, size_t len,
char *retval, size_t *outlen,
int *outlines, int wrap);
extern char *charset_qpencode_mimebody(const char *msg_base, size_t len,
int force_quote, size_t *outlen);
extern char *charset_to_utf8cstr(const char *msg_base, size_t len, charset_t charset, int encoding);
Expand Down

0 comments on commit fc2a1f7

Please sign in to comment.