First attempt at debianization
[erwise] / Cl / WWWLibrary / SGML.h
1 /*              SGML Parser definitions                         SGML.h
2 **              =======================
3 **
4 **      The SGML parser is a state machine. It is called for every character
5 **      of the input stream. The DTD data structure contains pointers
6 **      to functions which are called to implement the actual effect of the
7 **      text read. When these functions are called, the attribute structures
8 **      pointed to by the DTD are valid, and the function is passed
9 **      a pointer to the curent tag structure, and an
10 **      "element stack" which represents the state of nesting within SGML
11 **      elements.
12 */
13 /*      (c) Copyright CERN 1991 - See Copyright.html
14 */
15
16 #ifndef SGML_H
17 #define SGML_H
18
19 typedef struct {
20     char *      name;           /* The (constant) name of the attribute */
21     BOOL        present;        /* Was attribute specified for this tag? */
22     char *      value;          /* Malloced. Valid only if present is YES. */
23 } attr;
24
25
26 /*              A tag structure describes an SGML element.
27 **              -----------------------------------------
28 **
29 **      If the tag has an end tag, then treat and end must be non-zero.
30 **      If the tag does not, they must be zero.
31 **
32 **      name            is the string which comes after the tag opener "<".
33 **
34 **      attributes      points to a zero-terminated array
35 **                      of attribute structures filled in by the parser.
36 **
37 **      style           is a pointer left for use by oter modules (typically
38 **                      for storing the style used with this element)
39 **
40 **      litteral        determines how the SGML engine parses the charaters
41 **                      within the element. If set, tag openers are ignored
42 **                      except for that which opens a matching closing tag.
43 **
44 **      begin           is called when the tag has been parsed, and the
45 **                      attribute values set. The element pointer points
46 **                      to the top of the new element stack.
47 **
48 **      treat           is a pointer to a function which is called for
49 **                      each text character within the element.
50 **
51 **      end             is called when the end tag has been parsed.
52 **                      The element pointer points to the top of the
53 **                      new element stack.
54 */
55 typedef struct _tag HTTag;
56 typedef struct _HTElement HTElement;
57 struct _tag{
58     char * name;                /* The name of the tag */
59     attr * attributes;          /* The list of acceptable attributes */
60     void * style;               /* Not used by the SGML engine */
61     BOOL  litteral;             /* End only on end tag @@ */            
62     void (*begin) PARAMS((HTTag * t, HTElement * e));   /* Action on begin tag */
63     void (*treat) PARAMS((char c));     /* Action when character is parsed */
64     void (*end) PARAMS((HTTag * t, HTElement * e));     /* Action on </tag> or 0 if empty */
65 };
66
67 /*      Stack of previous tags:
68 **
69 **      This allows us to return down the stack reselcting styles.
70 **      As we return, attribute values will be garbage in general.
71 */
72 struct _HTElement {
73         HTElement *     next;   /* Previously nested element or 0 */
74         HTTag   *       tag;    /* The tag at this level */
75         void *          info;   /* Free to be used by caller only */
76 };
77
78
79 typedef struct _entity {
80     char * name;
81     char * representation;
82 } entity;
83
84 typedef struct {
85     HTTag *     tags;
86     HTTag *     default_tag;
87     entity *    entities;
88 } SGML_dtd;
89
90
91 /*      Initialise the SGML parser
92 **
93 ** On entry,
94 **      dtd     must point to a DTD structure as defined above
95 ** On exit,
96 **              The default tag starter has been processed.
97 */
98
99 extern void  SGML_begin PARAMS((SGML_dtd * dtd));
100
101
102 /*      Crank the SGML parser
103 **
104 ** On entry,
105 **      dtd     must point to a DTD structure as defined above.
106 **              SGML_begin must have been called on it.
107 **
108 **      c       is the next character of the input stream
109 */
110
111 extern void  SGML_character PARAMS((SGML_dtd * dtd, char c));
112
113
114 /*      Finish the SGML parser
115 **
116 ** On entry,
117 **      dtd     must point to a DTD structure as defined above
118 **              SGML_begin must have been called on it.
119 ** On exit,
120 **              The document will be completed.
121 **              SGML_begin must be called again before any
122 **              more parsing is done.
123 */
124
125 extern void  SGML_end PARAMS((SGML_dtd * dtd));
126
127
128
129 #endif  /* SGML_H */