HTMLPARS.H
[目次 | 型・クラス・構造体 | マクロ]
1|/**************************************************************************
2|* 1. <<< HTML パーサ (HtmlPars) >>>
3|***************************************************************************/
4|
5|#ifndef __HTMLPARS_H
6|#define __HTMLPARS_H
7|
8|
9|/*************************************************************************
10|* 2. <<< 優先ヘッダ >>>
11|**************************************************************************/
12|#ifndef USES_PRIORITY_HEADER
13|/*[START_OF_PRIORITY_HEADER]*/
14|
15|#define USES_HTMLPARS
16|typedef struct _HtmlPars HtmlPars;
17|
18|/*[END_OF_PRIORITY_HEADER]*/
19|#endif
20|
21|/* 派生属性の設定 */
22|#if defined(HTMLPARS_SOME)
23| #define HTMLPARS_OTHER
24|#endif
25|
26|/*************************************************************************
27|* 3. <<< エラーコード, リターンコード >>>
28|**************************************************************************/
29|
30|#define HtmlPars_Err_Some 0
31|#define HtmlPars_Err_UnexpectedEOF 1724
32|
33|/* 4. <<< [HtmlPars用トークンタイプ] >>> */
34|#define HtmlPars_StartOfTag 1
35|#define HtmlPars_EndOfTag 2
36|
37|/*--------------------------------------------------------------*/
38|/*5. <<< Interface Area -------------------------------------- >>> */
39|/*--------------------------------------------------------------*/
40|
41|#ifdef __cplusplus
42|extern "C" {
43|#endif
44|
45|
46|/**************************************************************************
47|* 6. <<< [HtmlPars] HTML パーサ >>>
48|*【補足】
49|*・(未記入)
50|*【内部補足】
51|*・attr_names と attr_vars は連続したメモリ領域の前半と後半に割り当てられます。
52|* attr_names + attr_n が attr_vars に達したら万杯です。
53|***************************************************************************/
54|struct _HtmlPars {
55| BLex3_EngineU* engU; /* 字句解析エンジン, NULL=未指定 */
56|
57| BLex3_Pos parsedPos; /* パースが済んだ位置の次のアドレス */
58| int prevTokenType;
59| bool bInTag;
60|
61| /* Tag Attributes */
62| char* name; /* タグ名(メイン)・小文字に変換済 */
63| char** attr_names; /* 属性名(サブ)の配列の先頭アドレス・小文字に変換済 */
64| char** attr_values; /* 属性の値の配列の先頭アドレス(→内部補足) */
65| int attr_n; /* 属性の数 */
66| char endCh; /* タグ終端文字 '>' の前の文字、'\0' or '/' or '?' */
67|
68| /* Memory Area */
69| StrX_Mem mem;
70|
71| ERRORS_INITCHK_VAR
72|};
73|
74|void HtmlPars_init( HtmlPars*, void* mem, int mem_size,
75| char** mem2, int mem2_size );
76|#ifndef ERRORS_CUT_DEBUG_TOOL
77| void HtmlPars_print( HtmlPars*, const char* title );
78|#endif
79|
80|void HtmlPars_linkEngine( HtmlPars*, BLex3_EngineU* engU );
81|void HtmlPars_parse( HtmlPars* );
82|int HtmlPars_getTokenType( HtmlPars* );
83|void HtmlPars_getNextParsePos( HtmlPars*, BLex3_Pos* pos );
84|bool HtmlPars_isInTag( HtmlPars* );
85|char* HtmlPars_getName( HtmlPars* );
86|char* HtmlPars_getValue( HtmlPars*, const char* attr_name );
87|/*
88|int HtmlPars_getTokenFirstPos( HtmlPars* );
89|int HtmlPars_getTokenOverPos( HtmlPars* );
90|*/
91|void HtmlPars_printLastMsg( HtmlPars*, FILE* f, const char* title );
92|
93|
94|#ifdef __cplusplus
95|}
96|#endif
97|
98|/*--------------------------------------------------------------*/
99|/*7. <<< Mapping Area ---------------------------------------- >>> */
100|/*--------------------------------------------------------------*/
101|
102|
103|/**************************************************************************
104|* 8. <<< [HtmlPars_getName] タグ名を返す >>>
105|*【補足】
106|*・char* HtmlPars_getName( HtmlPars* );
107|*・小文字に変換したタグ名が返ります。
108|***************************************************************************/
109|#define HtmlPars_getName( this ) \
110| ( (this)->name )
111|
112|#endif /* __HTMLPARS_H */
113|
114|