-rw-r--r-- | libkcal/versit/port.h | 15 | ||||
-rw-r--r-- | libkcal/versit/vcc.c | 1491 | ||||
-rw-r--r-- | libkcal/versit/vcc.h | 12 | ||||
-rw-r--r-- | libkcal/versit/vobject.c | 297 | ||||
-rw-r--r-- | libkcal/versit/vobject.h | 173 |
5 files changed, 1084 insertions, 904 deletions
diff --git a/libkcal/versit/port.h b/libkcal/versit/port.h index afc16dd..1768bee 100644 --- a/libkcal/versit/port.h +++ b/libkcal/versit/port.h | |||
@@ -30,46 +30,59 @@ INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE | |||
30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
31 | PURPOSE. | 31 | PURPOSE. |
32 | 32 | ||
33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or | 33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or |
34 | disclosure by the government are subject to restrictions set forth in | 34 | disclosure by the government are subject to restrictions set forth in |
35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | 35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. |
36 | 36 | ||
37 | ***************************************************************************/ | 37 | ***************************************************************************/ |
38 | 38 | ||
39 | #ifndef __PORT_H__ | 39 | #ifndef __PORT_H__ |
40 | #define __PORT_H__ 1 | 40 | #define __PORT_H__ 1 |
41 | 41 | ||
42 | |||
42 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) | 43 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) |
43 | extern "C" { | 44 | extern "C" { |
44 | #endif | 45 | #endif |
45 | 46 | ||
47 | /* some of these #defines are commented out because */ | ||
48 | /* Visual C++ sets them on the compiler command line instead */ | ||
49 | |||
50 | /* #define _DEBUG */ | ||
51 | /* #define WIN32 */ | ||
52 | /* #define WIN16 */ | ||
53 | /* #define _WINDOWS */ | ||
54 | /* #define __MWERKS__ */ | ||
55 | /* #define INCLUDEMFC */ | ||
56 | |||
46 | #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard" | 57 | #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard" |
47 | #define vCalendarClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCalendar" | 58 | #define vCalendarClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCalendar" |
48 | 59 | ||
49 | /* The above strings vCardClipboardFormat and vCalendarClipboardFormat | 60 | /* The above strings vCardClipboardFormat and vCalendarClipboardFormat |
50 | are globally unique IDs which can be used to generate clipboard format | 61 | are globally unique IDs which can be used to generate clipboard format |
51 | ID's as per the requirements of a specific platform. For example, in | 62 | ID's as per the requirements of a specific platform. For example, in |
52 | Windows they are used as the parameter in a call to RegisterClipboardFormat. | 63 | Windows they are used as the parameter in a call to RegisterClipboardFormat. |
53 | For example: | 64 | For example: |
54 | 65 | ||
55 | CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat); | 66 | CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat); |
56 | 67 | ||
57 | */ | 68 | */ |
58 | 69 | ||
59 | #define vCardMimeType "text/x-vCard" | 70 | #define vCardMimeType "text/x-vCard" |
60 | #define vCalendarMimeType "text/x-vCalendar" | 71 | #define vCalendarMimeType "text/x-vCalendar" |
61 | 72 | ||
73 | #define DLLEXPORT(t) t | ||
74 | |||
62 | #ifndef FALSE | 75 | #ifndef FALSE |
63 | #define FALSE 0 | 76 | #define FALSE 0 |
64 | #endif | 77 | #endif |
65 | #ifndef TRUE | 78 | #ifndef TRUE |
66 | #define TRUE 1 | 79 | #define TRUE 1 |
67 | #endif | 80 | #endif |
68 | 81 | ||
69 | #define Parse_Debug(t) | 82 | #define stricmp strcasecmp |
70 | 83 | ||
71 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) | 84 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) |
72 | } | 85 | } |
73 | #endif | 86 | #endif |
74 | 87 | ||
75 | #endif /* __PORT_H__ */ | 88 | #endif /* __PORT_H__ */ |
diff --git a/libkcal/versit/vcc.c b/libkcal/versit/vcc.c index 350cac3..9be752d 100644 --- a/libkcal/versit/vcc.c +++ b/libkcal/versit/vcc.c | |||
@@ -1,42 +1,37 @@ | |||
1 | 1 | /* A Bison parser, made from vcc.y | |
2 | /* A Bison parser, made from ./vcc.y | 2 | by GNU bison 1.35. */ |
3 | by GNU Bison version 1.28 */ | ||
4 | 3 | ||
5 | #define YYBISON 1 /* Identify Bison output. */ | 4 | #define YYBISON 1 /* Identify Bison output. */ |
6 | 5 | ||
7 | #ifdef _WIN32_ | ||
8 | #define strcasecmp _stricmp | ||
9 | #endif | ||
10 | |||
11 | #define EQ257 | 6 | #define EQ257 |
12 | #define COLON258 | 7 | #define COLON258 |
13 | #define DOT259 | 8 | #define DOT259 |
14 | #define SEMICOLON260 | 9 | #define SEMICOLON260 |
15 | #define SPACE261 | 10 | #define SPACE261 |
16 | #define HTAB262 | 11 | #define HTAB262 |
17 | #define LINESEP263 | 12 | #define LINESEP263 |
18 | #define NEWLINE264 | 13 | #define NEWLINE264 |
19 | #define BEGIN_VCARD265 | 14 | #define BEGIN_VCARD265 |
20 | #define END_VCARD266 | 15 | #define END_VCARD266 |
21 | #define BEGIN_VCAL267 | 16 | #define BEGIN_VCAL267 |
22 | #define END_VCAL268 | 17 | #define END_VCAL268 |
23 | #define BEGIN_VEVENT269 | 18 | #define BEGIN_VEVENT269 |
24 | #define END_VEVENT270 | 19 | #define END_VEVENT270 |
25 | #define BEGIN_VTODO271 | 20 | #define BEGIN_VTODO271 |
26 | #define END_VTODO272 | 21 | #define END_VTODO272 |
27 | #define ID273 | 22 | #define ID273 |
28 | #define STRING274 | 23 | #define STRING274 |
29 | 24 | ||
30 | #line 1 "./vcc.y" | 25 | #line 1 "vcc.y" |
31 | 26 | ||
32 | 27 | ||
33 | /*************************************************************************** | 28 | /*************************************************************************** |
34 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International | 29 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International |
35 | Business Machines Corporation and Siemens Rolm Communications Inc. | 30 | Business Machines Corporation and Siemens Rolm Communications Inc. |
36 | 31 | ||
37 | For purposes of this license notice, the term Licensors shall mean, | 32 | For purposes of this license notice, the term Licensors shall mean, |
38 | collectively, Apple Computer, Inc., AT&T Corp., International | 33 | collectively, Apple Computer, Inc., AT&T Corp., International |
39 | Business Machines Corporation and Siemens Rolm Communications Inc. | 34 | Business Machines Corporation and Siemens Rolm Communications Inc. |
40 | The term Licensor shall mean any of the Licensors. | 35 | The term Licensor shall mean any of the Licensors. |
41 | 36 | ||
42 | Subject to acceptance of the following conditions, permission is hereby | 37 | Subject to acceptance of the following conditions, permission is hereby |
@@ -77,24 +72,29 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
77 | * in a debugger. However, if a bug is found it should | 72 | * in a debugger. However, if a bug is found it should |
78 | * be fixed in vcc.y and this file regenerated. | 73 | * be fixed in vcc.y and this file regenerated. |
79 | */ | 74 | */ |
80 | 75 | ||
81 | 76 | ||
82 | /* debugging utilities */ | 77 | /* debugging utilities */ |
83 | #if __DEBUG | 78 | #if __DEBUG |
84 | #define DBG_(x) printf x | 79 | #define DBG_(x) printf x |
85 | #else | 80 | #else |
86 | #define DBG_(x) | 81 | #define DBG_(x) |
87 | #endif | 82 | #endif |
88 | 83 | ||
84 | #ifdef WIN32 | ||
85 | #define snprintf _snprintf | ||
86 | #define strcasecmp stricmp | ||
87 | #endif | ||
88 | |||
89 | /**** External Functions ****/ | 89 | /**** External Functions ****/ |
90 | 90 | ||
91 | /* assign local name to parser variables and functions so that | 91 | /* assign local name to parser variables and functions so that |
92 | we can use more than one yacc based parser. | 92 | we can use more than one yacc based parser. |
93 | */ | 93 | */ |
94 | 94 | ||
95 | #define yyparse mime_parse | 95 | #define yyparse mime_parse |
96 | #define yylex mime_lex | 96 | #define yylex mime_lex |
97 | #define yyerror mime_error | 97 | #define yyerror mime_error |
98 | #define yychar mime_char | 98 | #define yychar mime_char |
99 | /* #define p_yyval p_mime_val */ | 99 | /* #define p_yyval p_mime_val */ |
100 | #undef yyval | 100 | #undef yyval |
@@ -111,737 +111,895 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
111 | #define yyvsp mime_vsp | 111 | #define yyvsp mime_vsp |
112 | #define yylhs mime_lhs | 112 | #define yylhs mime_lhs |
113 | #define yylen mime_len | 113 | #define yylen mime_len |
114 | #define yydefred mime_defred | 114 | #define yydefred mime_defred |
115 | #define yydgoto mime_dgoto | 115 | #define yydgoto mime_dgoto |
116 | #define yysindex mime_sindex | 116 | #define yysindex mime_sindex |
117 | #define yyrindex mime_rindex | 117 | #define yyrindex mime_rindex |
118 | #define yygindex mime_gindex | 118 | #define yygindex mime_gindex |
119 | #define yytable mime_table | 119 | #define yytable mime_table |
120 | #define yycheck mime_check | 120 | #define yycheck mime_check |
121 | #define yyname mime_name | 121 | #define yyname mime_name |
122 | #define yyrule mime_rule | 122 | #define yyrule mime_rule |
123 | #undef YYPREFIX | ||
124 | #define YYPREFIX "mime_" | 123 | #define YYPREFIX "mime_" |
125 | 124 | ||
126 | 125 | ||
127 | #ifndef _NO_LINE_FOLDING | 126 | #ifndef _NO_LINE_FOLDING |
128 | #define _SUPPORT_LINE_FOLDING 1 | 127 | #define _SUPPORT_LINE_FOLDING 1 |
129 | #endif | 128 | #endif |
130 | 129 | ||
131 | #include <string.h> | 130 | /* undef below if compile with MFC */ |
132 | #ifndef __FreeBSD__ | 131 | /* #define INCLUDEMFC 1 */ |
133 | #include <malloc.h> | 132 | |
133 | #if defined(WIN32) || defined(_WIN32) | ||
134 | #ifdef INCLUDEMFC | ||
135 | #include <afx.h> | ||
136 | #endif | ||
134 | #endif | 137 | #endif |
138 | |||
139 | #include <string.h> | ||
135 | #include <stdio.h> | 140 | #include <stdio.h> |
136 | #include <stdlib.h> | 141 | #include <stdlib.h> |
137 | #include <ctype.h> | 142 | #include <ctype.h> |
138 | #include "vcc.h" | 143 | #include "vcc.h" |
139 | 144 | ||
140 | /* The following is a hack that I hope will get things compiling | ||
141 | * on SunOS 4.1.x systems | ||
142 | */ | ||
143 | #ifndef SEEK_SET | ||
144 | #define SEEK_SET 0 /* Seek from beginning of file. */ | ||
145 | #define SEEK_CUR 1 /* Seek from current position. */ | ||
146 | #define SEEK_END 2 /* Seek from end of file. */ | ||
147 | #endif | ||
148 | |||
149 | /**** Types, Constants ****/ | 145 | /**** Types, Constants ****/ |
150 | 146 | ||
151 | #define YYDEBUG 0/* 1 to compile in some debugging code */ | 147 | #define YYDEBUG 1/* 1 to compile in some debugging code */ |
152 | #define MAXTOKEN 256/* maximum token (line) length */ | 148 | #define MAXTOKEN 256/* maximum token (line) length */ |
153 | #define YYSTACKSIZE 1000/* ~unref ? */ | 149 | #define YYSTACKSIZE 50/* ~unref ? */ |
154 | #define MAXLEVEL 10/* max # of nested objects parseable */ | 150 | #define MAXLEVEL 10/* max # of nested objects parseable */ |
155 | /* (includes outermost) */ | 151 | /* (includes outermost) */ |
156 | 152 | ||
157 | 153 | ||
158 | /**** Global Variables ****/ | 154 | /**** Global Variables ****/ |
159 | int mime_lineNum, mime_numErrors; /* yyerror() can use these */ | 155 | int mime_lineNum, mime_numErrors; /* yyerror() can use these */ |
160 | static VObject* vObjList; | 156 | static VObject* vObjList; |
161 | static VObject *curProp; | 157 | static VObject *curProp; |
162 | static VObject *curObj; | 158 | static VObject *curObj; |
163 | static VObject* ObjStack[MAXLEVEL]; | 159 | static VObject* ObjStack[MAXLEVEL]; |
164 | static int ObjStackTop; | 160 | static int ObjStackTop; |
165 | 161 | ||
166 | 162 | ||
167 | /* A helpful utility for the rest of the app. */ | 163 | /* A helpful utility for the rest of the app. */ |
168 | #if __CPLUSPLUS__ | 164 | #if __CPLUSPLUS__ |
169 | extern "C" { | 165 | extern "C" { |
170 | #endif | 166 | #endif |
171 | 167 | ||
172 | /* static void Parse_Debug(const char *s);*/ | 168 | extern void Parse_Debug(const char *s); |
173 | static void yyerror(char *s); | 169 | static void yyerror(char *s); |
174 | 170 | ||
175 | #if __CPLUSPLUS__ | 171 | #if __CPLUSPLUS__ |
176 | }; | 172 | }; |
177 | #endif | 173 | #endif |
178 | 174 | ||
179 | int yyparse(); | 175 | int yyparse(); |
180 | static int yylex(); | 176 | |
181 | enum LexMode { | 177 | enum LexMode { |
182 | L_NORMAL, | 178 | L_NORMAL, |
183 | L_VCARD, | 179 | L_VCARD, |
184 | L_VCAL, | 180 | L_VCAL, |
185 | L_VEVENT, | 181 | L_VEVENT, |
186 | L_VTODO, | 182 | L_VTODO, |
187 | L_VALUES, | 183 | L_VALUES, |
188 | L_BASE64, | 184 | L_BASE64, |
189 | L_QUOTED_PRINTABLE | 185 | L_QUOTED_PRINTABLE |
190 | }; | 186 | }; |
191 | 187 | ||
192 | /**** Private Forward Declarations ****/ | 188 | /**** Private Forward Declarations ****/ |
193 | static int pushVObject(const char *prop); | 189 | static int pushVObject(const char *prop); |
194 | static VObject* popVObject(); | 190 | static VObject* popVObject(); |
195 | char* lexDataFromBase64(); | ||
196 | static void lexPopMode(int top); | 191 | static void lexPopMode(int top); |
197 | static int lexWithinMode(enum LexMode mode); | 192 | static int lexWithinMode(enum LexMode mode); |
198 | static void lexPushMode(enum LexMode mode); | 193 | static void lexPushMode(enum LexMode mode); |
199 | static void enterProps(const char *s); | 194 | static void enterProps(const char *s); |
200 | static void enterAttr(const char *s1, const char *s2); | 195 | static void enterAttr(const char *s1, const char *s2); |
201 | /* static void enterValues(const char *value); */ | 196 | static void enterValues(const char *value); |
202 | static void appendValue(const char *value); | ||
203 | static void mime_error_(char *s); | 197 | static void mime_error_(char *s); |
204 | 198 | ||
205 | 199 | ||
206 | #line 181 "./vcc.y" | 200 | #line 180 "vcc.y" |
201 | #ifndef YYSTYPE | ||
207 | typedef union { | 202 | typedef union { |
208 | char *str; | 203 | char *str; |
209 | VObject *vobj; | 204 | VObject *vobj; |
210 | } YYSTYPE; | 205 | } yystype; |
211 | #include <stdio.h> | 206 | # define YYSTYPE yystype |
212 | 207 | # define YYSTYPE_IS_TRIVIAL 1 | |
213 | #ifndef __cplusplus | ||
214 | #ifndef __STDC__ | ||
215 | #define const | ||
216 | #endif | 208 | #endif |
209 | #ifndef YYDEBUG | ||
210 | # define YYDEBUG 0 | ||
217 | #endif | 211 | #endif |
218 | 212 | ||
219 | 213 | ||
220 | 214 | ||
221 | #define YYFINAL 62 | 215 | #define YYFINAL 62 |
222 | #define YYFLAG -32768 | 216 | #define YYFLAG -32768 |
223 | #define YYNTBASE21 | 217 | #define YYNTBASE21 |
224 | 218 | ||
219 | /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ | ||
225 | #define YYTRANSLATE(x) ((unsigned)(x) <= 274 ? yytranslate[x] : 51) | 220 | #define YYTRANSLATE(x) ((unsigned)(x) <= 274 ? yytranslate[x] : 51) |
226 | 221 | ||
227 | static const char yytranslate[] = { 0, | 222 | /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ |
228 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 223 | static const char yytranslate[] = |
224 | { | ||
225 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
229 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 226 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
230 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 227 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
231 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 228 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
232 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 229 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
233 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 230 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
234 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 231 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
235 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 232 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
236 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 233 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
237 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 234 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
238 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 235 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
239 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 236 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
240 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 237 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
241 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 238 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
242 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 239 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
243 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 240 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
244 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 241 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
245 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 242 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
246 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 243 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
247 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 244 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
248 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 245 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
249 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 246 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
250 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 247 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
251 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 248 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
252 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 249 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
253 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, | 250 | 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, |
254 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, | 251 | 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
255 | 17, 18, 19, 20 | 252 | 16, 17, 18, 19, 20 |
256 | }; | 253 | }; |
257 | 254 | ||
258 | #if YYDEBUG != 0 | 255 | #if YYDEBUG |
259 | static const short yyprhs[] = { 0, | 256 | static const short yyprhs[] = |
260 | 0, 2, 3, 7, 9, 11, 13, 14, 19, 20, | 257 | { |
261 | 24, 27, 29, 30, 36, 38, 39, 43, 45, 48, | 258 | 0, 0, 2, 3, 7, 9, 11, 13, 14, 19, |
262 | 50, 53, 55, 59, 61, 62, 67, 69, 71, 72, | 259 | 20, 24, 27, 29, 30, 36, 38, 39, 43, 45, |
263 | 73, 78, 79, 83, 86, 88, 90, 92, 94, 95, | 260 | 48, 50, 53, 55, 59, 61, 62, 67, 69, 71, |
264 | 100, 101, 105, 106, 111, 112 | 261 | 72, 73, 78, 79, 83, 86, 88, 90, 92, 94, |
262 | 95, 100, 101, 105, 106, 111, 112 | ||
265 | }; | 263 | }; |
266 | 264 | static const short yyrhs[] = | |
267 | static const short yyrhs[] = { 22, | 265 | { |
268 | 0, 0, 24, 23, 22, 0, 24, 0, 25, 0, | 266 | 22, 0, 0, 24, 23, 22, 0, 24, 0, 25, |
269 | 40, 0, 0, 11, 26, 28, 12, 0, 0, 11, | 267 | 0, 40, 0, 0, 11, 26, 28, 12, 0, 0, |
270 | 27, 12, 0, 29, 28, 0, 29, 0, 0, 31, | 268 | 11, 27, 12, 0, 29, 28, 0, 29, 0, 0, |
271 | 4, 30, 37, 9, 0, 1, 0, 0, 36, 32, | 269 | 31, 4, 30, 37, 9, 0, 1, 0, 0, 36, |
272 | 33, 0, 36, 0, 34, 33, 0, 34, 0, 6, | 270 | 32, 33, 0, 36, 0, 34, 33, 0, 34, 0, |
273 | 35, 0, 36, 0, 36, 3, 36, 0, 19, 0, | 271 | 6, 35, 0, 36, 0, 36, 3, 36, 0, 19, |
274 | 0, 39, 6, 38, 37, 0, 39, 0, 20, 0, | 272 | 0, 0, 39, 6, 38, 37, 0, 39, 0, 20, |
275 | 0, 0, 13, 41, 43, 14, 0, 0, 13, 42, | 273 | 0, 0, 0, 13, 41, 43, 14, 0, 0, 13, |
276 | 14, 0, 44, 43, 0, 44, 0, 45, 0, 48, | 274 | 42, 14, 0, 44, 43, 0, 44, 0, 45, 0, |
277 | 0, 28, 0, 0, 15, 46, 28, 16, 0, 0, | 275 | 48, 0, 28, 0, 0, 15, 46, 28, 16, 0, |
278 | 15, 47, 16, 0, 0, 17, 49, 28, 18, 0, | 276 | 0, 15, 47, 16, 0, 0, 17, 49, 28, 18, |
279 | 0, 17, 50, 18, 0 | 277 | 0, 0, 17, 50, 18, 0 |
280 | }; | 278 | }; |
281 | 279 | ||
282 | #endif | 280 | #endif |
283 | 281 | ||
284 | #if YYDEBUG != 0 | 282 | #if YYDEBUG |
285 | static const short yyrline[] = { 0, | 283 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
286 | 209, 212, 215, 215, 219, 220, 223, 229, 234, 240, | 284 | static const short yyrline[] = |
287 | 246, 247, 250, 254, 260, 263, 268, 268, 274, 275, | 285 | { |
288 | 278, 281, 285, 292, 295, 296, 296, 300, 301, 305, | 286 | 0, 208, 211, 211, 214, 218, 219, 222, 222, 233, |
289 | 309, 311, 314, 317, 318, 321, 323, 324, 327, 334, | 287 | 233, 245, 246, 249, 249, 259, 262, 262, 267, 273, |
290 | 339, 345, 351, 358, 363, 369 | 288 | 274, 277, 280, 284, 291, 294, 294, 295, 299, 300, |
289 | 303, 303, 309, 309, 315, 316, 319, 321, 322, 325, | ||
290 | 325, 337, 337, 349, 349, 361, 361 | ||
291 | }; | 291 | }; |
292 | #endif | 292 | #endif |
293 | 293 | ||
294 | 294 | ||
295 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) | 295 | #if (YYDEBUG) || defined YYERROR_VERBOSE |
296 | 296 | ||
297 | static const char * const yytname[] = { "$","error","$undefined.","EQ","COLON", | 297 | /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ |
298 | "DOT","SEMICOLON","SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD", | 298 | static const char *const yytname[] = |
299 | "BEGIN_VCAL","END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO", | 299 | { |
300 | "ID","STRING","mime","vobjects","@1","vobject","vcard","@2","@3","items","item", | 300 | "$", "error", "$undefined.", "EQ", "COLON", "DOT", "SEMICOLON", "SPACE", |
301 | "@4","prop","@5","attr_params","attr_param","attr","name","values","@6","value", | 301 | "HTAB", "LINESEP", "NEWLINE", "BEGIN_VCARD", "END_VCARD", "BEGIN_VCAL", |
302 | "vcal","@7","@8","calitems","calitem","eventitem","@9","@10","todoitem","@11", | 302 | "END_VCAL", "BEGIN_VEVENT", "END_VEVENT", "BEGIN_VTODO", "END_VTODO", |
303 | "@12", NULL | 303 | "ID", "STRING", "mime", "vobjects", "@1", "vobject", "vcard", "@2", |
304 | "@3", "items", "item", "@4", "prop", "@5", "attr_params", "attr_param", | ||
305 | "attr", "name", "values", "@6", "value", "vcal", "@7", "@8", "calitems", | ||
306 | "calitem", "eventitem", "@9", "@10", "todoitem", "@11", "@12", 0 | ||
304 | }; | 307 | }; |
305 | #endif | 308 | #endif |
306 | 309 | ||
307 | static const short yyr1[] = { 0, | 310 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
308 | 21, 23, 22, 22, 24, 24, 26, 25, 27, 25, | 311 | static const short yyr1[] = |
309 | 28, 28, 30, 29, 29, 32, 31, 31, 33, 33, | 312 | { |
310 | 34, 35, 35, 36, 38, 37, 37, 39, 39, 41, | 313 | 0, 21, 23, 22, 22, 24, 24, 26, 25, 27, |
311 | 40, 42, 40, 43, 43, 44, 44, 44, 46, 45, | 314 | 25, 28, 28, 30, 29, 29, 32, 31, 31, 33, |
312 | 47, 45, 49, 48, 50, 48 | 315 | 33, 34, 35, 35, 36, 38, 37, 37, 39, 39, |
316 | 41, 40, 42, 40, 43, 43, 44, 44, 44, 46, | ||
317 | 45, 47, 45, 49, 48, 50, 48 | ||
313 | }; | 318 | }; |
314 | 319 | ||
315 | static const short yyr2[] = { 0, | 320 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
316 | 1, 0, 3, 1, 1, 1, 0, 4, 0, 3, | 321 | static const short yyr2[] = |
317 | 2, 1, 0, 5, 1, 0, 3, 1, 2, 1, | 322 | { |
318 | 2, 1, 3, 1, 0, 4, 1, 1, 0, 0, | 323 | 0, 1, 0, 3, 1, 1, 1, 0, 4, 0, |
319 | 4, 0, 3, 2, 1, 1, 1, 1, 0, 4, | 324 | 3, 2, 1, 0, 5, 1, 0, 3, 1, 2, |
320 | 0, 3, 0, 4, 0, 3 | 325 | 1, 2, 1, 3, 1, 0, 4, 1, 1, 0, |
326 | 0, 4, 0, 3, 2, 1, 1, 1, 1, 0, | ||
327 | 4, 0, 3, 0, 4, 0, 3 | ||
321 | }; | 328 | }; |
322 | 329 | ||
323 | static const short yydefact[] = { 0, | 330 | /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE |
324 | 7, 30, 1, 2, 5, 6, 0, 0, 0, 0, | 331 | doesn't specify something else to do. Zero means the default is an |
325 | 0, 15, 24, 0, 0, 0, 16, 10, 39, 43, | 332 | error. */ |
326 | 38, 0, 0, 36, 37, 33, 3, 8, 11, 13, | 333 | static const short yydefact[] = |
327 | 0, 0, 0, 0, 0, 31, 34, 29, 0, 17, | 334 | { |
328 | 20, 0, 42, 0, 46, 28, 0, 27, 21, 22, | 335 | 0, 7, 30, 1, 2, 5, 6, 0, 0, 0, |
329 | 19, 40, 44, 14, 25, 0, 29, 23, 26, 0, | 336 | 0, 0, 15, 24, 0, 0, 0, 16, 10, 39, |
330 | 0, 0 | 337 | 43, 38, 0, 0, 36, 37, 33, 3, 8, 11, |
338 | 13, 0, 0, 0, 0, 0, 31, 34, 29, 0, | ||
339 | 17, 20, 0, 42, 0, 46, 28, 0, 27, 21, | ||
340 | 22, 19, 40, 44, 14, 25, 0, 29, 23, 26, | ||
341 | 0, 0, 0 | ||
331 | }; | 342 | }; |
332 | 343 | ||
333 | static const short yydefgoto[] = { 60, | 344 | static const short yydefgoto[] = |
334 | 3, 11, 4, 5, 7, 8, 21, 15, 38, 16, | 345 | { |
335 | 31, 40, 41, 49, 17, 47, 57, 48, 6, 9, | 346 | 60, 3, 11, 4, 5, 7, 8, 21, 15, 38, |
336 | 10, 22, 23, 24, 32, 33, 25, 34, 35 | 347 | 16, 31, 40, 41, 49, 17, 47, 57, 48, 6, |
348 | 9, 10, 22, 23, 24, 32, 33, 25, 34, 35 | ||
337 | }; | 349 | }; |
338 | 350 | ||
339 | static const short yypact[] = { -9, | 351 | static const short yypact[] = |
340 | -6, -5,-32768, 7,-32768,-32768, 2, -1, 19, 15, | 352 | { |
341 | -9,-32768,-32768, 1, 0, 26, 27,-32768, 16, 17, | 353 | -9, -6, -5,-32768, 7,-32768,-32768, 2, -1, 19, |
342 | -32768, 23, 9,-32768,-32768,-32768,-32768,-32768,-32768,-32768, | 354 | 15, -9,-32768,-32768, 1, 0, 26, 27,-32768, 16, |
343 | 33, 2, 24, 2, 25,-32768,-32768, 13, 22,-32768, | 355 | 17,-32768, 23, 9,-32768,-32768,-32768,-32768,-32768,-32768, |
344 | 33, 28,-32768, 29,-32768,-32768, 36, 40,-32768, 39, | 356 | -32768, 33, 2, 24, 2, 25,-32768,-32768, 13, 22, |
345 | -32768,-32768,-32768,-32768,-32768, 22, 13,-32768,-32768, 48, | 357 | -32768, 33, 28,-32768, 29,-32768,-32768, 36, 40,-32768, |
346 | 49,-32768 | 358 | 39,-32768,-32768,-32768,-32768,-32768, 22, 13,-32768,-32768, |
359 | 48, 49,-32768 | ||
347 | }; | 360 | }; |
348 | 361 | ||
349 | static const short yypgoto[] = {-32768, | 362 | static const short yypgoto[] = |
350 | 41,-32768,-32768,-32768,-32768,-32768, -7,-32768,-32768,-32768, | 363 | { |
351 | -32768, 10,-32768,-32768, -34, -4,-32768,-32768,-32768,-32768, | 364 | -32768, 41,-32768,-32768,-32768,-32768,-32768, -7,-32768,-32768, |
352 | -32768, 31,-32768,-32768,-32768,-32768,-32768,-32768,-32768 | 365 | -32768,-32768, 10,-32768,-32768, -34, -4,-32768,-32768,-32768, |
366 | -32768,-32768, 31,-32768,-32768,-32768,-32768,-32768,-32768,-32768 | ||
353 | }; | 367 | }; |
354 | 368 | ||
355 | 369 | ||
356 | #define YYLAST 54 | 370 | #define YYLAST 54 |
357 | 371 | ||
358 | 372 | ||
359 | static const short yytable[] = { 14, | 373 | static const short yytable[] = |
360 | 12, 1, 12, 2, 50, -9, -4, 29, -32, 12, | 374 | { |
361 | 18, -12, 28, -12, -12, -12, -12, -12, 13, 12, | 375 | 14, 12, 1, 12, 2, 50, -9, -4, 29, -32, |
362 | 13, 58, -35, 19, 42, 20, 44, 13, 26, 30, | 376 | 12, 18, -12, 28, -12, -12, -12, -12, -12, 13, |
363 | -18, -41, 46, 19, -45, 20, 36, 13, 39, 43, | 377 | 12, 13, 58, -35, 19, 42, 20, 44, 13, 26, |
364 | 13, 56, 45, 52, 54, 55, 53, 61, 62, 0, | 378 | 30, -18, -41, 46, 19, -45, 20, 36, 13, 39, |
365 | 51, 27, 59, 37 | 379 | 43, 13, 56, 45, 52, 54, 55, 53, 61, 62, |
380 | 0, 51, 27, 59, 37 | ||
366 | }; | 381 | }; |
367 | 382 | ||
368 | static const short yycheck[] = { 7, | 383 | static const short yycheck[] = |
369 | 1, 11, 1, 13, 39, 12, 0, 15, 14, 1, | 384 | { |
370 | 12, 12, 12, 14, 15, 16, 17, 18, 19, 1, | 385 | 7, 1, 11, 1, 13, 39, 12, 0, 15, 14, |
371 | 19, 56, 14, 15, 32, 17, 34, 19, 14, 4, | 386 | 1, 12, 12, 12, 14, 15, 16, 17, 18, 19, |
372 | 4, 16, 20, 15, 18, 17, 14, 19, 6, 16, | 387 | 1, 19, 56, 14, 15, 32, 17, 34, 19, 14, |
373 | 19, 3, 18, 16, 9, 6, 18, 0, 0, -1, | 388 | 4, 4, 16, 20, 15, 18, 17, 14, 19, 6, |
374 | 41, 11, 57, 23 | 389 | 16, 19, 3, 18, 16, 9, 6, 18, 0, 0, |
390 | -1, 41, 11, 57, 23 | ||
375 | }; | 391 | }; |
376 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ | 392 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
377 | #line 3 "/usr/share/bison.simple" | 393 | #line 3 "/usr/share/bison/bison.simple" |
378 | /* This file comes from bison-1.28. */ | ||
379 | 394 | ||
380 | /* Skeleton output parser for bison, | 395 | /* Skeleton output parser for bison, |
381 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. | 396 | |
397 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software | ||
398 | Foundation, Inc. | ||
382 | 399 | ||
383 | This program is free software; you can redistribute it and/or modify | 400 | This program is free software; you can redistribute it and/or modify |
384 | it under the terms of the GNU General Public License as published by | 401 | it under the terms of the GNU General Public License as published by |
385 | the Free Software Foundation; either version 2, or (at your option) | 402 | the Free Software Foundation; either version 2, or (at your option) |
386 | any later version. | 403 | any later version. |
387 | 404 | ||
388 | This program is distributed in the hope that it will be useful, | 405 | This program is distributed in the hope that it will be useful, |
389 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 406 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
390 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 407 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
391 | GNU General Public License for more details. | 408 | GNU General Public License for more details. |
392 | 409 | ||
393 | You should have received a copy of the GNU General Public License | 410 | You should have received a copy of the GNU General Public License |
394 | along with this program; if not, write to the Free Software | 411 | along with this program; if not, write to the Free Software |
395 | Foundation, Inc., 59 Temple Place - Suite 330, | 412 | Foundation, Inc., 59 Temple Place - Suite 330, |
396 | Boston, MA 02111-1307, USA. */ | 413 | Boston, MA 02111-1307, USA. */ |
397 | 414 | ||
398 | /* As a special exception, when this file is copied by Bison into a | 415 | /* As a special exception, when this file is copied by Bison into a |
399 | Bison output file, you may use that output file without restriction. | 416 | Bison output file, you may use that output file without restriction. |
400 | This special exception was added by the Free Software Foundation | 417 | This special exception was added by the Free Software Foundation |
401 | in version 1.24 of Bison. */ | 418 | in version 1.24 of Bison. */ |
402 | 419 | ||
403 | /* This is the parser code that is written into each bison parser | 420 | /* This is the parser code that is written into each bison parser when |
404 | when the %semantic_parser declaration is not specified in the grammar. | 421 | the %semantic_parser declaration is not specified in the grammar. |
405 | It was written by Richard Stallman by simplifying the hairy parser | 422 | It was written by Richard Stallman by simplifying the hairy parser |
406 | used when %semantic_parser is specified. */ | 423 | used when %semantic_parser is specified. */ |
407 | 424 | ||
425 | /* All symbols defined below should begin with yy or YY, to avoid | ||
426 | infringing on user name space. This should be done even for local | ||
427 | variables, as they might otherwise be expanded by user macros. | ||
428 | There are some unavoidable exceptions within include files to | ||
429 | define necessary library symbols; they are noted "INFRINGES ON | ||
430 | USER NAME SPACE" below. */ | ||
431 | |||
432 | #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) | ||
433 | |||
434 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | ||
435 | |||
436 | # if YYSTACK_USE_ALLOCA | ||
437 | # define YYSTACK_ALLOC alloca | ||
438 | # else | ||
408 | #ifndef YYSTACK_USE_ALLOCA | 439 | #ifndef YYSTACK_USE_ALLOCA |
409 | #ifdef alloca | 440 | # if defined (alloca) || defined (_ALLOCA_H) |
410 | #define YYSTACK_USE_ALLOCA | ||
411 | #else /* alloca not defined */ | ||
412 | #ifdef __GNUC__ | ||
413 | #define YYSTACK_USE_ALLOCA | ||
414 | #define alloca __builtin_alloca | ||
415 | #else /* not GNU C. */ | ||
416 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) | ||
417 | #define YYSTACK_USE_ALLOCA | ||
418 | #include <alloca.h> | ||
419 | #else /* not sparc */ | ||
420 | /* We think this test detects Watcom and Microsoft C. */ | ||
421 | /* This used to test MSDOS, but that is a bad idea | ||
422 | since that symbol is in the user namespace. */ | ||
423 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) | ||
424 | #if 0 /* No need for malloc.h, which pollutes the namespace; | ||
425 | instead, just don't use alloca. */ | ||
426 | #include <malloc.h> | ||
427 | #endif | ||
428 | #else /* not MSDOS, or __TURBOC__ */ | ||
429 | #if defined(_AIX) | ||
430 | /* I don't know what this was needed for, but it pollutes the namespace. | ||
431 | So I turned it off. rms, 2 May 1997. */ | ||
432 | /* #include <malloc.h> */ | ||
433 | #pragma alloca | ||
434 | #define YYSTACK_USE_ALLOCA | ||
435 | #else /* not MSDOS, or __TURBOC__, or _AIX */ | ||
436 | #if 0 | ||
437 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, | ||
438 | and on HPUX 10. Eventually we can turn this on. */ | ||
439 | #define YYSTACK_USE_ALLOCA | ||
440 | #define alloca __builtin_alloca | ||
441 | #endif /* __hpux */ | ||
442 | #endif | ||
443 | #endif /* not _AIX */ | ||
444 | #endif /* not MSDOS, or __TURBOC__ */ | ||
445 | #endif /* not sparc */ | ||
446 | #endif /* not GNU C */ | ||
447 | #endif /* alloca not defined */ | ||
448 | #endif /* YYSTACK_USE_ALLOCA not defined */ | ||
449 | |||
450 | #ifdef YYSTACK_USE_ALLOCA | ||
451 | #define YYSTACK_ALLOC alloca | 441 | #define YYSTACK_ALLOC alloca |
452 | #else | 442 | #else |
443 | # ifdef __GNUC__ | ||
444 | # define YYSTACK_ALLOC __builtin_alloca | ||
445 | # endif | ||
446 | # endif | ||
447 | # endif | ||
448 | # endif | ||
449 | |||
450 | # ifdef YYSTACK_ALLOC | ||
451 | /* Pacify GCC's `empty if-body' warning. */ | ||
452 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) | ||
453 | # else | ||
454 | # if defined (__STDC__) || defined (__cplusplus) | ||
455 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
456 | # define YYSIZE_T size_t | ||
457 | # endif | ||
453 | #define YYSTACK_ALLOC malloc | 458 | #define YYSTACK_ALLOC malloc |
459 | # define YYSTACK_FREE free | ||
460 | # endif | ||
461 | #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ | ||
462 | |||
463 | |||
464 | #if (! defined (yyoverflow) \ | ||
465 | && (! defined (__cplusplus) \ | ||
466 | || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) | ||
467 | |||
468 | /* A type that is properly aligned for any stack member. */ | ||
469 | union yyalloc | ||
470 | { | ||
471 | short yyss; | ||
472 | YYSTYPE yyvs; | ||
473 | # if YYLSP_NEEDED | ||
474 | YYLTYPE yyls; | ||
475 | # endif | ||
476 | }; | ||
477 | |||
478 | /* The size of the maximum gap between one aligned stack and the next. */ | ||
479 | # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) | ||
480 | |||
481 | /* The size of an array large to enough to hold all stacks, each with | ||
482 | N elements. */ | ||
483 | # if YYLSP_NEEDED | ||
484 | # define YYSTACK_BYTES(N) \ | ||
485 | ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))\ | ||
486 | + 2 * YYSTACK_GAP_MAX) | ||
487 | # else | ||
488 | # define YYSTACK_BYTES(N) \ | ||
489 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ | ||
490 | + YYSTACK_GAP_MAX) | ||
491 | # endif | ||
492 | |||
493 | /* Copy COUNT objects from FROM to TO. The source and destination do | ||
494 | not overlap. */ | ||
495 | # ifndef YYCOPY | ||
496 | # if 1 < __GNUC__ | ||
497 | # define YYCOPY(To, From, Count) \ | ||
498 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) | ||
499 | # else | ||
500 | # define YYCOPY(To, From, Count) \ | ||
501 | do \ | ||
502 | { \ | ||
503 | register YYSIZE_T yyi; \ | ||
504 | for (yyi = 0; yyi < (Count); yyi++)\ | ||
505 | (To)[yyi] = (From)[yyi]; \ | ||
506 | } \ | ||
507 | while (0) | ||
454 | #endif | 508 | #endif |
509 | # endif | ||
510 | |||
511 | /* Relocate STACK from its old location to the new one. The | ||
512 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | ||
513 | elements in the stack, and YYPTR gives the new location of the | ||
514 | stack. Advance YYPTR to a properly aligned location for the next | ||
515 | stack. */ | ||
516 | # define YYSTACK_RELOCATE(Stack) \ | ||
517 | do \ | ||
518 | { \ | ||
519 | YYSIZE_T yynewbytes; \ | ||
520 | YYCOPY (&yyptr->Stack, Stack, yysize); \ | ||
521 | Stack = &yyptr->Stack; \ | ||
522 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;\ | ||
523 | yyptr += yynewbytes / sizeof (*yyptr); \ | ||
524 | } \ | ||
525 | while (0) | ||
455 | 526 | ||
456 | /* Note: there must be only one dollar sign in this file. | 527 | #endif |
457 | It is replaced by the list of actions, each action | 528 | |
458 | as one case of the switch. */ | 529 | |
530 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) | ||
531 | # define YYSIZE_T __SIZE_TYPE__ | ||
532 | #endif | ||
533 | #if ! defined (YYSIZE_T) && defined (size_t) | ||
534 | # define YYSIZE_T size_t | ||
535 | #endif | ||
536 | #if ! defined (YYSIZE_T) | ||
537 | # if defined (__STDC__) || defined (__cplusplus) | ||
538 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | ||
539 | # define YYSIZE_T size_t | ||
540 | # endif | ||
541 | #endif | ||
542 | #if ! defined (YYSIZE_T) | ||
543 | # define YYSIZE_T unsigned int | ||
544 | #endif | ||
459 | 545 | ||
460 | #define yyerrok (yyerrstatus = 0) | 546 | #define yyerrok (yyerrstatus = 0) |
461 | #define yyclearin(yychar = YYEMPTY) | 547 | #define yyclearin(yychar = YYEMPTY) |
462 | #define YYEMPTY -2 | 548 | #define YYEMPTY -2 |
463 | #define YYEOF 0 | 549 | #define YYEOF 0 |
464 | #define YYACCEPTgoto yyacceptlab | 550 | #define YYACCEPTgoto yyacceptlab |
465 | #define YYABORT goto yyabortlab | 551 | #define YYABORT goto yyabortlab |
466 | #define YYERROR goto yyerrlab1 | 552 | #define YYERROR goto yyerrlab1 |
467 | /* Like YYERROR except do call yyerror. | 553 | /* Like YYERROR except do call yyerror. This remains here temporarily |
468 | This remains here temporarily to ease the | 554 | to ease the transition to the new meaning of YYERROR, for GCC. |
469 | transition to the new meaning of YYERROR, for GCC. | ||
470 | Once GCC version 2 has supplanted version 1, this can go. */ | 555 | Once GCC version 2 has supplanted version 1, this can go. */ |
471 | #define YYFAIL goto yyerrlab | 556 | #define YYFAIL goto yyerrlab |
472 | #define YYRECOVERING() (!!yyerrstatus) | 557 | #define YYRECOVERING() (!!yyerrstatus) |
473 | #define YYBACKUP(token, value) \ | 558 | #define YYBACKUP(Token, Value) \ |
474 | do \ | 559 | do \ |
475 | if (yychar == YYEMPTY && yylen == 1) \ | 560 | if (yychar == YYEMPTY && yylen == 1) \ |
476 | { yychar = (token), yylval = (value); \ | 561 | { \ |
562 | yychar = (Token); \ | ||
563 | yylval = (Value); \ | ||
477 | yychar1 = YYTRANSLATE (yychar); \ | 564 | yychar1 = YYTRANSLATE (yychar); \ |
478 | YYPOPSTACK; \ | 565 | YYPOPSTACK; \ |
479 | goto yybackup; \ | 566 | goto yybackup; \ |
480 | } \ | 567 | } \ |
481 | else \ | 568 | else \ |
482 | { yyerror ("syntax error: cannot back up"); YYERROR; }\ | 569 | { \ |
570 | yyerror ("syntax error: cannot back up"); \ | ||
571 | YYERROR; \ | ||
572 | } \ | ||
483 | while (0) | 573 | while (0) |
484 | 574 | ||
485 | #define YYTERROR1 | 575 | #define YYTERROR1 |
486 | #define YYERRCODE256 | 576 | #define YYERRCODE256 |
487 | 577 | ||
488 | #ifndef YYPURE | 578 | |
489 | #define YYLEX yylex() | 579 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions |
580 | are run). | ||
581 | |||
582 | When YYLLOC_DEFAULT is run, CURRENT is set the location of the | ||
583 | first token. By default, to implement support for ranges, extend | ||
584 | its range to the last symbol. */ | ||
585 | |||
586 | #ifndef YYLLOC_DEFAULT | ||
587 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | ||
588 | Current.last_line = Rhs[N].last_line;\ | ||
589 | Current.last_column = Rhs[N].last_column; | ||
490 | #endif | 590 | #endif |
491 | 591 | ||
492 | #ifdef YYPURE | 592 | |
493 | #ifdef YYLSP_NEEDED | 593 | /* YYLEX -- calling `yylex' with the right arguments. */ |
594 | |||
595 | #if YYPURE | ||
596 | # if YYLSP_NEEDED | ||
494 | #ifdef YYLEX_PARAM | 597 | #ifdef YYLEX_PARAM |
495 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) | 598 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
496 | #else | 599 | #else |
497 | #define YYLEX yylex(&yylval, &yylloc) | 600 | #define YYLEX yylex(&yylval, &yylloc) |
498 | #endif | 601 | #endif |
499 | #else /* not YYLSP_NEEDED */ | 602 | # else /* !YYLSP_NEEDED */ |
500 | #ifdef YYLEX_PARAM | 603 | #ifdef YYLEX_PARAM |
501 | #define YYLEX yylex(&yylval, YYLEX_PARAM) | 604 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
502 | #else | 605 | #else |
503 | #define YYLEX yylex(&yylval) | 606 | #define YYLEX yylex(&yylval) |
504 | #endif | 607 | #endif |
505 | #endif /* not YYLSP_NEEDED */ | 608 | # endif /* !YYLSP_NEEDED */ |
506 | #endif | 609 | #else /* !YYPURE */ |
507 | 610 | # define YYLEX yylex () | |
508 | /* If nonreentrant, generate the variables here */ | 611 | #endif /* !YYPURE */ |
509 | |||
510 | #ifndef YYPURE | ||
511 | |||
512 | int yychar; /* the lookahead symbol */ | ||
513 | YYSTYPE yylval; /* the semantic value of the */ | ||
514 | /* lookahead symbol */ | ||
515 | 612 | ||
516 | #ifdef YYLSP_NEEDED | ||
517 | YYLTYPE yylloc; /* location data for the lookahead*/ | ||
518 | /* symbol */ | ||
519 | #endif | ||
520 | 613 | ||
521 | int yynerrs; /* number of parse errors so far */ | 614 | /* Enable debugging if requested. */ |
522 | #endif /* not YYPURE */ | 615 | #if YYDEBUG |
523 | 616 | ||
524 | #if YYDEBUG != 0 | 617 | # ifndef YYFPRINTF |
525 | int yydebug; /* nonzero means print parse trace*/ | 618 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
526 | /* Since this is uninitialized, it does not stop multiple parsers | 619 | # define YYFPRINTF fprintf |
527 | from coexisting. */ | ||
528 | #endif | 620 | #endif |
529 | 621 | ||
530 | /* YYINITDEPTH indicates the initial size of the parser's stacks*/ | 622 | # define YYDPRINTF(Args) \ |
531 | 623 | do { \ | |
624 | if (yydebug) \ | ||
625 | YYFPRINTF Args; \ | ||
626 | } while (0) | ||
627 | /* Nonzero means print parse trace. It is left uninitialized so that | ||
628 | multiple parsers can coexist. */ | ||
629 | int yydebug; | ||
630 | #else /* !YYDEBUG */ | ||
631 | # define YYDPRINTF(Args) | ||
632 | #endif /* !YYDEBUG */ | ||
633 | |||
634 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | ||
532 | #ifndefYYINITDEPTH | 635 | #ifndefYYINITDEPTH |
533 | #define YYINITDEPTH 200 | 636 | #define YYINITDEPTH 200 |
534 | #endif | 637 | #endif |
535 | 638 | ||
536 | /* YYMAXDEPTH is the maximum size the stacks can grow to | 639 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
537 | (effective only if the built-in stack extension method is used). */ | 640 | if the built-in stack extension method is used). |
641 | |||
642 | Do not make this value too large; the results are undefined if | ||
643 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) | ||
644 | evaluated with infinite-precision integer arithmetic. */ | ||
538 | 645 | ||
539 | #if YYMAXDEPTH == 0 | 646 | #if YYMAXDEPTH == 0 |
540 | #undef YYMAXDEPTH | 647 | #undef YYMAXDEPTH |
541 | #endif | 648 | #endif |
542 | 649 | ||
543 | #ifndef YYMAXDEPTH | 650 | #ifndef YYMAXDEPTH |
544 | #define YYMAXDEPTH 10000 | 651 | #define YYMAXDEPTH 10000 |
545 | #endif | 652 | #endif |
546 | 653 | ||
547 | /* Define __yy_memcpy. Note that the size argument | 654 | #ifdef YYERROR_VERBOSE |
548 | should be passed with type unsigned int, because that is what the non-GCC | ||
549 | definitions require. With GCC, __builtin_memcpy takes an arg | ||
550 | of type size_t, but it can handle unsigned int. */ | ||
551 | |||
552 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ | ||
553 | #define __yy_memcpy(TO,FROM,COUNT)__builtin_memcpy(TO,FROM,COUNT) | ||
554 | #else /* not GNU C or C++ */ | ||
555 | #ifndef __cplusplus | ||
556 | 655 | ||
557 | /* This is the most reliable way to avoid incompatibilities | 656 | # ifndef yystrlen |
558 | in available built-in functions on various systems. */ | 657 | # if defined (__GLIBC__) && defined (_STRING_H) |
559 | static void | 658 | # define yystrlen strlen |
560 | __yy_memcpy (to, from, count) | 659 | # else |
561 | char *to; | 660 | /* Return the length of YYSTR. */ |
562 | char *from; | 661 | static YYSIZE_T |
563 | unsigned int count; | 662 | # if defined (__STDC__) || defined (__cplusplus) |
663 | yystrlen (const char *yystr) | ||
664 | # else | ||
665 | yystrlen (yystr) | ||
666 | const char *yystr; | ||
667 | # endif | ||
564 | { | 668 | { |
565 | register char *f = from; | 669 | register const char *yys = yystr; |
566 | register char *t = to; | ||
567 | register int i = count; | ||
568 | 670 | ||
569 | while (i-- > 0) | 671 | while (*yys++ != '\0') |
570 | *t++ = *f++; | 672 | continue; |
571 | } | ||
572 | 673 | ||
573 | #else /* __cplusplus */ | 674 | return yys - yystr - 1; |
675 | } | ||
676 | # endif | ||
677 | # endif | ||
574 | 678 | ||
575 | /* This is the most reliable way to avoid incompatibilities | 679 | # ifndef yystpcpy |
576 | in available built-in functions on various systems. */ | 680 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
577 | static void | 681 | # define yystpcpy stpcpy |
578 | __yy_memcpy (char *to, char *from, unsigned int count) | 682 | # else |
683 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | ||
684 | YYDEST. */ | ||
685 | static char * | ||
686 | # if defined (__STDC__) || defined (__cplusplus) | ||
687 | yystpcpy (char *yydest, const char *yysrc) | ||
688 | # else | ||
689 | yystpcpy (yydest, yysrc) | ||
690 | char *yydest; | ||
691 | const char *yysrc; | ||
692 | # endif | ||
579 | { | 693 | { |
580 | register char *t = to; | 694 | register char *yyd = yydest; |
581 | register char *f = from; | 695 | register const char *yys = yysrc; |
582 | register int i = count; | ||
583 | 696 | ||
584 | while (i-- > 0) | 697 | while ((*yyd++ = *yys++) != '\0') |
585 | *t++ = *f++; | 698 | continue; |
586 | } | ||
587 | 699 | ||
700 | return yyd - 1; | ||
701 | } | ||
588 | #endif | 702 | #endif |
589 | #endif | 703 | #endif |
704 | #endif | ||
705 | |||
706 | #line 315 "/usr/share/bison/bison.simple" | ||
590 | 707 | ||
591 | #line 217 "/usr/share/bison.simple" | ||
592 | 708 | ||
593 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed | 709 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
594 | into yyparse. The argument should have type void *. | 710 | into yyparse. The argument should have type void *. |
595 | It should actually point to an object. | 711 | It should actually point to an object. |
596 | Grammar actions can access the variable by casting it | 712 | Grammar actions can access the variable by casting it |
597 | to the proper pointer type. */ | 713 | to the proper pointer type. */ |
598 | 714 | ||
599 | #ifdef YYPARSE_PARAM | 715 | #ifdef YYPARSE_PARAM |
600 | #ifdef __cplusplus | 716 | # if defined (__STDC__) || defined (__cplusplus) |
601 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM | 717 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
602 | #define YYPARSE_PARAM_DECL | 718 | #define YYPARSE_PARAM_DECL |
603 | #else /* not __cplusplus */ | 719 | # else |
604 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM | 720 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
605 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; | 721 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
606 | #endif /* not __cplusplus */ | 722 | # endif |
607 | #else /* not YYPARSE_PARAM */ | 723 | #else /* !YYPARSE_PARAM */ |
608 | #define YYPARSE_PARAM_ARG | 724 | #define YYPARSE_PARAM_ARG |
609 | #define YYPARSE_PARAM_DECL | 725 | #define YYPARSE_PARAM_DECL |
610 | #endif /* not YYPARSE_PARAM */ | 726 | #endif /* !YYPARSE_PARAM */ |
611 | 727 | ||
612 | /* Prevent warning if -Wstrict-prototypes. */ | 728 | /* Prevent warning if -Wstrict-prototypes. */ |
613 | #if defined (__GNUC__) && ! defined (__cplusplus) | 729 | #ifdef __GNUC__ |
614 | #ifdef YYPARSE_PARAM | 730 | #ifdef YYPARSE_PARAM |
615 | int yyparse (void *); | 731 | int yyparse (void *); |
616 | #else | 732 | #else |
617 | int yyparse (void); | 733 | int yyparse (void); |
618 | #endif | 734 | #endif |
619 | #endif | 735 | #endif |
620 | 736 | ||
737 | /* YY_DECL_VARIABLES -- depending whether we use a pure parser, | ||
738 | variables are global, or local to YYPARSE. */ | ||
739 | |||
740 | #define YY_DECL_NON_LSP_VARIABLES \ | ||
741 | /* The lookahead symbol. */ \ | ||
742 | int yychar; \ | ||
743 | \ | ||
744 | /* The semantic value of the lookahead symbol. */\ | ||
745 | YYSTYPE yylval; \ | ||
746 | \ | ||
747 | /* Number of parse errors so far. */ \ | ||
748 | int yynerrs; | ||
749 | |||
750 | #if YYLSP_NEEDED | ||
751 | # define YY_DECL_VARIABLES \ | ||
752 | YY_DECL_NON_LSP_VARIABLES \ | ||
753 | \ | ||
754 | /* Location data for the lookahead symbol. */\ | ||
755 | YYLTYPE yylloc; | ||
756 | #else | ||
757 | # define YY_DECL_VARIABLES \ | ||
758 | YY_DECL_NON_LSP_VARIABLES | ||
759 | #endif | ||
760 | |||
761 | |||
762 | /* If nonreentrant, generate the variables here. */ | ||
763 | |||
764 | #if !YYPURE | ||
765 | YY_DECL_VARIABLES | ||
766 | #endif /* !YYPURE */ | ||
767 | |||
621 | int | 768 | int |
622 | yyparse(YYPARSE_PARAM_ARG) | 769 | yyparse(YYPARSE_PARAM_ARG) |
623 | YYPARSE_PARAM_DECL | 770 | YYPARSE_PARAM_DECL |
624 | { | 771 | { |
772 | /* If reentrant, generate the variables here. */ | ||
773 | #if YYPURE | ||
774 | YY_DECL_VARIABLES | ||
775 | #endif /* !YYPURE */ | ||
776 | |||
625 | register int yystate; | 777 | register int yystate; |
626 | register int yyn; | 778 | register int yyn; |
779 | int yyresult; | ||
780 | /* Number of tokens to shift before error messages enabled. */ | ||
781 | int yyerrstatus; | ||
782 | /* Lookahead token as an internal (translated) token number. */ | ||
783 | int yychar1 = 0; | ||
784 | |||
785 | /* Three stacks and their tools: | ||
786 | `yyss': related to states, | ||
787 | `yyvs': related to semantic values, | ||
788 | `yyls': related to locations. | ||
789 | |||
790 | Refer to the stacks thru separate pointers, to allow yyoverflow | ||
791 | to reallocate them elsewhere. */ | ||
792 | |||
793 | /* The state stack. */ | ||
794 | shortyyssa[YYINITDEPTH]; | ||
795 | short *yyss = yyssa; | ||
627 | register short *yyssp; | 796 | register short *yyssp; |
628 | register YYSTYPE *yyvsp; | ||
629 | int yyerrstatus;/* number of tokens to shift before error messages enabled */ | ||
630 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ | ||
631 | |||
632 | short yyssa[YYINITDEPTH]; /* the state stack */ | ||
633 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ | ||
634 | 797 | ||
635 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ | 798 | /* The semantic value stack. */ |
636 | YYSTYPE *yyvs = yyvsa;/* to allow yyoverflow to reallocate them elsewhere */ | 799 | YYSTYPE yyvsa[YYINITDEPTH]; |
800 | YYSTYPE *yyvs = yyvsa; | ||
801 | register YYSTYPE *yyvsp; | ||
637 | 802 | ||
638 | #ifdef YYLSP_NEEDED | 803 | #if YYLSP_NEEDED |
639 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ | 804 | /* The location stack. */ |
805 | YYLTYPE yylsa[YYINITDEPTH]; | ||
640 | YYLTYPE *yyls = yylsa; | 806 | YYLTYPE *yyls = yylsa; |
641 | YYLTYPE *yylsp; | 807 | YYLTYPE *yylsp; |
808 | #endif | ||
642 | 809 | ||
810 | #if YYLSP_NEEDED | ||
643 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) | 811 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
644 | #else | 812 | #else |
645 | #define YYPOPSTACK (yyvsp--, yyssp--) | 813 | #define YYPOPSTACK (yyvsp--, yyssp--) |
646 | #endif | 814 | #endif |
647 | 815 | ||
648 | int yystacksize = YYINITDEPTH; | 816 | YYSIZE_T yystacksize = YYINITDEPTH; |
649 | int yyfree_stacks = 0; | ||
650 | 817 | ||
651 | #ifdef YYPURE | ||
652 | int yychar; | ||
653 | YYSTYPE yylval; | ||
654 | int yynerrs; | ||
655 | #ifdef YYLSP_NEEDED | ||
656 | YYLTYPE yylloc; | ||
657 | #endif | ||
658 | #endif | ||
659 | 818 | ||
660 | YYSTYPE yyval; /* the variable used to return */ | 819 | /* The variables used to return semantic value and location from the |
661 | /* semantic values from the action*/ | 820 | action routines. */ |
662 | /* routines */ | 821 | YYSTYPE yyval; |
822 | #if YYLSP_NEEDED | ||
823 | YYLTYPE yyloc; | ||
824 | #endif | ||
663 | 825 | ||
826 | /* When reducing, the number of symbols on the RHS of the reduced | ||
827 | rule. */ | ||
664 | int yylen; | 828 | int yylen; |
665 | 829 | ||
666 | #if YYDEBUG != 0 | 830 | YYDPRINTF ((stderr, "Starting parse\n")); |
667 | if (yydebug) | ||
668 | fprintf(stderr, "Starting parse\n"); | ||
669 | #endif | ||
670 | 831 | ||
671 | yystate = 0; | 832 | yystate = 0; |
672 | yyerrstatus = 0; | 833 | yyerrstatus = 0; |
673 | yynerrs = 0; | 834 | yynerrs = 0; |
674 | yychar = YYEMPTY; /* Cause a token to be read. */ | 835 | yychar = YYEMPTY; /* Cause a token to be read. */ |
675 | 836 | ||
676 | /* Initialize stack pointers. | 837 | /* Initialize stack pointers. |
677 | Waste one element of value and location stack | 838 | Waste one element of value and location stack |
678 | so that they stay on the same level as the state stack. | 839 | so that they stay on the same level as the state stack. |
679 | The wasted elements are never initialized. */ | 840 | The wasted elements are never initialized. */ |
680 | 841 | ||
681 | yyssp = yyss - 1; | 842 | yyssp = yyss; |
682 | yyvsp = yyvs; | 843 | yyvsp = yyvs; |
683 | #ifdef YYLSP_NEEDED | 844 | #if YYLSP_NEEDED |
684 | yylsp = yyls; | 845 | yylsp = yyls; |
685 | #endif | 846 | #endif |
847 | goto yysetstate; | ||
686 | 848 | ||
687 | /* Push a new state, which is found in yystate . */ | 849 | /*------------------------------------------------------------. |
688 | /* In all cases, when you get here, the value and location stacks | 850 | | yynewstate -- Push a new state, which is found in yystate. | |
689 | have just been pushed. so pushing a state here evens the stacks. */ | 851 | `------------------------------------------------------------*/ |
690 | yynewstate: | 852 | yynewstate: |
853 | /* In all cases, when you get here, the value and location stacks | ||
854 | have just been pushed. so pushing a state here evens the stacks. | ||
855 | */ | ||
856 | yyssp++; | ||
691 | 857 | ||
692 | *++yyssp = yystate; | 858 | yysetstate: |
859 | *yyssp = yystate; | ||
693 | 860 | ||
694 | if (yyssp >= yyss + yystacksize - 1) | 861 | if (yyssp >= yyss + yystacksize - 1) |
695 | { | 862 | { |
696 | /* Give user a chance to reallocate the stack */ | ||
697 | /* Use copies of these so that the &'s don't force the real ones into memory. */ | ||
698 | YYSTYPE *yyvs1 = yyvs; | ||
699 | short *yyss1 = yyss; | ||
700 | #ifdef YYLSP_NEEDED | ||
701 | YYLTYPE *yyls1 = yyls; | ||
702 | #endif | ||
703 | |||
704 | /* Get the current used size of the three stacks, in elements. */ | 863 | /* Get the current used size of the three stacks, in elements. */ |
705 | int size = yyssp - yyss + 1; | 864 | YYSIZE_T yysize = yyssp - yyss + 1; |
706 | 865 | ||
707 | #ifdef yyoverflow | 866 | #ifdef yyoverflow |
708 | /* Each stack pointer address is followed by the size of | 867 | { |
709 | the data in use in that stack, in bytes. */ | 868 | /* Give user a chance to reallocate the stack. Use copies of |
710 | #ifdef YYLSP_NEEDED | 869 | these so that the &'s don't force the real ones into |
870 | memory. */ | ||
871 | YYSTYPE *yyvs1 = yyvs; | ||
872 | short *yyss1 = yyss; | ||
873 | |||
874 | /* Each stack pointer address is followed by the size of the | ||
875 | data in use in that stack, in bytes. */ | ||
876 | # if YYLSP_NEEDED | ||
877 | YYLTYPE *yyls1 = yyls; | ||
711 | /* This used to be a conditional around just the two extra args, | 878 | /* This used to be a conditional around just the two extra args, |
712 | but that might be undefined if yyoverflow is a macro. */ | 879 | but that might be undefined if yyoverflow is a macro. */ |
713 | yyoverflow("parser stack overflow", | 880 | yyoverflow("parser stack overflow", |
714 | &yyss1, size * sizeof (*yyssp), | 881 | &yyss1, yysize * sizeof (*yyssp), |
715 | &yyvs1, size * sizeof (*yyvsp), | 882 | &yyvs1, yysize * sizeof (*yyvsp), |
716 | &yyls1, size * sizeof (*yylsp), | 883 | &yyls1, yysize * sizeof (*yylsp), |
717 | &yystacksize); | 884 | &yystacksize); |
885 | yyls = yyls1; | ||
718 | #else | 886 | #else |
719 | yyoverflow("parser stack overflow", | 887 | yyoverflow("parser stack overflow", |
720 | &yyss1, size * sizeof (*yyssp), | 888 | &yyss1, yysize * sizeof (*yyssp), |
721 | &yyvs1, size * sizeof (*yyvsp), | 889 | &yyvs1, yysize * sizeof (*yyvsp), |
722 | &yystacksize); | 890 | &yystacksize); |
723 | #endif | 891 | #endif |
724 | 892 | yyss = yyss1; | |
725 | yyss = yyss1; yyvs = yyvs1; | 893 | yyvs = yyvs1; |
726 | #ifdef YYLSP_NEEDED | 894 | } |
727 | yyls = yyls1; | ||
728 | #endif | ||
729 | #else /* no yyoverflow */ | 895 | #else /* no yyoverflow */ |
896 | # ifndef YYSTACK_RELOCATE | ||
897 | goto yyoverflowlab; | ||
898 | # else | ||
730 | /* Extend the stack our own way. */ | 899 | /* Extend the stack our own way. */ |
731 | if (yystacksize >= YYMAXDEPTH) | 900 | if (yystacksize >= YYMAXDEPTH) |
732 | { | 901 | goto yyoverflowlab; |
733 | yyerror("parser stack overflow"); | ||
734 | if (yyfree_stacks) | ||
735 | { | ||
736 | free (yyss); | ||
737 | free (yyvs); | ||
738 | #ifdef YYLSP_NEEDED | ||
739 | free (yyls); | ||
740 | #endif | ||
741 | } | ||
742 | return 2; | ||
743 | } | ||
744 | yystacksize *= 2; | 902 | yystacksize *= 2; |
745 | if (yystacksize > YYMAXDEPTH) | 903 | if (yystacksize > YYMAXDEPTH) |
746 | yystacksize = YYMAXDEPTH; | 904 | yystacksize = YYMAXDEPTH; |
747 | #ifndef YYSTACK_USE_ALLOCA | 905 | |
748 | yyfree_stacks = 1; | 906 | { |
749 | #endif | 907 | short *yyss1 = yyss; |
750 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); | 908 | union yyalloc *yyptr = |
751 | __yy_memcpy ((char *)yyss, (char *)yyss1, | 909 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
752 | size * (unsigned int) sizeof (*yyssp)); | 910 | if (! yyptr) |
753 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); | 911 | goto yyoverflowlab; |
754 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, | 912 | YYSTACK_RELOCATE (yyss); |
755 | size * (unsigned int) sizeof (*yyvsp)); | 913 | YYSTACK_RELOCATE (yyvs); |
756 | #ifdef YYLSP_NEEDED | 914 | # if YYLSP_NEEDED |
757 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); | 915 | YYSTACK_RELOCATE (yyls); |
758 | __yy_memcpy ((char *)yyls, (char *)yyls1, | 916 | # endif |
759 | size * (unsigned int) sizeof (*yylsp)); | 917 | # undef YYSTACK_RELOCATE |
918 | if (yyss1 != yyssa) | ||
919 | YYSTACK_FREE (yyss1); | ||
920 | } | ||
760 | #endif | 921 | #endif |
761 | #endif /* no yyoverflow */ | 922 | #endif /* no yyoverflow */ |
762 | 923 | ||
763 | yyssp = yyss + size - 1; | 924 | yyssp = yyss + yysize - 1; |
764 | yyvsp = yyvs + size - 1; | 925 | yyvsp = yyvs + yysize - 1; |
765 | #ifdef YYLSP_NEEDED | 926 | #if YYLSP_NEEDED |
766 | yylsp = yyls + size - 1; | 927 | yylsp = yyls + yysize - 1; |
767 | #endif | 928 | #endif |
768 | 929 | ||
769 | #if YYDEBUG != 0 | 930 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
770 | if (yydebug) | 931 | (unsigned long int) yystacksize)); |
771 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); | ||
772 | #endif | ||
773 | 932 | ||
774 | if (yyssp >= yyss + yystacksize - 1) | 933 | if (yyssp >= yyss + yystacksize - 1) |
775 | YYABORT; | 934 | YYABORT; |
776 | } | 935 | } |
777 | 936 | ||
778 | #if YYDEBUG != 0 | 937 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
779 | if (yydebug) | ||
780 | fprintf(stderr, "Entering state %d\n", yystate); | ||
781 | #endif | ||
782 | 938 | ||
783 | goto yybackup; | 939 | goto yybackup; |
940 | |||
941 | |||
942 | /*-----------. | ||
943 | | yybackup. | | ||
944 | `-----------*/ | ||
784 | yybackup: | 945 | yybackup: |
785 | 946 | ||
786 | /* Do appropriate processing given the current state. */ | 947 | /* Do appropriate processing given the current state. */ |
787 | /* Read a lookahead token if we need one and don't already have one. */ | 948 | /* Read a lookahead token if we need one and don't already have one. */ |
788 | /* yyresume: */ | 949 | /* yyresume: */ |
789 | 950 | ||
790 | /* First try to decide what to do without reference to lookahead token. */ | 951 | /* First try to decide what to do without reference to lookahead token. */ |
791 | 952 | ||
792 | yyn = yypact[yystate]; | 953 | yyn = yypact[yystate]; |
793 | if (yyn == YYFLAG) | 954 | if (yyn == YYFLAG) |
794 | goto yydefault; | 955 | goto yydefault; |
795 | 956 | ||
796 | /* Not known => get a lookahead token if don't already have one. */ | 957 | /* Not known => get a lookahead token if don't already have one. */ |
797 | 958 | ||
798 | /* yychar is either YYEMPTY or YYEOF | 959 | /* yychar is either YYEMPTY or YYEOF |
799 | or a valid token in external form. */ | 960 | or a valid token in external form. */ |
800 | 961 | ||
801 | if (yychar == YYEMPTY) | 962 | if (yychar == YYEMPTY) |
802 | { | 963 | { |
803 | #if YYDEBUG != 0 | 964 | YYDPRINTF ((stderr, "Reading a token: ")); |
804 | if (yydebug) | ||
805 | fprintf(stderr, "Reading a token: "); | ||
806 | #endif | ||
807 | yychar = YYLEX; | 965 | yychar = YYLEX; |
808 | } | 966 | } |
809 | 967 | ||
810 | /* Convert token to internal form (in yychar1) for indexing tables with */ | 968 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
811 | 969 | ||
812 | if (yychar <= 0) /* This means end of input. */ | 970 | if (yychar <= 0) /* This means end of input. */ |
813 | { | 971 | { |
814 | yychar1 = 0; | 972 | yychar1 = 0; |
815 | yychar = YYEOF; /* Don't call YYLEX any more */ | 973 | yychar = YYEOF; /* Don't call YYLEX any more */ |
816 | 974 | ||
817 | #if YYDEBUG != 0 | 975 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
818 | if (yydebug) | ||
819 | fprintf(stderr, "Now at end of input.\n"); | ||
820 | #endif | ||
821 | } | 976 | } |
822 | else | 977 | else |
823 | { | 978 | { |
824 | yychar1 = YYTRANSLATE(yychar); | 979 | yychar1 = YYTRANSLATE(yychar); |
825 | 980 | ||
826 | #if YYDEBUG != 0 | 981 | #if YYDEBUG |
982 | /* We have to keep this `#if YYDEBUG', since we use variables | ||
983 | which are defined only if `YYDEBUG' is set. */ | ||
827 | if (yydebug) | 984 | if (yydebug) |
828 | { | 985 | { |
829 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); | 986 | YYFPRINTF (stderr, "Next token is %d (%s", |
830 | /* Give the individual parser a way to print the precise meaning | 987 | yychar, yytname[yychar1]); |
831 | of a token, for further debugging info. */ | 988 | /* Give the individual parser a way to print the precise |
989 | meaning of a token, for further debugging info. */ | ||
832 | #ifdef YYPRINT | 990 | #ifdef YYPRINT |
833 | YYPRINT (stderr, yychar, yylval); | 991 | YYPRINT (stderr, yychar, yylval); |
834 | #endif | 992 | #endif |
835 | fprintf (stderr, ")\n"); | 993 | YYFPRINTF (stderr, ")\n"); |
836 | } | 994 | } |
837 | #endif | 995 | #endif |
838 | } | 996 | } |
839 | 997 | ||
840 | yyn += yychar1; | 998 | yyn += yychar1; |
841 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) | 999 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
842 | goto yydefault; | 1000 | goto yydefault; |
843 | 1001 | ||
844 | yyn = yytable[yyn]; | 1002 | yyn = yytable[yyn]; |
845 | 1003 | ||
846 | /* yyn is what to do for this token type in this state. | 1004 | /* yyn is what to do for this token type in this state. |
847 | Negative => reduce, -yyn is rule number. | 1005 | Negative => reduce, -yyn is rule number. |
@@ -855,584 +1013,604 @@ yynewstate: | |||
855 | if (yyn == YYFLAG) | 1013 | if (yyn == YYFLAG) |
856 | goto yyerrlab; | 1014 | goto yyerrlab; |
857 | yyn = -yyn; | 1015 | yyn = -yyn; |
858 | goto yyreduce; | 1016 | goto yyreduce; |
859 | } | 1017 | } |
860 | else if (yyn == 0) | 1018 | else if (yyn == 0) |
861 | goto yyerrlab; | 1019 | goto yyerrlab; |
862 | 1020 | ||
863 | if (yyn == YYFINAL) | 1021 | if (yyn == YYFINAL) |
864 | YYACCEPT; | 1022 | YYACCEPT; |
865 | 1023 | ||
866 | /* Shift the lookahead token. */ | 1024 | /* Shift the lookahead token. */ |
867 | 1025 | YYDPRINTF ((stderr, "Shifting token %d (%s), ", | |
868 | #if YYDEBUG != 0 | 1026 | yychar, yytname[yychar1])); |
869 | if (yydebug) | ||
870 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); | ||
871 | #endif | ||
872 | 1027 | ||
873 | /* Discard the token being shifted unless it is eof. */ | 1028 | /* Discard the token being shifted unless it is eof. */ |
874 | if (yychar != YYEOF) | 1029 | if (yychar != YYEOF) |
875 | yychar = YYEMPTY; | 1030 | yychar = YYEMPTY; |
876 | 1031 | ||
877 | *++yyvsp = yylval; | 1032 | *++yyvsp = yylval; |
878 | #ifdef YYLSP_NEEDED | 1033 | #if YYLSP_NEEDED |
879 | *++yylsp = yylloc; | 1034 | *++yylsp = yylloc; |
880 | #endif | 1035 | #endif |
881 | 1036 | ||
882 | /* count tokens shifted since error; after three, turn off error status. */ | 1037 | /* Count tokens shifted since error; after three, turn off error |
883 | if (yyerrstatus) yyerrstatus--; | 1038 | status. */ |
1039 | if (yyerrstatus) | ||
1040 | yyerrstatus--; | ||
884 | 1041 | ||
885 | yystate = yyn; | 1042 | yystate = yyn; |
886 | goto yynewstate; | 1043 | goto yynewstate; |
887 | 1044 | ||
888 | /* Do the default action for the current state. */ | ||
889 | yydefault: | ||
890 | 1045 | ||
1046 | /*-----------------------------------------------------------. | ||
1047 | | yydefault -- do the default action for the current state. | | ||
1048 | `-----------------------------------------------------------*/ | ||
1049 | yydefault: | ||
891 | yyn = yydefact[yystate]; | 1050 | yyn = yydefact[yystate]; |
892 | if (yyn == 0) | 1051 | if (yyn == 0) |
893 | goto yyerrlab; | 1052 | goto yyerrlab; |
1053 | goto yyreduce; | ||
894 | 1054 | ||
895 | /* Do a reduction. yyn is the number of a rule to reduce with. */ | 1055 | |
1056 | /*-----------------------------. | ||
1057 | | yyreduce -- Do a reduction. | | ||
1058 | `-----------------------------*/ | ||
896 | yyreduce: | 1059 | yyreduce: |
1060 | /* yyn is the number of a rule to reduce with. */ | ||
897 | yylen = yyr2[yyn]; | 1061 | yylen = yyr2[yyn]; |
898 | if (yylen > 0) | ||
899 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ | ||
900 | 1062 | ||
901 | #if YYDEBUG != 0 | 1063 | /* If YYLEN is nonzero, implement the default value of the action: |
1064 | `$$ = $1'. | ||
1065 | |||
1066 | Otherwise, the following line sets YYVAL to the semantic value of | ||
1067 | the lookahead token. This behavior is undocumented and Bison | ||
1068 | users should not rely upon it. Assigning to YYVAL | ||
1069 | unconditionally makes the parser a bit smaller, and it avoids a | ||
1070 | GCC warning that YYVAL may be used uninitialized. */ | ||
1071 | yyval = yyvsp[1-yylen]; | ||
1072 | |||
1073 | #if YYLSP_NEEDED | ||
1074 | /* Similarly for the default location. Let the user run additional | ||
1075 | commands if for instance locations are ranges. */ | ||
1076 | yyloc = yylsp[1-yylen]; | ||
1077 | YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); | ||
1078 | #endif | ||
1079 | |||
1080 | #if YYDEBUG | ||
1081 | /* We have to keep this `#if YYDEBUG', since we use variables which | ||
1082 | are defined only if `YYDEBUG' is set. */ | ||
902 | if (yydebug) | 1083 | if (yydebug) |
903 | { | 1084 | { |
904 | int i; | 1085 | int yyi; |
905 | 1086 | ||
906 | fprintf (stderr, "Reducing via rule %d (line %d), ", | 1087 | YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", |
907 | yyn, yyrline[yyn]); | 1088 | yyn, yyrline[yyn]); |
908 | 1089 | ||
909 | /* Print the symbols being reduced, and their result. */ | 1090 | /* Print the symbols being reduced, and their result. */ |
910 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) | 1091 | for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) |
911 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); | 1092 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
912 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); | 1093 | YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
913 | } | 1094 | } |
914 | #endif | 1095 | #endif |
915 | 1096 | ||
916 | |||
917 | switch (yyn) { | 1097 | switch (yyn) { |
918 | 1098 | ||
919 | case 2: | 1099 | case 2: |
920 | #line 213 "./vcc.y" | 1100 | #line 212 "vcc.y" |
921 | { addList(&vObjList, yyvsp[0].vobj); curObj = 0; ; | 1101 | { addList(&vObjList, yyvsp[0].vobj); curObj = 0; } |
922 | break;} | 1102 | break; |
923 | case 4: | 1103 | case 4: |
924 | #line 216 "./vcc.y" | 1104 | #line 215 "vcc.y" |
925 | { addList(&vObjList, yyvsp[0].vobj); curObj = 0; ; | 1105 | { addList(&vObjList, yyvsp[0].vobj); curObj = 0; } |
926 | break;} | 1106 | break; |
927 | case 7: | 1107 | case 7: |
928 | #line 225 "./vcc.y" | 1108 | #line 224 "vcc.y" |
929 | { | 1109 | { |
930 | lexPushMode(L_VCARD); | 1110 | lexPushMode(L_VCARD); |
931 | if (!pushVObject(VCCardProp)) YYERROR; | 1111 | if (!pushVObject(VCCardProp)) YYERROR; |
932 | ; | 1112 | } |
933 | break;} | 1113 | break; |
934 | case 8: | 1114 | case 8: |
935 | #line 230 "./vcc.y" | 1115 | #line 229 "vcc.y" |
936 | { | 1116 | { |
937 | lexPopMode(0); | 1117 | lexPopMode(0); |
938 | yyval.vobj = popVObject(); | 1118 | yyval.vobj = popVObject(); |
939 | ; | 1119 | } |
940 | break;} | 1120 | break; |
941 | case 9: | 1121 | case 9: |
942 | #line 235 "./vcc.y" | 1122 | #line 234 "vcc.y" |
943 | { | 1123 | { |
944 | lexPushMode(L_VCARD); | 1124 | lexPushMode(L_VCARD); |
945 | if (!pushVObject(VCCardProp)) YYERROR; | 1125 | if (!pushVObject(VCCardProp)) YYERROR; |
946 | ; | 1126 | } |
947 | break;} | 1127 | break; |
948 | case 10: | 1128 | case 10: |
949 | #line 240 "./vcc.y" | 1129 | #line 239 "vcc.y" |
950 | { | 1130 | { |
951 | lexPopMode(0); | 1131 | lexPopMode(0); |
952 | yyval.vobj = popVObject(); | 1132 | yyval.vobj = popVObject(); |
953 | ; | 1133 | } |
954 | break;} | 1134 | break; |
955 | case 13: | 1135 | case 13: |
956 | #line 251 "./vcc.y" | 1136 | #line 250 "vcc.y" |
957 | { | 1137 | { |
958 | lexPushMode(L_VALUES); | 1138 | lexPushMode(L_VALUES); |
959 | ; | 1139 | } |
960 | break;} | 1140 | break; |
961 | case 14: | 1141 | case 14: |
962 | #line 255 "./vcc.y" | 1142 | #line 254 "vcc.y" |
963 | { | 1143 | { |
964 | if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE)) | 1144 | if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE)) |
965 | lexPopMode(0); | 1145 | lexPopMode(0); |
966 | lexPopMode(0); | 1146 | lexPopMode(0); |
967 | ; | 1147 | } |
968 | break;} | 1148 | break; |
969 | case 16: | 1149 | case 16: |
970 | #line 264 "./vcc.y" | 1150 | #line 263 "vcc.y" |
971 | { | 1151 | { |
972 | enterProps(yyvsp[0].str); | 1152 | enterProps(yyvsp[0].str); |
973 | ; | 1153 | } |
974 | break;} | 1154 | break; |
975 | case 18: | 1155 | case 18: |
976 | #line 269 "./vcc.y" | 1156 | #line 268 "vcc.y" |
977 | { | 1157 | { |
978 | enterProps(yyvsp[0].str); | 1158 | enterProps(yyvsp[0].str); |
979 | ; | 1159 | } |
980 | break;} | 1160 | break; |
981 | case 22: | 1161 | case 22: |
982 | #line 282 "./vcc.y" | 1162 | #line 281 "vcc.y" |
983 | { | 1163 | { |
984 | enterAttr(yyvsp[0].str,0); | 1164 | enterAttr(yyvsp[0].str,0); |
985 | ; | 1165 | } |
986 | break;} | 1166 | break; |
987 | case 23: | 1167 | case 23: |
988 | #line 286 "./vcc.y" | 1168 | #line 285 "vcc.y" |
989 | { | 1169 | { |
990 | enterAttr(yyvsp[-2].str,yyvsp[0].str); | 1170 | enterAttr(yyvsp[-2].str,yyvsp[0].str); |
991 | 1171 | ||
992 | ; | 1172 | } |
993 | break;} | 1173 | break; |
994 | case 25: | 1174 | case 25: |
995 | #line 295 "./vcc.y" | 1175 | #line 294 "vcc.y" |
996 | { appendValue(yyvsp[-1].str); ; | 1176 | { enterValues(yyvsp[-1].str); } |
997 | break;} | 1177 | break; |
998 | case 27: | 1178 | case 27: |
999 | #line 297 "./vcc.y" | 1179 | #line 296 "vcc.y" |
1000 | { appendValue(yyvsp[0].str); ; | 1180 | { enterValues(yyvsp[0].str); } |
1001 | break;} | 1181 | break; |
1002 | case 29: | 1182 | case 29: |
1003 | #line 302 "./vcc.y" | 1183 | #line 300 "vcc.y" |
1004 | { yyval.str = 0; ; | 1184 | { yyval.str = 0; } |
1005 | break;} | 1185 | break; |
1006 | case 30: | 1186 | case 30: |
1007 | #line 307 "./vcc.y" | 1187 | #line 305 "vcc.y" |
1008 | { if (!pushVObject(VCCalProp)) YYERROR; ; | 1188 | { if (!pushVObject(VCCalProp)) YYERROR; } |
1009 | break;} | 1189 | break; |
1010 | case 31: | 1190 | case 31: |
1011 | #line 310 "./vcc.y" | 1191 | #line 308 "vcc.y" |
1012 | { yyval.vobj = popVObject(); ; | 1192 | { yyval.vobj = popVObject(); } |
1013 | break;} | 1193 | break; |
1014 | case 32: | 1194 | case 32: |
1015 | #line 312 "./vcc.y" | 1195 | #line 310 "vcc.y" |
1016 | { if (!pushVObject(VCCalProp)) YYERROR; ; | 1196 | { if (!pushVObject(VCCalProp)) YYERROR; } |
1017 | break;} | 1197 | break; |
1018 | case 33: | 1198 | case 33: |
1019 | #line 314 "./vcc.y" | 1199 | #line 312 "vcc.y" |
1020 | { yyval.vobj = popVObject(); ; | 1200 | { yyval.vobj = popVObject(); } |
1021 | break;} | 1201 | break; |
1022 | case 39: | 1202 | case 39: |
1023 | #line 329 "./vcc.y" | 1203 | #line 327 "vcc.y" |
1024 | { | 1204 | { |
1025 | lexPushMode(L_VEVENT); | 1205 | lexPushMode(L_VEVENT); |
1026 | if (!pushVObject(VCEventProp)) YYERROR; | 1206 | if (!pushVObject(VCEventProp)) YYERROR; |
1027 | ; | 1207 | } |
1028 | break;} | 1208 | break; |
1029 | case 40: | 1209 | case 40: |
1030 | #line 335 "./vcc.y" | 1210 | #line 333 "vcc.y" |
1031 | { | 1211 | { |
1032 | lexPopMode(0); | 1212 | lexPopMode(0); |
1033 | popVObject(); | 1213 | popVObject(); |
1034 | ; | 1214 | } |
1035 | break;} | 1215 | break; |
1036 | case 41: | 1216 | case 41: |
1037 | #line 340 "./vcc.y" | 1217 | #line 338 "vcc.y" |
1038 | { | 1218 | { |
1039 | lexPushMode(L_VEVENT); | 1219 | lexPushMode(L_VEVENT); |
1040 | if (!pushVObject(VCEventProp)) YYERROR; | 1220 | if (!pushVObject(VCEventProp)) YYERROR; |
1041 | ; | 1221 | } |
1042 | break;} | 1222 | break; |
1043 | case 42: | 1223 | case 42: |
1044 | #line 345 "./vcc.y" | 1224 | #line 343 "vcc.y" |
1045 | { | 1225 | { |
1046 | lexPopMode(0); | 1226 | lexPopMode(0); |
1047 | popVObject(); | 1227 | popVObject(); |
1048 | ; | 1228 | } |
1049 | break;} | 1229 | break; |
1050 | case 43: | 1230 | case 43: |
1051 | #line 353 "./vcc.y" | 1231 | #line 351 "vcc.y" |
1052 | { | 1232 | { |
1053 | lexPushMode(L_VTODO); | 1233 | lexPushMode(L_VTODO); |
1054 | if (!pushVObject(VCTodoProp)) YYERROR; | 1234 | if (!pushVObject(VCTodoProp)) YYERROR; |
1055 | ; | 1235 | } |
1056 | break;} | 1236 | break; |
1057 | case 44: | 1237 | case 44: |
1058 | #line 359 "./vcc.y" | 1238 | #line 357 "vcc.y" |
1059 | { | 1239 | { |
1060 | lexPopMode(0); | 1240 | lexPopMode(0); |
1061 | popVObject(); | 1241 | popVObject(); |
1062 | ; | 1242 | } |
1063 | break;} | 1243 | break; |
1064 | case 45: | 1244 | case 45: |
1065 | #line 364 "./vcc.y" | 1245 | #line 362 "vcc.y" |
1066 | { | 1246 | { |
1067 | lexPushMode(L_VTODO); | 1247 | lexPushMode(L_VTODO); |
1068 | if (!pushVObject(VCTodoProp)) YYERROR; | 1248 | if (!pushVObject(VCTodoProp)) YYERROR; |
1069 | ; | 1249 | } |
1070 | break;} | 1250 | break; |
1071 | case 46: | 1251 | case 46: |
1072 | #line 369 "./vcc.y" | 1252 | #line 367 "vcc.y" |
1073 | { | 1253 | { |
1074 | lexPopMode(0); | 1254 | lexPopMode(0); |
1075 | popVObject(); | 1255 | popVObject(); |
1076 | ; | ||
1077 | break;} | ||
1078 | } | 1256 | } |
1079 | /* the action file gets copied in in place of this dollarsign */ | 1257 | break; |
1080 | #line 543 "/usr/share/bison.simple" | 1258 | } |
1259 | |||
1260 | #line 705 "/usr/share/bison/bison.simple" | ||
1261 | |||
1081 | 1262 | ||
1082 | yyvsp -= yylen; | 1263 | yyvsp -= yylen; |
1083 | yyssp -= yylen; | 1264 | yyssp -= yylen; |
1084 | #ifdef YYLSP_NEEDED | 1265 | #if YYLSP_NEEDED |
1085 | yylsp -= yylen; | 1266 | yylsp -= yylen; |
1086 | #endif | 1267 | #endif |
1087 | 1268 | ||
1088 | #if YYDEBUG != 0 | 1269 | #if YYDEBUG |
1089 | if (yydebug) | 1270 | if (yydebug) |
1090 | { | 1271 | { |
1091 | short *ssp1 = yyss - 1; | 1272 | short *yyssp1 = yyss - 1; |
1092 | fprintf (stderr, "state stack now"); | 1273 | YYFPRINTF (stderr, "state stack now"); |
1093 | while (ssp1 != yyssp) | 1274 | while (yyssp1 != yyssp) |
1094 | fprintf (stderr, " %d", *++ssp1); | 1275 | YYFPRINTF (stderr, " %d", *++yyssp1); |
1095 | fprintf (stderr, "\n"); | 1276 | YYFPRINTF (stderr, "\n"); |
1096 | } | 1277 | } |
1097 | #endif | 1278 | #endif |
1098 | 1279 | ||
1099 | *++yyvsp = yyval; | 1280 | *++yyvsp = yyval; |
1100 | 1281 | #if YYLSP_NEEDED | |
1101 | #ifdef YYLSP_NEEDED | 1282 | *++yylsp = yyloc; |
1102 | yylsp++; | ||
1103 | if (yylen == 0) | ||
1104 | { | ||
1105 | yylsp->first_line = yylloc.first_line; | ||
1106 | yylsp->first_column = yylloc.first_column; | ||
1107 | yylsp->last_line = (yylsp-1)->last_line; | ||
1108 | yylsp->last_column = (yylsp-1)->last_column; | ||
1109 | yylsp->text = 0; | ||
1110 | } | ||
1111 | else | ||
1112 | { | ||
1113 | yylsp->last_line = (yylsp+yylen-1)->last_line; | ||
1114 | yylsp->last_column = (yylsp+yylen-1)->last_column; | ||
1115 | } | ||
1116 | #endif | 1283 | #endif |
1117 | 1284 | ||
1118 | /* Now "shift" the result of the reduction. | 1285 | /* Now `shift' the result of the reduction. Determine what state |
1119 | Determine what state that goes to, | 1286 | that goes to, based on the state we popped back to and the rule |
1120 | based on the state we popped back to | 1287 | number reduced by. */ |
1121 | and the rule number reduced by. */ | ||
1122 | 1288 | ||
1123 | yyn = yyr1[yyn]; | 1289 | yyn = yyr1[yyn]; |
1124 | 1290 | ||
1125 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; | 1291 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
1126 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) | 1292 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
1127 | yystate = yytable[yystate]; | 1293 | yystate = yytable[yystate]; |
1128 | else | 1294 | else |
1129 | yystate = yydefgoto[yyn - YYNTBASE]; | 1295 | yystate = yydefgoto[yyn - YYNTBASE]; |
1130 | 1296 | ||
1131 | goto yynewstate; | 1297 | goto yynewstate; |
1132 | 1298 | ||
1133 | yyerrlab: /* here on detecting error */ | ||
1134 | 1299 | ||
1135 | if (! yyerrstatus) | 1300 | /*------------------------------------. |
1301 | | yyerrlab -- here on detecting error | | ||
1302 | `------------------------------------*/ | ||
1303 | yyerrlab: | ||
1136 | /* If not already recovering from an error, report this error. */ | 1304 | /* If not already recovering from an error, report this error. */ |
1305 | if (!yyerrstatus) | ||
1137 | { | 1306 | { |
1138 | ++yynerrs; | 1307 | ++yynerrs; |
1139 | 1308 | ||
1140 | #ifdef YYERROR_VERBOSE | 1309 | #ifdef YYERROR_VERBOSE |
1141 | yyn = yypact[yystate]; | 1310 | yyn = yypact[yystate]; |
1142 | 1311 | ||
1143 | if (yyn > YYFLAG && yyn < YYLAST) | 1312 | if (yyn > YYFLAG && yyn < YYLAST) |
1144 | { | 1313 | { |
1145 | int size = 0; | 1314 | YYSIZE_T yysize = 0; |
1146 | char *msg; | 1315 | char *yymsg; |
1147 | int x, count; | 1316 | int yyx, yycount; |
1148 | 1317 | ||
1149 | count = 0; | 1318 | yycount = 0; |
1150 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ | 1319 | /* Start YYX at -YYN if negative to avoid negative indexes in |
1151 | for (x = (yyn < 0 ? -yyn : 0); | 1320 | YYCHECK. */ |
1152 | x < (sizeof(yytname) / sizeof(char *)); x++) | 1321 | for (yyx = yyn < 0 ? -yyn : 0; |
1153 | if (yycheck[x + yyn] == x) | 1322 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) |
1154 | size += strlen(yytname[x]) + 15, count++; | 1323 | if (yycheck[yyx + yyn] == yyx) |
1155 | msg = (char *) malloc(size + 15); | 1324 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; |
1156 | if (msg != 0) | 1325 | yysize += yystrlen ("parse error, unexpected ") + 1; |
1326 | yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); | ||
1327 | yymsg = (char *) YYSTACK_ALLOC (yysize); | ||
1328 | if (yymsg != 0) | ||
1157 | { | 1329 | { |
1158 | strcpy(msg, "parse error"); | 1330 | char *yyp = yystpcpy (yymsg, "parse error, unexpected "); |
1331 | yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); | ||
1159 | 1332 | ||
1160 | if (count < 5) | 1333 | if (yycount < 5) |
1161 | { | 1334 | { |
1162 | count = 0; | 1335 | yycount = 0; |
1163 | for (x = (yyn < 0 ? -yyn : 0); | 1336 | for (yyx = yyn < 0 ? -yyn : 0; |
1164 | x < (sizeof(yytname) / sizeof(char *)); x++) | 1337 | yyx < (int) (sizeof (yytname) / sizeof (char *)); |
1165 | if (yycheck[x + yyn] == x) | 1338 | yyx++) |
1339 | if (yycheck[yyx + yyn] == yyx) | ||
1166 | { | 1340 | { |
1167 | strcat(msg, count == 0 ? ", expecting `" : " or `"); | 1341 | const char *yyq = ! yycount ? ", expecting " : " or "; |
1168 | strcat(msg, yytname[x]); | 1342 | yyp = yystpcpy (yyp, yyq); |
1169 | strcat(msg, "'"); | 1343 | yyp = yystpcpy (yyp, yytname[yyx]); |
1170 | count++; | 1344 | yycount++; |
1171 | } | 1345 | } |
1172 | } | 1346 | } |
1173 | yyerror(msg); | 1347 | yyerror (yymsg); |
1174 | free(msg); | 1348 | YYSTACK_FREE (yymsg); |
1175 | } | 1349 | } |
1176 | else | 1350 | else |
1177 | yyerror ("parse error; also virtual memory exceeded"); | 1351 | yyerror ("parse error; also virtual memory exhausted"); |
1178 | } | 1352 | } |
1179 | else | 1353 | else |
1180 | #endif /* YYERROR_VERBOSE */ | 1354 | #endif /* defined (YYERROR_VERBOSE) */ |
1181 | yyerror("parse error"); | 1355 | yyerror("parse error"); |
1182 | } | 1356 | } |
1183 | |||
1184 | goto yyerrlab1; | 1357 | goto yyerrlab1; |
1185 | yyerrlab1: /* here on error raised explicitly by an action */ | ||
1186 | 1358 | ||
1359 | |||
1360 | /*--------------------------------------------------. | ||
1361 | | yyerrlab1 -- error raised explicitly by an action | | ||
1362 | `--------------------------------------------------*/ | ||
1363 | yyerrlab1: | ||
1187 | if (yyerrstatus == 3) | 1364 | if (yyerrstatus == 3) |
1188 | { | 1365 | { |
1189 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ | 1366 | /* If just tried and failed to reuse lookahead token after an |
1367 | error, discard it. */ | ||
1190 | 1368 | ||
1191 | /* return failure if at end of input */ | 1369 | /* return failure if at end of input */ |
1192 | if (yychar == YYEOF) | 1370 | if (yychar == YYEOF) |
1193 | YYABORT; | 1371 | YYABORT; |
1194 | 1372 | YYDPRINTF ((stderr, "Discarding token %d (%s).\n", | |
1195 | #if YYDEBUG != 0 | 1373 | yychar, yytname[yychar1])); |
1196 | if (yydebug) | ||
1197 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); | ||
1198 | #endif | ||
1199 | |||
1200 | yychar = YYEMPTY; | 1374 | yychar = YYEMPTY; |
1201 | } | 1375 | } |
1202 | 1376 | ||
1203 | /* Else will try to reuse lookahead token | 1377 | /* Else will try to reuse lookahead token after shifting the error |
1204 | after shifting the error token. */ | 1378 | token. */ |
1205 | 1379 | ||
1206 | yyerrstatus = 3; /* Each real token shifted decrements this */ | 1380 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
1207 | 1381 | ||
1208 | goto yyerrhandle; | 1382 | goto yyerrhandle; |
1209 | 1383 | ||
1210 | yyerrdefault: /* current state does not do anything special for the error token. */ | ||
1211 | 1384 | ||
1385 | /*-------------------------------------------------------------------. | ||
1386 | | yyerrdefault -- current state does not do anything special for the | | ||
1387 | | error token. | | ||
1388 | `-------------------------------------------------------------------*/ | ||
1389 | yyerrdefault: | ||
1212 | #if 0 | 1390 | #if 0 |
1213 | /* This is wrong; only states that explicitly want error tokens | 1391 | /* This is wrong; only states that explicitly want error tokens |
1214 | should shift them. */ | 1392 | should shift them. */ |
1215 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ | 1393 | |
1216 | if (yyn) goto yydefault; | 1394 | /* If its default is to accept any token, ok. Otherwise pop it. */ |
1395 | yyn = yydefact[yystate]; | ||
1396 | if (yyn) | ||
1397 | goto yydefault; | ||
1217 | #endif | 1398 | #endif |
1218 | 1399 | ||
1219 | yyerrpop: /* pop the current state because it cannot handle the error token */ | ||
1220 | 1400 | ||
1221 | if (yyssp == yyss) YYABORT; | 1401 | /*---------------------------------------------------------------. |
1402 | | yyerrpop -- pop the current state because it cannot handle the | | ||
1403 | | error token | | ||
1404 | `---------------------------------------------------------------*/ | ||
1405 | yyerrpop: | ||
1406 | if (yyssp == yyss) | ||
1407 | YYABORT; | ||
1222 | yyvsp--; | 1408 | yyvsp--; |
1223 | yystate = *--yyssp; | 1409 | yystate = *--yyssp; |
1224 | #ifdef YYLSP_NEEDED | 1410 | #if YYLSP_NEEDED |
1225 | yylsp--; | 1411 | yylsp--; |
1226 | #endif | 1412 | #endif |
1227 | 1413 | ||
1228 | #if YYDEBUG != 0 | 1414 | #if YYDEBUG |
1229 | if (yydebug) | 1415 | if (yydebug) |
1230 | { | 1416 | { |
1231 | short *ssp1 = yyss - 1; | 1417 | short *yyssp1 = yyss - 1; |
1232 | fprintf (stderr, "Error: state stack now"); | 1418 | YYFPRINTF (stderr, "Error: state stack now"); |
1233 | while (ssp1 != yyssp) | 1419 | while (yyssp1 != yyssp) |
1234 | fprintf (stderr, " %d", *++ssp1); | 1420 | YYFPRINTF (stderr, " %d", *++yyssp1); |
1235 | fprintf (stderr, "\n"); | 1421 | YYFPRINTF (stderr, "\n"); |
1236 | } | 1422 | } |
1237 | #endif | 1423 | #endif |
1238 | 1424 | ||
1425 | /*--------------. | ||
1426 | | yyerrhandle. | | ||
1427 | `--------------*/ | ||
1239 | yyerrhandle: | 1428 | yyerrhandle: |
1240 | |||
1241 | yyn = yypact[yystate]; | 1429 | yyn = yypact[yystate]; |
1242 | if (yyn == YYFLAG) | 1430 | if (yyn == YYFLAG) |
1243 | goto yyerrdefault; | 1431 | goto yyerrdefault; |
1244 | 1432 | ||
1245 | yyn += YYTERROR; | 1433 | yyn += YYTERROR; |
1246 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) | 1434 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
1247 | goto yyerrdefault; | 1435 | goto yyerrdefault; |
1248 | 1436 | ||
1249 | yyn = yytable[yyn]; | 1437 | yyn = yytable[yyn]; |
1250 | if (yyn < 0) | 1438 | if (yyn < 0) |
1251 | { | 1439 | { |
1252 | if (yyn == YYFLAG) | 1440 | if (yyn == YYFLAG) |
1253 | goto yyerrpop; | 1441 | goto yyerrpop; |
1254 | yyn = -yyn; | 1442 | yyn = -yyn; |
1255 | goto yyreduce; | 1443 | goto yyreduce; |
1256 | } | 1444 | } |
1257 | else if (yyn == 0) | 1445 | else if (yyn == 0) |
1258 | goto yyerrpop; | 1446 | goto yyerrpop; |
1259 | 1447 | ||
1260 | if (yyn == YYFINAL) | 1448 | if (yyn == YYFINAL) |
1261 | YYACCEPT; | 1449 | YYACCEPT; |
1262 | 1450 | ||
1263 | #if YYDEBUG != 0 | 1451 | YYDPRINTF ((stderr, "Shifting error token, ")); |
1264 | if (yydebug) | ||
1265 | fprintf(stderr, "Shifting error token, "); | ||
1266 | #endif | ||
1267 | 1452 | ||
1268 | *++yyvsp = yylval; | 1453 | *++yyvsp = yylval; |
1269 | #ifdef YYLSP_NEEDED | 1454 | #if YYLSP_NEEDED |
1270 | *++yylsp = yylloc; | 1455 | *++yylsp = yylloc; |
1271 | #endif | 1456 | #endif |
1272 | 1457 | ||
1273 | yystate = yyn; | 1458 | yystate = yyn; |
1274 | goto yynewstate; | 1459 | goto yynewstate; |
1275 | 1460 | ||
1461 | |||
1462 | /*-------------------------------------. | ||
1463 | | yyacceptlab -- YYACCEPT comes here. | | ||
1464 | `-------------------------------------*/ | ||
1276 | yyacceptlab: | 1465 | yyacceptlab: |
1277 | /* YYACCEPT comes here. */ | 1466 | yyresult = 0; |
1278 | if (yyfree_stacks) | 1467 | goto yyreturn; |
1279 | { | ||
1280 | free (yyss); | ||
1281 | free (yyvs); | ||
1282 | #ifdef YYLSP_NEEDED | ||
1283 | free (yyls); | ||
1284 | #endif | ||
1285 | } | ||
1286 | return 0; | ||
1287 | 1468 | ||
1469 | /*-----------------------------------. | ||
1470 | | yyabortlab -- YYABORT comes here. | | ||
1471 | `-----------------------------------*/ | ||
1288 | yyabortlab: | 1472 | yyabortlab: |
1289 | /* YYABORT comes here. */ | 1473 | yyresult = 1; |
1290 | if (yyfree_stacks) | 1474 | goto yyreturn; |
1291 | { | 1475 | |
1292 | free (yyss); | 1476 | /*---------------------------------------------. |
1293 | free (yyvs); | 1477 | | yyoverflowab -- parser overflow comes here. | |
1294 | #ifdef YYLSP_NEEDED | 1478 | `---------------------------------------------*/ |
1295 | free (yyls); | 1479 | yyoverflowlab: |
1480 | yyerror ("parser stack overflow"); | ||
1481 | yyresult = 2; | ||
1482 | /* Fall through. */ | ||
1483 | |||
1484 | yyreturn: | ||
1485 | #ifndef yyoverflow | ||
1486 | if (yyss != yyssa) | ||
1487 | YYSTACK_FREE (yyss); | ||
1296 | #endif | 1488 | #endif |
1489 | return yyresult; | ||
1297 | } | 1490 | } |
1298 | return 1; | 1491 | #line 373 "vcc.y" |
1299 | } | ||
1300 | #line 375 "./vcc.y" | ||
1301 | 1492 | ||
1302 | /****************************************************************************/ | ||
1303 | static int pushVObject(const char *prop) | 1493 | static int pushVObject(const char *prop) |
1304 | { | 1494 | { |
1305 | VObject *newObj; | 1495 | VObject *newObj; |
1306 | if (ObjStackTop == MAXLEVEL) | 1496 | if (ObjStackTop == MAXLEVEL) |
1307 | return FALSE; | 1497 | return FALSE; |
1308 | 1498 | ||
1309 | ObjStack[++ObjStackTop] = curObj; | 1499 | ObjStack[++ObjStackTop] = curObj; |
1310 | 1500 | ||
1311 | if (curObj) { | 1501 | if (curObj) { |
1312 | newObj = addProp(curObj,prop); | 1502 | newObj = addProp(curObj,prop); |
1313 | curObj = newObj; | 1503 | curObj = newObj; |
1314 | } | 1504 | } |
1315 | else | 1505 | else |
1316 | curObj = newVObject(prop); | 1506 | curObj = newVObject(prop); |
1317 | 1507 | ||
1318 | return TRUE; | 1508 | return TRUE; |
1319 | } | 1509 | } |
1320 | 1510 | ||
1321 | 1511 | ||
1322 | /****************************************************************************/ | ||
1323 | /* This pops the recently built vCard off the stack and returns it. */ | 1512 | /* This pops the recently built vCard off the stack and returns it. */ |
1324 | static VObject* popVObject() | 1513 | static VObject* popVObject() |
1325 | { | 1514 | { |
1326 | VObject *oldObj; | 1515 | VObject *oldObj; |
1327 | if (ObjStackTop < 0) { | 1516 | if (ObjStackTop < 0) { |
1328 | yyerror("pop on empty Object Stack\n"); | 1517 | yyerror("pop on empty Object Stack\n"); |
1329 | return 0; | 1518 | return 0; |
1330 | } | 1519 | } |
1331 | oldObj = curObj; | 1520 | oldObj = curObj; |
1332 | curObj = ObjStack[ObjStackTop--]; | 1521 | curObj = ObjStack[ObjStackTop--]; |
1333 | 1522 | ||
1334 | return oldObj; | 1523 | return oldObj; |
1335 | } | 1524 | } |
1336 | 1525 | ||
1337 | 1526 | ||
1338 | /* static void enterValues(const char *value) */ | 1527 | static void enterValues(const char *value) |
1339 | /* { */ | ||
1340 | /* if (fieldedProp && *fieldedProp) { */ | ||
1341 | /* if (value) { */ | ||
1342 | /* addPropValue(curProp,*fieldedProp,value); */ | ||
1343 | /* } */ | ||
1344 | /* else this field is empty, advance to next field */ | ||
1345 | /* fieldedProp++; */ | ||
1346 | /* } */ | ||
1347 | /* else { */ | ||
1348 | /* if (value) { */ | ||
1349 | /* setVObjectUStringZValue_(curProp,fakeUnicode(value,0)); */ | ||
1350 | /* } */ | ||
1351 | /* } */ | ||
1352 | /* deleteStr(value); */ | ||
1353 | /* } */ | ||
1354 | |||
1355 | static void appendValue(const char *value) | ||
1356 | { | 1528 | { |
1357 | char *p1, *p2; | ||
1358 | wchar_t *p3; | ||
1359 | int i; | ||
1360 | |||
1361 | if (fieldedProp && *fieldedProp) { | 1529 | if (fieldedProp && *fieldedProp) { |
1362 | if (value) { | 1530 | if (value) { |
1363 | addPropValue(curProp, *fieldedProp, value); | 1531 | addPropValue(curProp, *fieldedProp, value); |
1364 | } | 1532 | } |
1365 | /* else this field is empty, advance to next field */ | 1533 | /* else this field is empty, advance to next field */ |
1366 | fieldedProp++; | 1534 | fieldedProp++; |
1367 | } else { | 1535 | } |
1536 | else { | ||
1368 | if (value) { | 1537 | if (value) { |
1538 | char *p1, *p2; | ||
1539 | wchar_t *p3; | ||
1540 | int i; | ||
1541 | |||
1542 | /* If the property already has a string value, we append this one, | ||
1543 | using ';' to separate the values. */ | ||
1369 | if (vObjectUStringZValue(curProp)) { | 1544 | if (vObjectUStringZValue(curProp)) { |
1370 | p1 = fakeCString(vObjectUStringZValue(curProp)); | 1545 | p1 = fakeCString(vObjectUStringZValue(curProp)); |
1371 | p2 = malloc(sizeof(char *) * (strlen(p1)+strlen(value)+1)); | 1546 | p2 = malloc((strlen(p1)+strlen(value)+1)); |
1372 | strcpy(p2, p1); | 1547 | strcpy(p2, p1); |
1373 | deleteStr(p1); | 1548 | deleteStr(p1); |
1374 | 1549 | ||
1375 | i = strlen(p2); | 1550 | i = strlen(p2); |
1376 | p2[i] = ','; | 1551 | p2[i] = ';'; |
1377 | p2[i+1] = '\0'; | 1552 | p2[i+1] = '\0'; |
1378 | p2 = strcat(p2, value); | 1553 | p2 = strcat(p2, value); |
1379 | p3 = (wchar_t *) vObjectUStringZValue(curProp); | 1554 | p3 = (wchar_t *) vObjectUStringZValue(curProp); |
1380 | free(p3); | 1555 | free(p3); |
1381 | setVObjectUStringZValue_(curProp,fakeUnicode(p2,0)); | 1556 | setVObjectUStringZValue_(curProp,fakeUnicode(p2,0)); |
1382 | deleteStr(p2); | 1557 | deleteStr(p2); |
1383 | } else { | 1558 | } else { |
1384 | setVObjectUStringZValue_(curProp,fakeUnicode(value,0)); | 1559 | setVObjectUStringZValue_(curProp,fakeUnicode(value,0)); |
1385 | } | 1560 | } |
1386 | } | 1561 | } |
1387 | } | 1562 | } |
1388 | deleteStr(value); | 1563 | deleteStr(value); |
1389 | } | 1564 | } |
1390 | 1565 | ||
1391 | |||
1392 | static void enterProps(const char *s) | 1566 | static void enterProps(const char *s) |
1393 | { | 1567 | { |
1394 | curProp = addGroup(curObj,s); | 1568 | curProp = addGroup(curObj,s); |
1395 | deleteStr(s); | 1569 | deleteStr(s); |
1396 | } | 1570 | } |
1397 | 1571 | ||
1398 | static void enterAttr(const char *s1, const char *s2) | 1572 | static void enterAttr(const char *s1, const char *s2) |
1399 | { | 1573 | { |
1400 | const char *p1=0L, *p2=0L; | 1574 | const char *p1, *p2; |
1401 | p1 = lookupProp_(s1); | 1575 | p1 = lookupProp_(s1); |
1402 | if (s2) { | 1576 | if (s2) { |
1403 | VObject *a; | 1577 | VObject *a; |
1404 | p2 = lookupProp_(s2); | 1578 | p2 = lookupProp_(s2); |
1405 | a = addProp(curProp,p1); | 1579 | a = addProp(curProp,p1); |
1406 | setVObjectStringZValue(a,p2); | 1580 | setVObjectStringZValue(a,p2); |
1407 | } | 1581 | } |
1408 | else | 1582 | else |
1409 | addProp(curProp,p1); | 1583 | addProp(curProp,p1); |
1410 | if (strcasecmp(p1,VCBase64Prop) == 0 || (s2 && strcasecmp(p2,VCBase64Prop)==0)) | 1584 | if (stricmp(p1,VCBase64Prop) == 0 || (s2 && stricmp(p2,VCBase64Prop)==0)) |
1411 | lexPushMode(L_BASE64); | 1585 | lexPushMode(L_BASE64); |
1412 | else if (strcasecmp(p1,VCQuotedPrintableProp) == 0 | 1586 | else if (stricmp(p1,VCQuotedPrintableProp) == 0 |
1413 | || (s2 && strcasecmp(p2,VCQuotedPrintableProp)==0)) | 1587 | || (s2 && stricmp(p2,VCQuotedPrintableProp)==0)) |
1414 | lexPushMode(L_QUOTED_PRINTABLE); | 1588 | lexPushMode(L_QUOTED_PRINTABLE); |
1415 | deleteStr(s1); deleteStr(s2); | 1589 | deleteStr(s1); deleteStr(s2); |
1416 | } | 1590 | } |
1417 | 1591 | ||
1418 | 1592 | ||
1419 | #define MAX_LEX_LOOKAHEAD_0 32 | 1593 | #define MAX_LEX_LOOKAHEAD_0 32 |
1420 | #define MAX_LEX_LOOKAHEAD 64 | 1594 | #define MAX_LEX_LOOKAHEAD 64 |
1421 | #define MAX_LEX_MODE_STACK_SIZE 10 | 1595 | #define MAX_LEX_MODE_STACK_SIZE 10 |
1422 | #define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop]) | 1596 | #define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop]) |
1423 | 1597 | ||
1424 | struct LexBuf { | 1598 | struct LexBuf { |
1425 | /* input */ | 1599 | /* input */ |
1600 | #ifdef INCLUDEMFC | ||
1601 | CFile *inputFile; | ||
1602 | #else | ||
1426 | FILE *inputFile; | 1603 | FILE *inputFile; |
1604 | #endif | ||
1427 | char *inputString; | 1605 | char *inputString; |
1428 | unsigned long curPos; | 1606 | unsigned long curPos; |
1429 | unsigned long inputLen; | 1607 | unsigned long inputLen; |
1430 | /* lookahead buffer */ | 1608 | /* lookahead buffer */ |
1431 | /* -- lookahead buffer is short instead of char so that EOF | 1609 | /* -- lookahead buffer is short instead of char so that EOF |
1432 | / can be represented correctly. | 1610 | / can be represented correctly. |
1433 | */ | 1611 | */ |
1434 | unsigned long len; | 1612 | unsigned long len; |
1435 | short buf[MAX_LEX_LOOKAHEAD]; | 1613 | short buf[MAX_LEX_LOOKAHEAD]; |
1436 | unsigned long getPtr; | 1614 | unsigned long getPtr; |
1437 | /* context stack */ | 1615 | /* context stack */ |
1438 | unsigned long lexModeStackTop; | 1616 | unsigned long lexModeStackTop; |
@@ -1460,36 +1638,38 @@ static void lexPopMode(int top) | |||
1460 | lexBuf.lexModeStackTop = 0; | 1638 | lexBuf.lexModeStackTop = 0; |
1461 | else | 1639 | else |
1462 | if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--; | 1640 | if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--; |
1463 | } | 1641 | } |
1464 | 1642 | ||
1465 | static int lexWithinMode(enum LexMode mode) { | 1643 | static int lexWithinMode(enum LexMode mode) { |
1466 | unsigned long i; | 1644 | unsigned long i; |
1467 | for (i=0;i<lexBuf.lexModeStackTop;i++) | 1645 | for (i=0;i<lexBuf.lexModeStackTop;i++) |
1468 | if (mode == lexBuf.lexModeStack[i]) return 1; | 1646 | if (mode == lexBuf.lexModeStack[i]) return 1; |
1469 | return 0; | 1647 | return 0; |
1470 | } | 1648 | } |
1471 | 1649 | ||
1472 | static int lexGetc_() | 1650 | static char lexGetc_() |
1473 | { | 1651 | { |
1474 | /* get next char from input, no buffering. */ | 1652 | /* get next char from input, no buffering. */ |
1475 | if (lexBuf.curPos == lexBuf.inputLen) | 1653 | if (lexBuf.curPos == lexBuf.inputLen) |
1476 | return EOF; | 1654 | return EOF; |
1477 | else if (lexBuf.inputString) | 1655 | else if (lexBuf.inputString) |
1478 | return *(lexBuf.inputString + lexBuf.curPos++); | 1656 | return *(lexBuf.inputString + lexBuf.curPos++); |
1479 | else { | 1657 | else { |
1480 | if (!feof(lexBuf.inputFile)) | 1658 | #ifdef INCLUDEMFC |
1659 | char result; | ||
1660 | return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF; | ||
1661 | #else | ||
1481 | return fgetc(lexBuf.inputFile); | 1662 | return fgetc(lexBuf.inputFile); |
1482 | else | 1663 | #endif |
1483 | return EOF; | ||
1484 | } | 1664 | } |
1485 | } | 1665 | } |
1486 | 1666 | ||
1487 | static int lexGeta() | 1667 | static int lexGeta() |
1488 | { | 1668 | { |
1489 | ++lexBuf.len; | 1669 | ++lexBuf.len; |
1490 | return (lexBuf.buf[lexBuf.getPtr] = lexGetc_()); | 1670 | return (lexBuf.buf[lexBuf.getPtr] = lexGetc_()); |
1491 | } | 1671 | } |
1492 | 1672 | ||
1493 | static int lexGeta_(int i) | 1673 | static int lexGeta_(int i) |
1494 | { | 1674 | { |
1495 | ++lexBuf.len; | 1675 | ++lexBuf.len; |
@@ -1510,29 +1690,27 @@ static int lexLookahead() { | |||
1510 | lexGeta(); | 1690 | lexGeta(); |
1511 | /* do the \r\n -> \n or \r -> \n translation here */ | 1691 | /* do the \r\n -> \n or \r -> \n translation here */ |
1512 | if (c == '\r') { | 1692 | if (c == '\r') { |
1513 | int a = (lexBuf.len>1)? | 1693 | int a = (lexBuf.len>1)? |
1514 | lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]: | 1694 | lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]: |
1515 | lexGeta_(1); | 1695 | lexGeta_(1); |
1516 | if (a == '\n') { | 1696 | if (a == '\n') { |
1517 | lexSkipLookahead(); | 1697 | lexSkipLookahead(); |
1518 | } | 1698 | } |
1519 | lexBuf.buf[lexBuf.getPtr] = c = '\n'; | 1699 | lexBuf.buf[lexBuf.getPtr] = c = '\n'; |
1520 | } | 1700 | } |
1521 | else if (c == '\n') { | 1701 | else if (c == '\n') { |
1522 | int a; | 1702 | int a = (lexBuf.len>1)? |
1523 | if (lexBuf.len > 1) | 1703 | lexBuf.buf[lexBuf.getPtr+1]: |
1524 | a = lexBuf.buf[lexBuf.getPtr]; | 1704 | lexGeta_(1); |
1525 | else | ||
1526 | a = lexGeta_(1); | ||
1527 | if (a == '\r') { | 1705 | if (a == '\r') { |
1528 | lexSkipLookahead(); | 1706 | lexSkipLookahead(); |
1529 | } | 1707 | } |
1530 | lexBuf.buf[lexBuf.getPtr] = '\n'; | 1708 | lexBuf.buf[lexBuf.getPtr] = '\n'; |
1531 | } | 1709 | } |
1532 | return c; | 1710 | return c; |
1533 | } | 1711 | } |
1534 | 1712 | ||
1535 | static int lexGetc() { | 1713 | static int lexGetc() { |
1536 | int c = lexLookahead(); | 1714 | int c = lexLookahead(); |
1537 | if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { | 1715 | if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { |
1538 | /* EOF will remain in lookahead buffer */ | 1716 | /* EOF will remain in lookahead buffer */ |
@@ -1547,26 +1725,24 @@ static void lexSkipLookaheadWord() { | |||
1547 | lexBuf.len -= lexBuf.strsLen; | 1725 | lexBuf.len -= lexBuf.strsLen; |
1548 | lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; | 1726 | lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; |
1549 | } | 1727 | } |
1550 | } | 1728 | } |
1551 | 1729 | ||
1552 | static void lexClearToken() | 1730 | static void lexClearToken() |
1553 | { | 1731 | { |
1554 | lexBuf.strsLen = 0; | 1732 | lexBuf.strsLen = 0; |
1555 | } | 1733 | } |
1556 | 1734 | ||
1557 | static void lexAppendc(int c) | 1735 | static void lexAppendc(int c) |
1558 | { | 1736 | { |
1559 | /* not sure if I am doing this right to fix purify report -- PGB */ | ||
1560 | lexBuf.strs = (char *) realloc(lexBuf.strs, (size_t) lexBuf.strsLen + 1); | ||
1561 | lexBuf.strs[lexBuf.strsLen] = c; | 1737 | lexBuf.strs[lexBuf.strsLen] = c; |
1562 | /* append up to zero termination */ | 1738 | /* append up to zero termination */ |
1563 | if (c == 0) return; | 1739 | if (c == 0) return; |
1564 | lexBuf.strsLen++; | 1740 | lexBuf.strsLen++; |
1565 | if (lexBuf.strsLen > lexBuf.maxToken) { | 1741 | if (lexBuf.strsLen > lexBuf.maxToken) { |
1566 | /* double the token string size */ | 1742 | /* double the token string size */ |
1567 | lexBuf.maxToken <<= 1; | 1743 | lexBuf.maxToken <<= 1; |
1568 | lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); | 1744 | lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); |
1569 | } | 1745 | } |
1570 | } | 1746 | } |
1571 | 1747 | ||
1572 | static char* lexStr() { | 1748 | static char* lexStr() { |
@@ -1577,52 +1753,33 @@ static void lexSkipWhite() { | |||
1577 | int c = lexLookahead(); | 1753 | int c = lexLookahead(); |
1578 | while (c == ' ' || c == '\t') { | 1754 | while (c == ' ' || c == '\t') { |
1579 | lexSkipLookahead(); | 1755 | lexSkipLookahead(); |
1580 | c = lexLookahead(); | 1756 | c = lexLookahead(); |
1581 | } | 1757 | } |
1582 | } | 1758 | } |
1583 | 1759 | ||
1584 | static char* lexGetWord() { | 1760 | static char* lexGetWord() { |
1585 | int c; | 1761 | int c; |
1586 | lexSkipWhite(); | 1762 | lexSkipWhite(); |
1587 | lexClearToken(); | 1763 | lexClearToken(); |
1588 | c = lexLookahead(); | 1764 | c = lexLookahead(); |
1589 | /* some "words" have a space in them, like "NEEDS ACTION". | 1765 | while (c != EOF && !strchr("\t\n ;:=",c)) { |
1590 | this may be an oversight of the spec, but it is true nevertheless. | ||
1591 | while (c != EOF && !strchr("\t\n ;:=",c)) { */ | ||
1592 | while (c != EOF && !strchr("\n;:=",c)) { | ||
1593 | lexAppendc(c); | 1766 | lexAppendc(c); |
1594 | lexSkipLookahead(); | 1767 | lexSkipLookahead(); |
1595 | c = lexLookahead(); | 1768 | c = lexLookahead(); |
1596 | } | 1769 | } |
1597 | lexAppendc(0); | 1770 | lexAppendc(0); |
1598 | return lexStr(); | 1771 | return lexStr(); |
1599 | } | 1772 | } |
1600 | 1773 | ||
1601 | void lexPushLookahead(char *s, int len) { | ||
1602 | int putptr; | ||
1603 | if (len == 0) len = strlen(s); | ||
1604 | putptr = (int)lexBuf.getPtr - len; | ||
1605 | /* this function assumes that length of word to push back | ||
1606 | / is not greater than MAX_LEX_LOOKAHEAD. | ||
1607 | */ | ||
1608 | if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; | ||
1609 | lexBuf.getPtr = putptr; | ||
1610 | while (*s) { | ||
1611 | lexBuf.buf[putptr] = *s++; | ||
1612 | putptr = (putptr + 1) % MAX_LEX_LOOKAHEAD; | ||
1613 | } | ||
1614 | lexBuf.len += len; | ||
1615 | } | ||
1616 | |||
1617 | static void lexPushLookaheadc(int c) { | 1774 | static void lexPushLookaheadc(int c) { |
1618 | int putptr; | 1775 | int putptr; |
1619 | /* can't putback EOF, because it never leaves lookahead buffer */ | 1776 | /* can't putback EOF, because it never leaves lookahead buffer */ |
1620 | if (c == EOF) return; | 1777 | if (c == EOF) return; |
1621 | putptr = (int)lexBuf.getPtr - 1; | 1778 | putptr = (int)lexBuf.getPtr - 1; |
1622 | if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; | 1779 | if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; |
1623 | lexBuf.getPtr = putptr; | 1780 | lexBuf.getPtr = putptr; |
1624 | lexBuf.buf[putptr] = c; | 1781 | lexBuf.buf[putptr] = c; |
1625 | lexBuf.len += 1; | 1782 | lexBuf.len += 1; |
1626 | } | 1783 | } |
1627 | 1784 | ||
1628 | static char* lexLookaheadWord() { | 1785 | static char* lexLookaheadWord() { |
@@ -1713,77 +1870,69 @@ static char* lexGet1Value() { | |||
1713 | else { | 1870 | else { |
1714 | lexAppendc(c); | 1871 | lexAppendc(c); |
1715 | lexSkipLookahead(); | 1872 | lexSkipLookahead(); |
1716 | } | 1873 | } |
1717 | c = lexLookahead(); | 1874 | c = lexLookahead(); |
1718 | } | 1875 | } |
1719 | lexAppendc(0); | 1876 | lexAppendc(0); |
1720 | handleMoreRFC822LineBreak(c); | 1877 | handleMoreRFC822LineBreak(c); |
1721 | return c==EOF?0:lexStr(); | 1878 | return c==EOF?0:lexStr(); |
1722 | } | 1879 | } |
1723 | #endif | 1880 | #endif |
1724 | 1881 | ||
1725 | char* lexGetStrUntil(char *termset) { | ||
1726 | int c = lexLookahead(); | ||
1727 | lexClearToken(); | ||
1728 | while (c != EOF && !strchr(termset,c)) { | ||
1729 | lexAppendc(c); | ||
1730 | lexSkipLookahead(); | ||
1731 | c = lexLookahead(); | ||
1732 | } | ||
1733 | lexAppendc(0); | ||
1734 | return c==EOF?0:lexStr(); | ||
1735 | } | ||
1736 | 1882 | ||
1737 | static int match_begin_name(int end) { | 1883 | static int match_begin_name(int end) { |
1738 | char *n = lexLookaheadWord(); | 1884 | char *n = lexLookaheadWord(); |
1739 | int token = ID; | 1885 | int token = ID; |
1740 | if (n) { | 1886 | if (n) { |
1741 | if (!strcasecmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD; | 1887 | if (!stricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD; |
1742 | else if (!strcasecmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL; | 1888 | else if (!stricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL; |
1743 | else if (!strcasecmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT; | 1889 | else if (!stricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT; |
1744 | else if (!strcasecmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO; | 1890 | else if (!stricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO; |
1745 | deleteStr(n); | 1891 | deleteStr(n); |
1746 | return token; | 1892 | return token; |
1747 | } | 1893 | } |
1748 | return 0; | 1894 | return 0; |
1749 | } | 1895 | } |
1750 | 1896 | ||
1751 | 1897 | ||
1898 | #ifdef INCLUDEMFC | ||
1899 | void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) | ||
1900 | #else | ||
1752 | void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) | 1901 | void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) |
1902 | #endif | ||
1753 | { | 1903 | { |
1754 | /* initialize lex mode stack */ | 1904 | /* initialize lex mode stack */ |
1755 | lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL; | 1905 | lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL; |
1756 | 1906 | ||
1757 | /* iniatialize lex buffer. */ | 1907 | /* iniatialize lex buffer. */ |
1758 | lexBuf.inputString = (char*) inputstring; | 1908 | lexBuf.inputString = (char*) inputstring; |
1759 | lexBuf.inputLen = inputlen; | 1909 | lexBuf.inputLen = inputlen; |
1760 | lexBuf.curPos = 0; | 1910 | lexBuf.curPos = 0; |
1761 | lexBuf.inputFile = inputfile; | 1911 | lexBuf.inputFile = inputfile; |
1762 | 1912 | ||
1763 | lexBuf.len = 0; | 1913 | lexBuf.len = 0; |
1764 | lexBuf.getPtr = 0; | 1914 | lexBuf.getPtr = 0; |
1765 | 1915 | ||
1766 | lexBuf.maxToken = MAXTOKEN; | 1916 | lexBuf.maxToken = MAXTOKEN; |
1767 | lexBuf.strs = (char*)malloc(MAXTOKEN); | 1917 | lexBuf.strs = (char*)malloc(MAXTOKEN); |
1768 | lexBuf.strsLen = 0; | 1918 | lexBuf.strsLen = 0; |
1769 | 1919 | ||
1770 | } | 1920 | } |
1771 | 1921 | ||
1772 | static void finiLex() { | 1922 | static void finiLex() { |
1773 | free(lexBuf.strs); | 1923 | free(lexBuf.strs); |
1774 | } | 1924 | } |
1775 | 1925 | ||
1776 | 1926 | ||
1777 | /****************************************************************************/ | ||
1778 | /* This parses and converts the base64 format for binary encoding into | 1927 | /* This parses and converts the base64 format for binary encoding into |
1779 | * a decoded buffer (allocated with new). See RFC 1521. | 1928 | * a decoded buffer (allocated with new). See RFC 1521. |
1780 | */ | 1929 | */ |
1781 | static char * lexGetDataFromBase64() | 1930 | static char * lexGetDataFromBase64() |
1782 | { | 1931 | { |
1783 | unsigned long bytesLen = 0, bytesMax = 0; | 1932 | unsigned long bytesLen = 0, bytesMax = 0; |
1784 | int quadIx = 0, pad = 0; | 1933 | int quadIx = 0, pad = 0; |
1785 | unsigned long trip = 0; | 1934 | unsigned long trip = 0; |
1786 | unsigned char b; | 1935 | unsigned char b; |
1787 | int c; | 1936 | int c; |
1788 | unsigned char *bytes = NULL; | 1937 | unsigned char *bytes = NULL; |
1789 | unsigned char *oldBytes = NULL; | 1938 | unsigned char *oldBytes = NULL; |
@@ -1948,33 +2097,35 @@ static char* lexGetQuotedPrintable() | |||
1948 | break; | 2097 | break; |
1949 | default: | 2098 | default: |
1950 | lexAppendc(cur); | 2099 | lexAppendc(cur); |
1951 | break; | 2100 | break; |
1952 | } /* switch */ | 2101 | } /* switch */ |
1953 | } while (cur != (char)EOF); | 2102 | } while (cur != (char)EOF); |
1954 | 2103 | ||
1955 | EndString: | 2104 | EndString: |
1956 | lexAppendc(0); | 2105 | lexAppendc(0); |
1957 | return lexStr(); | 2106 | return lexStr(); |
1958 | } /* LexQuotedPrintable */ | 2107 | } /* LexQuotedPrintable */ |
1959 | 2108 | ||
1960 | static int yylex() { | 2109 | int yylex() { |
1961 | 2110 | ||
1962 | int lexmode = LEXMODE(); | 2111 | int lexmode = LEXMODE(); |
1963 | if (lexmode == L_VALUES) { | 2112 | if (lexmode == L_VALUES) { |
1964 | int c = lexGetc(); | 2113 | int c = lexGetc(); |
1965 | if (c == ';') { | 2114 | if (c == ';') { |
1966 | DBG_(("db: SEMICOLON\n")); | 2115 | DBG_(("db: SEMICOLON\n")); |
1967 | lexPushLookaheadc(c); | 2116 | lexPushLookaheadc(c); |
2117 | #ifdef _SUPPORT_LINE_FOLDING | ||
1968 | handleMoreRFC822LineBreak(c); | 2118 | handleMoreRFC822LineBreak(c); |
2119 | #endif | ||
1969 | lexSkipLookahead(); | 2120 | lexSkipLookahead(); |
1970 | return SEMICOLON; | 2121 | return SEMICOLON; |
1971 | } | 2122 | } |
1972 | else if (strchr("\n",c)) { | 2123 | else if (strchr("\n",c)) { |
1973 | ++mime_lineNum; | 2124 | ++mime_lineNum; |
1974 | /* consume all line separator(s) adjacent to each other */ | 2125 | /* consume all line separator(s) adjacent to each other */ |
1975 | c = lexLookahead(); | 2126 | c = lexLookahead(); |
1976 | while (strchr("\n",c)) { | 2127 | while (strchr("\n",c)) { |
1977 | lexSkipLookahead(); | 2128 | lexSkipLookahead(); |
1978 | c = lexLookahead(); | 2129 | c = lexLookahead(); |
1979 | ++mime_lineNum; | 2130 | ++mime_lineNum; |
1980 | } | 2131 | } |
@@ -1999,156 +2150,162 @@ static int yylex() { | |||
1999 | #else | 2150 | #else |
2000 | p = lexGetStrUntil(";\n"); | 2151 | p = lexGetStrUntil(";\n"); |
2001 | #endif | 2152 | #endif |
2002 | } | 2153 | } |
2003 | if (p) { | 2154 | if (p) { |
2004 | DBG_(("db: STRING: '%s'\n", p)); | 2155 | DBG_(("db: STRING: '%s'\n", p)); |
2005 | yylval.str = p; | 2156 | yylval.str = p; |
2006 | return STRING; | 2157 | return STRING; |
2007 | } | 2158 | } |
2008 | else return 0; | 2159 | else return 0; |
2009 | } | 2160 | } |
2010 | } | 2161 | } |
2011 | |||
2012 | else { | 2162 | else { |
2013 | /* normal mode */ | 2163 | /* normal mode */ |
2014 | while (1) { | 2164 | while (1) { |
2015 | int c = lexGetc(); | 2165 | int c = lexGetc(); |
2016 | switch(c) { | 2166 | switch(c) { |
2017 | case ':': { | 2167 | case ':': { |
2018 | /* consume all line separator(s) adjacent to each other */ | 2168 | /* consume all line separator(s) adjacent to each other */ |
2019 | /* ignoring linesep immediately after colon. */ | 2169 | /* ignoring linesep immediately after colon. */ |
2020 | c = lexLookahead(); | 2170 | /* c = lexLookahead(); |
2021 | while (strchr("\n",c)) { | 2171 | while (strchr("\n",c)) { |
2022 | lexSkipLookahead(); | 2172 | lexSkipLookahead(); |
2023 | c = lexLookahead(); | 2173 | c = lexLookahead(); |
2024 | ++mime_lineNum; | 2174 | ++mime_lineNum; |
2025 | } | 2175 | }*/ |
2026 | DBG_(("db: COLON\n")); | 2176 | DBG_(("db: COLON\n")); |
2027 | return COLON; | 2177 | return COLON; |
2028 | } | 2178 | } |
2029 | case ';': | 2179 | case ';': |
2030 | DBG_(("db: SEMICOLON\n")); | 2180 | DBG_(("db: SEMICOLON\n")); |
2031 | return SEMICOLON; | 2181 | return SEMICOLON; |
2032 | case '=': | 2182 | case '=': |
2033 | DBG_(("db: EQ\n")); | 2183 | DBG_(("db: EQ\n")); |
2034 | return EQ; | 2184 | return EQ; |
2035 | /* ignore tabs/newlines in this mode. We can't ignore | 2185 | /* ignore whitespace in this mode */ |
2036 | * spaces, because values like NEEDS ACTION have a space. */ | 2186 | case '\t': |
2037 | case '\t': continue; | 2187 | case ' ': continue; |
2038 | case '\n': { | 2188 | case '\n': { |
2039 | ++mime_lineNum; | 2189 | ++mime_lineNum; |
2040 | continue; | 2190 | continue; |
2041 | } | 2191 | } |
2042 | case EOF: return 0; | 2192 | case EOF: return 0; |
2043 | break; | 2193 | break; |
2044 | default: { | 2194 | default: { |
2045 | lexPushLookaheadc(c); | 2195 | lexPushLookaheadc(c); |
2046 | /* pending lutz : why linker error with isalpha(c)? */ | 2196 | if (isalpha(c)) { |
2047 | /*if ( isalpha(c) || c == ' ') { */ | ||
2048 | if ( ( c >= 'A' && c <= 'Z') || ( c >= 'a' && c <= 'z') || c == ' ') { | ||
2049 | |||
2050 | char *t = lexGetWord(); | 2197 | char *t = lexGetWord(); |
2051 | yylval.str = t; | 2198 | yylval.str = t; |
2052 | if (!strcasecmp(t, "begin")) { | 2199 | if (!stricmp(t, "begin")) { |
2053 | return match_begin_end_name(0); | 2200 | return match_begin_end_name(0); |
2054 | } | 2201 | } |
2055 | else if (!strcasecmp(t,"end")) { | 2202 | else if (!stricmp(t,"end")) { |
2056 | return match_begin_end_name(1); | 2203 | return match_begin_end_name(1); |
2057 | } | 2204 | } |
2058 | else { | 2205 | else { |
2059 | DBG_(("db: ID '%s'\n", t)); | 2206 | DBG_(("db: ID '%s'\n", t)); |
2060 | return ID; | 2207 | return ID; |
2061 | } | 2208 | } |
2062 | } | 2209 | } |
2063 | else { | 2210 | else { |
2064 | /* unknown token */ | 2211 | /* unknow token */ |
2065 | return 0; | 2212 | return 0; |
2066 | } | 2213 | } |
2067 | break; | 2214 | break; |
2068 | } | 2215 | } |
2069 | } | 2216 | } |
2070 | } | 2217 | } |
2071 | } | 2218 | } |
2072 | |||
2073 | return 0; | 2219 | return 0; |
2074 | } | 2220 | } |
2075 | 2221 | ||
2076 | 2222 | ||
2077 | /***************************************************************************/ | 2223 | /***************************************************************************/ |
2078 | /*** Public Functions ****/ | 2224 | /*** Public Functions ****/ |
2079 | /***************************************************************************/ | 2225 | /***************************************************************************/ |
2080 | 2226 | ||
2081 | static VObject* Parse_MIMEHelper() | 2227 | static VObject* Parse_MIMEHelper() |
2082 | { | 2228 | { |
2083 | ObjStackTop = -1; | 2229 | ObjStackTop = -1; |
2084 | mime_numErrors = 0; | 2230 | mime_numErrors = 0; |
2085 | mime_lineNum = 1; | 2231 | mime_lineNum = 1; |
2086 | vObjList = 0; | 2232 | vObjList = 0; |
2087 | curObj = 0; | 2233 | curObj = 0; |
2088 | 2234 | ||
2089 | if (yyparse() != 0) | 2235 | if (yyparse() != 0) |
2090 | return 0; | 2236 | return 0; |
2091 | 2237 | ||
2092 | finiLex(); | 2238 | finiLex(); |
2093 | return vObjList; | 2239 | return vObjList; |
2094 | } | 2240 | } |
2095 | 2241 | ||
2096 | /****************************************************************************/ | 2242 | DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len) |
2097 | VObject* Parse_MIME(const char *input, unsigned long len) | ||
2098 | { | 2243 | { |
2099 | initLex(input, len, 0); | 2244 | initLex(input, len, 0); |
2100 | return Parse_MIMEHelper(); | 2245 | return Parse_MIMEHelper(); |
2101 | } | 2246 | } |
2102 | 2247 | ||
2103 | 2248 | ||
2249 | #if INCLUDEMFC | ||
2250 | |||
2251 | DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file) | ||
2252 | { | ||
2253 | unsigned long startPos; | ||
2254 | VObject *result; | ||
2255 | |||
2256 | initLex(0,-1,file); | ||
2257 | startPos = file->GetPosition(); | ||
2258 | if (!(result = Parse_MIMEHelper())) | ||
2259 | file->Seek(startPos, CFile::begin); | ||
2260 | return result; | ||
2261 | } | ||
2262 | |||
2263 | #else | ||
2264 | |||
2104 | VObject* Parse_MIME_FromFile(FILE *file) | 2265 | VObject* Parse_MIME_FromFile(FILE *file) |
2105 | { | 2266 | { |
2106 | VObject *result; | 2267 | VObject *result; |
2107 | long startPos; | 2268 | long startPos; |
2108 | 2269 | ||
2109 | initLex(0,(unsigned long)-1,file); | 2270 | initLex(0,(unsigned long)-1,file); |
2110 | startPos = ftell(file); | 2271 | startPos = ftell(file); |
2111 | if (!(result = Parse_MIMEHelper())) { | 2272 | if (!(result = Parse_MIMEHelper())) { |
2112 | fseek(file,startPos,SEEK_SET); | 2273 | fseek(file,startPos,SEEK_SET); |
2113 | } | 2274 | } |
2114 | return result; | 2275 | return result; |
2115 | } | 2276 | } |
2116 | 2277 | ||
2117 | VObject* Parse_MIME_FromFileName(const char *fname) | 2278 | DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname) |
2118 | { | 2279 | { |
2119 | FILE *fp = fopen(fname,"r"); | 2280 | FILE *fp = fopen(fname,"r"); |
2120 | if (fp) { | 2281 | if (fp) { |
2121 | VObject* o = Parse_MIME_FromFile(fp); | 2282 | VObject* o = Parse_MIME_FromFile(fp); |
2122 | fclose(fp); | 2283 | fclose(fp); |
2123 | return o; | 2284 | return o; |
2124 | } | 2285 | } |
2125 | else { | 2286 | else { |
2126 | char msg[255]; | 2287 | char msg[256]; |
2127 | sprintf(msg, "can't open file '%s' for reading\n", fname); | 2288 | snprintf(msg, sizeof(msg), "can't open file '%s' for reading\n", fname); |
2128 | mime_error_(msg); | 2289 | mime_error_(msg); |
2129 | return 0; | 2290 | return 0; |
2130 | } | 2291 | } |
2131 | } | 2292 | } |
2132 | 2293 | ||
2133 | /****************************************************************************/ | 2294 | #endif |
2134 | void YYDebug(const char *s) | ||
2135 | { | ||
2136 | Parse_Debug(s); | ||
2137 | } | ||
2138 | 2295 | ||
2139 | 2296 | ||
2140 | static MimeErrorHandler mimeErrorHandler; | 2297 | static MimeErrorHandler mimeErrorHandler; |
2141 | 2298 | ||
2142 | void registerMimeErrorHandler(MimeErrorHandler me) | 2299 | DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me) |
2143 | { | 2300 | { |
2144 | mimeErrorHandler = me; | 2301 | mimeErrorHandler = me; |
2145 | } | 2302 | } |
2146 | 2303 | ||
2147 | static void mime_error(char *s) | 2304 | static void mime_error(char *s) |
2148 | { | 2305 | { |
2149 | char msg[256]; | 2306 | char msg[256]; |
2150 | if (mimeErrorHandler) { | 2307 | if (mimeErrorHandler) { |
2151 | sprintf(msg,"%s at line %d", s, mime_lineNum); | 2308 | sprintf(msg,"%s at line %d", s, mime_lineNum); |
2152 | mimeErrorHandler(msg); | 2309 | mimeErrorHandler(msg); |
2153 | } | 2310 | } |
2154 | } | 2311 | } |
diff --git a/libkcal/versit/vcc.h b/libkcal/versit/vcc.h index 03886d1..0e52034 100644 --- a/libkcal/versit/vcc.h +++ b/libkcal/versit/vcc.h | |||
@@ -39,38 +39,42 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
39 | #ifndef __VCC_H__ | 39 | #ifndef __VCC_H__ |
40 | #define __VCC_H__ 1 | 40 | #define __VCC_H__ 1 |
41 | 41 | ||
42 | #include "vobject.h" | 42 | #include "vobject.h" |
43 | 43 | ||
44 | 44 | ||
45 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) | 45 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) |
46 | extern "C" { | 46 | extern "C" { |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | typedef void (*MimeErrorHandler)(char *); | 49 | typedef void (*MimeErrorHandler)(char *); |
50 | 50 | ||
51 | extern void registerMimeErrorHandler(MimeErrorHandler); | 51 | extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); |
52 | 52 | ||
53 | extern VObject* Parse_MIME(const char *input, unsigned long len); | 53 | extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); |
54 | extern VObject* Parse_MIME_FromFileName(const char* fname); | 54 | extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); |
55 | 55 | ||
56 | 56 | ||
57 | /* NOTE regarding Parse_MIME_FromFile | 57 | /* NOTE regarding Parse_MIME_FromFile |
58 | The function below, Parse_MIME_FromFile, come in two flavors, | 58 | The function above, Parse_MIME_FromFile, comes in two flavors, |
59 | neither of which is exported from the DLL. Each version takes | 59 | neither of which is exported from the DLL. Each version takes |
60 | a CFile or FILE* as a parameter, neither of which can be | 60 | a CFile or FILE* as a parameter, neither of which can be |
61 | passed across a DLL interface (at least that is my experience). | 61 | passed across a DLL interface (at least that is my experience). |
62 | If you are linking this code into your build directly then | 62 | If you are linking this code into your build directly then |
63 | you may find them a more convenient API that the other flavors | 63 | you may find them a more convenient API that the other flavors |
64 | that take a file name. If you use them with the DLL LIB you | 64 | that take a file name. If you use them with the DLL LIB you |
65 | will get a link error. | 65 | will get a link error. |
66 | */ | 66 | */ |
67 | 67 | ||
68 | 68 | ||
69 | #if INCLUDEMFC | ||
70 | extern VObject* Parse_MIME_FromFile(CFile *file); | ||
71 | #else | ||
69 | extern VObject* Parse_MIME_FromFile(FILE *file); | 72 | extern VObject* Parse_MIME_FromFile(FILE *file); |
73 | #endif | ||
70 | 74 | ||
71 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) | 75 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) |
72 | } | 76 | } |
73 | #endif | 77 | #endif |
74 | 78 | ||
75 | #endif /* __VCC_H__ */ | 79 | #endif /* __VCC_H__ */ |
76 | 80 | ||
diff --git a/libkcal/versit/vobject.c b/libkcal/versit/vobject.c index 637efb2..3fac63e 100644 --- a/libkcal/versit/vobject.c +++ b/libkcal/versit/vobject.c | |||
@@ -33,228 +33,247 @@ PURPOSE. | |||
33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or | 33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or |
34 | disclosure by the government are subject to restrictions set forth in | 34 | disclosure by the government are subject to restrictions set forth in |
35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | 35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. |
36 | 36 | ||
37 | ***************************************************************************/ | 37 | ***************************************************************************/ |
38 | 38 | ||
39 | /* | 39 | /* |
40 | * src: vobject.c | 40 | * src: vobject.c |
41 | * doc: vobject and APIs to construct vobject, APIs pretty print | 41 | * doc: vobject and APIs to construct vobject, APIs pretty print |
42 | * vobject, and convert a vobject into its textual representation. | 42 | * vobject, and convert a vobject into its textual representation. |
43 | */ | 43 | */ |
44 | 44 | ||
45 | #include <stdlib.h> | 45 | #ifdef WIN32 |
46 | #define snprintf _snprintf | ||
47 | #define strcasecmp stricmp | ||
48 | #endif | ||
46 | 49 | ||
47 | #include "vobject.h" | 50 | #include "vobject.h" |
51 | #include <stdlib.h> | ||
48 | #include <string.h> | 52 | #include <string.h> |
49 | #include <stdio.h> | 53 | #include <stdio.h> |
50 | #ifdef _WIN32_ | 54 | #include <fcntl.h> |
51 | 55 | ||
52 | #define strcasecmp _stricmp | ||
53 | |||
54 | #endif | ||
55 | 56 | ||
56 | #define NAME_OF(o) o->id | 57 | #define NAME_OF(o) o->id |
57 | #define VALUE_TYPE(o) o->valType | 58 | #define VALUE_TYPE(o) o->valType |
58 | #define STRINGZ_VALUE_OF(o) o->val.strs | 59 | #define STRINGZ_VALUE_OF(o) o->val.strs |
59 | #define USTRINGZ_VALUE_OF(o)o->val.ustrs | 60 | #define USTRINGZ_VALUE_OF(o)o->val.ustrs |
60 | #define INTEGER_VALUE_OF(o) o->val.i | 61 | #define INTEGER_VALUE_OF(o) o->val.i |
61 | #define LONG_VALUE_OF(o) o->val.l | 62 | #define LONG_VALUE_OF(o) o->val.l |
62 | #define ANY_VALUE_OF(o) o->val.any | 63 | #define ANY_VALUE_OF(o) o->val.any |
63 | #define VOBJECT_VALUE_OF(o) o->val.vobj | 64 | #define VOBJECT_VALUE_OF(o) o->val.vobj |
64 | 65 | ||
66 | typedef union ValueItem { | ||
67 | const char *strs; | ||
68 | const wchar_t *ustrs; | ||
69 | unsigned int i; | ||
70 | unsigned long l; | ||
71 | void *any; | ||
72 | VObject *vobj; | ||
73 | } ValueItem; | ||
74 | |||
75 | struct VObject { | ||
76 | VObject *next; | ||
77 | const char *id; | ||
78 | VObject *prop; | ||
79 | unsigned short valType; | ||
80 | ValueItem val; | ||
81 | }; | ||
82 | |||
83 | typedef struct StrItem StrItem; | ||
84 | |||
85 | struct StrItem { | ||
86 | StrItem *next; | ||
87 | const char *s; | ||
88 | unsigned int refCnt; | ||
89 | }; | ||
90 | |||
65 | const char** fieldedProp; | 91 | const char** fieldedProp; |
66 | 92 | ||
67 | 93 | ||
68 | 94 | ||
69 | /*---------------------------------------------------------------------- | 95 | /*---------------------------------------------------------------------- |
70 | The following functions involve with memory allocation: | 96 | The following functions involve with memory allocation: |
71 | newVObject | 97 | newVObject |
72 | deleteVObject | 98 | deleteVObject |
73 | dupStr | 99 | dupStr |
74 | deleteStr | 100 | deleteStr |
75 | newStrItem | 101 | newStrItem |
76 | deleteStrItem | 102 | deleteStrItem |
77 | ----------------------------------------------------------------------*/ | 103 | ----------------------------------------------------------------------*/ |
78 | 104 | ||
79 | VObject* newVObject_(const char *id) | 105 | DLLEXPORT(VObject*) newVObject_(const char *id) |
80 | { | 106 | { |
81 | VObject *p = (VObject*)malloc(sizeof(VObject)); | 107 | VObject *p = (VObject*)malloc(sizeof(VObject)); |
82 | p->next = 0; | 108 | p->next = 0; |
83 | p->id = id; | 109 | p->id = id; |
84 | p->prop = 0; | 110 | p->prop = 0; |
85 | VALUE_TYPE(p) = 0; | 111 | VALUE_TYPE(p) = 0; |
86 | ANY_VALUE_OF(p) = 0; | 112 | ANY_VALUE_OF(p) = 0; |
87 | return p; | 113 | return p; |
88 | } | 114 | } |
89 | 115 | ||
90 | VObject* newVObject(const char *id) | 116 | DLLEXPORT(VObject*) newVObject(const char *id) |
91 | { | 117 | { |
92 | return newVObject_(lookupStr(id)); | 118 | return newVObject_(lookupStr(id)); |
93 | } | 119 | } |
94 | 120 | ||
95 | void deleteVObject(VObject *p) | 121 | DLLEXPORT(void) deleteVObject(VObject *p) |
96 | { | 122 | { |
97 | if (p->id) | ||
98 | unUseStr(p->id); | 123 | unUseStr(p->id); |
99 | if (p) | ||
100 | free(p); | 124 | free(p); |
101 | p = NULL; | ||
102 | } | 125 | } |
103 | 126 | ||
104 | char* dupStr(const char *s, unsigned int size) | 127 | DLLEXPORT(char*) dupStr(const char *s, unsigned int size) |
105 | { | 128 | { |
106 | char *t; | 129 | char *t; |
107 | if (size == 0) { | 130 | if (size == 0) { |
108 | size = strlen(s); | 131 | size = strlen(s); |
109 | } | 132 | } |
110 | t = (char*)malloc(size+1); | 133 | t = (char*)malloc(size+1); |
111 | if (t) { | 134 | if (t) { |
112 | memcpy(t,s,size); | 135 | memcpy(t,s,size); |
113 | t[size] = 0; | 136 | t[size] = 0; |
114 | return t; | 137 | return t; |
115 | } | 138 | } |
116 | else { | 139 | else { |
117 | return (char*)0; | 140 | return (char*)0; |
118 | } | 141 | } |
119 | } | 142 | } |
120 | 143 | ||
121 | void deleteStr(const char *p) | 144 | DLLEXPORT(void) deleteStr(const char *p) |
122 | { | 145 | { |
123 | if (p) | 146 | if (p) free((void*)p); |
124 | free((void*)p); | ||
125 | p = NULL; | ||
126 | } | 147 | } |
127 | 148 | ||
128 | 149 | ||
129 | static StrItem* newStrItem(const char *s, StrItem *next) | 150 | static StrItem* newStrItem(const char *s, StrItem *next) |
130 | { | 151 | { |
131 | StrItem *p = (StrItem*)malloc(sizeof(StrItem)); | 152 | StrItem *p = (StrItem*)malloc(sizeof(StrItem)); |
132 | p->next = next; | 153 | p->next = next; |
133 | p->s = s; | 154 | p->s = s; |
134 | p->refCnt = 1; | 155 | p->refCnt = 1; |
135 | return p; | 156 | return p; |
136 | } | 157 | } |
137 | 158 | ||
138 | static void deleteStrItem(StrItem *p) | 159 | static void deleteStrItem(StrItem *p) |
139 | { | 160 | { |
140 | if (p) | ||
141 | free((void*)p); | 161 | free((void*)p); |
142 | p = NULL; | ||
143 | } | 162 | } |
144 | 163 | ||
145 | 164 | ||
146 | /*---------------------------------------------------------------------- | 165 | /*---------------------------------------------------------------------- |
147 | The following function provide accesses to VObject's value. | 166 | The following function provide accesses to VObject's value. |
148 | ----------------------------------------------------------------------*/ | 167 | ----------------------------------------------------------------------*/ |
149 | 168 | ||
150 | const char* vObjectName(VObject *o) | 169 | DLLEXPORT(const char*) vObjectName(VObject *o) |
151 | { | 170 | { |
152 | return NAME_OF(o); | 171 | return NAME_OF(o); |
153 | } | 172 | } |
154 | 173 | ||
155 | void setVObjectName(VObject *o, const char* id) | 174 | DLLEXPORT(void) setVObjectName(VObject *o, const char* id) |
156 | { | 175 | { |
157 | NAME_OF(o) = id; | 176 | NAME_OF(o) = id; |
158 | } | 177 | } |
159 | 178 | ||
160 | const char* vObjectStringZValue(VObject *o) | 179 | DLLEXPORT(const char*) vObjectStringZValue(VObject *o) |
161 | { | 180 | { |
162 | return STRINGZ_VALUE_OF(o); | 181 | return STRINGZ_VALUE_OF(o); |
163 | } | 182 | } |
164 | 183 | ||
165 | void setVObjectStringZValue(VObject *o, const char *s) | 184 | DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s) |
166 | { | 185 | { |
167 | STRINGZ_VALUE_OF(o) = dupStr(s,0); | 186 | STRINGZ_VALUE_OF(o) = dupStr(s,0); |
168 | VALUE_TYPE(o) = VCVT_STRINGZ; | 187 | VALUE_TYPE(o) = VCVT_STRINGZ; |
169 | } | 188 | } |
170 | 189 | ||
171 | void setVObjectStringZValue_(VObject *o, const char *s) | 190 | DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s) |
172 | { | 191 | { |
173 | STRINGZ_VALUE_OF(o) = s; | 192 | STRINGZ_VALUE_OF(o) = s; |
174 | VALUE_TYPE(o) = VCVT_STRINGZ; | 193 | VALUE_TYPE(o) = VCVT_STRINGZ; |
175 | } | 194 | } |
176 | 195 | ||
177 | const wchar_t* vObjectUStringZValue(VObject *o) | 196 | DLLEXPORT(const wchar_t*) vObjectUStringZValue(VObject *o) |
178 | { | 197 | { |
179 | return USTRINGZ_VALUE_OF(o); | 198 | return USTRINGZ_VALUE_OF(o); |
180 | } | 199 | } |
181 | 200 | ||
182 | void setVObjectUStringZValue(VObject *o, const wchar_t *s) | 201 | DLLEXPORT(void) setVObjectUStringZValue(VObject *o, const wchar_t *s) |
183 | { | 202 | { |
184 | USTRINGZ_VALUE_OF(o) = (wchar_t*) dupStr((char*)s,(uStrLen(s)+1)*2); | 203 | USTRINGZ_VALUE_OF(o) = (wchar_t*) dupStr((char*)s,(uStrLen(s)+1)*2); |
185 | VALUE_TYPE(o) = VCVT_USTRINGZ; | 204 | VALUE_TYPE(o) = VCVT_USTRINGZ; |
186 | } | 205 | } |
187 | 206 | ||
188 | void setVObjectUStringZValue_(VObject *o, const wchar_t *s) | 207 | DLLEXPORT(void) setVObjectUStringZValue_(VObject *o, const wchar_t *s) |
189 | { | 208 | { |
190 | USTRINGZ_VALUE_OF(o) = s; | 209 | USTRINGZ_VALUE_OF(o) = s; |
191 | VALUE_TYPE(o) = VCVT_USTRINGZ; | 210 | VALUE_TYPE(o) = VCVT_USTRINGZ; |
192 | } | 211 | } |
193 | 212 | ||
194 | unsigned int vObjectIntegerValue(VObject *o) | 213 | DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o) |
195 | { | 214 | { |
196 | return INTEGER_VALUE_OF(o); | 215 | return INTEGER_VALUE_OF(o); |
197 | } | 216 | } |
198 | 217 | ||
199 | void setVObjectIntegerValue(VObject *o, unsigned int i) | 218 | DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i) |
200 | { | 219 | { |
201 | INTEGER_VALUE_OF(o) = i; | 220 | INTEGER_VALUE_OF(o) = i; |
202 | VALUE_TYPE(o) = VCVT_UINT; | 221 | VALUE_TYPE(o) = VCVT_UINT; |
203 | } | 222 | } |
204 | 223 | ||
205 | unsigned long vObjectLongValue(VObject *o) | 224 | DLLEXPORT(unsigned long) vObjectLongValue(VObject *o) |
206 | { | 225 | { |
207 | return LONG_VALUE_OF(o); | 226 | return LONG_VALUE_OF(o); |
208 | } | 227 | } |
209 | 228 | ||
210 | void setVObjectLongValue(VObject *o, unsigned long l) | 229 | DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l) |
211 | { | 230 | { |
212 | LONG_VALUE_OF(o) = l; | 231 | LONG_VALUE_OF(o) = l; |
213 | VALUE_TYPE(o) = VCVT_ULONG; | 232 | VALUE_TYPE(o) = VCVT_ULONG; |
214 | } | 233 | } |
215 | 234 | ||
216 | void* vObjectAnyValue(VObject *o) | 235 | DLLEXPORT(void*) vObjectAnyValue(VObject *o) |
217 | { | 236 | { |
218 | return ANY_VALUE_OF(o); | 237 | return ANY_VALUE_OF(o); |
219 | } | 238 | } |
220 | 239 | ||
221 | void setVObjectAnyValue(VObject *o, void *t) | 240 | DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t) |
222 | { | 241 | { |
223 | ANY_VALUE_OF(o) = t; | 242 | ANY_VALUE_OF(o) = t; |
224 | VALUE_TYPE(o) = VCVT_RAW; | 243 | VALUE_TYPE(o) = VCVT_RAW; |
225 | } | 244 | } |
226 | 245 | ||
227 | VObject* vObjectVObjectValue(VObject *o) | 246 | DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o) |
228 | { | 247 | { |
229 | return VOBJECT_VALUE_OF(o); | 248 | return VOBJECT_VALUE_OF(o); |
230 | } | 249 | } |
231 | 250 | ||
232 | void setVObjectVObjectValue(VObject *o, VObject *p) | 251 | DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p) |
233 | { | 252 | { |
234 | VOBJECT_VALUE_OF(o) = p; | 253 | VOBJECT_VALUE_OF(o) = p; |
235 | VALUE_TYPE(o) = VCVT_VOBJECT; | 254 | VALUE_TYPE(o) = VCVT_VOBJECT; |
236 | } | 255 | } |
237 | 256 | ||
238 | int vObjectValueType(VObject *o) | 257 | DLLEXPORT(int) vObjectValueType(VObject *o) |
239 | { | 258 | { |
240 | return VALUE_TYPE(o); | 259 | return VALUE_TYPE(o); |
241 | } | 260 | } |
242 | 261 | ||
243 | 262 | ||
244 | /*---------------------------------------------------------------------- | 263 | /*---------------------------------------------------------------------- |
245 | The following functions can be used to build VObject. | 264 | The following functions can be used to build VObject. |
246 | ----------------------------------------------------------------------*/ | 265 | ----------------------------------------------------------------------*/ |
247 | 266 | ||
248 | VObject* addVObjectProp(VObject *o, VObject *p) | 267 | DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p) |
249 | { | 268 | { |
250 | /* circular link list pointed to tail */ | 269 | /* circular link list pointed to tail */ |
251 | /* | 270 | /* |
252 | o {next,id,prop,val} | 271 | o {next,id,prop,val} |
253 | V | 272 | V |
254 | pn {next,id,prop,val} | 273 | pn {next,id,prop,val} |
255 | V | 274 | V |
256 | ... | 275 | ... |
257 | p1 {next,id,prop,val} | 276 | p1 {next,id,prop,val} |
258 | V | 277 | V |
259 | pn | 278 | pn |
260 | --> | 279 | --> |
@@ -271,114 +290,114 @@ VObject* addVObjectProp(VObject *o, VObject *p) | |||
271 | 290 | ||
272 | VObject *tail = o->prop; | 291 | VObject *tail = o->prop; |
273 | if (tail) { | 292 | if (tail) { |
274 | p->next = tail->next; | 293 | p->next = tail->next; |
275 | o->prop = tail->next = p; | 294 | o->prop = tail->next = p; |
276 | } | 295 | } |
277 | else { | 296 | else { |
278 | o->prop = p->next = p; | 297 | o->prop = p->next = p; |
279 | } | 298 | } |
280 | return p; | 299 | return p; |
281 | } | 300 | } |
282 | 301 | ||
283 | VObject* addProp(VObject *o, const char *id) | 302 | DLLEXPORT(VObject*) addProp(VObject *o, const char *id) |
284 | { | 303 | { |
285 | return addVObjectProp(o,newVObject(id)); | 304 | return addVObjectProp(o,newVObject(id)); |
286 | } | 305 | } |
287 | 306 | ||
288 | VObject* addProp_(VObject *o, const char *id) | 307 | DLLEXPORT(VObject*) addProp_(VObject *o, const char *id) |
289 | { | 308 | { |
290 | return addVObjectProp(o,newVObject_(id)); | 309 | return addVObjectProp(o,newVObject_(id)); |
291 | } | 310 | } |
292 | 311 | ||
293 | void addList(VObject **o, VObject *p) | 312 | DLLEXPORT(void) addList(VObject **o, VObject *p) |
294 | { | 313 | { |
295 | p->next = 0; | 314 | p->next = 0; |
296 | if (*o == 0) { | 315 | if (*o == 0) { |
297 | *o = p; | 316 | *o = p; |
298 | } | 317 | } |
299 | else { | 318 | else { |
300 | VObject *t = *o; | 319 | VObject *t = *o; |
301 | while (t->next) { | 320 | while (t->next) { |
302 | t = t->next; | 321 | t = t->next; |
303 | } | 322 | } |
304 | t->next = p; | 323 | t->next = p; |
305 | } | 324 | } |
306 | } | 325 | } |
307 | 326 | ||
308 | VObject* nextVObjectInList(VObject *o) | 327 | DLLEXPORT(VObject*) nextVObjectInList(VObject *o) |
309 | { | 328 | { |
310 | return o->next; | 329 | return o->next; |
311 | } | 330 | } |
312 | 331 | ||
313 | VObject* setValueWithSize_(VObject *prop, void *val, unsigned int size) | 332 | DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size) |
314 | { | 333 | { |
315 | VObject *sizeProp; | 334 | VObject *sizeProp; |
316 | setVObjectAnyValue(prop, val); | 335 | setVObjectAnyValue(prop, val); |
317 | sizeProp = addProp(prop,VCDataSizeProp); | 336 | sizeProp = addProp(prop,VCDataSizeProp); |
318 | setVObjectLongValue(sizeProp, size); | 337 | setVObjectLongValue(sizeProp, size); |
319 | return prop; | 338 | return prop; |
320 | } | 339 | } |
321 | 340 | ||
322 | VObject* setValueWithSize(VObject *prop, void *val, unsigned int size) | 341 | DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size) |
323 | { | 342 | { |
324 | void *p = dupStr(val,size); | 343 | void *p = dupStr((const char *)val,size); |
325 | return setValueWithSize_(prop,p,p?size:0); | 344 | return setValueWithSize_(prop,p,p?size:0); |
326 | } | 345 | } |
327 | 346 | ||
328 | void initPropIterator(VObjectIterator *i, VObject *o) | 347 | DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o) |
329 | { | 348 | { |
330 | i->start = o->prop; | 349 | i->start = o->prop; |
331 | i->next = 0; | 350 | i->next = 0; |
332 | } | 351 | } |
333 | 352 | ||
334 | void initVObjectIterator(VObjectIterator *i, VObject *o) | 353 | DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o) |
335 | { | 354 | { |
336 | i->start = o->next; | 355 | i->start = o->next; |
337 | i->next = 0; | 356 | i->next = 0; |
338 | } | 357 | } |
339 | 358 | ||
340 | int moreIteration(VObjectIterator *i) | 359 | DLLEXPORT(int) moreIteration(VObjectIterator *i) |
341 | { | 360 | { |
342 | return (i->start && (i->next==0 || i->next!=i->start)); | 361 | return (i->start && (i->next==0 || i->next!=i->start)); |
343 | } | 362 | } |
344 | 363 | ||
345 | VObject* nextVObject(VObjectIterator *i) | 364 | DLLEXPORT(VObject*) nextVObject(VObjectIterator *i) |
346 | { | 365 | { |
347 | if (i->start && i->next != i->start) { | 366 | if (i->start && i->next != i->start) { |
348 | if (i->next == 0) { | 367 | if (i->next == 0) { |
349 | i->next = i->start->next; | 368 | i->next = i->start->next; |
350 | return i->next; | 369 | return i->next; |
351 | } | 370 | } |
352 | else { | 371 | else { |
353 | i->next = i->next->next; | 372 | i->next = i->next->next; |
354 | return i->next; | 373 | return i->next; |
355 | } | 374 | } |
356 | } | 375 | } |
357 | else return (VObject*)0; | 376 | else return (VObject*)0; |
358 | } | 377 | } |
359 | 378 | ||
360 | VObject* isAPropertyOf(VObject *o, const char *id) | 379 | DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id) |
361 | { | 380 | { |
362 | VObjectIterator i; | 381 | VObjectIterator i; |
363 | initPropIterator(&i,o); | 382 | initPropIterator(&i,o); |
364 | while (moreIteration(&i)) { | 383 | while (moreIteration(&i)) { |
365 | VObject *each = nextVObject(&i); | 384 | VObject *each = nextVObject(&i); |
366 | if (!strcasecmp(id,each->id)) | 385 | if (!stricmp(id,each->id)) |
367 | return each; | 386 | return each; |
368 | } | 387 | } |
369 | return (VObject*)0; | 388 | return (VObject*)0; |
370 | } | 389 | } |
371 | 390 | ||
372 | VObject* addGroup(VObject *o, const char *g) | 391 | DLLEXPORT(VObject*) addGroup(VObject *o, const char *g) |
373 | { | 392 | { |
374 | /* | 393 | /* |
375 | a.b.c | 394 | a.b.c |
376 | --> | 395 | --> |
377 | prop(c) | 396 | prop(c) |
378 | prop(VCGrouping=b) | 397 | prop(VCGrouping=b) |
379 | prop(VCGrouping=a) | 398 | prop(VCGrouping=a) |
380 | */ | 399 | */ |
381 | char *dot = strrchr(g,'.'); | 400 | char *dot = strrchr(g,'.'); |
382 | if (dot) { | 401 | if (dot) { |
383 | VObject *p, *t; | 402 | VObject *p, *t; |
384 | char *gs, *n = dot+1; | 403 | char *gs, *n = dot+1; |
@@ -401,42 +420,42 @@ VObject* addGroup(VObject *o, const char *g) | |||
401 | *and the value may have VCGrouping property | 420 | *and the value may have VCGrouping property |
402 | */ | 421 | */ |
403 | t = addProp(t,VCGroupingProp); | 422 | t = addProp(t,VCGroupingProp); |
404 | setVObjectStringZValue(t,lookupProp_(n)); | 423 | setVObjectStringZValue(t,lookupProp_(n)); |
405 | } while (n != gs); | 424 | } while (n != gs); |
406 | deleteStr(gs); | 425 | deleteStr(gs); |
407 | return p; | 426 | return p; |
408 | } | 427 | } |
409 | else | 428 | else |
410 | return addProp_(o,lookupProp(g)); | 429 | return addProp_(o,lookupProp(g)); |
411 | } | 430 | } |
412 | 431 | ||
413 | VObject* addPropValue(VObject *o, const char *p, const char *v) | 432 | DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v) |
414 | { | 433 | { |
415 | VObject *prop; | 434 | VObject *prop; |
416 | prop = addProp(o,p); | 435 | prop = addProp(o,p); |
417 | setVObjectUStringZValue_(prop, fakeUnicode(v,0)); | 436 | setVObjectUStringZValue_(prop, fakeUnicode(v,0)); |
418 | return prop; | 437 | return prop; |
419 | } | 438 | } |
420 | 439 | ||
421 | VObject* addPropSizedValue_(VObject *o, const char *p, const char *v, | 440 | DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, |
422 | unsigned int size) | 441 | unsigned int size) |
423 | { | 442 | { |
424 | VObject *prop; | 443 | VObject *prop; |
425 | prop = addProp(o,p); | 444 | prop = addProp(o,p); |
426 | setValueWithSize_(prop, (void*)v, size); | 445 | setValueWithSize_(prop, (void*)v, size); |
427 | return prop; | 446 | return prop; |
428 | } | 447 | } |
429 | 448 | ||
430 | VObject* addPropSizedValue(VObject *o, const char *p, const char *v, | 449 | DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, |
431 | unsigned int size) | 450 | unsigned int size) |
432 | { | 451 | { |
433 | return addPropSizedValue_(o,p,dupStr(v,size),size); | 452 | return addPropSizedValue_(o,p,dupStr(v,size),size); |
434 | } | 453 | } |
435 | 454 | ||
436 | 455 | ||
437 | 456 | ||
438 | /*---------------------------------------------------------------------- | 457 | /*---------------------------------------------------------------------- |
439 | The following pretty print a VObject | 458 | The following pretty print a VObject |
440 | ----------------------------------------------------------------------*/ | 459 | ----------------------------------------------------------------------*/ |
441 | 460 | ||
442 | static void printVObject_(FILE *fp, VObject *o, int level); | 461 | static void printVObject_(FILE *fp, VObject *o, int level); |
@@ -519,46 +538,46 @@ static void printVObject_(FILE *fp, VObject *o, int level) | |||
519 | initPropIterator(&t,o); | 538 | initPropIterator(&t,o); |
520 | while (moreIteration(&t)) { | 539 | while (moreIteration(&t)) { |
521 | VObject *eachProp = nextVObject(&t); | 540 | VObject *eachProp = nextVObject(&t); |
522 | printVObject_(fp,eachProp,level+1); | 541 | printVObject_(fp,eachProp,level+1); |
523 | } | 542 | } |
524 | } | 543 | } |
525 | 544 | ||
526 | void printVObject(FILE *fp,VObject *o) | 545 | void printVObject(FILE *fp,VObject *o) |
527 | { | 546 | { |
528 | printVObject_(fp,o,0); | 547 | printVObject_(fp,o,0); |
529 | } | 548 | } |
530 | 549 | ||
531 | void printVObjectToFile(char *fname,VObject *o) | 550 | DLLEXPORT(void) printVObjectToFile(char *fname,VObject *o) |
532 | { | 551 | { |
533 | FILE *fp = fopen(fname,"w"); | 552 | FILE *fp = fopen(fname,"w"); |
534 | if (fp) { | 553 | if (fp) { |
535 | printVObject(fp,o); | 554 | printVObject(fp,o); |
536 | fclose(fp); | 555 | fclose(fp); |
537 | } | 556 | } |
538 | } | 557 | } |
539 | 558 | ||
540 | void printVObjectsToFile(char *fname,VObject *list) | 559 | DLLEXPORT(void) printVObjectsToFile(char *fname,VObject *list) |
541 | { | 560 | { |
542 | FILE *fp = fopen(fname,"w"); | 561 | FILE *fp = fopen(fname,"w"); |
543 | if (fp) { | 562 | if (fp) { |
544 | while (list) { | 563 | while (list) { |
545 | printVObject(fp,list); | 564 | printVObject(fp,list); |
546 | list = nextVObjectInList(list); | 565 | list = nextVObjectInList(list); |
547 | } | 566 | } |
548 | fclose(fp); | 567 | fclose(fp); |
549 | } | 568 | } |
550 | } | 569 | } |
551 | 570 | ||
552 | void cleanVObject(VObject *o) | 571 | DLLEXPORT(void) cleanVObject(VObject *o) |
553 | { | 572 | { |
554 | if (o == 0) return; | 573 | if (o == 0) return; |
555 | if (o->prop) { | 574 | if (o->prop) { |
556 | /* destroy time: cannot use the iterator here. | 575 | /* destroy time: cannot use the iterator here. |
557 | Have to break the cycle in the circular link | 576 | Have to break the cycle in the circular link |
558 | list and turns it into regular NULL-terminated | 577 | list and turns it into regular NULL-terminated |
559 | list -- since at some point of destruction, | 578 | list -- since at some point of destruction, |
560 | the reference entry for the iterator to work | 579 | the reference entry for the iterator to work |
561 | will not longer be valid. | 580 | will not longer be valid. |
562 | */ | 581 | */ |
563 | VObject *p; | 582 | VObject *p; |
564 | p = o->prop->next; | 583 | p = o->prop->next; |
@@ -574,25 +593,25 @@ void cleanVObject(VObject *o) | |||
574 | case VCVT_STRINGZ: | 593 | case VCVT_STRINGZ: |
575 | case VCVT_RAW: | 594 | case VCVT_RAW: |
576 | /* assume they are all allocated by malloc. */ | 595 | /* assume they are all allocated by malloc. */ |
577 | free((char*)STRINGZ_VALUE_OF(o)); | 596 | free((char*)STRINGZ_VALUE_OF(o)); |
578 | break; | 597 | break; |
579 | case VCVT_VOBJECT: | 598 | case VCVT_VOBJECT: |
580 | cleanVObject(VOBJECT_VALUE_OF(o)); | 599 | cleanVObject(VOBJECT_VALUE_OF(o)); |
581 | break; | 600 | break; |
582 | } | 601 | } |
583 | deleteVObject(o); | 602 | deleteVObject(o); |
584 | } | 603 | } |
585 | 604 | ||
586 | void cleanVObjects(VObject *list) | 605 | DLLEXPORT(void) cleanVObjects(VObject *list) |
587 | { | 606 | { |
588 | while (list) { | 607 | while (list) { |
589 | VObject *t = list; | 608 | VObject *t = list; |
590 | list = nextVObjectInList(list); | 609 | list = nextVObjectInList(list); |
591 | cleanVObject(t); | 610 | cleanVObject(t); |
592 | } | 611 | } |
593 | } | 612 | } |
594 | 613 | ||
595 | /*---------------------------------------------------------------------- | 614 | /*---------------------------------------------------------------------- |
596 | The following is a String Table Facilities. | 615 | The following is a String Table Facilities. |
597 | ----------------------------------------------------------------------*/ | 616 | ----------------------------------------------------------------------*/ |
598 | 617 | ||
@@ -601,85 +620,81 @@ void cleanVObjects(VObject *list) | |||
601 | static StrItem *strTbl[STRTBLSIZE]; | 620 | static StrItem *strTbl[STRTBLSIZE]; |
602 | 621 | ||
603 | static unsigned int hashStr(const char *s) | 622 | static unsigned int hashStr(const char *s) |
604 | { | 623 | { |
605 | unsigned int h = 0; | 624 | unsigned int h = 0; |
606 | int i; | 625 | int i; |
607 | for (i=0;s[i];i++) { | 626 | for (i=0;s[i];i++) { |
608 | h += s[i]*i; | 627 | h += s[i]*i; |
609 | } | 628 | } |
610 | return h % STRTBLSIZE; | 629 | return h % STRTBLSIZE; |
611 | } | 630 | } |
612 | 631 | ||
613 | const char* lookupStr(const char *s) | 632 | DLLEXPORT(const char*) lookupStr(const char *s) |
614 | { | 633 | { |
615 | char *newS; | ||
616 | |||
617 | StrItem *t; | 634 | StrItem *t; |
618 | unsigned int h = hashStr(s); | 635 | unsigned int h = hashStr(s); |
619 | if ((t = strTbl[h]) != 0) { | 636 | if ((t = strTbl[h]) != 0) { |
620 | do { | 637 | do { |
621 | if (strcasecmp(t->s,s) == 0) { | 638 | if (stricmp(t->s,s) == 0) { |
622 | t->refCnt++; | 639 | t->refCnt++; |
623 | return t->s; | 640 | return t->s; |
624 | } | 641 | } |
625 | t = t->next; | 642 | t = t->next; |
626 | } while (t); | 643 | } while (t); |
627 | } | 644 | } |
628 | newS = dupStr(s,0); | 645 | s = dupStr(s,0); |
629 | strTbl[h] = newStrItem(newS,strTbl[h]); | 646 | strTbl[h] = newStrItem(s,strTbl[h]); |
630 | return newS; | 647 | return s; |
631 | } | 648 | } |
632 | 649 | ||
633 | void unUseStr(const char *s) | 650 | DLLEXPORT(void) unUseStr(const char *s) |
634 | { | 651 | { |
635 | StrItem *cur, *prev; | 652 | StrItem *t, *p; |
636 | |||
637 | unsigned int h = hashStr(s); | 653 | unsigned int h = hashStr(s); |
638 | cur = strTbl[h]; | 654 | if ((t = strTbl[h]) != 0) { |
639 | prev = cur; | 655 | p = t; |
640 | while (cur != 0) { | 656 | do { |
641 | if (strcasecmp(cur->s,s) == 0) { | 657 | if (stricmp(t->s,s) == 0) { |
642 | cur->refCnt--; | 658 | t->refCnt--; |
643 | /* if that was the last reference to this string, kill it. */ | 659 | if (t->refCnt == 0) { |
644 | if (cur->refCnt == 0) { | 660 | if (p == strTbl[h]) { |
645 | if (cur == strTbl[h]) { | 661 | strTbl[h] = t->next; |
646 | strTbl[h] = cur->next; | 662 | } |
647 | deleteStr(prev->s); | 663 | else { |
648 | deleteStrItem(prev); | 664 | p->next = t->next; |
649 | } else { | ||
650 | prev->next = cur->next; | ||
651 | deleteStr(cur->s); | ||
652 | deleteStrItem(cur); | ||
653 | } | 665 | } |
666 | deleteStr(t->s); | ||
667 | deleteStrItem(t); | ||
654 | return; | 668 | return; |
655 | } | 669 | } |
656 | } | 670 | } |
657 | prev = cur; | 671 | p = t; |
658 | cur = cur->next; | 672 | t = t->next; |
673 | } while (t); | ||
659 | } | 674 | } |
660 | } | 675 | } |
661 | 676 | ||
662 | void cleanStrTbl() | 677 | DLLEXPORT(void) cleanStrTbl() |
663 | { | 678 | { |
664 | int i; | 679 | int i; |
665 | for (i=0; i<STRTBLSIZE;i++) { | 680 | for (i=0; i<STRTBLSIZE;i++) { |
666 | StrItem *t = strTbl[i]; | 681 | StrItem *t = strTbl[i]; |
667 | while (t) { | 682 | while (t) { |
668 | StrItem *p; | 683 | StrItem *p; |
669 | deleteStr(t->s); | 684 | deleteStr(t->s); |
670 | p = t; | 685 | p = t; |
671 | t = t->next; | 686 | t = t->next; |
672 | deleteStrItem(p); | 687 | deleteStrItem(p); |
673 | } | 688 | } while (t); |
674 | strTbl[i] = 0; | 689 | strTbl[i] = 0; |
675 | } | 690 | } |
676 | } | 691 | } |
677 | 692 | ||
678 | 693 | ||
679 | struct PreDefProp { | 694 | struct PreDefProp { |
680 | const char *name; | 695 | const char *name; |
681 | const char *alias; | 696 | const char *alias; |
682 | const char** fields; | 697 | const char** fields; |
683 | unsigned int flags; | 698 | unsigned int flags; |
684 | }; | 699 | }; |
685 | 700 | ||
@@ -798,25 +813,25 @@ static struct PreDefProp propNames[] = { | |||
798 | { VCDIBProp, 0, 0, 0 }, | 813 | { VCDIBProp, 0, 0, 0 }, |
799 | { VCDisplayStringProp, 0, 0, 0 }, | 814 | { VCDisplayStringProp, 0, 0, 0 }, |
800 | { VCDomesticProp, 0, 0, 0 }, | 815 | { VCDomesticProp, 0, 0, 0 }, |
801 | { VCDTendProp, 0, 0, 0 }, | 816 | { VCDTendProp, 0, 0, 0 }, |
802 | { VCDTstartProp, 0, 0, 0 }, | 817 | { VCDTstartProp, 0, 0, 0 }, |
803 | { VCDueProp, 0, 0, 0 }, | 818 | { VCDueProp, 0, 0, 0 }, |
804 | { VCEmailAddressProp, 0, 0, 0 }, | 819 | { VCEmailAddressProp, 0, 0, 0 }, |
805 | { VCEncodingProp, 0, 0, 0 }, | 820 | { VCEncodingProp, 0, 0, 0 }, |
806 | { VCEndProp, 0, 0, 0 }, | 821 | { VCEndProp, 0, 0, 0 }, |
807 | { VCEventProp, 0, 0, PD_BEGIN }, | 822 | { VCEventProp, 0, 0, PD_BEGIN }, |
808 | { VCEWorldProp, 0, 0, 0 }, | 823 | { VCEWorldProp, 0, 0, 0 }, |
809 | { VCExNumProp, 0, 0, 0 }, | 824 | { VCExNumProp, 0, 0, 0 }, |
810 | { VCExDateProp, 0, 0, 0 }, | 825 | { VCExpDateProp, 0, 0, 0 }, |
811 | { VCExpectProp, 0, 0, 0 }, | 826 | { VCExpectProp, 0, 0, 0 }, |
812 | { VCExtAddressProp, 0, 0, 0 }, | 827 | { VCExtAddressProp, 0, 0, 0 }, |
813 | { VCFamilyNameProp, 0, 0, 0 }, | 828 | { VCFamilyNameProp, 0, 0, 0 }, |
814 | { VCFaxProp, 0, 0, 0 }, | 829 | { VCFaxProp, 0, 0, 0 }, |
815 | { VCFullNameProp, 0, 0, 0 }, | 830 | { VCFullNameProp, 0, 0, 0 }, |
816 | { VCGeoLocationProp, 0, 0, 0 }, | 831 | { VCGeoLocationProp, 0, 0, 0 }, |
817 | { VCGeoProp, 0, 0, 0 }, | 832 | { VCGeoProp, 0, 0, 0 }, |
818 | { VCGIFProp, 0, 0, 0 }, | 833 | { VCGIFProp, 0, 0, 0 }, |
819 | { VCGivenNameProp, 0, 0, 0 }, | 834 | { VCGivenNameProp, 0, 0, 0 }, |
820 | { VCGroupingProp, 0, 0, 0 }, | 835 | { VCGroupingProp, 0, 0, 0 }, |
821 | { VCHomeProp, 0, 0, 0 }, | 836 | { VCHomeProp, 0, 0, 0 }, |
822 | { VCIBMMailProp, 0, 0, 0 }, | 837 | { VCIBMMailProp, 0, 0, 0 }, |
@@ -912,138 +927,129 @@ static struct PreDefProp propNames[] = { | |||
912 | { VCX509Prop, 0, 0, 0 }, | 927 | { VCX509Prop, 0, 0, 0 }, |
913 | { VCXRuleProp, 0, 0, 0 }, | 928 | { VCXRuleProp, 0, 0, 0 }, |
914 | { 0,0,0,0 } | 929 | { 0,0,0,0 } |
915 | }; | 930 | }; |
916 | 931 | ||
917 | 932 | ||
918 | static struct PreDefProp* lookupPropInfo(const char* str) | 933 | static struct PreDefProp* lookupPropInfo(const char* str) |
919 | { | 934 | { |
920 | /* brute force for now, could use a hash table here. */ | 935 | /* brute force for now, could use a hash table here. */ |
921 | int i; | 936 | int i; |
922 | 937 | ||
923 | for (i = 0; propNames[i].name; i++) | 938 | for (i = 0; propNames[i].name; i++) |
924 | if (strcasecmp(str, propNames[i].name) == 0) { | 939 | if (stricmp(str, propNames[i].name) == 0) { |
925 | return &propNames[i]; | 940 | return &propNames[i]; |
926 | } | 941 | } |
927 | 942 | ||
928 | return 0; | 943 | return 0; |
929 | } | 944 | } |
930 | 945 | ||
931 | 946 | ||
932 | const char* lookupProp_(const char* str) | 947 | DLLEXPORT(const char*) lookupProp_(const char* str) |
933 | { | 948 | { |
934 | int i; | 949 | int i; |
935 | 950 | ||
936 | for (i = 0; propNames[i].name; i++) | 951 | for (i = 0; propNames[i].name; i++) |
937 | if (strcasecmp(str, propNames[i].name) == 0) { | 952 | if (stricmp(str, propNames[i].name) == 0) { |
938 | const char* s; | 953 | const char* s; |
939 | s = propNames[i].alias?propNames[i].alias:propNames[i].name; | 954 | s = propNames[i].alias?propNames[i].alias:propNames[i].name; |
940 | return lookupStr(s); | 955 | return lookupStr(s); |
941 | } | 956 | } |
942 | return lookupStr(str); | 957 | return lookupStr(str); |
943 | } | 958 | } |
944 | 959 | ||
945 | 960 | ||
946 | const char* lookupProp(const char* str) | 961 | DLLEXPORT(const char*) lookupProp(const char* str) |
947 | { | 962 | { |
948 | int i; | 963 | int i; |
949 | 964 | ||
950 | for (i = 0; propNames[i].name; i++) | 965 | for (i = 0; propNames[i].name; i++) |
951 | if (strcasecmp(str, propNames[i].name) == 0) { | 966 | if (stricmp(str, propNames[i].name) == 0) { |
952 | const char *s; | 967 | const char *s; |
953 | fieldedProp = propNames[i].fields; | 968 | fieldedProp = propNames[i].fields; |
954 | s = propNames[i].alias?propNames[i].alias:propNames[i].name; | 969 | s = propNames[i].alias?propNames[i].alias:propNames[i].name; |
955 | return lookupStr(s); | 970 | return lookupStr(s); |
956 | } | 971 | } |
957 | fieldedProp = 0; | 972 | fieldedProp = 0; |
958 | return lookupStr(str); | 973 | return lookupStr(str); |
959 | } | 974 | } |
960 | 975 | ||
961 | 976 | ||
962 | /*---------------------------------------------------------------------- | 977 | /*---------------------------------------------------------------------- |
963 | APIs to Output text form. | 978 | APIs to Output text form. |
964 | ----------------------------------------------------------------------*/ | 979 | ----------------------------------------------------------------------*/ |
965 | #define OFILE_REALLOC_SIZE 256 | 980 | #define OFILE_REALLOC_SIZE 256 |
966 | typedef struct OFile { | 981 | typedef struct OFile { |
967 | FILE *fp; | 982 | FILE *fp; |
968 | char *s; | 983 | char *s; |
969 | int len; | 984 | int len; |
970 | int limit; | 985 | int limit; |
971 | int alloc:1; | 986 | int alloc:1; |
972 | int fail:1; | 987 | int fail:1; |
973 | } OFile; | 988 | } OFile; |
974 | 989 | ||
975 | |||
976 | /* vCalendar files need crlf linebreaks. The disabled functions didn't provide | ||
977 | that. */ | ||
978 | #if 0 | 990 | #if 0 |
979 | |||
980 | static void appendsOFile(OFile *fp, const char *s) | 991 | static void appendsOFile(OFile *fp, const char *s) |
981 | { | 992 | { |
982 | int slen; | 993 | int slen; |
983 | if (fp->fail) return; | 994 | if (fp->fail) return; |
984 | slen = strlen(s); | 995 | slen = strlen(s); |
985 | if (fp->fp) { | 996 | if (fp->fp) { |
986 | fwrite(s,1,slen,fp->fp); | 997 | fwrite(s,1,slen,fp->fp); |
987 | } | 998 | } |
988 | else { | 999 | else { |
989 | stuff: | 1000 | stuff: |
990 | if (fp->len + slen < fp->limit) { | 1001 | if (fp->len + slen < fp->limit) { |
991 | memcpy(fp->s+fp->len,s,slen); | 1002 | memcpy(fp->s+fp->len,s,slen); |
992 | fp->len += slen; | 1003 | fp->len += slen; |
993 | return; | 1004 | return; |
994 | } | 1005 | } |
995 | else if (fp->alloc) { | 1006 | else if (fp->alloc) { |
996 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; | 1007 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; |
997 | if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen; | 1008 | if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen; |
998 | if (fp->s) | 1009 | fp->s = (char *) realloc(fp->s,fp->limit); |
999 | fp->s = realloc(fp->s,fp->limit); | ||
1000 | else | ||
1001 | fp->s = malloc(fp->limit); | ||
1002 | if (fp->s) goto stuff; | 1010 | if (fp->s) goto stuff; |
1003 | } | 1011 | } |
1004 | if (fp->alloc) | 1012 | if (fp->alloc) |
1005 | free(fp->s); | 1013 | free(fp->s); |
1006 | fp->s = 0; | 1014 | fp->s = 0; |
1007 | fp->fail = 1; | 1015 | fp->fail = 1; |
1008 | } | 1016 | } |
1009 | } | 1017 | } |
1010 | 1018 | ||
1011 | static void appendcOFile(OFile *fp, char c) | 1019 | static void appendcOFile(OFile *fp, char c) |
1012 | { | 1020 | { |
1013 | if (fp->fail) return; | 1021 | if (fp->fail) return; |
1014 | if (fp->fp) { | 1022 | if (fp->fp) { |
1015 | fputc(c,fp->fp); | 1023 | fputc(c,fp->fp); |
1016 | } | 1024 | } |
1017 | else { | 1025 | else { |
1018 | stuff: | 1026 | stuff: |
1019 | if (fp->len+1 < fp->limit) { | 1027 | if (fp->len+1 < fp->limit) { |
1020 | fp->s[fp->len] = c; | 1028 | fp->s[fp->len] = c; |
1021 | fp->len++; | 1029 | fp->len++; |
1022 | return; | 1030 | return; |
1023 | } | 1031 | } |
1024 | else if (fp->alloc) { | 1032 | else if (fp->alloc) { |
1025 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; | 1033 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; |
1026 | fp->s = realloc(fp->s,fp->limit); | 1034 | fp->s = (char *) realloc(fp->s,fp->limit); |
1027 | if (fp->s) goto stuff; | 1035 | if (fp->s) goto stuff; |
1028 | } | 1036 | } |
1029 | if (fp->alloc) | 1037 | if (fp->alloc) |
1030 | free(fp->s); | 1038 | free(fp->s); |
1031 | fp->s = 0; | 1039 | fp->s = 0; |
1032 | fp->fail = 1; | 1040 | fp->fail = 1; |
1033 | } | 1041 | } |
1034 | } | 1042 | } |
1035 | |||
1036 | #else | 1043 | #else |
1037 | |||
1038 | static void appendcOFile_(OFile *fp, char c) | 1044 | static void appendcOFile_(OFile *fp, char c) |
1039 | { | 1045 | { |
1040 | if (fp->fail) return; | 1046 | if (fp->fail) return; |
1041 | if (fp->fp) { | 1047 | if (fp->fp) { |
1042 | fputc(c,fp->fp); | 1048 | fputc(c,fp->fp); |
1043 | } | 1049 | } |
1044 | else { | 1050 | else { |
1045 | stuff: | 1051 | stuff: |
1046 | if (fp->len+1 < fp->limit) { | 1052 | if (fp->len+1 < fp->limit) { |
1047 | fp->s[fp->len] = c; | 1053 | fp->s[fp->len] = c; |
1048 | fp->len++; | 1054 | fp->len++; |
1049 | return; | 1055 | return; |
@@ -1136,60 +1142,73 @@ static int writeBase64(OFile *fp, unsigned char *s, long len) | |||
1136 | } | 1142 | } |
1137 | /* now output 'quad' with appropriate whitespace and line ending */ | 1143 | /* now output 'quad' with appropriate whitespace and line ending */ |
1138 | appendsOFile(fp, (numQuads == 0 ? " " : "")); | 1144 | appendsOFile(fp, (numQuads == 0 ? " " : "")); |
1139 | appendsOFile(fp, quad); | 1145 | appendsOFile(fp, quad); |
1140 | appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : ""))); | 1146 | appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : ""))); |
1141 | numQuads = (numQuads + 1) % MAXQUADS; | 1147 | numQuads = (numQuads + 1) % MAXQUADS; |
1142 | } | 1148 | } |
1143 | appendcOFile(fp,'\n'); | 1149 | appendcOFile(fp,'\n'); |
1144 | 1150 | ||
1145 | return 1; | 1151 | return 1; |
1146 | } | 1152 | } |
1147 | 1153 | ||
1148 | /* this function really sucks. Too basic. */ | 1154 | static void writeString(OFile *fp, const char *s) |
1149 | static void writeQPString(OFile *fp, const char *s, int qp) | 1155 | { |
1156 | appendsOFile(fp,s); | ||
1157 | } | ||
1158 | |||
1159 | static void writeQPString(OFile *fp, const char *s) | ||
1150 | { | 1160 | { |
1161 | char buf[4]; | ||
1162 | int count=0; | ||
1151 | const char *p = s; | 1163 | const char *p = s; |
1164 | |||
1152 | while (*p) { | 1165 | while (*p) { |
1153 | if (*p == '\n') { | 1166 | /* break up lines biggger than 75 chars */ |
1154 | if (p[1]) appendsOFile(fp,"=0A="); | 1167 | if(count >=74){ |
1168 | count=0; | ||
1169 | appendsOFile(fp,"=\n"); | ||
1155 | } | 1170 | } |
1156 | if (*p == '=' && qp) | 1171 | |
1157 | appendsOFile(fp,"=3D"); | 1172 | /* escape any non ASCII characters and '=' as per rfc1521 */ |
1158 | else | 1173 | if (*p<= 0x1f || *p >=0x7f || *p == '=' ) { |
1174 | sprintf(buf,"=%02X",(unsigned char)*p); | ||
1175 | appendsOFile(fp,buf); | ||
1176 | count+=3; | ||
1177 | } else { | ||
1159 | appendcOFile(fp,*p); | 1178 | appendcOFile(fp,*p); |
1179 | count++; | ||
1180 | } | ||
1160 | p++; | 1181 | p++; |
1161 | } | 1182 | } |
1162 | } | 1183 | } |
1163 | 1184 | ||
1185 | |||
1186 | |||
1164 | static void writeVObject_(OFile *fp, VObject *o); | 1187 | static void writeVObject_(OFile *fp, VObject *o); |
1165 | 1188 | ||
1166 | static void writeValue(OFile *fp, VObject *o, unsigned long size) | 1189 | static void writeValue(OFile *fp, VObject *o, unsigned long size,int quote) |
1167 | { | 1190 | { |
1168 | if (o == 0) return; | 1191 | if (o == 0) return; |
1169 | switch (VALUE_TYPE(o)) { | 1192 | switch (VALUE_TYPE(o)) { |
1170 | case VCVT_USTRINGZ: { | 1193 | case VCVT_USTRINGZ: { |
1171 | char *s = fakeCString(USTRINGZ_VALUE_OF(o)); | 1194 | char *s = fakeCString(USTRINGZ_VALUE_OF(o)); |
1172 | if (isAPropertyOf(o, VCQuotedPrintableProp)) | 1195 | if(quote) writeQPString(fp, s); |
1173 | writeQPString(fp, s, 1); | 1196 | else writeString(fp,s); |
1174 | else | ||
1175 | writeQPString(fp, s, 0); | ||
1176 | deleteStr(s); | 1197 | deleteStr(s); |
1177 | break; | 1198 | break; |
1178 | } | 1199 | } |
1179 | case VCVT_STRINGZ: { | 1200 | case VCVT_STRINGZ: { |
1180 | if (isAPropertyOf(o, VCQuotedPrintableProp)) | 1201 | if(quote) writeQPString(fp, STRINGZ_VALUE_OF(o)); |
1181 | writeQPString(fp, STRINGZ_VALUE_OF(o), 1); | 1202 | else writeString(fp,STRINGZ_VALUE_OF(o)); |
1182 | else | ||
1183 | writeQPString(fp, STRINGZ_VALUE_OF(o), 0); | ||
1184 | break; | 1203 | break; |
1185 | } | 1204 | } |
1186 | case VCVT_UINT: { | 1205 | case VCVT_UINT: { |
1187 | char buf[16]; | 1206 | char buf[16]; |
1188 | sprintf(buf,"%u", INTEGER_VALUE_OF(o)); | 1207 | sprintf(buf,"%u", INTEGER_VALUE_OF(o)); |
1189 | appendsOFile(fp,buf); | 1208 | appendsOFile(fp,buf); |
1190 | break; | 1209 | break; |
1191 | } | 1210 | } |
1192 | case VCVT_ULONG: { | 1211 | case VCVT_ULONG: { |
1193 | char buf[16]; | 1212 | char buf[16]; |
1194 | sprintf(buf,"%lu", LONG_VALUE_OF(o)); | 1213 | sprintf(buf,"%lu", LONG_VALUE_OF(o)); |
1195 | appendsOFile(fp,buf); | 1214 | appendsOFile(fp,buf); |
@@ -1211,103 +1230,105 @@ static void writeAttrValue(OFile *fp, VObject *o) | |||
1211 | { | 1230 | { |
1212 | if (NAME_OF(o)) { | 1231 | if (NAME_OF(o)) { |
1213 | struct PreDefProp *pi; | 1232 | struct PreDefProp *pi; |
1214 | pi = lookupPropInfo(NAME_OF(o)); | 1233 | pi = lookupPropInfo(NAME_OF(o)); |
1215 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; | 1234 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; |
1216 | appendcOFile(fp,';'); | 1235 | appendcOFile(fp,';'); |
1217 | appendsOFile(fp,NAME_OF(o)); | 1236 | appendsOFile(fp,NAME_OF(o)); |
1218 | } | 1237 | } |
1219 | else | 1238 | else |
1220 | appendcOFile(fp,';'); | 1239 | appendcOFile(fp,';'); |
1221 | if (VALUE_TYPE(o)) { | 1240 | if (VALUE_TYPE(o)) { |
1222 | appendcOFile(fp,'='); | 1241 | appendcOFile(fp,'='); |
1223 | writeValue(fp,o,0); | 1242 | writeValue(fp,o,0,0); |
1224 | } | 1243 | } |
1225 | } | 1244 | } |
1226 | 1245 | ||
1227 | static void writeGroup(OFile *fp, VObject *o) | 1246 | static void writeGroup(OFile *fp, VObject *o) |
1228 | { | 1247 | { |
1229 | char buf1[256]; | 1248 | char buf1[256]; |
1230 | char buf2[256]; | 1249 | char buf2[256]; |
1231 | strcpy(buf1,NAME_OF(o)); | 1250 | strcpy(buf1,NAME_OF(o)); |
1232 | while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { | 1251 | while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { |
1233 | strncpy(buf2,STRINGZ_VALUE_OF(o),sizeof(buf2)); | 1252 | strcpy(buf2,STRINGZ_VALUE_OF(o)); |
1234 | buf2[sizeof(buf2)] = '\0'; | 1253 | strcat(buf2,"."); |
1235 | strncat(buf2,".",sizeof(buf2)-strlen(buf2)-1); | 1254 | strcat(buf2,buf1); |
1236 | strncat(buf2,buf1,sizeof(buf2)-strlen(buf2)-1); | ||
1237 | strcpy(buf1,buf2); | 1255 | strcpy(buf1,buf2); |
1238 | } | 1256 | } |
1239 | appendsOFile(fp,buf1); | 1257 | appendsOFile(fp,buf1); |
1240 | } | 1258 | } |
1241 | 1259 | ||
1242 | static int inList(const char **list, const char *s) | 1260 | static int inList(const char **list, const char *s) |
1243 | { | 1261 | { |
1244 | if (list == 0) return 0; | 1262 | if (list == 0) return 0; |
1245 | while (*list) { | 1263 | while (*list) { |
1246 | if (strcasecmp(*list,s) == 0) return 1; | 1264 | if (stricmp(*list,s) == 0) return 1; |
1247 | list++; | 1265 | list++; |
1248 | } | 1266 | } |
1249 | return 0; | 1267 | return 0; |
1250 | } | 1268 | } |
1251 | 1269 | ||
1252 | static void writeProp(OFile *fp, VObject *o) | 1270 | static void writeProp(OFile *fp, VObject *o) |
1253 | { | 1271 | { |
1272 | int isQuoted=0; | ||
1254 | if (NAME_OF(o)) { | 1273 | if (NAME_OF(o)) { |
1255 | struct PreDefProp *pi; | 1274 | struct PreDefProp *pi; |
1256 | VObjectIterator t; | 1275 | VObjectIterator t; |
1257 | const char **fields_ = 0; | 1276 | const char **fields_ = 0; |
1258 | pi = lookupPropInfo(NAME_OF(o)); | 1277 | pi = lookupPropInfo(NAME_OF(o)); |
1259 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { | 1278 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { |
1260 | writeVObject_(fp,o); | 1279 | writeVObject_(fp,o); |
1261 | return; | 1280 | return; |
1262 | } | 1281 | } |
1263 | if (isAPropertyOf(o,VCGroupingProp)) | 1282 | if (isAPropertyOf(o,VCGroupingProp)) |
1264 | writeGroup(fp,o); | 1283 | writeGroup(fp,o); |
1265 | else | 1284 | else |
1266 | appendsOFile(fp,NAME_OF(o)); | 1285 | appendsOFile(fp,NAME_OF(o)); |
1267 | if (pi) fields_ = pi->fields; | 1286 | if (pi) fields_ = pi->fields; |
1268 | initPropIterator(&t,o); | 1287 | initPropIterator(&t,o); |
1269 | while (moreIteration(&t)) { | 1288 | while (moreIteration(&t)) { |
1270 | const char *s; | 1289 | const char *s; |
1271 | VObject *eachProp = nextVObject(&t); | 1290 | VObject *eachProp = nextVObject(&t); |
1272 | s = NAME_OF(eachProp); | 1291 | s = NAME_OF(eachProp); |
1273 | if (strcasecmp(VCGroupingProp,s) && !inList(fields_,s)) | 1292 | if (stricmp(VCGroupingProp,s) && !inList(fields_,s)) |
1274 | writeAttrValue(fp,eachProp); | 1293 | writeAttrValue(fp,eachProp); |
1294 | if (stricmp(VCQPProp,s)==0 || stricmp(VCQuotedPrintableProp,s)==0) | ||
1295 | isQuoted=1; | ||
1275 | } | 1296 | } |
1276 | if (fields_) { | 1297 | if (fields_) { |
1277 | int i = 0, n = 0; | 1298 | int i = 0, n = 0; |
1278 | const char** fields = fields_; | 1299 | const char** fields = fields_; |
1279 | /* output prop as fields */ | 1300 | /* output prop as fields */ |
1280 | appendcOFile(fp,':'); | 1301 | appendcOFile(fp,':'); |
1281 | while (*fields) { | 1302 | while (*fields) { |
1282 | VObject *tl = isAPropertyOf(o,*fields); | 1303 | VObject *t = isAPropertyOf(o,*fields); |
1283 | i++; | 1304 | i++; |
1284 | if (tl) n = i; | 1305 | if (t) n = i; |
1285 | fields++; | 1306 | fields++; |
1286 | } | 1307 | } |
1287 | fields = fields_; | 1308 | fields = fields_; |
1288 | for (i=0;i<n;i++) { | 1309 | for (i=0;i<n;i++) { |
1289 | writeValue(fp,isAPropertyOf(o,*fields),0); | 1310 | writeValue(fp,isAPropertyOf(o,*fields),0,isQuoted); |
1290 | fields++; | 1311 | fields++; |
1291 | if (i<(n-1)) appendcOFile(fp,';'); | 1312 | if (i<(n-1)) appendcOFile(fp,';'); |
1292 | } | 1313 | } |
1293 | } | 1314 | } |
1294 | } | 1315 | } |
1295 | 1316 | ||
1296 | if (VALUE_TYPE(o)) { | 1317 | if (VALUE_TYPE(o)) { |
1297 | unsigned long size = 0; | 1318 | unsigned long size = 0; |
1298 | VObject *p = isAPropertyOf(o,VCDataSizeProp); | 1319 | VObject *p = isAPropertyOf(o,VCDataSizeProp); |
1299 | if (p) size = LONG_VALUE_OF(p); | 1320 | if (p) size = LONG_VALUE_OF(p); |
1300 | appendcOFile(fp,':'); | 1321 | appendcOFile(fp,':'); |
1301 | writeValue(fp,o,size); | 1322 | writeValue(fp,o,size,isQuoted); |
1302 | } | 1323 | } |
1303 | 1324 | ||
1304 | appendcOFile(fp,'\n'); | 1325 | appendcOFile(fp,'\n'); |
1305 | } | 1326 | } |
1306 | 1327 | ||
1307 | static void writeVObject_(OFile *fp, VObject *o) | 1328 | static void writeVObject_(OFile *fp, VObject *o) |
1308 | { | 1329 | { |
1309 | if (NAME_OF(o)) { | 1330 | if (NAME_OF(o)) { |
1310 | struct PreDefProp *pi; | 1331 | struct PreDefProp *pi; |
1311 | pi = lookupPropInfo(NAME_OF(o)); | 1332 | pi = lookupPropInfo(NAME_OF(o)); |
1312 | 1333 | ||
1313 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { | 1334 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { |
@@ -1326,106 +1347,106 @@ static void writeVObject_(OFile *fp, VObject *o) | |||
1326 | appendsOFile(fp,"\n\n"); | 1347 | appendsOFile(fp,"\n\n"); |
1327 | } | 1348 | } |
1328 | } | 1349 | } |
1329 | } | 1350 | } |
1330 | 1351 | ||
1331 | void writeVObject(FILE *fp, VObject *o) | 1352 | void writeVObject(FILE *fp, VObject *o) |
1332 | { | 1353 | { |
1333 | OFile ofp; | 1354 | OFile ofp; |
1334 | initOFile(&ofp,fp); | 1355 | initOFile(&ofp,fp); |
1335 | writeVObject_(&ofp,o); | 1356 | writeVObject_(&ofp,o); |
1336 | } | 1357 | } |
1337 | 1358 | ||
1338 | void writeVObjectToFile(char *fname, VObject *o) | 1359 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) |
1339 | { | 1360 | { |
1340 | FILE *fp = fopen(fname,"w"); | 1361 | FILE *fp = fopen(fname,"w"); |
1341 | if (fp) { | 1362 | if (fp) { |
1342 | writeVObject(fp,o); | 1363 | writeVObject(fp,o); |
1343 | fclose(fp); | 1364 | fclose(fp); |
1344 | } | 1365 | } |
1345 | } | 1366 | } |
1346 | 1367 | ||
1347 | void writeVObjectsToFile(char *fname, VObject *list) | 1368 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) |
1348 | { | 1369 | { |
1349 | FILE *fp = fopen(fname,"w"); | 1370 | FILE *fp = fopen(fname,"w"); |
1350 | if (fp) { | 1371 | if (fp) { |
1351 | while (list) { | 1372 | while (list) { |
1352 | writeVObject(fp,list); | 1373 | writeVObject(fp,list); |
1353 | list = nextVObjectInList(list); | 1374 | list = nextVObjectInList(list); |
1354 | } | 1375 | } |
1355 | fclose(fp); | 1376 | fclose(fp); |
1356 | } | 1377 | } |
1357 | } | 1378 | } |
1358 | 1379 | ||
1359 | char* writeMemVObject(char *s, int *len, VObject *o) | 1380 | DLLEXPORT(char*) writeMemVObject(char *s, int *len, VObject *o) |
1360 | { | 1381 | { |
1361 | OFile ofp; | 1382 | OFile ofp; |
1362 | initMemOFile(&ofp,s,len?*len:0); | 1383 | initMemOFile(&ofp,s,len?*len:0); |
1363 | writeVObject_(&ofp,o); | 1384 | writeVObject_(&ofp,o); |
1364 | if (len) *len = ofp.len; | 1385 | if (len) *len = ofp.len; |
1365 | appendcOFile(&ofp,0); | 1386 | appendcOFile(&ofp,0); |
1366 | return ofp.s; | 1387 | return ofp.s; |
1367 | } | 1388 | } |
1368 | 1389 | ||
1369 | char* writeMemVObjects(char *s, int *len, VObject *list) | 1390 | DLLEXPORT(char*) writeMemVObjects(char *s, int *len, VObject *list) |
1370 | { | 1391 | { |
1371 | OFile ofp; | 1392 | OFile ofp; |
1372 | initMemOFile(&ofp,s,len?*len:0); | 1393 | initMemOFile(&ofp,s,len?*len:0); |
1373 | while (list) { | 1394 | while (list) { |
1374 | writeVObject_(&ofp,list); | 1395 | writeVObject_(&ofp,list); |
1375 | list = nextVObjectInList(list); | 1396 | list = nextVObjectInList(list); |
1376 | } | 1397 | } |
1377 | if (len) *len = ofp.len; | 1398 | if (len) *len = ofp.len; |
1378 | appendcOFile(&ofp,0); | 1399 | appendcOFile(&ofp,0); |
1379 | return ofp.s; | 1400 | return ofp.s; |
1380 | } | 1401 | } |
1381 | 1402 | ||
1382 | /*---------------------------------------------------------------------- | 1403 | /*---------------------------------------------------------------------- |
1383 | APIs to do fake Unicode stuff. | 1404 | APIs to do fake Unicode stuff. |
1384 | ----------------------------------------------------------------------*/ | 1405 | ----------------------------------------------------------------------*/ |
1385 | wchar_t* fakeUnicode(const char *ps, int *bytes) | 1406 | DLLEXPORT(wchar_t*) fakeUnicode(const char *ps, int *bytes) |
1386 | { | 1407 | { |
1387 | wchar_t *r, *pw; | 1408 | wchar_t *r, *pw; |
1388 | int len = strlen(ps)+1; | 1409 | int len = strlen(ps)+1; |
1389 | 1410 | ||
1390 | pw = r = (wchar_t*)malloc(sizeof(wchar_t)*len); | 1411 | pw = r = (wchar_t*)malloc(sizeof(wchar_t)*len); |
1391 | if (bytes) | 1412 | if (bytes) |
1392 | *bytes = len * sizeof(wchar_t); | 1413 | *bytes = len * sizeof(wchar_t); |
1393 | 1414 | ||
1394 | while (*ps) { | 1415 | while (*ps) { |
1395 | if (*ps == '\n') | 1416 | if (*ps == '\n') |
1396 | *pw = (wchar_t)0x2028; | 1417 | *pw = (wchar_t)0x2028; |
1397 | else if (*ps == '\r') | 1418 | else if (*ps == '\r') |
1398 | *pw = (wchar_t)0x2029; | 1419 | *pw = (wchar_t)0x2029; |
1399 | else | 1420 | else |
1400 | *pw = (wchar_t)(unsigned char)*ps; | 1421 | *pw = (wchar_t)(unsigned char)*ps; |
1401 | ps++; pw++; | 1422 | ps++; pw++; |
1402 | } | 1423 | } |
1403 | *pw = (wchar_t)0; | 1424 | *pw = (wchar_t)0; |
1404 | 1425 | ||
1405 | return r; | 1426 | return r; |
1406 | } | 1427 | } |
1407 | 1428 | ||
1408 | int uStrLen(const wchar_t *u) | 1429 | DLLEXPORT(int) uStrLen(const wchar_t *u) |
1409 | { | 1430 | { |
1410 | int i = 0; | 1431 | int i = 0; |
1411 | while (*u != (wchar_t)0) { u++; i++; } | 1432 | while (*u != (wchar_t)0) { u++; i++; } |
1412 | return i; | 1433 | return i; |
1413 | } | 1434 | } |
1414 | 1435 | ||
1415 | char* fakeCString(const wchar_t *u) | 1436 | DLLEXPORT(char*) fakeCString(const wchar_t *u) |
1416 | { | 1437 | { |
1417 | char *s, *t; | 1438 | char *s, *t; |
1418 | int len = uStrLen(u) + 1; | 1439 | int len = uStrLen(u) + 1; |
1419 | t = s = (char*)malloc(len+1); | 1440 | t = s = (char*)malloc(len); |
1420 | while (*u) { | 1441 | while (*u) { |
1421 | if (*u == (wchar_t)0x2028) | 1442 | if (*u == (wchar_t)0x2028) |
1422 | *t = '\n'; | 1443 | *t = '\n'; |
1423 | else if (*u == (wchar_t)0x2029) | 1444 | else if (*u == (wchar_t)0x2029) |
1424 | *t = '\r'; | 1445 | *t = '\r'; |
1425 | else | 1446 | else |
1426 | *t = (char)*u; | 1447 | *t = (char)*u; |
1427 | u++; t++; | 1448 | u++; t++; |
1428 | } | 1449 | } |
1429 | *t = 0; | 1450 | *t = 0; |
1430 | return s; | 1451 | return s; |
1431 | } | 1452 | } |
diff --git a/libkcal/versit/vobject.h b/libkcal/versit/vobject.h index 0ec8b31..85c299e 100644 --- a/libkcal/versit/vobject.h +++ b/libkcal/versit/vobject.h | |||
@@ -133,25 +133,25 @@ extern "C" { | |||
133 | #define VCDIBProp "DIB" | 133 | #define VCDIBProp "DIB" |
134 | #define VCDisplayStringProp "DISPLAYSTRING" | 134 | #define VCDisplayStringProp "DISPLAYSTRING" |
135 | #define VCDomesticProp "DOM" | 135 | #define VCDomesticProp "DOM" |
136 | #define VCDTendProp "DTEND" | 136 | #define VCDTendProp "DTEND" |
137 | #define VCDTstartProp "DTSTART" | 137 | #define VCDTstartProp "DTSTART" |
138 | #define VCDueProp "DUE" | 138 | #define VCDueProp "DUE" |
139 | #define VCEmailAddressProp "EMAIL" | 139 | #define VCEmailAddressProp "EMAIL" |
140 | #define VCEncodingProp "ENCODING" | 140 | #define VCEncodingProp "ENCODING" |
141 | #define VCEndProp "END" | 141 | #define VCEndProp "END" |
142 | #define VCEventProp "VEVENT" | 142 | #define VCEventProp "VEVENT" |
143 | #define VCEWorldProp "EWORLD" | 143 | #define VCEWorldProp "EWORLD" |
144 | #define VCExNumProp "EXNUM" | 144 | #define VCExNumProp "EXNUM" |
145 | #define VCExDateProp "EXDATE" | 145 | #define VCExpDateProp "EXDATE" |
146 | #define VCExpectProp "EXPECT" | 146 | #define VCExpectProp "EXPECT" |
147 | #define VCExtAddressProp "EXT ADD" | 147 | #define VCExtAddressProp "EXT ADD" |
148 | #define VCFamilyNameProp "F" | 148 | #define VCFamilyNameProp "F" |
149 | #define VCFaxProp "FAX" | 149 | #define VCFaxProp "FAX" |
150 | #define VCFullNameProp "FN" | 150 | #define VCFullNameProp "FN" |
151 | #define VCGeoProp "GEO" | 151 | #define VCGeoProp "GEO" |
152 | #define VCGeoLocationProp "GEO" | 152 | #define VCGeoLocationProp "GEO" |
153 | #define VCGIFProp "GIF" | 153 | #define VCGIFProp "GIF" |
154 | #define VCGivenNameProp "G" | 154 | #define VCGivenNameProp "G" |
155 | #define VCGroupingProp "Grouping" | 155 | #define VCGroupingProp "Grouping" |
156 | #define VCHomeProp "HOME" | 156 | #define VCHomeProp "HOME" |
157 | #define VCIBMMailProp "IBMMail" | 157 | #define VCIBMMailProp "IBMMail" |
@@ -238,147 +238,132 @@ extern "C" { | |||
238 | #define VCURLValueProp "URLVAL" | 238 | #define VCURLValueProp "URLVAL" |
239 | #define VCValueProp "VALUE" | 239 | #define VCValueProp "VALUE" |
240 | #define VCVersionProp "VERSION" | 240 | #define VCVersionProp "VERSION" |
241 | #define VCVideoProp "VIDEO" | 241 | #define VCVideoProp "VIDEO" |
242 | #define VCVoiceProp "VOICE" | 242 | #define VCVoiceProp "VOICE" |
243 | #define VCWAVEProp "WAVE" | 243 | #define VCWAVEProp "WAVE" |
244 | #define VCWMFProp "WMF" | 244 | #define VCWMFProp "WMF" |
245 | #define VCWorkProp "WORK" | 245 | #define VCWorkProp "WORK" |
246 | #define VCX400Prop "X400" | 246 | #define VCX400Prop "X400" |
247 | #define VCX509Prop "X509" | 247 | #define VCX509Prop "X509" |
248 | #define VCXRuleProp "XRULE" | 248 | #define VCXRuleProp "XRULE" |
249 | 249 | ||
250 | /* extensions for KOrganizer / KPilot */ | 250 | /* Extensions */ |
251 | #define KPilotIdProp "X-PILOTID" | ||
252 | #define KPilotStatusProp "X-PILOTSTAT" | ||
253 | 251 | ||
252 | #define XPilotIdProp "X-PILOTID" | ||
253 | #define XPilotStatusProp "X-PILOTSTAT" | ||
254 | /* extensions for iMIP / iTIP */ | 254 | /* extensions for iMIP / iTIP */ |
255 | #define ICOrganizerProp "X-ORGANIZER" | 255 | #define ICOrganizerProp "X-ORGANIZER" |
256 | #define ICMethodProp "X-METHOD" | 256 | #define ICMethodProp "X-METHOD" |
257 | #define ICRequestStatusProp "X-REQUEST-STATUS" | 257 | #define ICRequestStatusProp "X-REQUEST-STATUS" |
258 | |||
259 | typedef struct VObject VObject; | 258 | typedef struct VObject VObject; |
260 | 259 | ||
261 | typedef union ValueItem { | ||
262 | const char *strs; | ||
263 | const wchar_t *ustrs; | ||
264 | unsigned int i; | ||
265 | unsigned long l; | ||
266 | void *any; | ||
267 | VObject *vobj; | ||
268 | } ValueItem; | ||
269 | |||
270 | struct VObject { | ||
271 | VObject *next; | ||
272 | const char *id; | ||
273 | VObject *prop; | ||
274 | unsigned short valType; | ||
275 | ValueItem val; | ||
276 | }; | ||
277 | |||
278 | typedef struct StrItem StrItem; | ||
279 | |||
280 | struct StrItem { | ||
281 | StrItem *next; | ||
282 | const char *s; | ||
283 | unsigned int refCnt; | ||
284 | }; | ||
285 | |||
286 | typedef struct VObjectIterator { | 260 | typedef struct VObjectIterator { |
287 | VObject* start; | 261 | VObject* start; |
288 | VObject* next; | 262 | VObject* next; |
289 | } VObjectIterator; | 263 | } VObjectIterator; |
290 | 264 | ||
291 | extern VObject* newVObject(const char *id); | 265 | extern DLLEXPORT(VObject*) newVObject(const char *id); |
292 | extern void deleteVObject(VObject *p); | 266 | extern DLLEXPORT(void) deleteVObject(VObject *p); |
293 | extern char* dupStr(const char *s, unsigned int size); | 267 | extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size); |
294 | extern void deleteStr(const char *p); | 268 | extern DLLEXPORT(void) deleteStr(const char *p); |
295 | extern void unUseStr(const char *s); | 269 | extern DLLEXPORT(void) unUseStr(const char *s); |
296 | 270 | ||
297 | extern void setVObjectName(VObject *o, const char* id); | 271 | extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id); |
298 | extern void setVObjectStringZValue(VObject *o, const char *s); | 272 | extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s); |
299 | extern void setVObjectStringZValue_(VObject *o, const char *s); | 273 | extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s); |
300 | extern void setVObjectUStringZValue(VObject *o, const wchar_t *s); | 274 | extern DLLEXPORT(void) setVObjectUStringZValue(VObject *o, const wchar_t *s); |
301 | extern void setVObjectUStringZValue_(VObject *o, const wchar_t *s); | 275 | extern DLLEXPORT(void) setVObjectUStringZValue_(VObject *o, const wchar_t *s); |
302 | extern void setVObjectIntegerValue(VObject *o, unsigned int i); | 276 | extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i); |
303 | extern void setVObjectLongValue(VObject *o, unsigned long l); | 277 | extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l); |
304 | extern void setVObjectAnyValue(VObject *o, void *t); | 278 | extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t); |
305 | extern VObject* setValueWithSize(VObject *prop, void *val, unsigned int size); | 279 | extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size); |
306 | extern VObject* setValueWithSize_(VObject *prop, void *val, unsigned int size); | 280 | extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size); |
307 | 281 | ||
308 | extern const char* vObjectName(VObject *o); | 282 | extern DLLEXPORT(const char*) vObjectName(VObject *o); |
309 | extern const char* vObjectStringZValue(VObject *o); | 283 | extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o); |
310 | extern const wchar_t* vObjectUStringZValue(VObject *o); | 284 | extern DLLEXPORT(const wchar_t*) vObjectUStringZValue(VObject *o); |
311 | extern unsigned int vObjectIntegerValue(VObject *o); | 285 | extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o); |
312 | extern unsigned long vObjectLongValue(VObject *o); | 286 | extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o); |
313 | extern void* vObjectAnyValue(VObject *o); | 287 | extern DLLEXPORT(void*) vObjectAnyValue(VObject *o); |
314 | extern VObject* vObjectVObjectValue(VObject *o); | 288 | extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o); |
315 | extern void setVObjectVObjectValue(VObject *o, VObject *p); | 289 | extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p); |
316 | 290 | ||
317 | extern VObject* addVObjectProp(VObject *o, VObject *p); | 291 | extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p); |
318 | extern VObject* addProp(VObject *o, const char *id); | 292 | extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id); |
319 | extern VObject* addProp_(VObject *o, const char *id); | 293 | extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id); |
320 | extern VObject* addPropValue(VObject *o, const char *p, const char *v); | 294 | extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v); |
321 | extern VObject* addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); | 295 | extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); |
322 | extern VObject* addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); | 296 | extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); |
323 | extern VObject* addGroup(VObject *o, const char *g); | 297 | extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g); |
324 | extern void addList(VObject **o, VObject *p); | 298 | extern DLLEXPORT(void) addList(VObject **o, VObject *p); |
325 | 299 | ||
326 | extern VObject* isAPropertyOf(VObject *o, const char *id); | 300 | extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id); |
327 | 301 | ||
328 | extern VObject* nextVObjectInList(VObject *o); | 302 | extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o); |
329 | extern void initPropIterator(VObjectIterator *i, VObject *o); | 303 | extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o); |
330 | extern int moreIteration(VObjectIterator *i); | 304 | extern DLLEXPORT(int) moreIteration(VObjectIterator *i); |
331 | extern VObject* nextVObject(VObjectIterator *i); | 305 | extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i); |
332 | 306 | ||
333 | extern char* writeMemVObject(char *s, int *len, VObject *o); | 307 | extern DLLEXPORT(char*) writeMemVObject(char *s, int *len, VObject *o); |
334 | extern char* writeMemVObjects(char *s, int *len, VObject *list); | 308 | extern DLLEXPORT(char*) writeMemVObjects(char *s, int *len, VObject *list); |
335 | 309 | ||
336 | extern const char* lookupStr(const char *s); | 310 | extern DLLEXPORT(const char*) lookupStr(const char *s); |
337 | extern void cleanStrTbl(); | 311 | extern DLLEXPORT(void) cleanStrTbl(); |
338 | 312 | ||
339 | extern void cleanVObject(VObject *o); | 313 | extern DLLEXPORT(void) cleanVObject(VObject *o); |
340 | extern void cleanVObjects(VObject *list); | 314 | extern DLLEXPORT(void) cleanVObjects(VObject *list); |
341 | 315 | ||
342 | extern const char* lookupProp(const char* str); | 316 | extern DLLEXPORT(const char*) lookupProp(const char* str); |
343 | extern const char* lookupProp_(const char* str); | 317 | extern DLLEXPORT(const char*) lookupProp_(const char* str); |
344 | 318 | ||
345 | extern wchar_t* fakeUnicode(const char *ps, int *bytes); | 319 | extern DLLEXPORT(wchar_t*) fakeUnicode(const char *ps, int *bytes); |
346 | extern int uStrLen(const wchar_t *u); | 320 | extern DLLEXPORT(int) uStrLen(const wchar_t *u); |
347 | extern char* fakeCString(const wchar_t *u); | 321 | extern DLLEXPORT(char*) fakeCString(const wchar_t *u); |
348 | 322 | ||
349 | extern void printVObjectToFile(char *fname,VObject *o); | 323 | extern DLLEXPORT(void) printVObjectToFile(char *fname,VObject *o); |
350 | extern void printVObjectsToFile(char *fname,VObject *list); | 324 | extern DLLEXPORT(void) printVObjectsToFile(char *fname,VObject *list); |
351 | extern void writeVObjectToFile(char *fname, VObject *o); | 325 | extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o); |
352 | extern void writeVObjectsToFile(char *fname, VObject *list); | 326 | extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); |
353 | 327 | ||
354 | extern int vObjectValueType(VObject *o); | 328 | extern DLLEXPORT(int) vObjectValueType(VObject *o); |
355 | 329 | ||
356 | /* return type of vObjectValueType: */ | 330 | /* return type of vObjectValueType: */ |
357 | #define VCVT_NOVALUE0 | 331 | #define VCVT_NOVALUE0 |
358 | /* if the VObject has no value associated with it. */ | 332 | /* if the VObject has no value associated with it. */ |
359 | #define VCVT_STRINGZ1 | 333 | #define VCVT_STRINGZ1 |
360 | /* if the VObject has value set by setVObjectStringZValue. */ | 334 | /* if the VObject has value set by setVObjectStringZValue. */ |
361 | #define VCVT_USTRINGZ2 | 335 | #define VCVT_USTRINGZ2 |
362 | /* if the VObject has value set by setVObjectUStringZValue. */ | 336 | /* if the VObject has value set by setVObjectUStringZValue. */ |
363 | #define VCVT_UINT 3 | 337 | #define VCVT_UINT 3 |
364 | /* if the VObject has value set by setVObjectIntegerValue. */ | 338 | /* if the VObject has value set by setVObjectIntegerValue. */ |
365 | #define VCVT_ULONG 4 | 339 | #define VCVT_ULONG 4 |
366 | /* if the VObject has value set by setVObjectLongValue. */ | 340 | /* if the VObject has value set by setVObjectLongValue. */ |
367 | #define VCVT_RAW 5 | 341 | #define VCVT_RAW 5 |
368 | /* if the VObject has value set by setVObjectAnyValue. */ | 342 | /* if the VObject has value set by setVObjectAnyValue. */ |
369 | #define VCVT_VOBJECT6 | 343 | #define VCVT_VOBJECT6 |
370 | /* if the VObject has value set by setVObjectVObjectValue. */ | 344 | /* if the VObject has value set by setVObjectVObjectValue. */ |
371 | 345 | ||
372 | extern const char** fieldedProp; | 346 | extern const char** fieldedProp; |
373 | 347 | ||
348 | /* NOTE regarding printVObject and writeVObject | ||
349 | |||
350 | The functions below are not exported from the DLL because they | ||
351 | take a FILE* as a parameter, which cannot be passed across a DLL | ||
352 | interface (at least that is my experience). Instead you can use | ||
353 | their companion functions which take file names or pointers | ||
354 | to memory. However, if you are linking this code into | ||
355 | your build directly then you may find them a more convenient API | ||
356 | and you can go ahead and use them. If you try to use them with | ||
357 | the DLL LIB you will get a link error. | ||
358 | */ | ||
374 | extern void printVObject(FILE *fp,VObject *o); | 359 | extern void printVObject(FILE *fp,VObject *o); |
375 | extern void writeVObject(FILE *fp, VObject *o); | 360 | extern void writeVObject(FILE *fp, VObject *o); |
376 | 361 | ||
377 | 362 | ||
378 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) | 363 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) |
379 | } | 364 | } |
380 | #endif | 365 | #endif |
381 | 366 | ||
382 | #endif /* __VOBJECT_H__ */ | 367 | #endif /* __VOBJECT_H__ */ |
383 | 368 | ||
384 | 369 | ||