summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/vcc.y29
-rw-r--r--library/backend/vcc_yacc.cpp33
-rw-r--r--library/backend/vobject.cpp5
-rw-r--r--library/backend/vobject_p.h4
4 files changed, 32 insertions, 39 deletions
diff --git a/library/backend/vcc.y b/library/backend/vcc.y
index 4c79368..bec2955 100644
--- a/library/backend/vcc.y
+++ b/library/backend/vcc.y
@@ -1,1220 +1,1219 @@
1%{ 1%{
2 2
3/*************************************************************************** 3/***************************************************************************
4(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International 4(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
5Business Machines Corporation and Siemens Rolm Communications Inc. 5Business Machines Corporation and Siemens Rolm Communications Inc.
6 6
7For purposes of this license notice, the term Licensors shall mean, 7For purposes of this license notice, the term Licensors shall mean,
8collectively, Apple Computer, Inc., AT&T Corp., International 8collectively, Apple Computer, Inc., AT&T Corp., International
9Business Machines Corporation and Siemens Rolm Communications Inc. 9Business Machines Corporation and Siemens Rolm Communications Inc.
10The term Licensor shall mean any of the Licensors. 10The term Licensor shall mean any of the Licensors.
11 11
12Subject to acceptance of the following conditions, permission is hereby 12Subject to acceptance of the following conditions, permission is hereby
13granted by Licensors without the need for written agreement and without 13granted by Licensors without the need for written agreement and without
14license or royalty fees, to use, copy, modify and distribute this 14license or royalty fees, to use, copy, modify and distribute this
15software for any purpose. 15software for any purpose.
16 16
17The above copyright notice and the following four paragraphs must be 17The above copyright notice and the following four paragraphs must be
18reproduced in all copies of this software and any software including 18reproduced in all copies of this software and any software including
19this software. 19this software.
20 20
21THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE 21THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
22ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR 22ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
23MODIFICATIONS. 23MODIFICATIONS.
24 24
25IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, 25IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
26INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT 26INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
27OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 27OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28DAMAGE. 28DAMAGE.
29 29
30EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, 30EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
31INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE 31INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
32IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 32IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33PURPOSE. 33PURPOSE.
34 34
35The software is provided with RESTRICTED RIGHTS. Use, duplication, or 35The software is provided with RESTRICTED RIGHTS. Use, duplication, or
36disclosure by the government are subject to restrictions set forth in 36disclosure by the government are subject to restrictions set forth in
37DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. 37DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
38 38
39***************************************************************************/ 39***************************************************************************/
40 40
41/* 41/*
42 * src: vcc.c 42 * src: vcc.c
43 * doc: Parser for vCard and vCalendar. Note that this code is 43 * doc: Parser for vCard and vCalendar. Note that this code is
44 * generated by a yacc parser generator. Generally it should not 44 * generated by a yacc parser generator. Generally it should not
45 * be edited by hand. The real source is vcc.y. The #line directives 45 * be edited by hand. The real source is vcc.y. The #line directives
46 * can be commented out here to make it easier to trace through 46 * can be commented out here to make it easier to trace through
47 * in a debugger. However, if a bug is found it should 47 * in a debugger. However, if a bug is found it should
48 * be fixed in vcc.y and this file regenerated. 48 * be fixed in vcc.y and this file regenerated.
49 */ 49 */
50 50
51 51
52/* debugging utilities */ 52/* debugging utilities */
53#if __DEBUG 53#if __DEBUG
54#define DBG_(x) printf x 54#define DBG_(x) printf x
55#else 55#else
56#define DBG_(x) 56#define DBG_(x)
57#endif 57#endif
58 58
59/**** External Functions ****/ 59/**** External Functions ****/
60 60
61/* assign local name to parser variables and functions so that 61/* assign local name to parser variables and functions so that
62 we can use more than one yacc based parser. 62 we can use more than one yacc based parser.
63*/ 63*/
64 64
65#if 0 65#if 0
66#define yyparse mime_parse 66#define yyparse mime_parse
67#define yylex mime_lex 67#define yylex mime_lex
68#define yyerror mime_error 68#define yyerror mime_error
69#define yychar mime_char 69#define yychar mime_char
70/* #define p_yyval p_mime_val */ 70/* #define p_yyval p_mime_val */
71#undef yyval 71#undef yyval
72#define yyval mime_yyval 72#define yyval mime_yyval
73/* #define p_yylval p_mime_lval */ 73/* #define p_yylval p_mime_lval */
74#undef yylval 74#undef yylval
75#define yylval mime_yylval 75#define yylval mime_yylval
76#define yydebug mime_debug 76#define yydebug mime_debug
77#define yynerrs mime_nerrs 77#define yynerrs mime_nerrs
78#define yyerrflag mime_errflag 78#define yyerrflag mime_errflag
79#define yyss mime_ss 79#define yyss mime_ss
80#define yyssp mime_ssp 80#define yyssp mime_ssp
81#define yyvs mime_vs 81#define yyvs mime_vs
82#define yyvsp mime_vsp 82#define yyvsp mime_vsp
83#define yylhs mime_lhs 83#define yylhs mime_lhs
84#define yylen mime_len 84#define yylen mime_len
85#define yydefred mime_defred 85#define yydefred mime_defred
86#define yydgoto mime_dgoto 86#define yydgoto mime_dgoto
87#define yysindex mime_sindex 87#define yysindex mime_sindex
88#define yyrindex mime_rindex 88#define yyrindex mime_rindex
89#define yygindex mime_gindex 89#define yygindex mime_gindex
90#define yytable mime_table 90#define yytable mime_table
91#define yycheck mime_check 91#define yycheck mime_check
92#define yyname mime_name 92#define yyname mime_name
93#define yyrule mime_rule 93#define yyrule mime_rule
94#ifdef YYPREFIX 94#ifdef YYPREFIX
95#undef YYPREFIX 95#undef YYPREFIX
96#endif 96#endif
97#define YYPREFIX "mime_" 97#define YYPREFIX "mime_"
98#endif 98#endif
99 99
100 100
101#ifndef _NO_LINE_FOLDING 101#ifndef _NO_LINE_FOLDING
102#define _SUPPORT_LINE_FOLDING 1 102#define _SUPPORT_LINE_FOLDING 1
103#endif 103#endif
104 104
105/* undef below if compile with MFC */ 105/* undef below if compile with MFC */
106/* #define INCLUDEMFC 1 */ 106/* #define INCLUDEMFC 1 */
107 107
108#if defined(WIN32) || defined(_WIN32) 108#if defined(WIN32) || defined(_WIN32)
109#ifdef INCLUDEMFC 109#ifdef INCLUDEMFC
110#include <afx.h> 110#include <afx.h>
111#endif 111#endif
112#endif 112#endif
113 113
114#include <string.h> 114#include <string.h>
115#ifndef __MWERKS__ 115#ifndef __MWERKS__
116#include <stdlib.h> 116#include <stdlib.h>
117#endif 117#endif
118#include <stdio.h> 118#include <stdio.h>
119#include <stdlib.h> 119#include <stdlib.h>
120#include <ctype.h> 120#include <ctype.h>
121 121
122//#ifdef PALMTOPCENTER 122//#ifdef PALMTOPCENTER
123//#include <qpe/vobject_p.h> 123//#include <qpe/vobject_p.h>
124//#else 124//#else
125#include "vobject_p.h" 125#include "vobject_p.h"
126//#endif 126//#endif
127 127
128/**** Types, Constants ****/ 128/**** Types, Constants ****/
129 129
130 #define YYDEBUG 0/* 1 to compile in some debugging code */ 130 #define YYDEBUG 0/* 1 to compile in some debugging code */
131 #define MAXTOKEN 256/* maximum token (line) length */ 131 #define MAXTOKEN 256/* maximum token (line) length */
132 #define YYSTACKSIZE 100// ~unref ? 132 #define YYSTACKSIZE 100// ~unref ?
133 #define MAXLEVEL 10/* max # of nested objects parseable */ 133 #define MAXLEVEL 10/* max # of nested objects parseable */
134 /* (includes outermost) */ 134 /* (includes outermost) */
135 135
136 136
137/**** Global Variables ****/ 137/**** Global Variables ****/
138int mime_lineNum, mime_numErrors; /* yyerror() can use these */ 138int mime_lineNum, mime_numErrors; /* yyerror() can use these */
139static VObject* vObjList; 139static VObject* vObjList;
140static VObject *curProp; 140static VObject *curProp;
141static VObject *curObj; 141static VObject *curObj;
142static VObject* ObjStack[MAXLEVEL]; 142static VObject* ObjStack[MAXLEVEL];
143static int ObjStackTop; 143static int ObjStackTop;
144 144
145 145
146/* A helpful utility for the rest of the app. */ 146/* A helpful utility for the rest of the app. */
147#if __CPLUSPLUS__ 147#if __CPLUSPLUS__
148extern "C" { 148extern "C" {
149#endif 149#endif
150 150
151 extern void yyerror(char *s); 151 extern void yyerror(char *s);
152 152
153#if __CPLUSPLUS__ 153#if __CPLUSPLUS__
154 }; 154 };
155#endif 155#endif
156 156
157int yyparse(); 157int yyparse();
158 158
159enum LexMode { 159enum LexMode {
160 L_NORMAL, 160 L_NORMAL,
161 L_VCARD, 161 L_VCARD,
162 L_VCAL, 162 L_VCAL,
163 L_VEVENT, 163 L_VEVENT,
164 L_VTODO, 164 L_VTODO,
165 L_VALUES, 165 L_VALUES,
166 L_BASE64, 166 L_BASE64,
167 L_QUOTED_PRINTABLE 167 L_QUOTED_PRINTABLE
168 }; 168 };
169 169
170/**** Private Forward Declarations ****/ 170/**** Private Forward Declarations ****/
171static int pushVObject(const char *prop); 171static int pushVObject(const char *prop);
172static VObject* popVObject(); 172static VObject* popVObject();
173static void lexPopMode(int top); 173static void lexPopMode(int top);
174static int lexWithinMode(enum LexMode mode); 174static int lexWithinMode(enum LexMode mode);
175static void lexPushMode(enum LexMode mode); 175static void lexPushMode(enum LexMode mode);
176static void enterProps(const char *s); 176static void enterProps(const char *s);
177static void enterAttr(const char *s1, const char *s2); 177static void enterAttr(const char *s1, const char *s2);
178static void enterValues(const char *value); 178static void enterValues(const char *value);
179#define mime_error yyerror 179#define mime_error yyerror
180void mime_error(char *s); 180void mime_error(char *s);
181void mime_error_(char *s); 181void mime_error_(char *s);
182 182
183%} 183%}
184 184
185/***************************************************************************/ 185/***************************************************************************/
186/*** The grammar ****/ 186/*** The grammar ****/
187/***************************************************************************/ 187/***************************************************************************/
188 188
189%union { 189%union {
190 char *str; 190 char *str;
191 VObject *vobj; 191 VObject *vobj;
192 } 192 }
193 193
194%token 194%token
195 EQ COLON DOT SEMICOLON SPACE HTAB LINESEP NEWLINE 195 EQ COLON DOT SEMICOLON SPACE HTAB LINESEP NEWLINE
196 BEGIN_VCARD END_VCARD BEGIN_VCAL END_VCAL 196 BEGIN_VCARD END_VCARD BEGIN_VCAL END_VCAL
197 BEGIN_VEVENT END_VEVENT BEGIN_VTODO END_VTODO 197 BEGIN_VEVENT END_VEVENT BEGIN_VTODO END_VTODO
198 ID 198 ID
199 199
200/* 200/*
201 * NEWLINE is the token that would occur outside a vCard, 201 * NEWLINE is the token that would occur outside a vCard,
202 * while LINESEP is the token that would occur inside a vCard. 202 * while LINESEP is the token that would occur inside a vCard.
203 */ 203 */
204 204
205%token <str> 205%token <str>
206 STRING ID 206 STRING ID
207 207
208%type <str> name value 208%type <str> name value
209 209
210%type <vobj> vcard vcal vobject 210%type <vobj> vcard vcal vobject
211 211
212%start mime 212%start mime
213 213
214%% 214%%
215 215
216 216
217mime: vobjects 217mime: vobjects
218 ; 218 ;
219 219
220vobjects: vobjects vobject 220vobjects: vobjects vobject
221 { addList(&vObjList, $2); curObj = 0; } 221 { addList(&vObjList, $2); curObj = 0; }
222 | vobject 222 | vobject
223 { addList(&vObjList, $1); curObj = 0; } 223 { addList(&vObjList, $1); curObj = 0; }
224 ; 224 ;
225 225
226vobject: vcard 226vobject: vcard
227 | vcal 227 | vcal
228 ; 228 ;
229 229
230vcard: 230vcard:
231 BEGIN_VCARD 231 BEGIN_VCARD
232 { 232 {
233 lexPushMode(L_VCARD); 233 lexPushMode(L_VCARD);
234 if (!pushVObject(VCCardProp)) YYERROR; 234 if (!pushVObject(VCCardProp)) YYERROR;
235 } 235 }
236 items END_VCARD 236 items END_VCARD
237 { 237 {
238 lexPopMode(0); 238 lexPopMode(0);
239 $$ = popVObject(); 239 $$ = popVObject();
240 } 240 }
241 | BEGIN_VCARD 241 | BEGIN_VCARD
242 { 242 {
243 lexPushMode(L_VCARD); 243 lexPushMode(L_VCARD);
244 if (!pushVObject(VCCardProp)) YYERROR; 244 if (!pushVObject(VCCardProp)) YYERROR;
245 } 245 }
246 END_VCARD 246 END_VCARD
247 { 247 {
248 lexPopMode(0); 248 lexPopMode(0);
249 $$ = popVObject(); 249 $$ = popVObject();
250 } 250 }
251 ; 251 ;
252 252
253items: items item 253items: items item
254 | item 254 | item
255 ; 255 ;
256 256
257item: prop COLON 257item: prop COLON
258 { 258 {
259 lexPushMode(L_VALUES); 259 lexPushMode(L_VALUES);
260 } 260 }
261 values LINESEP 261 values LINESEP
262 { 262 {
263 if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE)) 263 if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE))
264 lexPopMode(0); 264 lexPopMode(0);
265 lexPopMode(0); 265 lexPopMode(0);
266 } 266 }
267 | error 267 | error
268 ; 268 ;
269 269
270prop: name 270prop: name
271 { 271 {
272 enterProps($1); 272 enterProps($1);
273 } 273 }
274 attr_params 274 attr_params
275 | name 275 | name
276 { 276 {
277 enterProps($1); 277 enterProps($1);
278 } 278 }
279 ; 279 ;
280 280
281attr_params: attr_params attr_param 281attr_params: attr_params attr_param
282 | attr_param 282 | attr_param
283 ; 283 ;
284 284
285attr_param: SEMICOLON attr 285attr_param: SEMICOLON attr
286 ; 286 ;
287 287
288attr: name 288attr: name
289 { 289 {
290 enterAttr($1,0); 290 enterAttr($1,0);
291 } 291 }
292 | name EQ name 292 | name EQ name
293 { 293 {
294 enterAttr($1,$3); 294 enterAttr($1,$3);
295 295
296 } 296 }
297 ; 297 ;
298 298
299name: ID 299name: ID
300 ; 300 ;
301 301
302values: value SEMICOLON { enterValues($1); } values 302values: value SEMICOLON { enterValues($1); } values
303 | value 303 | value
304 { enterValues($1); } 304 { enterValues($1); }
305 ; 305 ;
306 306
307value: STRING 307value: STRING
308 | 308 |
309 { $$ = 0; } 309 { $$ = 0; }
310 ; 310 ;
311 311
312vcal: 312vcal:
313 BEGIN_VCAL 313 BEGIN_VCAL
314 { if (!pushVObject(VCCalProp)) YYERROR; } 314 { if (!pushVObject(VCCalProp)) YYERROR; }
315 calitems 315 calitems
316 END_VCAL 316 END_VCAL
317 { $$ = popVObject(); } 317 { $$ = popVObject(); }
318 | BEGIN_VCAL 318 | BEGIN_VCAL
319 { if (!pushVObject(VCCalProp)) YYERROR; } 319 { if (!pushVObject(VCCalProp)) YYERROR; }
320 END_VCAL 320 END_VCAL
321 { $$ = popVObject(); } 321 { $$ = popVObject(); }
322 ; 322 ;
323 323
324calitems: calitems calitem 324calitems: calitems calitem
325 | calitem 325 | calitem
326 ; 326 ;
327 327
328calitem: 328calitem:
329 eventitem 329 eventitem
330 | todoitem 330 | todoitem
331 | items 331 | items
332 ; 332 ;
333 333
334eventitem: 334eventitem:
335 BEGIN_VEVENT 335 BEGIN_VEVENT
336 { 336 {
337 lexPushMode(L_VEVENT); 337 lexPushMode(L_VEVENT);
338 if (!pushVObject(VCEventProp)) YYERROR; 338 if (!pushVObject(VCEventProp)) YYERROR;
339 } 339 }
340 items 340 items
341 END_VEVENT 341 END_VEVENT
342 { 342 {
343 lexPopMode(0); 343 lexPopMode(0);
344 popVObject(); 344 popVObject();
345 } 345 }
346 | BEGIN_VEVENT 346 | BEGIN_VEVENT
347 { 347 {
348 lexPushMode(L_VEVENT); 348 lexPushMode(L_VEVENT);
349 if (!pushVObject(VCEventProp)) YYERROR; 349 if (!pushVObject(VCEventProp)) YYERROR;
350 } 350 }
351 END_VEVENT 351 END_VEVENT
352 { 352 {
353 lexPopMode(0); 353 lexPopMode(0);
354 popVObject(); 354 popVObject();
355 } 355 }
356 ; 356 ;
357 357
358todoitem: 358todoitem:
359 BEGIN_VTODO 359 BEGIN_VTODO
360 { 360 {
361 lexPushMode(L_VTODO); 361 lexPushMode(L_VTODO);
362 if (!pushVObject(VCTodoProp)) YYERROR; 362 if (!pushVObject(VCTodoProp)) YYERROR;
363 } 363 }
364 items 364 items
365 END_VTODO 365 END_VTODO
366 { 366 {
367 lexPopMode(0); 367 lexPopMode(0);
368 popVObject(); 368 popVObject();
369 } 369 }
370 | BEGIN_VTODO 370 | BEGIN_VTODO
371 { 371 {
372 lexPushMode(L_VTODO); 372 lexPushMode(L_VTODO);
373 if (!pushVObject(VCTodoProp)) YYERROR; 373 if (!pushVObject(VCTodoProp)) YYERROR;
374 } 374 }
375 END_VTODO 375 END_VTODO
376 { 376 {
377 lexPopMode(0); 377 lexPopMode(0);
378 popVObject(); 378 popVObject();
379 } 379 }
380 ; 380 ;
381 381
382%% 382%%
383/*------------------------------------*/ 383/*------------------------------------*/
384static int pushVObject(const char *prop) 384static int pushVObject(const char *prop)
385 { 385 {
386 VObject *newObj; 386 VObject *newObj;
387 if (ObjStackTop == MAXLEVEL) 387 if (ObjStackTop == MAXLEVEL)
388 return FALSE; 388 return FALSE;
389 389
390 ObjStack[++ObjStackTop] = curObj; 390 ObjStack[++ObjStackTop] = curObj;
391 391
392 if (curObj) { 392 if (curObj) {
393 newObj = addProp(curObj,prop); 393 newObj = addProp(curObj,prop);
394 curObj = newObj; 394 curObj = newObj;
395 } 395 }
396 else 396 else
397 curObj = newVObject(prop); 397 curObj = newVObject(prop);
398 398
399 return TRUE; 399 return TRUE;
400 } 400 }
401 401
402 402
403/*---------------------------------------*/ 403/*---------------------------------------*/
404/* This pops the recently built vCard off the stack and returns it. */ 404/* This pops the recently built vCard off the stack and returns it. */
405static VObject* popVObject() 405static VObject* popVObject()
406 { 406 {
407 VObject *oldObj; 407 VObject *oldObj;
408 if (ObjStackTop < 0) { 408 if (ObjStackTop < 0) {
409 yyerror("pop on empty Object Stack\n"); 409 yyerror("pop on empty Object Stack\n");
410 return 0; 410 return 0;
411 } 411 }
412 oldObj = curObj; 412 oldObj = curObj;
413 curObj = ObjStack[ObjStackTop--]; 413 curObj = ObjStack[ObjStackTop--];
414 414
415 return oldObj; 415 return oldObj;
416 } 416 }
417 417
418 418
419static void enterValues(const char *value) 419static void enterValues(const char *value)
420 { 420 {
421 if (fieldedProp && *fieldedProp) { 421 if (fieldedProp && *fieldedProp) {
422 if (value) { 422 if (value) {
423 addPropValue(curProp,*fieldedProp,value); 423 addPropValue(curProp,*fieldedProp,value);
424 } 424 }
425 /* else this field is empty, advance to next field */ 425 /* else this field is empty, advance to next field */
426 fieldedProp++; 426 fieldedProp++;
427 } 427 }
428 else { 428 else {
429 if (value) { 429 if (value) {
430 setVObjectStringZValue_(curProp,strdup( value )); 430 setVObjectStringZValue_(curProp,strdup( value ));
431 } 431 }
432 } 432 }
433 deleteStr(value); 433 deleteStr(value);
434 } 434 }
435 435
436static void enterProps(const char *s) 436static void enterProps(const char *s)
437 { 437 {
438 curProp = addGroup(curObj,s); 438 curProp = addGroup(curObj,s);
439 deleteStr(s); 439 deleteStr(s);
440 } 440 }
441 441
442static void enterAttr(const char *s1, const char *s2) 442static void enterAttr(const char *s1, const char *s2)
443 { 443 {
444 const char *p1, *p2; 444 const char *p1, *p2=0;
445 p1 = lookupProp_(s1); 445 p1 = lookupProp_(s1);
446 if (s2) { 446 if (s2) {
447 VObject *a; 447 VObject *a;
448 p2 = lookupProp_(s2); 448 p2 = lookupProp_(s2);
449 a = addProp(curProp,p1); 449 a = addProp(curProp,p1);
450 setVObjectStringZValue(a,p2); 450 setVObjectStringZValue(a,p2);
451 } 451 }
452 else 452 else
453 addProp(curProp,p1); 453 addProp(curProp,p1);
454 if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0)) 454 if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0))
455 lexPushMode(L_BASE64); 455 lexPushMode(L_BASE64);
456 else if (qstricmp(p1,VCQuotedPrintableProp) == 0 456 else if (qstricmp(p1,VCQuotedPrintableProp) == 0
457 || (s2 && qstricmp(p2,VCQuotedPrintableProp)==0)) 457 || (s2 && qstricmp(p2,VCQuotedPrintableProp)==0))
458 lexPushMode(L_QUOTED_PRINTABLE); 458 lexPushMode(L_QUOTED_PRINTABLE);
459 deleteStr(s1); deleteStr(s2); 459 deleteStr(s1); deleteStr(s2);
460 } 460 }
461 461
462 462
463#define MAX_LEX_LOOKAHEAD_0 32 463#define MAX_LEX_LOOKAHEAD_0 32
464#define MAX_LEX_LOOKAHEAD 64 464#define MAX_LEX_LOOKAHEAD 64
465#define MAX_LEX_MODE_STACK_SIZE 10 465#define MAX_LEX_MODE_STACK_SIZE 10
466#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop]) 466#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop])
467 467
468struct LexBuf { 468struct LexBuf {
469 /* input */ 469 /* input */
470#ifdef INCLUDEMFC 470#ifdef INCLUDEMFC
471 CFile *inputFile; 471 CFile *inputFile;
472#else 472#else
473 FILE *inputFile; 473 FILE *inputFile;
474#endif 474#endif
475 char *inputString; 475 char *inputString;
476 unsigned long curPos; 476 unsigned long curPos;
477 unsigned long inputLen; 477 unsigned long inputLen;
478 /* lookahead buffer */ 478 /* lookahead buffer */
479 /* -- lookahead buffer is short instead of char so that EOF 479 /* -- lookahead buffer is short instead of char so that EOF
480 / can be represented correctly. 480 / can be represented correctly.
481 */ 481 */
482 unsigned long len; 482 unsigned long len;
483 short buf[MAX_LEX_LOOKAHEAD]; 483 short buf[MAX_LEX_LOOKAHEAD];
484 unsigned long getPtr; 484 unsigned long getPtr;
485 /* context stack */ 485 /* context stack */
486 unsigned long lexModeStackTop; 486 unsigned long lexModeStackTop;
487 enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE]; 487 enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE];
488 /* token buffer */ 488 /* token buffer */
489 unsigned long maxToken; 489 unsigned long maxToken;
490 char *strs; 490 char *strs;
491 unsigned long strsLen; 491 unsigned long strsLen;
492 } lexBuf; 492 } lexBuf;
493 493
494static void lexPushMode(enum LexMode mode) 494static void lexPushMode(enum LexMode mode)
495 { 495 {
496 if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1)) 496 if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1))
497 yyerror("lexical context stack overflow"); 497 yyerror("lexical context stack overflow");
498 else { 498 else {
499 lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode; 499 lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode;
500 } 500 }
501 } 501 }
502 502
503static void lexPopMode(int top) 503static void lexPopMode(int top)
504 { 504 {
505 /* special case of pop for ease of error recovery -- this 505 /* special case of pop for ease of error recovery -- this
506 version will never underflow */ 506 version will never underflow */
507 if (top) 507 if (top)
508 lexBuf.lexModeStackTop = 0; 508 lexBuf.lexModeStackTop = 0;
509 else 509 else
510 if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--; 510 if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--;
511 } 511 }
512 512
513static int lexWithinMode(enum LexMode mode) { 513static int lexWithinMode(enum LexMode mode) {
514 unsigned long i; 514 unsigned long i;
515 for (i=0;i<lexBuf.lexModeStackTop;i++) 515 for (i=0;i<lexBuf.lexModeStackTop;i++)
516 if (mode == lexBuf.lexModeStack[i]) return 1; 516 if (mode == lexBuf.lexModeStack[i]) return 1;
517 return 0; 517 return 0;
518 } 518 }
519 519
520static int lexGetc_() 520static int lexGetc_()
521 { 521 {
522 /* get next char from input, no buffering. */ 522 /* get next char from input, no buffering. */
523 if (lexBuf.curPos == lexBuf.inputLen) 523 if (lexBuf.curPos == lexBuf.inputLen)
524 return EOF; 524 return EOF;
525 else if (lexBuf.inputString) 525 else if (lexBuf.inputString)
526 return *(lexBuf.inputString + lexBuf.curPos++); 526 return *(lexBuf.inputString + lexBuf.curPos++);
527 else { 527 else {
528#ifdef INCLUDEMFC 528#ifdef INCLUDEMFC
529 char result; 529 char result;
530 return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF; 530 return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF;
531#else 531#else
532 return fgetc(lexBuf.inputFile); 532 return fgetc(lexBuf.inputFile);
533#endif 533#endif
534 } 534 }
535 } 535 }
536 536
537static int lexGeta() 537static int lexGeta()
538 { 538 {
539 ++lexBuf.len; 539 ++lexBuf.len;
540 return (lexBuf.buf[lexBuf.getPtr] = lexGetc_()); 540 return (lexBuf.buf[lexBuf.getPtr] = lexGetc_());
541 } 541 }
542 542
543static int lexGeta_(int i) 543static int lexGeta_(int i)
544 { 544 {
545 ++lexBuf.len; 545 ++lexBuf.len;
546 return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_()); 546 return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_());
547 } 547 }
548 548
549static void lexSkipLookahead() { 549static void lexSkipLookahead() {
550 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { 550 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
551 /* don't skip EOF. */ 551 /* don't skip EOF. */
552 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; 552 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
553 lexBuf.len--; 553 lexBuf.len--;
554 } 554 }
555 } 555 }
556 556
557static int lexLookahead() { 557static int lexLookahead() {
558 int c = (lexBuf.len)? 558 int c = (lexBuf.len)?
559 lexBuf.buf[lexBuf.getPtr]: 559 lexBuf.buf[lexBuf.getPtr]:
560 lexGeta(); 560 lexGeta();
561 /* do the \r\n -> \n or \r -> \n translation here */ 561 /* do the \r\n -> \n or \r -> \n translation here */
562 if (c == '\r') { 562 if (c == '\r') {
563 int a = (lexBuf.len>1)? 563 int a = (lexBuf.len>1)?
564 lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]: 564 lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]:
565 lexGeta_(1); 565 lexGeta_(1);
566 if (a == '\n') { 566 if (a == '\n') {
567 lexSkipLookahead(); 567 lexSkipLookahead();
568 } 568 }
569 lexBuf.buf[lexBuf.getPtr] = c = '\n'; 569 lexBuf.buf[lexBuf.getPtr] = c = '\n';
570 } 570 }
571 else if (c == '\n') { 571 else if (c == '\n') {
572 int a = (lexBuf.len>1)? 572 int a = (lexBuf.len>1)?
573 lexBuf.buf[lexBuf.getPtr+1]: 573 lexBuf.buf[lexBuf.getPtr+1]:
574 lexGeta_(1); 574 lexGeta_(1);
575 if (a == '\r') { 575 if (a == '\r') {
576 lexSkipLookahead(); 576 lexSkipLookahead();
577 } 577 }
578 lexBuf.buf[lexBuf.getPtr] = '\n'; 578 lexBuf.buf[lexBuf.getPtr] = '\n';
579 } 579 }
580 return c; 580 return c;
581 } 581 }
582 582
583static int lexGetc() { 583static int lexGetc() {
584 int c = lexLookahead(); 584 int c = lexLookahead();
585 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { 585 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
586 /* EOF will remain in lookahead buffer */ 586 /* EOF will remain in lookahead buffer */
587 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; 587 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
588 lexBuf.len--; 588 lexBuf.len--;
589 } 589 }
590 return c; 590 return c;
591 } 591 }
592 592
593static void lexSkipLookaheadWord() { 593static void lexSkipLookaheadWord() {
594 if (lexBuf.strsLen <= lexBuf.len) { 594 if (lexBuf.strsLen <= lexBuf.len) {
595 lexBuf.len -= lexBuf.strsLen; 595 lexBuf.len -= lexBuf.strsLen;
596 lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; 596 lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
597 } 597 }
598 } 598 }
599 599
600static void lexClearToken() 600static void lexClearToken()
601 { 601 {
602 lexBuf.strsLen = 0; 602 lexBuf.strsLen = 0;
603 } 603 }
604 604
605static void lexAppendc(int c) 605static void lexAppendc(int c)
606 { 606 {
607 lexBuf.strs[lexBuf.strsLen] = c; 607 lexBuf.strs[lexBuf.strsLen] = c;
608 /* append up to zero termination */ 608 /* append up to zero termination */
609 if (c == 0) return; 609 if (c == 0) return;
610 lexBuf.strsLen++; 610 lexBuf.strsLen++;
611 if (lexBuf.strsLen > lexBuf.maxToken) { 611 if (lexBuf.strsLen > lexBuf.maxToken) {
612 /* double the token string size */ 612 /* double the token string size */
613 lexBuf.maxToken <<= 1; 613 lexBuf.maxToken <<= 1;
614 lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); 614 lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken);
615 } 615 }
616 } 616 }
617 617
618static char* lexStr() { 618static char* lexStr() {
619 return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1); 619 return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1);
620 } 620 }
621 621
622static void lexSkipWhite() { 622static void lexSkipWhite() {
623 int c = lexLookahead(); 623 int c = lexLookahead();
624 while (c == ' ' || c == '\t') { 624 while (c == ' ' || c == '\t') {
625 lexSkipLookahead(); 625 lexSkipLookahead();
626 c = lexLookahead(); 626 c = lexLookahead();
627 } 627 }
628 } 628 }
629 629
630static char* lexGetWord() { 630static char* lexGetWord() {
631 int c; 631 int c;
632 lexSkipWhite(); 632 lexSkipWhite();
633 lexClearToken(); 633 lexClearToken();
634 c = lexLookahead(); 634 c = lexLookahead();
635 while (c != EOF && !strchr("\t\n ;:=",c)) { 635 while (c != EOF && !strchr("\t\n ;:=",c)) {
636 lexAppendc(c); 636 lexAppendc(c);
637 lexSkipLookahead(); 637 lexSkipLookahead();
638 c = lexLookahead(); 638 c = lexLookahead();
639 } 639 }
640 lexAppendc(0); 640 lexAppendc(0);
641 return lexStr(); 641 return lexStr();
642 } 642 }
643 643
644static void lexPushLookaheadc(int c) { 644static void lexPushLookaheadc(int c) {
645 int putptr; 645 int putptr;
646 /* can't putback EOF, because it never leaves lookahead buffer */ 646 /* can't putback EOF, because it never leaves lookahead buffer */
647 if (c == EOF) return; 647 if (c == EOF) return;
648 putptr = (int)lexBuf.getPtr - 1; 648 putptr = (int)lexBuf.getPtr - 1;
649 if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; 649 if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
650 lexBuf.getPtr = putptr; 650 lexBuf.getPtr = putptr;
651 lexBuf.buf[putptr] = c; 651 lexBuf.buf[putptr] = c;
652 lexBuf.len += 1; 652 lexBuf.len += 1;
653 } 653 }
654 654
655static char* lexLookaheadWord() { 655static char* lexLookaheadWord() {
656 /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0 656 /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0
657 / and thing bigger than that will stop the lookahead and return 0; 657 / and thing bigger than that will stop the lookahead and return 0;
658 / leading white spaces are not recoverable. 658 / leading white spaces are not recoverable.
659 */ 659 */
660 int c; 660 int c;
661 int len = 0; 661 int len = 0;
662 int curgetptr = 0; 662 int curgetptr = 0;
663 lexSkipWhite(); 663 lexSkipWhite();
664 lexClearToken(); 664 lexClearToken();
665 curgetptr = (int)lexBuf.getPtr;// remember! 665 curgetptr = (int)lexBuf.getPtr;// remember!
666 while (len < (MAX_LEX_LOOKAHEAD_0)) { 666 while (len < (MAX_LEX_LOOKAHEAD_0)) {
667 c = lexGetc(); 667 c = lexGetc();
668 len++; 668 len++;
669 if (c == EOF || strchr("\t\n ;:=", c)) { 669 if (c == EOF || strchr("\t\n ;:=", c)) {
670 lexAppendc(0); 670 lexAppendc(0);
671 /* restore lookahead buf. */ 671 /* restore lookahead buf. */
672 lexBuf.len += len; 672 lexBuf.len += len;
673 lexBuf.getPtr = curgetptr; 673 lexBuf.getPtr = curgetptr;
674 return lexStr(); 674 return lexStr();
675 } 675 }
676 else 676 else
677 lexAppendc(c); 677 lexAppendc(c);
678 } 678 }
679 lexBuf.len += len;/* char that has been moved to lookahead buffer */ 679 lexBuf.len += len;/* char that has been moved to lookahead buffer */
680 lexBuf.getPtr = curgetptr; 680 lexBuf.getPtr = curgetptr;
681 return 0; 681 return 0;
682 } 682 }
683 683
684#ifdef _SUPPORT_LINE_FOLDING 684#ifdef _SUPPORT_LINE_FOLDING
685static void handleMoreRFC822LineBreak(int c) { 685static void handleMoreRFC822LineBreak(int c) {
686 /* suport RFC 822 line break in cases like 686 /* suport RFC 822 line break in cases like
687 *ADR: foo; 687 *ADR: foo;
688 * morefoo; 688 * morefoo;
689 * more foo; 689 * more foo;
690 */ 690 */
691 if (c == ';') { 691 if (c == ';') {
692 int a; 692 int a;
693 lexSkipLookahead(); 693 lexSkipLookahead();
694 /* skip white spaces */ 694 /* skip white spaces */
695 a = lexLookahead(); 695 a = lexLookahead();
696 while (a == ' ' || a == '\t') { 696 while (a == ' ' || a == '\t') {
697 lexSkipLookahead(); 697 lexSkipLookahead();
698 a = lexLookahead(); 698 a = lexLookahead();
699 } 699 }
700 if (a == '\n') { 700 if (a == '\n') {
701 lexSkipLookahead(); 701 lexSkipLookahead();
702 a = lexLookahead(); 702 a = lexLookahead();
703 if (a == ' ' || a == '\t') { 703 if (a == ' ' || a == '\t') {
704 /* continuation, throw away all the \n and spaces read so 704 /* continuation, throw away all the \n and spaces read so
705 * far 705 * far
706 */ 706 */
707 lexSkipWhite(); 707 lexSkipWhite();
708 lexPushLookaheadc(';'); 708 lexPushLookaheadc(';');
709 } 709 }
710 else { 710 else {
711 lexPushLookaheadc('\n'); 711 lexPushLookaheadc('\n');
712 lexPushLookaheadc(';'); 712 lexPushLookaheadc(';');
713 } 713 }
714 } 714 }
715 else { 715 else {
716 lexPushLookaheadc(';'); 716 lexPushLookaheadc(';');
717 } 717 }
718 } 718 }
719 } 719 }
720 720
721static char* lexGet1Value() { 721static char* lexGet1Value() {
722 int c; 722 int c;
723 lexSkipWhite(); 723 lexSkipWhite();
724 c = lexLookahead(); 724 c = lexLookahead();
725 lexClearToken(); 725 lexClearToken();
726 while (c != EOF && (c != ';' || !fieldedProp)) { 726 while (c != EOF && (c != ';' || !fieldedProp)) {
727 if (c == '\\' ) { 727 if (c == '\\' ) {
728 int a; 728 int a;
729 lexSkipLookahead(); 729 lexSkipLookahead();
730 a = lexLookahead(); 730 a = lexLookahead();
731 if ( a == ';' ) { 731 if ( a == ';' ) {
732 lexAppendc( ';' ); 732 lexAppendc( ';' );
733 lexSkipLookahead(); 733 lexSkipLookahead();
734 } else if ( a == '\n' ) { 734 } else if ( a == '\n' ) {
735 lexAppendc( '\n' ); 735 lexAppendc( '\n' );
736 lexSkipLookahead(); 736 lexSkipLookahead();
737 } else if ( a == '\\' ) { 737 } else if ( a == '\\' ) {
738 lexAppendc( '\\' ); 738 lexAppendc( '\\' );
739 lexSkipLookahead(); 739 lexSkipLookahead();
740 } else { 740 } else {
741 lexAppendc('\\'); 741 lexAppendc('\\');
742 } 742 }
743 } else if (c == '\n') { 743 } else if (c == '\n') {
744 int a; 744 int a;
745 lexSkipLookahead(); 745 lexSkipLookahead();
746 a = lexLookahead(); 746 a = lexLookahead();
747 if (a == ' ' || a == '\t') { 747 if (a == ' ' || a == '\t') {
748 lexAppendc(' '); 748 lexAppendc(' ');
749 lexSkipLookahead(); 749 lexSkipLookahead();
750 } 750 }
751 else { 751 else {
752 lexPushLookaheadc('\n'); 752 lexPushLookaheadc('\n');
753 break; 753 break;
754 } 754 }
755 } 755 }
756 else { 756 else {
757 lexAppendc(c); 757 lexAppendc(c);
758 lexSkipLookahead(); 758 lexSkipLookahead();
759 } 759 }
760 c = lexLookahead(); 760 c = lexLookahead();
761 } 761 }
762 lexAppendc(0); 762 lexAppendc(0);
763 handleMoreRFC822LineBreak(c); 763 handleMoreRFC822LineBreak(c);
764 return c==EOF?0:lexStr(); 764 return c==EOF?0:lexStr();
765 } 765 }
766#endif 766#endif
767 767
768static int match_begin_name(int end) { 768static int match_begin_name(int end) {
769 char *n = lexLookaheadWord(); 769 char *n = lexLookaheadWord();
770 int token = ID; 770 int token = ID;
771 if (n) { 771 if (n) {
772 if (!qstricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD; 772 if (!qstricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
773 else if (!qstricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL; 773 else if (!qstricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
774 else if (!qstricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT; 774 else if (!qstricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
775 else if (!qstricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO; 775 else if (!qstricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
776 deleteStr(n); 776 deleteStr(n);
777 return token; 777 return token;
778 } 778 }
779 return 0; 779 return 0;
780 } 780 }
781 781
782 782
783#ifdef INCLUDEMFC 783#ifdef INCLUDEMFC
784void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) 784void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile)
785#else 785#else
786void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) 786void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
787#endif 787#endif
788 { 788 {
789 // initialize lex mode stack 789 // initialize lex mode stack
790 lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL; 790 lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
791 791
792 // iniatialize lex buffer. 792 // iniatialize lex buffer.
793 lexBuf.inputString = (char*) inputstring; 793 lexBuf.inputString = (char*) inputstring;
794 lexBuf.inputLen = inputlen; 794 lexBuf.inputLen = inputlen;
795 lexBuf.curPos = 0; 795 lexBuf.curPos = 0;
796 lexBuf.inputFile = inputfile; 796 lexBuf.inputFile = inputfile;
797 797
798 lexBuf.len = 0; 798 lexBuf.len = 0;
799 lexBuf.getPtr = 0; 799 lexBuf.getPtr = 0;
800 800
801 lexBuf.maxToken = MAXTOKEN; 801 lexBuf.maxToken = MAXTOKEN;
802 lexBuf.strs = (char*)malloc(MAXTOKEN); 802 lexBuf.strs = (char*)malloc(MAXTOKEN);
803 lexBuf.strsLen = 0; 803 lexBuf.strsLen = 0;
804 804
805 } 805 }
806 806
807static void finiLex() { 807static void finiLex() {
808 free(lexBuf.strs); 808 free(lexBuf.strs);
809 } 809 }
810 810
811 811
812/*-----------------------------------*/ 812/*-----------------------------------*/
813/* This parses and converts the base64 format for binary encoding into 813/* This parses and converts the base64 format for binary encoding into
814 * a decoded buffer (allocated with new). See RFC 1521. 814 * a decoded buffer (allocated with new). See RFC 1521.
815 */ 815 */
816static char * lexGetDataFromBase64() 816static int lexGetDataFromBase64()
817 { 817 {
818 unsigned long bytesLen = 0, bytesMax = 0; 818 unsigned long bytesLen = 0, bytesMax = 0;
819 int quadIx = 0, pad = 0; 819 int quadIx = 0, pad = 0;
820 unsigned long trip = 0; 820 unsigned long trip = 0;
821 unsigned char b; 821 unsigned char b;
822 int c; 822 int c;
823 unsigned char *bytes = NULL; 823 unsigned char *bytes = NULL;
824 unsigned char *oldBytes = NULL; 824 unsigned char *oldBytes = NULL;
825 825
826 DBG_(("db: lexGetDataFromBase64\n")); 826 DBG_(("db: lexGetDataFromBase64\n"));
827 while (1) { 827 while (1) {
828 c = lexGetc(); 828 c = lexGetc();
829 lexSkipWhite();
829 if (c == '\n') { 830 if (c == '\n') {
830 ++mime_lineNum; 831 ++mime_lineNum;
831 if (lexLookahead() == '\n') { 832 if (lexLookahead() == '\n') {
832 /* a '\n' character by itself means end of data */ 833 /* a '\n' character by itself means end of data */
833 break; 834 break;
834 } 835 }
835 else continue; /* ignore '\n' */ 836 else continue; /* ignore '\n' */
836 } 837 }
837 else { 838 else {
838 if ((c >= 'A') && (c <= 'Z')) 839 if ((c >= 'A') && (c <= 'Z'))
839 b = (unsigned char)(c - 'A'); 840 b = (unsigned char)(c - 'A');
840 else if ((c >= 'a') && (c <= 'z')) 841 else if ((c >= 'a') && (c <= 'z'))
841 b = (unsigned char)(c - 'a') + 26; 842 b = (unsigned char)(c - 'a') + 26;
842 else if ((c >= '0') && (c <= '9')) 843 else if ((c >= '0') && (c <= '9'))
843 b = (unsigned char)(c - '0') + 52; 844 b = (unsigned char)(c - '0') + 52;
844 else if (c == '+') 845 else if (c == '+')
845 b = 62; 846 b = 62;
846 else if (c == '/') 847 else if (c == '/')
847 b = 63; 848 b = 63;
848 else if (c == '=') { 849 else if (c == '=') {
849 b = 0; 850 b = 0;
850 pad++; 851 pad++;
851 } else if ((c == ' ') || (c == '\t')) {
852 continue;
853 } else { /* error condition */ 852 } else { /* error condition */
854 if (bytes) free(bytes); 853 if (bytes) free(bytes);
855 else if (oldBytes) free(oldBytes); 854 else if (oldBytes) free(oldBytes);
856 // error recovery: skip until 2 adjacent newlines. 855 // error recovery: skip until 2 adjacent newlines.
857 DBG_(("db: invalid character 0x%x '%c'\n", c,c)); 856 DBG_(("db: invalid character 0x%x '%c'\n", c,c));
858 if (c != EOF) { 857 if (c != EOF) {
859 c = lexGetc(); 858 c = lexGetc();
860 while (c != EOF) { 859 while (c != EOF) {
861 if (c == '\n' && lexLookahead() == '\n') { 860 if (c == '\n') {
862 ++mime_lineNum; 861 lexSkipWhite();
863 break; 862 if(lexLookahead() == '\n') {
863 ++mime_lineNum;
864 break;
865 }
864 } 866 }
865 c = lexGetc(); 867 c = lexGetc();
866 } 868 }
867 } 869 }
868 return NULL; 870 return c != EOF;
869 } 871 }
870 trip = (trip << 6) | b; 872 trip = (trip << 6) | b;
871 if (++quadIx == 4) { 873 if (++quadIx == 4) {
872 unsigned char outBytes[3]; 874 unsigned char outBytes[3];
873 int numOut; 875 int numOut;
874 int i; 876 int i;
875 for (i = 0; i < 3; i++) { 877 for (i = 0; i < 3; i++) {
876 outBytes[2-i] = (unsigned char)(trip & 0xFF); 878 outBytes[2-i] = (unsigned char)(trip & 0xFF);
877 trip >>= 8; 879 trip >>= 8;
878 } 880 }
879 numOut = 3 - pad; 881 numOut = 3 - pad;
880 if (bytesLen + numOut > bytesMax) { 882 if (bytesLen + numOut > bytesMax) {
881 if (!bytes) { 883 if (!bytes) {
882 bytesMax = 1024; 884 bytesMax = 1024;
883 bytes = (unsigned char*)malloc((size_t)bytesMax); 885 bytes = (unsigned char*)malloc((size_t)bytesMax);
884 } 886 }
885 else { 887 else {
886 bytesMax <<= 2; 888 bytesMax <<= 2;
887 oldBytes = bytes; 889 oldBytes = bytes;
888 bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax); 890 bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax);
889 } 891 }
890 if (bytes == 0) { 892 if (bytes == 0) {
891 mime_error("out of memory while processing BASE64 data\n"); 893 mime_error("out of memory while processing BASE64 data\n");
892 } 894 }
893 } 895 }
894 if (bytes) { 896 if (bytes) {
895 memcpy(bytes + bytesLen, outBytes, numOut); 897 memcpy(bytes + bytesLen, outBytes, numOut);
896 bytesLen += numOut; 898 bytesLen += numOut;
897 } 899 }
898 trip = 0; 900 trip = 0;
899 quadIx = 0; 901 quadIx = 0;
900 } 902 }
901 } 903 }
902 } /* while */ 904 } /* while */
903 DBG_(("db: bytesLen = %d\n", bytesLen)); 905 DBG_(("db: bytesLen = %d\n", bytesLen));
904 /* kludge: all this won't be necessary if we have tree form 906 /* kludge: all this won't be necessary if we have tree form
905 representation */ 907 representation */
906 if (bytes) { 908 if (bytes) {
907 setValueWithSize(curProp,bytes,(unsigned int)bytesLen); 909 setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
908 free(bytes); 910 free(bytes);
909 } 911 }
910 else if (oldBytes) { 912 else if (oldBytes) {
911 setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); 913 setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
912 free(oldBytes); 914 free(oldBytes);
913 } 915 }
914 return 0; 916 return bytesLen;
915 } 917 }
916 918
917static int match_begin_end_name(int end) { 919static int match_begin_end_name(int end) {
918 int token; 920 int token;
919 lexSkipWhite(); 921 lexSkipWhite();
920 if (lexLookahead() != ':') return ID; 922 if (lexLookahead() != ':') return ID;
921 lexSkipLookahead(); 923 lexSkipLookahead();
922 lexSkipWhite(); 924 lexSkipWhite();
923 token = match_begin_name(end); 925 token = match_begin_name(end);
924 if (token == ID) { 926 if (token == ID) {
925 lexPushLookaheadc(':'); 927 lexPushLookaheadc(':');
926 DBG_(("db: ID '%s'\n", yylval.str)); 928 DBG_(("db: ID '%s'\n", yylval.str));
927 return ID; 929 return ID;
928 } 930 }
929 else if (token != 0) { 931 else if (token != 0) {
930 lexSkipLookaheadWord(); 932 lexSkipLookaheadWord();
931 deleteStr(yylval.str); 933 deleteStr(yylval.str);
932 DBG_(("db: begin/end %d\n", token)); 934 DBG_(("db: begin/end %d\n", token));
933 return token; 935 return token;
934 } 936 }
935 return 0; 937 return 0;
936 } 938 }
937 939
938static char* lexGetQuotedPrintable() 940static char* lexGetQuotedPrintable()
939{ 941{
940 int c; 942 int c;
941 lexSkipWhite(); 943 lexSkipWhite();
942 c = lexLookahead(); 944 c = lexLookahead();
943 lexClearToken(); 945 lexClearToken();
944 946
945 while (c != EOF && c != ';') { 947 while (c != EOF && (c != ';' || !fieldedProp)) {
946 if (c == '\n') { 948 if (c == '\n') {
947 // break, leave '\n' on remaining chars. 949 // break, leave '\n' on remaining chars.
948 break; 950 break;
949 } else if (c == '=') { 951 } else if (c == '=') {
950 int cur = 0; 952 int cur = 0;
951 int next; 953 int next;
952 954
953 lexSkipLookahead(); // skip '=' 955 lexSkipLookahead(); // skip '='
954 next = lexLookahead(); 956 next = lexLookahead();
955 957
956 if (next == '\n') { 958 if (next == '\n') {
957 // skip and only skip the \n 959 // skip and only skip the \n
958 lexSkipLookahead(); 960 lexSkipLookahead();
959 c = lexLookahead(); 961 c = lexLookahead();
960 ++mime_lineNum; // aid in error reporting 962 ++mime_lineNum; // aid in error reporting
961 continue; 963 continue;
962 } else if (next >= '0' && next <= '9') { 964 } else if (next >= '0' && next <= '9') {
963 cur = next - '0'; 965 cur = next - '0';
964 } else if (next >= 'A' && next <= 'F') { 966 } else if (next >= 'A' && next <= 'F') {
965 cur = next - 'A' + 10; 967 cur = next - 'A' + 10;
966 } else { 968 } else {
967 // we have been sent buggy stuff. doesn't matter 969 // we have been sent buggy stuff. doesn't matter
968 // what we do so long as we keep going. 970 // what we do so long as we keep going.
969 // should probably spit an error here 971 // should probably spit an error here
970 lexSkipLookahead(); 972 lexSkipLookahead();
971 c = lexLookahead(); 973 c = lexLookahead();
972 continue; 974 continue;
973 } 975 }
974 976
975 lexSkipLookahead(); // skip A-Z0-9 977 lexSkipLookahead(); // skip A-Z0-9
976 next = lexLookahead(); 978 next = lexLookahead();
977 979
978 cur = cur * 16; 980 cur = cur * 16;
979 // this time really just expecting 0-9A-F 981 // this time really just expecting 0-9A-F
980 if (next >= '0' && next <= '9') { 982 if (next >= '0' && next <= '9') {
981 cur += next - '0'; 983 cur += next - '0';
982 } else if (next >= 'A' && next <= 'F') { 984 } else if (next >= 'A' && next <= 'F') {
983 cur += next - 'A' + 10; 985 cur += next - 'A' + 10;
984 } else { 986 } else {
985 // we have been sent buggy stuff. doesn't matter 987 // we have been sent buggy stuff. doesn't matter
986 // what we do so long as we keep going. 988 // what we do so long as we keep going.
987 // should probably spit an error here 989 // should probably spit an error here
988 lexSkipLookahead(); 990 lexSkipLookahead();
989 c = lexLookahead(); 991 c = lexLookahead();
990 continue; 992 continue;
991 } 993 }
992 994
993 // got a valid escaped =. append it. 995 // got a valid escaped =. append it.
994 lexSkipLookahead(); // skip second 0-9A-F 996 lexSkipLookahead(); // skip second 0-9A-F
995 lexAppendc(cur); 997 lexAppendc(cur);
996 } else { 998 } else {
997 lexSkipLookahead(); // skip whatever we just read. 999 lexSkipLookahead(); // skip whatever we just read.
998 lexAppendc(c); // and append it. 1000 lexAppendc(c); // and append it.
999 } 1001 }
1000 c = lexLookahead(); 1002 c = lexLookahead();
1001 } 1003 }
1002 lexAppendc(0); 1004 lexAppendc(0);
1003 return c==EOF?0:lexStr(); 1005 return c==EOF?0:lexStr();
1004} 1006}
1005 1007
1006static int yylex() { 1008static int yylex() {
1007 1009
1008 int lexmode = LEXMODE(); 1010 int lexmode = LEXMODE();
1009 if (lexmode == L_VALUES) { 1011 if (lexmode == L_VALUES) {
1010 int c = lexGetc(); 1012 int c = lexGetc();
1011 if (c == ';' && fieldedProp) { 1013 if (c == ';' && fieldedProp) {
1012 DBG_(("db: SEMICOLON\n")); 1014 DBG_(("db: SEMICOLON\n"));
1013 lexPushLookaheadc(c); 1015 lexPushLookaheadc(c);
1014 handleMoreRFC822LineBreak(c); 1016 handleMoreRFC822LineBreak(c);
1015 lexSkipLookahead(); 1017 lexSkipLookahead();
1016 return SEMICOLON; 1018 return SEMICOLON;
1017 } 1019 }
1018 else if (strchr("\n",c)) { 1020 else if (strchr("\n",c)) {
1019 ++mime_lineNum; 1021 ++mime_lineNum;
1020 /* consume all line separator(s) adjacent to each other */ 1022 /* consume all line separator(s) adjacent to each other */
1021 c = lexLookahead(); 1023 c = lexLookahead();
1022 while (strchr("\n",c)) { 1024 while (strchr("\n",c)) {
1023 lexSkipLookahead(); 1025 lexSkipLookahead();
1024 c = lexLookahead(); 1026 c = lexLookahead();
1025 ++mime_lineNum; 1027 ++mime_lineNum;
1026 } 1028 }
1027 DBG_(("db: LINESEP\n")); 1029 DBG_(("db: LINESEP\n"));
1028 return LINESEP; 1030 return LINESEP;
1029 } 1031 }
1030 else { 1032 else {
1031 char *p = 0; 1033 char *p = 0;
1032 lexPushLookaheadc(c); 1034 lexPushLookaheadc(c);
1033 if (lexWithinMode(L_BASE64)) { 1035 if (lexWithinMode(L_BASE64)) {
1034 /* get each char and convert to bin on the fly... */ 1036 /* get each char and convert to bin on the fly... */
1035 p = lexGetDataFromBase64(); 1037 yylval.str = NULL;
1036 #if 0 1038 return lexGetDataFromBase64() ? STRING : 0;
1037 yylval.str = p;
1038 return STRING;
1039 #endif
1040 } 1039 }
1041 else if (lexWithinMode(L_QUOTED_PRINTABLE)) { 1040 else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
1042 p = lexGetQuotedPrintable(); 1041 p = lexGetQuotedPrintable();
1043 } 1042 }
1044 else { 1043 else {
1045#ifdef _SUPPORT_LINE_FOLDING 1044#ifdef _SUPPORT_LINE_FOLDING
1046 p = lexGet1Value(); 1045 p = lexGet1Value();
1047#else 1046#else
1048 p = lexGetStrUntil(";\n"); 1047 p = lexGetStrUntil(";\n");
1049#endif 1048#endif
1050 } 1049 }
1051 if (p) { 1050 if (p) {
1052 DBG_(("db: STRING: '%s'\n", p)); 1051 DBG_(("db: STRING: '%s'\n", p));
1053 yylval.str = p; 1052 yylval.str = p;
1054 return STRING; 1053 return STRING;
1055 } 1054 }
1056 else return 0; 1055 else return 0;
1057 } 1056 }
1058 } 1057 }
1059 else { 1058 else {
1060 /* normal mode */ 1059 /* normal mode */
1061 while (1) { 1060 while (1) {
1062 int c = lexGetc(); 1061 int c = lexGetc();
1063 switch(c) { 1062 switch(c) {
1064 case ':': { 1063 case ':': {
1065 /* consume all line separator(s) adjacent to each other */ 1064 /* consume all line separator(s) adjacent to each other */
1066 /* ignoring linesep immediately after colon. */ 1065 /* ignoring linesep immediately after colon. */
1067 /* I don't see this in the spec, and it breaks null values -- WA 1066 /* I don't see this in the spec, and it breaks null values -- WA
1068 c = lexLookahead(); 1067 c = lexLookahead();
1069 while (strchr("\n",c)) { 1068 while (strchr("\n",c)) {
1070 lexSkipLookahead(); 1069 lexSkipLookahead();
1071 c = lexLookahead(); 1070 c = lexLookahead();
1072 ++mime_lineNum; 1071 ++mime_lineNum;
1073 } 1072 }
1074 */ 1073 */
1075 DBG_(("db: COLON\n")); 1074 DBG_(("db: COLON\n"));
1076 return COLON; 1075 return COLON;
1077 } 1076 }
1078 case ';': 1077 case ';':
1079 DBG_(("db: SEMICOLON\n")); 1078 DBG_(("db: SEMICOLON\n"));
1080 return SEMICOLON; 1079 return SEMICOLON;
1081 case '=': 1080 case '=':
1082 DBG_(("db: EQ\n")); 1081 DBG_(("db: EQ\n"));
1083 return EQ; 1082 return EQ;
1084 /* ignore whitespace in this mode */ 1083 /* ignore whitespace in this mode */
1085 case '\t': 1084 case '\t':
1086 case ' ': continue; 1085 case ' ': continue;
1087 case '\n': { 1086 case '\n': {
1088 ++mime_lineNum; 1087 ++mime_lineNum;
1089 continue; 1088 continue;
1090 } 1089 }
1091 case EOF: return 0; 1090 case EOF: return 0;
1092 break; 1091 break;
1093 default: { 1092 default: {
1094 lexPushLookaheadc(c); 1093 lexPushLookaheadc(c);
1095 if (isalnum(c)) { 1094 if (isalnum(c)) {
1096 char *t = lexGetWord(); 1095 char *t = lexGetWord();
1097 yylval.str = t; 1096 yylval.str = t;
1098 if (!qstricmp(t, "begin")) { 1097 if (!qstricmp(t, "begin")) {
1099 return match_begin_end_name(0); 1098 return match_begin_end_name(0);
1100 } 1099 }
1101 else if (!qstricmp(t,"end")) { 1100 else if (!qstricmp(t,"end")) {
1102 return match_begin_end_name(1); 1101 return match_begin_end_name(1);
1103 } 1102 }
1104 else { 1103 else {
1105 DBG_(("db: ID '%s'\n", t)); 1104 DBG_(("db: ID '%s'\n", t));
1106 return ID; 1105 return ID;
1107 } 1106 }
1108 } 1107 }
1109 else { 1108 else {
1110 /* unknow token */ 1109 /* unknow token */
1111 return 0; 1110 return 0;
1112 } 1111 }
1113 break; 1112 break;
1114 } 1113 }
1115 } 1114 }
1116 } 1115 }
1117 } 1116 }
1118 return 0; 1117 return 0;
1119 } 1118 }
1120 1119
1121 1120
1122/***************************************************************************/ 1121/***************************************************************************/
1123 /*** Public Functions ****/ 1122 /*** Public Functions ****/
1124/***************************************************************************/ 1123/***************************************************************************/
1125 1124
1126static VObject* Parse_MIMEHelper() 1125static VObject* Parse_MIMEHelper()
1127 { 1126 {
1128 ObjStackTop = -1; 1127 ObjStackTop = -1;
1129 mime_numErrors = 0; 1128 mime_numErrors = 0;
1130 mime_lineNum = 1; 1129 mime_lineNum = 1;
1131 vObjList = 0; 1130 vObjList = 0;
1132 curObj = 0; 1131 curObj = 0;
1133 1132
1134 if (yyparse() != 0) 1133 if (yyparse() != 0)
1135 return 0; 1134 return 0;
1136 1135
1137 finiLex(); 1136 finiLex();
1138 return vObjList; 1137 return vObjList;
1139 } 1138 }
1140 1139
1141/*--------------------------------------------*/ 1140/*--------------------------------------------*/
1142DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len) 1141DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len)
1143 { 1142 {
1144 initLex(input, len, 0); 1143 initLex(input, len, 0);
1145 return Parse_MIMEHelper(); 1144 return Parse_MIMEHelper();
1146 } 1145 }
1147 1146
1148 1147
1149#if INCLUDEMFC 1148#if INCLUDEMFC
1150 1149
1151DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file) 1150DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
1152 { 1151 {
1153 unsigned long startPos; 1152 unsigned long startPos;
1154 VObject *result; 1153 VObject *result;
1155 1154
1156 initLex(0,-1,file); 1155 initLex(0,-1,file);
1157 startPos = file->GetPosition(); 1156 startPos = file->GetPosition();
1158 if (!(result = Parse_MIMEHelper())) 1157 if (!(result = Parse_MIMEHelper()))
1159 file->Seek(startPos, CFile::begin); 1158 file->Seek(startPos, CFile::begin);
1160 return result; 1159 return result;
1161 } 1160 }
1162 1161
1163#else 1162#else
1164 1163
1165VObject* Parse_MIME_FromFile(FILE *file) 1164VObject* Parse_MIME_FromFile(FILE *file)
1166 { 1165 {
1167 VObject *result; 1166 VObject *result;
1168 long startPos; 1167 long startPos;
1169 1168
1170 initLex(0,(unsigned long)-1,file); 1169 initLex(0,(unsigned long)-1,file);
1171 startPos = ftell(file); 1170 startPos = ftell(file);
1172 if (!(result = Parse_MIMEHelper())) { 1171 if (!(result = Parse_MIMEHelper())) {
1173 fseek(file,startPos,SEEK_SET); 1172 fseek(file,startPos,SEEK_SET);
1174 } 1173 }
1175 return result; 1174 return result;
1176 } 1175 }
1177 1176
1178DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname) 1177DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
1179 { 1178 {
1180 FILE *fp = fopen(fname,"r"); 1179 FILE *fp = fopen(fname,"r");
1181 if (fp) { 1180 if (fp) {
1182 VObject* o = Parse_MIME_FromFile(fp); 1181 VObject* o = Parse_MIME_FromFile(fp);
1183 fclose(fp); 1182 fclose(fp);
1184 return o; 1183 return o;
1185 } 1184 }
1186 else { 1185 else {
1187 char msg[80]; 1186 char msg[80];
1188 sprintf(msg, "can't open file '%s' for reading\n", fname); 1187 sprintf(msg, "can't open file '%s' for reading\n", fname);
1189 mime_error_(msg); 1188 mime_error_(msg);
1190 return 0; 1189 return 0;
1191 } 1190 }
1192 } 1191 }
1193 1192
1194#endif 1193#endif
1195 1194
1196/*-------------------------------------*/ 1195/*-------------------------------------*/
1197 1196
1198static MimeErrorHandler mimeErrorHandler; 1197static MimeErrorHandler mimeErrorHandler;
1199 1198
1200DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me) 1199DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me)
1201 { 1200 {
1202 mimeErrorHandler = me; 1201 mimeErrorHandler = me;
1203 } 1202 }
1204 1203
1205void mime_error(char *s) 1204void mime_error(char *s)
1206 { 1205 {
1207 char msg[256]; 1206 char msg[256];
1208 if (mimeErrorHandler) { 1207 if (mimeErrorHandler) {
1209 sprintf(msg,"%s at line %d", s, mime_lineNum); 1208 sprintf(msg,"%s at line %d", s, mime_lineNum);
1210 mimeErrorHandler(msg); 1209 mimeErrorHandler(msg);
1211 } 1210 }
1212 } 1211 }
1213 1212
1214void mime_error_(char *s) 1213void mime_error_(char *s)
1215 { 1214 {
1216 if (mimeErrorHandler) { 1215 if (mimeErrorHandler) {
1217 mimeErrorHandler(s); 1216 mimeErrorHandler(s);
1218 } 1217 }
1219 } 1218 }
1220 1219
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp
index 5f53aef..4006bc2 100644
--- a/library/backend/vcc_yacc.cpp
+++ b/library/backend/vcc_yacc.cpp
@@ -1,1597 +1,1596 @@
1#ifndef lint 1#ifndef lint
2 /*static char yysccsid[] = "from: @(#)yaccpar1.9 (Berkeley) 02/21/93";*/ 2 /*static char yysccsid[] = "from: @(#)yaccpar1.9 (Berkeley) 02/21/93";*/
3static char yyrcsid[] = "$Id$"; 3static char yyrcsid[] = "$Id$";
4#endif 4#endif
5#define YYBYACC 1 5#define YYBYACC 1
6#define YYMAJOR 1 6#define YYMAJOR 1
7#define YYMINOR 9 7#define YYMINOR 9
8#define yyclearin (yychar=(-1)) 8#define yyclearin (yychar=(-1))
9#define yyerrok (yyerrflag=0) 9#define yyerrok (yyerrflag=0)
10#define YYRECOVERING (yyerrflag!=0) 10#define YYRECOVERING (yyerrflag!=0)
11#define yyparse vccparse 11#define yyparse vccparse
12#define yylex vcclex 12#define yylex vcclex
13#define yyerror vccerror 13#define yyerror vccerror
14#define yychar vccchar 14#define yychar vccchar
15#define yyval vccval 15#define yyval vccval
16#define yylval vcclval 16#define yylval vcclval
17#define yydebug vccdebug 17#define yydebug vccdebug
18#define yynerrs vccnerrs 18#define yynerrs vccnerrs
19#define yyerrflag vccerrflag 19#define yyerrflag vccerrflag
20#define yyss vccss 20#define yyss vccss
21#define yyssp vccssp 21#define yyssp vccssp
22#define yyvs vccvs 22#define yyvs vccvs
23#define yyvsp vccvsp 23#define yyvsp vccvsp
24#define yylhs vcclhs 24#define yylhs vcclhs
25#define yylen vcclen 25#define yylen vcclen
26#define yydefred vccdefred 26#define yydefred vccdefred
27#define yydgoto vccdgoto 27#define yydgoto vccdgoto
28#define yysindex vccsindex 28#define yysindex vccsindex
29#define yyrindex vccrindex 29#define yyrindex vccrindex
30#define yygindex vccgindex 30#define yygindex vccgindex
31#define yytable vcctable 31#define yytable vcctable
32#define yycheck vcccheck 32#define yycheck vcccheck
33#define yyname vccname 33#define yyname vccname
34#define yyrule vccrule 34#define yyrule vccrule
35#define YYPREFIX "vcc" 35#define YYPREFIX "vcc"
36#line 1 "backend/vcc.y" 36#line 1 "backend/vcc.y"
37 37
38 38
39/*************************************************************************** 39/***************************************************************************
40(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International 40(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
41Business Machines Corporation and Siemens Rolm Communications Inc. 41Business Machines Corporation and Siemens Rolm Communications Inc.
42 42
43For purposes of this license notice, the term Licensors shall mean, 43For purposes of this license notice, the term Licensors shall mean,
44collectively, Apple Computer, Inc., AT&T Corp., International 44collectively, Apple Computer, Inc., AT&T Corp., International
45Business Machines Corporation and Siemens Rolm Communications Inc. 45Business Machines Corporation and Siemens Rolm Communications Inc.
46The term Licensor shall mean any of the Licensors. 46The term Licensor shall mean any of the Licensors.
47 47
48Subject to acceptance of the following conditions, permission is hereby 48Subject to acceptance of the following conditions, permission is hereby
49granted by Licensors without the need for written agreement and without 49granted by Licensors without the need for written agreement and without
50license or royalty fees, to use, copy, modify and distribute this 50license or royalty fees, to use, copy, modify and distribute this
51software for any purpose. 51software for any purpose.
52 52
53The above copyright notice and the following four paragraphs must be 53The above copyright notice and the following four paragraphs must be
54reproduced in all copies of this software and any software including 54reproduced in all copies of this software and any software including
55this software. 55this software.
56 56
57THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE 57THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
58ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR 58ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
59MODIFICATIONS. 59MODIFICATIONS.
60 60
61IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, 61IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
62INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT 62INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
63OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 63OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
64DAMAGE. 64DAMAGE.
65 65
66EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, 66EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
67INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE 67INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
68IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 68IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
69PURPOSE. 69PURPOSE.
70 70
71The software is provided with RESTRICTED RIGHTS. Use, duplication, or 71The software is provided with RESTRICTED RIGHTS. Use, duplication, or
72disclosure by the government are subject to restrictions set forth in 72disclosure by the government are subject to restrictions set forth in
73DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. 73DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
74 74
75***************************************************************************/ 75***************************************************************************/
76 76
77/* 77/*
78 * src: vcc.c 78 * src: vcc.c
79 * doc: Parser for vCard and vCalendar. Note that this code is 79 * doc: Parser for vCard and vCalendar. Note that this code is
80 * generated by a yacc parser generator. Generally it should not 80 * generated by a yacc parser generator. Generally it should not
81 * be edited by hand. The real source is vcc.y. The #line directives 81 * be edited by hand. The real source is vcc.y. The #line directives
82 * can be commented out here to make it easier to trace through 82 * can be commented out here to make it easier to trace through
83 * in a debugger. However, if a bug is found it should 83 * in a debugger. However, if a bug is found it should
84 * be fixed in vcc.y and this file regenerated. 84 * be fixed in vcc.y and this file regenerated.
85 */ 85 */
86 86
87 87
88/* debugging utilities */ 88/* debugging utilities */
89#if __DEBUG 89#if __DEBUG
90#define DBG_(x) printf x 90#define DBG_(x) printf x
91#else 91#else
92#define DBG_(x) 92#define DBG_(x)
93#endif 93#endif
94 94
95/**** External Functions ****/ 95/**** External Functions ****/
96 96
97/* assign local name to parser variables and functions so that 97/* assign local name to parser variables and functions so that
98 we can use more than one yacc based parser. 98 we can use more than one yacc based parser.
99*/ 99*/
100 100
101#if 0 101#if 0
102#define yyparse mime_parse 102#define yyparse mime_parse
103#define yylex mime_lex 103#define yylex mime_lex
104#define yyerror mime_error 104#define yyerror mime_error
105#define yychar mime_char 105#define yychar mime_char
106/* #define p_yyval p_mime_val */ 106/* #define p_yyval p_mime_val */
107#undef yyval 107#undef yyval
108#define yyval mime_yyval 108#define yyval mime_yyval
109/* #define p_yylval p_mime_lval */ 109/* #define p_yylval p_mime_lval */
110#undef yylval 110#undef yylval
111#define yylval mime_yylval 111#define yylval mime_yylval
112#define yydebug mime_debug 112#define yydebug mime_debug
113#define yynerrs mime_nerrs 113#define yynerrs mime_nerrs
114#define yyerrflag mime_errflag 114#define yyerrflag mime_errflag
115#define yyss mime_ss 115#define yyss mime_ss
116#define yyssp mime_ssp 116#define yyssp mime_ssp
117#define yyvs mime_vs 117#define yyvs mime_vs
118#define yyvsp mime_vsp 118#define yyvsp mime_vsp
119#define yylhs mime_lhs 119#define yylhs mime_lhs
120#define yylen mime_len 120#define yylen mime_len
121#define yydefred mime_defred 121#define yydefred mime_defred
122#define yydgoto mime_dgoto 122#define yydgoto mime_dgoto
123#define yysindex mime_sindex 123#define yysindex mime_sindex
124#define yyrindex mime_rindex 124#define yyrindex mime_rindex
125#define yygindex mime_gindex 125#define yygindex mime_gindex
126#define yytable mime_table 126#define yytable mime_table
127#define yycheck mime_check 127#define yycheck mime_check
128#define yyname mime_name 128#define yyname mime_name
129#define yyrule mime_rule 129#define yyrule mime_rule
130#ifdef YYPREFIX 130#ifdef YYPREFIX
131#undef YYPREFIX 131#undef YYPREFIX
132#endif 132#endif
133#define YYPREFIX "mime_" 133#define YYPREFIX "mime_"
134#endif 134#endif
135 135
136 136
137#ifndef _NO_LINE_FOLDING 137#ifndef _NO_LINE_FOLDING
138#define _SUPPORT_LINE_FOLDING 1 138#define _SUPPORT_LINE_FOLDING 1
139#endif 139#endif
140 140
141/* undef below if compile with MFC */ 141/* undef below if compile with MFC */
142/* #define INCLUDEMFC 1 */ 142/* #define INCLUDEMFC 1 */
143 143
144#if defined(WIN32) || defined(_WIN32) 144#if defined(WIN32) || defined(_WIN32)
145#ifdef INCLUDEMFC 145#ifdef INCLUDEMFC
146#include <afx.h> 146#include <afx.h>
147#endif 147#endif
148#endif 148#endif
149 149
150#include <string.h> 150#include <string.h>
151#ifndef __MWERKS__ 151#ifndef __MWERKS__
152#include <stdlib.h> 152#include <stdlib.h>
153#endif 153#endif
154#include <stdio.h> 154#include <stdio.h>
155#include <stdlib.h> 155#include <stdlib.h>
156#include <ctype.h> 156#include <ctype.h>
157 157
158/*#ifdef PALMTOPCENTER */ 158/*#ifdef PALMTOPCENTER */
159/*#include <qpe/vobject_p.h> */ 159/*#include <qpe/vobject_p.h> */
160/*#else */ 160/*#else */
161#include "vobject_p.h" 161#include "vobject_p.h"
162/*#endif */ 162/*#endif */
163 163
164/**** Types, Constants ****/ 164/**** Types, Constants ****/
165 165
166 #define YYDEBUG 0/* 1 to compile in some debugging code */ 166 #define YYDEBUG 0/* 1 to compile in some debugging code */
167 #define MAXTOKEN 256/* maximum token (line) length */ 167 #define MAXTOKEN 256/* maximum token (line) length */
168 #define YYSTACKSIZE 100/* ~unref ? */ 168 #define YYSTACKSIZE 100/* ~unref ? */
169 #define MAXLEVEL 10/* max # of nested objects parseable */ 169 #define MAXLEVEL 10/* max # of nested objects parseable */
170 /* (includes outermost) */ 170 /* (includes outermost) */
171 171
172 172
173/**** Global Variables ****/ 173/**** Global Variables ****/
174int mime_lineNum, mime_numErrors; /* yyerror() can use these */ 174int mime_lineNum, mime_numErrors; /* yyerror() can use these */
175static VObject* vObjList; 175static VObject* vObjList;
176static VObject *curProp; 176static VObject *curProp;
177static VObject *curObj; 177static VObject *curObj;
178static VObject* ObjStack[MAXLEVEL]; 178static VObject* ObjStack[MAXLEVEL];
179static int ObjStackTop; 179static int ObjStackTop;
180 180
181 181
182/* A helpful utility for the rest of the app. */ 182/* A helpful utility for the rest of the app. */
183#if __CPLUSPLUS__ 183#if __CPLUSPLUS__
184extern "C" { 184extern "C" {
185#endif 185#endif
186 186
187 extern void yyerror(char *s); 187 extern void yyerror(char *s);
188 188
189#if __CPLUSPLUS__ 189#if __CPLUSPLUS__
190 }; 190 };
191#endif 191#endif
192 192
193int yyparse(); 193int yyparse();
194 194
195enum LexMode { 195enum LexMode {
196 L_NORMAL, 196 L_NORMAL,
197 L_VCARD, 197 L_VCARD,
198 L_VCAL, 198 L_VCAL,
199 L_VEVENT, 199 L_VEVENT,
200 L_VTODO, 200 L_VTODO,
201 L_VALUES, 201 L_VALUES,
202 L_BASE64, 202 L_BASE64,
203 L_QUOTED_PRINTABLE 203 L_QUOTED_PRINTABLE
204 }; 204 };
205 205
206/**** Private Forward Declarations ****/ 206/**** Private Forward Declarations ****/
207static int pushVObject(const char *prop); 207static int pushVObject(const char *prop);
208static VObject* popVObject(); 208static VObject* popVObject();
209static void lexPopMode(int top); 209static void lexPopMode(int top);
210static int lexWithinMode(enum LexMode mode); 210static int lexWithinMode(enum LexMode mode);
211static void lexPushMode(enum LexMode mode); 211static void lexPushMode(enum LexMode mode);
212static void enterProps(const char *s); 212static void enterProps(const char *s);
213static void enterAttr(const char *s1, const char *s2); 213static void enterAttr(const char *s1, const char *s2);
214static void enterValues(const char *value); 214static void enterValues(const char *value);
215#define mime_error yyerror 215#define mime_error yyerror
216void mime_error(char *s); 216void mime_error(char *s);
217void mime_error_(char *s); 217void mime_error_(char *s);
218 218
219#line 189 "backend/vcc.y" 219#line 189 "backend/vcc.y"
220typedef union { 220typedef union {
221 char *str; 221 char *str;
222 VObject *vobj; 222 VObject *vobj;
223 } YYSTYPE; 223 } YYSTYPE;
224#line 225 "y.tab.c" 224#line 225 "y.tab.c"
225#define EQ 257 225#define EQ 257
226#define COLON 258 226#define COLON 258
227#define DOT 259 227#define DOT 259
228#define SEMICOLON 260 228#define SEMICOLON 260
229#define SPACE 261 229#define SPACE 261
230#define HTAB 262 230#define HTAB 262
231#define LINESEP 263 231#define LINESEP 263
232#define NEWLINE 264 232#define NEWLINE 264
233#define BEGIN_VCARD 265 233#define BEGIN_VCARD 265
234#define END_VCARD 266 234#define END_VCARD 266
235#define BEGIN_VCAL 267 235#define BEGIN_VCAL 267
236#define END_VCAL 268 236#define END_VCAL 268
237#define BEGIN_VEVENT 269 237#define BEGIN_VEVENT 269
238#define END_VEVENT 270 238#define END_VEVENT 270
239#define BEGIN_VTODO 271 239#define BEGIN_VTODO 271
240#define END_VTODO 272 240#define END_VTODO 272
241#define ID 273 241#define ID 273
242#define STRING 274 242#define STRING 274
243#define YYERRCODE 256 243#define YYERRCODE 256
244short vcclhs[] = { -1, 244short vcclhs[] = { -1,
245 0, 6, 6, 5, 5, 8, 3, 9, 3, 7, 245 0, 6, 6, 5, 5, 8, 3, 9, 3, 7,
246 7, 13, 10, 10, 15, 11, 11, 14, 14, 16, 246 7, 13, 10, 10, 15, 11, 11, 14, 14, 16,
247 17, 17, 1, 18, 12, 12, 2, 2, 20, 4, 247 17, 17, 1, 18, 12, 12, 2, 2, 20, 4,
248 21, 4, 19, 19, 22, 22, 22, 25, 23, 26, 248 21, 4, 19, 19, 22, 22, 22, 25, 23, 26,
249 23, 27, 24, 28, 24, 249 23, 27, 24, 28, 24,
250}; 250};
251short vcclen[] = { 2, 251short vcclen[] = { 2,
252 1, 2, 1, 1, 1, 0, 4, 0, 3, 2, 252 1, 2, 1, 1, 1, 0, 4, 0, 3, 2,
253 1, 0, 5, 1, 0, 3, 1, 2, 1, 2, 253 1, 0, 5, 1, 0, 3, 1, 2, 1, 2,
254 1, 3, 1, 0, 4, 1, 1, 0, 0, 4, 254 1, 3, 1, 0, 4, 1, 1, 0, 0, 4,
255 0, 3, 2, 1, 1, 1, 1, 0, 4, 0, 255 0, 3, 2, 1, 1, 1, 1, 0, 4, 0,
256 3, 0, 4, 0, 3, 256 3, 0, 4, 0, 3,
257}; 257};
258short vccdefred[] = { 0, 258short vccdefred[] = { 0,
259 0, 0, 0, 4, 5, 3, 0, 0, 0, 0, 259 0, 0, 0, 4, 5, 3, 0, 0, 0, 0,
260 0, 2, 14, 23, 0, 0, 11, 0, 9, 0, 260 0, 2, 14, 23, 0, 0, 11, 0, 9, 0,
261 0, 0, 0, 34, 35, 36, 32, 0, 7, 10, 261 0, 0, 0, 34, 35, 36, 32, 0, 7, 10,
262 12, 0, 0, 0, 0, 30, 33, 0, 0, 19, 262 12, 0, 0, 0, 0, 30, 33, 0, 0, 19,
263 0, 0, 41, 0, 45, 0, 20, 18, 27, 0, 263 0, 0, 41, 0, 45, 0, 20, 18, 27, 0,
264 0, 39, 43, 0, 24, 13, 22, 0, 25, 264 0, 39, 43, 0, 24, 13, 22, 0, 25,
265}; 265};
266short vccdgoto[] = { 3, 266short vccdgoto[] = { 3,
267 15, 50, 4, 5, 6, 7, 22, 8, 9, 17, 267 15, 50, 4, 5, 6, 7, 22, 8, 9, 17,
268 18, 51, 41, 39, 28, 40, 47, 58, 23, 10, 268 18, 51, 41, 39, 28, 40, 47, 58, 23, 10,
269 11, 24, 25, 26, 32, 33, 34, 35, 269 11, 24, 25, 26, 32, 33, 34, 35,
270}; 270};
271short vccsindex[] = { -262, 271short vccsindex[] = { -262,
272 0, 0, 0, 0, 0, 0, -262, -252, -219, -249, 272 0, 0, 0, 0, 0, 0, -262, -252, -219, -249,
273 -256, 0, 0, 0, 0, -227, 0, -242, 0, 0, 273 -256, 0, 0, 0, 0, -227, 0, -242, 0, 0,
274 0, -252, -254, 0, 0, 0, 0, -208, 0, 0, 274 0, -252, -254, 0, 0, 0, 0, -208, 0, 0,
275 0, -252, -228, -252, -213, 0, 0, -212, -208, 0, 275 0, -252, -228, -252, -213, 0, 0, -212, -208, 0,
276 -214, -233, 0, -224, 0, -195, 0, 0, 0, -197, 276 -214, -233, 0, -224, 0, -195, 0, 0, 0, -197,
277 -199, 0, 0, -212, 0, 0, 0, -214, 0, 277 -199, 0, 0, -212, 0, 0, 0, -214, 0,
278}; 278};
279short vccrindex[] = { 0, 279short vccrindex[] = { 0,
280 -222, -238, 0, 0, 0, 0, 65, 0, 0, 0, 280 -222, -238, 0, 0, 0, 0, 65, 0, 0, 0,
281 0, 0, 0, 0, -215, 0, 0, 0, 0, -220, 281 0, 0, 0, 0, -215, 0, 0, 0, 0, -220,
282 -218, -260, 0, 0, 0, 0, 0, 0, 0, 0, 282 -218, -260, 0, 0, 0, 0, 0, 0, 0, 0,
283 0, 0, 0, 0, 0, 0, 0, 0, -192, 0, 283 0, 0, 0, 0, 0, 0, 0, 0, -192, 0,
284 -250, 0, 0, 0, 0, -202, 0, 0, 0, -196, 284 -250, 0, 0, 0, 0, -202, 0, 0, 0, -196,
285 0, 0, 0, 0, 0, 0, 0, -250, 0, 285 0, 0, 0, 0, 0, 0, 0, -250, 0,
286}; 286};
287short vccgindex[] = { 0, 287short vccgindex[] = { 0,
288 3, 0, 0, 0, 61, 0, -7, 0, 0, -16, 288 3, 0, 0, 0, 61, 0, -7, 0, 0, -16,
289 0, 11, 0, 0, 0, 31, 0, 0, 0, 0, 289 0, 11, 0, 0, 0, 31, 0, 0, 0, 0,
290 0, 48, 0, 0, 0, 0, 0, 0, 290 0, 48, 0, 0, 0, 0, 0, 0,
291}; 291};
292#define YYTABLESIZE 71 292#define YYTABLESIZE 71
293short vcctable[] = { 30, 293short vcctable[] = { 30,
294 16, 13, 1, 13, 2, 30, 13, 37, 37, 28, 294 16, 13, 1, 13, 2, 30, 13, 37, 37, 28,
295 37, 27, 28, 36, 20, 31, 21, 29, 14, 20, 295 37, 27, 28, 36, 20, 31, 21, 29, 14, 20,
296 14, 21, 13, 14, 42, 30, 44, 30, 13, 31, 296 14, 21, 13, 14, 42, 30, 44, 30, 13, 31,
297 29, 13, 29, 6, 29, 38, 52, 42, 29, 14, 297 29, 13, 29, 6, 29, 38, 52, 42, 29, 14,
298 46, 43, 17, 8, 15, 14, 19, 53, 14, 40, 298 46, 43, 17, 8, 15, 14, 19, 53, 14, 40,
299 6, 38, 38, 44, 42, 21, 57, 21, 45, 49, 299 6, 38, 38, 44, 42, 21, 57, 21, 45, 49,
300 14, 54, 55, 56, 1, 16, 26, 12, 59, 48, 300 14, 54, 55, 56, 1, 16, 26, 12, 59, 48,
301 37, 301 37,
302}; 302};
303short vcccheck[] = { 16, 303short vcccheck[] = { 16,
304 8, 256, 265, 256, 267, 22, 256, 268, 269, 260, 304 8, 256, 265, 256, 267, 22, 256, 268, 269, 260,
305 271, 268, 263, 268, 269, 258, 271, 256, 273, 269, 305 271, 268, 263, 268, 269, 258, 271, 256, 273, 269,
306 273, 271, 256, 273, 32, 42, 34, 44, 256, 268, 306 273, 271, 256, 273, 32, 42, 34, 44, 256, 268,
307 269, 256, 271, 256, 273, 256, 270, 256, 266, 273, 307 269, 256, 271, 256, 273, 256, 270, 256, 266, 273,
308 38, 270, 258, 266, 260, 273, 266, 272, 273, 270, 308 38, 270, 258, 266, 260, 273, 266, 272, 273, 270,
309 273, 260, 273, 272, 273, 258, 54, 260, 272, 274, 309 273, 260, 273, 272, 273, 258, 54, 260, 272, 274,
310 273, 257, 260, 263, 0, 258, 263, 7, 58, 39, 310 273, 257, 260, 263, 0, 258, 263, 7, 58, 39,
311 23, 311 23,
312}; 312};
313#define YYFINAL 3 313#define YYFINAL 3
314#ifndef YYDEBUG 314#ifndef YYDEBUG
315#define YYDEBUG 0 315#define YYDEBUG 0
316#endif 316#endif
317#define YYMAXTOKEN 274 317#define YYMAXTOKEN 274
318#if YYDEBUG 318#if YYDEBUG
319char *vccname[] = { 319char *vccname[] = {
320"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 320"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
3210,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3210,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
3220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
3230,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3230,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
3240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
3250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
3260,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"EQ","COLON","DOT","SEMICOLON", 3260,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"EQ","COLON","DOT","SEMICOLON",
327"SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD","BEGIN_VCAL", 327"SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD","BEGIN_VCAL",
328"END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO","ID","STRING", 328"END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO","ID","STRING",
329}; 329};
330char *vccrule[] = { 330char *vccrule[] = {
331"$accept : mime", 331"$accept : mime",
332"mime : vobjects", 332"mime : vobjects",
333"vobjects : vobjects vobject", 333"vobjects : vobjects vobject",
334"vobjects : vobject", 334"vobjects : vobject",
335"vobject : vcard", 335"vobject : vcard",
336"vobject : vcal", 336"vobject : vcal",
337"$$1 :", 337"$$1 :",
338"vcard : BEGIN_VCARD $$1 items END_VCARD", 338"vcard : BEGIN_VCARD $$1 items END_VCARD",
339"$$2 :", 339"$$2 :",
340"vcard : BEGIN_VCARD $$2 END_VCARD", 340"vcard : BEGIN_VCARD $$2 END_VCARD",
341"items : items item", 341"items : items item",
342"items : item", 342"items : item",
343"$$3 :", 343"$$3 :",
344"item : prop COLON $$3 values LINESEP", 344"item : prop COLON $$3 values LINESEP",
345"item : error", 345"item : error",
346"$$4 :", 346"$$4 :",
347"prop : name $$4 attr_params", 347"prop : name $$4 attr_params",
348"prop : name", 348"prop : name",
349"attr_params : attr_params attr_param", 349"attr_params : attr_params attr_param",
350"attr_params : attr_param", 350"attr_params : attr_param",
351"attr_param : SEMICOLON attr", 351"attr_param : SEMICOLON attr",
352"attr : name", 352"attr : name",
353"attr : name EQ name", 353"attr : name EQ name",
354"name : ID", 354"name : ID",
355"$$5 :", 355"$$5 :",
356"values : value SEMICOLON $$5 values", 356"values : value SEMICOLON $$5 values",
357"values : value", 357"values : value",
358"value : STRING", 358"value : STRING",
359"value :", 359"value :",
360"$$6 :", 360"$$6 :",
361"vcal : BEGIN_VCAL $$6 calitems END_VCAL", 361"vcal : BEGIN_VCAL $$6 calitems END_VCAL",
362"$$7 :", 362"$$7 :",
363"vcal : BEGIN_VCAL $$7 END_VCAL", 363"vcal : BEGIN_VCAL $$7 END_VCAL",
364"calitems : calitems calitem", 364"calitems : calitems calitem",
365"calitems : calitem", 365"calitems : calitem",
366"calitem : eventitem", 366"calitem : eventitem",
367"calitem : todoitem", 367"calitem : todoitem",
368"calitem : items", 368"calitem : items",
369"$$8 :", 369"$$8 :",
370"eventitem : BEGIN_VEVENT $$8 items END_VEVENT", 370"eventitem : BEGIN_VEVENT $$8 items END_VEVENT",
371"$$9 :", 371"$$9 :",
372"eventitem : BEGIN_VEVENT $$9 END_VEVENT", 372"eventitem : BEGIN_VEVENT $$9 END_VEVENT",
373"$$10 :", 373"$$10 :",
374"todoitem : BEGIN_VTODO $$10 items END_VTODO", 374"todoitem : BEGIN_VTODO $$10 items END_VTODO",
375"$$11 :", 375"$$11 :",
376"todoitem : BEGIN_VTODO $$11 END_VTODO", 376"todoitem : BEGIN_VTODO $$11 END_VTODO",
377}; 377};
378#endif 378#endif
379#ifdef YYSTACKSIZE 379#ifdef YYSTACKSIZE
380#undef YYMAXDEPTH 380#undef YYMAXDEPTH
381#define YYMAXDEPTH YYSTACKSIZE 381#define YYMAXDEPTH YYSTACKSIZE
382#else 382#else
383#ifdef YYMAXDEPTH 383#ifdef YYMAXDEPTH
384#define YYSTACKSIZE YYMAXDEPTH 384#define YYSTACKSIZE YYMAXDEPTH
385#else 385#else
386#define YYSTACKSIZE 500 386#define YYSTACKSIZE 500
387#define YYMAXDEPTH 500 387#define YYMAXDEPTH 500
388#endif 388#endif
389#endif 389#endif
390int yydebug; 390int yydebug;
391int yynerrs; 391int yynerrs;
392int yyerrflag; 392int yyerrflag;
393int yychar; 393int yychar;
394short *yyssp; 394short *yyssp;
395YYSTYPE *yyvsp; 395YYSTYPE *yyvsp;
396YYSTYPE yyval; 396YYSTYPE yyval;
397YYSTYPE yylval; 397YYSTYPE yylval;
398short yyss[YYSTACKSIZE]; 398short yyss[YYSTACKSIZE];
399YYSTYPE yyvs[YYSTACKSIZE]; 399YYSTYPE yyvs[YYSTACKSIZE];
400#define yystacksize YYSTACKSIZE 400#define yystacksize YYSTACKSIZE
401#line 382 "backend/vcc.y" 401#line 382 "backend/vcc.y"
402 402
403/*------------------------------------*/ 403/*------------------------------------*/
404static int pushVObject(const char *prop) 404static int pushVObject(const char *prop)
405 { 405 {
406 VObject *newObj; 406 VObject *newObj;
407 if (ObjStackTop == MAXLEVEL) 407 if (ObjStackTop == MAXLEVEL)
408 return FALSE; 408 return FALSE;
409 409
410 ObjStack[++ObjStackTop] = curObj; 410 ObjStack[++ObjStackTop] = curObj;
411 411
412 if (curObj) { 412 if (curObj) {
413 newObj = addProp(curObj,prop); 413 newObj = addProp(curObj,prop);
414 curObj = newObj; 414 curObj = newObj;
415 } 415 }
416 else 416 else
417 curObj = newVObject(prop); 417 curObj = newVObject(prop);
418 418
419 return TRUE; 419 return TRUE;
420 } 420 }
421 421
422 422
423/*---------------------------------------*/ 423/*---------------------------------------*/
424/* This pops the recently built vCard off the stack and returns it. */ 424/* This pops the recently built vCard off the stack and returns it. */
425static VObject* popVObject() 425static VObject* popVObject()
426 { 426 {
427 VObject *oldObj; 427 VObject *oldObj;
428 if (ObjStackTop < 0) { 428 if (ObjStackTop < 0) {
429 yyerror("pop on empty Object Stack\n"); 429 yyerror("pop on empty Object Stack\n");
430 return 0; 430 return 0;
431 } 431 }
432 oldObj = curObj; 432 oldObj = curObj;
433 curObj = ObjStack[ObjStackTop--]; 433 curObj = ObjStack[ObjStackTop--];
434 434
435 return oldObj; 435 return oldObj;
436 } 436 }
437 437
438 438
439static void enterValues(const char *value) 439static void enterValues(const char *value)
440 { 440 {
441 if (fieldedProp && *fieldedProp) { 441 if (fieldedProp && *fieldedProp) {
442 if (value) { 442 if (value) {
443 addPropValue(curProp,*fieldedProp,value); 443 addPropValue(curProp,*fieldedProp,value);
444 } 444 }
445 /* else this field is empty, advance to next field */ 445 /* else this field is empty, advance to next field */
446 fieldedProp++; 446 fieldedProp++;
447 } 447 }
448 else { 448 else {
449 if (value) { 449 if (value) {
450 setVObjectStringZValue_(curProp,strdup( value )); 450 setVObjectStringZValue_(curProp,strdup( value ));
451 } 451 }
452 } 452 }
453 deleteStr(value); 453 deleteStr(value);
454 } 454 }
455 455
456static void enterProps(const char *s) 456static void enterProps(const char *s)
457 { 457 {
458 curProp = addGroup(curObj,s); 458 curProp = addGroup(curObj,s);
459 deleteStr(s); 459 deleteStr(s);
460 } 460 }
461 461
462static void enterAttr(const char *s1, const char *s2) 462static void enterAttr(const char *s1, const char *s2)
463 { 463 {
464 const char *p1, *p2; 464 const char *p1, *p2=0;
465 p1 = lookupProp_(s1); 465 p1 = lookupProp_(s1);
466 if (s2) { 466 if (s2) {
467 VObject *a; 467 VObject *a;
468 p2 = lookupProp_(s2); 468 p2 = lookupProp_(s2);
469 a = addProp(curProp,p1); 469 a = addProp(curProp,p1);
470 setVObjectStringZValue(a,p2); 470 setVObjectStringZValue(a,p2);
471 } 471 }
472 else 472 else
473 addProp(curProp,p1); 473 addProp(curProp,p1);
474 if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0)) 474 if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0))
475 lexPushMode(L_BASE64); 475 lexPushMode(L_BASE64);
476 else if (qstricmp(p1,VCQuotedPrintableProp) == 0 476 else if (qstricmp(p1,VCQuotedPrintableProp) == 0
477 || (s2 && qstricmp(p2,VCQuotedPrintableProp)==0)) 477 || (s2 && qstricmp(p2,VCQuotedPrintableProp)==0))
478 lexPushMode(L_QUOTED_PRINTABLE); 478 lexPushMode(L_QUOTED_PRINTABLE);
479 deleteStr(s1); deleteStr(s2); 479 deleteStr(s1); deleteStr(s2);
480 } 480 }
481 481
482 482
483#define MAX_LEX_LOOKAHEAD_0 32 483#define MAX_LEX_LOOKAHEAD_0 32
484#define MAX_LEX_LOOKAHEAD 64 484#define MAX_LEX_LOOKAHEAD 64
485#define MAX_LEX_MODE_STACK_SIZE 10 485#define MAX_LEX_MODE_STACK_SIZE 10
486#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop]) 486#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop])
487 487
488struct LexBuf { 488struct LexBuf {
489 /* input */ 489 /* input */
490#ifdef INCLUDEMFC 490#ifdef INCLUDEMFC
491 CFile *inputFile; 491 CFile *inputFile;
492#else 492#else
493 FILE *inputFile; 493 FILE *inputFile;
494#endif 494#endif
495 char *inputString; 495 char *inputString;
496 unsigned long curPos; 496 unsigned long curPos;
497 unsigned long inputLen; 497 unsigned long inputLen;
498 /* lookahead buffer */ 498 /* lookahead buffer */
499 /* -- lookahead buffer is short instead of char so that EOF 499 /* -- lookahead buffer is short instead of char so that EOF
500 / can be represented correctly. 500 / can be represented correctly.
501 */ 501 */
502 unsigned long len; 502 unsigned long len;
503 short buf[MAX_LEX_LOOKAHEAD]; 503 short buf[MAX_LEX_LOOKAHEAD];
504 unsigned long getPtr; 504 unsigned long getPtr;
505 /* context stack */ 505 /* context stack */
506 unsigned long lexModeStackTop; 506 unsigned long lexModeStackTop;
507 enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE]; 507 enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE];
508 /* token buffer */ 508 /* token buffer */
509 unsigned long maxToken; 509 unsigned long maxToken;
510 char *strs; 510 char *strs;
511 unsigned long strsLen; 511 unsigned long strsLen;
512 } lexBuf; 512 } lexBuf;
513 513
514static void lexPushMode(enum LexMode mode) 514static void lexPushMode(enum LexMode mode)
515 { 515 {
516 if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1)) 516 if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1))
517 yyerror("lexical context stack overflow"); 517 yyerror("lexical context stack overflow");
518 else { 518 else {
519 lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode; 519 lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode;
520 } 520 }
521 } 521 }
522 522
523static void lexPopMode(int top) 523static void lexPopMode(int top)
524 { 524 {
525 /* special case of pop for ease of error recovery -- this 525 /* special case of pop for ease of error recovery -- this
526 version will never underflow */ 526 version will never underflow */
527 if (top) 527 if (top)
528 lexBuf.lexModeStackTop = 0; 528 lexBuf.lexModeStackTop = 0;
529 else 529 else
530 if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--; 530 if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--;
531 } 531 }
532 532
533static int lexWithinMode(enum LexMode mode) { 533static int lexWithinMode(enum LexMode mode) {
534 unsigned long i; 534 unsigned long i;
535 for (i=0;i<lexBuf.lexModeStackTop;i++) 535 for (i=0;i<lexBuf.lexModeStackTop;i++)
536 if (mode == lexBuf.lexModeStack[i]) return 1; 536 if (mode == lexBuf.lexModeStack[i]) return 1;
537 return 0; 537 return 0;
538 } 538 }
539 539
540static int lexGetc_() 540static int lexGetc_()
541 { 541 {
542 /* get next char from input, no buffering. */ 542 /* get next char from input, no buffering. */
543 if (lexBuf.curPos == lexBuf.inputLen) 543 if (lexBuf.curPos == lexBuf.inputLen)
544 return EOF; 544 return EOF;
545 else if (lexBuf.inputString) 545 else if (lexBuf.inputString)
546 return *(lexBuf.inputString + lexBuf.curPos++); 546 return *(lexBuf.inputString + lexBuf.curPos++);
547 else { 547 else {
548#ifdef INCLUDEMFC 548#ifdef INCLUDEMFC
549 char result; 549 char result;
550 return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF; 550 return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF;
551#else 551#else
552 return fgetc(lexBuf.inputFile); 552 return fgetc(lexBuf.inputFile);
553#endif 553#endif
554 } 554 }
555 } 555 }
556 556
557static int lexGeta() 557static int lexGeta()
558 { 558 {
559 ++lexBuf.len; 559 ++lexBuf.len;
560 return (lexBuf.buf[lexBuf.getPtr] = lexGetc_()); 560 return (lexBuf.buf[lexBuf.getPtr] = lexGetc_());
561 } 561 }
562 562
563static int lexGeta_(int i) 563static int lexGeta_(int i)
564 { 564 {
565 ++lexBuf.len; 565 ++lexBuf.len;
566 return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_()); 566 return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_());
567 } 567 }
568 568
569static void lexSkipLookahead() { 569static void lexSkipLookahead() {
570 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { 570 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
571 /* don't skip EOF. */ 571 /* don't skip EOF. */
572 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; 572 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
573 lexBuf.len--; 573 lexBuf.len--;
574 } 574 }
575 } 575 }
576 576
577static int lexLookahead() { 577static int lexLookahead() {
578 int c = (lexBuf.len)? 578 int c = (lexBuf.len)?
579 lexBuf.buf[lexBuf.getPtr]: 579 lexBuf.buf[lexBuf.getPtr]:
580 lexGeta(); 580 lexGeta();
581 /* do the \r\n -> \n or \r -> \n translation here */ 581 /* do the \r\n -> \n or \r -> \n translation here */
582 if (c == '\r') { 582 if (c == '\r') {
583 int a = (lexBuf.len>1)? 583 int a = (lexBuf.len>1)?
584 lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]: 584 lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]:
585 lexGeta_(1); 585 lexGeta_(1);
586 if (a == '\n') { 586 if (a == '\n') {
587 lexSkipLookahead(); 587 lexSkipLookahead();
588 } 588 }
589 lexBuf.buf[lexBuf.getPtr] = c = '\n'; 589 lexBuf.buf[lexBuf.getPtr] = c = '\n';
590 } 590 }
591 else if (c == '\n') { 591 else if (c == '\n') {
592 int a = (lexBuf.len>1)? 592 int a = (lexBuf.len>1)?
593 lexBuf.buf[lexBuf.getPtr+1]: 593 lexBuf.buf[lexBuf.getPtr+1]:
594 lexGeta_(1); 594 lexGeta_(1);
595 if (a == '\r') { 595 if (a == '\r') {
596 lexSkipLookahead(); 596 lexSkipLookahead();
597 } 597 }
598 lexBuf.buf[lexBuf.getPtr] = '\n'; 598 lexBuf.buf[lexBuf.getPtr] = '\n';
599 } 599 }
600 return c; 600 return c;
601 } 601 }
602 602
603static int lexGetc() { 603static int lexGetc() {
604 int c = lexLookahead(); 604 int c = lexLookahead();
605 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { 605 if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
606 /* EOF will remain in lookahead buffer */ 606 /* EOF will remain in lookahead buffer */
607 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; 607 lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
608 lexBuf.len--; 608 lexBuf.len--;
609 } 609 }
610 return c; 610 return c;
611 } 611 }
612 612
613static void lexSkipLookaheadWord() { 613static void lexSkipLookaheadWord() {
614 if (lexBuf.strsLen <= lexBuf.len) { 614 if (lexBuf.strsLen <= lexBuf.len) {
615 lexBuf.len -= lexBuf.strsLen; 615 lexBuf.len -= lexBuf.strsLen;
616 lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; 616 lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
617 } 617 }
618 } 618 }
619 619
620static void lexClearToken() 620static void lexClearToken()
621 { 621 {
622 lexBuf.strsLen = 0; 622 lexBuf.strsLen = 0;
623 } 623 }
624 624
625static void lexAppendc(int c) 625static void lexAppendc(int c)
626 { 626 {
627 lexBuf.strs[lexBuf.strsLen] = c; 627 lexBuf.strs[lexBuf.strsLen] = c;
628 /* append up to zero termination */ 628 /* append up to zero termination */
629 if (c == 0) return; 629 if (c == 0) return;
630 lexBuf.strsLen++; 630 lexBuf.strsLen++;
631 if (lexBuf.strsLen > lexBuf.maxToken) { 631 if (lexBuf.strsLen > lexBuf.maxToken) {
632 /* double the token string size */ 632 /* double the token string size */
633 lexBuf.maxToken <<= 1; 633 lexBuf.maxToken <<= 1;
634 lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); 634 lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken);
635 } 635 }
636 } 636 }
637 637
638static char* lexStr() { 638static char* lexStr() {
639 return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1); 639 return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1);
640 } 640 }
641 641
642static void lexSkipWhite() { 642static void lexSkipWhite() {
643 int c = lexLookahead(); 643 int c = lexLookahead();
644 while (c == ' ' || c == '\t') { 644 while (c == ' ' || c == '\t') {
645 lexSkipLookahead(); 645 lexSkipLookahead();
646 c = lexLookahead(); 646 c = lexLookahead();
647 } 647 }
648 } 648 }
649 649
650static char* lexGetWord() { 650static char* lexGetWord() {
651 int c; 651 int c;
652 lexSkipWhite(); 652 lexSkipWhite();
653 lexClearToken(); 653 lexClearToken();
654 c = lexLookahead(); 654 c = lexLookahead();
655 while (c != EOF && !strchr("\t\n ;:=",c)) { 655 while (c != EOF && !strchr("\t\n ;:=",c)) {
656 lexAppendc(c); 656 lexAppendc(c);
657 lexSkipLookahead(); 657 lexSkipLookahead();
658 c = lexLookahead(); 658 c = lexLookahead();
659 } 659 }
660 lexAppendc(0); 660 lexAppendc(0);
661 return lexStr(); 661 return lexStr();
662 } 662 }
663 663
664static void lexPushLookaheadc(int c) { 664static void lexPushLookaheadc(int c) {
665 int putptr; 665 int putptr;
666 /* can't putback EOF, because it never leaves lookahead buffer */ 666 /* can't putback EOF, because it never leaves lookahead buffer */
667 if (c == EOF) return; 667 if (c == EOF) return;
668 putptr = (int)lexBuf.getPtr - 1; 668 putptr = (int)lexBuf.getPtr - 1;
669 if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; 669 if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
670 lexBuf.getPtr = putptr; 670 lexBuf.getPtr = putptr;
671 lexBuf.buf[putptr] = c; 671 lexBuf.buf[putptr] = c;
672 lexBuf.len += 1; 672 lexBuf.len += 1;
673 } 673 }
674 674
675static char* lexLookaheadWord() { 675static char* lexLookaheadWord() {
676 /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0 676 /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0
677 / and thing bigger than that will stop the lookahead and return 0; 677 / and thing bigger than that will stop the lookahead and return 0;
678 / leading white spaces are not recoverable. 678 / leading white spaces are not recoverable.
679 */ 679 */
680 int c; 680 int c;
681 int len = 0; 681 int len = 0;
682 int curgetptr = 0; 682 int curgetptr = 0;
683 lexSkipWhite(); 683 lexSkipWhite();
684 lexClearToken(); 684 lexClearToken();
685 curgetptr = (int)lexBuf.getPtr;// remember! 685 curgetptr = (int)lexBuf.getPtr;// remember!
686 while (len < (MAX_LEX_LOOKAHEAD_0)) { 686 while (len < (MAX_LEX_LOOKAHEAD_0)) {
687 c = lexGetc(); 687 c = lexGetc();
688 len++; 688 len++;
689 if (c == EOF || strchr("\t\n ;:=", c)) { 689 if (c == EOF || strchr("\t\n ;:=", c)) {
690 lexAppendc(0); 690 lexAppendc(0);
691 /* restore lookahead buf. */ 691 /* restore lookahead buf. */
692 lexBuf.len += len; 692 lexBuf.len += len;
693 lexBuf.getPtr = curgetptr; 693 lexBuf.getPtr = curgetptr;
694 return lexStr(); 694 return lexStr();
695 } 695 }
696 else 696 else
697 lexAppendc(c); 697 lexAppendc(c);
698 } 698 }
699 lexBuf.len += len;/* char that has been moved to lookahead buffer */ 699 lexBuf.len += len;/* char that has been moved to lookahead buffer */
700 lexBuf.getPtr = curgetptr; 700 lexBuf.getPtr = curgetptr;
701 return 0; 701 return 0;
702 } 702 }
703 703
704#ifdef _SUPPORT_LINE_FOLDING 704#ifdef _SUPPORT_LINE_FOLDING
705static void handleMoreRFC822LineBreak(int c) { 705static void handleMoreRFC822LineBreak(int c) {
706 /* suport RFC 822 line break in cases like 706 /* suport RFC 822 line break in cases like
707 *ADR: foo; 707 *ADR: foo;
708 * morefoo; 708 * morefoo;
709 * more foo; 709 * more foo;
710 */ 710 */
711 if (c == ';') { 711 if (c == ';') {
712 int a; 712 int a;
713 lexSkipLookahead(); 713 lexSkipLookahead();
714 /* skip white spaces */ 714 /* skip white spaces */
715 a = lexLookahead(); 715 a = lexLookahead();
716 while (a == ' ' || a == '\t') { 716 while (a == ' ' || a == '\t') {
717 lexSkipLookahead(); 717 lexSkipLookahead();
718 a = lexLookahead(); 718 a = lexLookahead();
719 } 719 }
720 if (a == '\n') { 720 if (a == '\n') {
721 lexSkipLookahead(); 721 lexSkipLookahead();
722 a = lexLookahead(); 722 a = lexLookahead();
723 if (a == ' ' || a == '\t') { 723 if (a == ' ' || a == '\t') {
724 /* continuation, throw away all the \n and spaces read so 724 /* continuation, throw away all the \n and spaces read so
725 * far 725 * far
726 */ 726 */
727 lexSkipWhite(); 727 lexSkipWhite();
728 lexPushLookaheadc(';'); 728 lexPushLookaheadc(';');
729 } 729 }
730 else { 730 else {
731 lexPushLookaheadc('\n'); 731 lexPushLookaheadc('\n');
732 lexPushLookaheadc(';'); 732 lexPushLookaheadc(';');
733 } 733 }
734 } 734 }
735 else { 735 else {
736 lexPushLookaheadc(';'); 736 lexPushLookaheadc(';');
737 } 737 }
738 } 738 }
739 } 739 }
740 740
741static char* lexGet1Value() { 741static char* lexGet1Value() {
742 int c; 742 int c;
743 lexSkipWhite(); 743 lexSkipWhite();
744 c = lexLookahead(); 744 c = lexLookahead();
745 lexClearToken(); 745 lexClearToken();
746 while (c != EOF && (c != ';' || !fieldedProp)) { 746 while (c != EOF && (c != ';' || !fieldedProp)) {
747 if (c == '\\' ) { 747 if (c == '\\' ) {
748 int a; 748 int a;
749 lexSkipLookahead(); 749 lexSkipLookahead();
750 a = lexLookahead(); 750 a = lexLookahead();
751 if ( a == ';' ) { 751 if ( a == ';' ) {
752 lexAppendc( ';' ); 752 lexAppendc( ';' );
753 lexSkipLookahead(); 753 lexSkipLookahead();
754 } else if ( a == '\n' ) { 754 } else if ( a == '\n' ) {
755 lexAppendc( '\n' ); 755 lexAppendc( '\n' );
756 lexSkipLookahead(); 756 lexSkipLookahead();
757 } else if ( a == '\\' ) { 757 } else if ( a == '\\' ) {
758 lexAppendc( '\\' ); 758 lexAppendc( '\\' );
759 lexSkipLookahead(); 759 lexSkipLookahead();
760 } else { 760 } else {
761 lexAppendc('\\'); 761 lexAppendc('\\');
762 } 762 }
763 } else if (c == '\n') { 763 } else if (c == '\n') {
764 int a; 764 int a;
765 lexSkipLookahead(); 765 lexSkipLookahead();
766 a = lexLookahead(); 766 a = lexLookahead();
767 if (a == ' ' || a == '\t') { 767 if (a == ' ' || a == '\t') {
768 lexAppendc(' '); 768 lexAppendc(' ');
769 lexSkipLookahead(); 769 lexSkipLookahead();
770 } 770 }
771 else { 771 else {
772 lexPushLookaheadc('\n'); 772 lexPushLookaheadc('\n');
773 break; 773 break;
774 } 774 }
775 } 775 }
776 else { 776 else {
777 lexAppendc(c); 777 lexAppendc(c);
778 lexSkipLookahead(); 778 lexSkipLookahead();
779 } 779 }
780 c = lexLookahead(); 780 c = lexLookahead();
781 } 781 }
782 lexAppendc(0); 782 lexAppendc(0);
783 handleMoreRFC822LineBreak(c); 783 handleMoreRFC822LineBreak(c);
784 return c==EOF?0:lexStr(); 784 return c==EOF?0:lexStr();
785 } 785 }
786#endif 786#endif
787 787
788static int match_begin_name(int end) { 788static int match_begin_name(int end) {
789 char *n = lexLookaheadWord(); 789 char *n = lexLookaheadWord();
790 int token = ID; 790 int token = ID;
791 if (n) { 791 if (n) {
792 if (!qstricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD; 792 if (!qstricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
793 else if (!qstricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL; 793 else if (!qstricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
794 else if (!qstricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT; 794 else if (!qstricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
795 else if (!qstricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO; 795 else if (!qstricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
796 deleteStr(n); 796 deleteStr(n);
797 return token; 797 return token;
798 } 798 }
799 return 0; 799 return 0;
800 } 800 }
801 801
802 802
803#ifdef INCLUDEMFC 803#ifdef INCLUDEMFC
804void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) 804void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile)
805#else 805#else
806void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) 806void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
807#endif 807#endif
808 { 808 {
809 // initialize lex mode stack 809 // initialize lex mode stack
810 lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL; 810 lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
811 811
812 // iniatialize lex buffer. 812 // iniatialize lex buffer.
813 lexBuf.inputString = (char*) inputstring; 813 lexBuf.inputString = (char*) inputstring;
814 lexBuf.inputLen = inputlen; 814 lexBuf.inputLen = inputlen;
815 lexBuf.curPos = 0; 815 lexBuf.curPos = 0;
816 lexBuf.inputFile = inputfile; 816 lexBuf.inputFile = inputfile;
817 817
818 lexBuf.len = 0; 818 lexBuf.len = 0;
819 lexBuf.getPtr = 0; 819 lexBuf.getPtr = 0;
820 820
821 lexBuf.maxToken = MAXTOKEN; 821 lexBuf.maxToken = MAXTOKEN;
822 lexBuf.strs = (char*)malloc(MAXTOKEN); 822 lexBuf.strs = (char*)malloc(MAXTOKEN);
823 lexBuf.strsLen = 0; 823 lexBuf.strsLen = 0;
824 824
825 } 825 }
826 826
827static void finiLex() { 827static void finiLex() {
828 free(lexBuf.strs); 828 free(lexBuf.strs);
829 } 829 }
830 830
831 831
832/*-----------------------------------*/ 832/*-----------------------------------*/
833/* This parses and converts the base64 format for binary encoding into 833/* This parses and converts the base64 format for binary encoding into
834 * a decoded buffer (allocated with new). See RFC 1521. 834 * a decoded buffer (allocated with new). See RFC 1521.
835 */ 835 */
836static char * lexGetDataFromBase64() 836static int lexGetDataFromBase64()
837 { 837 {
838 unsigned long bytesLen = 0, bytesMax = 0; 838 unsigned long bytesLen = 0, bytesMax = 0;
839 int quadIx = 0, pad = 0; 839 int quadIx = 0, pad = 0;
840 unsigned long trip = 0; 840 unsigned long trip = 0;
841 unsigned char b; 841 unsigned char b;
842 int c; 842 int c;
843 unsigned char *bytes = NULL; 843 unsigned char *bytes = NULL;
844 unsigned char *oldBytes = NULL; 844 unsigned char *oldBytes = NULL;
845 845
846 DBG_(("db: lexGetDataFromBase64\n")); 846 DBG_(("db: lexGetDataFromBase64\n"));
847 while (1) { 847 while (1) {
848 c = lexGetc(); 848 c = lexGetc();
849 lexSkipWhite();
849 if (c == '\n') { 850 if (c == '\n') {
850 ++mime_lineNum; 851 ++mime_lineNum;
851 if (lexLookahead() == '\n') { 852 if (lexLookahead() == '\n') {
852 /* a '\n' character by itself means end of data */ 853 /* a '\n' character by itself means end of data */
853 break; 854 break;
854 } 855 }
855 else continue; /* ignore '\n' */ 856 else continue; /* ignore '\n' */
856 } 857 }
857 else { 858 else {
858 if ((c >= 'A') && (c <= 'Z')) 859 if ((c >= 'A') && (c <= 'Z'))
859 b = (unsigned char)(c - 'A'); 860 b = (unsigned char)(c - 'A');
860 else if ((c >= 'a') && (c <= 'z')) 861 else if ((c >= 'a') && (c <= 'z'))
861 b = (unsigned char)(c - 'a') + 26; 862 b = (unsigned char)(c - 'a') + 26;
862 else if ((c >= '0') && (c <= '9')) 863 else if ((c >= '0') && (c <= '9'))
863 b = (unsigned char)(c - '0') + 52; 864 b = (unsigned char)(c - '0') + 52;
864 else if (c == '+') 865 else if (c == '+')
865 b = 62; 866 b = 62;
866 else if (c == '/') 867 else if (c == '/')
867 b = 63; 868 b = 63;
868 else if (c == '=') { 869 else if (c == '=') {
869 b = 0; 870 b = 0;
870 pad++; 871 pad++;
871 } else if ((c == ' ') || (c == '\t')) {
872 continue;
873 } else { /* error condition */ 872 } else { /* error condition */
874 if (bytes) free(bytes); 873 if (bytes) free(bytes);
875 else if (oldBytes) free(oldBytes); 874 else if (oldBytes) free(oldBytes);
876 // error recovery: skip until 2 adjacent newlines. 875 // error recovery: skip until 2 adjacent newlines.
877 DBG_(("db: invalid character 0x%x '%c'\n", c,c)); 876 DBG_(("db: invalid character 0x%x '%c'\n", c,c));
878 if (c != EOF) { 877 if (c != EOF) {
879 c = lexGetc(); 878 c = lexGetc();
880 while (c != EOF) { 879 while (c != EOF) {
881 if (c == '\n' && lexLookahead() == '\n') { 880 if (c == '\n') {
882 ++mime_lineNum; 881 lexSkipWhite();
883 break; 882 if(lexLookahead() == '\n') {
883 ++mime_lineNum;
884 break;
885 }
884 } 886 }
885 c = lexGetc(); 887 c = lexGetc();
886 } 888 }
887 } 889 }
888 return NULL; 890 return c != EOF;
889 } 891 }
890 trip = (trip << 6) | b; 892 trip = (trip << 6) | b;
891 if (++quadIx == 4) { 893 if (++quadIx == 4) {
892 unsigned char outBytes[3]; 894 unsigned char outBytes[3];
893 int numOut; 895 int numOut;
894 int i; 896 int i;
895 for (i = 0; i < 3; i++) { 897 for (i = 0; i < 3; i++) {
896 outBytes[2-i] = (unsigned char)(trip & 0xFF); 898 outBytes[2-i] = (unsigned char)(trip & 0xFF);
897 trip >>= 8; 899 trip >>= 8;
898 } 900 }
899 numOut = 3 - pad; 901 numOut = 3 - pad;
900 if (bytesLen + numOut > bytesMax) { 902 if (bytesLen + numOut > bytesMax) {
901 if (!bytes) { 903 if (!bytes) {
902 bytesMax = 1024; 904 bytesMax = 1024;
903 bytes = (unsigned char*)malloc((size_t)bytesMax); 905 bytes = (unsigned char*)malloc((size_t)bytesMax);
904 } 906 }
905 else { 907 else {
906 bytesMax <<= 2; 908 bytesMax <<= 2;
907 oldBytes = bytes; 909 oldBytes = bytes;
908 bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax); 910 bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax);
909 } 911 }
910 if (bytes == 0) { 912 if (bytes == 0) {
911 mime_error("out of memory while processing BASE64 data\n"); 913 mime_error("out of memory while processing BASE64 data\n");
912 } 914 }
913 } 915 }
914 if (bytes) { 916 if (bytes) {
915 memcpy(bytes + bytesLen, outBytes, numOut); 917 memcpy(bytes + bytesLen, outBytes, numOut);
916 bytesLen += numOut; 918 bytesLen += numOut;
917 } 919 }
918 trip = 0; 920 trip = 0;
919 quadIx = 0; 921 quadIx = 0;
920 } 922 }
921 } 923 }
922 } /* while */ 924 } /* while */
923 DBG_(("db: bytesLen = %d\n", bytesLen)); 925 DBG_(("db: bytesLen = %d\n", bytesLen));
924 /* kludge: all this won't be necessary if we have tree form 926 /* kludge: all this won't be necessary if we have tree form
925 representation */ 927 representation */
926 if (bytes) { 928 if (bytes) {
927 setValueWithSize(curProp,bytes,(unsigned int)bytesLen); 929 setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
928 free(bytes); 930 free(bytes);
929 } 931 }
930 else if (oldBytes) { 932 else if (oldBytes) {
931 setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); 933 setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
932 free(oldBytes); 934 free(oldBytes);
933 } 935 }
934 return 0; 936 return bytesLen;
935 } 937 }
936 938
937static int match_begin_end_name(int end) { 939static int match_begin_end_name(int end) {
938 int token; 940 int token;
939 lexSkipWhite(); 941 lexSkipWhite();
940 if (lexLookahead() != ':') return ID; 942 if (lexLookahead() != ':') return ID;
941 lexSkipLookahead(); 943 lexSkipLookahead();
942 lexSkipWhite(); 944 lexSkipWhite();
943 token = match_begin_name(end); 945 token = match_begin_name(end);
944 if (token == ID) { 946 if (token == ID) {
945 lexPushLookaheadc(':'); 947 lexPushLookaheadc(':');
946 DBG_(("db: ID '%s'\n", yylval.str)); 948 DBG_(("db: ID '%s'\n", yylval.str));
947 return ID; 949 return ID;
948 } 950 }
949 else if (token != 0) { 951 else if (token != 0) {
950 lexSkipLookaheadWord(); 952 lexSkipLookaheadWord();
951 deleteStr(yylval.str); 953 deleteStr(yylval.str);
952 DBG_(("db: begin/end %d\n", token)); 954 DBG_(("db: begin/end %d\n", token));
953 return token; 955 return token;
954 } 956 }
955 return 0; 957 return 0;
956 } 958 }
957 959
958static char* lexGetQuotedPrintable() 960static char* lexGetQuotedPrintable()
959{ 961{
960 int c; 962 int c;
961 lexSkipWhite(); 963 lexSkipWhite();
962 c = lexLookahead(); 964 c = lexLookahead();
963 lexClearToken(); 965 lexClearToken();
964 966
965 while (c != EOF && c != ';') { 967 while (c != EOF && (c != ';' || !fieldedProp)) {
966 if (c == '\n') { 968 if (c == '\n') {
967 // break, leave '\n' on remaining chars. 969 // break, leave '\n' on remaining chars.
968 break; 970 break;
969 } else if (c == '=') { 971 } else if (c == '=') {
970 int cur = 0; 972 int cur = 0;
971 int next; 973 int next;
972 974
973 lexSkipLookahead(); // skip '=' 975 lexSkipLookahead(); // skip '='
974 next = lexLookahead(); 976 next = lexLookahead();
975 977
976 if (next == '\n') { 978 if (next == '\n') {
977 // skip and only skip the \n 979 // skip and only skip the \n
978 lexSkipLookahead(); 980 lexSkipLookahead();
979 c = lexLookahead(); 981 c = lexLookahead();
980 ++mime_lineNum; // aid in error reporting 982 ++mime_lineNum; // aid in error reporting
981 continue; 983 continue;
982 } else if (next >= '0' && next <= '9') { 984 } else if (next >= '0' && next <= '9') {
983 cur = next - '0'; 985 cur = next - '0';
984 } else if (next >= 'A' && next <= 'F') { 986 } else if (next >= 'A' && next <= 'F') {
985 cur = next - 'A' + 10; 987 cur = next - 'A' + 10;
986 } else { 988 } else {
987 // we have been sent buggy stuff. doesn't matter 989 // we have been sent buggy stuff. doesn't matter
988 // what we do so long as we keep going. 990 // what we do so long as we keep going.
989 // should probably spit an error here 991 // should probably spit an error here
990 lexSkipLookahead(); 992 lexSkipLookahead();
991 c = lexLookahead(); 993 c = lexLookahead();
992 continue; 994 continue;
993 } 995 }
994 996
995 lexSkipLookahead(); // skip A-Z0-9 997 lexSkipLookahead(); // skip A-Z0-9
996 next = lexLookahead(); 998 next = lexLookahead();
997 999
998 cur = cur * 16; 1000 cur = cur * 16;
999 // this time really just expecting 0-9A-F 1001 // this time really just expecting 0-9A-F
1000 if (next >= '0' && next <= '9') { 1002 if (next >= '0' && next <= '9') {
1001 cur += next - '0'; 1003 cur += next - '0';
1002 } else if (next >= 'A' && next <= 'F') { 1004 } else if (next >= 'A' && next <= 'F') {
1003 cur += next - 'A' + 10; 1005 cur += next - 'A' + 10;
1004 } else { 1006 } else {
1005 // we have been sent buggy stuff. doesn't matter 1007 // we have been sent buggy stuff. doesn't matter
1006 // what we do so long as we keep going. 1008 // what we do so long as we keep going.
1007 // should probably spit an error here 1009 // should probably spit an error here
1008 lexSkipLookahead(); 1010 lexSkipLookahead();
1009 c = lexLookahead(); 1011 c = lexLookahead();
1010 continue; 1012 continue;
1011 } 1013 }
1012 1014
1013 // got a valid escaped =. append it. 1015 // got a valid escaped =. append it.
1014 lexSkipLookahead(); // skip second 0-9A-F 1016 lexSkipLookahead(); // skip second 0-9A-F
1015 lexAppendc(cur); 1017 lexAppendc(cur);
1016 } else { 1018 } else {
1017 lexSkipLookahead(); // skip whatever we just read. 1019 lexSkipLookahead(); // skip whatever we just read.
1018 lexAppendc(c); // and append it. 1020 lexAppendc(c); // and append it.
1019 } 1021 }
1020 c = lexLookahead(); 1022 c = lexLookahead();
1021 } 1023 }
1022 lexAppendc(0); 1024 lexAppendc(0);
1023 return c==EOF?0:lexStr(); 1025 return c==EOF?0:lexStr();
1024} 1026}
1025 1027
1026static int yylex() { 1028static int yylex() {
1027 1029
1028 int lexmode = LEXMODE(); 1030 int lexmode = LEXMODE();
1029 if (lexmode == L_VALUES) { 1031 if (lexmode == L_VALUES) {
1030 int c = lexGetc(); 1032 int c = lexGetc();
1031 if (c == ';' && fieldedProp) { 1033 if (c == ';' && fieldedProp) {
1032 DBG_(("db: SEMICOLON\n")); 1034 DBG_(("db: SEMICOLON\n"));
1033 lexPushLookaheadc(c); 1035 lexPushLookaheadc(c);
1034 handleMoreRFC822LineBreak(c); 1036 handleMoreRFC822LineBreak(c);
1035 lexSkipLookahead(); 1037 lexSkipLookahead();
1036 return SEMICOLON; 1038 return SEMICOLON;
1037 } 1039 }
1038 else if (strchr("\n",c)) { 1040 else if (strchr("\n",c)) {
1039 ++mime_lineNum; 1041 ++mime_lineNum;
1040 /* consume all line separator(s) adjacent to each other */ 1042 /* consume all line separator(s) adjacent to each other */
1041 c = lexLookahead(); 1043 c = lexLookahead();
1042 while (strchr("\n",c)) { 1044 while (strchr("\n",c)) {
1043 lexSkipLookahead(); 1045 lexSkipLookahead();
1044 c = lexLookahead(); 1046 c = lexLookahead();
1045 ++mime_lineNum; 1047 ++mime_lineNum;
1046 } 1048 }
1047 DBG_(("db: LINESEP\n")); 1049 DBG_(("db: LINESEP\n"));
1048 return LINESEP; 1050 return LINESEP;
1049 } 1051 }
1050 else { 1052 else {
1051 char *p = 0; 1053 char *p = 0;
1052 lexPushLookaheadc(c); 1054 lexPushLookaheadc(c);
1053 if (lexWithinMode(L_BASE64)) { 1055 if (lexWithinMode(L_BASE64)) {
1054 /* get each char and convert to bin on the fly... */ 1056 /* get each char and convert to bin on the fly... */
1055 p = lexGetDataFromBase64(); 1057 yylval.str = NULL;
1056#if 0 1058 return lexGetDataFromBase64() ? STRING : 0;
1057 yylval.str = p;
1058 return STRING;
1059 #endif
1060 } 1059 }
1061 else if (lexWithinMode(L_QUOTED_PRINTABLE)) { 1060 else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
1062 p = lexGetQuotedPrintable(); 1061 p = lexGetQuotedPrintable();
1063 } 1062 }
1064 else { 1063 else {
1065#ifdef _SUPPORT_LINE_FOLDING 1064#ifdef _SUPPORT_LINE_FOLDING
1066 p = lexGet1Value(); 1065 p = lexGet1Value();
1067#else 1066#else
1068 p = lexGetStrUntil(";\n"); 1067 p = lexGetStrUntil(";\n");
1069#endif 1068#endif
1070 } 1069 }
1071 if (p) { 1070 if (p) {
1072 DBG_(("db: STRING: '%s'\n", p)); 1071 DBG_(("db: STRING: '%s'\n", p));
1073 yylval.str = p; 1072 yylval.str = p;
1074 return STRING; 1073 return STRING;
1075 } 1074 }
1076 else return 0; 1075 else return 0;
1077 } 1076 }
1078 } 1077 }
1079 else { 1078 else {
1080 /* normal mode */ 1079 /* normal mode */
1081 while (1) { 1080 while (1) {
1082 int c = lexGetc(); 1081 int c = lexGetc();
1083 switch(c) { 1082 switch(c) {
1084 case ':': { 1083 case ':': {
1085 /* consume all line separator(s) adjacent to each other */ 1084 /* consume all line separator(s) adjacent to each other */
1086 /* ignoring linesep immediately after colon. */ 1085 /* ignoring linesep immediately after colon. */
1087 /* I don't see this in the spec, and it breaks null values -- WA 1086 /* I don't see this in the spec, and it breaks null values -- WA
1088 c = lexLookahead(); 1087 c = lexLookahead();
1089 while (strchr("\n",c)) { 1088 while (strchr("\n",c)) {
1090 lexSkipLookahead(); 1089 lexSkipLookahead();
1091 c = lexLookahead(); 1090 c = lexLookahead();
1092 ++mime_lineNum; 1091 ++mime_lineNum;
1093 } 1092 }
1094 */ 1093 */
1095 DBG_(("db: COLON\n")); 1094 DBG_(("db: COLON\n"));
1096 return COLON; 1095 return COLON;
1097 } 1096 }
1098 case ';': 1097 case ';':
1099 DBG_(("db: SEMICOLON\n")); 1098 DBG_(("db: SEMICOLON\n"));
1100 return SEMICOLON; 1099 return SEMICOLON;
1101 case '=': 1100 case '=':
1102 DBG_(("db: EQ\n")); 1101 DBG_(("db: EQ\n"));
1103 return EQ; 1102 return EQ;
1104 /* ignore whitespace in this mode */ 1103 /* ignore whitespace in this mode */
1105 case '\t': 1104 case '\t':
1106 case ' ': continue; 1105 case ' ': continue;
1107 case '\n': { 1106 case '\n': {
1108 ++mime_lineNum; 1107 ++mime_lineNum;
1109 continue; 1108 continue;
1110 } 1109 }
1111 case EOF: return 0; 1110 case EOF: return 0;
1112 break; 1111 break;
1113 default: { 1112 default: {
1114 lexPushLookaheadc(c); 1113 lexPushLookaheadc(c);
1115 if (isalnum(c)) { 1114 if (isalnum(c)) {
1116 char *t = lexGetWord(); 1115 char *t = lexGetWord();
1117 yylval.str = t; 1116 yylval.str = t;
1118 if (!qstricmp(t, "begin")) { 1117 if (!qstricmp(t, "begin")) {
1119 return match_begin_end_name(0); 1118 return match_begin_end_name(0);
1120 } 1119 }
1121 else if (!qstricmp(t,"end")) { 1120 else if (!qstricmp(t,"end")) {
1122 return match_begin_end_name(1); 1121 return match_begin_end_name(1);
1123 } 1122 }
1124 else { 1123 else {
1125 DBG_(("db: ID '%s'\n", t)); 1124 DBG_(("db: ID '%s'\n", t));
1126 return ID; 1125 return ID;
1127 } 1126 }
1128 } 1127 }
1129 else { 1128 else {
1130 /* unknow token */ 1129 /* unknow token */
1131 return 0; 1130 return 0;
1132 } 1131 }
1133 break; 1132 break;
1134 } 1133 }
1135 } 1134 }
1136 } 1135 }
1137 } 1136 }
1138 return 0; 1137 return 0;
1139 } 1138 }
1140 1139
1141 1140
1142/***************************************************************************/ 1141/***************************************************************************/
1143 /*** Public Functions ****/ 1142 /*** Public Functions ****/
1144/***************************************************************************/ 1143/***************************************************************************/
1145 1144
1146static VObject* Parse_MIMEHelper() 1145static VObject* Parse_MIMEHelper()
1147 { 1146 {
1148 ObjStackTop = -1; 1147 ObjStackTop = -1;
1149 mime_numErrors = 0; 1148 mime_numErrors = 0;
1150 mime_lineNum = 1; 1149 mime_lineNum = 1;
1151 vObjList = 0; 1150 vObjList = 0;
1152 curObj = 0; 1151 curObj = 0;
1153 1152
1154 if (yyparse() != 0) 1153 if (yyparse() != 0)
1155 return 0; 1154 return 0;
1156 1155
1157 finiLex(); 1156 finiLex();
1158 return vObjList; 1157 return vObjList;
1159 } 1158 }
1160 1159
1161/*--------------------------------------------*/ 1160/*--------------------------------------------*/
1162DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len) 1161DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len)
1163 { 1162 {
1164 initLex(input, len, 0); 1163 initLex(input, len, 0);
1165 return Parse_MIMEHelper(); 1164 return Parse_MIMEHelper();
1166 } 1165 }
1167 1166
1168 1167
1169#if INCLUDEMFC 1168#if INCLUDEMFC
1170 1169
1171DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file) 1170DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
1172 { 1171 {
1173 unsigned long startPos; 1172 unsigned long startPos;
1174 VObject *result; 1173 VObject *result;
1175 1174
1176 initLex(0,-1,file); 1175 initLex(0,-1,file);
1177 startPos = file->GetPosition(); 1176 startPos = file->GetPosition();
1178 if (!(result = Parse_MIMEHelper())) 1177 if (!(result = Parse_MIMEHelper()))
1179 file->Seek(startPos, CFile::begin); 1178 file->Seek(startPos, CFile::begin);
1180 return result; 1179 return result;
1181 } 1180 }
1182 1181
1183#else 1182#else
1184 1183
1185VObject* Parse_MIME_FromFile(FILE *file) 1184VObject* Parse_MIME_FromFile(FILE *file)
1186 { 1185 {
1187 VObject *result; 1186 VObject *result;
1188 long startPos; 1187 long startPos;
1189 1188
1190 initLex(0,(unsigned long)-1,file); 1189 initLex(0,(unsigned long)-1,file);
1191 startPos = ftell(file); 1190 startPos = ftell(file);
1192 if (!(result = Parse_MIMEHelper())) { 1191 if (!(result = Parse_MIMEHelper())) {
1193 fseek(file,startPos,SEEK_SET); 1192 fseek(file,startPos,SEEK_SET);
1194 } 1193 }
1195 return result; 1194 return result;
1196 } 1195 }
1197 1196
1198DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname) 1197DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
1199 { 1198 {
1200 FILE *fp = fopen(fname,"r"); 1199 FILE *fp = fopen(fname,"r");
1201 if (fp) { 1200 if (fp) {
1202 VObject* o = Parse_MIME_FromFile(fp); 1201 VObject* o = Parse_MIME_FromFile(fp);
1203 fclose(fp); 1202 fclose(fp);
1204 return o; 1203 return o;
1205 } 1204 }
1206 else { 1205 else {
1207 char msg[80]; 1206 char msg[80];
1208 sprintf(msg, "can't open file '%s' for reading\n", fname); 1207 sprintf(msg, "can't open file '%s' for reading\n", fname);
1209 mime_error_(msg); 1208 mime_error_(msg);
1210 return 0; 1209 return 0;
1211 } 1210 }
1212 } 1211 }
1213 1212
1214#endif 1213#endif
1215 1214
1216/*-------------------------------------*/ 1215/*-------------------------------------*/
1217 1216
1218static MimeErrorHandler mimeErrorHandler; 1217static MimeErrorHandler mimeErrorHandler;
1219 1218
1220DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me) 1219DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me)
1221 { 1220 {
1222 mimeErrorHandler = me; 1221 mimeErrorHandler = me;
1223 } 1222 }
1224 1223
1225void mime_error(char *s) 1224void mime_error(char *s)
1226 { 1225 {
1227 char msg[256]; 1226 char msg[256];
1228 if (mimeErrorHandler) { 1227 if (mimeErrorHandler) {
1229 sprintf(msg,"%s at line %d", s, mime_lineNum); 1228 sprintf(msg,"%s at line %d", s, mime_lineNum);
1230 mimeErrorHandler(msg); 1229 mimeErrorHandler(msg);
1231 } 1230 }
1232 } 1231 }
1233 1232
1234void mime_error_(char *s) 1233void mime_error_(char *s)
1235 { 1234 {
1236 if (mimeErrorHandler) { 1235 if (mimeErrorHandler) {
1237 mimeErrorHandler(s); 1236 mimeErrorHandler(s);
1238 } 1237 }
1239 } 1238 }
1240 1239
1241#line 1240 "y.tab.c" 1240#line 1241 "y.tab.c"
1242#define YYABORT goto yyabort 1241#define YYABORT goto yyabort
1243#define YYREJECT goto yyabort 1242#define YYREJECT goto yyabort
1244#define YYACCEPT goto yyaccept 1243#define YYACCEPT goto yyaccept
1245#define YYERROR goto yyerrlab 1244#define YYERROR goto yyerrlab
1246int 1245int
1247#if defined(__STDC__) 1246#if defined(__STDC__)
1248yyparse(void) 1247yyparse(void)
1249#else 1248#else
1250yyparse() 1249yyparse()
1251#endif 1250#endif
1252{ 1251{
1253 register int yym, yyn, yystate; 1252 register int yym, yyn, yystate;
1254#if YYDEBUG 1253#if YYDEBUG
1255 register char *yys; 1254 register char *yys;
1256 extern char *getenv(); 1255 extern char *getenv();
1257 1256
1258 if (yys = getenv("YYDEBUG")) 1257 if (yys = getenv("YYDEBUG"))
1259 { 1258 {
1260 yyn = *yys; 1259 yyn = *yys;
1261 if (yyn >= '0' && yyn <= '9') 1260 if (yyn >= '0' && yyn <= '9')
1262 yydebug = yyn - '0'; 1261 yydebug = yyn - '0';
1263 } 1262 }
1264#endif 1263#endif
1265 1264
1266 yynerrs = 0; 1265 yynerrs = 0;
1267 yyerrflag = 0; 1266 yyerrflag = 0;
1268 yychar = (-1); 1267 yychar = (-1);
1269 1268
1270 yyssp = yyss; 1269 yyssp = yyss;
1271 yyvsp = yyvs; 1270 yyvsp = yyvs;
1272 *yyssp = yystate = 0; 1271 *yyssp = yystate = 0;
1273 1272
1274yyloop: 1273yyloop:
1275 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 1274 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1276 if (yychar < 0) 1275 if (yychar < 0)
1277 { 1276 {
1278 if ((yychar = yylex()) < 0) yychar = 0; 1277 if ((yychar = yylex()) < 0) yychar = 0;
1279#if YYDEBUG 1278#if YYDEBUG
1280 if (yydebug) 1279 if (yydebug)
1281 { 1280 {
1282 yys = 0; 1281 yys = 0;
1283 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 1282 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1284 if (!yys) yys = "illegal-symbol"; 1283 if (!yys) yys = "illegal-symbol";
1285 printf("%sdebug: state %d, reading %d (%s)\n", 1284 printf("%sdebug: state %d, reading %d (%s)\n",
1286 YYPREFIX, yystate, yychar, yys); 1285 YYPREFIX, yystate, yychar, yys);
1287 } 1286 }
1288#endif 1287#endif
1289 } 1288 }
1290 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 1289 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1291 yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 1290 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1292 { 1291 {
1293#if YYDEBUG 1292#if YYDEBUG
1294 if (yydebug) 1293 if (yydebug)
1295 printf("%sdebug: state %d, shifting to state %d\n", 1294 printf("%sdebug: state %d, shifting to state %d\n",
1296 YYPREFIX, yystate, yytable[yyn]); 1295 YYPREFIX, yystate, yytable[yyn]);
1297#endif 1296#endif
1298 if (yyssp >= yyss + yystacksize - 1) 1297 if (yyssp >= yyss + yystacksize - 1)
1299 { 1298 {
1300 goto yyoverflow; 1299 goto yyoverflow;
1301 } 1300 }
1302 *++yyssp = yystate = yytable[yyn]; 1301 *++yyssp = yystate = yytable[yyn];
1303 *++yyvsp = yylval; 1302 *++yyvsp = yylval;
1304 yychar = (-1); 1303 yychar = (-1);
1305 if (yyerrflag > 0) --yyerrflag; 1304 if (yyerrflag > 0) --yyerrflag;
1306 goto yyloop; 1305 goto yyloop;
1307 } 1306 }
1308 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 1307 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1309 yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 1308 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1310 { 1309 {
1311 yyn = yytable[yyn]; 1310 yyn = yytable[yyn];
1312 goto yyreduce; 1311 goto yyreduce;
1313 } 1312 }
1314 if (yyerrflag) goto yyinrecovery; 1313 if (yyerrflag) goto yyinrecovery;
1315 yyerror("syntax error"); 1314 yyerror("syntax error");
1316#ifdef lint 1315#ifdef lint
1317 goto yyerrlab; 1316 goto yyerrlab;
1318#endif 1317#endif
1319yyerrlab: 1318yyerrlab:
1320 ++yynerrs; 1319 ++yynerrs;
1321yyinrecovery: 1320yyinrecovery:
1322 if (yyerrflag < 3) 1321 if (yyerrflag < 3)
1323 { 1322 {
1324 yyerrflag = 3; 1323 yyerrflag = 3;
1325 for (;;) 1324 for (;;)
1326 { 1325 {
1327 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && 1326 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1328 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 1327 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1329 { 1328 {
1330#if YYDEBUG 1329#if YYDEBUG
1331 if (yydebug) 1330 if (yydebug)
1332 printf("%sdebug: state %d, error recovery shifting\ 1331 printf("%sdebug: state %d, error recovery shifting\
1333 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); 1332 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1334#endif 1333#endif
1335 if (yyssp >= yyss + yystacksize - 1) 1334 if (yyssp >= yyss + yystacksize - 1)
1336 { 1335 {
1337 goto yyoverflow; 1336 goto yyoverflow;
1338 } 1337 }
1339 *++yyssp = yystate = yytable[yyn]; 1338 *++yyssp = yystate = yytable[yyn];
1340 *++yyvsp = yylval; 1339 *++yyvsp = yylval;
1341 goto yyloop; 1340 goto yyloop;
1342 } 1341 }
1343 else 1342 else
1344 { 1343 {
1345#if YYDEBUG 1344#if YYDEBUG
1346 if (yydebug) 1345 if (yydebug)
1347 printf("%sdebug: error recovery discarding state %d\n", 1346 printf("%sdebug: error recovery discarding state %d\n",
1348 YYPREFIX, *yyssp); 1347 YYPREFIX, *yyssp);
1349#endif 1348#endif
1350 if (yyssp <= yyss) goto yyabort; 1349 if (yyssp <= yyss) goto yyabort;
1351 --yyssp; 1350 --yyssp;
1352 --yyvsp; 1351 --yyvsp;
1353 } 1352 }
1354 } 1353 }
1355 } 1354 }
1356 else 1355 else
1357 { 1356 {
1358 if (yychar == 0) goto yyabort; 1357 if (yychar == 0) goto yyabort;
1359#if YYDEBUG 1358#if YYDEBUG
1360 if (yydebug) 1359 if (yydebug)
1361 { 1360 {
1362 yys = 0; 1361 yys = 0;
1363 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 1362 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1364 if (!yys) yys = "illegal-symbol"; 1363 if (!yys) yys = "illegal-symbol";
1365 printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 1364 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1366 YYPREFIX, yystate, yychar, yys); 1365 YYPREFIX, yystate, yychar, yys);
1367 } 1366 }
1368#endif 1367#endif
1369 yychar = (-1); 1368 yychar = (-1);
1370 goto yyloop; 1369 goto yyloop;
1371 } 1370 }
1372yyreduce: 1371yyreduce:
1373#if YYDEBUG 1372#if YYDEBUG
1374 if (yydebug) 1373 if (yydebug)
1375 printf("%sdebug: state %d, reducing by rule %d (%s)\n", 1374 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1376 YYPREFIX, yystate, yyn, yyrule[yyn]); 1375 YYPREFIX, yystate, yyn, yyrule[yyn]);
1377#endif 1376#endif
1378 yym = yylen[yyn]; 1377 yym = yylen[yyn];
1379 yyval = yyvsp[1-yym]; 1378 yyval = yyvsp[1-yym];
1380 switch (yyn) 1379 switch (yyn)
1381 { 1380 {
1382case 2: 1381case 2:
1383#line 221 "backend/vcc.y" 1382#line 221 "backend/vcc.y"
1384{ addList(&vObjList, yyvsp[0].vobj); curObj = 0; } 1383{ addList(&vObjList, yyvsp[0].vobj); curObj = 0; }
1385break; 1384break;
1386case 3: 1385case 3:
1387#line 223 "backend/vcc.y" 1386#line 223 "backend/vcc.y"
1388{ addList(&vObjList, yyvsp[0].vobj); curObj = 0; } 1387{ addList(&vObjList, yyvsp[0].vobj); curObj = 0; }
1389break; 1388break;
1390case 6: 1389case 6:
1391#line 232 "backend/vcc.y" 1390#line 232 "backend/vcc.y"
1392{ 1391{
1393 lexPushMode(L_VCARD); 1392 lexPushMode(L_VCARD);
1394 if (!pushVObject(VCCardProp)) YYERROR; 1393 if (!pushVObject(VCCardProp)) YYERROR;
1395 } 1394 }
1396break; 1395break;
1397case 7: 1396case 7:
1398#line 237 "backend/vcc.y" 1397#line 237 "backend/vcc.y"
1399{ 1398{
1400 lexPopMode(0); 1399 lexPopMode(0);
1401 yyval.vobj = popVObject(); 1400 yyval.vobj = popVObject();
1402 } 1401 }
1403break; 1402break;
1404case 8: 1403case 8:
1405#line 242 "backend/vcc.y" 1404#line 242 "backend/vcc.y"
1406{ 1405{
1407 lexPushMode(L_VCARD); 1406 lexPushMode(L_VCARD);
1408 if (!pushVObject(VCCardProp)) YYERROR; 1407 if (!pushVObject(VCCardProp)) YYERROR;
1409 } 1408 }
1410break; 1409break;
1411case 9: 1410case 9:
1412#line 247 "backend/vcc.y" 1411#line 247 "backend/vcc.y"
1413{ 1412{
1414 lexPopMode(0); 1413 lexPopMode(0);
1415 yyval.vobj = popVObject(); 1414 yyval.vobj = popVObject();
1416 } 1415 }
1417break; 1416break;
1418case 12: 1417case 12:
1419#line 258 "backend/vcc.y" 1418#line 258 "backend/vcc.y"
1420{ 1419{
1421 lexPushMode(L_VALUES); 1420 lexPushMode(L_VALUES);
1422 } 1421 }
1423break; 1422break;
1424case 13: 1423case 13:
1425#line 262 "backend/vcc.y" 1424#line 262 "backend/vcc.y"
1426{ 1425{
1427 if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE)) 1426 if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE))
1428 lexPopMode(0); 1427 lexPopMode(0);
1429 lexPopMode(0); 1428 lexPopMode(0);
1430 } 1429 }
1431break; 1430break;
1432case 15: 1431case 15:
1433#line 271 "backend/vcc.y" 1432#line 271 "backend/vcc.y"
1434{ 1433{
1435 enterProps(yyvsp[0].str); 1434 enterProps(yyvsp[0].str);
1436 } 1435 }
1437break; 1436break;
1438case 17: 1437case 17:
1439#line 276 "backend/vcc.y" 1438#line 276 "backend/vcc.y"
1440{ 1439{
1441 enterProps(yyvsp[0].str); 1440 enterProps(yyvsp[0].str);
1442 } 1441 }
1443break; 1442break;
1444case 21: 1443case 21:
1445#line 289 "backend/vcc.y" 1444#line 289 "backend/vcc.y"
1446{ 1445{
1447 enterAttr(yyvsp[0].str,0); 1446 enterAttr(yyvsp[0].str,0);
1448 } 1447 }
1449break; 1448break;
1450case 22: 1449case 22:
1451#line 293 "backend/vcc.y" 1450#line 293 "backend/vcc.y"
1452{ 1451{
1453 enterAttr(yyvsp[-2].str,yyvsp[0].str); 1452 enterAttr(yyvsp[-2].str,yyvsp[0].str);
1454 1453
1455 } 1454 }
1456break; 1455break;
1457case 24: 1456case 24:
1458#line 302 "backend/vcc.y" 1457#line 302 "backend/vcc.y"
1459{ enterValues(yyvsp[-1].str); } 1458{ enterValues(yyvsp[-1].str); }
1460break; 1459break;
1461case 26: 1460case 26:
1462#line 304 "backend/vcc.y" 1461#line 304 "backend/vcc.y"
1463{ enterValues(yyvsp[0].str); } 1462{ enterValues(yyvsp[0].str); }
1464break; 1463break;
1465case 28: 1464case 28:
1466#line 309 "backend/vcc.y" 1465#line 309 "backend/vcc.y"
1467{ yyval.str = 0; } 1466{ yyval.str = 0; }
1468break; 1467break;
1469case 29: 1468case 29:
1470#line 314 "backend/vcc.y" 1469#line 314 "backend/vcc.y"
1471{ if (!pushVObject(VCCalProp)) YYERROR; } 1470{ if (!pushVObject(VCCalProp)) YYERROR; }
1472break; 1471break;
1473case 30: 1472case 30:
1474#line 317 "backend/vcc.y" 1473#line 317 "backend/vcc.y"
1475{ yyval.vobj = popVObject(); } 1474{ yyval.vobj = popVObject(); }
1476break; 1475break;
1477case 31: 1476case 31:
1478#line 319 "backend/vcc.y" 1477#line 319 "backend/vcc.y"
1479{ if (!pushVObject(VCCalProp)) YYERROR; } 1478{ if (!pushVObject(VCCalProp)) YYERROR; }
1480break; 1479break;
1481case 32: 1480case 32:
1482#line 321 "backend/vcc.y" 1481#line 321 "backend/vcc.y"
1483{ yyval.vobj = popVObject(); } 1482{ yyval.vobj = popVObject(); }
1484break; 1483break;
1485case 38: 1484case 38:
1486#line 336 "backend/vcc.y" 1485#line 336 "backend/vcc.y"
1487{ 1486{
1488 lexPushMode(L_VEVENT); 1487 lexPushMode(L_VEVENT);
1489 if (!pushVObject(VCEventProp)) YYERROR; 1488 if (!pushVObject(VCEventProp)) YYERROR;
1490 } 1489 }
1491break; 1490break;
1492case 39: 1491case 39:
1493#line 342 "backend/vcc.y" 1492#line 342 "backend/vcc.y"
1494{ 1493{
1495 lexPopMode(0); 1494 lexPopMode(0);
1496 popVObject(); 1495 popVObject();
1497 } 1496 }
1498break; 1497break;
1499case 40: 1498case 40:
1500#line 347 "backend/vcc.y" 1499#line 347 "backend/vcc.y"
1501{ 1500{
1502 lexPushMode(L_VEVENT); 1501 lexPushMode(L_VEVENT);
1503 if (!pushVObject(VCEventProp)) YYERROR; 1502 if (!pushVObject(VCEventProp)) YYERROR;
1504 } 1503 }
1505break; 1504break;
1506case 41: 1505case 41:
1507#line 352 "backend/vcc.y" 1506#line 352 "backend/vcc.y"
1508{ 1507{
1509 lexPopMode(0); 1508 lexPopMode(0);
1510 popVObject(); 1509 popVObject();
1511 } 1510 }
1512break; 1511break;
1513case 42: 1512case 42:
1514#line 360 "backend/vcc.y" 1513#line 360 "backend/vcc.y"
1515{ 1514{
1516 lexPushMode(L_VTODO); 1515 lexPushMode(L_VTODO);
1517 if (!pushVObject(VCTodoProp)) YYERROR; 1516 if (!pushVObject(VCTodoProp)) YYERROR;
1518 } 1517 }
1519break; 1518break;
1520case 43: 1519case 43:
1521#line 366 "backend/vcc.y" 1520#line 366 "backend/vcc.y"
1522{ 1521{
1523 lexPopMode(0); 1522 lexPopMode(0);
1524 popVObject(); 1523 popVObject();
1525 } 1524 }
1526break; 1525break;
1527case 44: 1526case 44:
1528#line 371 "backend/vcc.y" 1527#line 371 "backend/vcc.y"
1529{ 1528{
1530 lexPushMode(L_VTODO); 1529 lexPushMode(L_VTODO);
1531 if (!pushVObject(VCTodoProp)) YYERROR; 1530 if (!pushVObject(VCTodoProp)) YYERROR;
1532 } 1531 }
1533break; 1532break;
1534case 45: 1533case 45:
1535#line 376 "backend/vcc.y" 1534#line 376 "backend/vcc.y"
1536{ 1535{
1537 lexPopMode(0); 1536 lexPopMode(0);
1538 popVObject(); 1537 popVObject();
1539 } 1538 }
1540break; 1539break;
1541#line 1540 "y.tab.c" 1540#line 1541 "y.tab.c"
1542 } 1541 }
1543 yyssp -= yym; 1542 yyssp -= yym;
1544 yystate = *yyssp; 1543 yystate = *yyssp;
1545 yyvsp -= yym; 1544 yyvsp -= yym;
1546 yym = yylhs[yyn]; 1545 yym = yylhs[yyn];
1547 if (yystate == 0 && yym == 0) 1546 if (yystate == 0 && yym == 0)
1548 { 1547 {
1549#if YYDEBUG 1548#if YYDEBUG
1550 if (yydebug) 1549 if (yydebug)
1551 printf("%sdebug: after reduction, shifting from state 0 to\ 1550 printf("%sdebug: after reduction, shifting from state 0 to\
1552 state %d\n", YYPREFIX, YYFINAL); 1551 state %d\n", YYPREFIX, YYFINAL);
1553#endif 1552#endif
1554 yystate = YYFINAL; 1553 yystate = YYFINAL;
1555 *++yyssp = YYFINAL; 1554 *++yyssp = YYFINAL;
1556 *++yyvsp = yyval; 1555 *++yyvsp = yyval;
1557 if (yychar < 0) 1556 if (yychar < 0)
1558 { 1557 {
1559 if ((yychar = yylex()) < 0) yychar = 0; 1558 if ((yychar = yylex()) < 0) yychar = 0;
1560#if YYDEBUG 1559#if YYDEBUG
1561 if (yydebug) 1560 if (yydebug)
1562 { 1561 {
1563 yys = 0; 1562 yys = 0;
1564 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 1563 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1565 if (!yys) yys = "illegal-symbol"; 1564 if (!yys) yys = "illegal-symbol";
1566 printf("%sdebug: state %d, reading %d (%s)\n", 1565 printf("%sdebug: state %d, reading %d (%s)\n",
1567 YYPREFIX, YYFINAL, yychar, yys); 1566 YYPREFIX, YYFINAL, yychar, yys);
1568 } 1567 }
1569#endif 1568#endif
1570 } 1569 }
1571 if (yychar == 0) goto yyaccept; 1570 if (yychar == 0) goto yyaccept;
1572 goto yyloop; 1571 goto yyloop;
1573 } 1572 }
1574 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 1573 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1575 yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 1574 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1576 yystate = yytable[yyn]; 1575 yystate = yytable[yyn];
1577 else 1576 else
1578 yystate = yydgoto[yym]; 1577 yystate = yydgoto[yym];
1579#if YYDEBUG 1578#if YYDEBUG
1580 if (yydebug) 1579 if (yydebug)
1581 printf("%sdebug: after reduction, shifting from state %d \ 1580 printf("%sdebug: after reduction, shifting from state %d \
1582to state %d\n", YYPREFIX, *yyssp, yystate); 1581to state %d\n", YYPREFIX, *yyssp, yystate);
1583#endif 1582#endif
1584 if (yyssp >= yyss + yystacksize - 1) 1583 if (yyssp >= yyss + yystacksize - 1)
1585 { 1584 {
1586 goto yyoverflow; 1585 goto yyoverflow;
1587 } 1586 }
1588 *++yyssp = yystate; 1587 *++yyssp = yystate;
1589 *++yyvsp = yyval; 1588 *++yyvsp = yyval;
1590 goto yyloop; 1589 goto yyloop;
1591yyoverflow: 1590yyoverflow:
1592 yyerror("yacc stack overflow"); 1591 yyerror("yacc stack overflow");
1593yyabort: 1592yyabort:
1594 return (1); 1593 return (1);
1595yyaccept: 1594yyaccept:
1596 return (0); 1595 return (0);
1597} 1596}
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp
index 4c8de70..9263c3a 100644
--- a/library/backend/vobject.cpp
+++ b/library/backend/vobject.cpp
@@ -1,1366 +1,1363 @@
1/*************************************************************************** 1/***************************************************************************
2(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International 2(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
3Business Machines Corporation and Siemens Rolm Communications Inc. 3Business Machines Corporation and Siemens Rolm Communications Inc.
4 4
5For purposes of this license notice, the term Licensors shall mean, 5For purposes of this license notice, the term Licensors shall mean,
6collectively, Apple Computer, Inc., AT&T Corp., International 6collectively, Apple Computer, Inc., AT&T Corp., International
7Business Machines Corporation and Siemens Rolm Communications Inc. 7Business Machines Corporation and Siemens Rolm Communications Inc.
8The term Licensor shall mean any of the Licensors. 8The term Licensor shall mean any of the Licensors.
9 9
10Subject to acceptance of the following conditions, permission is hereby 10Subject to acceptance of the following conditions, permission is hereby
11granted by Licensors without the need for written agreement and without 11granted by Licensors without the need for written agreement and without
12license or royalty fees, to use, copy, modify and distribute this 12license or royalty fees, to use, copy, modify and distribute this
13software for any purpose. 13software for any purpose.
14 14
15The above copyright notice and the following four paragraphs must be 15The above copyright notice and the following four paragraphs must be
16reproduced in all copies of this software and any software including 16reproduced in all copies of this software and any software including
17this software. 17this software.
18 18
19THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE 19THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
20ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR 20ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
21MODIFICATIONS. 21MODIFICATIONS.
22 22
23IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, 23IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
24INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT 24INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
25OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26DAMAGE. 26DAMAGE.
27 27
28EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, 28EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
29INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE 29INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
30IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31PURPOSE. 31PURPOSE.
32 32
33The software is provided with RESTRICTED RIGHTS. Use, duplication, or 33The software is provided with RESTRICTED RIGHTS. Use, duplication, or
34disclosure by the government are subject to restrictions set forth in 34disclosure by the government are subject to restrictions set forth in
35DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. 35DFARS 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 #ifndef MWERKS 45#include <stdlib.h>
46#include <malloc.h>
47#endif
48 46
49#include <qtopia/config.h> 47#include <qtopia/config.h>
50#include "vobject_p.h" 48#include "vobject_p.h"
51#include "qfiledirect_p.h" 49#include "qfiledirect_p.h"
52#include <string.h> 50#include <string.h>
53#include <stdio.h> 51#include <stdio.h>
54#include <fcntl.h> 52#include <fcntl.h>
55//#include <io.h> 53//#include <io.h>
56 54
57 55
58 #define NAME_OF(o) o->id 56 #define NAME_OF(o) o->id
59 #define VALUE_TYPE(o) o->valType 57 #define VALUE_TYPE(o) o->valType
60 #define STRINGZ_VALUE_OF(o) o->val.strs 58 #define STRINGZ_VALUE_OF(o) o->val.strs
61 #define INTEGER_VALUE_OF(o) o->val.i 59 #define INTEGER_VALUE_OF(o) o->val.i
62 #define LONG_VALUE_OF(o) o->val.l 60 #define LONG_VALUE_OF(o) o->val.l
63 #define ANY_VALUE_OF(o) o->val.any 61 #define ANY_VALUE_OF(o) o->val.any
64 #define VOBJECT_VALUE_OF(o) o->val.vobj 62 #define VOBJECT_VALUE_OF(o) o->val.vobj
65 63
66static char vobj_cs[10]; 64static char vobj_cs[10];
67static enum { EightBit, QuotedPrintable, Base64 } vobj_enc=EightBit; 65static enum { EightBit, QuotedPrintable, Base64 } vobj_enc=EightBit;
68static const char *vobj_enc_s=0; 66static const char *vobj_enc_s=0;
69 67
70typedef union ValueItem { 68typedef union ValueItem {
71 const char *strs; 69 const char *strs;
72 unsigned int i; 70 unsigned int i;
73 unsigned long l; 71 unsigned long l;
74 void *any; 72 void *any;
75 VObject *vobj; 73 VObject *vobj;
76 } ValueItem; 74 } ValueItem;
77 75
78struct VObject { 76struct VObject {
79 VObject *next; 77 VObject *next;
80 const char *id; 78 const char *id;
81 VObject *prop; 79 VObject *prop;
82 unsigned short valType; 80 unsigned short valType;
83 ValueItem val; 81 ValueItem val;
84 }; 82 };
85 83
86typedef struct StrItem StrItem; 84typedef struct StrItem StrItem;
87 85
88struct StrItem { 86struct StrItem {
89 StrItem *next; 87 StrItem *next;
90 const char *s; 88 const char *s;
91 unsigned int refCnt; 89 unsigned int refCnt;
92 }; 90 };
93 91
94DLLEXPORT(const char**) fieldedProp; 92DLLEXPORT(const char**) fieldedProp;
95 93
96 94
97 95
98/*---------------------------------------------------------------------- 96/*----------------------------------------------------------------------
99 The following functions involve with memory allocation: 97 The following functions involve with memory allocation:
100 newVObject 98 newVObject
101 deleteVObject 99 deleteVObject
102 dupStr 100 dupStr
103 deleteStr 101 deleteStr
104 newStrItem 102 newStrItem
105 deleteStrItem 103 deleteStrItem
106 ----------------------------------------------------------------------*/ 104 ----------------------------------------------------------------------*/
107 105
108DLLEXPORT(VObject*) newVObject_(const char *id) 106DLLEXPORT(VObject*) newVObject_(const char *id)
109{ 107{
110 VObject *p = (VObject*)malloc(sizeof(VObject)); 108 VObject *p = (VObject*)malloc(sizeof(VObject));
111 p->next = 0; 109 p->next = 0;
112 p->id = id; 110 p->id = id;
113 p->prop = 0; 111 p->prop = 0;
114 VALUE_TYPE(p) = 0; 112 VALUE_TYPE(p) = 0;
115 ANY_VALUE_OF(p) = 0; 113 ANY_VALUE_OF(p) = 0;
116 return p; 114 return p;
117} 115}
118 116
119DLLEXPORT(VObject*) newVObject(const char *id) 117DLLEXPORT(VObject*) newVObject(const char *id)
120{ 118{
121 return newVObject_(lookupStr(id)); 119 return newVObject_(lookupStr(id));
122} 120}
123 121
124DLLEXPORT(void) deleteVObject(VObject *p) 122DLLEXPORT(void) deleteVObject(VObject *p)
125{ 123{
126 unUseStr(p->id); 124 unUseStr(p->id);
127 free(p); 125 free(p);
128} 126}
129 127
130DLLEXPORT(char*) dupStr(const char *s, unsigned int size) 128DLLEXPORT(char*) dupStr(const char *s, unsigned int size)
131{ 129{
132 char *t; 130 char *t;
133 if (size == 0) { 131 if (size == 0) {
134 size = strlen(s); 132 size = strlen(s);
135 } 133 }
136 t = (char*)malloc(size+1); 134 t = (char*)malloc(size+1);
137 if (t) { 135 if (t) {
138 memcpy(t,s,size); 136 memcpy(t,s,size);
139 t[size] = 0; 137 t[size] = 0;
140 return t; 138 return t;
141 } 139 }
142 else { 140 else {
143 return (char*)0; 141 return (char*)0;
144 } 142 }
145} 143}
146 144
147DLLEXPORT(void) deleteStr(const char *p) 145DLLEXPORT(void) deleteStr(const char *p)
148{ 146{
149 if (p) free((void*)p); 147 if (p) free((void*)p);
150} 148}
151 149
152 150
153static StrItem* newStrItem(const char *s, StrItem *next) 151static StrItem* newStrItem(const char *s, StrItem *next)
154{ 152{
155 StrItem *p = (StrItem*)malloc(sizeof(StrItem)); 153 StrItem *p = (StrItem*)malloc(sizeof(StrItem));
156 p->next = next; 154 p->next = next;
157 p->s = s; 155 p->s = s;
158 p->refCnt = 1; 156 p->refCnt = 1;
159 return p; 157 return p;
160} 158}
161 159
162static void deleteStrItem(StrItem *p) 160static void deleteStrItem(StrItem *p)
163{ 161{
164 free((void*)p); 162 free((void*)p);
165} 163}
166 164
167 165
168/*---------------------------------------------------------------------- 166/*----------------------------------------------------------------------
169 The following function provide accesses to VObject's value. 167 The following function provide accesses to VObject's value.
170 ----------------------------------------------------------------------*/ 168 ----------------------------------------------------------------------*/
171 169
172DLLEXPORT(const char*) vObjectName(VObject *o) 170DLLEXPORT(const char*) vObjectName(VObject *o)
173{ 171{
174 return NAME_OF(o); 172 return NAME_OF(o);
175} 173}
176 174
177DLLEXPORT(void) setVObjectName(VObject *o, const char* id) 175DLLEXPORT(void) setVObjectName(VObject *o, const char* id)
178{ 176{
179 NAME_OF(o) = id; 177 NAME_OF(o) = id;
180} 178}
181 179
182DLLEXPORT(const char*) vObjectStringZValue(VObject *o) 180DLLEXPORT(const char*) vObjectStringZValue(VObject *o)
183{ 181{
184 return STRINGZ_VALUE_OF(o); 182 return STRINGZ_VALUE_OF(o);
185} 183}
186 184
187DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s) 185DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s)
188{ 186{
189 STRINGZ_VALUE_OF(o) = dupStr(s,0); 187 STRINGZ_VALUE_OF(o) = dupStr(s,0);
190 VALUE_TYPE(o) = VCVT_STRINGZ; 188 VALUE_TYPE(o) = VCVT_STRINGZ;
191} 189}
192 190
193DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s) 191DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s)
194{ 192{
195 STRINGZ_VALUE_OF(o) = s; 193 STRINGZ_VALUE_OF(o) = s;
196 VALUE_TYPE(o) = VCVT_STRINGZ; 194 VALUE_TYPE(o) = VCVT_STRINGZ;
197} 195}
198 196
199DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o) 197DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o)
200{ 198{
201 return INTEGER_VALUE_OF(o); 199 return INTEGER_VALUE_OF(o);
202} 200}
203 201
204DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i) 202DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i)
205{ 203{
206 INTEGER_VALUE_OF(o) = i; 204 INTEGER_VALUE_OF(o) = i;
207 VALUE_TYPE(o) = VCVT_UINT; 205 VALUE_TYPE(o) = VCVT_UINT;
208} 206}
209 207
210DLLEXPORT(unsigned long) vObjectLongValue(VObject *o) 208DLLEXPORT(unsigned long) vObjectLongValue(VObject *o)
211{ 209{
212 return LONG_VALUE_OF(o); 210 return LONG_VALUE_OF(o);
213} 211}
214 212
215DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l) 213DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l)
216{ 214{
217 LONG_VALUE_OF(o) = l; 215 LONG_VALUE_OF(o) = l;
218 VALUE_TYPE(o) = VCVT_ULONG; 216 VALUE_TYPE(o) = VCVT_ULONG;
219} 217}
220 218
221DLLEXPORT(void*) vObjectAnyValue(VObject *o) 219DLLEXPORT(void*) vObjectAnyValue(VObject *o)
222{ 220{
223 return ANY_VALUE_OF(o); 221 return ANY_VALUE_OF(o);
224} 222}
225 223
226DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t) 224DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t)
227{ 225{
228 ANY_VALUE_OF(o) = t; 226 ANY_VALUE_OF(o) = t;
229 VALUE_TYPE(o) = VCVT_RAW; 227 VALUE_TYPE(o) = VCVT_RAW;
230} 228}
231 229
232DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o) 230DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o)
233{ 231{
234 return VOBJECT_VALUE_OF(o); 232 return VOBJECT_VALUE_OF(o);
235} 233}
236 234
237DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p) 235DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p)
238{ 236{
239 VOBJECT_VALUE_OF(o) = p; 237 VOBJECT_VALUE_OF(o) = p;
240 VALUE_TYPE(o) = VCVT_VOBJECT; 238 VALUE_TYPE(o) = VCVT_VOBJECT;
241} 239}
242 240
243DLLEXPORT(int) vObjectValueType(VObject *o) 241DLLEXPORT(int) vObjectValueType(VObject *o)
244{ 242{
245 return VALUE_TYPE(o); 243 return VALUE_TYPE(o);
246} 244}
247 245
248 246
249/*---------------------------------------------------------------------- 247/*----------------------------------------------------------------------
250 The following functions can be used to build VObject. 248 The following functions can be used to build VObject.
251 ----------------------------------------------------------------------*/ 249 ----------------------------------------------------------------------*/
252 250
253DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p) 251DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p)
254{ 252{
255 /* circular link list pointed to tail */ 253 /* circular link list pointed to tail */
256 /* 254 /*
257 o {next,id,prop,val} 255 o {next,id,prop,val}
258 V 256 V
259 pn {next,id,prop,val} 257 pn {next,id,prop,val}
260 V 258 V
261 ... 259 ...
262 p1 {next,id,prop,val} 260 p1 {next,id,prop,val}
263 V 261 V
264 pn 262 pn
265 --> 263 -->
266 o {next,id,prop,val} 264 o {next,id,prop,val}
267 V 265 V
268 pn {next,id,prop,val} 266 pn {next,id,prop,val}
269 V 267 V
270 p {next,id,prop,val} 268 p {next,id,prop,val}
271 ... 269 ...
272 p1 {next,id,prop,val} 270 p1 {next,id,prop,val}
273 V 271 V
274 pn 272 pn
275 */ 273 */
276 274
277 VObject *tail = o->prop; 275 VObject *tail = o->prop;
278 if (tail) { 276 if (tail) {
279 p->next = tail->next; 277 p->next = tail->next;
280 o->prop = tail->next = p; 278 o->prop = tail->next = p;
281 } 279 }
282 else { 280 else {
283 o->prop = p->next = p; 281 o->prop = p->next = p;
284 } 282 }
285 return p; 283 return p;
286} 284}
287 285
288DLLEXPORT(VObject*) addProp(VObject *o, const char *id) 286DLLEXPORT(VObject*) addProp(VObject *o, const char *id)
289{ 287{
290 return addVObjectProp(o,newVObject(id)); 288 return addVObjectProp(o,newVObject(id));
291} 289}
292 290
293DLLEXPORT(VObject*) addProp_(VObject *o, const char *id) 291DLLEXPORT(VObject*) addProp_(VObject *o, const char *id)
294{ 292{
295 return addVObjectProp(o,newVObject_(id)); 293 return addVObjectProp(o,newVObject_(id));
296} 294}
297 295
298DLLEXPORT(void) addList(VObject **o, VObject *p) 296DLLEXPORT(void) addList(VObject **o, VObject *p)
299{ 297{
300 p->next = 0; 298 p->next = 0;
301 if (*o == 0) { 299 if (*o == 0) {
302 *o = p; 300 *o = p;
303 } 301 }
304 else { 302 else {
305 VObject *t = *o; 303 VObject *t = *o;
306 while (t->next) { 304 while (t->next) {
307 t = t->next; 305 t = t->next;
308 } 306 }
309 t->next = p; 307 t->next = p;
310 } 308 }
311} 309}
312 310
313DLLEXPORT(VObject*) nextVObjectInList(VObject *o) 311DLLEXPORT(VObject*) nextVObjectInList(VObject *o)
314{ 312{
315 return o->next; 313 return o->next;
316} 314}
317 315
318DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size) 316DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size)
319{ 317{
320 VObject *sizeProp; 318 VObject *sizeProp;
321 setVObjectAnyValue(prop, val); 319 setVObjectAnyValue(prop, val);
322 sizeProp = addProp(prop,VCDataSizeProp); 320 sizeProp = addProp(prop,VCDataSizeProp);
323 setVObjectLongValue(sizeProp, size); 321 setVObjectLongValue(sizeProp, size);
324 return prop; 322 return prop;
325} 323}
326 324
327DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size) 325DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size)
328{ 326{
329 void *p = dupStr((const char *)val,size); 327 void *p = dupStr((const char *)val,size);
330 return setValueWithSize_(prop,p,p?size:0); 328 return setValueWithSize_(prop,p,p?size:0);
331} 329}
332 330
333DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o) 331DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o)
334{ 332{
335 i->start = o->prop; 333 i->start = o->prop;
336 i->next = 0; 334 i->next = 0;
337} 335}
338 336
339DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o) 337DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o)
340{ 338{
341 i->start = o->next; 339 i->start = o->next;
342 i->next = 0; 340 i->next = 0;
343} 341}
344 342
345DLLEXPORT(int) moreIteration(VObjectIterator *i) 343DLLEXPORT(int) moreIteration(VObjectIterator *i)
346{ 344{
347 return (i->start && (i->next==0 || i->next!=i->start)); 345 return (i->start && (i->next==0 || i->next!=i->start));
348} 346}
349 347
350DLLEXPORT(VObject*) nextVObject(VObjectIterator *i) 348DLLEXPORT(VObject*) nextVObject(VObjectIterator *i)
351{ 349{
352 if (i->start && i->next != i->start) { 350 if (i->start && i->next != i->start) {
353 if (i->next == 0) { 351 if (i->next == 0) {
354 i->next = i->start->next; 352 i->next = i->start->next;
355 return i->next; 353 return i->next;
356 } 354 }
357 else { 355 else {
358 i->next = i->next->next; 356 i->next = i->next->next;
359 return i->next; 357 return i->next;
360 } 358 }
361 } 359 }
362 else return (VObject*)0; 360 else return (VObject*)0;
363} 361}
364 362
365DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id) 363DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id)
366{ 364{
367 VObjectIterator i; 365 VObjectIterator i;
368 initPropIterator(&i,o); 366 initPropIterator(&i,o);
369 while (moreIteration(&i)) { 367 while (moreIteration(&i)) {
370 VObject *each = nextVObject(&i); 368 VObject *each = nextVObject(&i);
371 if (!qstricmp(id,each->id)) 369 if (!qstricmp(id,each->id))
372 return each; 370 return each;
373 } 371 }
374 return (VObject*)0; 372 return (VObject*)0;
375} 373}
376 374
377DLLEXPORT(VObject*) addGroup(VObject *o, const char *g) 375DLLEXPORT(VObject*) addGroup(VObject *o, const char *g)
378{ 376{
379 /* 377 /*
380 a.b.c 378 a.b.c
381 --> 379 -->
382 prop(c) 380 prop(c)
383 prop(VCGrouping=b) 381 prop(VCGrouping=b)
384 prop(VCGrouping=a) 382 prop(VCGrouping=a)
385 */ 383 */
386 char *dot = strrchr(g,'.'); 384 char *dot = strrchr(g,'.');
387 if (dot) { 385 if (dot) {
388 VObject *p, *t; 386 VObject *p, *t;
389 char *gs, *n = dot+1; 387 char *gs, *n = dot+1;
390 gs = dupStr(g,0);/* so we can write to it. */ 388 gs = dupStr(g,0);/* so we can write to it. */
391 /* used to be 389 /* used to be
392 * t = p = addProp_(o,lookupProp_(n)); 390 * t = p = addProp_(o,lookupProp_(n));
393 */ 391 */
394 t = p = addProp_(o,lookupProp(n)); 392 t = p = addProp_(o,lookupProp(n));
395 dot = strrchr(gs,'.'); 393 dot = strrchr(gs,'.');
396 *dot = 0; 394 *dot = 0;
397 do { 395 do {
398 dot = strrchr(gs,'.'); 396 dot = strrchr(gs,'.');
399 if (dot) { 397 if (dot) {
400 n = dot+1; 398 n = dot+1;
401 *dot=0; 399 *dot=0;
402 } 400 }
403 else 401 else
404 n = gs; 402 n = gs;
405 /* property(VCGroupingProp=n); 403 /* property(VCGroupingProp=n);
406 *and the value may have VCGrouping property 404 *and the value may have VCGrouping property
407 */ 405 */
408 t = addProp(t,VCGroupingProp); 406 t = addProp(t,VCGroupingProp);
409 setVObjectStringZValue(t,lookupProp_(n)); 407 setVObjectStringZValue(t,lookupProp_(n));
410 } while (n != gs); 408 } while (n != gs);
411 deleteStr(gs); 409 deleteStr(gs);
412 return p; 410 return p;
413 } 411 }
414 else 412 else
415 return addProp_(o,lookupProp(g)); 413 return addProp_(o,lookupProp(g));
416} 414}
417 415
418DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v) 416DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v)
419{ 417{
420 VObject *prop; 418 VObject *prop;
421 prop = addProp(o,p); 419 prop = addProp(o,p);
422 setVObjectStringZValue_(prop, strdup( v ) ); 420 setVObjectStringZValue_(prop, strdup( v ) );
423 return prop; 421 return prop;
424} 422}
425 423
426DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, 424DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v,
427 unsigned int size) 425 unsigned int size)
428{ 426{
429 VObject *prop; 427 VObject *prop;
430 prop = addProp(o,p); 428 prop = addProp(o,p);
431 setValueWithSize_(prop, (void*)v, size); 429 setValueWithSize_(prop, (void*)v, size);
432 return prop; 430 return prop;
433} 431}
434 432
435DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, 433DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v,
436 unsigned int size) 434 unsigned int size)
437{ 435{
438 return addPropSizedValue_(o,p,dupStr(v,size),size); 436 return addPropSizedValue_(o,p,dupStr(v,size),size);
439} 437}
440 438
441 439
442DLLEXPORT(void) cleanVObject(VObject *o) 440DLLEXPORT(void) cleanVObject(VObject *o)
443{ 441{
444 if (o == 0) return; 442 if (o == 0) return;
445 if (o->prop) { 443 if (o->prop) {
446 /* destroy time: cannot use the iterator here. 444 /* destroy time: cannot use the iterator here.
447 Have to break the cycle in the circular link 445 Have to break the cycle in the circular link
448 list and turns it into regular NULL-terminated 446 list and turns it into regular NULL-terminated
449 list -- since at some point of destruction, 447 list -- since at some point of destruction,
450 the reference entry for the iterator to work 448 the reference entry for the iterator to work
451 will not longer be valid. 449 will not longer be valid.
452 */ 450 */
453 VObject *p; 451 VObject *p;
454 p = o->prop->next; 452 p = o->prop->next;
455 o->prop->next = 0; 453 o->prop->next = 0;
456 do { 454 do {
457 VObject *t = p->next; 455 VObject *t = p->next;
458 cleanVObject(p); 456 cleanVObject(p);
459 p = t; 457 p = t;
460 } while (p); 458 } while (p);
461 } 459 }
462 switch (VALUE_TYPE(o)) { 460 switch (VALUE_TYPE(o)) {
463 case VCVT_STRINGZ: 461 case VCVT_STRINGZ:
464 case VCVT_RAW: 462 case VCVT_RAW:
465 // assume they are all allocated by malloc. 463 // assume they are all allocated by malloc.
466 free((char*)STRINGZ_VALUE_OF(o)); 464 free((char*)STRINGZ_VALUE_OF(o));
467 break; 465 break;
468 case VCVT_VOBJECT: 466 case VCVT_VOBJECT:
469 cleanVObject(VOBJECT_VALUE_OF(o)); 467 cleanVObject(VOBJECT_VALUE_OF(o));
470 break; 468 break;
471 } 469 }
472 deleteVObject(o); 470 deleteVObject(o);
473} 471}
474 472
475DLLEXPORT(void) cleanVObjects(VObject *list) 473DLLEXPORT(void) cleanVObjects(VObject *list)
476{ 474{
477 while (list) { 475 while (list) {
478 VObject *t = list; 476 VObject *t = list;
479 list = nextVObjectInList(list); 477 list = nextVObjectInList(list);
480 cleanVObject(t); 478 cleanVObject(t);
481 } 479 }
482} 480}
483 481
484/*---------------------------------------------------------------------- 482/*----------------------------------------------------------------------
485 The following is a String Table Facilities. 483 The following is a String Table Facilities.
486 ----------------------------------------------------------------------*/ 484 ----------------------------------------------------------------------*/
487 485
488#define STRTBLSIZE 255 486#define STRTBLSIZE 255
489 487
490static StrItem *strTbl[STRTBLSIZE]; 488static StrItem *strTbl[STRTBLSIZE];
491 489
492static unsigned int hashStr(const char *s) 490static unsigned int hashStr(const char *s)
493{ 491{
494 unsigned int h = 0; 492 unsigned int h = 0;
495 int i; 493 int i;
496 for (i=0;s[i];i++) { 494 for (i=0;s[i];i++) {
497 h += s[i]*i; 495 h += s[i]*i;
498 } 496 }
499 return h % STRTBLSIZE; 497 return h % STRTBLSIZE;
500} 498}
501 499
502DLLEXPORT(const char*) lookupStr(const char *s) 500DLLEXPORT(const char*) lookupStr(const char *s)
503{ 501{
504 StrItem *t; 502 StrItem *t;
505 unsigned int h = hashStr(s); 503 unsigned int h = hashStr(s);
506 if ((t = strTbl[h]) != 0) { 504 if ((t = strTbl[h]) != 0) {
507 do { 505 do {
508 if (qstricmp(t->s,s) == 0) { 506 if (qstricmp(t->s,s) == 0) {
509 t->refCnt++; 507 t->refCnt++;
510 return t->s; 508 return t->s;
511 } 509 }
512 t = t->next; 510 t = t->next;
513 } while (t); 511 } while (t);
514 } 512 }
515 s = dupStr(s,0); 513 s = dupStr(s,0);
516 strTbl[h] = newStrItem(s,strTbl[h]); 514 strTbl[h] = newStrItem(s,strTbl[h]);
517 return s; 515 return s;
518} 516}
519 517
520DLLEXPORT(void) unUseStr(const char *s) 518DLLEXPORT(void) unUseStr(const char *s)
521{ 519{
522 StrItem *t, *p; 520 StrItem *t, *p;
523 unsigned int h = hashStr(s); 521 unsigned int h = hashStr(s);
524 if ((t = strTbl[h]) != 0) { 522 if ((t = strTbl[h]) != 0) {
525 p = t; 523 p = t;
526 do { 524 do {
527 if (qstricmp(t->s,s) == 0) { 525 if (qstricmp(t->s,s) == 0) {
528 t->refCnt--; 526 t->refCnt--;
529 if (t->refCnt == 0) { 527 if (t->refCnt == 0) {
530 if (p == strTbl[h]) { 528 if (p == strTbl[h]) {
531 strTbl[h] = t->next; 529 strTbl[h] = t->next;
532 } 530 }
533 else { 531 else {
534 p->next = t->next; 532 p->next = t->next;
535 } 533 }
536 deleteStr(t->s); 534 deleteStr(t->s);
537 deleteStrItem(t); 535 deleteStrItem(t);
538 return; 536 return;
539 } 537 }
540 } 538 }
541 p = t; 539 p = t;
542 t = t->next; 540 t = t->next;
543 } while (t); 541 } while (t);
544 } 542 }
545} 543}
546 544
547DLLEXPORT(void) cleanStrTbl() 545DLLEXPORT(void) cleanStrTbl()
548{ 546{
549 int i; 547 int i;
550 for (i=0; i<STRTBLSIZE;i++) { 548 for (i=0; i<STRTBLSIZE;i++) {
551 StrItem *t = strTbl[i]; 549 StrItem *t = strTbl[i];
552 while (t) { 550 while (t) {
553 StrItem *p; 551 StrItem *p;
554 deleteStr(t->s); 552 deleteStr(t->s);
555 p = t; 553 p = t;
556 t = t->next; 554 t = t->next;
557 deleteStrItem(p); 555 deleteStrItem(p);
558 } while (t); 556 } while (t);
559 strTbl[i] = 0; 557 strTbl[i] = 0;
560 } 558 }
561} 559}
562 560
563 561
564struct PreDefProp { 562struct PreDefProp {
565 const char *name; 563 const char *name;
566 const char *alias; 564 const char *alias;
567 const char** fields; 565 const char** fields;
568 unsigned int flags; 566 unsigned int flags;
569 }; 567 };
570 568
571/* flags in PreDefProp */ 569/* flags in PreDefProp */
572 #define PD_BEGIN0x1 570 #define PD_BEGIN0x1
573 #define PD_INTERNAL0x2 571 #define PD_INTERNAL0x2
574 572
575static const char *adrFields[] = { 573static const char *adrFields[] = {
576 VCPostalBoxProp, 574 VCPostalBoxProp,
577 VCExtAddressProp, 575 VCExtAddressProp,
578 VCStreetAddressProp, 576 VCStreetAddressProp,
579 VCCityProp, 577 VCCityProp,
580 VCRegionProp, 578 VCRegionProp,
581 VCPostalCodeProp, 579 VCPostalCodeProp,
582 VCCountryNameProp, 580 VCCountryNameProp,
583 0 581 0
584}; 582};
585 583
586static const char *nameFields[] = { 584static const char *nameFields[] = {
587 VCFamilyNameProp, 585 VCFamilyNameProp,
588 VCGivenNameProp, 586 VCGivenNameProp,
589 VCAdditionalNamesProp, 587 VCAdditionalNamesProp,
590 VCNamePrefixesProp, 588 VCNamePrefixesProp,
591 VCNameSuffixesProp, 589 VCNameSuffixesProp,
592 NULL 590 NULL
593 }; 591 };
594 592
595static const char *orgFields[] = { 593static const char *orgFields[] = {
596 VCOrgNameProp, 594 VCOrgNameProp,
597 VCOrgUnitProp, 595 VCOrgUnitProp,
598 VCOrgUnit2Prop, 596 VCOrgUnit2Prop,
599 VCOrgUnit3Prop, 597 VCOrgUnit3Prop,
600 VCOrgUnit4Prop, 598 VCOrgUnit4Prop,
601 NULL 599 NULL
602 }; 600 };
603 601
604static const char *AAlarmFields[] = { 602static const char *AAlarmFields[] = {
605 VCRunTimeProp, 603 VCRunTimeProp,
606 VCSnoozeTimeProp, 604 VCSnoozeTimeProp,
607 VCRepeatCountProp, 605 VCRepeatCountProp,
608 VCAudioContentProp, 606 VCAudioContentProp,
609 0 607 0
610 }; 608 };
611 609
612/* ExDate -- has unamed fields */ 610/* ExDate -- has unamed fields */
613/* RDate -- has unamed fields */ 611/* RDate -- has unamed fields */
614 612
615static const char *DAlarmFields[] = { 613static const char *DAlarmFields[] = {
616 VCRunTimeProp, 614 VCRunTimeProp,
617 VCSnoozeTimeProp, 615 VCSnoozeTimeProp,
618 VCRepeatCountProp, 616 VCRepeatCountProp,
619 VCDisplayStringProp, 617 VCDisplayStringProp,
620 0 618 0
621 }; 619 };
622 620
623static const char *MAlarmFields[] = { 621static const char *MAlarmFields[] = {
624 VCRunTimeProp, 622 VCRunTimeProp,
625 VCSnoozeTimeProp, 623 VCSnoozeTimeProp,
626 VCRepeatCountProp, 624 VCRepeatCountProp,
627 VCEmailAddressProp, 625 VCEmailAddressProp,
628 VCNoteProp, 626 VCNoteProp,
629 0 627 0
630 }; 628 };
631 629
632static const char *PAlarmFields[] = { 630static const char *PAlarmFields[] = {
633 VCRunTimeProp, 631 VCRunTimeProp,
634 VCSnoozeTimeProp, 632 VCSnoozeTimeProp,
635 VCRepeatCountProp, 633 VCRepeatCountProp,
636 VCProcedureNameProp, 634 VCProcedureNameProp,
637 0 635 0
638 }; 636 };
639 637
640static struct PreDefProp propNames[] = { 638static struct PreDefProp propNames[] = {
641 { VC7bitProp, 0, 0, 0 }, 639 { VC7bitProp, 0, 0, 0 },
642 { VC8bitProp, 0, 0, 0 }, 640 { VC8bitProp, 0, 0, 0 },
643 { VCAAlarmProp, 0, AAlarmFields, 0 }, 641 { VCAAlarmProp, 0, AAlarmFields, 0 },
644 { VCAdditionalNamesProp, 0, 0, 0 }, 642 { VCAdditionalNamesProp, 0, 0, 0 },
645 { VCAdrProp, 0, adrFields, 0 }, 643 { VCAdrProp, 0, adrFields, 0 },
646 { VCAgentProp, 0, 0, 0 }, 644 { VCAgentProp, 0, 0, 0 },
647 { VCAIFFProp, 0, 0, 0 }, 645 { VCAIFFProp, 0, 0, 0 },
648 { VCAOLProp, 0, 0, 0 }, 646 { VCAOLProp, 0, 0, 0 },
649 { VCAppleLinkProp, 0, 0, 0 }, 647 { VCAppleLinkProp, 0, 0, 0 },
650 { VCAttachProp, 0, 0, 0 }, 648 { VCAttachProp, 0, 0, 0 },
651 { VCAttendeeProp, 0, 0, 0 }, 649 { VCAttendeeProp, 0, 0, 0 },
652 { VCATTMailProp, 0, 0, 0 }, 650 { VCATTMailProp, 0, 0, 0 },
653 { VCAudioContentProp, 0, 0, 0 }, 651 { VCAudioContentProp, 0, 0, 0 },
654 { VCAVIProp, 0, 0, 0 }, 652 { VCAVIProp, 0, 0, 0 },
655 { VCBase64Prop, 0, 0, 0 }, 653 { VCBase64Prop, 0, 0, 0 },
656 { VCBBSProp, 0, 0, 0 }, 654 { VCBBSProp, 0, 0, 0 },
657 { VCBirthDateProp, 0, 0, 0 }, 655 { VCBirthDateProp, 0, 0, 0 },
658 { VCBMPProp, 0, 0, 0 }, 656 { VCBMPProp, 0, 0, 0 },
659 { VCBodyProp, 0, 0, 0 }, 657 { VCBodyProp, 0, 0, 0 },
660 { VCBusinessRoleProp, 0, 0, 0 }, 658 { VCBusinessRoleProp, 0, 0, 0 },
661 { VCCalProp, 0, 0, PD_BEGIN }, 659 { VCCalProp, 0, 0, PD_BEGIN },
662 { VCCaptionProp, 0, 0, 0 }, 660 { VCCaptionProp, 0, 0, 0 },
663 { VCCardProp, 0, 0, PD_BEGIN }, 661 { VCCardProp, 0, 0, PD_BEGIN },
664 { VCCarProp, 0, 0, 0 }, 662 { VCCarProp, 0, 0, 0 },
665 { VCCategoriesProp, 0, 0, 0 }, 663 { VCCategoriesProp, 0, 0, 0 },
666 { VCCellularProp, 0, 0, 0 }, 664 { VCCellularProp, 0, 0, 0 },
667 { VCCGMProp, 0, 0, 0 }, 665 { VCCGMProp, 0, 0, 0 },
668 { VCCharSetProp, 0, 0, 0 }, 666 { VCCharSetProp, 0, 0, 0 },
669 { VCCIDProp, VCContentIDProp, 0, 0 }, 667 { VCCIDProp, VCContentIDProp, 0, 0 },
670 { VCCISProp, 0, 0, 0 }, 668 { VCCISProp, 0, 0, 0 },
671 { VCCityProp, 0, 0, 0 }, 669 { VCCityProp, 0, 0, 0 },
672 { VCClassProp, 0, 0, 0 }, 670 { VCClassProp, 0, 0, 0 },
673 { VCCommentProp, 0, 0, 0 }, 671 { VCCommentProp, 0, 0, 0 },
674 { VCCompletedProp, 0, 0, 0 }, 672 { VCCompletedProp, 0, 0, 0 },
675 { VCContentIDProp, 0, 0, 0 }, 673 { VCContentIDProp, 0, 0, 0 },
676 { VCCountryNameProp, 0, 0, 0 }, 674 { VCCountryNameProp, 0, 0, 0 },
677 { VCDAlarmProp, 0, DAlarmFields, 0 }, 675 { VCDAlarmProp, 0, DAlarmFields, 0 },
678 { VCDataSizeProp, 0, 0, PD_INTERNAL }, 676 { VCDataSizeProp, 0, 0, PD_INTERNAL },
679 { VCDayLightProp, 0, 0, 0 }, 677 { VCDayLightProp, 0, 0, 0 },
680 { VCDCreatedProp, 0, 0, 0 }, 678 { VCDCreatedProp, 0, 0, 0 },
681 { VCDeliveryLabelProp, 0, 0, 0 }, 679 { VCDeliveryLabelProp, 0, 0, 0 },
682 { VCDescriptionProp, 0, 0, 0 }, 680 { VCDescriptionProp, 0, 0, 0 },
683 { VCDIBProp, 0, 0, 0 }, 681 { VCDIBProp, 0, 0, 0 },
684 { VCDisplayStringProp, 0, 0, 0 }, 682 { VCDisplayStringProp, 0, 0, 0 },
685 { VCDomesticProp, 0, 0, 0 }, 683 { VCDomesticProp, 0, 0, 0 },
686 { VCDTendProp, 0, 0, 0 }, 684 { VCDTendProp, 0, 0, 0 },
687 { VCDTstartProp, 0, 0, 0 }, 685 { VCDTstartProp, 0, 0, 0 },
688 { VCDueProp, 0, 0, 0 }, 686 { VCDueProp, 0, 0, 0 },
689 { VCEmailAddressProp, 0, 0, 0 }, 687 { VCEmailAddressProp, 0, 0, 0 },
690 { VCEncodingProp, 0, 0, 0 }, 688 { VCEncodingProp, 0, 0, 0 },
691 { VCEndProp, 0, 0, 0 }, 689 { VCEndProp, 0, 0, 0 },
692 { VCEventProp, 0, 0, PD_BEGIN }, 690 { VCEventProp, 0, 0, PD_BEGIN },
693 { VCEWorldProp, 0, 0, 0 }, 691 { VCEWorldProp, 0, 0, 0 },
694 { VCExNumProp, 0, 0, 0 }, 692 { VCExNumProp, 0, 0, 0 },
695 { VCExpDateProp, 0, 0, 0 }, 693 { VCExpDateProp, 0, 0, 0 },
696 { VCExpectProp, 0, 0, 0 }, 694 { VCExpectProp, 0, 0, 0 },
697 { VCExtAddressProp, 0, 0, 0 }, 695 { VCExtAddressProp, 0, 0, 0 },
698 { VCFamilyNameProp, 0, 0, 0 }, 696 { VCFamilyNameProp, 0, 0, 0 },
699 { VCFaxProp, 0, 0, 0 }, 697 { VCFaxProp, 0, 0, 0 },
700 { VCFullNameProp, 0, 0, 0 }, 698 { VCFullNameProp, 0, 0, 0 },
701 { VCGeoLocationProp, 0, 0, 0 }, 699 { VCGeoLocationProp, 0, 0, 0 },
702 { VCGeoProp, 0, 0, 0 }, 700 { VCGeoProp, 0, 0, 0 },
703 { VCGIFProp, 0, 0, 0 }, 701 { VCGIFProp, 0, 0, 0 },
704 { VCGivenNameProp, 0, 0, 0 }, 702 { VCGivenNameProp, 0, 0, 0 },
705 { VCGroupingProp, 0, 0, 0 }, 703 { VCGroupingProp, 0, 0, 0 },
706 { VCHomeProp, 0, 0, 0 }, 704 { VCHomeProp, 0, 0, 0 },
707 { VCIBMMailProp, 0, 0, 0 }, 705 { VCIBMMailProp, 0, 0, 0 },
708 { VCInlineProp, 0, 0, 0 }, 706 { VCInlineProp, 0, 0, 0 },
709 { VCInternationalProp, 0, 0, 0 }, 707 { VCInternationalProp, 0, 0, 0 },
710 { VCInternetProp, 0, 0, 0 }, 708 { VCInternetProp, 0, 0, 0 },
711 { VCISDNProp, 0, 0, 0 }, 709 { VCISDNProp, 0, 0, 0 },
712 { VCJPEGProp, 0, 0, 0 }, 710 { VCJPEGProp, 0, 0, 0 },
713 { VCLanguageProp, 0, 0, 0 }, 711 { VCLanguageProp, 0, 0, 0 },
714 { VCLastModifiedProp, 0, 0, 0 }, 712 { VCLastModifiedProp, 0, 0, 0 },
715 { VCLastRevisedProp, 0, 0, 0 }, 713 { VCLastRevisedProp, 0, 0, 0 },
716 { VCLocationProp, 0, 0, 0 }, 714 { VCLocationProp, 0, 0, 0 },
717 { VCLogoProp, 0, 0, 0 }, 715 { VCLogoProp, 0, 0, 0 },
718 { VCMailerProp, 0, 0, 0 }, 716 { VCMailerProp, 0, 0, 0 },
719 { VCMAlarmProp, 0, MAlarmFields, 0 }, 717 { VCMAlarmProp, 0, MAlarmFields, 0 },
720 { VCMCIMailProp, 0, 0, 0 }, 718 { VCMCIMailProp, 0, 0, 0 },
721 { VCMessageProp, 0, 0, 0 }, 719 { VCMessageProp, 0, 0, 0 },
722 { VCMETProp, 0, 0, 0 }, 720 { VCMETProp, 0, 0, 0 },
723 { VCModemProp, 0, 0, 0 }, 721 { VCModemProp, 0, 0, 0 },
724 { VCMPEG2Prop, 0, 0, 0 }, 722 { VCMPEG2Prop, 0, 0, 0 },
725 { VCMPEGProp, 0, 0, 0 }, 723 { VCMPEGProp, 0, 0, 0 },
726 { VCMSNProp, 0, 0, 0 }, 724 { VCMSNProp, 0, 0, 0 },
727 { VCNamePrefixesProp, 0, 0, 0 }, 725 { VCNamePrefixesProp, 0, 0, 0 },
728 { VCNameProp, 0, nameFields, 0 }, 726 { VCNameProp, 0, nameFields, 0 },
729 { VCNameSuffixesProp, 0, 0, 0 }, 727 { VCNameSuffixesProp, 0, 0, 0 },
730 { VCNoteProp, 0, 0, 0 }, 728 { VCNoteProp, 0, 0, 0 },
731 { VCOrgNameProp, 0, 0, 0 }, 729 { VCOrgNameProp, 0, 0, 0 },
732 { VCOrgProp, 0, orgFields, 0 }, 730 { VCOrgProp, 0, orgFields, 0 },
733 { VCOrgUnit2Prop, 0, 0, 0 }, 731 { VCOrgUnit2Prop, 0, 0, 0 },
734 { VCOrgUnit3Prop, 0, 0, 0 }, 732 { VCOrgUnit3Prop, 0, 0, 0 },
735 { VCOrgUnit4Prop, 0, 0, 0 }, 733 { VCOrgUnit4Prop, 0, 0, 0 },
736 { VCOrgUnitProp, 0, 0, 0 }, 734 { VCOrgUnitProp, 0, 0, 0 },
737 { VCPagerProp, 0, 0, 0 }, 735 { VCPagerProp, 0, 0, 0 },
738 { VCPAlarmProp, 0, PAlarmFields, 0 }, 736 { VCPAlarmProp, 0, PAlarmFields, 0 },
739 { VCParcelProp, 0, 0, 0 }, 737 { VCParcelProp, 0, 0, 0 },
740 { VCPartProp, 0, 0, 0 }, 738 { VCPartProp, 0, 0, 0 },
741 { VCPCMProp, 0, 0, 0 }, 739 { VCPCMProp, 0, 0, 0 },
742 { VCPDFProp, 0, 0, 0 }, 740 { VCPDFProp, 0, 0, 0 },
743 { VCPGPProp, 0, 0, 0 }, 741 { VCPGPProp, 0, 0, 0 },
744 { VCPhotoProp, 0, 0, 0 }, 742 { VCPhotoProp, 0, 0, 0 },
745 { VCPICTProp, 0, 0, 0 }, 743 { VCPICTProp, 0, 0, 0 },
746 { VCPMBProp, 0, 0, 0 }, 744 { VCPMBProp, 0, 0, 0 },
747 { VCPostalBoxProp, 0, 0, 0 }, 745 { VCPostalBoxProp, 0, 0, 0 },
748 { VCPostalCodeProp, 0, 0, 0 }, 746 { VCPostalCodeProp, 0, 0, 0 },
749 { VCPostalProp, 0, 0, 0 }, 747 { VCPostalProp, 0, 0, 0 },
750 { VCPowerShareProp, 0, 0, 0 }, 748 { VCPowerShareProp, 0, 0, 0 },
751 { VCPreferredProp, 0, 0, 0 }, 749 { VCPreferredProp, 0, 0, 0 },
752 { VCPriorityProp, 0, 0, 0 }, 750 { VCPriorityProp, 0, 0, 0 },
753 { VCProcedureNameProp, 0, 0, 0 }, 751 { VCProcedureNameProp, 0, 0, 0 },
754 { VCProdIdProp, 0, 0, 0 }, 752 { VCProdIdProp, 0, 0, 0 },
755 { VCProdigyProp, 0, 0, 0 }, 753 { VCProdigyProp, 0, 0, 0 },
756 { VCPronunciationProp, 0, 0, 0 }, 754 { VCPronunciationProp, 0, 0, 0 },
757 { VCPSProp, 0, 0, 0 }, 755 { VCPSProp, 0, 0, 0 },
758 { VCPublicKeyProp, 0, 0, 0 }, 756 { VCPublicKeyProp, 0, 0, 0 },
759 { VCQPProp, VCQuotedPrintableProp, 0, 0 }, 757 { VCQPProp, VCQuotedPrintableProp, 0, 0 },
760 { VCQPProp, VCBase64Prop, 0, 0 },
761 { VCQuickTimeProp, 0, 0, 0 }, 758 { VCQuickTimeProp, 0, 0, 0 },
762 { VCQuotedPrintableProp, 0, 0, 0 }, 759 { VCQuotedPrintableProp, 0, 0, 0 },
763 { VCRDateProp, 0, 0, 0 }, 760 { VCRDateProp, 0, 0, 0 },
764 { VCRegionProp, 0, 0, 0 }, 761 { VCRegionProp, 0, 0, 0 },
765 { VCRelatedToProp, 0, 0, 0 }, 762 { VCRelatedToProp, 0, 0, 0 },
766 { VCRepeatCountProp, 0, 0, 0 }, 763 { VCRepeatCountProp, 0, 0, 0 },
767 { VCResourcesProp, 0, 0, 0 }, 764 { VCResourcesProp, 0, 0, 0 },
768 { VCRNumProp, 0, 0, 0 }, 765 { VCRNumProp, 0, 0, 0 },
769 { VCRoleProp, 0, 0, 0 }, 766 { VCRoleProp, 0, 0, 0 },
770 { VCRRuleProp, 0, 0, 0 }, 767 { VCRRuleProp, 0, 0, 0 },
771 { VCRSVPProp, 0, 0, 0 }, 768 { VCRSVPProp, 0, 0, 0 },
772 { VCRunTimeProp, 0, 0, 0 }, 769 { VCRunTimeProp, 0, 0, 0 },
773 { VCSequenceProp, 0, 0, 0 }, 770 { VCSequenceProp, 0, 0, 0 },
774 { VCSnoozeTimeProp, 0, 0, 0 }, 771 { VCSnoozeTimeProp, 0, 0, 0 },
775 { VCStartProp, 0, 0, 0 }, 772 { VCStartProp, 0, 0, 0 },
776 { VCStatusProp, 0, 0, 0 }, 773 { VCStatusProp, 0, 0, 0 },
777 { VCStreetAddressProp, 0, 0, 0 }, 774 { VCStreetAddressProp, 0, 0, 0 },
778 { VCSubTypeProp, 0, 0, 0 }, 775 { VCSubTypeProp, 0, 0, 0 },
779 { VCSummaryProp, 0, 0, 0 }, 776 { VCSummaryProp, 0, 0, 0 },
780 { VCTelephoneProp, 0, 0, 0 }, 777 { VCTelephoneProp, 0, 0, 0 },
781 { VCTIFFProp, 0, 0, 0 }, 778 { VCTIFFProp, 0, 0, 0 },
782 { VCTimeZoneProp, 0, 0, 0 }, 779 { VCTimeZoneProp, 0, 0, 0 },
783 { VCTitleProp, 0, 0, 0 }, 780 { VCTitleProp, 0, 0, 0 },
784 { VCTLXProp, 0, 0, 0 }, 781 { VCTLXProp, 0, 0, 0 },
785 { VCTodoProp, 0, 0, PD_BEGIN }, 782 { VCTodoProp, 0, 0, PD_BEGIN },
786 { VCTranspProp, 0, 0, 0 }, 783 { VCTranspProp, 0, 0, 0 },
787 { VCUniqueStringProp, 0, 0, 0 }, 784 { VCUniqueStringProp, 0, 0, 0 },
788 { VCURLProp, 0, 0, 0 }, 785 { VCURLProp, 0, 0, 0 },
789 { VCURLValueProp, 0, 0, 0 }, 786 { VCURLValueProp, 0, 0, 0 },
790 { VCValueProp, 0, 0, 0 }, 787 { VCValueProp, 0, 0, 0 },
791 { VCVersionProp, 0, 0, 0 }, 788 { VCVersionProp, 0, 0, 0 },
792 { VCVideoProp, 0, 0, 0 }, 789 { VCVideoProp, 0, 0, 0 },
793 { VCVoiceProp, 0, 0, 0 }, 790 { VCVoiceProp, 0, 0, 0 },
794 { VCWAVEProp, 0, 0, 0 }, 791 { VCWAVEProp, 0, 0, 0 },
795 { VCWMFProp, 0, 0, 0 }, 792 { VCWMFProp, 0, 0, 0 },
796 { VCWorkProp, 0, 0, 0 }, 793 { VCWorkProp, 0, 0, 0 },
797 { VCX400Prop, 0, 0, 0 }, 794 { VCX400Prop, 0, 0, 0 },
798 { VCX509Prop, 0, 0, 0 }, 795 { VCX509Prop, 0, 0, 0 },
799 { VCXRuleProp, 0, 0, 0 }, 796 { VCXRuleProp, 0, 0, 0 },
800 { 0,0,0,0 } 797 { 0,0,0,0 }
801 }; 798 };
802 799
803 800
804static struct PreDefProp* lookupPropInfo(const char* str) 801static struct PreDefProp* lookupPropInfo(const char* str)
805{ 802{
806 /* brute force for now, could use a hash table here. */ 803 /* brute force for now, could use a hash table here. */
807 int i; 804 int i;
808 805
809 for (i = 0; propNames[i].name; i++) 806 for (i = 0; propNames[i].name; i++)
810 if (qstricmp(str, propNames[i].name) == 0) { 807 if (qstricmp(str, propNames[i].name) == 0) {
811 return &propNames[i]; 808 return &propNames[i];
812 } 809 }
813 810
814 return 0; 811 return 0;
815} 812}
816 813
817 814
818DLLEXPORT(const char*) lookupProp_(const char* str) 815DLLEXPORT(const char*) lookupProp_(const char* str)
819{ 816{
820 int i; 817 int i;
821 818
822 for (i = 0; propNames[i].name; i++) 819 for (i = 0; propNames[i].name; i++)
823 if (qstricmp(str, propNames[i].name) == 0) { 820 if (qstricmp(str, propNames[i].name) == 0) {
824 const char* s; 821 const char* s;
825 s = propNames[i].alias?propNames[i].alias:propNames[i].name; 822 s = propNames[i].alias?propNames[i].alias:propNames[i].name;
826 return lookupStr(s); 823 return lookupStr(s);
827 } 824 }
828 return lookupStr(str); 825 return lookupStr(str);
829} 826}
830 827
831 828
832DLLEXPORT(const char*) lookupProp(const char* str) 829DLLEXPORT(const char*) lookupProp(const char* str)
833{ 830{
834 int i; 831 int i;
835 832
836 for (i = 0; propNames[i].name; i++) 833 for (i = 0; propNames[i].name; i++)
837 if (qstricmp(str, propNames[i].name) == 0) { 834 if (qstricmp(str, propNames[i].name) == 0) {
838 const char *s; 835 const char *s;
839 fieldedProp = propNames[i].fields; 836 fieldedProp = propNames[i].fields;
840 s = propNames[i].alias?propNames[i].alias:propNames[i].name; 837 s = propNames[i].alias?propNames[i].alias:propNames[i].name;
841 return lookupStr(s); 838 return lookupStr(s);
842 } 839 }
843 fieldedProp = 0; 840 fieldedProp = 0;
844 return lookupStr(str); 841 return lookupStr(str);
845} 842}
846 843
847 844
848/*---------------------------------------------------------------------- 845/*----------------------------------------------------------------------
849 APIs to Output text form. 846 APIs to Output text form.
850 ----------------------------------------------------------------------*/ 847 ----------------------------------------------------------------------*/
851#define OFILE_REALLOC_SIZE 256 848#define OFILE_REALLOC_SIZE 256
852typedef struct OFile { 849typedef struct OFile {
853 FILE *fp; 850 FILE *fp;
854 char *s; 851 char *s;
855 int len; 852 int len;
856 int limit; 853 int limit;
857 int alloc:1; 854 int alloc:1;
858 int fail:1; 855 int fail:1;
859 } OFile; 856 } OFile;
860 857
861#if 0 858#if 0
862static void appendsOFile(OFile *fp, const char *s) 859static void appendsOFile(OFile *fp, const char *s)
863{ 860{
864 int slen; 861 int slen;
865 if (fp->fail) return; 862 if (fp->fail) return;
866 slen = strlen(s); 863 slen = strlen(s);
867 if (fp->fp) { 864 if (fp->fp) {
868 fwrite(s,1,slen,fp->fp); 865 fwrite(s,1,slen,fp->fp);
869 } 866 }
870 else { 867 else {
871stuff: 868stuff:
872 if (fp->len + slen < fp->limit) { 869 if (fp->len + slen < fp->limit) {
873 memcpy(fp->s+fp->len,s,slen); 870 memcpy(fp->s+fp->len,s,slen);
874 fp->len += slen; 871 fp->len += slen;
875 return; 872 return;
876 } 873 }
877 else if (fp->alloc) { 874 else if (fp->alloc) {
878 fp->limit = fp->limit + OFILE_REALLOC_SIZE; 875 fp->limit = fp->limit + OFILE_REALLOC_SIZE;
879 if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen; 876 if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen;
880 fp->s = (char *) realloc(fp->s,fp->limit); 877 fp->s = (char *) realloc(fp->s,fp->limit);
881 if (fp->s) goto stuff; 878 if (fp->s) goto stuff;
882 } 879 }
883 if (fp->alloc) 880 if (fp->alloc)
884 free(fp->s); 881 free(fp->s);
885 fp->s = 0; 882 fp->s = 0;
886 fp->fail = 1; 883 fp->fail = 1;
887 } 884 }
888} 885}
889 886
890static void appendcOFile(OFile *fp, char c) 887static void appendcOFile(OFile *fp, char c)
891{ 888{
892 if (fp->fail) return; 889 if (fp->fail) return;
893 if (fp->fp) { 890 if (fp->fp) {
894 fputc(c,fp->fp); 891 fputc(c,fp->fp);
895 } 892 }
896 else { 893 else {
897stuff: 894stuff:
898 if (fp->len+1 < fp->limit) { 895 if (fp->len+1 < fp->limit) {
899 fp->s[fp->len] = c; 896 fp->s[fp->len] = c;
900 fp->len++; 897 fp->len++;
901 return; 898 return;
902 } 899 }
903 else if (fp->alloc) { 900 else if (fp->alloc) {
904 fp->limit = fp->limit + OFILE_REALLOC_SIZE; 901 fp->limit = fp->limit + OFILE_REALLOC_SIZE;
905 fp->s = (char *) realloc(fp->s,fp->limit); 902 fp->s = (char *) realloc(fp->s,fp->limit);
906 if (fp->s) goto stuff; 903 if (fp->s) goto stuff;
907 } 904 }
908 if (fp->alloc) 905 if (fp->alloc)
909 free(fp->s); 906 free(fp->s);
910 fp->s = 0; 907 fp->s = 0;
911 fp->fail = 1; 908 fp->fail = 1;
912 } 909 }
913} 910}
914#else 911#else
915static void appendcOFile_(OFile *fp, char c) 912static void appendcOFile_(OFile *fp, char c)
916{ 913{
917 if (fp->fail) return; 914 if (fp->fail) return;
918 if (fp->fp) { 915 if (fp->fp) {
919 fputc(c,fp->fp); 916 fputc(c,fp->fp);
920 } 917 }
921 else { 918 else {
922stuff: 919stuff:
923 if (fp->len+1 < fp->limit) { 920 if (fp->len+1 < fp->limit) {
924 fp->s[fp->len] = c; 921 fp->s[fp->len] = c;
925 fp->len++; 922 fp->len++;
926 return; 923 return;
927 } 924 }
928 else if (fp->alloc) { 925 else if (fp->alloc) {
929 fp->limit = fp->limit + OFILE_REALLOC_SIZE; 926 fp->limit = fp->limit + OFILE_REALLOC_SIZE;
930 fp->s = (char *)realloc(fp->s,fp->limit); 927 fp->s = (char *)realloc(fp->s,fp->limit);
931 if (fp->s) goto stuff; 928 if (fp->s) goto stuff;
932 } 929 }
933 if (fp->alloc) 930 if (fp->alloc)
934 free(fp->s); 931 free(fp->s);
935 fp->s = 0; 932 fp->s = 0;
936 fp->fail = 1; 933 fp->fail = 1;
937 } 934 }
938} 935}
939 936
940static void appendcOFile(OFile *fp, char c) 937static void appendcOFile(OFile *fp, char c)
941{ 938{
942 if (c == '\n') { 939 if (c == '\n') {
943 /* write out as <CR><LF> */ 940 /* write out as <CR><LF> */
944 appendcOFile_(fp,0xd); 941 appendcOFile_(fp,0xd);
945 appendcOFile_(fp,0xa); 942 appendcOFile_(fp,0xa);
946 } 943 }
947 else 944 else
948 appendcOFile_(fp,c); 945 appendcOFile_(fp,c);
949} 946}
950 947
951static void appendsOFile(OFile *fp, const char *s) 948static void appendsOFile(OFile *fp, const char *s)
952{ 949{
953 int i, slen; 950 int i, slen;
954 slen = strlen(s); 951 slen = strlen(s);
955 for (i=0; i<slen; i++) { 952 for (i=0; i<slen; i++) {
956 appendcOFile(fp,s[i]); 953 appendcOFile(fp,s[i]);
957 } 954 }
958} 955}
959 956
960#endif 957#endif
961 958
962static void appendsOFileEncCs(OFile *fp) 959static void appendsOFileEncCs(OFile *fp)
963{ 960{
964 if ( vobj_enc_s ) { 961 if ( vobj_enc_s ) {
965 appendsOFile(fp, ";" VCEncodingProp "="); 962 appendsOFile(fp, ";" VCEncodingProp "=");
966 appendsOFile(fp, vobj_enc_s); 963 appendsOFile(fp, vobj_enc_s);
967 } 964 }
968 appendsOFile(fp, ";" VCCharSetProp "="); 965 appendsOFile(fp, ";" VCCharSetProp "=");
969 appendsOFile(fp, vobj_cs); 966 appendsOFile(fp, vobj_cs);
970} 967}
971 968
972 969
973static void initOFile(OFile *fp, FILE *ofp) 970static void initOFile(OFile *fp, FILE *ofp)
974{ 971{
975 fp->fp = ofp; 972 fp->fp = ofp;
976 fp->s = 0; 973 fp->s = 0;
977 fp->len = 0; 974 fp->len = 0;
978 fp->limit = 0; 975 fp->limit = 0;
979 fp->alloc = 0; 976 fp->alloc = 0;
980 fp->fail = 0; 977 fp->fail = 0;
981} 978}
982 979
983static int writeBase64(OFile *fp, unsigned char *s, long len) 980static int writeBase64(OFile *fp, unsigned char *s, long len)
984{ 981{
985 long cur = 0; 982 long cur = 0;
986 int i, numQuads = 0; 983 int i, numQuads = 0;
987 unsigned long trip; 984 unsigned long trip;
988 unsigned char b; 985 unsigned char b;
989 char quad[5]; 986 char quad[5];
990#define MAXQUADS 16 987#define MAXQUADS 16
991 988
992 quad[4] = 0; 989 quad[4] = 0;
993 990
994 while (cur < len) { 991 while (cur < len) {
995 // collect the triplet of bytes into 'trip' 992 // collect the triplet of bytes into 'trip'
996 trip = 0; 993 trip = 0;
997 for (i = 0; i < 3; i++) { 994 for (i = 0; i < 3; i++) {
998 b = (cur < len) ? *(s + cur) : 0; 995 b = (cur < len) ? *(s + cur) : 0;
999 cur++; 996 cur++;
1000 trip = trip << 8 | b; 997 trip = trip << 8 | b;
1001 } 998 }
1002 // fill in 'quad' with the appropriate four characters 999 // fill in 'quad' with the appropriate four characters
1003 for (i = 3; i >= 0; i--) { 1000 for (i = 3; i >= 0; i--) {
1004 b = (unsigned char)(trip & 0x3F); 1001 b = (unsigned char)(trip & 0x3F);
1005 trip = trip >> 6; 1002 trip = trip >> 6;
1006 if ((3 - i) < (cur - len)) 1003 if ((3 - i) < (cur - len))
1007 quad[i] = '='; // pad char 1004 quad[i] = '='; // pad char
1008 else if (b < 26) quad[i] = (char)b + 'A'; 1005 else if (b < 26) quad[i] = (char)b + 'A';
1009 else if (b < 52) quad[i] = (char)(b - 26) + 'a'; 1006 else if (b < 52) quad[i] = (char)(b - 26) + 'a';
1010 else if (b < 62) quad[i] = (char)(b - 52) + '0'; 1007 else if (b < 62) quad[i] = (char)(b - 52) + '0';
1011 else if (b == 62) quad[i] = '+'; 1008 else if (b == 62) quad[i] = '+';
1012 else quad[i] = '/'; 1009 else quad[i] = '/';
1013 } 1010 }
1014 // now output 'quad' with appropriate whitespace and line ending 1011 // now output 'quad' with appropriate whitespace and line ending
1015 appendsOFile(fp, (numQuads == 0 ? " " : "")); 1012 appendsOFile(fp, (numQuads == 0 ? " " : ""));
1016 appendsOFile(fp, quad); 1013 appendsOFile(fp, quad);
1017 appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : ""))); 1014 appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : "")));
1018 numQuads = (numQuads + 1) % MAXQUADS; 1015 numQuads = (numQuads + 1) % MAXQUADS;
1019 } 1016 }
1020 appendcOFile(fp,'\n'); 1017 appendcOFile(fp,'\n');
1021 1018
1022 return 1; 1019 return 1;
1023} 1020}
1024 1021
1025static const char *qpReplaceChar(unsigned char c) 1022static const char *qpReplaceChar(unsigned char c)
1026{ 1023{
1027 if (c == '\n') { 1024 if (c == '\n') {
1028 return "=0A=\n"; 1025 return "=0A=\n";
1029 } else if ( 1026 } else if (
1030 // RFC 1521 1027 // RFC 1521
1031 (c >= 32 && c <= 60) // Note: " " not allowed at EOL 1028 (c >= 32 && c <= 60) // Note: " " not allowed at EOL
1032 || 1029 ||
1033 (c >= 62 && c <= 126) 1030 (c >= 62 && c <= 126)
1034 ) 1031 )
1035 { 1032 {
1036 return 0; 1033 return 0;
1037 } 1034 }
1038 1035
1039 static char trans[4]; 1036 static char trans[4];
1040 trans[0] = '='; 1037 trans[0] = '=';
1041 trans[3] = '\0'; 1038 trans[3] = '\0';
1042 int rem = c % 16; 1039 int rem = c % 16;
1043 int div = c / 16; 1040 int div = c / 16;
1044 1041
1045 if (div < 10) 1042 if (div < 10)
1046 trans[1] = '0' + div; 1043 trans[1] = '0' + div;
1047 else 1044 else
1048 trans[1] = 'A' + (div - 10); 1045 trans[1] = 'A' + (div - 10);
1049 1046
1050 if (rem < 10) 1047 if (rem < 10)
1051 trans[2] = '0' + rem; 1048 trans[2] = '0' + rem;
1052 else 1049 else
1053 trans[2] = 'A' + (rem - 10); 1050 trans[2] = 'A' + (rem - 10);
1054 1051
1055 return trans; 1052 return trans;
1056} 1053}
1057 1054
1058static void writeEncString(OFile *fp, const char *s, bool nosemi) 1055static void writeEncString(OFile *fp, const char *s, bool nosemi)
1059{ 1056{
1060 /* 1057 /*
1061 only A-Z, 0-9 and 1058 only A-Z, 0-9 and
1062 "'" (ASCII code 39) 1059 "'" (ASCII code 39)
1063 "(" (ASCII code 40) 1060 "(" (ASCII code 40)
1064 ")" (ASCII code 41) 1061 ")" (ASCII code 41)
1065 "+" (ASCII code 43) 1062 "+" (ASCII code 43)
1066 "," (ASCII code 44) 1063 "," (ASCII code 44)
1067 "-" (ASCII code 45) 1064 "-" (ASCII code 45)
1068 "/" (ASCII code 47) 1065 "/" (ASCII code 47)
1069 "?" (ASCII code 63) 1066 "?" (ASCII code 63)
1070 1067
1071 should remain un-encoded. 1068 should remain un-encoded.
1072 '=' needs to be encoded as it is the escape character. 1069 '=' needs to be encoded as it is the escape character.
1073 ';' needs to be as it is a field separator. 1070 ';' needs to be as it is a field separator.
1074 1071
1075 */ 1072 */
1076 const char *p = s; 1073 const char *p = s;
1077 switch ( vobj_enc ) { 1074 switch ( vobj_enc ) {
1078 case EightBit: 1075 case EightBit:
1079 while (*p) { 1076 while (*p) {
1080 if ( *p == '\n' || nosemi && ( *p == '\\' || *p == ';' ) ) 1077 if ( *p == '\n' || nosemi && ( *p == '\\' || *p == ';' ) )
1081 appendcOFile(fp, '\\'); 1078 appendcOFile(fp, '\\');
1082 appendcOFile(fp, *p); 1079 appendcOFile(fp, *p);
1083 p++; 1080 p++;
1084 } 1081 }
1085 break; 1082 break;
1086 case QuotedPrintable: 1083 case QuotedPrintable:
1087 while (*p) { 1084 while (*p) {
1088 const char *rep = qpReplaceChar(*p); 1085 const char *rep = qpReplaceChar(*p);
1089 if (rep) 1086 if (rep)
1090 appendsOFile(fp, rep); 1087 appendsOFile(fp, rep);
1091 else if ( *p == ';' && nosemi ) 1088 else if ( *p == ';' && nosemi )
1092 appendsOFile(fp, "=3B"); 1089 appendsOFile(fp, "=3B");
1093 else if ( *p == ' ' ) { 1090 else if ( *p == ' ' ) {
1094 if ( !p[1] || p[1] == '\n' ) // RFC 1521 1091 if ( !p[1] || p[1] == '\n' ) // RFC 1521
1095 appendsOFile(fp, "=20"); 1092 appendsOFile(fp, "=20");
1096 else 1093 else
1097 appendcOFile(fp, *p); 1094 appendcOFile(fp, *p);
1098 } else 1095 } else
1099 appendcOFile(fp, *p); 1096 appendcOFile(fp, *p);
1100 p++; 1097 p++;
1101 } 1098 }
1102 break; 1099 break;
1103 case Base64: 1100 case Base64:
1104 writeBase64(fp, (unsigned char*)p, strlen(p)); 1101 writeBase64(fp, (unsigned char*)p, strlen(p));
1105 break; 1102 break;
1106 } 1103 }
1107} 1104}
1108 1105
1109static bool includesUnprintable(VObject *o) 1106static bool includesUnprintable(VObject *o)
1110{ 1107{
1111 if (o) { 1108 if (o) {
1112 if (VALUE_TYPE(o) == VCVT_STRINGZ) { 1109 if (VALUE_TYPE(o) == VCVT_STRINGZ) {
1113 const char *p = STRINGZ_VALUE_OF(o); 1110 const char *p = STRINGZ_VALUE_OF(o);
1114 if (p) { 1111 if (p) {
1115 while (*p) { 1112 while (*p) {
1116 if (*p==' ' && (!p[1] || p[1]=='\n') // RFC 1521: spaces at ends need quoting 1113 if (*p==' ' && (!p[1] || p[1]=='\n') // RFC 1521: spaces at ends need quoting
1117 || qpReplaceChar(*p) ) 1114 || qpReplaceChar(*p) )
1118 return TRUE; 1115 return TRUE;
1119 p++; 1116 p++;
1120 } 1117 }
1121 } 1118 }
1122 } 1119 }
1123 } 1120 }
1124 return FALSE; 1121 return FALSE;
1125} 1122}
1126 1123
1127static void writeVObject_(OFile *fp, VObject *o); 1124static void writeVObject_(OFile *fp, VObject *o);
1128 1125
1129static void writeValue(OFile *fp, VObject *o, unsigned long size, bool nosemi) 1126static void writeValue(OFile *fp, VObject *o, unsigned long size, bool nosemi)
1130{ 1127{
1131 if (o == 0) return; 1128 if (o == 0) return;
1132 switch (VALUE_TYPE(o)) { 1129 switch (VALUE_TYPE(o)) {
1133 case VCVT_STRINGZ: { 1130 case VCVT_STRINGZ: {
1134 writeEncString(fp, STRINGZ_VALUE_OF(o), nosemi); 1131 writeEncString(fp, STRINGZ_VALUE_OF(o), nosemi);
1135 break; 1132 break;
1136 } 1133 }
1137 case VCVT_UINT: { 1134 case VCVT_UINT: {
1138 char buf[16]; 1135 char buf[16];
1139 sprintf(buf,"%u", INTEGER_VALUE_OF(o)); 1136 sprintf(buf,"%u", INTEGER_VALUE_OF(o));
1140 appendsOFile(fp,buf); 1137 appendsOFile(fp,buf);
1141 break; 1138 break;
1142 } 1139 }
1143 case VCVT_ULONG: { 1140 case VCVT_ULONG: {
1144 char buf[16]; 1141 char buf[16];
1145 sprintf(buf,"%lu", LONG_VALUE_OF(o)); 1142 sprintf(buf,"%lu", LONG_VALUE_OF(o));
1146 appendsOFile(fp,buf); 1143 appendsOFile(fp,buf);
1147 break; 1144 break;
1148 } 1145 }
1149 case VCVT_RAW: { 1146 case VCVT_RAW: {
1150 appendcOFile(fp,'\n'); 1147 appendcOFile(fp,'\n');
1151 writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); 1148 writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size);
1152 break; 1149 break;
1153 } 1150 }
1154 case VCVT_VOBJECT: 1151 case VCVT_VOBJECT:
1155 appendcOFile(fp,'\n'); 1152 appendcOFile(fp,'\n');
1156 writeVObject_(fp,VOBJECT_VALUE_OF(o)); 1153 writeVObject_(fp,VOBJECT_VALUE_OF(o));
1157 break; 1154 break;
1158 } 1155 }
1159} 1156}
1160 1157
1161static void writeAttrValue(OFile *fp, VObject *o) 1158static void writeAttrValue(OFile *fp, VObject *o)
1162{ 1159{
1163 if (NAME_OF(o)) { 1160 if (NAME_OF(o)) {
1164 struct PreDefProp *pi; 1161 struct PreDefProp *pi;
1165 pi = lookupPropInfo(NAME_OF(o)); 1162 pi = lookupPropInfo(NAME_OF(o));
1166 if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; 1163 if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
1167 if ( includesUnprintable(o) ) 1164 if ( includesUnprintable(o) )
1168 appendsOFileEncCs(fp); 1165 appendsOFileEncCs(fp);
1169 appendcOFile(fp,';'); 1166 appendcOFile(fp,';');
1170 appendsOFile(fp,NAME_OF(o)); 1167 appendsOFile(fp,NAME_OF(o));
1171 } else { 1168 } else {
1172 appendcOFile(fp,';'); 1169 appendcOFile(fp,';');
1173 } 1170 }
1174 if (VALUE_TYPE(o)) { 1171 if (VALUE_TYPE(o)) {
1175 appendcOFile(fp,'='); 1172 appendcOFile(fp,'=');
1176 writeValue(fp,o,0,TRUE); 1173 writeValue(fp,o,0,TRUE);
1177 } 1174 }
1178} 1175}
1179 1176
1180static void writeGroup(OFile *fp, VObject *o) 1177static void writeGroup(OFile *fp, VObject *o)
1181{ 1178{
1182 char buf1[256]; 1179 char buf1[256];
1183 char buf2[256]; 1180 char buf2[256];
1184 strcpy(buf1,NAME_OF(o)); 1181 strcpy(buf1,NAME_OF(o));
1185 while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { 1182 while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
1186 strcpy(buf2,STRINGZ_VALUE_OF(o)); 1183 strcpy(buf2,STRINGZ_VALUE_OF(o));
1187 strcat(buf2,"."); 1184 strcat(buf2,".");
1188 strcat(buf2,buf1); 1185 strcat(buf2,buf1);
1189 strcpy(buf1,buf2); 1186 strcpy(buf1,buf2);
1190 } 1187 }
1191 appendsOFile(fp,buf1); 1188 appendsOFile(fp,buf1);
1192} 1189}
1193 1190
1194static int inList(const char **list, const char *s) 1191static int inList(const char **list, const char *s)
1195{ 1192{
1196 if (list == 0) return 0; 1193 if (list == 0) return 0;
1197 while (*list) { 1194 while (*list) {
1198 if (qstricmp(*list,s) == 0) return 1; 1195 if (qstricmp(*list,s) == 0) return 1;
1199 list++; 1196 list++;
1200 } 1197 }
1201 return 0; 1198 return 0;
1202} 1199}
1203 1200
1204static void writeProp(OFile *fp, VObject *o) 1201static void writeProp(OFile *fp, VObject *o)
1205{ 1202{
1206 if (NAME_OF(o)) { 1203 if (NAME_OF(o)) {
1207 struct PreDefProp *pi; 1204 struct PreDefProp *pi;
1208 VObjectIterator t; 1205 VObjectIterator t;
1209 const char **fields_ = 0; 1206 const char **fields_ = 0;
1210 pi = lookupPropInfo(NAME_OF(o)); 1207 pi = lookupPropInfo(NAME_OF(o));
1211 if (pi && ((pi->flags & PD_BEGIN) != 0)) { 1208 if (pi && ((pi->flags & PD_BEGIN) != 0)) {
1212 writeVObject_(fp,o); 1209 writeVObject_(fp,o);
1213 return; 1210 return;
1214 } 1211 }
1215 if (isAPropertyOf(o,VCGroupingProp)) 1212 if (isAPropertyOf(o,VCGroupingProp))
1216 writeGroup(fp,o); 1213 writeGroup(fp,o);
1217 else 1214 else
1218 appendsOFile(fp,NAME_OF(o)); 1215 appendsOFile(fp,NAME_OF(o));
1219 if (pi) fields_ = pi->fields; 1216 if (pi) fields_ = pi->fields;
1220 initPropIterator(&t,o); 1217 initPropIterator(&t,o);
1221 while (moreIteration(&t)) { 1218 while (moreIteration(&t)) {
1222 const char *s; 1219 const char *s;
1223 VObject *eachProp = nextVObject(&t); 1220 VObject *eachProp = nextVObject(&t);
1224 s = NAME_OF(eachProp); 1221 s = NAME_OF(eachProp);
1225 if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) 1222 if (qstricmp(VCGroupingProp,s) && !inList(fields_,s))
1226 writeAttrValue(fp,eachProp); 1223 writeAttrValue(fp,eachProp);
1227 } 1224 }
1228 if (fields_) { 1225 if (fields_) {
1229 int i = 0, n = 0; 1226 int i = 0, n = 0;
1230 const char** fields = fields_; 1227 const char** fields = fields_;
1231 /* output prop as fields */ 1228 /* output prop as fields */
1232 bool printable = TRUE; 1229 bool printable = TRUE;
1233 while (*fields && printable) { 1230 while (*fields && printable) {
1234 VObject *t = isAPropertyOf(o,*fields); 1231 VObject *t = isAPropertyOf(o,*fields);
1235 if (includesUnprintable(t)) 1232 if (includesUnprintable(t))
1236 printable = FALSE; 1233 printable = FALSE;
1237 fields++; 1234 fields++;
1238 } 1235 }
1239 fields = fields_; 1236 fields = fields_;
1240 if (!printable) 1237 if (!printable)
1241 appendsOFileEncCs(fp); 1238 appendsOFileEncCs(fp);
1242 appendcOFile(fp,':'); 1239 appendcOFile(fp,':');
1243 while (*fields) { 1240 while (*fields) {
1244 VObject *t = isAPropertyOf(o,*fields); 1241 VObject *t = isAPropertyOf(o,*fields);
1245 i++; 1242 i++;
1246 if (t) n = i; 1243 if (t) n = i;
1247 fields++; 1244 fields++;
1248 } 1245 }
1249 fields = fields_; 1246 fields = fields_;
1250 for (i=0;i<n;i++) { 1247 for (i=0;i<n;i++) {
1251 writeValue(fp,isAPropertyOf(o,*fields),0,TRUE); 1248 writeValue(fp,isAPropertyOf(o,*fields),0,TRUE);
1252 fields++; 1249 fields++;
1253 if (i<(n-1)) appendcOFile(fp,';'); 1250 if (i<(n-1)) appendcOFile(fp,';');
1254 } 1251 }
1255 } 1252 }
1256 } 1253 }
1257 1254
1258 1255
1259 if (VALUE_TYPE(o)) { 1256 if (VALUE_TYPE(o)) {
1260 if ( includesUnprintable(o) ) 1257 if ( includesUnprintable(o) )
1261 appendsOFileEncCs(fp); 1258 appendsOFileEncCs(fp);
1262 unsigned long size = 0; 1259 unsigned long size = 0;
1263 VObject *p = isAPropertyOf(o,VCDataSizeProp); 1260 VObject *p = isAPropertyOf(o,VCDataSizeProp);
1264 if (p) size = LONG_VALUE_OF(p); 1261 if (p) size = LONG_VALUE_OF(p);
1265 appendcOFile(fp,':'); 1262 appendcOFile(fp,':');
1266 writeValue(fp,o,size,FALSE); 1263 writeValue(fp,o,size,FALSE);
1267 } 1264 }
1268 1265
1269 appendcOFile(fp,'\n'); 1266 appendcOFile(fp,'\n');
1270} 1267}
1271 1268
1272static void writeVObject_(OFile *fp, VObject *o) 1269static void writeVObject_(OFile *fp, VObject *o)
1273{ 1270{
1274 if (NAME_OF(o)) { 1271 if (NAME_OF(o)) {
1275 struct PreDefProp *pi; 1272 struct PreDefProp *pi;
1276 pi = lookupPropInfo(NAME_OF(o)); 1273 pi = lookupPropInfo(NAME_OF(o));
1277 1274
1278 if (pi && ((pi->flags & PD_BEGIN) != 0)) { 1275 if (pi && ((pi->flags & PD_BEGIN) != 0)) {
1279 VObjectIterator t; 1276 VObjectIterator t;
1280 const char *begin = NAME_OF(o); 1277 const char *begin = NAME_OF(o);
1281 appendsOFile(fp,"BEGIN:"); 1278 appendsOFile(fp,"BEGIN:");
1282 appendsOFile(fp,begin); 1279 appendsOFile(fp,begin);
1283 appendcOFile(fp,'\n'); 1280 appendcOFile(fp,'\n');
1284 initPropIterator(&t,o); 1281 initPropIterator(&t,o);
1285 while (moreIteration(&t)) { 1282 while (moreIteration(&t)) {
1286 VObject *eachProp = nextVObject(&t); 1283 VObject *eachProp = nextVObject(&t);
1287 writeProp(fp, eachProp); 1284 writeProp(fp, eachProp);
1288 } 1285 }
1289 appendsOFile(fp,"END:"); 1286 appendsOFile(fp,"END:");
1290 appendsOFile(fp,begin); 1287 appendsOFile(fp,begin);
1291 appendsOFile(fp,"\n\n"); 1288 appendsOFile(fp,"\n\n");
1292 } 1289 }
1293 } 1290 }
1294} 1291}
1295 1292
1296static void initVObjectEncoding() 1293static void initVObjectEncoding()
1297{ 1294{
1298 Config pimConfig( "Beam" ); 1295 Config pimConfig( "Beam" );
1299 pimConfig.setGroup("Send"); 1296 pimConfig.setGroup("Send");
1300 Config devcfg(pimConfig.readEntry("DeviceConfig"),Config::File); 1297 Config devcfg(pimConfig.readEntry("DeviceConfig"),Config::File);
1301 QString enc = "QP"; 1298 QString enc = "QP";
1302 QString cs = "UTF-8"; 1299 QString cs = "UTF-8";
1303 if ( devcfg.isValid() ) { 1300 if ( devcfg.isValid() ) {
1304 devcfg.setGroup("Send"); 1301 devcfg.setGroup("Send");
1305 enc = devcfg.readEntry("Encoding","QP"); 1302 enc = devcfg.readEntry("Encoding","QP");
1306 cs = devcfg.readEntry("CharSet","UTF-8"); 1303 cs = devcfg.readEntry("CharSet","UTF-8");
1307 } 1304 }
1308 strncpy(vobj_cs,cs.latin1(),10); 1305 strncpy(vobj_cs,cs.latin1(),10);
1309 if ( enc == "QP" ) { 1306 if ( enc == "QP" ) {
1310 vobj_enc = QuotedPrintable; 1307 vobj_enc = QuotedPrintable;
1311 vobj_enc_s = VCQuotedPrintableProp; 1308 vobj_enc_s = VCQuotedPrintableProp;
1312 } else if ( enc == "B64" ) { 1309 } else if ( enc == "B64" ) {
1313 vobj_enc = Base64; 1310 vobj_enc = Base64;
1314 vobj_enc_s = VCBase64Prop; 1311 vobj_enc_s = VCBase64Prop;
1315 } else { 1312 } else {
1316 vobj_enc = EightBit; 1313 vobj_enc = EightBit;
1317 vobj_enc_s = 0; 1314 vobj_enc_s = 0;
1318 } 1315 }
1319} 1316}
1320 1317
1321void writeVObject(FILE *fp, VObject *o) 1318void writeVObject(FILE *fp, VObject *o)
1322{ 1319{
1323 initVObjectEncoding(); 1320 initVObjectEncoding();
1324 1321
1325 OFile ofp; 1322 OFile ofp;
1326 // ##### 1323 // #####
1327 //_setmode(_fileno(fp), _O_BINARY); 1324 //_setmode(_fileno(fp), _O_BINARY);
1328 initOFile(&ofp,fp); 1325 initOFile(&ofp,fp);
1329 writeVObject_(&ofp,o); 1326 writeVObject_(&ofp,o);
1330} 1327}
1331 1328
1332DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) 1329DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o)
1333{ 1330{
1334 QFileDirect f( fname); 1331 QFileDirect f( fname);
1335 if ( !f.open( IO_WriteOnly ) ) { 1332 if ( !f.open( IO_WriteOnly ) ) {
1336 qWarning("Unable to open vobject write %s", fname); 1333 qWarning("Unable to open vobject write %s", fname);
1337 return; 1334 return;
1338 } 1335 }
1339 1336
1340 writeVObject( f.directHandle(),o ); 1337 writeVObject( f.directHandle(),o );
1341} 1338}
1342 1339
1343DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) 1340DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
1344{ 1341{
1345 QFileDirect f( fname); 1342 QFileDirect f( fname);
1346 if ( !f.open( IO_WriteOnly ) ) { 1343 if ( !f.open( IO_WriteOnly ) ) {
1347 qWarning("Unable to open vobject write %s", fname); 1344 qWarning("Unable to open vobject write %s", fname);
1348 return; 1345 return;
1349 } 1346 }
1350 1347
1351 while (list) { 1348 while (list) {
1352 writeVObject(f.directHandle(),list); 1349 writeVObject(f.directHandle(),list);
1353 list = nextVObjectInList(list); 1350 list = nextVObjectInList(list);
1354 } 1351 }
1355} 1352}
1356 1353
1357DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) 1354DLLEXPORT(const char *) vObjectTypeInfo(VObject *o)
1358{ 1355{
1359 const char *type = vObjectName( o ); 1356 const char *type = vObjectName( o );
1360 if ( strcmp( type, "TYPE" ) == 0 ) 1357 if ( strcmp( type, "TYPE" ) == 0 )
1361 type = vObjectStringZValue( o ); 1358 type = vObjectStringZValue( o );
1362 return type; 1359 return type;
1363} 1360}
1364 1361
1365 1362
1366// end of source file vobject.c 1363// end of source file vobject.c
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h
index f969898..3c9d0d3 100644
--- a/library/backend/vobject_p.h
+++ b/library/backend/vobject_p.h
@@ -1,410 +1,408 @@
1/*************************************************************************** 1/***************************************************************************
2(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International 2(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
3Business Machines Corporation and Siemens Rolm Communications Inc. 3Business Machines Corporation and Siemens Rolm Communications Inc.
4 4
5For purposes of this license notice, the term Licensors shall mean, 5For purposes of this license notice, the term Licensors shall mean,
6collectively, Apple Computer, Inc., AT&T Corp., International 6collectively, Apple Computer, Inc., AT&T Corp., International
7Business Machines Corporation and Siemens Rolm Communications Inc. 7Business Machines Corporation and Siemens Rolm Communications Inc.
8The term Licensor shall mean any of the Licensors. 8The term Licensor shall mean any of the Licensors.
9 9
10Subject to acceptance of the following conditions, permission is hereby 10Subject to acceptance of the following conditions, permission is hereby
11granted by Licensors without the need for written agreement and without 11granted by Licensors without the need for written agreement and without
12license or royalty fees, to use, copy, modify and distribute this 12license or royalty fees, to use, copy, modify and distribute this
13software for any purpose. 13software for any purpose.
14 14
15The above copyright notice and the following four paragraphs must be 15The above copyright notice and the following four paragraphs must be
16reproduced in all copies of this software and any software including 16reproduced in all copies of this software and any software including
17this software. 17this software.
18 18
19THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE 19THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
20ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR 20ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
21MODIFICATIONS. 21MODIFICATIONS.
22 22
23IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, 23IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
24INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT 24INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
25OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26DAMAGE. 26DAMAGE.
27 27
28EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, 28EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
29INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE 29INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
30IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31PURPOSE. 31PURPOSE.
32 32
33The software is provided with RESTRICTED RIGHTS. Use, duplication, or 33The software is provided with RESTRICTED RIGHTS. Use, duplication, or
34disclosure by the government are subject to restrictions set forth in 34disclosure by the government are subject to restrictions set forth in
35DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. 35DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
36 36
37***************************************************************************/ 37***************************************************************************/
38 38
39/* 39/*
40 40
41The vCard/vCalendar C interface is implemented in the set 41The vCard/vCalendar C interface is implemented in the set
42of files as follows: 42of files as follows:
43 43
44vcc.y, yacc source, and vcc.c, the yacc output you will use 44vcc.y, yacc source, and vcc.c, the yacc output you will use
45implements the core parser 45implements the core parser
46 46
47vobject.c implements an API that insulates the caller from 47vobject.c implements an API that insulates the caller from
48the parser and changes in the vCard/vCalendar BNF 48the parser and changes in the vCard/vCalendar BNF
49 49
50port.h defines compilation environment dependent stuff 50port.h defines compilation environment dependent stuff
51 51
52vcc.h and vobject.h are header files for their .c counterparts 52vcc.h and vobject.h are header files for their .c counterparts
53 53
54vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions 54vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
55which you may find useful. 55which you may find useful.
56 56
57test.c is a standalone test driver that exercises some of 57test.c is a standalone test driver that exercises some of
58the features of the APIs provided. Invoke test.exe on a 58the features of the APIs provided. Invoke test.exe on a
59VCARD/VCALENDAR input text file and you will see the pretty 59VCARD/VCALENDAR input text file and you will see the pretty
60print output of the internal representation (this pretty print 60print output of the internal representation (this pretty print
61output should give you a good idea of how the internal 61output should give you a good idea of how the internal
62representation looks like -- there is one such output in the 62representation looks like -- there is one such output in the
63following too). Also, a file with the .out suffix is generated 63following too). Also, a file with the .out suffix is generated
64to show that the internal representation can be written back 64to show that the internal representation can be written back
65in the original text format. 65in the original text format.
66 66
67For more information on this API see the readme.txt file 67For more information on this API see the readme.txt file
68which accompanied this distribution. 68which accompanied this distribution.
69 69
70 Also visit: 70 Also visit:
71 71
72 http://www.versit.com 72 http://www.versit.com
73 http://www.ralden.com 73 http://www.ralden.com
74 74
75*/ 75*/
76 76
77// No tr() anywhere in this file 77// No tr() anywhere in this file
78 78
79 79
80#ifndef __VOBJECT_H__ 80#ifndef __VOBJECT_H__
81#define __VOBJECT_H__ 1 81#define __VOBJECT_H__ 1
82 82
83#include <qstring.h> 83#include <qstring.h>
84 84
85 #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard" 85 #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard"
86 #define vCalendarClipboardFormat"+//ISBN 1-887687-00-9::versit::PDI//vCalendar" 86 #define vCalendarClipboardFormat"+//ISBN 1-887687-00-9::versit::PDI//vCalendar"
87 87
88/* The above strings vCardClipboardFormat and vCalendarClipboardFormat 88/* The above strings vCardClipboardFormat and vCalendarClipboardFormat
89are globally unique IDs which can be used to generate clipboard format 89are globally unique IDs which can be used to generate clipboard format
90ID's as per the requirements of a specific platform. For example, in 90ID's as per the requirements of a specific platform. For example, in
91Windows they are used as the parameter in a call to RegisterClipboardFormat. 91Windows they are used as the parameter in a call to RegisterClipboardFormat.
92For example: 92For example:
93 93
94 CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat); 94 CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat);
95 95
96*/ 96*/
97 97
98 #define vCardMimeType "text/x-vCard" 98 #define vCardMimeType "text/x-vCard"
99 #define vCalendarMimeType"text/x-vCalendar" 99 #define vCalendarMimeType"text/x-vCalendar"
100 100
101#undef DLLEXPORT 101#undef DLLEXPORT
102 //#include <qtopia/qpeglobal.h> 102#include <qtopia/global.h>
103#include <qglobal.h>
104
105#if defined(QTOPIA_MAKEDLL) 103#if defined(QTOPIA_MAKEDLL)
106#define DLLEXPORT(t) __declspec(dllexport) t 104#define DLLEXPORT(t) __declspec(dllexport) t
107#elif defined(QTOPIA_DLL) 105#elif defined(QTOPIA_DLL)
108#define DLLEXPORT(t) __declspec(dllimport) t 106#define DLLEXPORT(t) __declspec(dllimport) t
109#else 107#else
110#define DLLEXPORT(t) t 108#define DLLEXPORT(t) t
111#endif 109#endif
112 110
113#ifndef FALSE 111#ifndef FALSE
114 #define FALSE0 112 #define FALSE0
115#endif 113#endif
116#ifndef TRUE 114#ifndef TRUE
117 #define TRUE1 115 #define TRUE1
118#endif 116#endif
119 117
120#include <stdlib.h> 118#include <stdlib.h>
121#include <stdio.h> 119#include <stdio.h>
122 120
123 121
124 #define VC7bitProp "7BIT" 122 #define VC7bitProp "7BIT"
125 #define VC8bitProp "8BIT" 123 #define VC8bitProp "8BIT"
126 #define VCAAlarmProp "AALARM" 124 #define VCAAlarmProp "AALARM"
127 #define VCAdditionalNamesProp"ADDN" 125 #define VCAdditionalNamesProp"ADDN"
128 #define VCAdrProp "ADR" 126 #define VCAdrProp "ADR"
129 #define VCAgentProp "AGENT" 127 #define VCAgentProp "AGENT"
130 #define VCAIFFProp "AIFF" 128 #define VCAIFFProp "AIFF"
131 #define VCAOLProp "AOL" 129 #define VCAOLProp "AOL"
132 #define VCAppleLinkProp "APPLELINK" 130 #define VCAppleLinkProp "APPLELINK"
133 #define VCAttachProp "ATTACH" 131 #define VCAttachProp "ATTACH"
134 #define VCAttendeeProp "ATTENDEE" 132 #define VCAttendeeProp "ATTENDEE"
135 #define VCATTMailProp "ATTMAIL" 133 #define VCATTMailProp "ATTMAIL"
136 #define VCAudioContentProp "AUDIOCONTENT" 134 #define VCAudioContentProp "AUDIOCONTENT"
137 #define VCAVIProp "AVI" 135 #define VCAVIProp "AVI"
138 #define VCBase64Prop "BASE64" 136 #define VCBase64Prop "BASE64"
139 #define VCBBSProp "BBS" 137 #define VCBBSProp "BBS"
140 #define VCBirthDateProp "BDAY" 138 #define VCBirthDateProp "BDAY"
141 #define VCBMPProp "BMP" 139 #define VCBMPProp "BMP"
142 #define VCBodyProp "BODY" 140 #define VCBodyProp "BODY"
143 #define VCBusinessRoleProp "ROLE" 141 #define VCBusinessRoleProp "ROLE"
144 #define VCCalProp "VCALENDAR" 142 #define VCCalProp "VCALENDAR"
145 #define VCCaptionProp "CAP" 143 #define VCCaptionProp "CAP"
146 #define VCCardProp "VCARD" 144 #define VCCardProp "VCARD"
147 #define VCCarProp "CAR" 145 #define VCCarProp "CAR"
148 #define VCCategoriesProp "CATEGORIES" 146 #define VCCategoriesProp "CATEGORIES"
149 #define VCCellularProp "CELL" 147 #define VCCellularProp "CELL"
150 #define VCCGMProp "CGM" 148 #define VCCGMProp "CGM"
151 #define VCCharSetProp "CHARSET" 149 #define VCCharSetProp "CHARSET"
152 #define VCCIDProp "CID" 150 #define VCCIDProp "CID"
153 #define VCCISProp "CIS" 151 #define VCCISProp "CIS"
154 #define VCCityProp "L" 152 #define VCCityProp "L"
155 #define VCClassProp "CLASS" 153 #define VCClassProp "CLASS"
156 #define VCCommentProp "NOTE" 154 #define VCCommentProp "NOTE"
157 #define VCCompletedProp "COMPLETED" 155 #define VCCompletedProp "COMPLETED"
158 #define VCContentIDProp "CONTENT-ID" 156 #define VCContentIDProp "CONTENT-ID"
159 #define VCCountryNameProp "C" 157 #define VCCountryNameProp "C"
160 #define VCDAlarmProp "DALARM" 158 #define VCDAlarmProp "DALARM"
161 #define VCDataSizeProp "DATASIZE" 159 #define VCDataSizeProp "DATASIZE"
162 #define VCDayLightProp "DAYLIGHT" 160 #define VCDayLightProp "DAYLIGHT"
163 #define VCDCreatedProp "DCREATED" 161 #define VCDCreatedProp "DCREATED"
164#define VCDeliveryLabelProp "LABEL" 162#define VCDeliveryLabelProp "LABEL"
165 #define VCDescriptionProp "DESCRIPTION" 163 #define VCDescriptionProp "DESCRIPTION"
166 #define VCDIBProp "DIB" 164 #define VCDIBProp "DIB"
167 #define VCDisplayStringProp "DISPLAYSTRING" 165 #define VCDisplayStringProp "DISPLAYSTRING"
168 #define VCDomesticProp "DOM" 166 #define VCDomesticProp "DOM"
169 #define VCDTendProp "DTEND" 167 #define VCDTendProp "DTEND"
170 #define VCDTstartProp "DTSTART" 168 #define VCDTstartProp "DTSTART"
171 #define VCDueProp "DUE" 169 #define VCDueProp "DUE"
172 #define VCEmailAddressProp "EMAIL" 170 #define VCEmailAddressProp "EMAIL"
173 #define VCEncodingProp "ENCODING" 171 #define VCEncodingProp "ENCODING"
174 #define VCEndProp "END" 172 #define VCEndProp "END"
175 #define VCEventProp "VEVENT" 173 #define VCEventProp "VEVENT"
176 #define VCEWorldProp "EWORLD" 174 #define VCEWorldProp "EWORLD"
177 #define VCExNumProp "EXNUM" 175 #define VCExNumProp "EXNUM"
178 #define VCExpDateProp "EXDATE" 176 #define VCExpDateProp "EXDATE"
179 #define VCExpectProp "EXPECT" 177 #define VCExpectProp "EXPECT"
180 #define VCExtAddressProp "EXT ADD" 178 #define VCExtAddressProp "EXT ADD"
181 #define VCFamilyNameProp "F" 179 #define VCFamilyNameProp "F"
182 #define VCFaxProp "FAX" 180 #define VCFaxProp "FAX"
183 #define VCFullNameProp "FN" 181 #define VCFullNameProp "FN"
184 #define VCGeoProp "GEO" 182 #define VCGeoProp "GEO"
185 #define VCGeoLocationProp "GEO" 183 #define VCGeoLocationProp "GEO"
186 #define VCGIFProp "GIF" 184 #define VCGIFProp "GIF"
187 #define VCGivenNameProp "G" 185 #define VCGivenNameProp "G"
188 #define VCGroupingProp "Grouping" 186 #define VCGroupingProp "Grouping"
189 #define VCHomeProp "HOME" 187 #define VCHomeProp "HOME"
190 #define VCIBMMailProp "IBMMail" 188 #define VCIBMMailProp "IBMMail"
191 #define VCInlineProp "INLINE" 189 #define VCInlineProp "INLINE"
192 #define VCInternationalProp "INTL" 190 #define VCInternationalProp "INTL"
193 #define VCInternetProp "INTERNET" 191 #define VCInternetProp "INTERNET"
194 #define VCISDNProp "ISDN" 192 #define VCISDNProp "ISDN"
195 #define VCJPEGProp "JPEG" 193 #define VCJPEGProp "JPEG"
196 #define VCLanguageProp "LANG" 194 #define VCLanguageProp "LANG"
197 #define VCLastModifiedProp "LAST-MODIFIED" 195 #define VCLastModifiedProp "LAST-MODIFIED"
198 #define VCLastRevisedProp "REV" 196 #define VCLastRevisedProp "REV"
199 #define VCLocationProp "LOCATION" 197 #define VCLocationProp "LOCATION"
200 #define VCLogoProp "LOGO" 198 #define VCLogoProp "LOGO"
201 #define VCMailerProp "MAILER" 199 #define VCMailerProp "MAILER"
202 #define VCMAlarmProp "MALARM" 200 #define VCMAlarmProp "MALARM"
203 #define VCMCIMailProp "MCIMAIL" 201 #define VCMCIMailProp "MCIMAIL"
204 #define VCMessageProp "MSG" 202 #define VCMessageProp "MSG"
205 #define VCMETProp "MET" 203 #define VCMETProp "MET"
206 #define VCModemProp "MODEM" 204 #define VCModemProp "MODEM"
207 #define VCMPEG2Prop "MPEG2" 205 #define VCMPEG2Prop "MPEG2"
208 #define VCMPEGProp "MPEG" 206 #define VCMPEGProp "MPEG"
209 #define VCMSNProp "MSN" 207 #define VCMSNProp "MSN"
210 #define VCNamePrefixesProp "NPRE" 208 #define VCNamePrefixesProp "NPRE"
211 #define VCNameProp "N" 209 #define VCNameProp "N"
212 #define VCNameSuffixesProp "NSUF" 210 #define VCNameSuffixesProp "NSUF"
213 #define VCNoteProp "NOTE" 211 #define VCNoteProp "NOTE"
214 #define VCOrgNameProp "ORGNAME" 212 #define VCOrgNameProp "ORGNAME"
215 #define VCOrgProp "ORG" 213 #define VCOrgProp "ORG"
216 #define VCOrgUnit2Prop "OUN2" 214 #define VCOrgUnit2Prop "OUN2"
217 #define VCOrgUnit3Prop "OUN3" 215 #define VCOrgUnit3Prop "OUN3"
218 #define VCOrgUnit4Prop "OUN4" 216 #define VCOrgUnit4Prop "OUN4"
219 #define VCOrgUnitProp "OUN" 217 #define VCOrgUnitProp "OUN"
220 #define VCPagerProp "PAGER" 218 #define VCPagerProp "PAGER"
221 #define VCPAlarmProp "PALARM" 219 #define VCPAlarmProp "PALARM"
222 #define VCParcelProp "PARCEL" 220 #define VCParcelProp "PARCEL"
223 #define VCPartProp "PART" 221 #define VCPartProp "PART"
224 #define VCPCMProp "PCM" 222 #define VCPCMProp "PCM"
225 #define VCPDFProp "PDF" 223 #define VCPDFProp "PDF"
226 #define VCPGPProp "PGP" 224 #define VCPGPProp "PGP"
227 #define VCPhotoProp "PHOTO" 225 #define VCPhotoProp "PHOTO"
228 #define VCPICTProp "PICT" 226 #define VCPICTProp "PICT"
229 #define VCPMBProp "PMB" 227 #define VCPMBProp "PMB"
230 #define VCPostalBoxProp "BOX" 228 #define VCPostalBoxProp "BOX"
231 #define VCPostalCodeProp "PC" 229 #define VCPostalCodeProp "PC"
232 #define VCPostalProp "POSTAL" 230 #define VCPostalProp "POSTAL"
233 #define VCPowerShareProp "POWERSHARE" 231 #define VCPowerShareProp "POWERSHARE"
234 #define VCPreferredProp "PREF" 232 #define VCPreferredProp "PREF"
235 #define VCPriorityProp "PRIORITY" 233 #define VCPriorityProp "PRIORITY"
236 #define VCProcedureNameProp "PROCEDURENAME" 234 #define VCProcedureNameProp "PROCEDURENAME"
237 #define VCProdIdProp "PRODID" 235 #define VCProdIdProp "PRODID"
238 #define VCProdigyProp "PRODIGY" 236 #define VCProdigyProp "PRODIGY"
239 #define VCPronunciationProp "SOUND" 237 #define VCPronunciationProp "SOUND"
240 #define VCPSProp "PS" 238 #define VCPSProp "PS"
241 #define VCPublicKeyProp "KEY" 239 #define VCPublicKeyProp "KEY"
242 #define VCQPProp "QP" 240 #define VCQPProp "QP"
243 #define VCQuickTimeProp "QTIME" 241 #define VCQuickTimeProp "QTIME"
244 #define VCQuotedPrintableProp"QUOTED-PRINTABLE" 242 #define VCQuotedPrintableProp"QUOTED-PRINTABLE"
245 #define VCRDateProp "RDATE" 243 #define VCRDateProp "RDATE"
246 #define VCRegionProp "R" 244 #define VCRegionProp "R"
247 #define VCRelatedToProp "RELATED-TO" 245 #define VCRelatedToProp "RELATED-TO"
248 #define VCRepeatCountProp "REPEATCOUNT" 246 #define VCRepeatCountProp "REPEATCOUNT"
249 #define VCResourcesProp "RESOURCES" 247 #define VCResourcesProp "RESOURCES"
250 #define VCRNumProp "RNUM" 248 #define VCRNumProp "RNUM"
251 #define VCRoleProp "ROLE" 249 #define VCRoleProp "ROLE"
252 #define VCRRuleProp "RRULE" 250 #define VCRRuleProp "RRULE"
253 #define VCRSVPProp "RSVP" 251 #define VCRSVPProp "RSVP"
254 #define VCRunTimeProp "RUNTIME" 252 #define VCRunTimeProp "RUNTIME"
255 #define VCSequenceProp "SEQUENCE" 253 #define VCSequenceProp "SEQUENCE"
256 #define VCSnoozeTimeProp "SNOOZETIME" 254 #define VCSnoozeTimeProp "SNOOZETIME"
257 #define VCStartProp "START" 255 #define VCStartProp "START"
258 #define VCStatusProp "STATUS" 256 #define VCStatusProp "STATUS"
259 #define VCStreetAddressProp "STREET" 257 #define VCStreetAddressProp "STREET"
260 #define VCSubTypeProp "SUBTYPE" 258 #define VCSubTypeProp "SUBTYPE"
261 #define VCSummaryProp "SUMMARY" 259 #define VCSummaryProp "SUMMARY"
262 #define VCTelephoneProp "TEL" 260 #define VCTelephoneProp "TEL"
263 #define VCTIFFProp "TIFF" 261 #define VCTIFFProp "TIFF"
264 #define VCTimeZoneProp "TZ" 262 #define VCTimeZoneProp "TZ"
265 #define VCTitleProp "TITLE" 263 #define VCTitleProp "TITLE"
266 #define VCTLXProp "TLX" 264 #define VCTLXProp "TLX"
267 #define VCTodoProp "VTODO" 265 #define VCTodoProp "VTODO"
268 #define VCTranspProp "TRANSP" 266 #define VCTranspProp "TRANSP"
269 #define VCUniqueStringProp "UID" 267 #define VCUniqueStringProp "UID"
270 #define VCURLProp "URL" 268 #define VCURLProp "URL"
271 #define VCURLValueProp "URLVAL" 269 #define VCURLValueProp "URLVAL"
272 #define VCValueProp "VALUE" 270 #define VCValueProp "VALUE"
273 #define VCVersionProp "VERSION" 271 #define VCVersionProp "VERSION"
274 #define VCVideoProp "VIDEO" 272 #define VCVideoProp "VIDEO"
275 #define VCVoiceProp "VOICE" 273 #define VCVoiceProp "VOICE"
276 #define VCWAVEProp "WAVE" 274 #define VCWAVEProp "WAVE"
277 #define VCWMFProp "WMF" 275 #define VCWMFProp "WMF"
278 #define VCWorkProp "WORK" 276 #define VCWorkProp "WORK"
279 #define VCX400Prop "X400" 277 #define VCX400Prop "X400"
280 #define VCX509Prop "X509" 278 #define VCX509Prop "X509"
281 #define VCXRuleProp "XRULE" 279 #define VCXRuleProp "XRULE"
282 280
283 281
284typedef struct VObject VObject; 282typedef struct VObject VObject;
285 283
286typedef struct VObjectIterator { 284typedef struct VObjectIterator {
287 VObject* start; 285 VObject* start;
288 VObject* next; 286 VObject* next;
289 } VObjectIterator; 287 } VObjectIterator;
290 288
291extern DLLEXPORT(VObject*) newVObject(const char *id); 289extern DLLEXPORT(VObject*) newVObject(const char *id);
292extern DLLEXPORT(void) deleteVObject(VObject *p); 290extern DLLEXPORT(void) deleteVObject(VObject *p);
293extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size); 291extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size);
294extern DLLEXPORT(void) deleteStr(const char *p); 292extern DLLEXPORT(void) deleteStr(const char *p);
295extern DLLEXPORT(void) unUseStr(const char *s); 293extern DLLEXPORT(void) unUseStr(const char *s);
296 294
297extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id); 295extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id);
298extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s); 296extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s);
299extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s); 297extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s);
300extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i); 298extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i);
301extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l); 299extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l);
302extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t); 300extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t);
303extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size); 301extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size);
304extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size); 302extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size);
305 303
306extern DLLEXPORT(const char*) vObjectName(VObject *o); 304extern DLLEXPORT(const char*) vObjectName(VObject *o);
307extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o); 305extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o);
308extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o); 306extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o);
309extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o); 307extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o);
310extern DLLEXPORT(void*) vObjectAnyValue(VObject *o); 308extern DLLEXPORT(void*) vObjectAnyValue(VObject *o);
311extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o); 309extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o);
312extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p); 310extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p);
313 311
314extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p); 312extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p);
315extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id); 313extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id);
316extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id); 314extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id);
317extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v); 315extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v);
318extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); 316extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size);
319extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); 317extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size);
320extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g); 318extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g);
321extern DLLEXPORT(void) addList(VObject **o, VObject *p); 319extern DLLEXPORT(void) addList(VObject **o, VObject *p);
322 320
323extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id); 321extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id);
324 322
325extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o); 323extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o);
326extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o); 324extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o);
327extern DLLEXPORT(int) moreIteration(VObjectIterator *i); 325extern DLLEXPORT(int) moreIteration(VObjectIterator *i);
328extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i); 326extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i);
329 327
330extern DLLEXPORT(const char*) lookupStr(const char *s); 328extern DLLEXPORT(const char*) lookupStr(const char *s);
331extern DLLEXPORT(void) cleanStrTbl(); 329extern DLLEXPORT(void) cleanStrTbl();
332 330
333extern DLLEXPORT(void) cleanVObject(VObject *o); 331extern DLLEXPORT(void) cleanVObject(VObject *o);
334extern DLLEXPORT(void) cleanVObjects(VObject *list); 332extern DLLEXPORT(void) cleanVObjects(VObject *list);
335 333
336extern DLLEXPORT(const char*) lookupProp(const char* str); 334extern DLLEXPORT(const char*) lookupProp(const char* str);
337extern DLLEXPORT(const char*) lookupProp_(const char* str); 335extern DLLEXPORT(const char*) lookupProp_(const char* str);
338 336
339extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o); 337extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o);
340extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); 338extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list);
341 339
342extern DLLEXPORT(int) vObjectValueType(VObject *o); 340extern DLLEXPORT(int) vObjectValueType(VObject *o);
343 341
344/* return type of vObjectValueType: */ 342/* return type of vObjectValueType: */
345 #define VCVT_NOVALUE0 343 #define VCVT_NOVALUE0
346 /* if the VObject has no value associated with it. */ 344 /* if the VObject has no value associated with it. */
347 #define VCVT_STRINGZ1 345 #define VCVT_STRINGZ1
348 /* if the VObject has value set by setVObjectStringZValue. */ 346 /* if the VObject has value set by setVObjectStringZValue. */
349 #define VCVT_UINT 2 347 #define VCVT_UINT 2
350 /* if the VObject has value set by setVObjectIntegerValue. */ 348 /* if the VObject has value set by setVObjectIntegerValue. */
351 #define VCVT_ULONG 3 349 #define VCVT_ULONG 3
352 /* if the VObject has value set by setVObjectLongValue. */ 350 /* if the VObject has value set by setVObjectLongValue. */
353 #define VCVT_RAW 4 351 #define VCVT_RAW 4
354 /* if the VObject has value set by setVObjectAnyValue. */ 352 /* if the VObject has value set by setVObjectAnyValue. */
355 #define VCVT_VOBJECT5 353 #define VCVT_VOBJECT5
356 /* if the VObject has value set by setVObjectVObjectValue. */ 354 /* if the VObject has value set by setVObjectVObjectValue. */
357 355
358extern DLLEXPORT(const char**) fieldedProp; 356extern DLLEXPORT(const char**) fieldedProp;
359 357
360/*************************************************** 358/***************************************************
361 * The methods below are implemented in vcc.c (generated from vcc.y ) 359 * The methods below are implemented in vcc.c (generated from vcc.y )
362 ***************************************************/ 360 ***************************************************/
363 361
364/* NOTE regarding printVObject and writeVObject 362/* NOTE regarding printVObject and writeVObject
365 363
366The functions below are not exported from the DLL because they 364The functions below are not exported from the DLL because they
367take a FILE* as a parameter, which cannot be passed across a DLL 365take a FILE* as a parameter, which cannot be passed across a DLL
368interface (at least that is my experience). Instead you can use 366interface (at least that is my experience). Instead you can use
369their companion functions which take file names or pointers 367their companion functions which take file names or pointers
370to memory. However, if you are linking this code into 368to memory. However, if you are linking this code into
371your build directly then you may find them a more convenient API 369your build directly then you may find them a more convenient API
372and you can go ahead and use them. If you try to use them with 370and you can go ahead and use them. If you try to use them with
373the DLL LIB you will get a link error. 371the DLL LIB you will get a link error.
374*/ 372*/
375extern DLLEXPORT(void) writeVObject(FILE *fp, VObject *o); 373extern DLLEXPORT(void) writeVObject(FILE *fp, VObject *o);
376 374
377 375
378 376
379typedef void (*MimeErrorHandler)(char *); 377typedef void (*MimeErrorHandler)(char *);
380 378
381extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); 379extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
382 380
383extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); 381extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
384extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); 382extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
385 383
386 384
387/* NOTE regarding Parse_MIME_FromFile 385/* NOTE regarding Parse_MIME_FromFile
388The function above, Parse_MIME_FromFile, comes in two flavors, 386The function above, Parse_MIME_FromFile, comes in two flavors,
389neither of which is exported from the DLL. Each version takes 387neither of which is exported from the DLL. Each version takes
390a CFile or FILE* as a parameter, neither of which can be 388a CFile or FILE* as a parameter, neither of which can be
391passed across a DLL interface (at least that is my experience). 389passed across a DLL interface (at least that is my experience).
392If you are linking this code into your build directly then 390If you are linking this code into your build directly then
393you may find them a more convenient API that the other flavors 391you may find them a more convenient API that the other flavors
394that take a file name. If you use them with the DLL LIB you 392that take a file name. If you use them with the DLL LIB you
395will get a link error. 393will get a link error.
396*/ 394*/
397 395
398 396
399#if INCLUDEMFC 397#if INCLUDEMFC
400extern DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file); 398extern DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file);
401#else 399#else
402extern DLLEXPORT(VObject*) Parse_MIME_FromFile(FILE *file); 400extern DLLEXPORT(VObject*) Parse_MIME_FromFile(FILE *file);
403#endif 401#endif
404 402
405extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o); 403extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o);
406 404
407 405
408#endif /* __VOBJECT_H__ */ 406#endif /* __VOBJECT_H__ */
409 407
410 408