390
if (hexadecimal == 1) {
393
/* the "(uint32_t)" cast disables the BCC's warning */
394
*--p = hex[(uint32_t) (ui64 & 0xf)];
396
} while (ui64 >>= 4);
398
} else if (hexadecimal == 2) {
401
/* the "(uint32_t)" cast disables the BCC's warning */
402
*--p = HEX[(uint32_t) (ui64 & 0xf)];
404
} while (ui64 >>= 4);
406
} else if (ui64 <= NGX_MAX_UINT32_VALUE) {
409
* To divide 64-bit number and to find the remainder
410
* on the x86 platform gcc and icc call the libc functions
411
* [u]divdi3() and [u]moddi3(), they call another function
412
* in its turn. On FreeBSD it is the qdivrem() function,
413
* its source code is about 170 lines of the code.
414
* The glibc counterpart is about 150 lines of the code.
416
* For 32-bit numbers and some divisors gcc and icc use
417
* the inlined multiplication and shifts. For example,
418
* unsigned "i32 / 10" is compiled to
420
* (i32 * 0xCCCCCCCD) >> 35
423
ui32 = (uint32_t) ui64;
426
*--p = (u_char) (ui32 % 10 + '0');
427
} while (ui32 /= 10);
431
*--p = (u_char) (ui64 % 10 + '0');
432
} while (ui64 /= 10);
435
len = (temp + NGX_INT64_LEN) - p;
437
while (len++ < width && buf < last) {
441
len = (temp + NGX_INT64_LEN) - p;
442
if (buf + len > last) {
446
buf = ngx_cpymem(buf, p, len);
458
buf = ngx_sprintf_num(buf, last, ui64, zero, hex, width);
472
ngx_sprintf_num(u_char *buf, u_char *last, uint64_t ui64, u_char zero,
473
ngx_uint_t hexadecimal, ngx_uint_t width)
475
u_char *p, temp[NGX_INT64_LEN + 1];
477
* we need temp[NGX_INT64_LEN] only,
478
* but icc issues the warning
482
static u_char hex[] = "0123456789abcdef";
483
static u_char HEX[] = "0123456789ABCDEF";
485
p = temp + NGX_INT64_LEN;
487
if (hexadecimal == 0) {
489
if (ui64 <= NGX_MAX_UINT32_VALUE) {
492
* To divide 64-bit numbers and to find remainders
493
* on the x86 platform gcc and icc call the libc functions
494
* [u]divdi3() and [u]moddi3(), they call another function
495
* in its turn. On FreeBSD it is the qdivrem() function,
496
* its source code is about 170 lines of the code.
497
* The glibc counterpart is about 150 lines of the code.
499
* For 32-bit numbers and some divisors gcc and icc use
500
* a inlined multiplication and shifts. For example,
501
* unsigned "i32 / 10" is compiled to
503
* (i32 * 0xCCCCCCCD) >> 35
506
ui32 = (uint32_t) ui64;
509
*--p = (u_char) (ui32 % 10 + '0');
510
} while (ui32 /= 10);
514
*--p = (u_char) (ui64 % 10 + '0');
515
} while (ui64 /= 10);
518
} else if (hexadecimal == 1) {
522
/* the "(uint32_t)" cast disables the BCC's warning */
523
*--p = hex[(uint32_t) (ui64 & 0xf)];
525
} while (ui64 >>= 4);
527
} else { /* hexadecimal == 2 */
531
/* the "(uint32_t)" cast disables the BCC's warning */
532
*--p = HEX[(uint32_t) (ui64 & 0xf)];
534
} while (ui64 >>= 4);
537
/* zero or space padding */
539
len = (temp + NGX_INT64_LEN) - p;
541
while (len++ < width && buf < last) {
545
/* number safe copy */
547
len = (temp + NGX_INT64_LEN) - p;
549
if (buf + len > last) {
553
return ngx_cpymem(buf, p, len);
460
558
* We use ngx_strcasecmp()/ngx_strncasecmp() for 7-bit ASCII strings only,
461
559
* and implement our own ngx_strcasecmp()/ngx_strncasecmp()
911
1121
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77
1124
return ngx_decode_base64_internal(dst, src, basis64);
1129
ngx_decode_base64url(ngx_str_t *dst, ngx_str_t *src)
1131
static u_char basis64[] = {
1132
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1133
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1134
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 62, 77, 77,
1135
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 77, 77, 77, 77, 77, 77,
1136
77, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1137
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 77, 77, 77, 77, 63,
1138
77, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
1139
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 77, 77, 77, 77, 77,
1141
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1142
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1143
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1144
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1145
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1146
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1147
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
1148
77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77
1151
return ngx_decode_base64_internal(dst, src, basis64);
1156
ngx_decode_base64_internal(ngx_str_t *dst, ngx_str_t *src, const u_char *basis)
914
1161
for (len = 0; len < src->len; len++) {
915
1162
if (src->data[len] == '=') {
919
if (basis64[src->data[len]] == 77) {
1166
if (basis[src->data[len]] == 77) {
920
1167
return NGX_ERROR;
1696
*dst++ = '&'; *dst++ = 'q'; *dst++ = 'u'; *dst++ = 'o';
1697
*dst++ = 't'; *dst++ = ';';
1425
1707
return (uintptr_t) dst;
1712
ngx_str_rbtree_insert_value(ngx_rbtree_node_t *temp,
1713
ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel)
1715
ngx_str_node_t *n, *t;
1716
ngx_rbtree_node_t **p;
1720
n = (ngx_str_node_t *) node;
1721
t = (ngx_str_node_t *) temp;
1723
if (node->key != temp->key) {
1725
p = (node->key < temp->key) ? &temp->left : &temp->right;
1727
} else if (n->str.len != t->str.len) {
1729
p = (n->str.len < t->str.len) ? &temp->left : &temp->right;
1732
p = (ngx_memcmp(n->str.data, t->str.data, n->str.len) < 0)
1733
? &temp->left : &temp->right;
1736
if (*p == sentinel) {
1744
node->parent = temp;
1745
node->left = sentinel;
1746
node->right = sentinel;
1752
ngx_str_rbtree_lookup(ngx_rbtree_t *rbtree, ngx_str_t *val, uint32_t hash)
1756
ngx_rbtree_node_t *node, *sentinel;
1758
node = rbtree->root;
1759
sentinel = rbtree->sentinel;
1761
while (node != sentinel) {
1763
n = (ngx_str_node_t *) node;
1765
if (hash != node->key) {
1766
node = (hash < node->key) ? node->left : node->right;
1770
if (val->len != n->str.len) {
1771
node = (val->len < n->str.len) ? node->left : node->right;
1775
rc = ngx_memcmp(val->data, n->str.data, val->len);
1429
1794
/* ngx_sort() is implemented as insertion sort because we need stable sort */