2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: source.h /main/3 1996/06/19 17:18:30 drk $ */
24 /* SOURCE.H: Entity and source control block structures and definitions.
26 #define ENTHASH 503 /* Size of entity hash table. Must be prime. */
27 /* Entity storage class values for estore member of entity structure. */
28 #define EST 1 /* String: Tag (usually a fixed STARTGI). */
29 /* <MDENTITY sets these:> */
30 #define ESMD 2 /* String: Markup declaration. */
31 #define ESMS 3 /* String: Marked section. */
32 #define ESM 4 /* String: ordinary text. */
33 /* <ENTOPEN treats these specially:> */
34 #define ESS 5 /* ETD: Start-tag. */
35 #define ESE 6 /* ETD: End-tag. */
36 #define ESI 7 /* String: PI. */
37 #define ESX 8 /* String: SDATA general entity. */
38 #define ESC 9 /* String: CDATA general entity. */
39 /* </MDENTITY> <MDEXTID sets these:> */
40 #define ESFM 10 /* LPU: minimum external (file) storage class. */
41 #define ESN 10 /* XCB: N/C/SDATA or SUBDOC control block. */
43 #define ESF 11 /* LPU: General entity. */
44 #define ESP 12 /* LPU: Parameter entity. */
45 #define ESD 13 /* LPU: Document type definition. */
46 #define ESL 14 /* LPU: Link process definition. */
47 #define ESK 15 /* LPU: Data content notation. */
50 union etext { /* Entity text. */
51 UNIV x; /* External ID generated by system. */
52 UNCH *c; /* Character string. */
53 struct ne *n; /* N/C/SDATA or SUBDOC entity control block. */
55 #define ETEXTSZ sizeof(union etext)
56 struct entity { /* Entity control block. */
57 struct entity *enext; /* Next entity in chain. */
58 UNCH *ename; /* Entity name with length and EOS. */
59 UNCH estore; /* Storage class (see values above). */
60 UNCH dflt; /* Declared as default entity. */
61 UNCH mark; /* For use by for sgmlment. */
62 union etext etx; /* Entity text. */
64 #define ENTSZ sizeof(struct entity)
65 typedef struct entity *PECB; /* Ptr to entity control block. */
66 typedef struct entity **TECB; /* Table of entity control blocks. */
68 struct source { /* Source control block. */
69 struct entity ecb; /* Entity control block. */
70 unsigned long rcnt; /* Source record number. */
71 int ccnt; /* Source record chars since last RS. */
72 int curoff; /* Offset of curchar (chars read in this block).*/
73 UNCH curchar; /* Current character. */
74 UNCH nextchar; /* If curchar was DELNONCH, next character. */
75 UNIV fcb; /* SGMLIO fcb ptr returned by OPEN. */
76 UNCH *fbuf; /* 1st char in buffer (0=PEND) or entity text. */
77 UNCH *fpos; /* Current char in buffer or entity text. */
78 UNCH pushback; /* Character before pend position */
79 char copied; /* Is this a copy of the internal entity? */
81 #define SCBSZ sizeof(struct source)
82 typedef struct source *PSCB; /* Ptr to source control block. */
84 extern int es; /* Index of current source in stack. */
85 extern struct source *scbs; /* Stack of open sources ("SCB stack"). */
87 /* Member definitions for source and entity control blocks.
89 #define SCB (scbs[es]) /* Ptr to current source control block. */
91 #define ECB SCB.ecb /* Pointer to current entity control block. */
92 #define FBUF SCB.fbuf /* Pointer to start of entity buffer. */
93 #define FPOS SCB.fpos /* Pointer to current char of current source. */
94 #define RSCC SCB.ccnt /* CCNT at start of block (across EOB/EOS/EOF). */
95 #define CCO SCB.curoff /* Offset in read buffer of current char. */
96 #define CC SCB.curchar /* Current character of current source entity. */
97 #define NEXTC SCB.nextchar /* Next character in current source entity. */
98 #define CCNT (SCB.ccnt+CCO) /* Position of CC in current record (RS=0). */
99 #define RCNT SCB.rcnt /* Position of record in entity (origin=1). */
100 #define SCBFCB SCB.fcb /* Current file control block (if FILESW). */
101 #define ECBPTR ((ECB.enext)) /* Pointer to this entity's ECB. */
102 #define ENTITY ((ECB.ename)) /* Current entity name. */
103 #define FILESW (ECB.estore>=ESFM) /* 1=Entity is external file; 0=internal. */
104 #define NEWCC (++FPOS) /* Get next current character. */
105 #define REPEATCC (--FPOS) /* Repeat previous current character. */
106 #define COPIEDSW SCB.copied /* Non-zero means entity was copied. */
108 struct srh { /* Short reference map header. */
109 struct srh *enext; /* Next short reference map in chain. */
110 UNCH *ename; /* Short reference map name. */
111 TECB srhsrm; /* Ptr to short reference map. */
113 #define SRHSZ (sizeof(struct srh))
114 typedef struct srh *PSRH; /* Ptr to short reference map header. */
115 #define SRMNULL (&dumpecb) /* Dummy ptr to empty short reference map. */
117 /* Definitions for ENTOPEN/ENTREF return codes.
119 #define ENTUNDEF -1 /* Callers of ENTOPEN: entity undefined. */
120 #define ENTLOOP -2 /* ENTOPEN: endless loop entity. */
121 #define ENTMAX -3 /* ENTOPEN: too many open entities. */
122 #define ENTFILE -4 /* ENTOPEN: file I/O error. */
123 #define ENTDATA -5 /* ENTOPEN: CDATA or SDATA entity. */
124 #define ENTPI -6 /* ENTOPEN: PI entity. */
126 /* Definitions for ENTDATA switches set in contersw.
128 #define CDECONT 2 /* 0010 CDATA entity referenced. */
129 #define SDECONT 4 /* 0100 SDATA entity referenced. */
130 #define NDECONT 8 /* 1000 NDATA entity referenced. */
132 /* Definitions for manipulating signed source character counters.
134 #define CTRSET(CTR) (CTR = (int) -(FPOS+1-FBUF)) /* Init source char ctr. */
135 #define CTRGET(CTR) (CTR + (int) (FPOS+1-FBUF)) /* Read source char ctr. */