Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
encode.c File Reference
#include "postgres.h"
#include <ctype.h>
#include "mb/pg_wchar.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "varatt.h"
Include dependency graph for encode.c:

Go to the source code of this file.

Data Structures

struct  pg_encoding
 

Macros

#define VAL(CH)   ((CH) - '0')
 
#define DIG(VAL)   ((VAL) + '0')
 

Functions

static const struct pg_encodingpg_find_encoding (const char *name)
 
Datum binary_encode (PG_FUNCTION_ARGS)
 
Datum binary_decode (PG_FUNCTION_ARGS)
 
uint64 hex_encode (const char *src, size_t len, char *dst)
 
static bool get_hex (const char *cp, char *out)
 
uint64 hex_decode (const char *src, size_t len, char *dst)
 
uint64 hex_decode_safe (const char *src, size_t len, char *dst, Node *escontext)
 
static uint64 hex_enc_len (const char *src, size_t srclen)
 
static uint64 hex_dec_len (const char *src, size_t srclen)
 
static uint64 pg_base64_encode_internal (const char *src, size_t len, char *dst, bool url)
 
static uint64 pg_base64_encode (const char *src, size_t len, char *dst)
 
static uint64 pg_base64url_encode (const char *src, size_t len, char *dst)
 
static uint64 pg_base64_decode_internal (const char *src, size_t len, char *dst, bool url)
 
static uint64 pg_base64_decode (const char *src, size_t len, char *dst)
 
static uint64 pg_base64url_decode (const char *src, size_t len, char *dst)
 
static uint64 pg_base64_enc_len (const char *src, size_t srclen)
 
static uint64 pg_base64_dec_len (const char *src, size_t srclen)
 
static uint64 pg_base64url_enc_len (const char *src, size_t srclen)
 
static uint64 pg_base64url_dec_len (const char *src, size_t srclen)
 
static uint64 esc_encode (const char *src, size_t srclen, char *dst)
 
static uint64 esc_decode (const char *src, size_t srclen, char *dst)
 
static uint64 esc_enc_len (const char *src, size_t srclen)
 
static uint64 esc_dec_len (const char *src, size_t srclen)
 

Variables

static const char hextbl [512]
 
static const int8 hexlookup [128]
 
static const char _base64 []
 
static const char _base64url []
 
static const int8 b64lookup [128]
 
struct {
   const char *   name
 
   struct pg_encoding   enc
 
enclist []
 

Macro Definition Documentation

◆ DIG

#define DIG (   VAL)    ((VAL) + '0')

Definition at line 542 of file encode.c.

◆ VAL

#define VAL (   CH)    ((CH) - '0')

Definition at line 541 of file encode.c.

Function Documentation

◆ binary_decode()

Datum binary_decode ( PG_FUNCTION_ARGS  )

Definition at line 96 of file encode.c.

97{
100 bytea *result;
101 char *namebuf;
102 char *dataptr;
103 size_t datalen;
104 uint64 resultlen;
105 uint64 res;
106 const struct pg_encoding *enc;
107
108 namebuf = TextDatumGetCString(name);
109
110 enc = pg_find_encoding(namebuf);
111 if (enc == NULL)
113 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
114 errmsg("unrecognized encoding: \"%s\"", namebuf)));
115
116 dataptr = VARDATA_ANY(data);
117 datalen = VARSIZE_ANY_EXHDR(data);
118
119 resultlen = enc->decode_len(dataptr, datalen);
120
121 /*
122 * resultlen possibly overflows uint32, therefore on 32-bit machines it's
123 * unsafe to rely on palloc's internal check.
124 */
125 if (resultlen > MaxAllocSize - VARHDRSZ)
127 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
128 errmsg("result of decoding conversion is too large")));
129
130 result = palloc(VARHDRSZ + resultlen);
131
132 res = enc->decode(dataptr, datalen, VARDATA(result));
133
134 /* Make this FATAL 'cause we've trodden on memory ... */
135 if (res > resultlen)
136 elog(FATAL, "overflow - decode estimate too small");
137
138 SET_VARSIZE(result, VARHDRSZ + res);
139
140 PG_RETURN_BYTEA_P(result);
141}
#define TextDatumGetCString(d)
Definition: builtins.h:98
#define VARHDRSZ
Definition: c.h:698
uint64_t uint64
Definition: c.h:540
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define FATAL
Definition: elog.h:41
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
#define ereport(elevel,...)
Definition: elog.h:150
static const struct pg_encoding * pg_find_encoding(const char *name)
Definition: encode.c:739
const char * name
Definition: encode.c:701
struct pg_encoding enc
Definition: encode.c:702
#define MaxAllocSize
Definition: fe_memutils.h:22
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define PG_RETURN_BYTEA_P(x)
Definition: fmgr.h:371
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
void * palloc(Size size)
Definition: mcxt.c:1365
const void * data
uint64_t Datum
Definition: postgres.h:70
uint64(* decode_len)(const char *data, size_t dlen)
Definition: encode.c:36
uint64(* decode)(const char *data, size_t dlen, char *res)
Definition: encode.c:38
Definition: c.h:693
static Size VARSIZE_ANY_EXHDR(const void *PTR)
Definition: varatt.h:472
static char * VARDATA(const void *PTR)
Definition: varatt.h:305
static char * VARDATA_ANY(const void *PTR)
Definition: varatt.h:486
static void SET_VARSIZE(void *PTR, Size len)
Definition: varatt.h:432

