Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __HDRTOKEN_H__
00025 #define __HDRTOKEN_H__
00026
00027 #include <assert.h>
00028 #include <sys/types.h>
00029 #include "ink_assert.h"
00030 #include "ink_atomic.h"
00031 #include "ink_defs.h"
00032 #include "ink_string.h"
00033 #include "Allocator.h"
00034 #include "Regex.h"
00035 #include "ink_apidefs.h"
00036
00037
00038
00039
00040
00041
00042
00043 #define SIZEOF(x) (sizeof (x) / sizeof (x[0]))
00044
00045 enum HdrTokenType
00046 {
00047 HDRTOKEN_TYPE_OTHER = 0,
00048 HDRTOKEN_TYPE_FIELD = 1,
00049 HDRTOKEN_TYPE_METHOD = 2,
00050 HDRTOKEN_TYPE_SCHEME = 3,
00051 HDRTOKEN_TYPE_CACHE_CONTROL = 4
00052 };
00053
00054 struct HdrTokenTypeBinding
00055 {
00056 const char *name;
00057 HdrTokenType type;
00058 };
00059
00060 struct HdrTokenFieldInfo
00061 {
00062 const char *name;
00063 int32_t slotid;
00064 uint64_t mask;
00065 uint32_t flags;
00066 };
00067
00068 struct HdrTokenTypeSpecific
00069 {
00070 union
00071 {
00072 struct
00073 {
00074 uint32_t cc_mask;
00075 } cache_control;
00076 } u;
00077 };
00078
00079 struct HdrTokenHeapPrefix
00080 {
00081 int wks_idx;
00082 int wks_length;
00083 HdrTokenType wks_token_type;
00084 HdrTokenFieldInfo wks_info;
00085 HdrTokenTypeSpecific wks_type_specific;
00086 };
00087
00088 enum HdrTokenInfoFlags
00089 {
00090 HTIF_NONE = 0,
00091 HTIF_COMMAS = 1 << 0,
00092 HTIF_MULTVALS = 1 << 1,
00093 HTIF_HOPBYHOP = 1 << 2,
00094 HTIF_PROXYAUTH = 1 << 3
00095 };
00096
00097 #define MIME_FLAGS_NONE HTIF_NONE
00098 #define MIME_FLAGS_COMMAS HTIF_COMMAS
00099 #define MIME_FLAGS_MULTVALS HTIF_MULTVALS
00100 #define MIME_FLAGS_HOPBYHOP HTIF_HOPBYHOP
00101 #define MIME_FLAGS_PROXYAUTH HTIF_PROXYAUTH
00102
00103 extern DFA *hdrtoken_strs_dfa;
00104 extern int hdrtoken_num_wks;
00105
00106 extern const char *hdrtoken_strs[];
00107 extern int hdrtoken_str_lengths[];
00108 extern HdrTokenType hdrtoken_str_token_types[];
00109 extern int32_t hdrtoken_str_slotids[];
00110 extern uint64_t hdrtoken_str_masks[];
00111 extern uint32_t hdrtoken_str_flags[];
00112
00113
00114
00115
00116
00117
00118
00119 extern void hdrtoken_init();
00120 extern int hdrtoken_tokenize_dfa(const char *string, int string_len, const char **wks_string_out = NULL);
00121 inkcoreapi extern int hdrtoken_tokenize(const char *string, int string_len, const char **wks_string_out = NULL);
00122 extern const char *hdrtoken_string_to_wks(const char *string);
00123 extern const char *hdrtoken_string_to_wks(const char *string, int length);
00124
00125
00126
00127
00128 inline bool
00129 hdrtoken_is_wks(const char *str)
00130 {
00131 extern const char *_hdrtoken_strs_heap_f;
00132 extern const char *_hdrtoken_strs_heap_l;
00133
00134 return ((str >= _hdrtoken_strs_heap_f) && (str <= _hdrtoken_strs_heap_l));
00135 }
00136
00137
00138
00139
00140 inline bool
00141 hdrtoken_is_valid_wks_idx(int wks_idx)
00142 {
00143 return ((wks_idx >= 0) && (wks_idx < hdrtoken_num_wks));
00144 }
00145
00146
00147
00148
00149 inline HdrTokenHeapPrefix *
00150 hdrtoken_wks_to_prefix(const char *wks)
00151 {
00152 ink_assert(hdrtoken_is_wks(wks));
00153 return ((HdrTokenHeapPrefix *) (wks - sizeof(HdrTokenHeapPrefix)));
00154 }
00155
00156
00157
00158
00159 inline const char *
00160 hdrtoken_index_to_wks(int wks_idx)
00161 {
00162 ink_assert(hdrtoken_is_valid_wks_idx(wks_idx));
00163 return hdrtoken_strs[wks_idx];
00164 }
00165
00166 inline int
00167 hdrtoken_index_to_length(int wks_idx)
00168 {
00169 ink_assert(hdrtoken_is_valid_wks_idx(wks_idx));
00170 return hdrtoken_str_lengths[wks_idx];
00171 }
00172
00173 inline HdrTokenType
00174 hdrtoken_index_to_token_type(int wks_idx)
00175 {
00176 ink_assert(hdrtoken_is_valid_wks_idx(wks_idx));
00177 return hdrtoken_str_token_types[wks_idx];
00178 }
00179
00180 inline int
00181 hdrtoken_index_to_slotid(int wks_idx)
00182 {
00183 ink_assert(hdrtoken_is_valid_wks_idx(wks_idx));
00184 return hdrtoken_str_slotids[wks_idx];
00185 }
00186
00187 inline uint64_t
00188 hdrtoken_index_to_mask(int wks_idx)
00189 {
00190 ink_assert(hdrtoken_is_valid_wks_idx(wks_idx));
00191 return hdrtoken_str_masks[wks_idx];
00192 }
00193
00194 inline int
00195 hdrtoken_index_to_flags(int wks_idx)
00196 {
00197 ink_assert(hdrtoken_is_valid_wks_idx(wks_idx));
00198 return hdrtoken_str_flags[wks_idx];
00199 }
00200
00201 inline HdrTokenHeapPrefix *
00202 hdrtoken_index_to_prefix(int wks_idx)
00203 {
00204 ink_assert(hdrtoken_is_valid_wks_idx(wks_idx));
00205 return hdrtoken_wks_to_prefix(hdrtoken_index_to_wks(wks_idx));
00206 }
00207
00208
00209
00210
00211 inline int
00212 hdrtoken_wks_to_index(const char *wks)
00213 {
00214 ink_assert(hdrtoken_is_wks(wks));
00215 return hdrtoken_wks_to_prefix(wks)->wks_idx;
00216 }
00217
00218 inline int
00219 hdrtoken_wks_to_length(const char *wks)
00220 {
00221 ink_assert(hdrtoken_is_wks(wks));
00222 return hdrtoken_wks_to_prefix(wks)->wks_length;
00223 }
00224
00225 inline int
00226 hdrtoken_wks_to_token_type(const char *wks)
00227 {
00228 ink_assert(hdrtoken_is_wks(wks));
00229 return hdrtoken_wks_to_prefix(wks)->wks_token_type;
00230 }
00231
00232 inline int
00233 hdrtoken_wks_to_slotid(const char *wks)
00234 {
00235 ink_assert(hdrtoken_is_wks(wks));
00236 return hdrtoken_wks_to_prefix(wks)->wks_info.slotid;
00237 }
00238
00239 inline uint64_t
00240 hdrtoken_wks_to_mask(const char *wks)
00241 {
00242 ink_assert(hdrtoken_is_wks(wks));
00243 HdrTokenHeapPrefix *prefix = hdrtoken_wks_to_prefix(wks);
00244 return prefix->wks_info.mask;
00245 }
00246
00247 inline int
00248 hdrtoken_wks_to_flags(const char *wks)
00249 {
00250 ink_assert(hdrtoken_is_wks(wks));
00251 return hdrtoken_wks_to_prefix(wks)->wks_info.flags;
00252 }
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 #define MIME_SLOTID_ACCEPT 0
00267 #define MIME_SLOTID_ACCEPT_CHARSET 1
00268 #define MIME_SLOTID_ACCEPT_ENCODING 2
00269 #define MIME_SLOTID_ACCEPT_LANGUAGE 3
00270 #define MIME_SLOTID_AGE 4
00271 #define MIME_SLOTID_AUTHORIZATION 5
00272 #define MIME_SLOTID_CACHE_CONTROL 6
00273 #define MIME_SLOTID_CLIENT_IP 7
00274 #define MIME_SLOTID_CONNECTION 8
00275 #define MIME_SLOTID_CONTENT_ENCODING 9
00276 #define MIME_SLOTID_CONTENT_LANGUAGE 10
00277 #define MIME_SLOTID_CONTENT_LENGTH 11
00278 #define MIME_SLOTID_CONTENT_TYPE 12
00279 #define MIME_SLOTID_COOKIE 13
00280 #define MIME_SLOTID_DATE 14
00281 #define MIME_SLOTID_EXPIRES 15
00282 #define MIME_SLOTID_IF_MATCH 16
00283 #define MIME_SLOTID_IF_MODIFIED_SINCE 17
00284 #define MIME_SLOTID_IF_NONE_MATCH 18
00285 #define MIME_SLOTID_IF_RANGE 19
00286 #define MIME_SLOTID_IF_UNMODIFIED_SINCE 20
00287 #define MIME_SLOTID_LAST_MODIFIED 21
00288 #define MIME_SLOTID_PRAGMA 22
00289 #define MIME_SLOTID_PROXY_CONNECTION 23
00290 #define MIME_SLOTID_RANGE 24
00291 #define MIME_SLOTID_SET_COOKIE 25
00292 #define MIME_SLOTID_TE 26
00293 #define MIME_SLOTID_TRANSFER_ENCODING 27
00294 #define MIME_SLOTID_USER_AGENT 28
00295 #define MIME_SLOTID_VARY 29
00296 #define MIME_SLOTID_VIA 30
00297 #define MIME_SLOTID_WWW_AUTHENTICATE 31
00298
00299 #define MIME_SLOTID_NONE -1
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315 #define TOK_64_CONST(x) x ## LL
00316
00317 #define MIME_PRESENCE_ACCEPT (TOK_64_CONST(1) << 0)
00318 #define MIME_PRESENCE_ACCEPT_CHARSET (TOK_64_CONST(1) << 1)
00319 #define MIME_PRESENCE_ACCEPT_ENCODING (TOK_64_CONST(1) << 2)
00320 #define MIME_PRESENCE_ACCEPT_LANGUAGE (TOK_64_CONST(1) << 3)
00321 #define MIME_PRESENCE_ACCEPT_RANGES (TOK_64_CONST(1) << 4)
00322 #define MIME_PRESENCE_AGE (TOK_64_CONST(1) << 5)
00323 #define MIME_PRESENCE_ALLOW (TOK_64_CONST(1) << 6)
00324 #define MIME_PRESENCE_AUTHORIZATION (TOK_64_CONST(1) << 7)
00325 #define MIME_PRESENCE_BYTES (TOK_64_CONST(1) << 8)
00326 #define MIME_PRESENCE_CACHE_CONTROL (TOK_64_CONST(1) << 9)
00327 #define MIME_PRESENCE_CLIENT_IP (TOK_64_CONST(1) << 10)
00328 #define MIME_PRESENCE_CONNECTION (TOK_64_CONST(1) << 11)
00329 #define MIME_PRESENCE_CONTENT_ENCODING (TOK_64_CONST(1) << 12)
00330 #define MIME_PRESENCE_CONTENT_LANGUAGE (TOK_64_CONST(1) << 13)
00331 #define MIME_PRESENCE_CONTENT_LENGTH (TOK_64_CONST(1) << 14)
00332 #define MIME_PRESENCE_CONTENT_LOCATION (TOK_64_CONST(1) << 15)
00333 #define MIME_PRESENCE_CONTENT_MD5 (TOK_64_CONST(1) << 16)
00334 #define MIME_PRESENCE_CONTENT_RANGE (TOK_64_CONST(1) << 17)
00335 #define MIME_PRESENCE_CONTENT_TYPE (TOK_64_CONST(1) << 18)
00336 #define MIME_PRESENCE_COOKIE (TOK_64_CONST(1) << 19)
00337 #define MIME_PRESENCE_DATE (TOK_64_CONST(1) << 20)
00338 #define MIME_PRESENCE_ETAG (TOK_64_CONST(1) << 21)
00339 #define MIME_PRESENCE_EXPIRES (TOK_64_CONST(1) << 22)
00340 #define MIME_PRESENCE_FROM (TOK_64_CONST(1) << 23)
00341 #define MIME_PRESENCE_HOST (TOK_64_CONST(1) << 24)
00342 #define MIME_PRESENCE_IF_MATCH (TOK_64_CONST(1) << 25)
00343 #define MIME_PRESENCE_IF_MODIFIED_SINCE (TOK_64_CONST(1) << 26)
00344 #define MIME_PRESENCE_IF_NONE_MATCH (TOK_64_CONST(1) << 27)
00345 #define MIME_PRESENCE_IF_RANGE (TOK_64_CONST(1) << 28)
00346 #define MIME_PRESENCE_IF_UNMODIFIED_SINCE (TOK_64_CONST(1) << 29)
00347 #define MIME_PRESENCE_KEEP_ALIVE (TOK_64_CONST(1) << 30)
00348 #define MIME_PRESENCE_KEYWORDS (TOK_64_CONST(1) << 31)
00349 #define MIME_PRESENCE_LAST_MODIFIED (TOK_64_CONST(1) << 32)
00350 #define MIME_PRESENCE_LINES (TOK_64_CONST(1) << 33)
00351 #define MIME_PRESENCE_LOCATION (TOK_64_CONST(1) << 34)
00352 #define MIME_PRESENCE_MAX_FORWARDS (TOK_64_CONST(1) << 35)
00353 #define MIME_PRESENCE_PATH (TOK_64_CONST(1) << 36)
00354 #define MIME_PRESENCE_PRAGMA (TOK_64_CONST(1) << 37)
00355 #define MIME_PRESENCE_PROXY_AUTHENTICATE (TOK_64_CONST(1) << 38)
00356 #define MIME_PRESENCE_PROXY_AUTHORIZATION (TOK_64_CONST(1) << 39)
00357 #define MIME_PRESENCE_PROXY_CONNECTION (TOK_64_CONST(1) << 40)
00358 #define MIME_PRESENCE_PUBLIC (TOK_64_CONST(1) << 41)
00359 #define MIME_PRESENCE_RANGE (TOK_64_CONST(1) << 42)
00360 #define MIME_PRESENCE_REFERER (TOK_64_CONST(1) << 43)
00361 #define MIME_PRESENCE_SERVER (TOK_64_CONST(1) << 44)
00362 #define MIME_PRESENCE_SET_COOKIE (TOK_64_CONST(1) << 45)
00363 #define MIME_PRESENCE_SUBJECT (TOK_64_CONST(1) << 46)
00364 #define MIME_PRESENCE_SUMMARY (TOK_64_CONST(1) << 47)
00365 #define MIME_PRESENCE_TE (TOK_64_CONST(1) << 48)
00366 #define MIME_PRESENCE_TRANSFER_ENCODING (TOK_64_CONST(1) << 49)
00367 #define MIME_PRESENCE_UPGRADE (TOK_64_CONST(1) << 50)
00368 #define MIME_PRESENCE_USER_AGENT (TOK_64_CONST(1) << 51)
00369 #define MIME_PRESENCE_VARY (TOK_64_CONST(1) << 52)
00370 #define MIME_PRESENCE_VIA (TOK_64_CONST(1) << 53)
00371 #define MIME_PRESENCE_WARNING (TOK_64_CONST(1) << 54)
00372 #define MIME_PRESENCE_WWW_AUTHENTICATE (TOK_64_CONST(1) << 55)
00373
00374
00375
00376 #define MIME_PRESENCE_UNUSED_1 (TOK_64_CONST(1) << 56)
00377 #define MIME_PRESENCE_UNUSED_2 (TOK_64_CONST(1) << 57)
00378 #define MIME_PRESENCE_UNUSED_3 (TOK_64_CONST(1) << 58)
00379 #define MIME_PRESENCE_UNUSED_4 (TOK_64_CONST(1) << 59)
00380 #define MIME_PRESENCE_UNUSED_5 (TOK_64_CONST(1) << 60)
00381
00382 #define MIME_PRESENCE_XREF (TOK_64_CONST(1) << 61)
00383 #define MIME_PRESENCE_INT_DATA_INFO (TOK_64_CONST(1) << 62)
00384
00385 #define MIME_PRESENCE_NONE TOK_64_CONST(0)
00386 #define MIME_PRESENCE_ALL ~(TOK_64_CONST(0))
00387
00388
00389
00390
00391 #endif