rfc1918_parser.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. #line 1 "rfc1918_parser.rl"
  2. #include "rfc1918_parser.h"
  3. /** Ragel machine **/
  4. #line 21 "rfc1918_parser.rl"
  5. /** Data **/
  6. #line 15 "rfc1918_parser.c"
  7. static const int rfc1918_parser_start = 1;
  8. static const int rfc1918_parser_first_final = 28;
  9. static const int rfc1918_parser_error = 0;
  10. static const int rfc1918_parser_en_main = 1;
  11. #line 26 "rfc1918_parser.rl"
  12. /** exec **/
  13. unsigned int rfc1918_parser_execute(const char *str, size_t len)
  14. {
  15. int cs = 0;
  16. const char *p, *pe;
  17. unsigned int is_ip_rfc1918 = 0;
  18. p = str;
  19. pe = str+len;
  20. #line 37 "rfc1918_parser.c"
  21. {
  22. cs = rfc1918_parser_start;
  23. }
  24. #line 39 "rfc1918_parser.rl"
  25. #line 44 "rfc1918_parser.c"
  26. {
  27. if ( p == pe )
  28. goto _test_eof;
  29. switch ( cs )
  30. {
  31. case 1:
  32. if ( (*p) == 49 )
  33. goto st2;
  34. goto st0;
  35. st0:
  36. cs = 0;
  37. goto _out;
  38. st2:
  39. if ( ++p == pe )
  40. goto _test_eof2;
  41. case 2:
  42. switch( (*p) ) {
  43. case 48: goto st3;
  44. case 55: goto st17;
  45. case 57: goto st23;
  46. }
  47. goto st0;
  48. st3:
  49. if ( ++p == pe )
  50. goto _test_eof3;
  51. case 3:
  52. if ( (*p) == 46 )
  53. goto st4;
  54. goto st0;
  55. st4:
  56. if ( ++p == pe )
  57. goto _test_eof4;
  58. case 4:
  59. switch( (*p) ) {
  60. case 48: goto st5;
  61. case 49: goto st13;
  62. case 50: goto st15;
  63. }
  64. if ( 51 <= (*p) && (*p) <= 57 )
  65. goto st14;
  66. goto st0;
  67. st5:
  68. if ( ++p == pe )
  69. goto _test_eof5;
  70. case 5:
  71. if ( (*p) == 46 )
  72. goto st6;
  73. goto st0;
  74. st6:
  75. if ( ++p == pe )
  76. goto _test_eof6;
  77. case 6:
  78. switch( (*p) ) {
  79. case 48: goto st7;
  80. case 49: goto st9;
  81. case 50: goto st11;
  82. }
  83. if ( 51 <= (*p) && (*p) <= 57 )
  84. goto st10;
  85. goto st0;
  86. st7:
  87. if ( ++p == pe )
  88. goto _test_eof7;
  89. case 7:
  90. if ( (*p) == 46 )
  91. goto st8;
  92. goto st0;
  93. st8:
  94. if ( ++p == pe )
  95. goto _test_eof8;
  96. case 8:
  97. switch( (*p) ) {
  98. case 48: goto tr16;
  99. case 49: goto tr17;
  100. case 50: goto tr18;
  101. }
  102. if ( 51 <= (*p) && (*p) <= 57 )
  103. goto tr19;
  104. goto st0;
  105. tr16:
  106. #line 8 "rfc1918_parser.rl"
  107. {
  108. is_ip_rfc1918 = 1;
  109. }
  110. goto st28;
  111. st28:
  112. if ( ++p == pe )
  113. goto _test_eof28;
  114. case 28:
  115. #line 134 "rfc1918_parser.c"
  116. goto st0;
  117. tr17:
  118. #line 8 "rfc1918_parser.rl"
  119. {
  120. is_ip_rfc1918 = 1;
  121. }
  122. goto st29;
  123. st29:
  124. if ( ++p == pe )
  125. goto _test_eof29;
  126. case 29:
  127. #line 146 "rfc1918_parser.c"
  128. if ( 48 <= (*p) && (*p) <= 57 )
  129. goto tr19;
  130. goto st0;
  131. tr19:
  132. #line 8 "rfc1918_parser.rl"
  133. {
  134. is_ip_rfc1918 = 1;
  135. }
  136. goto st30;
  137. st30:
  138. if ( ++p == pe )
  139. goto _test_eof30;
  140. case 30:
  141. #line 160 "rfc1918_parser.c"
  142. if ( 48 <= (*p) && (*p) <= 57 )
  143. goto tr16;
  144. goto st0;
  145. tr18:
  146. #line 8 "rfc1918_parser.rl"
  147. {
  148. is_ip_rfc1918 = 1;
  149. }
  150. goto st31;
  151. st31:
  152. if ( ++p == pe )
  153. goto _test_eof31;
  154. case 31:
  155. #line 174 "rfc1918_parser.c"
  156. if ( (*p) == 53 )
  157. goto tr31;
  158. if ( (*p) > 52 ) {
  159. if ( 54 <= (*p) && (*p) <= 57 )
  160. goto tr16;
  161. } else if ( (*p) >= 48 )
  162. goto tr19;
  163. goto st0;
  164. tr31:
  165. #line 8 "rfc1918_parser.rl"
  166. {
  167. is_ip_rfc1918 = 1;
  168. }
  169. goto st32;
  170. st32:
  171. if ( ++p == pe )
  172. goto _test_eof32;
  173. case 32:
  174. #line 193 "rfc1918_parser.c"
  175. if ( 48 <= (*p) && (*p) <= 53 )
  176. goto tr16;
  177. goto st0;
  178. st9:
  179. if ( ++p == pe )
  180. goto _test_eof9;
  181. case 9:
  182. if ( (*p) == 46 )
  183. goto st8;
  184. if ( 48 <= (*p) && (*p) <= 57 )
  185. goto st10;
  186. goto st0;
  187. st10:
  188. if ( ++p == pe )
  189. goto _test_eof10;
  190. case 10:
  191. if ( (*p) == 46 )
  192. goto st8;
  193. if ( 48 <= (*p) && (*p) <= 57 )
  194. goto st7;
  195. goto st0;
  196. st11:
  197. if ( ++p == pe )
  198. goto _test_eof11;
  199. case 11:
  200. switch( (*p) ) {
  201. case 46: goto st8;
  202. case 53: goto st12;
  203. }
  204. if ( (*p) > 52 ) {
  205. if ( 54 <= (*p) && (*p) <= 57 )
  206. goto st7;
  207. } else if ( (*p) >= 48 )
  208. goto st10;
  209. goto st0;
  210. st12:
  211. if ( ++p == pe )
  212. goto _test_eof12;
  213. case 12:
  214. if ( (*p) == 46 )
  215. goto st8;
  216. if ( 48 <= (*p) && (*p) <= 53 )
  217. goto st7;
  218. goto st0;
  219. st13:
  220. if ( ++p == pe )
  221. goto _test_eof13;
  222. case 13:
  223. if ( (*p) == 46 )
  224. goto st6;
  225. if ( 48 <= (*p) && (*p) <= 57 )
  226. goto st14;
  227. goto st0;
  228. st14:
  229. if ( ++p == pe )
  230. goto _test_eof14;
  231. case 14:
  232. if ( (*p) == 46 )
  233. goto st6;
  234. if ( 48 <= (*p) && (*p) <= 57 )
  235. goto st5;
  236. goto st0;
  237. st15:
  238. if ( ++p == pe )
  239. goto _test_eof15;
  240. case 15:
  241. switch( (*p) ) {
  242. case 46: goto st6;
  243. case 53: goto st16;
  244. }
  245. if ( (*p) > 52 ) {
  246. if ( 54 <= (*p) && (*p) <= 57 )
  247. goto st5;
  248. } else if ( (*p) >= 48 )
  249. goto st14;
  250. goto st0;
  251. st16:
  252. if ( ++p == pe )
  253. goto _test_eof16;
  254. case 16:
  255. if ( (*p) == 46 )
  256. goto st6;
  257. if ( 48 <= (*p) && (*p) <= 53 )
  258. goto st5;
  259. goto st0;
  260. st17:
  261. if ( ++p == pe )
  262. goto _test_eof17;
  263. case 17:
  264. if ( (*p) == 50 )
  265. goto st18;
  266. goto st0;
  267. st18:
  268. if ( ++p == pe )
  269. goto _test_eof18;
  270. case 18:
  271. if ( (*p) == 46 )
  272. goto st19;
  273. goto st0;
  274. st19:
  275. if ( ++p == pe )
  276. goto _test_eof19;
  277. case 19:
  278. switch( (*p) ) {
  279. case 49: goto st20;
  280. case 50: goto st21;
  281. case 51: goto st22;
  282. }
  283. goto st0;
  284. st20:
  285. if ( ++p == pe )
  286. goto _test_eof20;
  287. case 20:
  288. if ( 54 <= (*p) && (*p) <= 57 )
  289. goto st5;
  290. goto st0;
  291. st21:
  292. if ( ++p == pe )
  293. goto _test_eof21;
  294. case 21:
  295. if ( 48 <= (*p) && (*p) <= 57 )
  296. goto st5;
  297. goto st0;
  298. st22:
  299. if ( ++p == pe )
  300. goto _test_eof22;
  301. case 22:
  302. if ( 48 <= (*p) && (*p) <= 49 )
  303. goto st5;
  304. goto st0;
  305. st23:
  306. if ( ++p == pe )
  307. goto _test_eof23;
  308. case 23:
  309. if ( (*p) == 50 )
  310. goto st24;
  311. goto st0;
  312. st24:
  313. if ( ++p == pe )
  314. goto _test_eof24;
  315. case 24:
  316. if ( (*p) == 46 )
  317. goto st25;
  318. goto st0;
  319. st25:
  320. if ( ++p == pe )
  321. goto _test_eof25;
  322. case 25:
  323. if ( (*p) == 49 )
  324. goto st26;
  325. goto st0;
  326. st26:
  327. if ( ++p == pe )
  328. goto _test_eof26;
  329. case 26:
  330. if ( (*p) == 54 )
  331. goto st27;
  332. goto st0;
  333. st27:
  334. if ( ++p == pe )
  335. goto _test_eof27;
  336. case 27:
  337. if ( (*p) == 56 )
  338. goto st5;
  339. goto st0;
  340. }
  341. _test_eof2: cs = 2; goto _test_eof;
  342. _test_eof3: cs = 3; goto _test_eof;
  343. _test_eof4: cs = 4; goto _test_eof;
  344. _test_eof5: cs = 5; goto _test_eof;
  345. _test_eof6: cs = 6; goto _test_eof;
  346. _test_eof7: cs = 7; goto _test_eof;
  347. _test_eof8: cs = 8; goto _test_eof;
  348. _test_eof28: cs = 28; goto _test_eof;
  349. _test_eof29: cs = 29; goto _test_eof;
  350. _test_eof30: cs = 30; goto _test_eof;
  351. _test_eof31: cs = 31; goto _test_eof;
  352. _test_eof32: cs = 32; goto _test_eof;
  353. _test_eof9: cs = 9; goto _test_eof;
  354. _test_eof10: cs = 10; goto _test_eof;
  355. _test_eof11: cs = 11; goto _test_eof;
  356. _test_eof12: cs = 12; goto _test_eof;
  357. _test_eof13: cs = 13; goto _test_eof;
  358. _test_eof14: cs = 14; goto _test_eof;
  359. _test_eof15: cs = 15; goto _test_eof;
  360. _test_eof16: cs = 16; goto _test_eof;
  361. _test_eof17: cs = 17; goto _test_eof;
  362. _test_eof18: cs = 18; goto _test_eof;
  363. _test_eof19: cs = 19; goto _test_eof;
  364. _test_eof20: cs = 20; goto _test_eof;
  365. _test_eof21: cs = 21; goto _test_eof;
  366. _test_eof22: cs = 22; goto _test_eof;
  367. _test_eof23: cs = 23; goto _test_eof;
  368. _test_eof24: cs = 24; goto _test_eof;
  369. _test_eof25: cs = 25; goto _test_eof;
  370. _test_eof26: cs = 26; goto _test_eof;
  371. _test_eof27: cs = 27; goto _test_eof;
  372. _test_eof: {}
  373. _out: {}
  374. }
  375. #line 40 "rfc1918_parser.rl"
  376. return is_ip_rfc1918;
  377. }