References data, pg_encoding::decode, pg_encoding::decode_len, elog, enc, ereport, errcode(), errmsg(), ERROR, FATAL, MaxAllocSize, name, palloc(), pg_find_encoding(), PG_GETARG_DATUM, PG_GETARG_TEXT_PP, PG_RETURN_BYTEA_P, SET_VARSIZE(), TextDatumGetCString, VARDATA(), VARDATA_ANY(), VARHDRSZ, and VARSIZE_ANY_EXHDR().

◆ binary_encode()

Datum binary_encode ( PG_FUNCTION_ARGS  )

Definition at line 48 of file encode.c.

49{
52 text *result;
53 char *namebuf;
54 char *dataptr;
55 size_t datalen;
56 uint64 resultlen;
57 uint64 res;
58 const struct pg_encoding *enc;
59
60 namebuf = TextDatumGetCString(name);
61
62 enc = pg_find_encoding(namebuf);
63 if (enc == NULL)
65 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
66 errmsg("unrecognized encoding: \"%s\"", namebuf)));
67
68 dataptr = VARDATA_ANY(data);
69 datalen = VARSIZE_ANY_EXHDR(data);
70
71 resultlen = enc->encode_len(dataptr, datalen);
72
73 /*
74 * resultlen possibly overflows uint32, therefore on 32-bit machines it's
75 * unsafe to rely on palloc's internal check.
76 */
77 if (resultlen > MaxAllocSize - VARHDRSZ)
79 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
80 errmsg("result of encoding conversion is too large")));
81
82 result = palloc(VARHDRSZ + resultlen);
83
84 res = enc->encode(dataptr, datalen, VARDATA(result));
85
86 /* Make this FATAL 'cause we've trodden on memory ... */
87 if (res > resultlen)
88 elog(FATAL, "overflow - encode estimate too small");
89
90 SET_VARSIZE(result, VARHDRSZ + res);
91
92 PG_RETURN_TEXT_P(result);
93}
#define PG_GETARG_BYTEA_PP(n)
Definition: fmgr.h:308
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
uint64(* encode_len)(const char *data, size_t dlen)
Definition: encode.c:35
uint64(* encode)(const char *data, size_t dlen, char *res)
Definition: encode.c:37

References data, elog, enc, pg_encoding::encode, pg_encoding::encode_len, ereport, errcode(), errmsg(), ERROR, FATAL, MaxAllocSize, name, palloc(), pg_find_encoding(), PG_GETARG_BYTEA_PP, PG_GETARG_DATUM, PG_RETURN_TEXT_P, SET_VARSIZE(), TextDatumGetCString, VARDATA(), VARDATA_ANY(), VARHDRSZ, and VARSIZE_ANY_EXHDR().

◆ esc_dec_len()

static uint64 esc_dec_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 653 of file encode.c.

