acl.yy.cpp 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /* A lexical scanner generated by flex */
  13. #define FLEX_SCANNER
  14. #define ACL_FLEX_MAJOR_VERSION 2
  15. #define ACL_FLEX_MINOR_VERSION 5
  16. #include <stdio.h>
  17. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  18. #ifdef c_plusplus
  19. #ifndef __cplusplus
  20. #define __cplusplus
  21. #endif
  22. #endif
  23. #ifdef __cplusplus
  24. #include <stdlib.h>
  25. /* Use prototypes in function declarations. */
  26. #define ACL_USE_PROTOS
  27. /* The "const" storage-class-modifier is valid. */
  28. #define ACL_USE_CONST
  29. #else /* ! __cplusplus */
  30. #if __STDC__
  31. #define ACL_USE_PROTOS
  32. #define ACL_USE_CONST
  33. #endif /* __STDC__ */
  34. #endif /* ! __cplusplus */
  35. #ifdef __TURBOC__
  36. #pragma warn -rch
  37. #pragma warn -use
  38. #include <io.h>
  39. #include <stdlib.h>
  40. #define ACL_USE_CONST
  41. #define ACL_USE_PROTOS
  42. #endif
  43. #ifdef ACL_USE_CONST
  44. #define aclconst const
  45. #else
  46. #define aclconst
  47. #endif
  48. #ifdef ACL_USE_PROTOS
  49. #define ACL_PROTO(proto) proto
  50. #else
  51. #define ACL_PROTO(proto) ()
  52. #endif
  53. /* Returned upon end-of-file. */
  54. #define ACL_NULL 0
  55. /* Promotes a possibly negative, possibly signed char to an unsigned
  56. * integer for use as an array index. If the signed char is negative,
  57. * we want to instead treat it as an 8-bit unsigned char, hence the
  58. * double cast.
  59. */
  60. #define ACL_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  61. /* Enter a start condition. This macro really ought to take a parameter,
  62. * but we do it the disgusting crufty way forced on us by the ()-less
  63. * definition of BEGIN.
  64. */
  65. #define BEGIN acl_start = 1 + 2 *
  66. /* Translate the current start state into a value that can be later handed
  67. * to BEGIN to return to the state. The ACLSTATE alias is for lex
  68. * compatibility.
  69. */
  70. #define ACL_START ((acl_start - 1) / 2)
  71. #define ACLSTATE ACL_START
  72. /* Action number for EOF rule of a given start state. */
  73. #define ACL_STATE_EOF(state) (ACL_END_OF_BUFFER + state + 1)
  74. /* Special action meaning "start processing a new file". */
  75. #define ACL_NEW_FILE aclrestart( aclin )
  76. #define ACL_END_OF_BUFFER_CHAR 0
  77. /* Size of default input buffer. */
  78. #define ACL_BUF_SIZE 16384
  79. typedef struct acl_buffer_state *ACL_BUFFER_STATE;
  80. extern int aclleng;
  81. extern FILE *aclin, *aclout;
  82. #define EOB_ACT_CONTINUE_SCAN 0
  83. #define EOB_ACT_END_OF_FILE 1
  84. #define EOB_ACT_LAST_MATCH 2
  85. /* The funky do-while in the following #define is used to turn the definition
  86. * int a single C statement (which needs a semi-colon terminator). This
  87. * avoids problems with code like:
  88. *
  89. * if ( condition_holds )
  90. * aclless( 5 );
  91. * else
  92. * do_something_else();
  93. *
  94. * Prior to using the do-while the compiler would get upset at the
  95. * "else" because it interpreted the "if" statement as being all
  96. * done when it reached the ';' after the aclless() call.
  97. */
  98. /* Return all but the first 'n' matched characters back to the input stream. */
  99. #define aclless(n) \
  100. do \
  101. { \
  102. /* Undo effects of setting up acltext. */ \
  103. *acl_cp = acl_hold_char; \
  104. ACL_RESTORE_ACL_MORE_OFFSET \
  105. acl_c_buf_p = acl_cp = acl_bp + n - ACL_MORE_ADJ; \
  106. ACL_DO_BEFORE_ACTION; /* set up acltext again */ \
  107. } \
  108. while ( 0 )
  109. #define unput(c) aclunput( c, acltext_ptr )
  110. /* The following is because we cannot portably get our hands on size_t
  111. * (without autoconf's help, which isn't available because we want
  112. * flex-generated scanners to compile on their own).
  113. */
  114. typedef unsigned int acl_size_t;
  115. struct acl_buffer_state
  116. {
  117. FILE *acl_input_file;
  118. char *acl_ch_buf; /* input buffer */
  119. char *acl_buf_pos; /* current position in input buffer */
  120. /* Size of input buffer in bytes, not including room for EOB
  121. * characters.
  122. */
  123. acl_size_t acl_buf_size;
  124. /* Number of characters read into acl_ch_buf, not including EOB
  125. * characters.
  126. */
  127. int acl_n_chars;
  128. /* Whether we "own" the buffer - i.e., we know we created it,
  129. * and can PERM_REALLOC() it to grow it, and should PERM_FREE() it to
  130. * delete it.
  131. */
  132. int acl_is_our_buffer;
  133. /* Whether this is an "interactive" input source; if so, and
  134. * if we're using stdio for input, then we want to use getc()
  135. * instead of fread(), to make sure we stop fetching input after
  136. * each newline.
  137. */
  138. int acl_is_interactive;
  139. /* Whether we're considered to be at the beginning of a line.
  140. * If so, '^' rules will be active on the next match, otherwise
  141. * not.
  142. */
  143. int acl_at_bol;
  144. /* Whether to try to fill the input buffer when we reach the
  145. * end of it.
  146. */
  147. int acl_fill_buffer;
  148. int acl_buffer_status;
  149. #define ACL_BUFFER_NEW 0
  150. #define ACL_BUFFER_NORMAL 1
  151. /* When an EOF's been seen but there's still some text to process
  152. * then we mark the buffer as ACL_EOF_PENDING, to indicate that we
  153. * shouldn't try reading from the input source any more. We might
  154. * still have a bunch of tokens to match, though, because of
  155. * possible backing-up.
  156. *
  157. * When we actually see the EOF, we change the status to "new"
  158. * (via aclrestart()), so that the user can continue scanning by
  159. * just pointing aclin at a new input file.
  160. */
  161. #define ACL_BUFFER_EOF_PENDING 2
  162. };
  163. static ACL_BUFFER_STATE acl_current_buffer = 0;
  164. /* We provide macros for accessing buffer states in case in the
  165. * future we want to put the buffer states in a more general
  166. * "scanner state".
  167. */
  168. #define ACL_CURRENT_BUFFER acl_current_buffer
  169. /* acl_hold_char holds the character lost when acltext is formed. */
  170. static char acl_hold_char;
  171. static int acl_n_chars; /* number of characters read into acl_ch_buf */
  172. int aclleng;
  173. /* Points to current character in buffer. */
  174. static char *acl_c_buf_p = (char *) 0;
  175. static int acl_init = 1; /* whether we need to initialize */
  176. static int acl_start = 0; /* start state number */
  177. /* Flag which is used to allow aclwrap()'s to do buffer switches
  178. * instead of setting up a fresh aclin. A bit of a hack ...
  179. */
  180. static int acl_did_buffer_switch_on_eof;
  181. void aclrestart ACL_PROTO(( FILE *input_file ));
  182. void acl_switch_to_buffer ACL_PROTO(( ACL_BUFFER_STATE new_buffer ));
  183. void acl_load_buffer_state ACL_PROTO(( void ));
  184. ACL_BUFFER_STATE acl_create_buffer ACL_PROTO(( FILE *file, int size ));
  185. void acl_delete_buffer ACL_PROTO(( ACL_BUFFER_STATE b ));
  186. void acl_init_buffer ACL_PROTO(( ACL_BUFFER_STATE b, FILE *file ));
  187. void acl_flush_buffer ACL_PROTO(( ACL_BUFFER_STATE b ));
  188. #define ACL_FLUSH_BUFFER acl_flush_buffer( acl_current_buffer )
  189. ACL_BUFFER_STATE acl_scan_buffer ACL_PROTO(( char *base, acl_size_t size ));
  190. ACL_BUFFER_STATE acl_scan_string ACL_PROTO(( aclconst char *str ));
  191. ACL_BUFFER_STATE acl_scan_bytes ACL_PROTO(( aclconst char *bytes, int len ));
  192. static void *ACL_FLEX_ALLOC ACL_PROTO(( acl_size_t ));
  193. static void *ACL_FLEX_REALLOC ACL_PROTO(( void *, acl_size_t ));
  194. static void ACL_FLEX_FREE ACL_PROTO(( void * ));
  195. #define acl_new_buffer acl_create_buffer
  196. #define acl_set_interactive(is_interactive) \
  197. { \
  198. if ( ! acl_current_buffer ) \
  199. acl_current_buffer = acl_create_buffer( aclin, ACL_BUF_SIZE ); \
  200. acl_current_buffer->acl_is_interactive = is_interactive; \
  201. }
  202. #define acl_set_bol(at_bol) \
  203. { \
  204. if ( ! acl_current_buffer ) \
  205. acl_current_buffer = acl_create_buffer( aclin, ACL_BUF_SIZE ); \
  206. acl_current_buffer->acl_at_bol = at_bol; \
  207. }
  208. #define ACL_AT_BOL() (acl_current_buffer->acl_at_bol)
  209. typedef unsigned char ACL_CHAR;
  210. FILE *aclin = (FILE *) 0, *aclout = (FILE *) 0;
  211. typedef int acl_state_type;
  212. extern char *acltext;
  213. #define acltext_ptr acltext
  214. static acl_state_type acl_get_previous_state ACL_PROTO(( void ));
  215. static acl_state_type acl_try_NUL_trans ACL_PROTO(( acl_state_type current_state ));
  216. static int acl_get_next_buffer ACL_PROTO(( void ));
  217. static void acl_fatal_error ACL_PROTO(( aclconst char msg[] ));
  218. /* Done after the current pattern has been matched and before the
  219. * corresponding action - sets up acltext.
  220. */
  221. #define ACL_DO_BEFORE_ACTION \
  222. acltext_ptr = acl_bp; \
  223. aclleng = (int) (acl_cp - acl_bp); \
  224. acl_hold_char = *acl_cp; \
  225. *acl_cp = '\0'; \
  226. acl_c_buf_p = acl_cp;
  227. #define ACL_NUM_RULES 30
  228. #define ACL_END_OF_BUFFER 31
  229. static aclconst short int acl_accept[104] =
  230. { 0,
  231. 0, 0, 31, 30, 2, 1, 30, 30, 3, 28,
  232. 29, 25, 22, 24, 29, 29, 29, 29, 29, 29,
  233. 29, 29, 29, 2, 1, 27, 0, 4, 3, 29,
  234. 26, 23, 29, 29, 29, 29, 9, 29, 29, 29,
  235. 14, 29, 21, 29, 29, 29, 29, 6, 29, 29,
  236. 20, 29, 29, 29, 29, 29, 19, 29, 29, 29,
  237. 29, 29, 29, 29, 29, 29, 13, 29, 29, 29,
  238. 18, 29, 7, 29, 29, 29, 29, 29, 29, 29,
  239. 29, 8, 29, 29, 29, 29, 29, 29, 29, 29,
  240. 11, 12, 15, 29, 17, 5, 29, 16, 29, 29,
  241. 29, 10, 0
  242. } ;
  243. static aclconst int acl_ec[256] =
  244. { 0,
  245. 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  246. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  247. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  248. 1, 2, 4, 5, 6, 1, 1, 1, 1, 7,
  249. 7, 8, 1, 7, 8, 8, 1, 8, 8, 8,
  250. 8, 8, 8, 8, 8, 8, 8, 1, 7, 9,
  251. 10, 11, 1, 1, 12, 13, 14, 15, 16, 17,
  252. 8, 18, 19, 8, 8, 20, 21, 22, 23, 8,
  253. 8, 24, 25, 26, 27, 28, 29, 8, 30, 8,
  254. 1, 1, 1, 1, 8, 1, 12, 13, 14, 15,
  255. 16, 17, 8, 18, 19, 8, 8, 20, 21, 22,
  256. 23, 8, 8, 24, 25, 26, 27, 28, 29, 8,
  257. 30, 8, 7, 1, 7, 1, 1, 1, 1, 1,
  258. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  259. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  260. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  261. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  262. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  263. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  264. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  265. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  266. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  267. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  268. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  269. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  270. 1, 1, 1, 1, 1
  271. } ;
  272. static aclconst int acl_meta[31] =
  273. { 0,
  274. 1, 1, 2, 1, 1, 1, 1, 3, 1, 1,
  275. 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  276. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
  277. } ;
  278. static aclconst short int acl_base[108] =
  279. { 0,
  280. 0, 0, 118, 119, 115, 0, 106, 28, 0, 119,
  281. 0, 105, 119, 104, 21, 90, 96, 89, 87, 85,
  282. 92, 91, 87, 103, 0, 119, 33, 119, 0, 0,
  283. 119, 119, 79, 83, 17, 87, 0, 75, 78, 22,
  284. 81, 72, 0, 73, 72, 69, 71, 0, 70, 80,
  285. 0, 73, 64, 77, 58, 71, 0, 65, 60, 66,
  286. 63, 53, 51, 64, 63, 51, 0, 53, 57, 56,
  287. 0, 47, 0, 48, 50, 49, 50, 50, 46, 44,
  288. 40, 0, 39, 38, 37, 36, 49, 38, 43, 39,
  289. 0, 0, 0, 36, 0, 0, 36, 0, 33, 16,
  290. 24, 0, 119, 48, 51, 54, 29
  291. } ;
  292. static aclconst short int acl_def[108] =
  293. { 0,
  294. 103, 1, 103, 103, 103, 104, 103, 105, 106, 103,
  295. 107, 103, 103, 103, 107, 107, 107, 107, 107, 107,
  296. 107, 107, 107, 103, 104, 103, 105, 103, 106, 107,
  297. 103, 103, 107, 107, 107, 107, 107, 107, 107, 107,
  298. 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
  299. 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
  300. 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
  301. 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
  302. 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
  303. 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
  304. 107, 107, 0, 103, 103, 103, 103
  305. } ;
  306. static aclconst short int acl_nxt[150] =
  307. { 0,
  308. 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
  309. 14, 15, 11, 16, 17, 11, 11, 11, 18, 11,
  310. 11, 19, 20, 11, 11, 21, 11, 22, 23, 11,
  311. 28, 30, 28, 33, 34, 28, 49, 28, 54, 102,
  312. 35, 101, 36, 55, 100, 50, 37, 38, 25, 99,
  313. 25, 27, 27, 27, 29, 98, 29, 97, 96, 95,
  314. 94, 93, 92, 91, 90, 89, 88, 87, 86, 85,
  315. 84, 83, 82, 81, 80, 79, 78, 77, 76, 75,
  316. 74, 73, 72, 71, 70, 69, 68, 67, 66, 65,
  317. 64, 63, 62, 61, 60, 59, 58, 57, 56, 53,
  318. 52, 51, 48, 47, 24, 46, 45, 44, 43, 42,
  319. 41, 40, 39, 32, 31, 26, 24, 103, 3, 103,
  320. 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
  321. 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
  322. 103, 103, 103, 103, 103, 103, 103, 103, 103
  323. } ;
  324. static aclconst short int acl_chk[150] =
  325. { 0,
  326. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  327. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  328. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  329. 8, 107, 8, 15, 15, 27, 35, 27, 40, 101,
  330. 15, 100, 15, 40, 99, 35, 15, 15, 104, 97,
  331. 104, 105, 105, 105, 106, 94, 106, 90, 89, 88,
  332. 87, 86, 85, 84, 83, 81, 80, 79, 78, 77,
  333. 76, 75, 74, 72, 70, 69, 68, 66, 65, 64,
  334. 63, 62, 61, 60, 59, 58, 56, 55, 54, 53,
  335. 52, 50, 49, 47, 46, 45, 44, 42, 41, 39,
  336. 38, 36, 34, 33, 24, 23, 22, 21, 20, 19,
  337. 18, 17, 16, 14, 12, 7, 5, 3, 103, 103,
  338. 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
  339. 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
  340. 103, 103, 103, 103, 103, 103, 103, 103, 103
  341. } ;
  342. static acl_state_type acl_last_accepting_state;
  343. static char *acl_last_accepting_cpos;
  344. /* The intent behind this definition is that it'll catch
  345. * any uses of REJECT which flex missed.
  346. */
  347. #define REJECT reject_used_but_not_detected
  348. #define aclmore() aclmore_used_but_not_detected
  349. #define ACL_MORE_ADJ 0
  350. #define ACL_RESTORE_ACL_MORE_OFFSET
  351. char *acltext;
  352. #line 1 "aclscan.l"
  353. #define INITIAL 0
  354. /*
  355. * Lexical analyzer for ACL
  356. */
  357. #line 6 "aclscan.l"
  358. #include "acl.tab.h" /* token codes */
  359. #include <base/file.h>
  360. #include <libaccess/acl.h>
  361. #include <libaccess/nserror.h>
  362. #include "aclpriv.h"
  363. #include <string.h>
  364. #include <stdio.h>
  365. #include <ctype.h>
  366. #include <libaccess/aclerror.h>
  367. #include "plstr.h"
  368. #include "parse.h"
  369. #include "aclscan.h"
  370. static int acl_scanner_input(char *buffer, int max_size);
  371. #define ACL_NEVER_INTERACTIVE 1
  372. #undef ACL_INPUT
  373. #define ACL_INPUT(buf, result, max) (result = acl_scanner_input(buf, max))
  374. static int acl_lineno;
  375. static int acl_tokenpos;
  376. static char acl_filename[500];
  377. static NSErr_t *acl_errp;
  378. static int acl_use_buffer;
  379. static char *acl_buffer;
  380. static int acl_buffer_length;
  381. static int acl_buffer_offset;
  382. static char *last_string;
  383. static SYS_FILE acl_prfd;
  384. #line 466 "acl.yy.cpp"
  385. /* Macros after this point can all be overridden by user definitions in
  386. * section 1.
  387. */
  388. #ifndef ACL_SKIP_ACLWRAP
  389. #ifdef __cplusplus
  390. extern "C" int aclwrap ACL_PROTO(( void ));
  391. #else
  392. extern int aclwrap ACL_PROTO(( void ));
  393. #endif
  394. #endif
  395. #ifndef ACL_NO_UNPUT
  396. static void aclunput ACL_PROTO(( int c, char *buf_ptr ));
  397. #endif
  398. #ifndef acltext_ptr
  399. static void acl_flex_strncpy ACL_PROTO(( char *, aclconst char *, int ));
  400. #endif
  401. #ifdef ACL_NEED_STRLEN
  402. static int acl_flex_strlen ACL_PROTO(( aclconst char * ));
  403. #endif
  404. #ifndef ACL_NO_INPUT
  405. #ifdef __cplusplus
  406. static int aclinput ACL_PROTO(( void ));
  407. #else
  408. static int input ACL_PROTO(( void ));
  409. #endif
  410. #endif
  411. #if ACL_STACK_USED
  412. static int acl_start_stack_ptr = 0;
  413. static int acl_start_stack_depth = 0;
  414. static int *acl_start_stack = 0;
  415. #ifndef ACL_NO_PUSH_STATE
  416. static void acl_push_state ACL_PROTO(( int new_state ));
  417. #endif
  418. #ifndef ACL_NO_POP_STATE
  419. static void acl_pop_state ACL_PROTO(( void ));
  420. #endif
  421. #ifndef ACL_NO_TOP_STATE
  422. static int acl_top_state ACL_PROTO(( void ));
  423. #endif
  424. #else
  425. #define ACL_NO_PUSH_STATE 1
  426. #define ACL_NO_POP_STATE 1
  427. #define ACL_NO_TOP_STATE 1
  428. #endif
  429. #ifdef ACL_MALLOC_DECL
  430. ACL_MALLOC_DECL
  431. #else
  432. #if __STDC__
  433. #ifndef __cplusplus
  434. #include <stdlib.h>
  435. #endif
  436. #else
  437. /* Just try to get by without declaring the routines. This will fail
  438. * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
  439. * or sizeof(void*) != sizeof(int).
  440. */
  441. #endif
  442. #endif
  443. /* Amount of stuff to slurp up with each read. */
  444. #ifndef ACL_READ_BUF_SIZE
  445. #define ACL_READ_BUF_SIZE 8192
  446. #endif
  447. /* Copy whatever the last rule matched to the standard output. */
  448. #ifndef ECHO
  449. /* This used to be an fputs(), but since the string might contain NUL's,
  450. * we now use fwrite().
  451. */
  452. #define ECHO (void) fwrite( acltext, aclleng, 1, aclout )
  453. #endif
  454. /* Gets input and stuffs it into "buf". number of characters read, or ACL_NULL,
  455. * is returned in "result".
  456. */
  457. #ifndef ACL_INPUT
  458. #define ACL_INPUT(buf,result,max_size) \
  459. if ( acl_current_buffer->acl_is_interactive ) \
  460. { \
  461. int c = '*', n; \
  462. for ( n = 0; n < max_size && \
  463. (c = getc( aclin )) != EOF && c != '\n'; ++n ) \
  464. buf[n] = (char) c; \
  465. if ( c == '\n' ) \
  466. buf[n++] = (char) c; \
  467. if ( c == EOF && ferror( aclin ) ) \
  468. ACL_FATAL_ERROR( "input in flex scanner failed" ); \
  469. result = n; \
  470. } \
  471. else if ( ((result = fread( buf, 1, max_size, aclin )) == 0) \
  472. && ferror( aclin ) ) \
  473. ACL_FATAL_ERROR( "input in flex scanner failed" );
  474. #endif
  475. /* No semi-colon after return; correct usage is to write "aclterminate();" -
  476. * we don't want an extra ';' after the "return" because that will cause
  477. * some compilers to complain about unreachable statements.
  478. */
  479. #ifndef aclterminate
  480. #define aclterminate() return ACL_NULL
  481. #endif
  482. /* Number of entries by which start-condition stack grows. */
  483. #ifndef ACL_START_STACK_INCR
  484. #define ACL_START_STACK_INCR 25
  485. #endif
  486. /* Report a fatal error. */
  487. #ifndef ACL_FATAL_ERROR
  488. #define ACL_FATAL_ERROR(msg) acl_fatal_error( msg )
  489. #endif
  490. /* Default declaration of generated scanner - a define so the user can
  491. * easily add parameters.
  492. */
  493. #ifndef ACL_DECL
  494. #define ACL_DECL int acllex ACL_PROTO(( void ))
  495. #endif
  496. /* Code executed at the beginning of each rule, after acltext and aclleng
  497. * have been set up.
  498. */
  499. #ifndef ACL_USER_ACTION
  500. #define ACL_USER_ACTION
  501. #endif
  502. /* Code executed at the end of each rule. */
  503. #ifndef ACL_BREAK
  504. #define ACL_BREAK break;
  505. #endif
  506. #define ACL_RULE_SETUP \
  507. ACL_USER_ACTION
  508. ACL_DECL
  509. {
  510. register acl_state_type acl_current_state;
  511. register char *acl_cp, *acl_bp;
  512. register int acl_act;
  513. #line 47 "aclscan.l"
  514. #line 620 "acl.yy.cpp"
  515. if ( acl_init )
  516. {
  517. acl_init = 0;
  518. #ifdef ACL_USER_INIT
  519. ACL_USER_INIT;
  520. #endif
  521. if ( ! acl_start )
  522. acl_start = 1; /* first start state */
  523. if ( ! aclin )
  524. aclin = stdin;
  525. if ( ! aclout )
  526. aclout = stdout;
  527. if ( ! acl_current_buffer )
  528. acl_current_buffer =
  529. acl_create_buffer( aclin, ACL_BUF_SIZE );
  530. acl_load_buffer_state();
  531. }
  532. while ( 1 ) /* loops until end-of-file is reached */
  533. {
  534. acl_cp = acl_c_buf_p;
  535. /* Support of acltext. */
  536. *acl_cp = acl_hold_char;
  537. /* acl_bp points to the position in acl_ch_buf of the start of
  538. * the current run.
  539. */
  540. acl_bp = acl_cp;
  541. acl_current_state = acl_start;
  542. acl_match:
  543. do
  544. {
  545. register ACL_CHAR acl_c = acl_ec[ACL_SC_TO_UI(*acl_cp)];
  546. if ( acl_accept[acl_current_state] )
  547. {
  548. acl_last_accepting_state = acl_current_state;
  549. acl_last_accepting_cpos = acl_cp;
  550. }
  551. while ( acl_chk[acl_base[acl_current_state] + acl_c] != acl_current_state )
  552. {
  553. acl_current_state = (int) acl_def[acl_current_state];
  554. if ( acl_current_state >= 104 )
  555. acl_c = acl_meta[(unsigned int) acl_c];
  556. }
  557. acl_current_state = acl_nxt[acl_base[acl_current_state] + (unsigned int) acl_c];
  558. ++acl_cp;
  559. }
  560. while ( acl_base[acl_current_state] != 119 );
  561. acl_find_action:
  562. acl_act = acl_accept[acl_current_state];
  563. if ( acl_act == 0 )
  564. { /* have to back up */
  565. acl_cp = acl_last_accepting_cpos;
  566. acl_current_state = acl_last_accepting_state;
  567. acl_act = acl_accept[acl_current_state];
  568. }
  569. ACL_DO_BEFORE_ACTION;
  570. do_action: /* This label is used only to access EOF actions. */
  571. switch ( acl_act )
  572. { /* beginning of action switch */
  573. case 0: /* must back up */
  574. /* undo the effects of ACL_DO_BEFORE_ACTION */
  575. *acl_cp = acl_hold_char;
  576. acl_cp = acl_last_accepting_cpos;
  577. acl_current_state = acl_last_accepting_state;
  578. goto acl_find_action;
  579. case 1:
  580. ACL_RULE_SETUP
  581. #line 49 "aclscan.l"
  582. {
  583. acl_lineno++;
  584. acl_tokenpos = 0;
  585. aclless(1);
  586. }
  587. ACL_BREAK
  588. case 2:
  589. ACL_RULE_SETUP
  590. #line 55 "aclscan.l"
  591. ;
  592. ACL_BREAK
  593. case 3:
  594. ACL_RULE_SETUP
  595. #line 57 "aclscan.l"
  596. ;
  597. ACL_BREAK
  598. case ACL_STATE_EOF(INITIAL):
  599. #line 59 "aclscan.l"
  600. {
  601. acllval.string = NULL;
  602. last_string = acllval.string;
  603. return(0);
  604. }
  605. ACL_BREAK
  606. case 4:
  607. ACL_RULE_SETUP
  608. #line 65 "aclscan.l"
  609. {
  610. acllval.string = PERM_STRDUP( acltext+1 );
  611. last_string = acllval.string;
  612. if ( acllval.string[aclleng-2] != '"' )
  613. fprintf(stderr, "Unterminated string\n") ;
  614. else
  615. acllval.string[aclleng-2] = '\0';
  616. acl_tokenpos += aclleng;
  617. return ACL_QSTRING_TOK;
  618. }
  619. ACL_BREAK
  620. case 5:
  621. ACL_RULE_SETUP
  622. #line 77 "aclscan.l"
  623. {
  624. last_string = NULL;
  625. acl_tokenpos += aclleng;
  626. return ACL_ABSOLUTE_TOK;
  627. }
  628. ACL_BREAK
  629. case 6:
  630. ACL_RULE_SETUP
  631. #line 83 "aclscan.l"
  632. {
  633. last_string = NULL;
  634. acl_tokenpos += aclleng;
  635. return ACL_ACL_TOK;
  636. }
  637. ACL_BREAK
  638. case 7:
  639. ACL_RULE_SETUP
  640. #line 89 "aclscan.l"
  641. {
  642. last_string = NULL;
  643. acl_tokenpos += aclleng;
  644. return ACL_ALLOW_TOK;
  645. }
  646. ACL_BREAK
  647. case 8:
  648. ACL_RULE_SETUP
  649. #line 95 "aclscan.l"
  650. {
  651. last_string = NULL;
  652. acl_tokenpos += aclleng;
  653. return ACL_ALWAYS_TOK;
  654. }
  655. ACL_BREAK
  656. case 9:
  657. ACL_RULE_SETUP
  658. #line 101 "aclscan.l"
  659. {
  660. last_string = NULL;
  661. acl_tokenpos += aclleng;
  662. return ACL_AT_TOK;
  663. }
  664. ACL_BREAK
  665. case 10:
  666. ACL_RULE_SETUP
  667. #line 107 "aclscan.l"
  668. {
  669. last_string = NULL;
  670. acl_tokenpos += aclleng;
  671. return ACL_AUTHENTICATE_TOK;
  672. }
  673. ACL_BREAK
  674. case 11:
  675. ACL_RULE_SETUP
  676. #line 113 "aclscan.l"
  677. {
  678. last_string = NULL;
  679. acl_tokenpos += aclleng;
  680. return ACL_CONTENT_TOK;
  681. }
  682. ACL_BREAK
  683. case 12:
  684. ACL_RULE_SETUP
  685. #line 119 "aclscan.l"
  686. {
  687. last_string = NULL;
  688. acl_tokenpos += aclleng;
  689. return ACL_DEFAULT_TOK;
  690. }
  691. ACL_BREAK
  692. case 13:
  693. ACL_RULE_SETUP
  694. #line 125 "aclscan.l"
  695. {
  696. last_string = NULL;
  697. acl_tokenpos += aclleng;
  698. return ACL_DENY_TOK;
  699. }
  700. ACL_BREAK
  701. case 14:
  702. ACL_RULE_SETUP
  703. #line 131 "aclscan.l"
  704. {
  705. last_string = NULL;
  706. acl_tokenpos += aclleng;
  707. return ACL_IN_TOK;
  708. }
  709. ACL_BREAK
  710. case 15:
  711. ACL_RULE_SETUP
  712. #line 137 "aclscan.l"
  713. {
  714. last_string = NULL;
  715. acl_tokenpos += aclleng;
  716. return ACL_INHERIT_TOK;
  717. }
  718. ACL_BREAK
  719. case 16:
  720. ACL_RULE_SETUP
  721. #line 143 "aclscan.l"
  722. {
  723. last_string = NULL;
  724. acl_tokenpos += aclleng;
  725. return ACL_TERMINAL_TOK;
  726. }
  727. ACL_BREAK
  728. case 17:
  729. ACL_RULE_SETUP
  730. #line 149 "aclscan.l"
  731. {
  732. last_string = NULL;
  733. acl_tokenpos += aclleng;
  734. return ACL_VERSION_TOK;
  735. }
  736. ACL_BREAK
  737. case 18:
  738. ACL_RULE_SETUP
  739. #line 155 "aclscan.l"
  740. {
  741. last_string = NULL;
  742. acl_tokenpos += aclleng;
  743. return ACL_WITH_TOK;
  744. }
  745. ACL_BREAK
  746. case 19:
  747. ACL_RULE_SETUP
  748. #line 161 "aclscan.l"
  749. {
  750. last_string = NULL;
  751. acl_tokenpos += aclleng;
  752. return ACL_NOT_TOK;
  753. }
  754. ACL_BREAK
  755. case 20:
  756. ACL_RULE_SETUP
  757. #line 167 "aclscan.l"
  758. {
  759. last_string = NULL;
  760. acllval.ival = ACL_EXPR_OP_AND;
  761. acl_tokenpos += aclleng;
  762. return ACL_AND_TOK;
  763. }
  764. ACL_BREAK
  765. case 21:
  766. ACL_RULE_SETUP
  767. #line 174 "aclscan.l"
  768. {
  769. last_string = NULL;
  770. acllval.ival = ACL_EXPR_OP_OR;
  771. acl_tokenpos += aclleng;
  772. return ACL_OR_TOK;
  773. }
  774. ACL_BREAK
  775. case 22:
  776. ACL_RULE_SETUP
  777. #line 181 "aclscan.l"
  778. {
  779. last_string = NULL;
  780. acllval.ival = CMP_OP_EQ;
  781. acl_tokenpos += aclleng;
  782. return ACL_EQ_TOK;
  783. }
  784. ACL_BREAK
  785. case 23:
  786. ACL_RULE_SETUP
  787. #line 188 "aclscan.l"
  788. {
  789. last_string = NULL;
  790. acllval.ival = CMP_OP_GE;
  791. acl_tokenpos += aclleng;
  792. return ACL_GE_TOK;
  793. }
  794. ACL_BREAK
  795. case 24:
  796. ACL_RULE_SETUP
  797. #line 195 "aclscan.l"
  798. {
  799. last_string = NULL;
  800. acllval.ival = CMP_OP_GT;
  801. acl_tokenpos += aclleng;
  802. return ACL_GT_TOK;
  803. }
  804. ACL_BREAK
  805. case 25:
  806. ACL_RULE_SETUP
  807. #line 202 "aclscan.l"
  808. {
  809. last_string = NULL;
  810. acllval.ival = CMP_OP_LT;
  811. acl_tokenpos += aclleng;
  812. return ACL_LT_TOK;
  813. }
  814. ACL_BREAK
  815. case 26:
  816. ACL_RULE_SETUP
  817. #line 209 "aclscan.l"
  818. {
  819. last_string = NULL;
  820. acllval.ival = CMP_OP_LE;
  821. acl_tokenpos += aclleng;
  822. return ACL_LE_TOK;
  823. }
  824. ACL_BREAK
  825. case 27:
  826. ACL_RULE_SETUP
  827. #line 216 "aclscan.l"
  828. {
  829. last_string = NULL;
  830. acllval.ival = CMP_OP_NE;
  831. acl_tokenpos += aclleng;
  832. return ACL_NE_TOK;
  833. }
  834. ACL_BREAK
  835. case 28:
  836. ACL_RULE_SETUP
  837. #line 223 "aclscan.l"
  838. {
  839. last_string = NULL;
  840. acl_tokenpos += aclleng;
  841. return acltext[0];
  842. }
  843. ACL_BREAK
  844. case 29:
  845. ACL_RULE_SETUP
  846. #line 229 "aclscan.l"
  847. {
  848. acl_tokenpos += aclleng;
  849. acllval.string = PERM_STRDUP( acltext );
  850. last_string = acllval.string;
  851. return ACL_VARIABLE_TOK;
  852. }
  853. ACL_BREAK
  854. case 30:
  855. ACL_RULE_SETUP
  856. #line 235 "aclscan.l"
  857. ECHO;
  858. ACL_BREAK
  859. #line 983 "acl.yy.cpp"
  860. case ACL_END_OF_BUFFER:
  861. {
  862. /* Amount of text matched not including the EOB char. */
  863. int acl_amount_of_matched_text = (int) (acl_cp - acltext_ptr) - 1;
  864. /* Undo the effects of ACL_DO_BEFORE_ACTION. */
  865. *acl_cp = acl_hold_char;
  866. ACL_RESTORE_ACL_MORE_OFFSET
  867. if ( acl_current_buffer->acl_buffer_status == ACL_BUFFER_NEW )
  868. {
  869. /* We're scanning a new file or input source. It's
  870. * possible that this happened because the user
  871. * just pointed aclin at a new source and called
  872. * acllex(). If so, then we have to assure
  873. * consistency between acl_current_buffer and our
  874. * globals. Here is the right place to do so, because
  875. * this is the first action (other than possibly a
  876. * back-up) that will match for the new input source.
  877. */
  878. acl_n_chars = acl_current_buffer->acl_n_chars;
  879. acl_current_buffer->acl_input_file = aclin;
  880. acl_current_buffer->acl_buffer_status = ACL_BUFFER_NORMAL;
  881. }
  882. /* Note that here we test for acl_c_buf_p "<=" to the position
  883. * of the first EOB in the buffer, since acl_c_buf_p will
  884. * already have been incremented past the NUL character
  885. * (since all states make transitions on EOB to the
  886. * end-of-buffer state). Contrast this with the test
  887. * in input().
  888. */
  889. if ( acl_c_buf_p <= &acl_current_buffer->acl_ch_buf[acl_n_chars] )
  890. { /* This was really a NUL. */
  891. acl_state_type acl_next_state;
  892. acl_c_buf_p = acltext_ptr + acl_amount_of_matched_text;
  893. acl_current_state = acl_get_previous_state();
  894. /* Okay, we're now positioned to make the NUL
  895. * transition. We couldn't have
  896. * acl_get_previous_state() go ahead and do it
  897. * for us because it doesn't know how to deal
  898. * with the possibility of jamming (and we don't
  899. * want to build jamming into it because then it
  900. * will run more slowly).
  901. */
  902. acl_next_state = acl_try_NUL_trans( acl_current_state );
  903. acl_bp = acltext_ptr + ACL_MORE_ADJ;
  904. if ( acl_next_state )
  905. {
  906. /* Consume the NUL. */
  907. acl_cp = ++acl_c_buf_p;
  908. acl_current_state = acl_next_state;
  909. goto acl_match;
  910. }
  911. else
  912. {
  913. acl_cp = acl_c_buf_p;
  914. goto acl_find_action;
  915. }
  916. }
  917. else switch ( acl_get_next_buffer() )
  918. {
  919. case EOB_ACT_END_OF_FILE:
  920. {
  921. acl_did_buffer_switch_on_eof = 0;
  922. if ( aclwrap() )
  923. {
  924. /* Note: because we've taken care in
  925. * acl_get_next_buffer() to have set up
  926. * acltext, we can now set up
  927. * acl_c_buf_p so that if some total
  928. * hoser (like flex itself) wants to
  929. * call the scanner after we return the
  930. * ACL_NULL, it'll still work - another
  931. * ACL_NULL will get returned.
  932. */
  933. acl_c_buf_p = acltext_ptr + ACL_MORE_ADJ;
  934. acl_act = ACL_STATE_EOF(ACL_START);
  935. goto do_action;
  936. }
  937. else
  938. {
  939. if ( ! acl_did_buffer_switch_on_eof )
  940. ACL_NEW_FILE;
  941. }
  942. break;
  943. }
  944. case EOB_ACT_CONTINUE_SCAN:
  945. acl_c_buf_p =
  946. acltext_ptr + acl_amount_of_matched_text;
  947. acl_current_state = acl_get_previous_state();
  948. acl_cp = acl_c_buf_p;
  949. acl_bp = acltext_ptr + ACL_MORE_ADJ;
  950. goto acl_match;
  951. case EOB_ACT_LAST_MATCH:
  952. acl_c_buf_p =
  953. &acl_current_buffer->acl_ch_buf[acl_n_chars];
  954. acl_current_state = acl_get_previous_state();
  955. acl_cp = acl_c_buf_p;
  956. acl_bp = acltext_ptr + ACL_MORE_ADJ;
  957. goto acl_find_action;
  958. }
  959. break;
  960. }
  961. default:
  962. ACL_FATAL_ERROR(
  963. "fatal flex scanner internal error--no action found" );
  964. } /* end of action switch */
  965. } /* end of scanning one token */
  966. } /* end of acllex */
  967. /* acl_get_next_buffer - try to read in a new buffer
  968. *
  969. * Returns a code representing an action:
  970. * EOB_ACT_LAST_MATCH -
  971. * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  972. * EOB_ACT_END_OF_FILE - end of file
  973. */
  974. static int acl_get_next_buffer()
  975. {
  976. register char *dest = acl_current_buffer->acl_ch_buf;
  977. register char *source = acltext_ptr;
  978. register int number_to_move, i;
  979. int ret_val;
  980. if ( acl_c_buf_p > &acl_current_buffer->acl_ch_buf[acl_n_chars + 1] )
  981. ACL_FATAL_ERROR(
  982. "fatal flex scanner internal error--end of buffer missed" );
  983. if ( acl_current_buffer->acl_fill_buffer == 0 )
  984. { /* Don't try to fill the buffer, so this is an EOF. */
  985. if ( acl_c_buf_p - acltext_ptr - ACL_MORE_ADJ == 1 )
  986. {
  987. /* We matched a single character, the EOB, so
  988. * treat this as a final EOF.
  989. */
  990. return EOB_ACT_END_OF_FILE;
  991. }
  992. else
  993. {
  994. /* We matched some text prior to the EOB, first
  995. * process it.
  996. */
  997. return EOB_ACT_LAST_MATCH;
  998. }
  999. }
  1000. /* Try to read more data. */
  1001. /* First move last chars to start of buffer. */
  1002. number_to_move = (int) (acl_c_buf_p - acltext_ptr) - 1;
  1003. for ( i = 0; i < number_to_move; ++i )
  1004. *(dest++) = *(source++);
  1005. if ( acl_current_buffer->acl_buffer_status == ACL_BUFFER_EOF_PENDING )
  1006. /* don't do the read, it's not guaranteed to return an EOF,
  1007. * just force an EOF
  1008. */
  1009. acl_n_chars = 0;
  1010. else
  1011. {
  1012. int num_to_read =
  1013. acl_current_buffer->acl_buf_size - number_to_move - 1;
  1014. while ( num_to_read <= 0 )
  1015. { /* Not enough room in the buffer - grow it. */
  1016. #ifdef ACL_USES_REJECT
  1017. ACL_FATAL_ERROR(
  1018. "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
  1019. #else
  1020. /* just a shorter name for the current buffer */
  1021. ACL_BUFFER_STATE b = acl_current_buffer;
  1022. int acl_c_buf_p_offset =
  1023. (int) (acl_c_buf_p - b->acl_ch_buf);
  1024. if ( b->acl_is_our_buffer )
  1025. {
  1026. int new_size = b->acl_buf_size * 2;
  1027. if ( new_size <= 0 )
  1028. b->acl_buf_size += b->acl_buf_size / 8;
  1029. else
  1030. b->acl_buf_size *= 2;
  1031. b->acl_ch_buf = (char *)
  1032. /* Include room in for 2 EOB chars. */
  1033. ACL_FLEX_REALLOC( (void *) b->acl_ch_buf,
  1034. b->acl_buf_size + 2 );
  1035. }
  1036. else
  1037. /* Can't grow it, we don't own it. */
  1038. b->acl_ch_buf = 0;
  1039. if ( ! b->acl_ch_buf )
  1040. ACL_FATAL_ERROR(
  1041. "fatal error - scanner input buffer overflow" );
  1042. acl_c_buf_p = &b->acl_ch_buf[acl_c_buf_p_offset];
  1043. num_to_read = acl_current_buffer->acl_buf_size -
  1044. number_to_move - 1;
  1045. #endif
  1046. }
  1047. if ( num_to_read > ACL_READ_BUF_SIZE )
  1048. num_to_read = ACL_READ_BUF_SIZE;
  1049. /* Read in more data. */
  1050. ACL_INPUT( (&acl_current_buffer->acl_ch_buf[number_to_move]),
  1051. acl_n_chars, num_to_read );
  1052. }
  1053. if ( acl_n_chars == 0 )
  1054. {
  1055. if ( number_to_move == ACL_MORE_ADJ )
  1056. {
  1057. ret_val = EOB_ACT_END_OF_FILE;
  1058. aclrestart( aclin );
  1059. }
  1060. else
  1061. {
  1062. ret_val = EOB_ACT_LAST_MATCH;
  1063. acl_current_buffer->acl_buffer_status =
  1064. ACL_BUFFER_EOF_PENDING;
  1065. }
  1066. }
  1067. else
  1068. ret_val = EOB_ACT_CONTINUE_SCAN;
  1069. acl_n_chars += number_to_move;
  1070. acl_current_buffer->acl_ch_buf[acl_n_chars] = ACL_END_OF_BUFFER_CHAR;
  1071. acl_current_buffer->acl_ch_buf[acl_n_chars + 1] = ACL_END_OF_BUFFER_CHAR;
  1072. acltext_ptr = &acl_current_buffer->acl_ch_buf[0];
  1073. return ret_val;
  1074. }
  1075. /* acl_get_previous_state - get the state just before the EOB char was reached */
  1076. static acl_state_type acl_get_previous_state()
  1077. {
  1078. register acl_state_type acl_current_state;
  1079. register char *acl_cp;
  1080. acl_current_state = acl_start;
  1081. for ( acl_cp = acltext_ptr + ACL_MORE_ADJ; acl_cp < acl_c_buf_p; ++acl_cp )
  1082. {
  1083. register ACL_CHAR acl_c = (*acl_cp ? acl_ec[ACL_SC_TO_UI(*acl_cp)] : 1);
  1084. if ( acl_accept[acl_current_state] )
  1085. {
  1086. acl_last_accepting_state = acl_current_state;
  1087. acl_last_accepting_cpos = acl_cp;
  1088. }
  1089. while ( acl_chk[acl_base[acl_current_state] + acl_c] != acl_current_state )
  1090. {
  1091. acl_current_state = (int) acl_def[acl_current_state];
  1092. if ( acl_current_state >= 104 )
  1093. acl_c = acl_meta[(unsigned int) acl_c];
  1094. }
  1095. acl_current_state = acl_nxt[acl_base[acl_current_state] + (unsigned int) acl_c];
  1096. }
  1097. return acl_current_state;
  1098. }
  1099. /* acl_try_NUL_trans - try to make a transition on the NUL character
  1100. *
  1101. * synopsis
  1102. * next_state = acl_try_NUL_trans( current_state );
  1103. */
  1104. #ifdef ACL_USE_PROTOS
  1105. static acl_state_type acl_try_NUL_trans( acl_state_type acl_current_state )
  1106. #else
  1107. static acl_state_type acl_try_NUL_trans( acl_current_state )
  1108. acl_state_type acl_current_state;
  1109. #endif
  1110. {
  1111. register int acl_is_jam;
  1112. register char *acl_cp = acl_c_buf_p;
  1113. register ACL_CHAR acl_c = 1;
  1114. if ( acl_accept[acl_current_state] )
  1115. {
  1116. acl_last_accepting_state = acl_current_state;
  1117. acl_last_accepting_cpos = acl_cp;
  1118. }
  1119. while ( acl_chk[acl_base[acl_current_state] + acl_c] != acl_current_state )
  1120. {
  1121. acl_current_state = (int) acl_def[acl_current_state];
  1122. if ( acl_current_state >= 104 )
  1123. acl_c = acl_meta[(unsigned int) acl_c];
  1124. }
  1125. acl_current_state = acl_nxt[acl_base[acl_current_state] + (unsigned int) acl_c];
  1126. acl_is_jam = (acl_current_state == 103);
  1127. return acl_is_jam ? 0 : acl_current_state;
  1128. }
  1129. #ifndef ACL_NO_UNPUT
  1130. #ifdef ACL_USE_PROTOS
  1131. static void aclunput( int c, register char *acl_bp )
  1132. #else
  1133. static void aclunput( c, acl_bp )
  1134. int c;
  1135. register char *acl_bp;
  1136. #endif
  1137. {
  1138. register char *acl_cp = acl_c_buf_p;
  1139. /* undo effects of setting up acltext */
  1140. *acl_cp = acl_hold_char;
  1141. if ( acl_cp < acl_current_buffer->acl_ch_buf + 2 )
  1142. { /* need to shift things up to make room */
  1143. /* +2 for EOB chars. */
  1144. register int number_to_move = acl_n_chars + 2;
  1145. register char *dest = &acl_current_buffer->acl_ch_buf[
  1146. acl_current_buffer->acl_buf_size + 2];
  1147. register char *source =
  1148. &acl_current_buffer->acl_ch_buf[number_to_move];
  1149. while ( source > acl_current_buffer->acl_ch_buf )
  1150. *--dest = *--source;
  1151. acl_cp += (int) (dest - source);
  1152. acl_bp += (int) (dest - source);
  1153. acl_n_chars = acl_current_buffer->acl_buf_size;
  1154. if ( acl_cp < acl_current_buffer->acl_ch_buf + 2 )
  1155. ACL_FATAL_ERROR( "flex scanner push-back overflow" );
  1156. }
  1157. *--acl_cp = (char) c;
  1158. acltext_ptr = acl_bp;
  1159. acl_hold_char = *acl_cp;
  1160. acl_c_buf_p = acl_cp;
  1161. }
  1162. #endif /* ifndef ACL_NO_UNPUT */
  1163. #ifdef __cplusplus
  1164. static int aclinput()
  1165. #else
  1166. static int input()
  1167. #endif
  1168. {
  1169. int c;
  1170. *acl_c_buf_p = acl_hold_char;
  1171. if ( *acl_c_buf_p == ACL_END_OF_BUFFER_CHAR )
  1172. {
  1173. /* acl_c_buf_p now points to the character we want to return.
  1174. * If this occurs *before* the EOB characters, then it's a
  1175. * valid NUL; if not, then we've hit the end of the buffer.
  1176. */
  1177. if ( acl_c_buf_p < &acl_current_buffer->acl_ch_buf[acl_n_chars] )
  1178. /* This was really a NUL. */
  1179. *acl_c_buf_p = '\0';
  1180. else
  1181. { /* need more input */
  1182. int offset = acl_c_buf_p - acltext_ptr;
  1183. ++acl_c_buf_p;
  1184. switch ( acl_get_next_buffer() )
  1185. {
  1186. case EOB_ACT_END_OF_FILE:
  1187. {
  1188. if ( aclwrap() )
  1189. {
  1190. acl_c_buf_p = acltext_ptr + offset;
  1191. return EOF;
  1192. }
  1193. if ( ! acl_did_buffer_switch_on_eof )
  1194. ACL_NEW_FILE;
  1195. #ifdef __cplusplus
  1196. return aclinput();
  1197. #else
  1198. return input();
  1199. #endif
  1200. }
  1201. case EOB_ACT_CONTINUE_SCAN:
  1202. acl_c_buf_p = acltext_ptr + offset;
  1203. break;
  1204. case EOB_ACT_LAST_MATCH:
  1205. #ifdef __cplusplus
  1206. ACL_FATAL_ERROR(
  1207. "unexpected last match in aclinput()" );
  1208. #else
  1209. ACL_FATAL_ERROR(
  1210. "unexpected last match in input()" );
  1211. #endif
  1212. }
  1213. }
  1214. }
  1215. c = *(unsigned char *) acl_c_buf_p; /* cast for 8-bit char's */
  1216. *acl_c_buf_p = '\0'; /* preserve acltext */
  1217. acl_hold_char = *++acl_c_buf_p;
  1218. return c;
  1219. }
  1220. #ifdef ACL_USE_PROTOS
  1221. void aclrestart( FILE *input_file )
  1222. #else
  1223. void aclrestart( input_file )
  1224. FILE *input_file;
  1225. #endif
  1226. {
  1227. if ( ! acl_current_buffer )
  1228. acl_current_buffer = acl_create_buffer( aclin, ACL_BUF_SIZE );
  1229. acl_init_buffer( acl_current_buffer, input_file );
  1230. acl_load_buffer_state();
  1231. }
  1232. #ifdef ACL_USE_PROTOS
  1233. void acl_switch_to_buffer( ACL_BUFFER_STATE new_buffer )
  1234. #else
  1235. void acl_switch_to_buffer( new_buffer )
  1236. ACL_BUFFER_STATE new_buffer;
  1237. #endif
  1238. {
  1239. if ( acl_current_buffer == new_buffer )
  1240. return;
  1241. if ( acl_current_buffer )
  1242. {
  1243. /* Flush out information for old buffer. */
  1244. *acl_c_buf_p = acl_hold_char;
  1245. acl_current_buffer->acl_buf_pos = acl_c_buf_p;
  1246. acl_current_buffer->acl_n_chars = acl_n_chars;
  1247. }
  1248. acl_current_buffer = new_buffer;
  1249. acl_load_buffer_state();
  1250. /* We don't actually know whether we did this switch during
  1251. * EOF (aclwrap()) processing, but the only time this flag
  1252. * is looked at is after aclwrap() is called, so it's safe
  1253. * to go ahead and always set it.
  1254. */
  1255. acl_did_buffer_switch_on_eof = 1;
  1256. }
  1257. #ifdef ACL_USE_PROTOS
  1258. void acl_load_buffer_state( void )
  1259. #else
  1260. void acl_load_buffer_state()
  1261. #endif
  1262. {
  1263. acl_n_chars = acl_current_buffer->acl_n_chars;
  1264. acltext_ptr = acl_c_buf_p = acl_current_buffer->acl_buf_pos;
  1265. aclin = acl_current_buffer->acl_input_file;
  1266. acl_hold_char = *acl_c_buf_p;
  1267. }
  1268. #ifdef ACL_USE_PROTOS
  1269. ACL_BUFFER_STATE acl_create_buffer( FILE *file, int size )
  1270. #else
  1271. ACL_BUFFER_STATE acl_create_buffer( file, size )
  1272. FILE *file;
  1273. int size;
  1274. #endif
  1275. {
  1276. ACL_BUFFER_STATE b;
  1277. b = (ACL_BUFFER_STATE) ACL_FLEX_ALLOC( sizeof( struct acl_buffer_state ) );
  1278. if ( ! b )
  1279. ACL_FATAL_ERROR( "out of dynamic memory in acl_create_buffer()" );
  1280. b->acl_buf_size = size;
  1281. /* acl_ch_buf has to be 2 characters longer than the size given because
  1282. * we need to put in 2 end-of-buffer characters.
  1283. */
  1284. b->acl_ch_buf = (char *) ACL_FLEX_ALLOC( b->acl_buf_size + 2 );
  1285. if ( ! b->acl_ch_buf )
  1286. ACL_FATAL_ERROR( "out of dynamic memory in acl_create_buffer()" );
  1287. b->acl_is_our_buffer = 1;
  1288. acl_init_buffer( b, file );
  1289. return b;
  1290. }
  1291. #ifdef ACL_USE_PROTOS
  1292. void acl_delete_buffer( ACL_BUFFER_STATE b )
  1293. #else
  1294. void acl_delete_buffer( b )
  1295. ACL_BUFFER_STATE b;
  1296. #endif
  1297. {
  1298. if ( ! b )
  1299. return;
  1300. if ( b == acl_current_buffer )
  1301. acl_current_buffer = (ACL_BUFFER_STATE) 0;
  1302. if ( b->acl_is_our_buffer )
  1303. ACL_FLEX_FREE( (void *) b->acl_ch_buf );
  1304. ACL_FLEX_FREE( (void *) b );
  1305. }
  1306. void
  1307. acl_free_buffer(void)
  1308. {
  1309. acl_delete_buffer(acl_current_buffer);
  1310. }
  1311. #ifndef ACL_ALWAYS_INTERACTIVE
  1312. #ifndef ACL_NEVER_INTERACTIVE
  1313. extern int isatty ACL_PROTO(( int ));
  1314. #endif
  1315. #endif
  1316. #ifdef ACL_USE_PROTOS
  1317. void acl_init_buffer( ACL_BUFFER_STATE b, FILE *file )
  1318. #else
  1319. void acl_init_buffer( b, file )
  1320. ACL_BUFFER_STATE b;
  1321. FILE *file;
  1322. #endif
  1323. {
  1324. acl_flush_buffer( b );
  1325. b->acl_input_file = file;
  1326. b->acl_fill_buffer = 1;
  1327. #if ACL_ALWAYS_INTERACTIVE
  1328. b->acl_is_interactive = 1;
  1329. #else
  1330. #if ACL_NEVER_INTERACTIVE
  1331. b->acl_is_interactive = 0;
  1332. #else
  1333. b->acl_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
  1334. #endif
  1335. #endif
  1336. }
  1337. #ifdef ACL_USE_PROTOS
  1338. void acl_flush_buffer( ACL_BUFFER_STATE b )
  1339. #else
  1340. void acl_flush_buffer( b )
  1341. ACL_BUFFER_STATE b;
  1342. #endif
  1343. {
  1344. b->acl_n_chars = 0;
  1345. /* We always need two end-of-buffer characters. The first causes
  1346. * a transition to the end-of-buffer state. The second causes
  1347. * a jam in that state.
  1348. */
  1349. b->acl_ch_buf[0] = ACL_END_OF_BUFFER_CHAR;
  1350. b->acl_ch_buf[1] = ACL_END_OF_BUFFER_CHAR;
  1351. b->acl_buf_pos = &b->acl_ch_buf[0];
  1352. b->acl_at_bol = 1;
  1353. b->acl_buffer_status = ACL_BUFFER_NEW;
  1354. if ( b == acl_current_buffer )
  1355. acl_load_buffer_state();
  1356. }
  1357. #ifndef ACL_NO_SCAN_BUFFER
  1358. #ifdef ACL_USE_PROTOS
  1359. ACL_BUFFER_STATE acl_scan_buffer( char *base, acl_size_t size )
  1360. #else
  1361. ACL_BUFFER_STATE acl_scan_buffer( base, size )
  1362. char *base;
  1363. acl_size_t size;
  1364. #endif
  1365. {
  1366. ACL_BUFFER_STATE b;
  1367. if ( size < 2 ||
  1368. base[size-2] != ACL_END_OF_BUFFER_CHAR ||
  1369. base[size-1] != ACL_END_OF_BUFFER_CHAR )
  1370. /* They forgot to leave room for the EOB's. */
  1371. return 0;
  1372. b = (ACL_BUFFER_STATE) ACL_FLEX_ALLOC( sizeof( struct acl_buffer_state ) );
  1373. if ( ! b )
  1374. ACL_FATAL_ERROR( "out of dynamic memory in acl_scan_buffer()" );
  1375. b->acl_buf_size = size - 2; /* "- 2" to take care of EOB's */
  1376. b->acl_buf_pos = b->acl_ch_buf = base;
  1377. b->acl_is_our_buffer = 0;
  1378. b->acl_input_file = 0;
  1379. b->acl_n_chars = b->acl_buf_size;
  1380. b->acl_is_interactive = 0;
  1381. b->acl_at_bol = 1;
  1382. b->acl_fill_buffer = 0;
  1383. b->acl_buffer_status = ACL_BUFFER_NEW;
  1384. acl_switch_to_buffer( b );
  1385. return b;
  1386. }
  1387. #endif
  1388. #ifndef ACL_NO_SCAN_STRING
  1389. #ifdef ACL_USE_PROTOS
  1390. ACL_BUFFER_STATE acl_scan_string( aclconst char *str )
  1391. #else
  1392. ACL_BUFFER_STATE acl_scan_string( str )
  1393. aclconst char *str;
  1394. #endif
  1395. {
  1396. int len;
  1397. for ( len = 0; str[len]; ++len )
  1398. ;
  1399. return acl_scan_bytes( str, len );
  1400. }
  1401. #endif
  1402. #ifndef ACL_NO_SCAN_BYTES
  1403. #ifdef ACL_USE_PROTOS
  1404. ACL_BUFFER_STATE acl_scan_bytes( aclconst char *bytes, int len )
  1405. #else
  1406. ACL_BUFFER_STATE acl_scan_bytes( bytes, len )
  1407. aclconst char *bytes;
  1408. int len;
  1409. #endif
  1410. {
  1411. ACL_BUFFER_STATE b;
  1412. char *buf;
  1413. acl_size_t n;
  1414. int i;
  1415. /* Get memory for full buffer, including space for trailing EOB's. */
  1416. n = len + 2;
  1417. buf = (char *) ACL_FLEX_ALLOC( n );
  1418. if ( ! buf )
  1419. ACL_FATAL_ERROR( "out of dynamic memory in acl_scan_bytes()" );
  1420. for ( i = 0; i < len; ++i )
  1421. buf[i] = bytes[i];
  1422. buf[len] = buf[len+1] = ACL_END_OF_BUFFER_CHAR;
  1423. b = acl_scan_buffer( buf, n );
  1424. if ( ! b )
  1425. ACL_FATAL_ERROR( "bad buffer in acl_scan_bytes()" );
  1426. /* It's okay to grow etc. this buffer, and we should throw it
  1427. * away when we're done.
  1428. */
  1429. b->acl_is_our_buffer = 1;
  1430. return b;
  1431. }
  1432. #endif
  1433. #ifndef ACL_NO_PUSH_STATE
  1434. #ifdef ACL_USE_PROTOS
  1435. static void acl_push_state( int new_state )
  1436. #else
  1437. static void acl_push_state( new_state )
  1438. int new_state;
  1439. #endif
  1440. {
  1441. if ( acl_start_stack_ptr >= acl_start_stack_depth )
  1442. {
  1443. acl_size_t new_size;
  1444. acl_start_stack_depth += ACL_START_STACK_INCR;
  1445. new_size = acl_start_stack_depth * sizeof( int );
  1446. if ( ! acl_start_stack )
  1447. acl_start_stack = (int *) ACL_FLEX_ALLOC( new_size );
  1448. else
  1449. acl_start_stack = (int *) ACL_FLEX_REALLOC(
  1450. (void *) acl_start_stack, new_size );
  1451. if ( ! acl_start_stack )
  1452. ACL_FATAL_ERROR(
  1453. "out of memory expanding start-condition stack" );
  1454. }
  1455. acl_start_stack[acl_start_stack_ptr++] = ACL_START;
  1456. BEGIN(new_state);
  1457. }
  1458. #endif
  1459. #ifndef ACL_NO_POP_STATE
  1460. static void acl_pop_state()
  1461. {
  1462. if ( --acl_start_stack_ptr < 0 )
  1463. ACL_FATAL_ERROR( "start-condition stack underflow" );
  1464. BEGIN(acl_start_stack[acl_start_stack_ptr]);
  1465. }
  1466. #endif
  1467. #ifndef ACL_NO_TOP_STATE
  1468. static int acl_top_state()
  1469. {
  1470. return acl_start_stack[acl_start_stack_ptr - 1];
  1471. }
  1472. #endif
  1473. #ifndef ACL_EXIT_FAILURE
  1474. #define ACL_EXIT_FAILURE 2
  1475. #endif
  1476. #ifdef ACL_USE_PROTOS
  1477. static void acl_fatal_error( aclconst char msg[] )
  1478. #else
  1479. static void acl_fatal_error( msg )
  1480. char msg[];
  1481. #endif
  1482. {
  1483. (void) fprintf( stderr, "%s\n", msg );
  1484. exit( ACL_EXIT_FAILURE );
  1485. }
  1486. /* Redefine aclless() so it works in section 3 code. */
  1487. #undef aclless
  1488. #define aclless(n) \
  1489. do \
  1490. { \
  1491. /* Undo effects of setting up acltext. */ \
  1492. acltext[aclleng] = acl_hold_char; \
  1493. acl_c_buf_p = acltext + n; \
  1494. acl_hold_char = *acl_c_buf_p; \
  1495. *acl_c_buf_p = '\0'; \
  1496. aclleng = n; \
  1497. } \
  1498. while ( 0 )
  1499. /* Internal utility routines. */
  1500. #ifndef acltext_ptr
  1501. #ifdef ACL_USE_PROTOS
  1502. static void acl_flex_strncpy( char *s1, aclconst char *s2, int n )
  1503. #else
  1504. static void acl_flex_strncpy( s1, s2, n )
  1505. char *s1;
  1506. aclconst char *s2;
  1507. int n;
  1508. #endif
  1509. {
  1510. register int i;
  1511. for ( i = 0; i < n; ++i )
  1512. s1[i] = s2[i];
  1513. }
  1514. #endif
  1515. #ifdef ACL_NEED_STRLEN
  1516. #ifdef ACL_USE_PROTOS
  1517. static int acl_flex_strlen( aclconst char *s )
  1518. #else
  1519. static int acl_flex_strlen( s )
  1520. aclconst char *s;
  1521. #endif
  1522. {
  1523. register int n;
  1524. for ( n = 0; s[n]; ++n )
  1525. ;
  1526. return n;
  1527. }
  1528. #endif
  1529. #ifdef ACL_USE_PROTOS
  1530. static void *ACL_FLEX_ALLOC( acl_size_t size )
  1531. #else
  1532. static void *ACL_FLEX_ALLOC( size )
  1533. acl_size_t size;
  1534. #endif
  1535. {
  1536. return (void *) PERM_MALLOC( size );
  1537. }
  1538. #ifdef ACL_USE_PROTOS
  1539. static void *ACL_FLEX_REALLOC( void *ptr, acl_size_t size )
  1540. #else
  1541. static void *ACL_FLEX_REALLOC( ptr, size )
  1542. void *ptr;
  1543. acl_size_t size;
  1544. #endif
  1545. {
  1546. /* The cast to (char *) in the following accommodates both
  1547. * implementations that use char* generic pointers, and those
  1548. * that use void* generic pointers. It works with the latter
  1549. * because both ANSI C and C++ allow castless assignment from
  1550. * any pointer type to void*, and deal with argument conversions
  1551. * as though doing an assignment.
  1552. */
  1553. return (void *) PERM_REALLOC( (char *) ptr, size );
  1554. }
  1555. #ifdef ACL_USE_PROTOS
  1556. static void ACL_FLEX_FREE( void *ptr )
  1557. #else
  1558. static void ACL_FLEX_FREE( ptr )
  1559. void *ptr;
  1560. #endif
  1561. {
  1562. PERM_FREE( ptr );
  1563. }
  1564. #if ACL_MAIN
  1565. int main()
  1566. {
  1567. acllex();
  1568. return 0;
  1569. }
  1570. #endif
  1571. #line 235 "aclscan.l"
  1572. void
  1573. acl_detab(char *t, char *s)
  1574. {
  1575. int ii;
  1576. int pos;
  1577. int len;
  1578. if (s == NULL || t == NULL)
  1579. return;
  1580. len = strlen(s);
  1581. pos = 0;
  1582. for (ii = 0; ii < len; ii++) {
  1583. if (s[ii] == '\t') {
  1584. t[pos] = ' ';
  1585. } else {
  1586. t[pos] = s[ii];
  1587. }
  1588. pos++;
  1589. }
  1590. t[pos] = '\0';
  1591. return;
  1592. }
  1593. void
  1594. aclerror(const char *s)
  1595. {
  1596. char errorStr[256];
  1597. #if defined(UTEST) || defined(ACL_COMPILER)
  1598. printf("ACL file: %s\n", acl_filename);
  1599. printf("Syntax error at line: %d, token: %s\n", acl_lineno, acltext);
  1600. if ( last_string )
  1601. PERM_FREE(last_string);
  1602. #else
  1603. sprintf(errorStr, "%d", acl_lineno);
  1604. if (acltext) {
  1605. nserrGenerate(acl_errp, ACLERRPARSE, ACLERR1780, ACL_Program,
  1606. 3, acl_filename, errorStr, acltext);
  1607. } else {
  1608. nserrGenerate(acl_errp, ACLERRPARSE, ACLERR1780, ACL_Program,
  1609. 2, acl_filename, errorStr);
  1610. }
  1611. if ( last_string )
  1612. PERM_FREE(last_string);
  1613. #endif
  1614. }
  1615. int
  1616. acl_InitScanner(NSErr_t *errp, char *filename, char *buffer)
  1617. {
  1618. acl_errp = errp;
  1619. acl_lineno = 1;
  1620. acl_use_buffer = (filename == NULL) ? 1 : 0 ;
  1621. if ( filename != NULL ) {
  1622. PL_strncpyz(acl_filename, filename, sizeof(acl_filename));
  1623. #ifdef UTEST
  1624. aclin = fopen(filename, "r");
  1625. if ( aclin == NULL ) {
  1626. return(-1);
  1627. }
  1628. #else
  1629. acl_prfd = system_fopenRO(filename);
  1630. if ( acl_prfd == NULL ) {
  1631. return(-1);
  1632. }
  1633. aclin = (FILE *) acl_prfd;
  1634. #endif
  1635. aclrestart(aclin);
  1636. } else if ( buffer != NULL ) {
  1637. strcpy(acl_filename, "internal-buffer");
  1638. acl_buffer_offset = 0;
  1639. acl_buffer_length = strlen(buffer);
  1640. acl_buffer = PERM_STRDUP(buffer);
  1641. if (acl_buffer == NULL)
  1642. return(-1);
  1643. aclrestart(NULL);
  1644. } else {
  1645. return(-1);
  1646. }
  1647. return(0);
  1648. }
  1649. int
  1650. acl_EndScanner()
  1651. {
  1652. acl_lineno = 0;
  1653. if ( acl_use_buffer) {
  1654. if ( acl_buffer )
  1655. PERM_FREE(acl_buffer);
  1656. } else if ( aclin ) {
  1657. #ifdef UTEST
  1658. fclose(aclin);
  1659. #else
  1660. if ( acl_prfd ) {
  1661. system_fclose(acl_prfd);
  1662. acl_prfd = NULL;
  1663. }
  1664. #endif
  1665. aclin = NULL ;
  1666. }
  1667. return(0);
  1668. }
  1669. int
  1670. aclwrap()
  1671. {
  1672. return(1);
  1673. }
  1674. static int
  1675. acl_scanner_input(char *buffer, int max_size)
  1676. {
  1677. int len = 0;
  1678. if ( acl_use_buffer ) {
  1679. len = (acl_buffer_length > max_size) ? max_size :
  1680. acl_buffer_length;
  1681. memcpy(buffer, (const void *) &acl_buffer[acl_buffer_offset],
  1682. len);
  1683. acl_buffer_length -= len;
  1684. acl_buffer_offset += len;
  1685. }
  1686. #ifdef UTEST
  1687. else if ( ((len = fread( buffer, 1, max_size, aclin )) == 0)
  1688. && ferror( aclin ) ) {
  1689. aclerror( "scanner input failed" );
  1690. }
  1691. #else
  1692. else if ( (len = system_fread( acl_prfd, buffer, max_size)) < 0 ) {
  1693. aclerror( "scanner input failed" );
  1694. }
  1695. #endif
  1696. return(len);
  1697. }