3 * Copyright 2015 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 /* generates constant table for metadata.cc */
24 static unsigned char legal_bits[256 / 8];
26 static void legal(int x) {
29 /* NB: the following integer arithmetic operation needs to be in its
30 * expanded form due to the "integral promotion" performed (see section
31 * 3.2.1.1 of the C89 draft standard). A cast to the smaller container type
32 * is then required to avoid the compiler warning */
34 (unsigned char)((legal_bits[byte] | (unsigned char)(1 << bit)));
37 static void dump(void) {
40 printf("static const uint8_t legal_header_bits[256/8] = ");
41 for (i = 0; i < 256 / 8; i++)
42 printf("%c 0x%02x", i ? ',' : '{', legal_bits[i]);
46 static void clear(void) { memset(legal_bits, 0, sizeof(legal_bits)); }
52 for (i = 'a'; i <= 'z'; i++) legal(i);
53 for (i = '0'; i <= '9'; i++) legal(i);
60 for (i = 32; i <= 126; i++) {