654{
655 const char *end = src + srclen;
656 uint64 len = 0;
657
658 while (src < end)
659 {
660 if (src[0] != '\\')
661 src++;
662 else if (src + 3 < end &&
663 (src[1] >= '0' && src[1] <= '3') &&
664 (src[2] >= '0' && src[2] <= '7') &&
665 (src[3] >= '0' && src[3] <= '7'))
666 {
667 /*
668 * backslash + valid octal
669 */
670 src += 4;
671 }
672 else if (src + 1 < end &&
673 (src[1] == '\\'))
674 {
675 /*
676 * two backslashes = backslash
677 */
678 src += 2;
679 }
680 else
681 {
682 /*
683 * one backslash, not followed by ### valid octal
684 */
686 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
687 errmsg("invalid input syntax for type %s", "bytea")));
688 }
689
690 len++;
691 }
692 return len;
693}
const void size_t len

References ereport, errcode(), errmsg(), ERROR, and len.

◆ esc_decode()

static uint64 esc_decode ( const char *  src,
size_t  srclen,
char *  dst 
)
static

Definition at line 584 of file encode.c.

585{
586 const char *end = src + srclen;
587 char *rp = dst;
588 uint64 len = 0;
589
590 while (src < end)
591 {
592 if (src[0] != '\\')
593 *rp++ = *src++;
594 else if (src + 3 < end &&
595 (src[1] >= '0' && src[1] <= '3') &&
596 (src[2] >= '0' && src[2] <= '7') &&
597 (src[3] >= '0' && src[3] <= '7'))
598 {
599 int val;
600
601 val = VAL(src[1]);
602 val <<= 3;
603 val += VAL(src[2]);
604 val <<= 3;
605 *rp++ = val + VAL(src[3]);
606 src += 4;
607 }
608 else if (src + 1 < end &&
609 (src[1] == '\\'))
610 {
611 *rp++ = '\\';
612 src += 2;
613 }
614 else
615 {
616 /*
617 * One backslash, not followed by ### valid octal. Should never
618 * get here, since esc_dec_len does same check.
619 */
621 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
622 errmsg("invalid input syntax for type %s", "bytea")));
623 }
624
625 len++;
626 }
627
628 return len;
629}
#define VAL(CH)
Definition: encode.c:541
long val
Definition: informix.c:689

References ereport, errcode(), errmsg(), ERROR, len, VAL, and val.

◆ esc_enc_len()

static uint64 esc_enc_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 632 of file encode.c.

633{
634 const char *end = src + srclen;
635 uint64 len = 0;
636
637 while (src < end)
638 {
639 if (*src == '\0' || IS_HIGHBIT_SET(*src))
640 len += 4;
641 else if (*src == '\\')
642 len += 2;
643 else
644 len++;
645
646 src++;
647 }
648
649 return len;
650}
#define IS_HIGHBIT_SET(ch)
Definition: c.h:1155

References IS_HIGHBIT_SET, and len.

◆ esc_encode()

static uint64 esc_encode ( const char *  src,
size_t  srclen,
char *  dst 
)
static

Definition at line 545 of file encode.c.

546{
547 const char *end = src + srclen;
548 char *rp = dst;
549 uint64 len = 0;
550
551 while (src < end)
552 {
553 unsigned char c = (unsigned char) *src;
554
555 if (c == '\0' || IS_HIGHBIT_SET(c))
556 {
557 rp[0] = '\\';
558 rp[1] = DIG(c >> 6);
559 rp[2] = DIG((c >> 3) & 7);
560 rp[3] = DIG(c & 7);
561 rp += 4;
562 len += 4;
563 }
564 else if (c == '\\')
565 {
566 rp[0] = '\\';
567 rp[1] = '\\';
568 rp += 2;
569 len += 2;
570 }
571 else
572 {
573 *rp++ = c;
574 len++;
575 }
576
577 src++;
578 }
579
580 return len;
581}
#define DIG(VAL)
Definition: encode.c:542
char * c

References DIG, IS_HIGHBIT_SET, and len.

◆ get_hex()

static bool get_hex ( const char *  cp,
char *  out 
)
inlinestatic

Definition at line 197 of file encode.c.

198{
199 unsigned char c = (unsigned char) *cp;
200 int res = -1;
201
202 if (c < 127)
203 res = hexlookup[c];
204
205 *out = (char) res;
206
207 return (res >= 0);
208}
static const int8 hexlookup[128]
Definition: encode.c:169

References hexlookup.

Referenced by hex_decode_safe().

