1 /* retawq/parser.h - content parsing (HTML, ...)
2    This file is part of retawq (<http://retawq.sourceforge.net/>), a network
3    client created by Arne Thomassen; retawq is basically released under certain
4    versions of the GNU General Public License and WITHOUT ANY WARRANTY.
5    Read the file COPYING for license details, README for program information.
6    Copyright (C) 2001-2005 Arne Thomassen <arne@arne-thomassen.de>
7 */
8 
9 #ifndef __retawq_parser_h__
10 #define __retawq_parser_h__
11 
12 #include "stuff.h"
13 #include "resource.h"
14 #if CONFIG_JAVASCRIPT
15 #include "javascript.h"
16 #endif
17 
18 /* begin-autogenerated */
19 enum
20 { htkText = 0, /* a very special tag kind :-) */
21   htkA = 1, htkAddress = 2, htkArea = 3, htkB = 4, htkBig = 5,
22   htkBlockquote = 6, htkBody = 7, htkBr = 8, htkButton = 9, htkCaption = 10,
23   htkCenter = 11, htkCite = 12, htkDd = 13, htkDel = 14, htkDfn = 15,
24   htkDir = 16, htkDiv = 17, htkDl = 18, htkDt = 19, htkEm = 20,
25   htkFieldset = 21, htkFont = 22, htkForm = 23, htkFrame = 24,
26   htkFrameset = 25, htkH1 = 26, htkH2 = 27, htkH3 = 28, htkH4 = 29, htkH5 = 30,
27   htkH6 = 31, htkHead = 32, htkHr = 33, htkHtml = 34, htkI = 35,
28   htkIframe = 36, htkImg = 37, htkInput = 38, htkLi = 39, htkMenu = 40,
29   htkMeta = 41, htkNoframes = 42, htkNoscript = 43, htkObject = 44, htkOl = 45,
30   htkOptgroup = 46, htkOption = 47, htkP = 48, htkPre = 49, htkQ = 50,
31   htkS = 51, htkScript = 52, htkSelect = 53, htkStrike = 54, htkStrong = 55,
32   htkStyle = 56, htkSub = 57, htkSup = 58, htkTable = 59, htkTd = 60,
33   htkTextarea = 61, htkTh = 62, htkTitle = 63, htkTr = 64, htkU = 65,
34   htkUl = 66,
35   htkInvalid = 255
36 };
37 typedef unsigned char tHtmlTagKind;
38 
39 my_enum1 enum
40 { anUnknown = 0,
41   anAction = 1, anAlign = 2, anAlt = 3, anChecked = 4, anColor = 5,
42   anContent = 6, anDeclare = 7, anDisabled = 8, anEnctype = 9, anFace = 10,
43   anHref = 11, anHttpEquiv = 12, anId = 13, anInternalTagname = 14,
44   anInternalText = 15, anLabel = 16, anMaxlength = 17, anMethod = 18,
45   anMultiple = 19, anName = 20, anReadonly = 21, anSelected = 22, anSize = 23,
46   anSrc = 24, anTitle = 25, anType = 26, anValue = 27, anWidth = 28
47 /* #if CONFIG_CSS */
48   , anClass = 29, anMedia = 30, anStyle = 31
49 /* #endif */
50 /* #if CONFIG_JAVASCRIPT */
51   , anLanguage = 32
52 /* #endif */
53 } my_enum2(unsigned char) tAttributeName;
54 #define NUM_ATTRNAMES (33) /* (ignores anJavascript stuff) */
55 #if CONFIG_JAVASCRIPT
56 #define anJavascriptBegin (33)
57 #define is_an_for_javascript(an) ( ((an) >= anJavascriptBegin) && \
58   ((an) <= anJavascriptBegin + JAVASCRIPT_MAX_EVENT_CODE) )
59 #endif
60 /* end-autogenerated */
61 
62 typedef struct tAttribute
63 { struct tAttribute* next;
64   char* value;
65   tAttributeName name;
66 } tAttribute;
67 
68 my_enum1 enum
69 { hnfNone = 0, hnfIsEndtag = 0x01, hnfTagblockEnds = 0x02,
70   hnfStoredInTree = 0x04, hnfHasAeBase = 0x08, hnfAlignLeft = 0x10,
71   hnfAlignCenter = 0x20, hnfAlignRight = 0x40, hnfGoodForm = 0x80
72 } my_enum2(unsigned char) tHtmlNodeFlags;
73 #define hnfAlignAny (hnfAlignLeft | hnfAlignCenter | hnfAlignRight)
74 
75 typedef struct tHtmlNode
76 { struct tHtmlNode* next;
77   void* data; /* text (char*) or attribute list head (tAttribute*) */
78   tHtmlNodeFlags flags;
79   tHtmlTagKind kind;
80 } tHtmlNode;
81 
82 #define aenum_incvalue(max) \
83   ( ((max) >= 1000) ? 1000 : (((max) >= 100) ? 100 : 20) )
84 
85 my_enum1 enum
86 { hofNone = 0, hofSelected = 0x01, hofDisabled = 0x02, hofOptgroupStart = 0x04
87 } my_enum2(unsigned char) tHtmlOptionFlags;
88 typedef tHtmlInputLength tHtmlOptionNumber;
89 
90 typedef struct tHtmlOption
91 { struct tHtmlOption* next;
92   char *value, *render;
93   tHtmlOptionFlags flags;
94 } tHtmlOption;
95 
96 extern void deallocate_html_node(const tHtmlNode*);
97 extern void deallocate_one_aebase(const tActiveElementBase*);
98 
99 extern tBoolean htk_forbids_endtag(const tHtmlTagKind);
100 extern tBoolean htk_forbids_pre(const tHtmlTagKind);
101 extern tBoolean htk_is_block(const tHtmlTagKind);
102 extern tBoolean htk_is_par(const tHtmlTagKind);
103 
104 extern void parser_html_start(tCantent*);
105 extern const tHtmlNode* parser_html_next(tBoolean);
106 extern void parser_html_finish(void);
107 
108 extern void parser_initialize(void);
109 
110 #endif /* #ifndef __retawq_parser_h__ */
111