summaryrefslogtreecommitdiff
authorzecke <zecke>2003-08-29 18:02:09 (UTC)
committer zecke <zecke>2003-08-29 18:02:09 (UTC)
commit885c645ee48ae53467e244521c011c73bc106afb (patch) (unidiff)
tree9024be25b2503788d3aa77b7a86b89e543cdd865
parented6da2303a8fabec50991365914f0e4d20a21ea6 (diff)
downloadopie-885c645ee48ae53467e244521c011c73bc106afb.zip
opie-885c645ee48ae53467e244521c011c73bc106afb.tar.gz
opie-885c645ee48ae53467e244521c011c73bc106afb.tar.bz2
Fixes for base64 decoding and encoding of vCard
Diffstat (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
@@ -316,257 +316,257 @@ vcal:
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)?
@@ -688,480 +688,479 @@ static void handleMoreRFC822LineBreak(int c) {
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;
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
@@ -336,257 +336,257 @@ char *vccrule[] = {
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)?
@@ -708,662 +708,661 @@ static void handleMoreRFC822LineBreak(int c) {
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);
@@ -1413,185 +1412,185 @@ case 9:
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,175 +1,173 @@
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}
@@ -632,257 +630,256 @@ static const char *MAlarmFields[] = {
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}
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,232 +1,230 @@
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"