ยปCore Development>Code coverage>Modules/expat/xmlrole.c

Python code coverage for Modules/expat/xmlrole.c

#countcontent
1n/a/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2n/a See the file COPYING for copying permission.
3n/a*/
4n/a
5n/a#include <stddef.h>
6n/a
7n/a#ifdef COMPILED_FROM_DSP
8n/a#include "winconfig.h"
9n/a#elif defined(MACOS_CLASSIC)
10n/a#include "macconfig.h"
11n/a#elif defined(__amigaos__)
12n/a#include "amigaconfig.h"
13n/a#elif defined(__WATCOMC__)
14n/a#include "watcomconfig.h"
15n/a#else
16n/a#ifdef HAVE_EXPAT_CONFIG_H
17n/a#include <expat_config.h>
18n/a#endif
19n/a#endif /* ndef COMPILED_FROM_DSP */
20n/a
21n/a#include "expat_external.h"
22n/a#include "internal.h"
23n/a#include "xmlrole.h"
24n/a#include "ascii.h"
25n/a
26n/a/* Doesn't check:
27n/a
28n/a that ,| are not mixed in a model group
29n/a content of literals
30n/a
31n/a*/
32n/a
33n/astatic const char KW_ANY[] = {
34n/a ASCII_A, ASCII_N, ASCII_Y, '\0' };
35n/astatic const char KW_ATTLIST[] = {
36n/a ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' };
37n/astatic const char KW_CDATA[] = {
38n/a ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
39n/astatic const char KW_DOCTYPE[] = {
40n/a ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' };
41n/astatic const char KW_ELEMENT[] = {
42n/a ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' };
43n/astatic const char KW_EMPTY[] = {
44n/a ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' };
45n/astatic const char KW_ENTITIES[] = {
46n/a ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S,
47n/a '\0' };
48n/astatic const char KW_ENTITY[] = {
49n/a ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' };
50n/astatic const char KW_FIXED[] = {
51n/a ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' };
52n/astatic const char KW_ID[] = {
53n/a ASCII_I, ASCII_D, '\0' };
54n/astatic const char KW_IDREF[] = {
55n/a ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
56n/astatic const char KW_IDREFS[] = {
57n/a ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
58n/a#ifdef XML_DTD
59n/astatic const char KW_IGNORE[] = {
60n/a ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' };
61n/a#endif
62n/astatic const char KW_IMPLIED[] = {
63n/a ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' };
64n/a#ifdef XML_DTD
65n/astatic const char KW_INCLUDE[] = {
66n/a ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' };
67n/a#endif
68n/astatic const char KW_NDATA[] = {
69n/a ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
70n/astatic const char KW_NMTOKEN[] = {
71n/a ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
72n/astatic const char KW_NMTOKENS[] = {
73n/a ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S,
74n/a '\0' };
75n/astatic const char KW_NOTATION[] =
76n/a { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N,
77n/a '\0' };
78n/astatic const char KW_PCDATA[] = {
79n/a ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
80n/astatic const char KW_PUBLIC[] = {
81n/a ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' };
82n/astatic const char KW_REQUIRED[] = {
83n/a ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D,
84n/a '\0' };
85n/astatic const char KW_SYSTEM[] = {
86n/a ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' };
87n/a
88n/a#ifndef MIN_BYTES_PER_CHAR
89n/a#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
90n/a#endif
91n/a
92n/a#ifdef XML_DTD
93n/a#define setTopLevel(state) \
94n/a ((state)->handler = ((state)->documentEntity \
95n/a ? internalSubset \
96n/a : externalSubset1))
97n/a#else /* not XML_DTD */
98n/a#define setTopLevel(state) ((state)->handler = internalSubset)
99n/a#endif /* not XML_DTD */
100n/a
101n/atypedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state,
102n/a int tok,
103n/a const char *ptr,
104n/a const char *end,
105n/a const ENCODING *enc);
106n/a
107n/astatic PROLOG_HANDLER
108n/a prolog0, prolog1, prolog2,
109n/a doctype0, doctype1, doctype2, doctype3, doctype4, doctype5,
110n/a internalSubset,
111n/a entity0, entity1, entity2, entity3, entity4, entity5, entity6,
112n/a entity7, entity8, entity9, entity10,
113n/a notation0, notation1, notation2, notation3, notation4,
114n/a attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6,
115n/a attlist7, attlist8, attlist9,
116n/a element0, element1, element2, element3, element4, element5, element6,
117n/a element7,
118n/a#ifdef XML_DTD
119n/a externalSubset0, externalSubset1,
120n/a condSect0, condSect1, condSect2,
121n/a#endif /* XML_DTD */
122n/a declClose,
123n/a error;
124n/a
125n/astatic int FASTCALL common(PROLOG_STATE *state, int tok);
126n/a
127n/astatic int PTRCALL
128n/aprolog0(PROLOG_STATE *state,
129n/a int tok,
130n/a const char *ptr,
131n/a const char *end,
132n/a const ENCODING *enc)
133n/a{
134n/a switch (tok) {
135n/a case XML_TOK_PROLOG_S:
136n/a state->handler = prolog1;
137n/a return XML_ROLE_NONE;
138n/a case XML_TOK_XML_DECL:
139n/a state->handler = prolog1;
140n/a return XML_ROLE_XML_DECL;
141n/a case XML_TOK_PI:
142n/a state->handler = prolog1;
143n/a return XML_ROLE_PI;
144n/a case XML_TOK_COMMENT:
145n/a state->handler = prolog1;
146n/a return XML_ROLE_COMMENT;
147n/a case XML_TOK_BOM:
148n/a return XML_ROLE_NONE;
149n/a case XML_TOK_DECL_OPEN:
150n/a if (!XmlNameMatchesAscii(enc,
151n/a ptr + 2 * MIN_BYTES_PER_CHAR(enc),
152n/a end,
153n/a KW_DOCTYPE))
154n/a break;
155n/a state->handler = doctype0;
156n/a return XML_ROLE_DOCTYPE_NONE;
157n/a case XML_TOK_INSTANCE_START:
158n/a state->handler = error;
159n/a return XML_ROLE_INSTANCE_START;
160n/a }
161n/a return common(state, tok);
162n/a}
163n/a
164n/astatic int PTRCALL
165n/aprolog1(PROLOG_STATE *state,
166n/a int tok,
167n/a const char *ptr,
168n/a const char *end,
169n/a const ENCODING *enc)
170n/a{
171n/a switch (tok) {
172n/a case XML_TOK_PROLOG_S:
173n/a return XML_ROLE_NONE;
174n/a case XML_TOK_PI:
175n/a return XML_ROLE_PI;
176n/a case XML_TOK_COMMENT:
177n/a return XML_ROLE_COMMENT;
178n/a case XML_TOK_BOM:
179n/a return XML_ROLE_NONE;
180n/a case XML_TOK_DECL_OPEN:
181n/a if (!XmlNameMatchesAscii(enc,
182n/a ptr + 2 * MIN_BYTES_PER_CHAR(enc),
183n/a end,
184n/a KW_DOCTYPE))
185n/a break;
186n/a state->handler = doctype0;
187n/a return XML_ROLE_DOCTYPE_NONE;
188n/a case XML_TOK_INSTANCE_START:
189n/a state->handler = error;
190n/a return XML_ROLE_INSTANCE_START;
191n/a }
192n/a return common(state, tok);
193n/a}
194n/a
195n/astatic int PTRCALL
196n/aprolog2(PROLOG_STATE *state,
197n/a int tok,
198n/a const char *ptr,
199n/a const char *end,
200n/a const ENCODING *enc)
201n/a{
202n/a switch (tok) {
203n/a case XML_TOK_PROLOG_S:
204n/a return XML_ROLE_NONE;
205n/a case XML_TOK_PI:
206n/a return XML_ROLE_PI;
207n/a case XML_TOK_COMMENT:
208n/a return XML_ROLE_COMMENT;
209n/a case XML_TOK_INSTANCE_START:
210n/a state->handler = error;
211n/a return XML_ROLE_INSTANCE_START;
212n/a }
213n/a return common(state, tok);
214n/a}
215n/a
216n/astatic int PTRCALL
217n/adoctype0(PROLOG_STATE *state,
218n/a int tok,
219n/a const char *ptr,
220n/a const char *end,
221n/a const ENCODING *enc)
222n/a{
223n/a switch (tok) {
224n/a case XML_TOK_PROLOG_S:
225n/a return XML_ROLE_DOCTYPE_NONE;
226n/a case XML_TOK_NAME:
227n/a case XML_TOK_PREFIXED_NAME:
228n/a state->handler = doctype1;
229n/a return XML_ROLE_DOCTYPE_NAME;
230n/a }
231n/a return common(state, tok);
232n/a}
233n/a
234n/astatic int PTRCALL
235n/adoctype1(PROLOG_STATE *state,
236n/a int tok,
237n/a const char *ptr,
238n/a const char *end,
239n/a const ENCODING *enc)
240n/a{
241n/a switch (tok) {
242n/a case XML_TOK_PROLOG_S:
243n/a return XML_ROLE_DOCTYPE_NONE;
244n/a case XML_TOK_OPEN_BRACKET:
245n/a state->handler = internalSubset;
246n/a return XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
247n/a case XML_TOK_DECL_CLOSE:
248n/a state->handler = prolog2;
249n/a return XML_ROLE_DOCTYPE_CLOSE;
250n/a case XML_TOK_NAME:
251n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
252n/a state->handler = doctype3;
253n/a return XML_ROLE_DOCTYPE_NONE;
254n/a }
255n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
256n/a state->handler = doctype2;
257n/a return XML_ROLE_DOCTYPE_NONE;
258n/a }
259n/a break;
260n/a }
261n/a return common(state, tok);
262n/a}
263n/a
264n/astatic int PTRCALL
265n/adoctype2(PROLOG_STATE *state,
266n/a int tok,
267n/a const char *ptr,
268n/a const char *end,
269n/a const ENCODING *enc)
270n/a{
271n/a switch (tok) {
272n/a case XML_TOK_PROLOG_S:
273n/a return XML_ROLE_DOCTYPE_NONE;
274n/a case XML_TOK_LITERAL:
275n/a state->handler = doctype3;
276n/a return XML_ROLE_DOCTYPE_PUBLIC_ID;
277n/a }
278n/a return common(state, tok);
279n/a}
280n/a
281n/astatic int PTRCALL
282n/adoctype3(PROLOG_STATE *state,
283n/a int tok,
284n/a const char *ptr,
285n/a const char *end,
286n/a const ENCODING *enc)
287n/a{
288n/a switch (tok) {
289n/a case XML_TOK_PROLOG_S:
290n/a return XML_ROLE_DOCTYPE_NONE;
291n/a case XML_TOK_LITERAL:
292n/a state->handler = doctype4;
293n/a return XML_ROLE_DOCTYPE_SYSTEM_ID;
294n/a }
295n/a return common(state, tok);
296n/a}
297n/a
298n/astatic int PTRCALL
299n/adoctype4(PROLOG_STATE *state,
300n/a int tok,
301n/a const char *ptr,
302n/a const char *end,
303n/a const ENCODING *enc)
304n/a{
305n/a switch (tok) {
306n/a case XML_TOK_PROLOG_S:
307n/a return XML_ROLE_DOCTYPE_NONE;
308n/a case XML_TOK_OPEN_BRACKET:
309n/a state->handler = internalSubset;
310n/a return XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
311n/a case XML_TOK_DECL_CLOSE:
312n/a state->handler = prolog2;
313n/a return XML_ROLE_DOCTYPE_CLOSE;
314n/a }
315n/a return common(state, tok);
316n/a}
317n/a
318n/astatic int PTRCALL
319n/adoctype5(PROLOG_STATE *state,
320n/a int tok,
321n/a const char *ptr,
322n/a const char *end,
323n/a const ENCODING *enc)
324n/a{
325n/a switch (tok) {
326n/a case XML_TOK_PROLOG_S:
327n/a return XML_ROLE_DOCTYPE_NONE;
328n/a case XML_TOK_DECL_CLOSE:
329n/a state->handler = prolog2;
330n/a return XML_ROLE_DOCTYPE_CLOSE;
331n/a }
332n/a return common(state, tok);
333n/a}
334n/a
335n/astatic int PTRCALL
336n/ainternalSubset(PROLOG_STATE *state,
337n/a int tok,
338n/a const char *ptr,
339n/a const char *end,
340n/a const ENCODING *enc)
341n/a{
342n/a switch (tok) {
343n/a case XML_TOK_PROLOG_S:
344n/a return XML_ROLE_NONE;
345n/a case XML_TOK_DECL_OPEN:
346n/a if (XmlNameMatchesAscii(enc,
347n/a ptr + 2 * MIN_BYTES_PER_CHAR(enc),
348n/a end,
349n/a KW_ENTITY)) {
350n/a state->handler = entity0;
351n/a return XML_ROLE_ENTITY_NONE;
352n/a }
353n/a if (XmlNameMatchesAscii(enc,
354n/a ptr + 2 * MIN_BYTES_PER_CHAR(enc),
355n/a end,
356n/a KW_ATTLIST)) {
357n/a state->handler = attlist0;
358n/a return XML_ROLE_ATTLIST_NONE;
359n/a }
360n/a if (XmlNameMatchesAscii(enc,
361n/a ptr + 2 * MIN_BYTES_PER_CHAR(enc),
362n/a end,
363n/a KW_ELEMENT)) {
364n/a state->handler = element0;
365n/a return XML_ROLE_ELEMENT_NONE;
366n/a }
367n/a if (XmlNameMatchesAscii(enc,
368n/a ptr + 2 * MIN_BYTES_PER_CHAR(enc),
369n/a end,
370n/a KW_NOTATION)) {
371n/a state->handler = notation0;
372n/a return XML_ROLE_NOTATION_NONE;
373n/a }
374n/a break;
375n/a case XML_TOK_PI:
376n/a return XML_ROLE_PI;
377n/a case XML_TOK_COMMENT:
378n/a return XML_ROLE_COMMENT;
379n/a case XML_TOK_PARAM_ENTITY_REF:
380n/a return XML_ROLE_PARAM_ENTITY_REF;
381n/a case XML_TOK_CLOSE_BRACKET:
382n/a state->handler = doctype5;
383n/a return XML_ROLE_DOCTYPE_NONE;
384n/a case XML_TOK_NONE:
385n/a return XML_ROLE_NONE;
386n/a }
387n/a return common(state, tok);
388n/a}
389n/a
390n/a#ifdef XML_DTD
391n/a
392n/astatic int PTRCALL
393n/aexternalSubset0(PROLOG_STATE *state,
394n/a int tok,
395n/a const char *ptr,
396n/a const char *end,
397n/a const ENCODING *enc)
398n/a{
399n/a state->handler = externalSubset1;
400n/a if (tok == XML_TOK_XML_DECL)
401n/a return XML_ROLE_TEXT_DECL;
402n/a return externalSubset1(state, tok, ptr, end, enc);
403n/a}
404n/a
405n/astatic int PTRCALL
406n/aexternalSubset1(PROLOG_STATE *state,
407n/a int tok,
408n/a const char *ptr,
409n/a const char *end,
410n/a const ENCODING *enc)
411n/a{
412n/a switch (tok) {
413n/a case XML_TOK_COND_SECT_OPEN:
414n/a state->handler = condSect0;
415n/a return XML_ROLE_NONE;
416n/a case XML_TOK_COND_SECT_CLOSE:
417n/a if (state->includeLevel == 0)
418n/a break;
419n/a state->includeLevel -= 1;
420n/a return XML_ROLE_NONE;
421n/a case XML_TOK_PROLOG_S:
422n/a return XML_ROLE_NONE;
423n/a case XML_TOK_CLOSE_BRACKET:
424n/a break;
425n/a case XML_TOK_NONE:
426n/a if (state->includeLevel)
427n/a break;
428n/a return XML_ROLE_NONE;
429n/a default:
430n/a return internalSubset(state, tok, ptr, end, enc);
431n/a }
432n/a return common(state, tok);
433n/a}
434n/a
435n/a#endif /* XML_DTD */
436n/a
437n/astatic int PTRCALL
438n/aentity0(PROLOG_STATE *state,
439n/a int tok,
440n/a const char *ptr,
441n/a const char *end,
442n/a const ENCODING *enc)
443n/a{
444n/a switch (tok) {
445n/a case XML_TOK_PROLOG_S:
446n/a return XML_ROLE_ENTITY_NONE;
447n/a case XML_TOK_PERCENT:
448n/a state->handler = entity1;
449n/a return XML_ROLE_ENTITY_NONE;
450n/a case XML_TOK_NAME:
451n/a state->handler = entity2;
452n/a return XML_ROLE_GENERAL_ENTITY_NAME;
453n/a }
454n/a return common(state, tok);
455n/a}
456n/a
457n/astatic int PTRCALL
458n/aentity1(PROLOG_STATE *state,
459n/a int tok,
460n/a const char *ptr,
461n/a const char *end,
462n/a const ENCODING *enc)
463n/a{
464n/a switch (tok) {
465n/a case XML_TOK_PROLOG_S:
466n/a return XML_ROLE_ENTITY_NONE;
467n/a case XML_TOK_NAME:
468n/a state->handler = entity7;
469n/a return XML_ROLE_PARAM_ENTITY_NAME;
470n/a }
471n/a return common(state, tok);
472n/a}
473n/a
474n/astatic int PTRCALL
475n/aentity2(PROLOG_STATE *state,
476n/a int tok,
477n/a const char *ptr,
478n/a const char *end,
479n/a const ENCODING *enc)
480n/a{
481n/a switch (tok) {
482n/a case XML_TOK_PROLOG_S:
483n/a return XML_ROLE_ENTITY_NONE;
484n/a case XML_TOK_NAME:
485n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
486n/a state->handler = entity4;
487n/a return XML_ROLE_ENTITY_NONE;
488n/a }
489n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
490n/a state->handler = entity3;
491n/a return XML_ROLE_ENTITY_NONE;
492n/a }
493n/a break;
494n/a case XML_TOK_LITERAL:
495n/a state->handler = declClose;
496n/a state->role_none = XML_ROLE_ENTITY_NONE;
497n/a return XML_ROLE_ENTITY_VALUE;
498n/a }
499n/a return common(state, tok);
500n/a}
501n/a
502n/astatic int PTRCALL
503n/aentity3(PROLOG_STATE *state,
504n/a int tok,
505n/a const char *ptr,
506n/a const char *end,
507n/a const ENCODING *enc)
508n/a{
509n/a switch (tok) {
510n/a case XML_TOK_PROLOG_S:
511n/a return XML_ROLE_ENTITY_NONE;
512n/a case XML_TOK_LITERAL:
513n/a state->handler = entity4;
514n/a return XML_ROLE_ENTITY_PUBLIC_ID;
515n/a }
516n/a return common(state, tok);
517n/a}
518n/a
519n/astatic int PTRCALL
520n/aentity4(PROLOG_STATE *state,
521n/a int tok,
522n/a const char *ptr,
523n/a const char *end,
524n/a const ENCODING *enc)
525n/a{
526n/a switch (tok) {
527n/a case XML_TOK_PROLOG_S:
528n/a return XML_ROLE_ENTITY_NONE;
529n/a case XML_TOK_LITERAL:
530n/a state->handler = entity5;
531n/a return XML_ROLE_ENTITY_SYSTEM_ID;
532n/a }
533n/a return common(state, tok);
534n/a}
535n/a
536n/astatic int PTRCALL
537n/aentity5(PROLOG_STATE *state,
538n/a int tok,
539n/a const char *ptr,
540n/a const char *end,
541n/a const ENCODING *enc)
542n/a{
543n/a switch (tok) {
544n/a case XML_TOK_PROLOG_S:
545n/a return XML_ROLE_ENTITY_NONE;
546n/a case XML_TOK_DECL_CLOSE:
547n/a setTopLevel(state);
548n/a return XML_ROLE_ENTITY_COMPLETE;
549n/a case XML_TOK_NAME:
550n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) {
551n/a state->handler = entity6;
552n/a return XML_ROLE_ENTITY_NONE;
553n/a }
554n/a break;
555n/a }
556n/a return common(state, tok);
557n/a}
558n/a
559n/astatic int PTRCALL
560n/aentity6(PROLOG_STATE *state,
561n/a int tok,
562n/a const char *ptr,
563n/a const char *end,
564n/a const ENCODING *enc)
565n/a{
566n/a switch (tok) {
567n/a case XML_TOK_PROLOG_S:
568n/a return XML_ROLE_ENTITY_NONE;
569n/a case XML_TOK_NAME:
570n/a state->handler = declClose;
571n/a state->role_none = XML_ROLE_ENTITY_NONE;
572n/a return XML_ROLE_ENTITY_NOTATION_NAME;
573n/a }
574n/a return common(state, tok);
575n/a}
576n/a
577n/astatic int PTRCALL
578n/aentity7(PROLOG_STATE *state,
579n/a int tok,
580n/a const char *ptr,
581n/a const char *end,
582n/a const ENCODING *enc)
583n/a{
584n/a switch (tok) {
585n/a case XML_TOK_PROLOG_S:
586n/a return XML_ROLE_ENTITY_NONE;
587n/a case XML_TOK_NAME:
588n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
589n/a state->handler = entity9;
590n/a return XML_ROLE_ENTITY_NONE;
591n/a }
592n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
593n/a state->handler = entity8;
594n/a return XML_ROLE_ENTITY_NONE;
595n/a }
596n/a break;
597n/a case XML_TOK_LITERAL:
598n/a state->handler = declClose;
599n/a state->role_none = XML_ROLE_ENTITY_NONE;
600n/a return XML_ROLE_ENTITY_VALUE;
601n/a }
602n/a return common(state, tok);
603n/a}
604n/a
605n/astatic int PTRCALL
606n/aentity8(PROLOG_STATE *state,
607n/a int tok,
608n/a const char *ptr,
609n/a const char *end,
610n/a const ENCODING *enc)
611n/a{
612n/a switch (tok) {
613n/a case XML_TOK_PROLOG_S:
614n/a return XML_ROLE_ENTITY_NONE;
615n/a case XML_TOK_LITERAL:
616n/a state->handler = entity9;
617n/a return XML_ROLE_ENTITY_PUBLIC_ID;
618n/a }
619n/a return common(state, tok);
620n/a}
621n/a
622n/astatic int PTRCALL
623n/aentity9(PROLOG_STATE *state,
624n/a int tok,
625n/a const char *ptr,
626n/a const char *end,
627n/a const ENCODING *enc)
628n/a{
629n/a switch (tok) {
630n/a case XML_TOK_PROLOG_S:
631n/a return XML_ROLE_ENTITY_NONE;
632n/a case XML_TOK_LITERAL:
633n/a state->handler = entity10;
634n/a return XML_ROLE_ENTITY_SYSTEM_ID;
635n/a }
636n/a return common(state, tok);
637n/a}
638n/a
639n/astatic int PTRCALL
640n/aentity10(PROLOG_STATE *state,
641n/a int tok,
642n/a const char *ptr,
643n/a const char *end,
644n/a const ENCODING *enc)
645n/a{
646n/a switch (tok) {
647n/a case XML_TOK_PROLOG_S:
648n/a return XML_ROLE_ENTITY_NONE;
649n/a case XML_TOK_DECL_CLOSE:
650n/a setTopLevel(state);
651n/a return XML_ROLE_ENTITY_COMPLETE;
652n/a }
653n/a return common(state, tok);
654n/a}
655n/a
656n/astatic int PTRCALL
657n/anotation0(PROLOG_STATE *state,
658n/a int tok,
659n/a const char *ptr,
660n/a const char *end,
661n/a const ENCODING *enc)
662n/a{
663n/a switch (tok) {
664n/a case XML_TOK_PROLOG_S:
665n/a return XML_ROLE_NOTATION_NONE;
666n/a case XML_TOK_NAME:
667n/a state->handler = notation1;
668n/a return XML_ROLE_NOTATION_NAME;
669n/a }
670n/a return common(state, tok);
671n/a}
672n/a
673n/astatic int PTRCALL
674n/anotation1(PROLOG_STATE *state,
675n/a int tok,
676n/a const char *ptr,
677n/a const char *end,
678n/a const ENCODING *enc)
679n/a{
680n/a switch (tok) {
681n/a case XML_TOK_PROLOG_S:
682n/a return XML_ROLE_NOTATION_NONE;
683n/a case XML_TOK_NAME:
684n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
685n/a state->handler = notation3;
686n/a return XML_ROLE_NOTATION_NONE;
687n/a }
688n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
689n/a state->handler = notation2;
690n/a return XML_ROLE_NOTATION_NONE;
691n/a }
692n/a break;
693n/a }
694n/a return common(state, tok);
695n/a}
696n/a
697n/astatic int PTRCALL
698n/anotation2(PROLOG_STATE *state,
699n/a int tok,
700n/a const char *ptr,
701n/a const char *end,
702n/a const ENCODING *enc)
703n/a{
704n/a switch (tok) {
705n/a case XML_TOK_PROLOG_S:
706n/a return XML_ROLE_NOTATION_NONE;
707n/a case XML_TOK_LITERAL:
708n/a state->handler = notation4;
709n/a return XML_ROLE_NOTATION_PUBLIC_ID;
710n/a }
711n/a return common(state, tok);
712n/a}
713n/a
714n/astatic int PTRCALL
715n/anotation3(PROLOG_STATE *state,
716n/a int tok,
717n/a const char *ptr,
718n/a const char *end,
719n/a const ENCODING *enc)
720n/a{
721n/a switch (tok) {
722n/a case XML_TOK_PROLOG_S:
723n/a return XML_ROLE_NOTATION_NONE;
724n/a case XML_TOK_LITERAL:
725n/a state->handler = declClose;
726n/a state->role_none = XML_ROLE_NOTATION_NONE;
727n/a return XML_ROLE_NOTATION_SYSTEM_ID;
728n/a }
729n/a return common(state, tok);
730n/a}
731n/a
732n/astatic int PTRCALL
733n/anotation4(PROLOG_STATE *state,
734n/a int tok,
735n/a const char *ptr,
736n/a const char *end,
737n/a const ENCODING *enc)
738n/a{
739n/a switch (tok) {
740n/a case XML_TOK_PROLOG_S:
741n/a return XML_ROLE_NOTATION_NONE;
742n/a case XML_TOK_LITERAL:
743n/a state->handler = declClose;
744n/a state->role_none = XML_ROLE_NOTATION_NONE;
745n/a return XML_ROLE_NOTATION_SYSTEM_ID;
746n/a case XML_TOK_DECL_CLOSE:
747n/a setTopLevel(state);
748n/a return XML_ROLE_NOTATION_NO_SYSTEM_ID;
749n/a }
750n/a return common(state, tok);
751n/a}
752n/a
753n/astatic int PTRCALL
754n/aattlist0(PROLOG_STATE *state,
755n/a int tok,
756n/a const char *ptr,
757n/a const char *end,
758n/a const ENCODING *enc)
759n/a{
760n/a switch (tok) {
761n/a case XML_TOK_PROLOG_S:
762n/a return XML_ROLE_ATTLIST_NONE;
763n/a case XML_TOK_NAME:
764n/a case XML_TOK_PREFIXED_NAME:
765n/a state->handler = attlist1;
766n/a return XML_ROLE_ATTLIST_ELEMENT_NAME;
767n/a }
768n/a return common(state, tok);
769n/a}
770n/a
771n/astatic int PTRCALL
772n/aattlist1(PROLOG_STATE *state,
773n/a int tok,
774n/a const char *ptr,
775n/a const char *end,
776n/a const ENCODING *enc)
777n/a{
778n/a switch (tok) {
779n/a case XML_TOK_PROLOG_S:
780n/a return XML_ROLE_ATTLIST_NONE;
781n/a case XML_TOK_DECL_CLOSE:
782n/a setTopLevel(state);
783n/a return XML_ROLE_ATTLIST_NONE;
784n/a case XML_TOK_NAME:
785n/a case XML_TOK_PREFIXED_NAME:
786n/a state->handler = attlist2;
787n/a return XML_ROLE_ATTRIBUTE_NAME;
788n/a }
789n/a return common(state, tok);
790n/a}
791n/a
792n/astatic int PTRCALL
793n/aattlist2(PROLOG_STATE *state,
794n/a int tok,
795n/a const char *ptr,
796n/a const char *end,
797n/a const ENCODING *enc)
798n/a{
799n/a switch (tok) {
800n/a case XML_TOK_PROLOG_S:
801n/a return XML_ROLE_ATTLIST_NONE;
802n/a case XML_TOK_NAME:
803n/a {
804n/a static const char * const types[] = {
805n/a KW_CDATA,
806n/a KW_ID,
807n/a KW_IDREF,
808n/a KW_IDREFS,
809n/a KW_ENTITY,
810n/a KW_ENTITIES,
811n/a KW_NMTOKEN,
812n/a KW_NMTOKENS,
813n/a };
814n/a int i;
815n/a for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++)
816n/a if (XmlNameMatchesAscii(enc, ptr, end, types[i])) {
817n/a state->handler = attlist8;
818n/a return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
819n/a }
820n/a }
821n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) {
822n/a state->handler = attlist5;
823n/a return XML_ROLE_ATTLIST_NONE;
824n/a }
825n/a break;
826n/a case XML_TOK_OPEN_PAREN:
827n/a state->handler = attlist3;
828n/a return XML_ROLE_ATTLIST_NONE;
829n/a }
830n/a return common(state, tok);
831n/a}
832n/a
833n/astatic int PTRCALL
834n/aattlist3(PROLOG_STATE *state,
835n/a int tok,
836n/a const char *ptr,
837n/a const char *end,
838n/a const ENCODING *enc)
839n/a{
840n/a switch (tok) {
841n/a case XML_TOK_PROLOG_S:
842n/a return XML_ROLE_ATTLIST_NONE;
843n/a case XML_TOK_NMTOKEN:
844n/a case XML_TOK_NAME:
845n/a case XML_TOK_PREFIXED_NAME:
846n/a state->handler = attlist4;
847n/a return XML_ROLE_ATTRIBUTE_ENUM_VALUE;
848n/a }
849n/a return common(state, tok);
850n/a}
851n/a
852n/astatic int PTRCALL
853n/aattlist4(PROLOG_STATE *state,
854n/a int tok,
855n/a const char *ptr,
856n/a const char *end,
857n/a const ENCODING *enc)
858n/a{
859n/a switch (tok) {
860n/a case XML_TOK_PROLOG_S:
861n/a return XML_ROLE_ATTLIST_NONE;
862n/a case XML_TOK_CLOSE_PAREN:
863n/a state->handler = attlist8;
864n/a return XML_ROLE_ATTLIST_NONE;
865n/a case XML_TOK_OR:
866n/a state->handler = attlist3;
867n/a return XML_ROLE_ATTLIST_NONE;
868n/a }
869n/a return common(state, tok);
870n/a}
871n/a
872n/astatic int PTRCALL
873n/aattlist5(PROLOG_STATE *state,
874n/a int tok,
875n/a const char *ptr,
876n/a const char *end,
877n/a const ENCODING *enc)
878n/a{
879n/a switch (tok) {
880n/a case XML_TOK_PROLOG_S:
881n/a return XML_ROLE_ATTLIST_NONE;
882n/a case XML_TOK_OPEN_PAREN:
883n/a state->handler = attlist6;
884n/a return XML_ROLE_ATTLIST_NONE;
885n/a }
886n/a return common(state, tok);
887n/a}
888n/a
889n/astatic int PTRCALL
890n/aattlist6(PROLOG_STATE *state,
891n/a int tok,
892n/a const char *ptr,
893n/a const char *end,
894n/a const ENCODING *enc)
895n/a{
896n/a switch (tok) {
897n/a case XML_TOK_PROLOG_S:
898n/a return XML_ROLE_ATTLIST_NONE;
899n/a case XML_TOK_NAME:
900n/a state->handler = attlist7;
901n/a return XML_ROLE_ATTRIBUTE_NOTATION_VALUE;
902n/a }
903n/a return common(state, tok);
904n/a}
905n/a
906n/astatic int PTRCALL
907n/aattlist7(PROLOG_STATE *state,
908n/a int tok,
909n/a const char *ptr,
910n/a const char *end,
911n/a const ENCODING *enc)
912n/a{
913n/a switch (tok) {
914n/a case XML_TOK_PROLOG_S:
915n/a return XML_ROLE_ATTLIST_NONE;
916n/a case XML_TOK_CLOSE_PAREN:
917n/a state->handler = attlist8;
918n/a return XML_ROLE_ATTLIST_NONE;
919n/a case XML_TOK_OR:
920n/a state->handler = attlist6;
921n/a return XML_ROLE_ATTLIST_NONE;
922n/a }
923n/a return common(state, tok);
924n/a}
925n/a
926n/a/* default value */
927n/astatic int PTRCALL
928n/aattlist8(PROLOG_STATE *state,
929n/a int tok,
930n/a const char *ptr,
931n/a const char *end,
932n/a const ENCODING *enc)
933n/a{
934n/a switch (tok) {
935n/a case XML_TOK_PROLOG_S:
936n/a return XML_ROLE_ATTLIST_NONE;
937n/a case XML_TOK_POUND_NAME:
938n/a if (XmlNameMatchesAscii(enc,
939n/a ptr + MIN_BYTES_PER_CHAR(enc),
940n/a end,
941n/a KW_IMPLIED)) {
942n/a state->handler = attlist1;
943n/a return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE;
944n/a }
945n/a if (XmlNameMatchesAscii(enc,
946n/a ptr + MIN_BYTES_PER_CHAR(enc),
947n/a end,
948n/a KW_REQUIRED)) {
949n/a state->handler = attlist1;
950n/a return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE;
951n/a }
952n/a if (XmlNameMatchesAscii(enc,
953n/a ptr + MIN_BYTES_PER_CHAR(enc),
954n/a end,
955n/a KW_FIXED)) {
956n/a state->handler = attlist9;
957n/a return XML_ROLE_ATTLIST_NONE;
958n/a }
959n/a break;
960n/a case XML_TOK_LITERAL:
961n/a state->handler = attlist1;
962n/a return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE;
963n/a }
964n/a return common(state, tok);
965n/a}
966n/a
967n/astatic int PTRCALL
968n/aattlist9(PROLOG_STATE *state,
969n/a int tok,
970n/a const char *ptr,
971n/a const char *end,
972n/a const ENCODING *enc)
973n/a{
974n/a switch (tok) {
975n/a case XML_TOK_PROLOG_S:
976n/a return XML_ROLE_ATTLIST_NONE;
977n/a case XML_TOK_LITERAL:
978n/a state->handler = attlist1;
979n/a return XML_ROLE_FIXED_ATTRIBUTE_VALUE;
980n/a }
981n/a return common(state, tok);
982n/a}
983n/a
984n/astatic int PTRCALL
985n/aelement0(PROLOG_STATE *state,
986n/a int tok,
987n/a const char *ptr,
988n/a const char *end,
989n/a const ENCODING *enc)
990n/a{
991n/a switch (tok) {
992n/a case XML_TOK_PROLOG_S:
993n/a return XML_ROLE_ELEMENT_NONE;
994n/a case XML_TOK_NAME:
995n/a case XML_TOK_PREFIXED_NAME:
996n/a state->handler = element1;
997n/a return XML_ROLE_ELEMENT_NAME;
998n/a }
999n/a return common(state, tok);
1000n/a}
1001n/a
1002n/astatic int PTRCALL
1003n/aelement1(PROLOG_STATE *state,
1004n/a int tok,
1005n/a const char *ptr,
1006n/a const char *end,
1007n/a const ENCODING *enc)
1008n/a{
1009n/a switch (tok) {
1010n/a case XML_TOK_PROLOG_S:
1011n/a return XML_ROLE_ELEMENT_NONE;
1012n/a case XML_TOK_NAME:
1013n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) {
1014n/a state->handler = declClose;
1015n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1016n/a return XML_ROLE_CONTENT_EMPTY;
1017n/a }
1018n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_ANY)) {
1019n/a state->handler = declClose;
1020n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1021n/a return XML_ROLE_CONTENT_ANY;
1022n/a }
1023n/a break;
1024n/a case XML_TOK_OPEN_PAREN:
1025n/a state->handler = element2;
1026n/a state->level = 1;
1027n/a return XML_ROLE_GROUP_OPEN;
1028n/a }
1029n/a return common(state, tok);
1030n/a}
1031n/a
1032n/astatic int PTRCALL
1033n/aelement2(PROLOG_STATE *state,
1034n/a int tok,
1035n/a const char *ptr,
1036n/a const char *end,
1037n/a const ENCODING *enc)
1038n/a{
1039n/a switch (tok) {
1040n/a case XML_TOK_PROLOG_S:
1041n/a return XML_ROLE_ELEMENT_NONE;
1042n/a case XML_TOK_POUND_NAME:
1043n/a if (XmlNameMatchesAscii(enc,
1044n/a ptr + MIN_BYTES_PER_CHAR(enc),
1045n/a end,
1046n/a KW_PCDATA)) {
1047n/a state->handler = element3;
1048n/a return XML_ROLE_CONTENT_PCDATA;
1049n/a }
1050n/a break;
1051n/a case XML_TOK_OPEN_PAREN:
1052n/a state->level = 2;
1053n/a state->handler = element6;
1054n/a return XML_ROLE_GROUP_OPEN;
1055n/a case XML_TOK_NAME:
1056n/a case XML_TOK_PREFIXED_NAME:
1057n/a state->handler = element7;
1058n/a return XML_ROLE_CONTENT_ELEMENT;
1059n/a case XML_TOK_NAME_QUESTION:
1060n/a state->handler = element7;
1061n/a return XML_ROLE_CONTENT_ELEMENT_OPT;
1062n/a case XML_TOK_NAME_ASTERISK:
1063n/a state->handler = element7;
1064n/a return XML_ROLE_CONTENT_ELEMENT_REP;
1065n/a case XML_TOK_NAME_PLUS:
1066n/a state->handler = element7;
1067n/a return XML_ROLE_CONTENT_ELEMENT_PLUS;
1068n/a }
1069n/a return common(state, tok);
1070n/a}
1071n/a
1072n/astatic int PTRCALL
1073n/aelement3(PROLOG_STATE *state,
1074n/a int tok,
1075n/a const char *ptr,
1076n/a const char *end,
1077n/a const ENCODING *enc)
1078n/a{
1079n/a switch (tok) {
1080n/a case XML_TOK_PROLOG_S:
1081n/a return XML_ROLE_ELEMENT_NONE;
1082n/a case XML_TOK_CLOSE_PAREN:
1083n/a state->handler = declClose;
1084n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1085n/a return XML_ROLE_GROUP_CLOSE;
1086n/a case XML_TOK_CLOSE_PAREN_ASTERISK:
1087n/a state->handler = declClose;
1088n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1089n/a return XML_ROLE_GROUP_CLOSE_REP;
1090n/a case XML_TOK_OR:
1091n/a state->handler = element4;
1092n/a return XML_ROLE_ELEMENT_NONE;
1093n/a }
1094n/a return common(state, tok);
1095n/a}
1096n/a
1097n/astatic int PTRCALL
1098n/aelement4(PROLOG_STATE *state,
1099n/a int tok,
1100n/a const char *ptr,
1101n/a const char *end,
1102n/a const ENCODING *enc)
1103n/a{
1104n/a switch (tok) {
1105n/a case XML_TOK_PROLOG_S:
1106n/a return XML_ROLE_ELEMENT_NONE;
1107n/a case XML_TOK_NAME:
1108n/a case XML_TOK_PREFIXED_NAME:
1109n/a state->handler = element5;
1110n/a return XML_ROLE_CONTENT_ELEMENT;
1111n/a }
1112n/a return common(state, tok);
1113n/a}
1114n/a
1115n/astatic int PTRCALL
1116n/aelement5(PROLOG_STATE *state,
1117n/a int tok,
1118n/a const char *ptr,
1119n/a const char *end,
1120n/a const ENCODING *enc)
1121n/a{
1122n/a switch (tok) {
1123n/a case XML_TOK_PROLOG_S:
1124n/a return XML_ROLE_ELEMENT_NONE;
1125n/a case XML_TOK_CLOSE_PAREN_ASTERISK:
1126n/a state->handler = declClose;
1127n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1128n/a return XML_ROLE_GROUP_CLOSE_REP;
1129n/a case XML_TOK_OR:
1130n/a state->handler = element4;
1131n/a return XML_ROLE_ELEMENT_NONE;
1132n/a }
1133n/a return common(state, tok);
1134n/a}
1135n/a
1136n/astatic int PTRCALL
1137n/aelement6(PROLOG_STATE *state,
1138n/a int tok,
1139n/a const char *ptr,
1140n/a const char *end,
1141n/a const ENCODING *enc)
1142n/a{
1143n/a switch (tok) {
1144n/a case XML_TOK_PROLOG_S:
1145n/a return XML_ROLE_ELEMENT_NONE;
1146n/a case XML_TOK_OPEN_PAREN:
1147n/a state->level += 1;
1148n/a return XML_ROLE_GROUP_OPEN;
1149n/a case XML_TOK_NAME:
1150n/a case XML_TOK_PREFIXED_NAME:
1151n/a state->handler = element7;
1152n/a return XML_ROLE_CONTENT_ELEMENT;
1153n/a case XML_TOK_NAME_QUESTION:
1154n/a state->handler = element7;
1155n/a return XML_ROLE_CONTENT_ELEMENT_OPT;
1156n/a case XML_TOK_NAME_ASTERISK:
1157n/a state->handler = element7;
1158n/a return XML_ROLE_CONTENT_ELEMENT_REP;
1159n/a case XML_TOK_NAME_PLUS:
1160n/a state->handler = element7;
1161n/a return XML_ROLE_CONTENT_ELEMENT_PLUS;
1162n/a }
1163n/a return common(state, tok);
1164n/a}
1165n/a
1166n/astatic int PTRCALL
1167n/aelement7(PROLOG_STATE *state,
1168n/a int tok,
1169n/a const char *ptr,
1170n/a const char *end,
1171n/a const ENCODING *enc)
1172n/a{
1173n/a switch (tok) {
1174n/a case XML_TOK_PROLOG_S:
1175n/a return XML_ROLE_ELEMENT_NONE;
1176n/a case XML_TOK_CLOSE_PAREN:
1177n/a state->level -= 1;
1178n/a if (state->level == 0) {
1179n/a state->handler = declClose;
1180n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1181n/a }
1182n/a return XML_ROLE_GROUP_CLOSE;
1183n/a case XML_TOK_CLOSE_PAREN_ASTERISK:
1184n/a state->level -= 1;
1185n/a if (state->level == 0) {
1186n/a state->handler = declClose;
1187n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1188n/a }
1189n/a return XML_ROLE_GROUP_CLOSE_REP;
1190n/a case XML_TOK_CLOSE_PAREN_QUESTION:
1191n/a state->level -= 1;
1192n/a if (state->level == 0) {
1193n/a state->handler = declClose;
1194n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1195n/a }
1196n/a return XML_ROLE_GROUP_CLOSE_OPT;
1197n/a case XML_TOK_CLOSE_PAREN_PLUS:
1198n/a state->level -= 1;
1199n/a if (state->level == 0) {
1200n/a state->handler = declClose;
1201n/a state->role_none = XML_ROLE_ELEMENT_NONE;
1202n/a }
1203n/a return XML_ROLE_GROUP_CLOSE_PLUS;
1204n/a case XML_TOK_COMMA:
1205n/a state->handler = element6;
1206n/a return XML_ROLE_GROUP_SEQUENCE;
1207n/a case XML_TOK_OR:
1208n/a state->handler = element6;
1209n/a return XML_ROLE_GROUP_CHOICE;
1210n/a }
1211n/a return common(state, tok);
1212n/a}
1213n/a
1214n/a#ifdef XML_DTD
1215n/a
1216n/astatic int PTRCALL
1217n/acondSect0(PROLOG_STATE *state,
1218n/a int tok,
1219n/a const char *ptr,
1220n/a const char *end,
1221n/a const ENCODING *enc)
1222n/a{
1223n/a switch (tok) {
1224n/a case XML_TOK_PROLOG_S:
1225n/a return XML_ROLE_NONE;
1226n/a case XML_TOK_NAME:
1227n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) {
1228n/a state->handler = condSect1;
1229n/a return XML_ROLE_NONE;
1230n/a }
1231n/a if (XmlNameMatchesAscii(enc, ptr, end, KW_IGNORE)) {
1232n/a state->handler = condSect2;
1233n/a return XML_ROLE_NONE;
1234n/a }
1235n/a break;
1236n/a }
1237n/a return common(state, tok);
1238n/a}
1239n/a
1240n/astatic int PTRCALL
1241n/acondSect1(PROLOG_STATE *state,
1242n/a int tok,
1243n/a const char *ptr,
1244n/a const char *end,
1245n/a const ENCODING *enc)
1246n/a{
1247n/a switch (tok) {
1248n/a case XML_TOK_PROLOG_S:
1249n/a return XML_ROLE_NONE;
1250n/a case XML_TOK_OPEN_BRACKET:
1251n/a state->handler = externalSubset1;
1252n/a state->includeLevel += 1;
1253n/a return XML_ROLE_NONE;
1254n/a }
1255n/a return common(state, tok);
1256n/a}
1257n/a
1258n/astatic int PTRCALL
1259n/acondSect2(PROLOG_STATE *state,
1260n/a int tok,
1261n/a const char *ptr,
1262n/a const char *end,
1263n/a const ENCODING *enc)
1264n/a{
1265n/a switch (tok) {
1266n/a case XML_TOK_PROLOG_S:
1267n/a return XML_ROLE_NONE;
1268n/a case XML_TOK_OPEN_BRACKET:
1269n/a state->handler = externalSubset1;
1270n/a return XML_ROLE_IGNORE_SECT;
1271n/a }
1272n/a return common(state, tok);
1273n/a}
1274n/a
1275n/a#endif /* XML_DTD */
1276n/a
1277n/astatic int PTRCALL
1278n/adeclClose(PROLOG_STATE *state,
1279n/a int tok,
1280n/a const char *ptr,
1281n/a const char *end,
1282n/a const ENCODING *enc)
1283n/a{
1284n/a switch (tok) {
1285n/a case XML_TOK_PROLOG_S:
1286n/a return state->role_none;
1287n/a case XML_TOK_DECL_CLOSE:
1288n/a setTopLevel(state);
1289n/a return state->role_none;
1290n/a }
1291n/a return common(state, tok);
1292n/a}
1293n/a
1294n/astatic int PTRCALL
1295n/aerror(PROLOG_STATE *state,
1296n/a int tok,
1297n/a const char *ptr,
1298n/a const char *end,
1299n/a const ENCODING *enc)
1300n/a{
1301n/a return XML_ROLE_NONE;
1302n/a}
1303n/a
1304n/astatic int FASTCALL
1305n/acommon(PROLOG_STATE *state, int tok)
1306n/a{
1307n/a#ifdef XML_DTD
1308n/a if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF)
1309n/a return XML_ROLE_INNER_PARAM_ENTITY_REF;
1310n/a#endif
1311n/a state->handler = error;
1312n/a return XML_ROLE_ERROR;
1313n/a}
1314n/a
1315n/avoid
1316n/aXmlPrologStateInit(PROLOG_STATE *state)
1317n/a{
1318n/a state->handler = prolog0;
1319n/a#ifdef XML_DTD
1320n/a state->documentEntity = 1;
1321n/a state->includeLevel = 0;
1322n/a state->inEntityValue = 0;
1323n/a#endif /* XML_DTD */
1324n/a}
1325n/a
1326n/a#ifdef XML_DTD
1327n/a
1328n/avoid
1329n/aXmlPrologStateInitExternalEntity(PROLOG_STATE *state)
1330n/a{
1331n/a state->handler = externalSubset0;
1332n/a state->documentEntity = 0;
1333n/a state->includeLevel = 0;
1334n/a}
1335n/a
1336n/a#endif /* XML_DTD */