acl.yy.cpp 49 KB

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