aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2013-11-09 10:09:09 +0800
committerAndy Green <andy.green@linaro.org>2013-11-09 10:09:09 +0800
commitcc13c6f187f47fd31a377d05477f90c0fd7f7452 (patch)
treefbc1fdf405ddc8e00458809c3da1f2d5af6b3a3a /lib
parent7ee4f890a3497997a963fceca256069ecdf829d5 (diff)
downloadlibwebsockets-cc13c6f187f47fd31a377d05477f90c0fd7f7452.tar.gz
improve minilex use external parsing header
Clean up minilex Move the header output to stdout Introduce lexfile.h as the header output Use lexfile.h in both minilex itself and lws Add the following header support "Accept:", "If-Modified-Since:", "Accept-Encoding:", "Accept-Language:", "Pragma:", "Cache-Control:", "Authorization:", "Cookie:", "Content-Type:", "Date:", "Range:", "Referer:" Signed-off-by: Andy Green <andy.green@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/lextable.h166
-rw-r--r--lib/libwebsockets.h16
-rw-r--r--lib/minilex.c360
-rw-r--r--lib/parsers.c297
4 files changed, 271 insertions, 568 deletions
diff --git a/lib/lextable.h b/lib/lextable.h
new file mode 100644
index 00000000..d3b8fd5e
--- /dev/null
+++ b/lib/lextable.h
@@ -0,0 +1,166 @@
+/* pos 0: state 0 */ 0x47 /* 'G' */, 0x09 /* (to pos 18 state 1) */,
+ 0x48 /* 'H' */, 0x0C /* (to pos 26 state 5) */,
+ 0x43 /* 'C' */, 0x11 /* (to pos 38 state 10) */,
+ 0x53 /* 'S' */, 0x1B /* (to pos 60 state 21) */,
+ 0x55 /* 'U' */, 0x41 /* (to pos 138 state 51) */,
+ 0x4F /* 'O' */, 0x48 /* (to pos 154 state 59) */,
+ 0x0D /* '.' */, 0x54 /* (to pos 180 state 72) */,
+ 0x41 /* 'A' */, 0x85 /* (to pos 280 state 122) */,
+ 0xC9 /* 'I' */, 0x8B /* (to pos 294 state 129) */,
+/* pos 18: state 1 */ 0xC5 /* 'E' */, 0x01 /* (to pos 20 state 2) */,
+/* pos 20: state 2 */ 0xD4 /* 'T' */, 0x01 /* (to pos 22 state 3) */,
+/* pos 22: state 3 */ 0xA0 /* ' ' */, 0x01 /* (to pos 24 state 4) */,
+/* pos 24: state 4 */ 0x80, 0x00 /* - terminal marker 0 - */,
+/* pos 26: state 5 */ 0x6F /* 'o' */, 0x02 /* (to pos 30 state 6) */,
+ 0xD4 /* 'T' */, 0x76 /* (to pos 264 state 114) */,
+/* pos 30: state 6 */ 0xF3 /* 's' */, 0x01 /* (to pos 32 state 7) */,
+/* pos 32: state 7 */ 0xF4 /* 't' */, 0x01 /* (to pos 34 state 8) */,
+/* pos 34: state 8 */ 0xBA /* ':' */, 0x01 /* (to pos 36 state 9) */,
+/* pos 36: state 9 */ 0x81, 0x00 /* - terminal marker 1 - */,
+/* pos 38: state 10 */ 0xEF /* 'o' */, 0x01 /* (to pos 40 state 11) */,
+/* pos 40: state 11 */ 0xEE /* 'n' */, 0x01 /* (to pos 42 state 12) */,
+/* pos 42: state 12 */ 0xEE /* 'n' */, 0x01 /* (to pos 44 state 13) */,
+/* pos 44: state 13 */ 0xE5 /* 'e' */, 0x01 /* (to pos 46 state 14) */,
+/* pos 46: state 14 */ 0xE3 /* 'c' */, 0x01 /* (to pos 48 state 15) */,
+/* pos 48: state 15 */ 0xF4 /* 't' */, 0x01 /* (to pos 50 state 16) */,
+/* pos 50: state 16 */ 0xE9 /* 'i' */, 0x01 /* (to pos 52 state 17) */,
+/* pos 52: state 17 */ 0xEF /* 'o' */, 0x01 /* (to pos 54 state 18) */,
+/* pos 54: state 18 */ 0xEE /* 'n' */, 0x01 /* (to pos 56 state 19) */,
+/* pos 56: state 19 */ 0xBA /* ':' */, 0x01 /* (to pos 58 state 20) */,
+/* pos 58: state 20 */ 0x82, 0x00 /* - terminal marker 2 - */,
+/* pos 60: state 21 */ 0xE5 /* 'e' */, 0x01 /* (to pos 62 state 22) */,
+/* pos 62: state 22 */ 0xE3 /* 'c' */, 0x01 /* (to pos 64 state 23) */,
+/* pos 64: state 23 */ 0xAD /* '-' */, 0x01 /* (to pos 66 state 24) */,
+/* pos 66: state 24 */ 0xD7 /* 'W' */, 0x01 /* (to pos 68 state 25) */,
+/* pos 68: state 25 */ 0xE5 /* 'e' */, 0x01 /* (to pos 70 state 26) */,
+/* pos 70: state 26 */ 0xE2 /* 'b' */, 0x01 /* (to pos 72 state 27) */,
+/* pos 72: state 27 */ 0xD3 /* 'S' */, 0x01 /* (to pos 74 state 28) */,
+/* pos 74: state 28 */ 0xEF /* 'o' */, 0x01 /* (to pos 76 state 29) */,
+/* pos 76: state 29 */ 0xE3 /* 'c' */, 0x01 /* (to pos 78 state 30) */,
+/* pos 78: state 30 */ 0xEB /* 'k' */, 0x01 /* (to pos 80 state 31) */,
+/* pos 80: state 31 */ 0xE5 /* 'e' */, 0x01 /* (to pos 82 state 32) */,
+/* pos 82: state 32 */ 0xF4 /* 't' */, 0x01 /* (to pos 84 state 33) */,
+/* pos 84: state 33 */ 0xAD /* '-' */, 0x01 /* (to pos 86 state 34) */,
+/* pos 86: state 34 */ 0x4B /* 'K' */, 0x08 /* (to pos 102 state 35) */,
+ 0x50 /* 'P' */, 0x10 /* (to pos 120 state 42) */,
+ 0x44 /* 'D' */, 0x27 /* (to pos 168 state 66) */,
+ 0x56 /* 'V' */, 0x2F /* (to pos 186 state 75) */,
+ 0x4F /* 'O' */, 0x36 /* (to pos 202 state 83) */,
+ 0x45 /* 'E' */, 0x3C /* (to pos 216 state 90) */,
+ 0x41 /* 'A' */, 0x46 /* (to pos 238 state 101) */,
+ 0xCE /* 'N' */, 0x4C /* (to pos 252 state 108) */,
+/* pos 102: state 35 */ 0xE5 /* 'e' */, 0x01 /* (to pos 104 state 36) */,
+/* pos 104: state 36 */ 0xF9 /* 'y' */, 0x01 /* (to pos 106 state 37) */,
+/* pos 106: state 37 */ 0x31 /* '1' */, 0x03 /* (to pos 112 state 38) */,
+ 0x32 /* '2' */, 0x04 /* (to pos 116 state 40) */,
+ 0xBA /* ':' */, 0x25 /* (to pos 184 state 74) */,
+/* pos 112: state 38 */ 0xBA /* ':' */, 0x01 /* (to pos 114 state 39) */,
+/* pos 114: state 39 */ 0x83, 0x00 /* - terminal marker 3 - */,
+/* pos 116: state 40 */ 0xBA /* ':' */, 0x01 /* (to pos 118 state 41) */,
+/* pos 118: state 41 */ 0x84, 0x00 /* - terminal marker 4 - */,
+/* pos 120: state 42 */ 0xF2 /* 'r' */, 0x01 /* (to pos 122 state 43) */,
+/* pos 122: state 43 */ 0xEF /* 'o' */, 0x01 /* (to pos 124 state 44) */,
+/* pos 124: state 44 */ 0xF4 /* 't' */, 0x01 /* (to pos 126 state 45) */,
+/* pos 126: state 45 */ 0xEF /* 'o' */, 0x01 /* (to pos 128 state 46) */,
+/* pos 128: state 46 */ 0xE3 /* 'c' */, 0x01 /* (to pos 130 state 47) */,
+/* pos 130: state 47 */ 0xEF /* 'o' */, 0x01 /* (to pos 132 state 48) */,
+/* pos 132: state 48 */ 0xEC /* 'l' */, 0x01 /* (to pos 134 state 49) */,
+/* pos 134: state 49 */ 0xBA /* ':' */, 0x01 /* (to pos 136 state 50) */,
+/* pos 136: state 50 */ 0x85, 0x00 /* - terminal marker 5 - */,
+/* pos 138: state 51 */ 0xF0 /* 'p' */, 0x01 /* (to pos 140 state 52) */,
+/* pos 140: state 52 */ 0xE7 /* 'g' */, 0x01 /* (to pos 142 state 53) */,
+/* pos 142: state 53 */ 0xF2 /* 'r' */, 0x01 /* (to pos 144 state 54) */,
+/* pos 144: state 54 */ 0xE1 /* 'a' */, 0x01 /* (to pos 146 state 55) */,
+/* pos 146: state 55 */ 0xE4 /* 'd' */, 0x01 /* (to pos 148 state 56) */,
+/* pos 148: state 56 */ 0xE5 /* 'e' */, 0x01 /* (to pos 150 state 57) */,
+/* pos 150: state 57 */ 0xBA /* ':' */, 0x01 /* (to pos 152 state 58) */,
+/* pos 152: state 58 */ 0x86, 0x00 /* - terminal marker 6 - */,
+/* pos 154: state 59 */ 0xF2 /* 'r' */, 0x01 /* (to pos 156 state 60) */,
+/* pos 156: state 60 */ 0xE9 /* 'i' */, 0x01 /* (to pos 158 state 61) */,
+/* pos 158: state 61 */ 0xE7 /* 'g' */, 0x01 /* (to pos 160 state 62) */,
+/* pos 160: state 62 */ 0xE9 /* 'i' */, 0x01 /* (to pos 162 state 63) */,
+/* pos 162: state 63 */ 0xEE /* 'n' */, 0x01 /* (to pos 164 state 64) */,
+/* pos 164: state 64 */ 0xBA /* ':' */, 0x01 /* (to pos 166 state 65) */,
+/* pos 166: state 65 */ 0x87, 0x00 /* - terminal marker 7 - */,
+/* pos 168: state 66 */ 0xF2 /* 'r' */, 0x01 /* (to pos 170 state 67) */,
+/* pos 170: state 67 */ 0xE1 /* 'a' */, 0x01 /* (to pos 172 state 68) */,
+/* pos 172: state 68 */ 0xE6 /* 'f' */, 0x01 /* (to pos 174 state 69) */,
+/* pos 174: state 69 */ 0xF4 /* 't' */, 0x01 /* (to pos 176 state 70) */,
+/* pos 176: state 70 */ 0xBA /* ':' */, 0x01 /* (to pos 178 state 71) */,
+/* pos 178: state 71 */ 0x88, 0x00 /* - terminal marker 8 - */,
+/* pos 180: state 72 */ 0x8A /* '.' */, 0x01 /* (to pos 182 state 73) */,
+/* pos 182: state 73 */ 0x89, 0x00 /* - terminal marker 9 - */,
+/* pos 184: state 74 */ 0x8A, 0x00 /* - terminal marker 10 - */,
+/* pos 186: state 75 */ 0xE5 /* 'e' */, 0x01 /* (to pos 188 state 76) */,
+/* pos 188: state 76 */ 0xF2 /* 'r' */, 0x01 /* (to pos 190 state 77) */,
+/* pos 190: state 77 */ 0xF3 /* 's' */, 0x01 /* (to pos 192 state 78) */,
+/* pos 192: state 78 */ 0xE9 /* 'i' */, 0x01 /* (to pos 194 state 79) */,
+/* pos 194: state 79 */ 0xEF /* 'o' */, 0x01 /* (to pos 196 state 80) */,
+/* pos 196: state 80 */ 0xEE /* 'n' */, 0x01 /* (to pos 198 state 81) */,
+/* pos 198: state 81 */ 0xBA /* ':' */, 0x01 /* (to pos 200 state 82) */,
+/* pos 200: state 82 */ 0x8B, 0x00 /* - terminal marker 11 - */,
+/* pos 202: state 83 */ 0xF2 /* 'r' */, 0x01 /* (to pos 204 state 84) */,
+/* pos 204: state 84 */ 0xE9 /* 'i' */, 0x01 /* (to pos 206 state 85) */,
+/* pos 206: state 85 */ 0xE7 /* 'g' */, 0x01 /* (to pos 208 state 86) */,
+/* pos 208: state 86 */ 0xE9 /* 'i' */, 0x01 /* (to pos 210 state 87) */,
+/* pos 210: state 87 */ 0xEE /* 'n' */, 0x01 /* (to pos 212 state 88) */,
+/* pos 212: state 88 */ 0xBA /* ':' */, 0x01 /* (to pos 214 state 89) */,
+/* pos 214: state 89 */ 0x8C, 0x00 /* - terminal marker 12 - */,
+/* pos 216: state 90 */ 0xF8 /* 'x' */, 0x01 /* (to pos 218 state 91) */,
+/* pos 218: state 91 */ 0xF4 /* 't' */, 0x01 /* (to pos 220 state 92) */,
+/* pos 220: state 92 */ 0xE5 /* 'e' */, 0x01 /* (to pos 222 state 93) */,
+/* pos 222: state 93 */ 0xEE /* 'n' */, 0x01 /* (to pos 224 state 94) */,
+/* pos 224: state 94 */ 0xF3 /* 's' */, 0x01 /* (to pos 226 state 95) */,
+/* pos 226: state 95 */ 0xE9 /* 'i' */, 0x01 /* (to pos 228 state 96) */,
+/* pos 228: state 96 */ 0xEF /* 'o' */, 0x01 /* (to pos 230 state 97) */,
+/* pos 230: state 97 */ 0xEE /* 'n' */, 0x01 /* (to pos 232 state 98) */,
+/* pos 232: state 98 */ 0xF3 /* 's' */, 0x01 /* (to pos 234 state 99) */,
+/* pos 234: state 99 */ 0xBA /* ':' */, 0x01 /* (to pos 236 state 100) */,
+/* pos 236: state 100 */ 0x8D, 0x00 /* - terminal marker 13 - */,
+/* pos 238: state 101 */ 0xE3 /* 'c' */, 0x01 /* (to pos 240 state 102) */,
+/* pos 240: state 102 */ 0xE3 /* 'c' */, 0x01 /* (to pos 242 state 103) */,
+/* pos 242: state 103 */ 0xE5 /* 'e' */, 0x01 /* (to pos 244 state 104) */,
+/* pos 244: state 104 */ 0xF0 /* 'p' */, 0x01 /* (to pos 246 state 105) */,
+/* pos 246: state 105 */ 0xF4 /* 't' */, 0x01 /* (to pos 248 state 106) */,
+/* pos 248: state 106 */ 0xBA /* ':' */, 0x01 /* (to pos 250 state 107) */,
+/* pos 250: state 107 */ 0x8E, 0x00 /* - terminal marker 14 - */,
+/* pos 252: state 108 */ 0xEF /* 'o' */, 0x01 /* (to pos 254 state 109) */,
+/* pos 254: state 109 */ 0xEE /* 'n' */, 0x01 /* (to pos 256 state 110) */,
+/* pos 256: state 110 */ 0xE3 /* 'c' */, 0x01 /* (to pos 258 state 111) */,
+/* pos 258: state 111 */ 0xE5 /* 'e' */, 0x01 /* (to pos 260 state 112) */,
+/* pos 260: state 112 */ 0xBA /* ':' */, 0x01 /* (to pos 262 state 113) */,
+/* pos 262: state 113 */ 0x8F, 0x00 /* - terminal marker 15 - */,
+/* pos 264: state 114 */ 0xD4 /* 'T' */, 0x01 /* (to pos 266 state 115) */,
+/* pos 266: state 115 */ 0xD0 /* 'P' */, 0x01 /* (to pos 268 state 116) */,
+/* pos 268: state 116 */ 0xAF /* '/' */, 0x01 /* (to pos 270 state 117) */,
+/* pos 270: state 117 */ 0xB1 /* '1' */, 0x01 /* (to pos 272 state 118) */,
+/* pos 272: state 118 */ 0xAE /* '.' */, 0x01 /* (to pos 274 state 119) */,
+/* pos 274: state 119 */ 0xB1 /* '1' */, 0x01 /* (to pos 276 state 120) */,
+/* pos 276: state 120 */ 0xA0 /* ' ' */, 0x01 /* (to pos 278 state 121) */,
+/* pos 278: state 121 */ 0x90, 0x00 /* - terminal marker 16 - */,
+/* pos 280: state 122 */ 0xE3 /* 'c' */, 0x01 /* (to pos 282 state 123) */,
+/* pos 282: state 123 */ 0xE3 /* 'c' */, 0x01 /* (to pos 284 state 124) */,
+/* pos 284: state 124 */ 0xE5 /* 'e' */, 0x01 /* (to pos 286 state 125) */,
+/* pos 286: state 125 */ 0xF0 /* 'p' */, 0x01 /* (to pos 288 state 126) */,
+/* pos 288: state 126 */ 0xF4 /* 't' */, 0x01 /* (to pos 290 state 127) */,
+/* pos 290: state 127 */ 0xBA /* ':' */, 0x01 /* (to pos 292 state 128) */,
+/* pos 292: state 128 */ 0x91, 0x00 /* - terminal marker 17 - */,
+/* pos 294: state 129 */ 0xE6 /* 'f' */, 0x01 /* (to pos 296 state 130) */,
+/* pos 296: state 130 */ 0xAD /* '-' */, 0x01 /* (to pos 298 state 131) */,
+/* pos 298: state 131 */ 0xCD /* 'M' */, 0x01 /* (to pos 300 state 132) */,
+/* pos 300: state 132 */ 0xEF /* 'o' */, 0x01 /* (to pos 302 state 133) */,
+/* pos 302: state 133 */ 0xE4 /* 'd' */, 0x01 /* (to pos 304 state 134) */,
+/* pos 304: state 134 */ 0xE9 /* 'i' */, 0x01 /* (to pos 306 state 135) */,
+/* pos 306: state 135 */ 0xE6 /* 'f' */, 0x01 /* (to pos 308 state 136) */,
+/* pos 308: state 136 */ 0xE9 /* 'i' */, 0x01 /* (to pos 310 state 137) */,
+/* pos 310: state 137 */ 0xE5 /* 'e' */, 0x01 /* (to pos 312 state 138) */,
+/* pos 312: state 138 */ 0xE4 /* 'd' */, 0x01 /* (to pos 314 state 139) */,
+/* pos 314: state 139 */ 0xAD /* '-' */, 0x01 /* (to pos 316 state 140) */,
+/* pos 316: state 140 */ 0xD3 /* 'S' */, 0x01 /* (to pos 318 state 141) */,
+/* pos 318: state 141 */ 0xE9 /* 'i' */, 0x01 /* (to pos 320 state 142) */,
+/* pos 320: state 142 */ 0xEE /* 'n' */, 0x01 /* (to pos 322 state 143) */,
+/* pos 322: state 143 */ 0xE3 /* 'c' */, 0x01 /* (to pos 324 state 144) */,
+/* pos 324: state 144 */ 0xE5 /* 'e' */, 0x01 /* (to pos 326 state 145) */,
+/* pos 326: state 145 */ 0xBA /* ':' */, 0x01 /* (to pos 328 state 146) */,
+/* pos 328: state 146 */ 0x92, 0x00 /* - terminal marker 18 - */,
+/* total size 330 bytes */
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index 440d2d9d..389bcb6c 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -251,6 +251,22 @@ enum lws_token_indexes {
WSI_TOKEN_ACCEPT,
WSI_TOKEN_NONCE,
WSI_TOKEN_HTTP,
+
+ /* http-related */
+ WSI_TOKEN_HTTP_ACCEPT,
+ WSI_TOKEN_HTTP_IF_MODIFIED_SINCE,
+ WSI_TOKEN_HTTP_ACCEPT_ENCODING,
+ WSI_TOKEN_HTTP_ACCEPT_LANGUAGE,
+ WSI_TOKEN_HTTP_PRAGMA,
+ WSI_TOKEN_HTTP_CACHE_CONTROL,
+ WSI_TOKEN_HTTP_AUTHORIZATION,
+ WSI_TOKEN_HTTP_COOKIE,
+ WSI_TOKEN_HTTP_CONTENT_TYPE,
+ WSI_TOKEN_HTTP_DATE,
+ WSI_TOKEN_HTTP_RANGE,
+ WSI_TOKEN_HTTP_REFERER,
+
+
WSI_TOKEN_MUXURL,
/* use token storage to stash these */
diff --git a/lib/minilex.c b/lib/minilex.c
index 4912ad60..a085c33e 100644
--- a/lib/minilex.c
+++ b/lib/minilex.c
@@ -1,7 +1,23 @@
+/*
+ * minilex.c
+ *
+ * High efficiency lexical state parser
+ *
+ * Copyright (C)2011-2013 Andy Green <andy@warmcat.com>
+ *
+ * Licensed under LGPL2
+ *
+ * Usage: gcc minilex.c -o minilex && ./minilex > lextable.h
+ *
+ * Run it twice to test parsing on the generated table on stderr
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+/* set of parsable strings */
+
const char *set[] = {
"GET ",
"Host:",
@@ -23,272 +39,23 @@ const char *set[] = {
"Sec-WebSocket-Accept:",
"Sec-WebSocket-Nonce:",
"HTTP/1.1 ",
+
+ "Accept:",
+ "If-Modified-Since:",
+ "Accept-Encoding:",
+ "Accept-Language:",
+ "Pragma:",
+ "Cache-Control:",
+ "Authorization:",
+ "Cookie:",
+ "Content-Type:",
+ "Date:",
+ "Range:",
+ "Referer:"
};
unsigned char lextable[] = {
-/* pos 0: state 0 */
- 0x47 /* 'G' */, 0x07 /* to pos 14 state 1 */,
- 0x48 /* 'H' */, 0x0A /* to pos 22 state 5 */,
- 0x43 /* 'C' */, 0x0F /* to pos 34 state 10 */,
- 0x53 /* 'S' */, 0x19 /* to pos 56 state 21 */,
- 0x55 /* 'U' */, 0x3F /* to pos 134 state 51 */,
- 0x4F /* 'O' */, 0x46 /* to pos 150 state 59 */,
- 0x8D /* '.' */, 0x52 /* to pos 176 state 72 */,
-/* pos 14: state 1 */
- 0xC5 /* 'E' */, 0x01 /* to pos 16 state 2 */,
-/* pos 16: state 2 */
- 0xD4 /* 'T' */, 0x01 /* to pos 18 state 3 */,
-/* pos 18: state 3 */
- 0xA0 /* ' ' */, 0x01 /* to pos 20 state 4 */,
-/* pos 20: state 4 */
- 0x80, 0x00 /* terminal marker */,
-/* pos 22: state 5 */
- 0x6F /* 'o' */, 0x02 /* to pos 26 state 6 */,
- 0xD4 /* 'T' */, 0x76 /* to pos 260 state 114 */,
-/* pos 26: state 6 */
- 0xF3 /* 's' */, 0x01 /* to pos 28 state 7 */,
-/* pos 28: state 7 */
- 0xF4 /* 't' */, 0x01 /* to pos 30 state 8 */,
-/* pos 30: state 8 */
- 0xBA /* ':' */, 0x01 /* to pos 32 state 9 */,
-/* pos 32: state 9 */
- 0x81, 0x00 /* terminal marker */,
-/* pos 34: state 10 */
- 0xEF /* 'o' */, 0x01 /* to pos 36 state 11 */,
-/* pos 36: state 11 */
- 0xEE /* 'n' */, 0x01 /* to pos 38 state 12 */,
-/* pos 38: state 12 */
- 0xEE /* 'n' */, 0x01 /* to pos 40 state 13 */,
-/* pos 40: state 13 */
- 0xE5 /* 'e' */, 0x01 /* to pos 42 state 14 */,
-/* pos 42: state 14 */
- 0xE3 /* 'c' */, 0x01 /* to pos 44 state 15 */,
-/* pos 44: state 15 */
- 0xF4 /* 't' */, 0x01 /* to pos 46 state 16 */,
-/* pos 46: state 16 */
- 0xE9 /* 'i' */, 0x01 /* to pos 48 state 17 */,
-/* pos 48: state 17 */
- 0xEF /* 'o' */, 0x01 /* to pos 50 state 18 */,
-/* pos 50: state 18 */
- 0xEE /* 'n' */, 0x01 /* to pos 52 state 19 */,
-/* pos 52: state 19 */
- 0xBA /* ':' */, 0x01 /* to pos 54 state 20 */,
-/* pos 54: state 20 */
- 0x82, 0x00 /* terminal marker */,
-/* pos 56: state 21 */
- 0xE5 /* 'e' */, 0x01 /* to pos 58 state 22 */,
-/* pos 58: state 22 */
- 0xE3 /* 'c' */, 0x01 /* to pos 60 state 23 */,
-/* pos 60: state 23 */
- 0xAD /* '-' */, 0x01 /* to pos 62 state 24 */,
-/* pos 62: state 24 */
- 0xD7 /* 'W' */, 0x01 /* to pos 64 state 25 */,
-/* pos 64: state 25 */
- 0xE5 /* 'e' */, 0x01 /* to pos 66 state 26 */,
-/* pos 66: state 26 */
- 0xE2 /* 'b' */, 0x01 /* to pos 68 state 27 */,
-/* pos 68: state 27 */
- 0xD3 /* 'S' */, 0x01 /* to pos 70 state 28 */,
-/* pos 70: state 28 */
- 0xEF /* 'o' */, 0x01 /* to pos 72 state 29 */,
-/* pos 72: state 29 */
- 0xE3 /* 'c' */, 0x01 /* to pos 74 state 30 */,
-/* pos 74: state 30 */
- 0xEB /* 'k' */, 0x01 /* to pos 76 state 31 */,
-/* pos 76: state 31 */
- 0xE5 /* 'e' */, 0x01 /* to pos 78 state 32 */,
-/* pos 78: state 32 */
- 0xF4 /* 't' */, 0x01 /* to pos 80 state 33 */,
-/* pos 80: state 33 */
- 0xAD /* '-' */, 0x01 /* to pos 82 state 34 */,
-/* pos 82: state 34 */
- 0x4B /* 'K' */, 0x08 /* to pos 98 state 35 */,
- 0x50 /* 'P' */, 0x10 /* to pos 116 state 42 */,
- 0x44 /* 'D' */, 0x27 /* to pos 164 state 66 */,
- 0x56 /* 'V' */, 0x2F /* to pos 182 state 75 */,
- 0x4F /* 'O' */, 0x36 /* to pos 198 state 83 */,
- 0x45 /* 'E' */, 0x3C /* to pos 212 state 90 */,
- 0x41 /* 'A' */, 0x46 /* to pos 234 state 101 */,
- 0xCE /* 'N' */, 0x4C /* to pos 248 state 108 */,
-/* pos 98: state 35 */
- 0xE5 /* 'e' */, 0x01 /* to pos 100 state 36 */,
-/* pos 100: state 36 */
- 0xF9 /* 'y' */, 0x01 /* to pos 102 state 37 */,
-/* pos 102: state 37 */
- 0x31 /* '1' */, 0x03 /* to pos 108 state 38 */,
- 0x32 /* '2' */, 0x04 /* to pos 112 state 40 */,
- 0xBA /* ':' */, 0x25 /* to pos 180 state 74 */,
-/* pos 108: state 38 */
- 0xBA /* ':' */, 0x01 /* to pos 110 state 39 */,
-/* pos 110: state 39 */
- 0x83, 0x00 /* terminal marker */,
-/* pos 112: state 40 */
- 0xBA /* ':' */, 0x01 /* to pos 114 state 41 */,
-/* pos 114: state 41 */
- 0x84, 0x00 /* terminal marker */,
-/* pos 116: state 42 */
- 0xF2 /* 'r' */, 0x01 /* to pos 118 state 43 */,
-/* pos 118: state 43 */
- 0xEF /* 'o' */, 0x01 /* to pos 120 state 44 */,
-/* pos 120: state 44 */
- 0xF4 /* 't' */, 0x01 /* to pos 122 state 45 */,
-/* pos 122: state 45 */
- 0xEF /* 'o' */, 0x01 /* to pos 124 state 46 */,
-/* pos 124: state 46 */
- 0xE3 /* 'c' */, 0x01 /* to pos 126 state 47 */,
-/* pos 126: state 47 */
- 0xEF /* 'o' */, 0x01 /* to pos 128 state 48 */,
-/* pos 128: state 48 */
- 0xEC /* 'l' */, 0x01 /* to pos 130 state 49 */,
-/* pos 130: state 49 */
- 0xBA /* ':' */, 0x01 /* to pos 132 state 50 */,
-/* pos 132: state 50 */
- 0x85, 0x00 /* terminal marker */,
-/* pos 134: state 51 */
- 0xF0 /* 'p' */, 0x01 /* to pos 136 state 52 */,
-/* pos 136: state 52 */
- 0xE7 /* 'g' */, 0x01 /* to pos 138 state 53 */,
-/* pos 138: state 53 */
- 0xF2 /* 'r' */, 0x01 /* to pos 140 state 54 */,
-/* pos 140: state 54 */
- 0xE1 /* 'a' */, 0x01 /* to pos 142 state 55 */,
-/* pos 142: state 55 */
- 0xE4 /* 'd' */, 0x01 /* to pos 144 state 56 */,
-/* pos 144: state 56 */
- 0xE5 /* 'e' */, 0x01 /* to pos 146 state 57 */,
-/* pos 146: state 57 */
- 0xBA /* ':' */, 0x01 /* to pos 148 state 58 */,
-/* pos 148: state 58 */
- 0x86, 0x00 /* terminal marker */,
-/* pos 150: state 59 */
- 0xF2 /* 'r' */, 0x01 /* to pos 152 state 60 */,
-/* pos 152: state 60 */
- 0xE9 /* 'i' */, 0x01 /* to pos 154 state 61 */,
-/* pos 154: state 61 */
- 0xE7 /* 'g' */, 0x01 /* to pos 156 state 62 */,
-/* pos 156: state 62 */
- 0xE9 /* 'i' */, 0x01 /* to pos 158 state 63 */,
-/* pos 158: state 63 */
- 0xEE /* 'n' */, 0x01 /* to pos 160 state 64 */,
-/* pos 160: state 64 */
- 0xBA /* ':' */, 0x01 /* to pos 162 state 65 */,
-/* pos 162: state 65 */
- 0x87, 0x00 /* terminal marker */,
-/* pos 164: state 66 */
- 0xF2 /* 'r' */, 0x01 /* to pos 166 state 67 */,
-/* pos 166: state 67 */
- 0xE1 /* 'a' */, 0x01 /* to pos 168 state 68 */,
-/* pos 168: state 68 */
- 0xE6 /* 'f' */, 0x01 /* to pos 170 state 69 */,
-/* pos 170: state 69 */
- 0xF4 /* 't' */, 0x01 /* to pos 172 state 70 */,
-/* pos 172: state 70 */
- 0xBA /* ':' */, 0x01 /* to pos 174 state 71 */,
-/* pos 174: state 71 */
- 0x88, 0x00 /* terminal marker */,
-/* pos 176: state 72 */
- 0x8A /* '.' */, 0x01 /* to pos 178 state 73 */,
-/* pos 178: state 73 */
- 0x89, 0x00 /* terminal marker */,
-/* pos 180: state 74 */
- 0x8A, 0x00 /* terminal marker */,
-/* pos 182: state 75 */
- 0xE5 /* 'e' */, 0x01 /* to pos 184 state 76 */,
-/* pos 184: state 76 */
- 0xF2 /* 'r' */, 0x01 /* to pos 186 state 77 */,
-/* pos 186: state 77 */
- 0xF3 /* 's' */, 0x01 /* to pos 188 state 78 */,
-/* pos 188: state 78 */
- 0xE9 /* 'i' */, 0x01 /* to pos 190 state 79 */,
-/* pos 190: state 79 */
- 0xEF /* 'o' */, 0x01 /* to pos 192 state 80 */,
-/* pos 192: state 80 */
- 0xEE /* 'n' */, 0x01 /* to pos 194 state 81 */,
-/* pos 194: state 81 */
- 0xBA /* ':' */, 0x01 /* to pos 196 state 82 */,
-/* pos 196: state 82 */
- 0x8B, 0x00 /* terminal marker */,
-/* pos 198: state 83 */
- 0xF2 /* 'r' */, 0x01 /* to pos 200 state 84 */,
-/* pos 200: state 84 */
- 0xE9 /* 'i' */, 0x01 /* to pos 202 state 85 */,
-/* pos 202: state 85 */
- 0xE7 /* 'g' */, 0x01 /* to pos 204 state 86 */,
-/* pos 204: state 86 */
- 0xE9 /* 'i' */, 0x01 /* to pos 206 state 87 */,
-/* pos 206: state 87 */
- 0xEE /* 'n' */, 0x01 /* to pos 208 state 88 */,
-/* pos 208: state 88 */
- 0xBA /* ':' */, 0x01 /* to pos 210 state 89 */,
-/* pos 210: state 89 */
- 0x8C, 0x00 /* terminal marker */,
-/* pos 212: state 90 */
- 0xF8 /* 'x' */, 0x01 /* to pos 214 state 91 */,
-/* pos 214: state 91 */
- 0xF4 /* 't' */, 0x01 /* to pos 216 state 92 */,
-/* pos 216: state 92 */
- 0xE5 /* 'e' */, 0x01 /* to pos 218 state 93 */,
-/* pos 218: state 93 */
- 0xEE /* 'n' */, 0x01 /* to pos 220 state 94 */,
-/* pos 220: state 94 */
- 0xF3 /* 's' */, 0x01 /* to pos 222 state 95 */,
-/* pos 222: state 95 */
- 0xE9 /* 'i' */, 0x01 /* to pos 224 state 96 */,
-/* pos 224: state 96 */
- 0xEF /* 'o' */, 0x01 /* to pos 226 state 97 */,
-/* pos 226: state 97 */
- 0xEE /* 'n' */, 0x01 /* to pos 228 state 98 */,
-/* pos 228: state 98 */
- 0xF3 /* 's' */, 0x01 /* to pos 230 state 99 */,
-/* pos 230: state 99 */
- 0xBA /* ':' */, 0x01 /* to pos 232 state 100 */,
-/* pos 232: state 100 */
- 0x8D, 0x00 /* terminal marker */,
-/* pos 234: state 101 */
- 0xE3 /* 'c' */, 0x01 /* to pos 236 state 102 */,
-/* pos 236: state 102 */
- 0xE3 /* 'c' */, 0x01 /* to pos 238 state 103 */,
-/* pos 238: state 103 */
- 0xE5 /* 'e' */, 0x01 /* to pos 240 state 104 */,
-/* pos 240: state 104 */
- 0xF0 /* 'p' */, 0x01 /* to pos 242 state 105 */,
-/* pos 242: state 105 */
- 0xF4 /* 't' */, 0x01 /* to pos 244 state 106 */,
-/* pos 244: state 106 */
- 0xBA /* ':' */, 0x01 /* to pos 246 state 107 */,
-/* pos 246: state 107 */
- 0x8E, 0x00 /* terminal marker */,
-/* pos 248: state 108 */
- 0xEF /* 'o' */, 0x01 /* to pos 250 state 109 */,
-/* pos 250: state 109 */
- 0xEE /* 'n' */, 0x01 /* to pos 252 state 110 */,
-/* pos 252: state 110 */
- 0xE3 /* 'c' */, 0x01 /* to pos 254 state 111 */,
-/* pos 254: state 111 */
- 0xE5 /* 'e' */, 0x01 /* to pos 256 state 112 */,
-/* pos 256: state 112 */
- 0xBA /* ':' */, 0x01 /* to pos 258 state 113 */,
-/* pos 258: state 113 */
- 0x8F, 0x00 /* terminal marker */,
-/* pos 260: state 114 */
- 0xD4 /* 'T' */, 0x01 /* to pos 262 state 115 */,
-/* pos 262: state 115 */
- 0xD0 /* 'P' */, 0x01 /* to pos 264 state 116 */,
-/* pos 264: state 116 */
- 0xAF /* '/' */, 0x01 /* to pos 266 state 117 */,
-/* pos 266: state 117 */
- 0xB1 /* '1' */, 0x01 /* to pos 268 state 118 */,
-/* pos 268: state 118 */
- 0xAE /* '.' */, 0x01 /* to pos 270 state 119 */,
-/* pos 270: state 119 */
- 0xB1 /* '1' */, 0x01 /* to pos 272 state 120 */,
-/* pos 272: state 120 */
- 0xA0 /* ' ' */, 0x01 /* to pos 274 state 121 */,
-/* pos 274: state 121 */
- 0x90, 0x00 /* terminal marker */,
-/* total size 276 bytes */
-
-
+ #include "lextable.h"
};
#define PARALLEL 30
@@ -303,21 +70,21 @@ struct state {
struct state state[1000];
int next = 1;
+
int lextable_decode(int pos, char c)
{
while (1) {
- if (lextable[pos + 1] == 0) // terminal marker
+ if (!lextable[pos + 1]) /* terminal marker */
return pos;
- if ((lextable[pos] & 0x7f) == c)
+ if ((lextable[pos] & 0x7f) == c) /* goto */
return pos + (lextable[pos + 1] << 1);
- if (lextable[pos] & 0x80)
+ if (lextable[pos] & 0x80) /* fail */
return -1;
pos += 2;
}
- return pos;
}
@@ -341,8 +108,9 @@ int main(void)
saw = 0;
for (y = 0; y < state[walk].count; y++)
- if (state[walk].c[y] == set[n][m]) { /* exists */
- walk = state[walk].state[y]; /* go forward */
+ if (state[walk].c[y] == set[n][m]) {
+ /* exists -- go forward */
+ walk = state[walk].state[y];
saw = 1;
break;
}
@@ -356,19 +124,14 @@ int main(void)
state[walk].state[state[walk].count] = next;
state[walk].count++;
-
-// if (set[n][m + 1] == '\0') /* terminal */
- walk = next++;
+ walk = next++;
again:
m++;
}
- state[walk].c[0] = n;
+ state[walk].c[0] = n++;
state[walk].state[0] = 0; /* terminal marker */
state[walk].count = 1;
-
- n++;
-
}
walk = 0;
@@ -376,19 +139,17 @@ again:
state[n].bytepos = walk;
walk += (2 * state[n].count);
}
-#if 0
- for (n = 0; n < next; n++) {
- fprintf(stderr, "State %d\n", n);
- for (m = 0; m < state[n].count; m++)
- fprintf(stderr, "'%c' -> %d\n", state[n].c[m], state[n].state[m]);
- fprintf(stderr, "(stop)\n");
- }
-#endif
walk = 0;
for (n = 0; n < next; n++) {
- fprintf(stderr, "/* pos %d: state %d */\n", walk, n);
for (m = 0; m < state[n].count; m++) {
+
+ if (!m)
+ fprintf(stdout, "/* pos %3d: state %3d */ ",
+ walk, n);
+ else
+ fprintf(stdout, " ");
+
y = state[n].c[m];
saw = state[n].state[m];
@@ -396,28 +157,39 @@ again:
y |= 0x80; /* last option */
if (saw == 0) // c is a terminal then
- fprintf(stderr, " 0x%02X, 0x00 /* terminal marker */, \n", y);
- else { // c is a character and we need a byte delta
+ fprintf(stdout, " 0x%02X, 0x00 "
+ "/* - terminal marker %2d - */, \n",
+ y, y - 0x80);
+ else { /* c is a character and we need a byte delta */
if ((state[saw].bytepos - walk) / 2 > 0xff) {
- fprintf(stderr, "Tried to jump > 510 bytes ahead\n");
+ fprintf(stdout,
+ "Tried to jump > 510 bytes ahead\n");
return 1;
}
prev = y &0x7f;
if (prev < 32 || prev > 126)
prev = '.';
- fprintf(stderr, " 0x%02X /* '%c' */, 0x%02X /* to pos %d state %d */,\n", y, prev, (state[saw].bytepos - walk) / 2, state[saw].bytepos, saw);
+ fprintf(stdout, " 0x%02X /* '%c' */, 0x%02X "
+ "/* (to pos %3d state %3d) */,\n",
+ y, prev,
+ (state[saw].bytepos - walk) / 2,
+ state[saw].bytepos, saw);
}
walk += 2;
}
}
- fprintf(stderr, "/* total size %d bytes */\n", walk);
+ fprintf(stdout, "/* total size %d bytes */\n", walk);
+
+ /*
+ * Test parser... real parser code is the same
+ */
for (n = 0; n < sizeof(set) / sizeof(set[0]); n++) {
walk = 0;
m = 0;
- fprintf(stderr, "Trying %s\n", set[n]);
+ fprintf(stderr, "Trying '%s'\n", set[n]);
while (set[n][m]) {
walk = lextable_decode(walk, set[n][m]);
@@ -426,7 +198,8 @@ again:
break;
}
if (lextable[walk + 1] == 0) {
- fprintf(stderr, "decode: %d\n", lextable[walk] & 0x7f);
+ fprintf(stderr, "decode: %d\n",
+ lextable[walk] & 0x7f);
break;
}
m++;
@@ -435,6 +208,3 @@ again:
return 0;
}
-
-
-
diff --git a/lib/parsers.c b/lib/parsers.c
index cae50d88..ba10899a 100644
--- a/lib/parsers.c
+++ b/lib/parsers.c
@@ -27,267 +27,7 @@
unsigned char lextable[] = {
- /* pos 0: state 0 */
- 0x47 /* 'G' */, 0x07 /* to pos 14 state 1 */,
- 0x48 /* 'H' */, 0x0A /* to pos 22 state 5 */,
- 0x43 /* 'C' */, 0x0F /* to pos 34 state 10 */,
- 0x53 /* 'S' */, 0x19 /* to pos 56 state 21 */,
- 0x55 /* 'U' */, 0x3F /* to pos 134 state 51 */,
- 0x4F /* 'O' */, 0x46 /* to pos 150 state 59 */,
- 0x8D /* '.' */, 0x52 /* to pos 176 state 72 */,
- /* pos 14: state 1 */
- 0xC5 /* 'E' */, 0x01 /* to pos 16 state 2 */,
- /* pos 16: state 2 */
- 0xD4 /* 'T' */, 0x01 /* to pos 18 state 3 */,
- /* pos 18: state 3 */
- 0xA0 /* ' ' */, 0x01 /* to pos 20 state 4 */,
- /* pos 20: state 4 */
- 0x80, 0x00 /* terminal marker */,
- /* pos 22: state 5 */
- 0x6F /* 'o' */, 0x02 /* to pos 26 state 6 */,
- 0xD4 /* 'T' */, 0x76 /* to pos 260 state 114 */,
- /* pos 26: state 6 */
- 0xF3 /* 's' */, 0x01 /* to pos 28 state 7 */,
- /* pos 28: state 7 */
- 0xF4 /* 't' */, 0x01 /* to pos 30 state 8 */,
- /* pos 30: state 8 */
- 0xBA /* ':' */, 0x01 /* to pos 32 state 9 */,
- /* pos 32: state 9 */
- 0x81, 0x00 /* terminal marker */,
- /* pos 34: state 10 */
- 0xEF /* 'o' */, 0x01 /* to pos 36 state 11 */,
- /* pos 36: state 11 */
- 0xEE /* 'n' */, 0x01 /* to pos 38 state 12 */,
- /* pos 38: state 12 */
- 0xEE /* 'n' */, 0x01 /* to pos 40 state 13 */,
- /* pos 40: state 13 */
- 0xE5 /* 'e' */, 0x01 /* to pos 42 state 14 */,
- /* pos 42: state 14 */
- 0xE3 /* 'c' */, 0x01 /* to pos 44 state 15 */,
- /* pos 44: state 15 */
- 0xF4 /* 't' */, 0x01 /* to pos 46 state 16 */,
- /* pos 46: state 16 */
- 0xE9 /* 'i' */, 0x01 /* to pos 48 state 17 */,
- /* pos 48: state 17 */
- 0xEF /* 'o' */, 0x01 /* to pos 50 state 18 */,
- /* pos 50: state 18 */
- 0xEE /* 'n' */, 0x01 /* to pos 52 state 19 */,
- /* pos 52: state 19 */
- 0xBA /* ':' */, 0x01 /* to pos 54 state 20 */,
- /* pos 54: state 20 */
- 0x82, 0x00 /* terminal marker */,
- /* pos 56: state 21 */
- 0xE5 /* 'e' */, 0x01 /* to pos 58 state 22 */,
- /* pos 58: state 22 */
- 0xE3 /* 'c' */, 0x01 /* to pos 60 state 23 */,
- /* pos 60: state 23 */
- 0xAD /* '-' */, 0x01 /* to pos 62 state 24 */,
- /* pos 62: state 24 */
- 0xD7 /* 'W' */, 0x01 /* to pos 64 state 25 */,
- /* pos 64: state 25 */
- 0xE5 /* 'e' */, 0x01 /* to pos 66 state 26 */,
- /* pos 66: state 26 */
- 0xE2 /* 'b' */, 0x01 /* to pos 68 state 27 */,
- /* pos 68: state 27 */
- 0xD3 /* 'S' */, 0x01 /* to pos 70 state 28 */,
- /* pos 70: state 28 */
- 0xEF /* 'o' */, 0x01 /* to pos 72 state 29 */,
- /* pos 72: state 29 */
- 0xE3 /* 'c' */, 0x01 /* to pos 74 state 30 */,
- /* pos 74: state 30 */
- 0xEB /* 'k' */, 0x01 /* to pos 76 state 31 */,
- /* pos 76: state 31 */
- 0xE5 /* 'e' */, 0x01 /* to pos 78 state 32 */,
- /* pos 78: state 32 */
- 0xF4 /* 't' */, 0x01 /* to pos 80 state 33 */,
- /* pos 80: state 33 */
- 0xAD /* '-' */, 0x01 /* to pos 82 state 34 */,
- /* pos 82: state 34 */
- 0x4B /* 'K' */, 0x08 /* to pos 98 state 35 */,
- 0x50 /* 'P' */, 0x10 /* to pos 116 state 42 */,
- 0x44 /* 'D' */, 0x27 /* to pos 164 state 66 */,
- 0x56 /* 'V' */, 0x2F /* to pos 182 state 75 */,
- 0x4F /* 'O' */, 0x36 /* to pos 198 state 83 */,
- 0x45 /* 'E' */, 0x3C /* to pos 212 state 90 */,
- 0x41 /* 'A' */, 0x46 /* to pos 234 state 101 */,
- 0xCE /* 'N' */, 0x4C /* to pos 248 state 108 */,
- /* pos 98: state 35 */
- 0xE5 /* 'e' */, 0x01 /* to pos 100 state 36 */,
- /* pos 100: state 36 */
- 0xF9 /* 'y' */, 0x01 /* to pos 102 state 37 */,
- /* pos 102: state 37 */
- 0x31 /* '1' */, 0x03 /* to pos 108 state 38 */,
- 0x32 /* '2' */, 0x04 /* to pos 112 state 40 */,
- 0xBA /* ':' */, 0x25 /* to pos 180 state 74 */,
- /* pos 108: state 38 */
- 0xBA /* ':' */, 0x01 /* to pos 110 state 39 */,
- /* pos 110: state 39 */
- 0x83, 0x00 /* terminal marker */,
- /* pos 112: state 40 */
- 0xBA /* ':' */, 0x01 /* to pos 114 state 41 */,
- /* pos 114: state 41 */
- 0x84, 0x00 /* terminal marker */,
- /* pos 116: state 42 */
- 0xF2 /* 'r' */, 0x01 /* to pos 118 state 43 */,
- /* pos 118: state 43 */
- 0xEF /* 'o' */, 0x01 /* to pos 120 state 44 */,
- /* pos 120: state 44 */
- 0xF4 /* 't' */, 0x01 /* to pos 122 state 45 */,
- /* pos 122: state 45 */
- 0xEF /* 'o' */, 0x01 /* to pos 124 state 46 */,
- /* pos 124: state 46 */
- 0xE3 /* 'c' */, 0x01 /* to pos 126 state 47 */,
- /* pos 126: state 47 */
- 0xEF /* 'o' */, 0x01 /* to pos 128 state 48 */,
- /* pos 128: state 48 */
- 0xEC /* 'l' */, 0x01 /* to pos 130 state 49 */,
- /* pos 130: state 49 */
- 0xBA /* ':' */, 0x01 /* to pos 132 state 50 */,
- /* pos 132: state 50 */
- 0x85, 0x00 /* terminal marker */,
- /* pos 134: state 51 */
- 0xF0 /* 'p' */, 0x01 /* to pos 136 state 52 */,
- /* pos 136: state 52 */
- 0xE7 /* 'g' */, 0x01 /* to pos 138 state 53 */,
- /* pos 138: state 53 */
- 0xF2 /* 'r' */, 0x01 /* to pos 140 state 54 */,
- /* pos 140: state 54 */
- 0xE1 /* 'a' */, 0x01 /* to pos 142 state 55 */,
- /* pos 142: state 55 */
- 0xE4 /* 'd' */, 0x01 /* to pos 144 state 56 */,
- /* pos 144: state 56 */
- 0xE5 /* 'e' */, 0x01 /* to pos 146 state 57 */,
- /* pos 146: state 57 */
- 0xBA /* ':' */, 0x01 /* to pos 148 state 58 */,
- /* pos 148: state 58 */
- 0x86, 0x00 /* terminal marker */,
- /* pos 150: state 59 */
- 0xF2 /* 'r' */, 0x01 /* to pos 152 state 60 */,
- /* pos 152: state 60 */
- 0xE9 /* 'i' */, 0x01 /* to pos 154 state 61 */,
- /* pos 154: state 61 */
- 0xE7 /* 'g' */, 0x01 /* to pos 156 state 62 */,
- /* pos 156: state 62 */
- 0xE9 /* 'i' */, 0x01 /* to pos 158 state 63 */,
- /* pos 158: state 63 */
- 0xEE /* 'n' */, 0x01 /* to pos 160 state 64 */,
- /* pos 160: state 64 */
- 0xBA /* ':' */, 0x01 /* to pos 162 state 65 */,
- /* pos 162: state 65 */
- 0x87, 0x00 /* terminal marker */,
- /* pos 164: state 66 */
- 0xF2 /* 'r' */, 0x01 /* to pos 166 state 67 */,
- /* pos 166: state 67 */
- 0xE1 /* 'a' */, 0x01 /* to pos 168 state 68 */,
- /* pos 168: state 68 */
- 0xE6 /* 'f' */, 0x01 /* to pos 170 state 69 */,
- /* pos 170: state 69 */
- 0xF4 /* 't' */, 0x01 /* to pos 172 state 70 */,
- /* pos 172: state 70 */
- 0xBA /* ':' */, 0x01 /* to pos 174 state 71 */,
- /* pos 174: state 71 */
- 0x88, 0x00 /* terminal marker */,
- /* pos 176: state 72 */
- 0x8A /* '.' */, 0x01 /* to pos 178 state 73 */,
- /* pos 178: state 73 */
- 0x89, 0x00 /* terminal marker */,
- /* pos 180: state 74 */
- 0x8A, 0x00 /* terminal marker */,
- /* pos 182: state 75 */
- 0xE5 /* 'e' */, 0x01 /* to pos 184 state 76 */,
- /* pos 184: state 76 */
- 0xF2 /* 'r' */, 0x01 /* to pos 186 state 77 */,
- /* pos 186: state 77 */
- 0xF3 /* 's' */, 0x01 /* to pos 188 state 78 */,
- /* pos 188: state 78 */
- 0xE9 /* 'i' */, 0x01 /* to pos 190 state 79 */,
- /* pos 190: state 79 */
- 0xEF /* 'o' */, 0x01 /* to pos 192 state 80 */,
- /* pos 192: state 80 */
- 0xEE /* 'n' */, 0x01 /* to pos 194 state 81 */,
- /* pos 194: state 81 */
- 0xBA /* ':' */, 0x01 /* to pos 196 state 82 */,
- /* pos 196: state 82 */
- 0x8B, 0x00 /* terminal marker */,
- /* pos 198: state 83 */
- 0xF2 /* 'r' */, 0x01 /* to pos 200 state 84 */,
- /* pos 200: state 84 */
- 0xE9 /* 'i' */, 0x01 /* to pos 202 state 85 */,
- /* pos 202: state 85 */
- 0xE7 /* 'g' */, 0x01 /* to pos 204 state 86 */,
- /* pos 204: state 86 */
- 0xE9 /* 'i' */, 0x01 /* to pos 206 state 87 */,
- /* pos 206: state 87 */
- 0xEE /* 'n' */, 0x01 /* to pos 208 state 88 */,
- /* pos 208: state 88 */
- 0xBA /* ':' */, 0x01 /* to pos 210 state 89 */,
- /* pos 210: state 89 */
- 0x8C, 0x00 /* terminal marker */,
- /* pos 212: state 90 */
- 0xF8 /* 'x' */, 0x01 /* to pos 214 state 91 */,
- /* pos 214: state 91 */
- 0xF4 /* 't' */, 0x01 /* to pos 216 state 92 */,
- /* pos 216: state 92 */
- 0xE5 /* 'e' */, 0x01 /* to pos 218 state 93 */,
- /* pos 218: state 93 */
- 0xEE /* 'n' */, 0x01 /* to pos 220 state 94 */,
- /* pos 220: state 94 */
- 0xF3 /* 's' */, 0x01 /* to pos 222 state 95 */,
- /* pos 222: state 95 */
- 0xE9 /* 'i' */, 0x01 /* to pos 224 state 96 */,
- /* pos 224: state 96 */
- 0xEF /* 'o' */, 0x01 /* to pos 226 state 97 */,
- /* pos 226: state 97 */
- 0xEE /* 'n' */, 0x01 /* to pos 228 state 98 */,
- /* pos 228: state 98 */
- 0xF3 /* 's' */, 0x01 /* to pos 230 state 99 */,
- /* pos 230: state 99 */
- 0xBA /* ':' */, 0x01 /* to pos 232 state 100 */,
- /* pos 232: state 100 */
- 0x8D, 0x00 /* terminal marker */,
- /* pos 234: state 101 */
- 0xE3 /* 'c' */, 0x01 /* to pos 236 state 102 */,
- /* pos 236: state 102 */
- 0xE3 /* 'c' */, 0x01 /* to pos 238 state 103 */,
- /* pos 238: state 103 */
- 0xE5 /* 'e' */, 0x01 /* to pos 240 state 104 */,
- /* pos 240: state 104 */
- 0xF0 /* 'p' */, 0x01 /* to pos 242 state 105 */,
- /* pos 242: state 105 */
- 0xF4 /* 't' */, 0x01 /* to pos 244 state 106 */,
- /* pos 244: state 106 */
- 0xBA /* ':' */, 0x01 /* to pos 246 state 107 */,
- /* pos 246: state 107 */
- 0x8E, 0x00 /* terminal marker */,
- /* pos 248: state 108 */
- 0xEF /* 'o' */, 0x01 /* to pos 250 state 109 */,
- /* pos 250: state 109 */
- 0xEE /* 'n' */, 0x01 /* to pos 252 state 110 */,
- /* pos 252: state 110 */
- 0xE3 /* 'c' */, 0x01 /* to pos 254 state 111 */,
- /* pos 254: state 111 */
- 0xE5 /* 'e' */, 0x01 /* to pos 256 state 112 */,
- /* pos 256: state 112 */
- 0xBA /* ':' */, 0x01 /* to pos 258 state 113 */,
- /* pos 258: state 113 */
- 0x8F, 0x00 /* terminal marker */,
- /* pos 260: state 114 */
- 0xD4 /* 'T' */, 0x01 /* to pos 262 state 115 */,
- /* pos 262: state 115 */
- 0xD0 /* 'P' */, 0x01 /* to pos 264 state 116 */,
- /* pos 264: state 116 */
- 0xAF /* '/' */, 0x01 /* to pos 266 state 117 */,
- /* pos 266: state 117 */
- 0xB1 /* '1' */, 0x01 /* to pos 268 state 118 */,
- /* pos 268: state 118 */
- 0xAE /* '.' */, 0x01 /* to pos 270 state 119 */,
- /* pos 270: state 119 */
- 0xB1 /* '1' */, 0x01 /* to pos 272 state 120 */,
- /* pos 272: state 120 */
- 0xA0 /* ' ' */, 0x01 /* to pos 274 state 121 */,
- /* pos 274: state 121 */
- 0x90, 0x00 /* terminal marker */,
- /* total size 276 bytes */
+ #include "lextable.h"
};
int lextable_decode(int pos, char c)
@@ -426,6 +166,19 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
case WSI_TOKEN_NONCE:
case WSI_TOKEN_EXTENSIONS:
case WSI_TOKEN_HTTP:
+ case WSI_TOKEN_HTTP_ACCEPT:
+ case WSI_TOKEN_HTTP_IF_MODIFIED_SINCE:
+ case WSI_TOKEN_HTTP_ACCEPT_ENCODING:
+ case WSI_TOKEN_HTTP_ACCEPT_LANGUAGE:
+ case WSI_TOKEN_HTTP_PRAGMA:
+ case WSI_TOKEN_HTTP_CACHE_CONTROL:
+ case WSI_TOKEN_HTTP_AUTHORIZATION:
+ case WSI_TOKEN_HTTP_COOKIE:
+ case WSI_TOKEN_HTTP_CONTENT_TYPE:
+ case WSI_TOKEN_HTTP_DATE:
+ case WSI_TOKEN_HTTP_RANGE:
+ case WSI_TOKEN_HTTP_REFERER:
+
lwsl_parser("WSI_TOK_(%d) '%c'\n", wsi->u.hdr.parser_state, c);
@@ -539,25 +292,23 @@ start_fragment:
if (!n) { /* first fragment */
wsi->u.hdr.ah->frag_index[wsi->u.hdr.parser_state] =
wsi->u.hdr.ah->next_frag_index;
- } else { /* continuation */
- while (wsi->u.hdr.ah->frags[n].next_frag_index)
+ break;
+ }
+ /* continuation */
+ while (wsi->u.hdr.ah->frags[n].next_frag_index)
n = wsi->u.hdr.ah->frags[n].next_frag_index;
- wsi->u.hdr.ah->frags[n].next_frag_index =
+ wsi->u.hdr.ah->frags[n].next_frag_index =
wsi->u.hdr.ah->next_frag_index;
- if (wsi->u.hdr.ah->pos == sizeof(wsi->u.hdr.ah->data)) {
- lwsl_warn("excessive header content\n");
- return -1;
- }
-
- wsi->u.hdr.ah->data[wsi->u.hdr.ah->pos++] = ' ';
- wsi->u.hdr.ah->frags[
- wsi->u.hdr.ah->next_frag_index].len++;
+ if (wsi->u.hdr.ah->pos == sizeof(wsi->u.hdr.ah->data)) {
+ lwsl_warn("excessive header content\n");
+ return -1;
}
+ wsi->u.hdr.ah->data[wsi->u.hdr.ah->pos++] = ' ';
+ wsi->u.hdr.ah->frags[wsi->u.hdr.ah->next_frag_index].len++;
break;
-
/* skipping arg part of a name we didn't recognize */
case WSI_TOKEN_SKIPPING:
lwsl_parser("WSI_TOKEN_SKIPPING '%c'\n", c);