◆ hex_dec_len()

static uint64 hex_dec_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 264 of file encode.c.

265{
266 return (uint64) srclen >> 1;
267}

◆ hex_decode()

uint64 hex_decode ( const char *  src,
size_t  len,
char *  dst 
)

Definition at line 211 of file encode.c.

212{
213 return hex_decode_safe(src, len, dst, NULL);
214}
uint64 hex_decode_safe(const char *src, size_t len, char *dst, Node *escontext)
Definition: encode.c:217

References hex_decode_safe(), and len.

◆ hex_decode_safe()

uint64 hex_decode_safe ( const char *  src,
size_t  len,
char *  dst,
Node escontext 
)

Definition at line 217 of file encode.c.

218{
219 const char *s,
220 *srcend;
221 char v1,
222 v2,
223 *p;
224
225 srcend = src + len;
226 s = src;
227 p = dst;
228 while (s < srcend)
229 {
230 if (*s == ' ' || *s == '\n' || *s == '\t' || *s == '\r')
231 {
232 s++;
233 continue;
234 }
235 if (!get_hex(s, &v1))
236 ereturn(escontext, 0,
237 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
238 errmsg("invalid hexadecimal digit: \"%.*s\"",
239 pg_mblen(s), s)));
240 s++;
241 if (s >= srcend)
242 ereturn(escontext, 0,
243 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
244 errmsg("invalid hexadecimal data: odd number of digits")));
245 if (!get_hex(s, &v2))
246 ereturn(escontext, 0,
247 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
248 errmsg("invalid hexadecimal digit: \"%.*s\"",
249 pg_mblen(s), s)));
250 s++;
251 *p++ = (v1 << 4) | v2;
252 }
253
254 return p - dst;
255}
#define ereturn(context, dummy_value,...)
Definition: elog.h:278
static bool get_hex(const char *cp, char *out)
Definition: encode.c:197
int pg_mblen(const char *mbstr)
Definition: mbutils.c:1024

References ereturn, errcode(), errmsg(), get_hex(), len, and pg_mblen().

Referenced by byteain(), and hex_decode().

◆ hex_enc_len()

static uint64 hex_enc_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 258 of file encode.c.

259{
260 return (uint64) srclen << 1;
261}

◆ hex_encode()

uint64 hex_encode ( const char *  src,
size_t  len,
char *  dst 
)

Definition at line 181 of file encode.c.

182{
183 const char *end = src + len;
184
185 while (src < end)
186 {
187 unsigned char usrc = *((const unsigned char *) src);
188
189 memcpy(dst, &hextbl[2 * usrc], 2);
190 src++;
191 dst += 2;
192 }
193 return (uint64) len * 2;
194}
static const char hextbl[512]
Definition: encode.c:151

References hextbl, and len.

Referenced by AddFileToBackupManifest(), byteaout(), and SendBackupManifest().

◆ pg_base64_dec_len()

static uint64 pg_base64_dec_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 496 of file encode.c.

497{
498 return ((uint64) srclen * 3) >> 2;
499}

◆ pg_base64_decode()

static uint64 pg_base64_decode ( const char *  src,
size_t  len,
char *  dst 
)
static

Definition at line 477 of file encode.c.

478{
479 return pg_base64_decode_internal(src, len, dst, false);
480}
static uint64 pg_base64_decode_internal(const char *src, size_t len, char *dst, bool url)
Definition: encode.c:377

References len, and pg_base64_decode_internal().

◆ pg_base64_decode_internal()

static uint64 pg_base64_decode_internal ( const char *  src,
size_t  len,
char *  dst,
bool  url 
)
static

Definition at line 377 of file encode.c.

