mirror of https://github.com/grpc/grpc.git
commit
6fce197b3f
66 changed files with 1676 additions and 1040 deletions
@ -0,0 +1,53 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_METADATA_H |
||||
#define GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_METADATA_H |
||||
|
||||
#include <grpc/compression.h> |
||||
#include "src/core/transport/metadata.h" |
||||
|
||||
/** Return compression algorithm based metadata value */ |
||||
grpc_mdstr *grpc_compression_algorithm_mdstr( |
||||
grpc_compression_algorithm algorithm); |
||||
|
||||
/** Return compression algorithm based metadata element (grpc-encoding: xxx) */ |
||||
grpc_mdelem *grpc_compression_encoding_mdelem( |
||||
grpc_compression_algorithm algorithm); |
||||
|
||||
/** Find compression algorithm based on passed in mdstr - returns
|
||||
* GRPC_COMPRESS_ALGORITHM_COUNT on failure */ |
||||
grpc_compression_algorithm grpc_compression_algorithm_from_mdstr( |
||||
grpc_mdstr *str); |
||||
|
||||
#endif /* GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_METADATA_H */ |
@ -0,0 +1,157 @@ |
||||
/*
|
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
/*
|
||||
* WARNING: Auto-generated code. |
||||
* |
||||
* To make changes to this file, change |
||||
* tools/codegen/core/gen_static_metadata.py, |
||||
* and then re-run it. |
||||
* |
||||
* See metadata.h for an explanation of the interface here, and metadata.c for |
||||
* an |
||||
* explanation of what's going on. |
||||
*/ |
||||
|
||||
#include "src/core/transport/static_metadata.h" |
||||
|
||||
grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT]; |
||||
|
||||
grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; |
||||
gpr_uintptr grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { |
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
||||
0, 0, 0, 0, 0, 0, 3, 7, 5, 2, 4, 8, 6, 0, 0, 0, 0, 0, 0, 0, |
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
||||
|
||||
const gpr_uint8 |
||||
grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2] = { |
||||
11, 33, 10, 33, 12, 33, 12, 47, 13, 33, 14, 33, 15, 33, 16, 33, 17, 33, |
||||
19, 33, 20, 33, 21, 33, 22, 33, 23, 33, 24, 33, 25, 33, 26, 33, 27, 33, |
||||
28, 18, 28, 33, 29, 33, 30, 33, 34, 33, 35, 33, 36, 33, 37, 33, 40, 31, |
||||
40, 32, 40, 46, 40, 51, 40, 52, 40, 53, 40, 54, 41, 31, 41, 46, 41, 51, |
||||
44, 0, 44, 1, 44, 2, 48, 33, 55, 33, 56, 33, 57, 33, 58, 33, 59, 33, |
||||
60, 33, 61, 33, 62, 33, 63, 33, 64, 38, 64, 66, 65, 76, 65, 77, 67, 33, |
||||
68, 33, 69, 33, 70, 33, 71, 33, 72, 33, 73, 39, 73, 49, 73, 50, 74, 33, |
||||
75, 33, 78, 3, 78, 4, 78, 5, 78, 6, 78, 7, 78, 8, 78, 9, 79, 33, |
||||
80, 81, 82, 33, 83, 33, 84, 33, 85, 33, 86, 33}; |
||||
|
||||
const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = { |
||||
"0", |
||||
"1", |
||||
"2", |
||||
"200", |
||||
"204", |
||||
"206", |
||||
"304", |
||||
"400", |
||||
"404", |
||||
"500", |
||||
"accept", |
||||
"accept-charset", |
||||
"accept-encoding", |
||||
"accept-language", |
||||
"accept-ranges", |
||||
"access-control-allow-origin", |
||||
"age", |
||||
"allow", |
||||
"application/grpc", |
||||
":authority", |
||||
"authorization", |
||||
"cache-control", |
||||
"content-disposition", |
||||
"content-encoding", |
||||
"content-language", |
||||
"content-length", |
||||
"content-location", |
||||
"content-range", |
||||
"content-type", |
||||
"cookie", |
||||
"date", |
||||
"deflate", |
||||
"deflate,gzip", |
||||
"", |
||||
"etag", |
||||
"expect", |
||||
"expires", |
||||
"from", |
||||
"GET", |
||||
"grpc", |
||||
"grpc-accept-encoding", |
||||
"grpc-encoding", |
||||
"grpc-internal-encoding-request", |
||||
"grpc-message", |
||||
"grpc-status", |
||||
"grpc-timeout", |
||||
"gzip", |
||||
"gzip, deflate", |
||||
"host", |
||||
"http", |
||||
"https", |
||||
"identity", |
||||
"identity,deflate", |
||||
"identity,deflate,gzip", |
||||
"identity,gzip", |
||||
"if-match", |
||||
"if-modified-since", |
||||
"if-none-match", |
||||
"if-range", |
||||
"if-unmodified-since", |
||||
"last-modified", |
||||
"link", |
||||
"location", |
||||
"max-forwards", |
||||
":method", |
||||
":path", |
||||
"POST", |
||||
"proxy-authenticate", |
||||
"proxy-authorization", |
||||
"range", |
||||
"referer", |
||||
"refresh", |
||||
"retry-after", |
||||
":scheme", |
||||
"server", |
||||
"set-cookie", |
||||
"/", |
||||
"/index.html", |
||||
":status", |
||||
"strict-transport-security", |
||||
"te", |
||||
"trailers", |
||||
"transfer-encoding", |
||||
"user-agent", |
||||
"vary", |
||||
"via", |
||||
"www-authenticate"}; |
||||
|
||||
const gpr_uint8 grpc_static_accept_encoding_metadata[8] = {0, 29, 26, 30, |
||||
28, 32, 27, 31}; |
@ -0,0 +1,402 @@ |
||||
/*
|
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
/*
|
||||
* WARNING: Auto-generated code. |
||||
* |
||||
* To make changes to this file, change |
||||
* tools/codegen/core/gen_static_metadata.py, |
||||
* and then re-run it. |
||||
* |
||||
* See metadata.h for an explanation of the interface here, and metadata.c for |
||||
* an |
||||
* explanation of what's going on. |
||||
*/ |
||||
|
||||
#ifndef GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H |
||||
#define GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H |
||||
|
||||
#include "src/core/transport/metadata.h" |
||||
|
||||
#define GRPC_STATIC_MDSTR_COUNT 87 |
||||
extern grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT]; |
||||
/* "0" */ |
||||
#define GRPC_MDSTR_0 (&grpc_static_mdstr_table[0]) |
||||
/* "1" */ |
||||
#define GRPC_MDSTR_1 (&grpc_static_mdstr_table[1]) |
||||
/* "2" */ |
||||
#define GRPC_MDSTR_2 (&grpc_static_mdstr_table[2]) |
||||
/* "200" */ |
||||
#define GRPC_MDSTR_200 (&grpc_static_mdstr_table[3]) |
||||
/* "204" */ |
||||
#define GRPC_MDSTR_204 (&grpc_static_mdstr_table[4]) |
||||
/* "206" */ |
||||
#define GRPC_MDSTR_206 (&grpc_static_mdstr_table[5]) |
||||
/* "304" */ |
||||
#define GRPC_MDSTR_304 (&grpc_static_mdstr_table[6]) |
||||
/* "400" */ |
||||
#define GRPC_MDSTR_400 (&grpc_static_mdstr_table[7]) |
||||
/* "404" */ |
||||
#define GRPC_MDSTR_404 (&grpc_static_mdstr_table[8]) |
||||
/* "500" */ |
||||
#define GRPC_MDSTR_500 (&grpc_static_mdstr_table[9]) |
||||
/* "accept" */ |
||||
#define GRPC_MDSTR_ACCEPT (&grpc_static_mdstr_table[10]) |
||||
/* "accept-charset" */ |
||||
#define GRPC_MDSTR_ACCEPT_CHARSET (&grpc_static_mdstr_table[11]) |
||||
/* "accept-encoding" */ |
||||
#define GRPC_MDSTR_ACCEPT_ENCODING (&grpc_static_mdstr_table[12]) |
||||
/* "accept-language" */ |
||||
#define GRPC_MDSTR_ACCEPT_LANGUAGE (&grpc_static_mdstr_table[13]) |
||||
/* "accept-ranges" */ |
||||
#define GRPC_MDSTR_ACCEPT_RANGES (&grpc_static_mdstr_table[14]) |
||||
/* "access-control-allow-origin" */ |
||||
#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (&grpc_static_mdstr_table[15]) |
||||
/* "age" */ |
||||
#define GRPC_MDSTR_AGE (&grpc_static_mdstr_table[16]) |
||||
/* "allow" */ |
||||
#define GRPC_MDSTR_ALLOW (&grpc_static_mdstr_table[17]) |
||||
/* "application/grpc" */ |
||||
#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (&grpc_static_mdstr_table[18]) |
||||
/* ":authority" */ |
||||
#define GRPC_MDSTR_AUTHORITY (&grpc_static_mdstr_table[19]) |
||||
/* "authorization" */ |
||||
#define GRPC_MDSTR_AUTHORIZATION (&grpc_static_mdstr_table[20]) |
||||
/* "cache-control" */ |
||||
#define GRPC_MDSTR_CACHE_CONTROL (&grpc_static_mdstr_table[21]) |
||||
/* "content-disposition" */ |
||||
#define GRPC_MDSTR_CONTENT_DISPOSITION (&grpc_static_mdstr_table[22]) |
||||
/* "content-encoding" */ |
||||
#define GRPC_MDSTR_CONTENT_ENCODING (&grpc_static_mdstr_table[23]) |
||||
/* "content-language" */ |
||||
#define GRPC_MDSTR_CONTENT_LANGUAGE (&grpc_static_mdstr_table[24]) |
||||
/* "content-length" */ |
||||
#define GRPC_MDSTR_CONTENT_LENGTH (&grpc_static_mdstr_table[25]) |
||||
/* "content-location" */ |
||||
#define GRPC_MDSTR_CONTENT_LOCATION (&grpc_static_mdstr_table[26]) |
||||
/* "content-range" */ |
||||
#define GRPC_MDSTR_CONTENT_RANGE (&grpc_static_mdstr_table[27]) |
||||
/* "content-type" */ |
||||
#define GRPC_MDSTR_CONTENT_TYPE (&grpc_static_mdstr_table[28]) |
||||
/* "cookie" */ |
||||
#define GRPC_MDSTR_COOKIE (&grpc_static_mdstr_table[29]) |
||||
/* "date" */ |
||||
#define GRPC_MDSTR_DATE (&grpc_static_mdstr_table[30]) |
||||
/* "deflate" */ |
||||
#define GRPC_MDSTR_DEFLATE (&grpc_static_mdstr_table[31]) |
||||
/* "deflate,gzip" */ |
||||
#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (&grpc_static_mdstr_table[32]) |
||||
/* "" */ |
||||
#define GRPC_MDSTR_EMPTY (&grpc_static_mdstr_table[33]) |
||||
/* "etag" */ |
||||
#define GRPC_MDSTR_ETAG (&grpc_static_mdstr_table[34]) |
||||
/* "expect" */ |
||||
#define GRPC_MDSTR_EXPECT (&grpc_static_mdstr_table[35]) |
||||
/* "expires" */ |
||||
#define GRPC_MDSTR_EXPIRES (&grpc_static_mdstr_table[36]) |
||||
/* "from" */ |
||||
#define GRPC_MDSTR_FROM (&grpc_static_mdstr_table[37]) |
||||
/* "GET" */ |
||||
#define GRPC_MDSTR_GET (&grpc_static_mdstr_table[38]) |
||||
/* "grpc" */ |
||||
#define GRPC_MDSTR_GRPC (&grpc_static_mdstr_table[39]) |
||||
/* "grpc-accept-encoding" */ |
||||
#define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (&grpc_static_mdstr_table[40]) |
||||
/* "grpc-encoding" */ |
||||
#define GRPC_MDSTR_GRPC_ENCODING (&grpc_static_mdstr_table[41]) |
||||
/* "grpc-internal-encoding-request" */ |
||||
#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST (&grpc_static_mdstr_table[42]) |
||||
/* "grpc-message" */ |
||||
#define GRPC_MDSTR_GRPC_MESSAGE (&grpc_static_mdstr_table[43]) |
||||
/* "grpc-status" */ |
||||
#define GRPC_MDSTR_GRPC_STATUS (&grpc_static_mdstr_table[44]) |
||||
/* "grpc-timeout" */ |
||||
#define GRPC_MDSTR_GRPC_TIMEOUT (&grpc_static_mdstr_table[45]) |
||||
/* "gzip" */ |
||||
#define GRPC_MDSTR_GZIP (&grpc_static_mdstr_table[46]) |
||||
/* "gzip, deflate" */ |
||||
#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (&grpc_static_mdstr_table[47]) |
||||
/* "host" */ |
||||
#define GRPC_MDSTR_HOST (&grpc_static_mdstr_table[48]) |
||||
/* "http" */ |
||||
#define GRPC_MDSTR_HTTP (&grpc_static_mdstr_table[49]) |
||||
/* "https" */ |
||||
#define GRPC_MDSTR_HTTPS (&grpc_static_mdstr_table[50]) |
||||
/* "identity" */ |
||||
#define GRPC_MDSTR_IDENTITY (&grpc_static_mdstr_table[51]) |
||||
/* "identity,deflate" */ |
||||
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (&grpc_static_mdstr_table[52]) |
||||
/* "identity,deflate,gzip" */ |
||||
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ |
||||
(&grpc_static_mdstr_table[53]) |
||||
/* "identity,gzip" */ |
||||
#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (&grpc_static_mdstr_table[54]) |
||||
/* "if-match" */ |
||||
#define GRPC_MDSTR_IF_MATCH (&grpc_static_mdstr_table[55]) |
||||
/* "if-modified-since" */ |
||||
#define GRPC_MDSTR_IF_MODIFIED_SINCE (&grpc_static_mdstr_table[56]) |
||||
/* "if-none-match" */ |
||||
#define GRPC_MDSTR_IF_NONE_MATCH (&grpc_static_mdstr_table[57]) |
||||
/* "if-range" */ |
||||
#define GRPC_MDSTR_IF_RANGE (&grpc_static_mdstr_table[58]) |
||||
/* "if-unmodified-since" */ |
||||
#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (&grpc_static_mdstr_table[59]) |
||||
/* "last-modified" */ |
||||
#define GRPC_MDSTR_LAST_MODIFIED (&grpc_static_mdstr_table[60]) |
||||
/* "link" */ |
||||
#define GRPC_MDSTR_LINK (&grpc_static_mdstr_table[61]) |
||||
/* "location" */ |
||||
#define GRPC_MDSTR_LOCATION (&grpc_static_mdstr_table[62]) |
||||
/* "max-forwards" */ |
||||
#define GRPC_MDSTR_MAX_FORWARDS (&grpc_static_mdstr_table[63]) |
||||
/* ":method" */ |
||||
#define GRPC_MDSTR_METHOD (&grpc_static_mdstr_table[64]) |
||||
/* ":path" */ |
||||
#define GRPC_MDSTR_PATH (&grpc_static_mdstr_table[65]) |
||||
/* "POST" */ |
||||
#define GRPC_MDSTR_POST (&grpc_static_mdstr_table[66]) |
||||
/* "proxy-authenticate" */ |
||||
#define GRPC_MDSTR_PROXY_AUTHENTICATE (&grpc_static_mdstr_table[67]) |
||||
/* "proxy-authorization" */ |
||||
#define GRPC_MDSTR_PROXY_AUTHORIZATION (&grpc_static_mdstr_table[68]) |
||||
/* "range" */ |
||||
#define GRPC_MDSTR_RANGE (&grpc_static_mdstr_table[69]) |
||||
/* "referer" */ |
||||
#define GRPC_MDSTR_REFERER (&grpc_static_mdstr_table[70]) |
||||
/* "refresh" */ |
||||
#define GRPC_MDSTR_REFRESH (&grpc_static_mdstr_table[71]) |
||||
/* "retry-after" */ |
||||
#define GRPC_MDSTR_RETRY_AFTER (&grpc_static_mdstr_table[72]) |
||||
/* ":scheme" */ |
||||
#define GRPC_MDSTR_SCHEME (&grpc_static_mdstr_table[73]) |
||||
/* "server" */ |
||||
#define GRPC_MDSTR_SERVER (&grpc_static_mdstr_table[74]) |
||||
/* "set-cookie" */ |
||||
#define GRPC_MDSTR_SET_COOKIE (&grpc_static_mdstr_table[75]) |
||||
/* "/" */ |
||||
#define GRPC_MDSTR_SLASH (&grpc_static_mdstr_table[76]) |
||||
/* "/index.html" */ |
||||
#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (&grpc_static_mdstr_table[77]) |
||||
/* ":status" */ |
||||
#define GRPC_MDSTR_STATUS (&grpc_static_mdstr_table[78]) |
||||
/* "strict-transport-security" */ |
||||
#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (&grpc_static_mdstr_table[79]) |
||||
/* "te" */ |
||||
#define GRPC_MDSTR_TE (&grpc_static_mdstr_table[80]) |
||||
/* "trailers" */ |
||||
#define GRPC_MDSTR_TRAILERS (&grpc_static_mdstr_table[81]) |
||||
/* "transfer-encoding" */ |
||||
#define GRPC_MDSTR_TRANSFER_ENCODING (&grpc_static_mdstr_table[82]) |
||||
/* "user-agent" */ |
||||
#define GRPC_MDSTR_USER_AGENT (&grpc_static_mdstr_table[83]) |
||||
/* "vary" */ |
||||
#define GRPC_MDSTR_VARY (&grpc_static_mdstr_table[84]) |
||||
/* "via" */ |
||||
#define GRPC_MDSTR_VIA (&grpc_static_mdstr_table[85]) |
||||
/* "www-authenticate" */ |
||||
#define GRPC_MDSTR_WWW_AUTHENTICATE (&grpc_static_mdstr_table[86]) |
||||
|
||||
#define GRPC_STATIC_MDELEM_COUNT 78 |
||||
extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; |
||||
extern gpr_uintptr grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; |
||||
/* "accept-charset": "" */ |
||||
#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY (&grpc_static_mdelem_table[0]) |
||||
/* "accept": "" */ |
||||
#define GRPC_MDELEM_ACCEPT_EMPTY (&grpc_static_mdelem_table[1]) |
||||
/* "accept-encoding": "" */ |
||||
#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY (&grpc_static_mdelem_table[2]) |
||||
/* "accept-encoding": "gzip, deflate" */ |
||||
#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ |
||||
(&grpc_static_mdelem_table[3]) |
||||
/* "accept-language": "" */ |
||||
#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY (&grpc_static_mdelem_table[4]) |
||||
/* "accept-ranges": "" */ |
||||
#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY (&grpc_static_mdelem_table[5]) |
||||
/* "access-control-allow-origin": "" */ |
||||
#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ |
||||
(&grpc_static_mdelem_table[6]) |
||||
/* "age": "" */ |
||||
#define GRPC_MDELEM_AGE_EMPTY (&grpc_static_mdelem_table[7]) |
||||
/* "allow": "" */ |
||||
#define GRPC_MDELEM_ALLOW_EMPTY (&grpc_static_mdelem_table[8]) |
||||
/* ":authority": "" */ |
||||
#define GRPC_MDELEM_AUTHORITY_EMPTY (&grpc_static_mdelem_table[9]) |
||||
/* "authorization": "" */ |
||||
#define GRPC_MDELEM_AUTHORIZATION_EMPTY (&grpc_static_mdelem_table[10]) |
||||
/* "cache-control": "" */ |
||||
#define GRPC_MDELEM_CACHE_CONTROL_EMPTY (&grpc_static_mdelem_table[11]) |
||||
/* "content-disposition": "" */ |
||||
#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY (&grpc_static_mdelem_table[12]) |
||||
/* "content-encoding": "" */ |
||||
#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY (&grpc_static_mdelem_table[13]) |
||||
/* "content-language": "" */ |
||||
#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY (&grpc_static_mdelem_table[14]) |
||||
/* "content-length": "" */ |
||||
#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY (&grpc_static_mdelem_table[15]) |
||||
/* "content-location": "" */ |
||||
#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY (&grpc_static_mdelem_table[16]) |
||||
/* "content-range": "" */ |
||||
#define GRPC_MDELEM_CONTENT_RANGE_EMPTY (&grpc_static_mdelem_table[17]) |
||||
/* "content-type": "application/grpc" */ |
||||
#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ |
||||
(&grpc_static_mdelem_table[18]) |
||||
/* "content-type": "" */ |
||||
#define GRPC_MDELEM_CONTENT_TYPE_EMPTY (&grpc_static_mdelem_table[19]) |
||||
/* "cookie": "" */ |
||||
#define GRPC_MDELEM_COOKIE_EMPTY (&grpc_static_mdelem_table[20]) |
||||
/* "date": "" */ |
||||
#define GRPC_MDELEM_DATE_EMPTY (&grpc_static_mdelem_table[21]) |
||||
/* "etag": "" */ |
||||
#define GRPC_MDELEM_ETAG_EMPTY (&grpc_static_mdelem_table[22]) |
||||
/* "expect": "" */ |
||||
#define GRPC_MDELEM_EXPECT_EMPTY (&grpc_static_mdelem_table[23]) |
||||
/* "expires": "" */ |
||||
#define GRPC_MDELEM_EXPIRES_EMPTY (&grpc_static_mdelem_table[24]) |
||||
/* "from": "" */ |
||||
#define GRPC_MDELEM_FROM_EMPTY (&grpc_static_mdelem_table[25]) |
||||
/* "grpc-accept-encoding": "deflate" */ |
||||
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE (&grpc_static_mdelem_table[26]) |
||||
/* "grpc-accept-encoding": "deflate,gzip" */ |
||||
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \ |
||||
(&grpc_static_mdelem_table[27]) |
||||
/* "grpc-accept-encoding": "gzip" */ |
||||
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP (&grpc_static_mdelem_table[28]) |
||||
/* "grpc-accept-encoding": "identity" */ |
||||
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ |
||||
(&grpc_static_mdelem_table[29]) |
||||
/* "grpc-accept-encoding": "identity,deflate" */ |
||||
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \ |
||||
(&grpc_static_mdelem_table[30]) |
||||
/* "grpc-accept-encoding": "identity,deflate,gzip" */ |
||||
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ |
||||
(&grpc_static_mdelem_table[31]) |
||||
/* "grpc-accept-encoding": "identity,gzip" */ |
||||
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ |
||||
(&grpc_static_mdelem_table[32]) |
||||
/* "grpc-encoding": "deflate" */ |
||||
#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE (&grpc_static_mdelem_table[33]) |
||||
/* "grpc-encoding": "gzip" */ |
||||
#define GRPC_MDELEM_GRPC_ENCODING_GZIP (&grpc_static_mdelem_table[34]) |
||||
/* "grpc-encoding": "identity" */ |
||||
#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY (&grpc_static_mdelem_table[35]) |
||||
/* "grpc-status": "0" */ |
||||
#define GRPC_MDELEM_GRPC_STATUS_0 (&grpc_static_mdelem_table[36]) |
||||
/* "grpc-status": "1" */ |
||||
#define GRPC_MDELEM_GRPC_STATUS_1 (&grpc_static_mdelem_table[37]) |
||||
/* "grpc-status": "2" */ |
||||
#define GRPC_MDELEM_GRPC_STATUS_2 (&grpc_static_mdelem_table[38]) |
||||
/* "host": "" */ |
||||
#define GRPC_MDELEM_HOST_EMPTY (&grpc_static_mdelem_table[39]) |
||||
/* "if-match": "" */ |
||||
#define GRPC_MDELEM_IF_MATCH_EMPTY (&grpc_static_mdelem_table[40]) |
||||
/* "if-modified-since": "" */ |
||||
#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY (&grpc_static_mdelem_table[41]) |
||||
/* "if-none-match": "" */ |
||||
#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY (&grpc_static_mdelem_table[42]) |
||||
/* "if-range": "" */ |
||||
#define GRPC_MDELEM_IF_RANGE_EMPTY (&grpc_static_mdelem_table[43]) |
||||
/* "if-unmodified-since": "" */ |
||||
#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY (&grpc_static_mdelem_table[44]) |
||||
/* "last-modified": "" */ |
||||
#define GRPC_MDELEM_LAST_MODIFIED_EMPTY (&grpc_static_mdelem_table[45]) |
||||
/* "link": "" */ |
||||
#define GRPC_MDELEM_LINK_EMPTY (&grpc_static_mdelem_table[46]) |
||||
/* "location": "" */ |
||||
#define GRPC_MDELEM_LOCATION_EMPTY (&grpc_static_mdelem_table[47]) |
||||
/* "max-forwards": "" */ |
||||
#define GRPC_MDELEM_MAX_FORWARDS_EMPTY (&grpc_static_mdelem_table[48]) |
||||
/* ":method": "GET" */ |
||||
#define GRPC_MDELEM_METHOD_GET (&grpc_static_mdelem_table[49]) |
||||
/* ":method": "POST" */ |
||||
#define GRPC_MDELEM_METHOD_POST (&grpc_static_mdelem_table[50]) |
||||
/* ":path": "/" */ |
||||
#define GRPC_MDELEM_PATH_SLASH (&grpc_static_mdelem_table[51]) |
||||
/* ":path": "/index.html" */ |
||||
#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML (&grpc_static_mdelem_table[52]) |
||||
/* "proxy-authenticate": "" */ |
||||
#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY (&grpc_static_mdelem_table[53]) |
||||
/* "proxy-authorization": "" */ |
||||
#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY (&grpc_static_mdelem_table[54]) |
||||
/* "range": "" */ |
||||
#define GRPC_MDELEM_RANGE_EMPTY (&grpc_static_mdelem_table[55]) |
||||
/* "referer": "" */ |
||||
#define GRPC_MDELEM_REFERER_EMPTY (&grpc_static_mdelem_table[56]) |
||||
/* "refresh": "" */ |
||||
#define GRPC_MDELEM_REFRESH_EMPTY (&grpc_static_mdelem_table[57]) |
||||
/* "retry-after": "" */ |
||||
#define GRPC_MDELEM_RETRY_AFTER_EMPTY (&grpc_static_mdelem_table[58]) |
||||
/* ":scheme": "grpc" */ |
||||
#define GRPC_MDELEM_SCHEME_GRPC (&grpc_static_mdelem_table[59]) |
||||
/* ":scheme": "http" */ |
||||
#define GRPC_MDELEM_SCHEME_HTTP (&grpc_static_mdelem_table[60]) |
||||
/* ":scheme": "https" */ |
||||
#define GRPC_MDELEM_SCHEME_HTTPS (&grpc_static_mdelem_table[61]) |
||||
/* "server": "" */ |
||||
#define GRPC_MDELEM_SERVER_EMPTY (&grpc_static_mdelem_table[62]) |
||||
/* "set-cookie": "" */ |
||||
#define GRPC_MDELEM_SET_COOKIE_EMPTY (&grpc_static_mdelem_table[63]) |
||||
/* ":status": "200" */ |
||||
#define GRPC_MDELEM_STATUS_200 (&grpc_static_mdelem_table[64]) |
||||
/* ":status": "204" */ |
||||
#define GRPC_MDELEM_STATUS_204 (&grpc_static_mdelem_table[65]) |
||||
/* ":status": "206" */ |
||||
#define GRPC_MDELEM_STATUS_206 (&grpc_static_mdelem_table[66]) |
||||
/* ":status": "304" */ |
||||
#define GRPC_MDELEM_STATUS_304 (&grpc_static_mdelem_table[67]) |
||||
/* ":status": "400" */ |
||||
#define GRPC_MDELEM_STATUS_400 (&grpc_static_mdelem_table[68]) |
||||
/* ":status": "404" */ |
||||
#define GRPC_MDELEM_STATUS_404 (&grpc_static_mdelem_table[69]) |
||||
/* ":status": "500" */ |
||||
#define GRPC_MDELEM_STATUS_500 (&grpc_static_mdelem_table[70]) |
||||
/* "strict-transport-security": "" */ |
||||
#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ |
||||
(&grpc_static_mdelem_table[71]) |
||||
/* "te": "trailers" */ |
||||
#define GRPC_MDELEM_TE_TRAILERS (&grpc_static_mdelem_table[72]) |
||||
/* "transfer-encoding": "" */ |
||||
#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY (&grpc_static_mdelem_table[73]) |
||||
/* "user-agent": "" */ |
||||
#define GRPC_MDELEM_USER_AGENT_EMPTY (&grpc_static_mdelem_table[74]) |
||||
/* "vary": "" */ |
||||
#define GRPC_MDELEM_VARY_EMPTY (&grpc_static_mdelem_table[75]) |
||||
/* "via": "" */ |
||||
#define GRPC_MDELEM_VIA_EMPTY (&grpc_static_mdelem_table[76]) |
||||
/* "www-authenticate": "" */ |
||||
#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (&grpc_static_mdelem_table[77]) |
||||
|
||||
extern const gpr_uint8 |
||||
grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2]; |
||||
extern const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT]; |
||||
extern const gpr_uint8 grpc_static_accept_encoding_metadata[8]; |
||||
#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \ |
||||
(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]]) |
||||
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H */ |
@ -0,0 +1,310 @@ |
||||
#!/usr/bin/env python2.7 |
||||
|
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
import hashlib |
||||
import itertools |
||||
import os |
||||
import sys |
||||
|
||||
# configuration: a list of either strings or 2-tuples of strings |
||||
# a single string represents a static grpc_mdstr |
||||
# a 2-tuple represents a static grpc_mdelem (and appropriate grpc_mdstrs will |
||||
# also be created) |
||||
|
||||
CONFIG = [ |
||||
'grpc-timeout', |
||||
'grpc-internal-encoding-request', |
||||
':path', |
||||
'grpc-encoding', |
||||
'grpc-accept-encoding', |
||||
'user-agent', |
||||
':authority', |
||||
'host', |
||||
'grpc-message', |
||||
'grpc-status', |
||||
'', |
||||
('grpc-status', '0'), |
||||
('grpc-status', '1'), |
||||
('grpc-status', '2'), |
||||
('grpc-encoding', 'identity'), |
||||
('grpc-encoding', 'gzip'), |
||||
('grpc-encoding', 'deflate'), |
||||
('te', 'trailers'), |
||||
('content-type', 'application/grpc'), |
||||
(':method', 'POST'), |
||||
(':status', '200'), |
||||
(':status', '404'), |
||||
(':scheme', 'http'), |
||||
(':scheme', 'https'), |
||||
(':scheme', 'grpc'), |
||||
(':authority', ''), |
||||
(':method', 'GET'), |
||||
(':path', '/'), |
||||
(':path', '/index.html'), |
||||
(':status', '204'), |
||||
(':status', '206'), |
||||
(':status', '304'), |
||||
(':status', '400'), |
||||
(':status', '500'), |
||||
('accept-charset', ''), |
||||
('accept-encoding', ''), |
||||
('accept-encoding', 'gzip, deflate'), |
||||
('accept-language', ''), |
||||
('accept-ranges', ''), |
||||
('accept', ''), |
||||
('access-control-allow-origin', ''), |
||||
('age', ''), |
||||
('allow', ''), |
||||
('authorization', ''), |
||||
('cache-control', ''), |
||||
('content-disposition', ''), |
||||
('content-encoding', ''), |
||||
('content-language', ''), |
||||
('content-length', ''), |
||||
('content-location', ''), |
||||
('content-range', ''), |
||||
('content-type', ''), |
||||
('cookie', ''), |
||||
('date', ''), |
||||
('etag', ''), |
||||
('expect', ''), |
||||
('expires', ''), |
||||
('from', ''), |
||||
('host', ''), |
||||
('if-match', ''), |
||||
('if-modified-since', ''), |
||||
('if-none-match', ''), |
||||
('if-range', ''), |
||||
('if-unmodified-since', ''), |
||||
('last-modified', ''), |
||||
('link', ''), |
||||
('location', ''), |
||||
('max-forwards', ''), |
||||
('proxy-authenticate', ''), |
||||
('proxy-authorization', ''), |
||||
('range', ''), |
||||
('referer', ''), |
||||
('refresh', ''), |
||||
('retry-after', ''), |
||||
('server', ''), |
||||
('set-cookie', ''), |
||||
('strict-transport-security', ''), |
||||
('transfer-encoding', ''), |
||||
('user-agent', ''), |
||||
('vary', ''), |
||||
('via', ''), |
||||
('www-authenticate', ''), |
||||
] |
||||
|
||||
COMPRESSION_ALGORITHMS = [ |
||||
'identity', |
||||
'deflate', |
||||
'gzip', |
||||
] |
||||
|
||||
# utility: mangle the name of a config |
||||
def mangle(elem): |
||||
xl = { |
||||
'-': '_', |
||||
':': '', |
||||
'/': 'slash', |
||||
'.': 'dot', |
||||
',': 'comma', |
||||
' ': '_', |
||||
} |
||||
def m0(x): |
||||
if not x: return 'empty' |
||||
r = '' |
||||
for c in x: |
||||
put = xl.get(c, c.lower()) |
||||
if not put: continue |
||||
last_is_underscore = r[-1] == '_' if r else True |
||||
if last_is_underscore and put == '_': continue |
||||
elif len(put) > 1: |
||||
if not last_is_underscore: r += '_' |
||||
r += put |
||||
r += '_' |
||||
else: |
||||
r += put |
||||
if r[-1] == '_': r = r[:-1] |
||||
return r |
||||
if isinstance(elem, tuple): |
||||
return 'grpc_mdelem_%s_%s' % (m0(elem[0]), m0(elem[1])) |
||||
else: |
||||
return 'grpc_mdstr_%s' % (m0(elem)) |
||||
|
||||
# utility: generate some hash value for a string |
||||
def fake_hash(elem): |
||||
return hashlib.md5(elem).hexdigest()[0:8] |
||||
|
||||
# utility: print a big comment block into a set of files |
||||
def put_banner(files, banner): |
||||
for f in files: |
||||
print >>f, '/*' |
||||
for line in banner: |
||||
print >>f, ' * %s' % line |
||||
print >>f, ' */' |
||||
print >>f |
||||
|
||||
# build a list of all the strings we need |
||||
all_strs = set() |
||||
all_elems = set() |
||||
static_userdata = {} |
||||
for elem in CONFIG: |
||||
if isinstance(elem, tuple): |
||||
all_strs.add(elem[0]) |
||||
all_strs.add(elem[1]) |
||||
all_elems.add(elem) |
||||
else: |
||||
all_strs.add(elem) |
||||
compression_elems = [] |
||||
for mask in range(1, 1<<len(COMPRESSION_ALGORITHMS)): |
||||
val = ','.join(COMPRESSION_ALGORITHMS[alg] |
||||
for alg in range(0, len(COMPRESSION_ALGORITHMS)) |
||||
if (1 << alg) & mask) |
||||
elem = ('grpc-accept-encoding', val) |
||||
all_strs.add(val) |
||||
all_elems.add(elem) |
||||
compression_elems.append(elem) |
||||
static_userdata[elem] = 1 + mask |
||||
all_strs = sorted(list(all_strs), key=mangle) |
||||
all_elems = sorted(list(all_elems), key=mangle) |
||||
|
||||
# output configuration |
||||
args = sys.argv[1:] |
||||
H = None |
||||
C = None |
||||
if args: |
||||
if 'header' in args: |
||||
H = sys.stdout |
||||
else: |
||||
H = open('/dev/null', 'w') |
||||
if 'source' in args: |
||||
C = sys.stdout |
||||
else: |
||||
C = open('/dev/null', 'w') |
||||
else: |
||||
H = open(os.path.join( |
||||
os.path.dirname(sys.argv[0]), '../../../src/core/transport/static_metadata.h'), 'w') |
||||
C = open(os.path.join( |
||||
os.path.dirname(sys.argv[0]), '../../../src/core/transport/static_metadata.c'), 'w') |
||||
|
||||
# copy-paste copyright notice from this file |
||||
with open(sys.argv[0]) as my_source: |
||||
copyright = [] |
||||
for line in my_source: |
||||
if line[0] != '#': break |
||||
for line in my_source: |
||||
if line[0] == '#': |
||||
copyright.append(line) |
||||
break |
||||
for line in my_source: |
||||
if line[0] != '#': |
||||
break |
||||
copyright.append(line) |
||||
put_banner([H,C], [line[1:].strip() for line in copyright]) |
||||
|
||||
put_banner([H,C], |
||||
"""WARNING: Auto-generated code. |
||||
|
||||
To make changes to this file, change tools/codegen/core/gen_static_metadata.py, |
||||
and then re-run it. |
||||
|
||||
See metadata.h for an explanation of the interface here, and metadata.c for an |
||||
explanation of what's going on. |
||||
""".splitlines()) |
||||
|
||||
print >>H, '#ifndef GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H' |
||||
print >>H, '#define GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H' |
||||
print >>H |
||||
print >>H, '#include "src/core/transport/metadata.h"' |
||||
print >>H |
||||
|
||||
print >>C, '#include "src/core/transport/static_metadata.h"' |
||||
print >>C |
||||
|
||||
print >>H, '#define GRPC_STATIC_MDSTR_COUNT %d' % len(all_strs) |
||||
print >>H, 'extern grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];' |
||||
for i, elem in enumerate(all_strs): |
||||
print >>H, '/* "%s" */' % elem |
||||
print >>H, '#define %s (&grpc_static_mdstr_table[%d])' % (mangle(elem).upper(), i) |
||||
print >>H |
||||
print >>C, 'grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];' |
||||
print >>C |
||||
|
||||
print >>H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems) |
||||
print >>H, 'extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];' |
||||
print >>H, 'extern gpr_uintptr grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];' |
||||
for i, elem in enumerate(all_elems): |
||||
print >>H, '/* "%s": "%s" */' % elem |
||||
print >>H, '#define %s (&grpc_static_mdelem_table[%d])' % (mangle(elem).upper(), i) |
||||
print >>H |
||||
print >>C, 'grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];' |
||||
print >>C, 'gpr_uintptr grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {' |
||||
print >>C, ' %s' % ','.join('%d' % static_userdata.get(elem, 0) for elem in all_elems) |
||||
print >>C, '};' |
||||
print >>C |
||||
|
||||
def str_idx(s): |
||||
for i, s2 in enumerate(all_strs): |
||||
if s == s2: |
||||
return i |
||||
|
||||
def md_idx(m): |
||||
for i, m2 in enumerate(all_elems): |
||||
if m == m2: |
||||
return i |
||||
|
||||
print >>H, 'extern const gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT*2];' |
||||
print >>C, 'const gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT*2] = {' |
||||
print >>C, ','.join('%d' % str_idx(x) for x in itertools.chain.from_iterable([a,b] for a, b in all_elems)) |
||||
print >>C, '};' |
||||
print >>C |
||||
|
||||
print >>H, 'extern const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT];' |
||||
print >>C, 'const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {' |
||||
print >>C, '%s' % ',\n'.join(' "%s"' % s for s in all_strs) |
||||
print >>C, '};' |
||||
print >>C |
||||
|
||||
print >>H, 'extern const gpr_uint8 grpc_static_accept_encoding_metadata[%d];' % (1 << len(COMPRESSION_ALGORITHMS)) |
||||
print >>C, 'const gpr_uint8 grpc_static_accept_encoding_metadata[%d] = {' % (1 << len(COMPRESSION_ALGORITHMS)) |
||||
print >>C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in compression_elems) |
||||
print >>C, '};' |
||||
print >>C |
||||
|
||||
print >>H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]])' |
||||
|
||||
print >>H, '#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H */' |
||||
|
||||
H.close() |
||||
C.close() |
||||
|
Loading…
Reference in new issue