-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathparser.h
104 lines (92 loc) · 3.89 KB
/
parser.h
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
/*
* parser.h -- Parser functions for HTML expressions.
*
* AltF4 - Jan 14, 2002
*
*/
#ifndef __PARSER_C__
#define __PARSER_C__
#ifdef __PUREC__
# undef PARSER
typedef struct s_parser * PARSER;
#endif
struct s_parser {
LOADER Loader;
CONTAINR Target;
FRAME Frame;
BOOL hasStyle;
PARSESUB Current;
WCHAR * Watermark; /* points to the last position that can be written, */
/* 10 bytes reserve behind the high watermark */
void * ResumeFnc; /* fields to store data for the case that a parser */
const char * ResumePtr; /* function needs to get a break (eg. for loading */
short ResumeErr; /* additional files) */
};
PARSER new_parser (LOADER);
void delete_parser (PARSER);
int parser_resume (PARSER, void * func, const char * ptr_or_sub);
/* Prepares the parser for getting interupted and stores the data
* needed for the later resume. If the location is not NULL it will
* be used to start a loader job.
*/
#define parser_resumed(parser) parser_resume (parser, NULL,NULL);
/* Shortcut, resets the resume data fields.
*/
#ifdef HTMLTAG
HTMLTAG parse_tag (PARSER, const char ** pptr);
/* Parses a html TAG expression of the forms
* <TAG> | <TAG KEY ...> | <TAG KEY=VALUE ...>
* The 'pptr' content must point to the first character after the
* leading '<' and a possibly '/'. After processing it is set to
* first character behind the expression, either behind the closing
* '>' or to a trailing '\0'.
* If successful the found known KEYs are stored with their VALUEs
* internally and a TAG enum is returned.
* Else the symbol TAG_Unknown is returned.
* The PARSER argument may be NULL if no KEY storage is needed.
*/
const char * parse_css (PARSER, LOCATION, const char * ptr);
/* Parses a whole <style> area from 'ptr' and stores recognized
* style set internallly in the parser structure. Following
* get_value..() calls will be served from these sets automatically.
* The result value is a pointer to the first not read character
* from 'ptr'.
*/
BOOL get_value (PARSER, HTMLKEY, char * output, const size_t max_len);
/* Finds the VALUE of 'key' that was read while the last parse()
* call. If successful the VALUE will be copied to 'output' up to
* 'max_len' character (including the trailing '\0') and a TRUE
* will be returned. Else a FALSE will be returned.
*/
#define get_value_exists( p, key ) get_value (p, key, NULL,0)
/* A shorthand that returns TRUE if 'key' was found at all while the
* last parse() call.
*/
char * get_value_str (PARSER, HTMLKEY);
/* Returns the VALUE of 'key' that was read while the last parse()
* call as a malloc'ed zero terminated character string. If not
* successful the result is a NULL pointer.
*/
char get_value_char (PARSER, HTMLKEY);
/* Returns the first character of the VALUE of 'key' that was read
* while the last parse() call. If not successful a '\0' will be
* returned.
*/
WORD get_value_unum (PARSER, HTMLKEY, WORD dflt);
/* Returns the VALUE of 'key' that was read while the last parse()
* call as a unsigned short. If not successful the value of 'dflt'
* will be returned instead, which may also be negative.
*/
WORD get_value_size (PARSER, HTMLKEY);
/* Returns the VALUE of 'key' that was read while the last parse()
* call as a signed short. On success the return value is either a
* positive absolute number or a negative fractional of -1024 if a
* trailing '%' was found. Else a zero will be returned.
*/
WORD get_value_color (PARSER, HTMLKEY);
/* Returns the VDI color VALUE of 'key' that was read while the last
* parse() call. If not successful a negative number will be
* returned.
*/
#endif /*HTMLTAG*/
#endif /*__PARSER_C__*/