378{
379 const char *srcend = src + len,
380 *s = src;
381 char *p = dst;
382 char c;
383 int b = 0;
384 uint32 buf = 0;
385 int pos = 0,
386 end = 0;
387
388 while (s < srcend)
389 {
390 c = *s++;
391
392 if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
393 continue;
394
395 /* convert base64url to base64 */
396 if (url)
397 {
398 if (c == '-')
399 c = '+';
400 else if (c == '_')
401 c = '/';
402 }
403
404 if (c == '=')
405 {
406 /* end sequence */
407 if (!end)
408 {
409 if (pos == 2)
410 end = 1;
411 else if (pos == 3)
412 end = 2;
413 else
414 {
415 /* translator: %s is the name of an encoding scheme */
417 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
418 errmsg("unexpected \"=\" while decoding %s sequence", url ? "base64url" : "base64")));
419 }
420 }
421 b = 0;
422 }
423 else
424 {
425 b = -1;
426 if (c > 0 && c < 127)
427 b = b64lookup[(unsigned char) c];
428 if (b < 0)
429 {
430 /* translator: %s is the name of an encoding scheme */
432 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
433 errmsg("invalid symbol \"%.*s\" found while decoding %s sequence",
434 pg_mblen(s - 1), s - 1,
435 url ? "base64url" : "base64")));
436 }
437 }
438 /* add it to buffer */
439 buf = (buf << 6) + b;
440 pos++;
441 if (pos == 4)
442 {
443 *p++ = (buf >> 16) & 255;
444 if (end == 0 || end > 1)
445 *p++ = (buf >> 8) & 255;
446 if (end == 0 || end > 2)
447 *p++ = buf & 255;
448 buf = 0;
449 pos = 0;
450 }
451 }
452
453 if (pos == 2)
454 {
455 buf <<= 12;
456 *p++ = (buf >> 16) & 0xFF;
457 }
458 else if (pos == 3)
459 {
460 buf <<= 6;
461 *p++ = (buf >> 16) & 0xFF;
462 *p++ = (buf >> 8) & 0xFF;
463 }
464 else if (pos != 0)
465 {
466 /* translator: %s is the name of an encoding scheme */
468 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
469 errmsg("invalid %s end sequence", url ? "base64url" : "base64"),
470 errhint("Input data is missing padding, is truncated, or is otherwise corrupted.")));
471 }
472
473 return p - dst;
474}
uint32_t uint32
Definition: c.h:539
int errhint(const char *fmt,...)
Definition: elog.c:1321
static const int8 b64lookup[128]
Definition: encode.c:279
int b
Definition: isn.c:74
static char * buf
Definition: pg_test_fsync.c:72

References b, b64lookup, buf, ereport, errcode(), errhint(), errmsg(), ERROR, len, and pg_mblen().

Referenced by pg_base64_decode(), and pg_base64url_decode().

◆ pg_base64_enc_len()

static uint64 pg_base64_enc_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 489 of file encode.c.

490{
491 /* 3 bytes will be converted to 4, linefeed after 76 chars */
492 return ((uint64) srclen + 2) / 3 * 4 + (uint64) srclen / (76 * 3 / 4);
493}

◆ pg_base64_encode()

static uint64 pg_base64_encode ( const char *  src,
size_t  len,
char *  dst 
)
static

Definition at line 359 of file encode.c.

360{
361 return pg_base64_encode_internal(src, len, dst, false);
362}
static uint64 pg_base64_encode_internal(const char *src, size_t len, char *dst, bool url)
Definition: encode.c:298

References len, and pg_base64_encode_internal().

◆ pg_base64_encode_internal()

static uint64 pg_base64_encode_internal ( const char *  src,
size_t  len,
char *  dst,
bool  url 
)
static

Definition at line 298 of file encode.c.

299{
300 char *p,
301 *lend = dst + 76;
302 const char *s,
303 *end = src + len;
304 int pos = 2;
305 uint32 buf = 0;
306 const char *alphabet = url ? _base64url : _base64;
307
308 s = src;
309 p = dst;
310
311 while (s < end)
312 {
313 buf |= (unsigned char) *s << (pos << 3);
314 pos--;
315 s++;
316
317 /* write it out */
318 if (pos < 0)
319 {
320 *p++ = alphabet[(buf >> 18) & 0x3f];
321 *p++ = alphabet[(buf >> 12) & 0x3f];
322 *p++ = alphabet[(buf >> 6) & 0x3f];
323 *p++ = alphabet[buf & 0x3f];
324
325 pos = 2;
326 buf = 0;
327
328 if (!url && p >= lend)
329 {
330 *p++ = '\n';
331 lend = p + 76;
332 }
333 }
334 }
335
336 /* Handle remaining bytes in buf */
337 if (pos != 2)
338 {
339 *p++ = alphabet[(buf >> 18) & 0x3f];
340 *p++ = alphabet[(buf >> 12) & 0x3f];
341
342 if (pos == 0)
343 {
344 *p++ = alphabet[(buf >> 6) & 0x3f];
345 if (!url)
346 *p++ = '=';
347 }
348 else if (!url)
349 {
350 *p++ = '=';
351 *p++ = '=';
352 }
353 }
354
355 return p - dst;
356}
static const char _base64url[]
Definition: encode.c:276
static const char _base64[]
Definition: encode.c:273

