-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.h
More file actions
117 lines (98 loc) · 3.58 KB
/
Copy pathparser.h
File metadata and controls
117 lines (98 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* parser.h */
/*
* @(#)highwire/parser.h
*
* parser.h -- Definitions for the HTML parser.
*
* AltF4 - Jan 14, 2002
* GenAI Refactor - July 13, 2025
*
* MODIFIED: This header has been updated to reflect the new parser
* architecture. All legacy CSS parsing structures have been removed.
* The PARSER struct now contains a memory arena for efficient attribute
* handling and a simplified TEXTBUFF structure.
*/
#ifndef __PARSER_H__
#define __PARSER_H__
#include "defs.h"
#include "fontbase.h"
/* Forward declarations */
typedef struct s_loader * LOADER;
typedef struct s_dombox DOMBOX;
typedef struct s_table_stack * TBLSTACK;
typedef struct s_form * FORM;
typedef struct s_maparea ** MAPAREA_P;
/*
* GenAI: Moved from parser.c to make them public.
* These are needed by render.c and style.c
*/
#ifdef LATTICE /* get rid of compiler bitfield bug */
# define BF16(t,n) UWORD n
#else
# define BF16(t,n) t n :16
#endif
typedef struct {
BF16(HTMLKEY, Key);
BF16(unsigned, Len);
const char * Value;
} KEYVALUE;
/*
* The main PARSER object. It holds the loader, target container, the frame
* being built, and the current text processing buffer. It also contains
* resume information for handling asynchronous operations like loading
* external stylesheets.
*/
typedef struct s_parser {
LOADER Loader;
CONTAINR Target;
FRAME Frame;
TEXTBUFF Current;
BOOL hasStyle; /* Set to TRUE if any style information is found */
WCHAR * Watermark; /* High-water mark for the text buffer to prevent overflow */
void * ResumeFnc; /* Function to call upon resuming */
const char * ResumePtr; /* Pointer to resume parsing from */
short ResumeErr; /* Error code from a paused operation */
} * PARSER;
/*============================================================================*/
/* PUBLIC FUNCTIONS */
/*============================================================================*/
/*
* Creates a new parser instance for a given loader object.
*/
PARSER new_parser (LOADER);
/*
* Destroys a parser instance and frees all associated memory, including
* the new memory arena.
*/
void delete_parser (PARSER);
/*
* Prepares the parser to be interrupted for an asynchronous operation.
*/
int parser_resume (PARSER, void * func, const char * ptr_or_sub);
#define parser_resumed(parser) parser_resume (parser, NULL, NULL)
/*
* Parses an HTML tag expression, extracts all attributes into an internal
* table, and returns the tag's enum identifier. The parser's internal
* memory arena is used for attribute values, which is reset for each new tag.
*/
HTMLTAG parse_tag (PARSER, const char ** pptr);
/* GenAI: Added public prototype for find_key */
KEYVALUE * find_key (PARSER parser, HTMLKEY key);
/*
* Functions to retrieve attribute values that were parsed by the last call
* to parse_tag(). These functions search the parser's internal KeyValTab.
*/
BOOL get_value (PARSER, HTMLKEY key, char * out, size_t max);
#define get_value_exists(p,k) get_value(p,k,NULL,0)
char * get_value_str (PARSER, HTMLKEY key);
char get_value_char (PARSER, HTMLKEY key);
WORD get_value_unum (PARSER, HTMLKEY key, WORD dflt);
WORD get_value_size (PARSER, HTMLKEY key);
WORD get_value_color (PARSER, HTMLKEY key);
/*
* Main parsing entry points. These are passed to the scheduler to run.
*/
int parse_html (void * arg, long invalidated);
int parse_plain (void * arg, long invalidated);
int parse_image (void * arg, long invalidated);
#endif /* __PARSER_H__ */