"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static int
-b64_encode(const uint8 *src, unsigned len, uint8 *dst)
+pg_base64_encode(const uint8 *src, unsigned len, uint8 *dst)
{
uint8 *p,
*lend = dst + 76;
/* probably should use lookup table */
static int
-b64_decode(const uint8 *src, unsigned len, uint8 *dst)
+pg_base64_decode(const uint8 *src, unsigned len, uint8 *dst)
{
const uint8 *srcend = src + len,
*s = src;
}
static unsigned
-b64_enc_len(unsigned srclen)
+pg_base64_enc_len(unsigned srclen)
{
/*
* 3 bytes will be converted to 4, linefeed after 76 chars
}
static unsigned
-b64_dec_len(unsigned srclen)
+pg_base64_dec_len(unsigned srclen)
{
return (srclen * 3) >> 2;
}
appendStringInfo(dst, "%s: %s\n", keys[n], values[n]);
appendStringInfoChar(dst, '\n');
- /* make sure we have enough room to b64_encode() */
- b64len = b64_enc_len(len);
+ /* make sure we have enough room to pg_base64_encode() */
+ b64len = pg_base64_enc_len(len);
enlargeStringInfo(dst, (int) b64len);
- res = b64_encode(src, len, (uint8 *) dst->data + dst->len);
+ res = pg_base64_encode(src, len, (uint8 *) dst->data + dst->len);
if (res > b64len)
elog(FATAL, "overflow - encode estimate too small");
dst->len += res;
goto out;
/* decode crc */
- if (b64_decode(p + 1, 4, buf) != 3)
+ if (pg_base64_decode(p + 1, 4, buf) != 3)
goto out;
crc = (((long) buf[0]) << 16) + (((long) buf[1]) << 8) + (long) buf[2];
/* decode data */
- blen = (int) b64_dec_len(len);
+ blen = (int) pg_base64_dec_len(len);
enlargeStringInfo(dst, blen);
- res = b64_decode(base64_start, base64_end - base64_start, (uint8 *) dst->data);
+ res = pg_base64_decode(base64_start, base64_end - base64_start, (uint8 *) dst->data);
if (res > blen)
elog(FATAL, "overflow - decode estimate too small");
if (res >= 0)
};
static unsigned
-b64_encode(const char *src, unsigned len, char *dst)
+pg_base64_encode(const char *src, unsigned len, char *dst)
{
char *p,
*lend = dst + 76;
}
static unsigned
-b64_decode(const char *src, unsigned len, char *dst)
+pg_base64_decode(const char *src, unsigned len, char *dst)
{
const char *srcend = src + len,
*s = src;
static unsigned
-b64_enc_len(const char *src, unsigned srclen)
+pg_base64_enc_len(const char *src, unsigned srclen)
{
/* 3 bytes will be converted to 4, linefeed after 76 chars */
return (srclen + 2) * 4 / 3 + srclen / (76 * 3 / 4);
}
static unsigned
-b64_dec_len(const char *src, unsigned srclen)
+pg_base64_dec_len(const char *src, unsigned srclen)
{
return (srclen * 3) >> 2;
}
{
"base64",
{
- b64_enc_len, b64_dec_len, b64_encode, b64_decode
+ pg_base64_enc_len, pg_base64_dec_len, pg_base64_encode, pg_base64_decode
}
},
{