References _base64, _base64url, buf, and len.

Referenced by pg_base64_encode(), and pg_base64url_encode().

◆ pg_base64url_dec_len()

static uint64 pg_base64url_dec_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 512 of file encode.c.

513{
514 /*
515 * For base64, each 4 characters of input produce at most 3 bytes of
516 * output. For base64url without padding, we need to round up to the
517 * nearest 4
518 */
519 size_t adjusted_len = srclen;
520
521 if (srclen % 4 != 0)
522 adjusted_len += 4 - (srclen % 4);
523
524 return (adjusted_len * 3) / 4;
525}

◆ pg_base64url_decode()

static uint64 pg_base64url_decode ( const char *  src,
size_t  len,
char *  dst 
)
static

Definition at line 483 of file encode.c.

484{
485 return pg_base64_decode_internal(src, len, dst, true);
486}

References len, and pg_base64_decode_internal().

◆ pg_base64url_enc_len()

static uint64 pg_base64url_enc_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 502 of file encode.c.

503{
504 /*
505 * Unlike standard base64, base64url doesn't use padding characters when
506 * the input length is not divisible by 3
507 */
508 return (srclen + 2) / 3 * 4;
509}

◆ pg_base64url_encode()

static uint64 pg_base64url_encode ( const char *  src,
size_t  len,
char *  dst 
)
static

Definition at line 365 of file encode.c.

366{
367 return pg_base64_encode_internal(src, len, dst, true);
368}

References len, and pg_base64_encode_internal().

◆ pg_find_encoding()

static const struct pg_encoding * pg_find_encoding ( const char *  name)
static

Definition at line 739 of file encode.c.

740{
741 int i;
742
743 for (i = 0; enclist[i].name; i++)
744 if (pg_strcasecmp(enclist[i].name, name) == 0)
745 return &enclist[i].enc;
746
747 return NULL;
748}
static const struct @23 enclist[]
int i
Definition: isn.c:77
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36

References enclist, i, name, and pg_strcasecmp().

Referenced by binary_decode(), and binary_encode().

Variable Documentation

◆ _base64

const char _base64[]
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Definition at line 273 of file encode.c.

Referenced by pg_base64_encode_internal().

◆ _base64url

const char _base64url[]
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"

Definition at line 276 of file encode.c.

Referenced by pg_base64_encode_internal().

◆ b64lookup

const int8 b64lookup[128]
static
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
}

Definition at line 279 of file encode.c.

Referenced by pg_base64_decode_internal().

◆ enc

struct pg_encoding enc

Definition at line 702 of file encode.c.

Referenced by binary_decode(), and binary_encode().

◆ 

const struct { ... } enclist[]

Referenced by pg_find_encoding().

◆ hexlookup

const int8 hexlookup[128]
static
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
}

Definition at line 169 of file encode.c.

Referenced by get_hex().

◆ hextbl

const char hextbl[512]
static
Initial value:
=
"000102030405060708090a0b0c0d0e0f"
"101112131415161718191a1b1c1d1e1f"
"202122232425262728292a2b2c2d2e2f"
"303132333435363738393a3b3c3d3e3f"
"404142434445464748494a4b4c4d4e4f"
"505152535455565758595a5b5c5d5e5f"
"606162636465666768696a6b6c6d6e6f"
"707172737475767778797a7b7c7d7e7f"
"808182838485868788898a8b8c8d8e8f"
"909192939495969798999a9b9c9d9e9f"
"a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
"b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
"c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
"d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"
"e0e1e2e3e4e5e6e7e8e9eaebecedeeef"
"f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"

Definition at line 151 of file encode.c.

Referenced by hex_encode().

◆ name

const char* name

Definition at line 701 of file encode.c.

Referenced by binary_decode(), binary_encode(), and pg_find_encoding().