author | zecke <zecke> | 2003-08-29 18:02:09 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-29 18:02:09 (UTC) |
commit | 885c645ee48ae53467e244521c011c73bc106afb (patch) (unidiff) | |
tree | 9024be25b2503788d3aa77b7a86b89e543cdd865 | |
parent | ed6da2303a8fabec50991365914f0e4d20a21ea6 (diff) | |
download | opie-885c645ee48ae53467e244521c011c73bc106afb.zip opie-885c645ee48ae53467e244521c011c73bc106afb.tar.gz opie-885c645ee48ae53467e244521c011c73bc106afb.tar.bz2 |
Fixes for base64 decoding and encoding of vCard
-rw-r--r-- | library/backend/vcc.y | 29 | ||||
-rw-r--r-- | library/backend/vcc_yacc.cpp | 33 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 5 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 4 |
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 | |||
@@ -396,97 +396,97 @@ static int pushVObject(const char *prop) | |||
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. */ |
405 | static VObject* popVObject() | 405 | static 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 | ||
419 | static void enterValues(const char *value) | 419 | static 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 | ||
436 | static void enterProps(const char *s) | 436 | static 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 | ||
442 | static void enterAttr(const char *s1, const char *s2) | 442 | static 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 | ||
468 | struct LexBuf { | 468 | struct 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; |
@@ -768,320 +768,319 @@ static char* lexGet1Value() { | |||
768 | static int match_begin_name(int end) { | 768 | static 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 |
784 | void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) | 784 | void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) |
785 | #else | 785 | #else |
786 | void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) | 786 | void 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 | ||
807 | static void finiLex() { | 807 | static 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 | */ |
816 | static char * lexGetDataFromBase64() | 816 | static 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 | ||
917 | static int match_begin_end_name(int end) { | 919 | static 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 | ||
938 | static char* lexGetQuotedPrintable() | 940 | static 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 | ||
1006 | static int yylex() { | 1008 | static 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': { |
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 | |||
@@ -416,97 +416,97 @@ static int pushVObject(const char *prop) | |||
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. */ |
425 | static VObject* popVObject() | 425 | static 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 | ||
439 | static void enterValues(const char *value) | 439 | static 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 | ||
456 | static void enterProps(const char *s) | 456 | static 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 | ||
462 | static void enterAttr(const char *s1, const char *s2) | 462 | static 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 | ||
488 | struct LexBuf { | 488 | struct 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; |
@@ -788,320 +788,319 @@ static char* lexGet1Value() { | |||
788 | static int match_begin_name(int end) { | 788 | static 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 |
804 | void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) | 804 | void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) |
805 | #else | 805 | #else |
806 | void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) | 806 | void 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 | ||
827 | static void finiLex() { | 827 | static 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 | */ |
836 | static char * lexGetDataFromBase64() | 836 | static 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 | ||
937 | static int match_begin_end_name(int end) { | 939 | static 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 | ||
958 | static char* lexGetQuotedPrintable() | 960 | static 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 | ||
1026 | static int yylex() { | 1028 | static 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': { |
@@ -1193,97 +1192,97 @@ VObject* Parse_MIME_FromFile(FILE *file) | |||
1193 | fseek(file,startPos,SEEK_SET); | 1192 | fseek(file,startPos,SEEK_SET); |
1194 | } | 1193 | } |
1195 | return result; | 1194 | return result; |
1196 | } | 1195 | } |
1197 | 1196 | ||
1198 | DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname) | 1197 | DLLEXPORT(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 | ||
1218 | static MimeErrorHandler mimeErrorHandler; | 1217 | static MimeErrorHandler mimeErrorHandler; |
1219 | 1218 | ||
1220 | DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me) | 1219 | DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me) |
1221 | { | 1220 | { |
1222 | mimeErrorHandler = me; | 1221 | mimeErrorHandler = me; |
1223 | } | 1222 | } |
1224 | 1223 | ||
1225 | void mime_error(char *s) | 1224 | void 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 | ||
1234 | void mime_error_(char *s) | 1233 | void 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 |
1246 | int | 1245 | int |
1247 | #if defined(__STDC__) | 1246 | #if defined(__STDC__) |
1248 | yyparse(void) | 1247 | yyparse(void) |
1249 | #else | 1248 | #else |
1250 | yyparse() | 1249 | yyparse() |
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 | ||
1274 | yyloop: | 1273 | yyloop: |
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 | } |
@@ -1493,97 +1492,97 @@ case 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 | } |
1498 | break; | 1497 | break; |
1499 | case 40: | 1498 | case 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 | } |
1505 | break; | 1504 | break; |
1506 | case 41: | 1505 | case 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 | } |
1512 | break; | 1511 | break; |
1513 | case 42: | 1512 | case 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 | } |
1519 | break; | 1518 | break; |
1520 | case 43: | 1519 | case 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 | } |
1526 | break; | 1525 | break; |
1527 | case 44: | 1526 | case 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 | } |
1533 | break; | 1532 | break; |
1534 | case 45: | 1533 | case 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 | } |
1540 | break; | 1539 | break; |
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 \ |
1582 | to state %d\n", YYPREFIX, *yyssp, yystate); | 1581 | to 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; |
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,95 +1,93 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International | 2 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International |
3 | Business Machines Corporation and Siemens Rolm Communications Inc. | 3 | Business Machines Corporation and Siemens Rolm Communications Inc. |
4 | 4 | ||
5 | For purposes of this license notice, the term Licensors shall mean, | 5 | For purposes of this license notice, the term Licensors shall mean, |
6 | collectively, Apple Computer, Inc., AT&T Corp., International | 6 | collectively, Apple Computer, Inc., AT&T Corp., International |
7 | Business Machines Corporation and Siemens Rolm Communications Inc. | 7 | Business Machines Corporation and Siemens Rolm Communications Inc. |
8 | The term Licensor shall mean any of the Licensors. | 8 | The term Licensor shall mean any of the Licensors. |
9 | 9 | ||
10 | Subject to acceptance of the following conditions, permission is hereby | 10 | Subject to acceptance of the following conditions, permission is hereby |
11 | granted by Licensors without the need for written agreement and without | 11 | granted by Licensors without the need for written agreement and without |
12 | license or royalty fees, to use, copy, modify and distribute this | 12 | license or royalty fees, to use, copy, modify and distribute this |
13 | software for any purpose. | 13 | software for any purpose. |
14 | 14 | ||
15 | The above copyright notice and the following four paragraphs must be | 15 | The above copyright notice and the following four paragraphs must be |
16 | reproduced in all copies of this software and any software including | 16 | reproduced in all copies of this software and any software including |
17 | this software. | 17 | this software. |
18 | 18 | ||
19 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE | 19 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE |
20 | ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR | 20 | ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR |
21 | MODIFICATIONS. | 21 | MODIFICATIONS. |
22 | 22 | ||
23 | IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, | 23 | IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, |
24 | INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT | 24 | INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT |
25 | OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | 25 | OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
26 | DAMAGE. | 26 | DAMAGE. |
27 | 27 | ||
28 | EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, | 28 | EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, |
29 | INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE | 29 | INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE |
30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
31 | PURPOSE. | 31 | PURPOSE. |
32 | 32 | ||
33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or | 33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or |
34 | disclosure by the government are subject to restrictions set forth in | 34 | disclosure by the government are subject to restrictions set forth in |
35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | 35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. |
36 | 36 | ||
37 | ***************************************************************************/ | 37 | ***************************************************************************/ |
38 | 38 | ||
39 | /* | 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 | ||
66 | static char vobj_cs[10]; | 64 | static char vobj_cs[10]; |
67 | static enum { EightBit, QuotedPrintable, Base64 } vobj_enc=EightBit; | 65 | static enum { EightBit, QuotedPrintable, Base64 } vobj_enc=EightBit; |
68 | static const char *vobj_enc_s=0; | 66 | static const char *vobj_enc_s=0; |
69 | 67 | ||
70 | typedef union ValueItem { | 68 | typedef 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 | ||
78 | struct VObject { | 76 | struct 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 | ||
86 | typedef struct StrItem StrItem; | 84 | typedef struct StrItem StrItem; |
87 | 85 | ||
88 | struct StrItem { | 86 | struct 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 | ||
94 | DLLEXPORT(const char**) fieldedProp; | 92 | DLLEXPORT(const char**) fieldedProp; |
95 | 93 | ||
@@ -712,97 +710,96 @@ static struct PreDefProp propNames[] = { | |||
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 | ||
804 | static struct PreDefProp* lookupPropInfo(const char* str) | 801 | static 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 | ||
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 | |||
@@ -54,99 +54,97 @@ vcc.h and vobject.h are header files for their .c counterparts | |||
54 | vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions | 54 | vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions |
55 | which you may find useful. | 55 | which you may find useful. |
56 | 56 | ||
57 | test.c is a standalone test driver that exercises some of | 57 | test.c is a standalone test driver that exercises some of |
58 | the features of the APIs provided. Invoke test.exe on a | 58 | the features of the APIs provided. Invoke test.exe on a |
59 | VCARD/VCALENDAR input text file and you will see the pretty | 59 | VCARD/VCALENDAR input text file and you will see the pretty |
60 | print output of the internal representation (this pretty print | 60 | print output of the internal representation (this pretty print |
61 | output should give you a good idea of how the internal | 61 | output should give you a good idea of how the internal |
62 | representation looks like -- there is one such output in the | 62 | representation looks like -- there is one such output in the |
63 | following too). Also, a file with the .out suffix is generated | 63 | following too). Also, a file with the .out suffix is generated |
64 | to show that the internal representation can be written back | 64 | to show that the internal representation can be written back |
65 | in the original text format. | 65 | in the original text format. |
66 | 66 | ||
67 | For more information on this API see the readme.txt file | 67 | For more information on this API see the readme.txt file |
68 | which accompanied this distribution. | 68 | which 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 |
89 | are globally unique IDs which can be used to generate clipboard format | 89 | are globally unique IDs which can be used to generate clipboard format |
90 | ID's as per the requirements of a specific platform. For example, in | 90 | ID's as per the requirements of a specific platform. For example, in |
91 | Windows they are used as the parameter in a call to RegisterClipboardFormat. | 91 | Windows they are used as the parameter in a call to RegisterClipboardFormat. |
92 | For example: | 92 | For 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" |