acl.yy.cpp 49 KB

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