11cb0ef41Sopenharmony_ci/* 21cb0ef41Sopenharmony_ci * nghttp3 31cb0ef41Sopenharmony_ci * 41cb0ef41Sopenharmony_ci * Copyright (c) 2019 nghttp3 contributors 51cb0ef41Sopenharmony_ci * Copyright (c) 2017 ngtcp2 contributors 61cb0ef41Sopenharmony_ci * Copyright (c) 2012 nghttp2 contributors 71cb0ef41Sopenharmony_ci * 81cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining 91cb0ef41Sopenharmony_ci * a copy of this software and associated documentation files (the 101cb0ef41Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 111cb0ef41Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 121cb0ef41Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to 131cb0ef41Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 141cb0ef41Sopenharmony_ci * the following conditions: 151cb0ef41Sopenharmony_ci * 161cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice shall be 171cb0ef41Sopenharmony_ci * included in all copies or substantial portions of the Software. 181cb0ef41Sopenharmony_ci * 191cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 201cb0ef41Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 211cb0ef41Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 221cb0ef41Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 231cb0ef41Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 241cb0ef41Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 251cb0ef41Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 261cb0ef41Sopenharmony_ci */ 271cb0ef41Sopenharmony_ci#include "nghttp3_str.h" 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci#include <string.h> 301cb0ef41Sopenharmony_ci#include <assert.h> 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ciuint8_t *nghttp3_cpymem(uint8_t *dest, const uint8_t *src, size_t n) { 331cb0ef41Sopenharmony_ci memcpy(dest, src, n); 341cb0ef41Sopenharmony_ci return dest + n; 351cb0ef41Sopenharmony_ci} 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci/* Generated by gendowncasetbl.py */ 381cb0ef41Sopenharmony_cistatic const uint8_t DOWNCASE_TBL[] = { 391cb0ef41Sopenharmony_ci 0 /* NUL */, 1 /* SOH */, 2 /* STX */, 3 /* ETX */, 401cb0ef41Sopenharmony_ci 4 /* EOT */, 5 /* ENQ */, 6 /* ACK */, 7 /* BEL */, 411cb0ef41Sopenharmony_ci 8 /* BS */, 9 /* HT */, 10 /* LF */, 11 /* VT */, 421cb0ef41Sopenharmony_ci 12 /* FF */, 13 /* CR */, 14 /* SO */, 15 /* SI */, 431cb0ef41Sopenharmony_ci 16 /* DLE */, 17 /* DC1 */, 18 /* DC2 */, 19 /* DC3 */, 441cb0ef41Sopenharmony_ci 20 /* DC4 */, 21 /* NAK */, 22 /* SYN */, 23 /* ETB */, 451cb0ef41Sopenharmony_ci 24 /* CAN */, 25 /* EM */, 26 /* SUB */, 27 /* ESC */, 461cb0ef41Sopenharmony_ci 28 /* FS */, 29 /* GS */, 30 /* RS */, 31 /* US */, 471cb0ef41Sopenharmony_ci 32 /* SPC */, 33 /* ! */, 34 /* " */, 35 /* # */, 481cb0ef41Sopenharmony_ci 36 /* $ */, 37 /* % */, 38 /* & */, 39 /* ' */, 491cb0ef41Sopenharmony_ci 40 /* ( */, 41 /* ) */, 42 /* * */, 43 /* + */, 501cb0ef41Sopenharmony_ci 44 /* , */, 45 /* - */, 46 /* . */, 47 /* / */, 511cb0ef41Sopenharmony_ci 48 /* 0 */, 49 /* 1 */, 50 /* 2 */, 51 /* 3 */, 521cb0ef41Sopenharmony_ci 52 /* 4 */, 53 /* 5 */, 54 /* 6 */, 55 /* 7 */, 531cb0ef41Sopenharmony_ci 56 /* 8 */, 57 /* 9 */, 58 /* : */, 59 /* ; */, 541cb0ef41Sopenharmony_ci 60 /* < */, 61 /* = */, 62 /* > */, 63 /* ? */, 551cb0ef41Sopenharmony_ci 64 /* @ */, 97 /* A */, 98 /* B */, 99 /* C */, 561cb0ef41Sopenharmony_ci 100 /* D */, 101 /* E */, 102 /* F */, 103 /* G */, 571cb0ef41Sopenharmony_ci 104 /* H */, 105 /* I */, 106 /* J */, 107 /* K */, 581cb0ef41Sopenharmony_ci 108 /* L */, 109 /* M */, 110 /* N */, 111 /* O */, 591cb0ef41Sopenharmony_ci 112 /* P */, 113 /* Q */, 114 /* R */, 115 /* S */, 601cb0ef41Sopenharmony_ci 116 /* T */, 117 /* U */, 118 /* V */, 119 /* W */, 611cb0ef41Sopenharmony_ci 120 /* X */, 121 /* Y */, 122 /* Z */, 91 /* [ */, 621cb0ef41Sopenharmony_ci 92 /* \ */, 93 /* ] */, 94 /* ^ */, 95 /* _ */, 631cb0ef41Sopenharmony_ci 96 /* ` */, 97 /* a */, 98 /* b */, 99 /* c */, 641cb0ef41Sopenharmony_ci 100 /* d */, 101 /* e */, 102 /* f */, 103 /* g */, 651cb0ef41Sopenharmony_ci 104 /* h */, 105 /* i */, 106 /* j */, 107 /* k */, 661cb0ef41Sopenharmony_ci 108 /* l */, 109 /* m */, 110 /* n */, 111 /* o */, 671cb0ef41Sopenharmony_ci 112 /* p */, 113 /* q */, 114 /* r */, 115 /* s */, 681cb0ef41Sopenharmony_ci 116 /* t */, 117 /* u */, 118 /* v */, 119 /* w */, 691cb0ef41Sopenharmony_ci 120 /* x */, 121 /* y */, 122 /* z */, 123 /* { */, 701cb0ef41Sopenharmony_ci 124 /* | */, 125 /* } */, 126 /* ~ */, 127 /* DEL */, 711cb0ef41Sopenharmony_ci 128 /* 0x80 */, 129 /* 0x81 */, 130 /* 0x82 */, 131 /* 0x83 */, 721cb0ef41Sopenharmony_ci 132 /* 0x84 */, 133 /* 0x85 */, 134 /* 0x86 */, 135 /* 0x87 */, 731cb0ef41Sopenharmony_ci 136 /* 0x88 */, 137 /* 0x89 */, 138 /* 0x8a */, 139 /* 0x8b */, 741cb0ef41Sopenharmony_ci 140 /* 0x8c */, 141 /* 0x8d */, 142 /* 0x8e */, 143 /* 0x8f */, 751cb0ef41Sopenharmony_ci 144 /* 0x90 */, 145 /* 0x91 */, 146 /* 0x92 */, 147 /* 0x93 */, 761cb0ef41Sopenharmony_ci 148 /* 0x94 */, 149 /* 0x95 */, 150 /* 0x96 */, 151 /* 0x97 */, 771cb0ef41Sopenharmony_ci 152 /* 0x98 */, 153 /* 0x99 */, 154 /* 0x9a */, 155 /* 0x9b */, 781cb0ef41Sopenharmony_ci 156 /* 0x9c */, 157 /* 0x9d */, 158 /* 0x9e */, 159 /* 0x9f */, 791cb0ef41Sopenharmony_ci 160 /* 0xa0 */, 161 /* 0xa1 */, 162 /* 0xa2 */, 163 /* 0xa3 */, 801cb0ef41Sopenharmony_ci 164 /* 0xa4 */, 165 /* 0xa5 */, 166 /* 0xa6 */, 167 /* 0xa7 */, 811cb0ef41Sopenharmony_ci 168 /* 0xa8 */, 169 /* 0xa9 */, 170 /* 0xaa */, 171 /* 0xab */, 821cb0ef41Sopenharmony_ci 172 /* 0xac */, 173 /* 0xad */, 174 /* 0xae */, 175 /* 0xaf */, 831cb0ef41Sopenharmony_ci 176 /* 0xb0 */, 177 /* 0xb1 */, 178 /* 0xb2 */, 179 /* 0xb3 */, 841cb0ef41Sopenharmony_ci 180 /* 0xb4 */, 181 /* 0xb5 */, 182 /* 0xb6 */, 183 /* 0xb7 */, 851cb0ef41Sopenharmony_ci 184 /* 0xb8 */, 185 /* 0xb9 */, 186 /* 0xba */, 187 /* 0xbb */, 861cb0ef41Sopenharmony_ci 188 /* 0xbc */, 189 /* 0xbd */, 190 /* 0xbe */, 191 /* 0xbf */, 871cb0ef41Sopenharmony_ci 192 /* 0xc0 */, 193 /* 0xc1 */, 194 /* 0xc2 */, 195 /* 0xc3 */, 881cb0ef41Sopenharmony_ci 196 /* 0xc4 */, 197 /* 0xc5 */, 198 /* 0xc6 */, 199 /* 0xc7 */, 891cb0ef41Sopenharmony_ci 200 /* 0xc8 */, 201 /* 0xc9 */, 202 /* 0xca */, 203 /* 0xcb */, 901cb0ef41Sopenharmony_ci 204 /* 0xcc */, 205 /* 0xcd */, 206 /* 0xce */, 207 /* 0xcf */, 911cb0ef41Sopenharmony_ci 208 /* 0xd0 */, 209 /* 0xd1 */, 210 /* 0xd2 */, 211 /* 0xd3 */, 921cb0ef41Sopenharmony_ci 212 /* 0xd4 */, 213 /* 0xd5 */, 214 /* 0xd6 */, 215 /* 0xd7 */, 931cb0ef41Sopenharmony_ci 216 /* 0xd8 */, 217 /* 0xd9 */, 218 /* 0xda */, 219 /* 0xdb */, 941cb0ef41Sopenharmony_ci 220 /* 0xdc */, 221 /* 0xdd */, 222 /* 0xde */, 223 /* 0xdf */, 951cb0ef41Sopenharmony_ci 224 /* 0xe0 */, 225 /* 0xe1 */, 226 /* 0xe2 */, 227 /* 0xe3 */, 961cb0ef41Sopenharmony_ci 228 /* 0xe4 */, 229 /* 0xe5 */, 230 /* 0xe6 */, 231 /* 0xe7 */, 971cb0ef41Sopenharmony_ci 232 /* 0xe8 */, 233 /* 0xe9 */, 234 /* 0xea */, 235 /* 0xeb */, 981cb0ef41Sopenharmony_ci 236 /* 0xec */, 237 /* 0xed */, 238 /* 0xee */, 239 /* 0xef */, 991cb0ef41Sopenharmony_ci 240 /* 0xf0 */, 241 /* 0xf1 */, 242 /* 0xf2 */, 243 /* 0xf3 */, 1001cb0ef41Sopenharmony_ci 244 /* 0xf4 */, 245 /* 0xf5 */, 246 /* 0xf6 */, 247 /* 0xf7 */, 1011cb0ef41Sopenharmony_ci 248 /* 0xf8 */, 249 /* 0xf9 */, 250 /* 0xfa */, 251 /* 0xfb */, 1021cb0ef41Sopenharmony_ci 252 /* 0xfc */, 253 /* 0xfd */, 254 /* 0xfe */, 255 /* 0xff */, 1031cb0ef41Sopenharmony_ci}; 1041cb0ef41Sopenharmony_ci 1051cb0ef41Sopenharmony_civoid nghttp3_downcase(uint8_t *s, size_t len) { 1061cb0ef41Sopenharmony_ci size_t i; 1071cb0ef41Sopenharmony_ci for (i = 0; i < len; ++i) { 1081cb0ef41Sopenharmony_ci s[i] = DOWNCASE_TBL[s[i]]; 1091cb0ef41Sopenharmony_ci } 1101cb0ef41Sopenharmony_ci} 111