author | eilers <eilers> | 2002-10-22 09:07:07 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-22 09:07:07 (UTC) |
commit | bbb2c5fee87baa345ff5c16404204054442f5c11 (patch) (unidiff) | |
tree | 7a61b3afc81c9c3d96bfe12e82689843bf58d972 | |
parent | 896bea1ee64705bfc8753d7b3d1d51fddf43efaf (diff) | |
download | opie-bbb2c5fee87baa345ff5c16404204054442f5c11.zip opie-bbb2c5fee87baa345ff5c16404204054442f5c11.tar.gz opie-bbb2c5fee87baa345ff5c16404204054442f5c11.tar.bz2 |
fixing incompatibility to orignal sharp rom
-rw-r--r-- | library/backend/vobject.cpp | 7 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 15 |
2 files changed, 21 insertions, 1 deletions
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index dab128e..2f22c20 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp | |||
@@ -922,394 +922,399 @@ stuff: | |||
922 | else if (fp->alloc) { | 922 | else if (fp->alloc) { |
923 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; | 923 | fp->limit = fp->limit + OFILE_REALLOC_SIZE; |
924 | fp->s = (char *)realloc(fp->s,fp->limit); | 924 | fp->s = (char *)realloc(fp->s,fp->limit); |
925 | if (fp->s) goto stuff; | 925 | if (fp->s) goto stuff; |
926 | } | 926 | } |
927 | if (fp->alloc) | 927 | if (fp->alloc) |
928 | free(fp->s); | 928 | free(fp->s); |
929 | fp->s = 0; | 929 | fp->s = 0; |
930 | fp->fail = 1; | 930 | fp->fail = 1; |
931 | } | 931 | } |
932 | } | 932 | } |
933 | 933 | ||
934 | static void appendcOFile(OFile *fp, char c) | 934 | static void appendcOFile(OFile *fp, char c) |
935 | { | 935 | { |
936 | if (c == '\n') { | 936 | if (c == '\n') { |
937 | /* write out as <CR><LF> */ | 937 | /* write out as <CR><LF> */ |
938 | appendcOFile_(fp,0xd); | 938 | appendcOFile_(fp,0xd); |
939 | appendcOFile_(fp,0xa); | 939 | appendcOFile_(fp,0xa); |
940 | } | 940 | } |
941 | else | 941 | else |
942 | appendcOFile_(fp,c); | 942 | appendcOFile_(fp,c); |
943 | } | 943 | } |
944 | 944 | ||
945 | static void appendsOFile(OFile *fp, const char *s) | 945 | static void appendsOFile(OFile *fp, const char *s) |
946 | { | 946 | { |
947 | int i, slen; | 947 | int i, slen; |
948 | slen = strlen(s); | 948 | slen = strlen(s); |
949 | for (i=0; i<slen; i++) { | 949 | for (i=0; i<slen; i++) { |
950 | appendcOFile(fp,s[i]); | 950 | appendcOFile(fp,s[i]); |
951 | } | 951 | } |
952 | } | 952 | } |
953 | 953 | ||
954 | #endif | 954 | #endif |
955 | 955 | ||
956 | static void initOFile(OFile *fp, FILE *ofp) | 956 | static void initOFile(OFile *fp, FILE *ofp) |
957 | { | 957 | { |
958 | fp->fp = ofp; | 958 | fp->fp = ofp; |
959 | fp->s = 0; | 959 | fp->s = 0; |
960 | fp->len = 0; | 960 | fp->len = 0; |
961 | fp->limit = 0; | 961 | fp->limit = 0; |
962 | fp->alloc = 0; | 962 | fp->alloc = 0; |
963 | fp->fail = 0; | 963 | fp->fail = 0; |
964 | } | 964 | } |
965 | 965 | ||
966 | static int writeBase64(OFile *fp, unsigned char *s, long len) | 966 | static int writeBase64(OFile *fp, unsigned char *s, long len) |
967 | { | 967 | { |
968 | long cur = 0; | 968 | long cur = 0; |
969 | int i, numQuads = 0; | 969 | int i, numQuads = 0; |
970 | unsigned long trip; | 970 | unsigned long trip; |
971 | unsigned char b; | 971 | unsigned char b; |
972 | char quad[5]; | 972 | char quad[5]; |
973 | #define MAXQUADS 16 | 973 | #define MAXQUADS 16 |
974 | 974 | ||
975 | quad[4] = 0; | 975 | quad[4] = 0; |
976 | 976 | ||
977 | while (cur < len) { | 977 | while (cur < len) { |
978 | // collect the triplet of bytes into 'trip' | 978 | // collect the triplet of bytes into 'trip' |
979 | trip = 0; | 979 | trip = 0; |
980 | for (i = 0; i < 3; i++) { | 980 | for (i = 0; i < 3; i++) { |
981 | b = (cur < len) ? *(s + cur) : 0; | 981 | b = (cur < len) ? *(s + cur) : 0; |
982 | cur++; | 982 | cur++; |
983 | trip = trip << 8 | b; | 983 | trip = trip << 8 | b; |
984 | } | 984 | } |
985 | // fill in 'quad' with the appropriate four characters | 985 | // fill in 'quad' with the appropriate four characters |
986 | for (i = 3; i >= 0; i--) { | 986 | for (i = 3; i >= 0; i--) { |
987 | b = (unsigned char)(trip & 0x3F); | 987 | b = (unsigned char)(trip & 0x3F); |
988 | trip = trip >> 6; | 988 | trip = trip >> 6; |
989 | if ((3 - i) < (cur - len)) | 989 | if ((3 - i) < (cur - len)) |
990 | quad[i] = '='; // pad char | 990 | quad[i] = '='; // pad char |
991 | else if (b < 26) quad[i] = (char)b + 'A'; | 991 | else if (b < 26) quad[i] = (char)b + 'A'; |
992 | else if (b < 52) quad[i] = (char)(b - 26) + 'a'; | 992 | else if (b < 52) quad[i] = (char)(b - 26) + 'a'; |
993 | else if (b < 62) quad[i] = (char)(b - 52) + '0'; | 993 | else if (b < 62) quad[i] = (char)(b - 52) + '0'; |
994 | else if (b == 62) quad[i] = '+'; | 994 | else if (b == 62) quad[i] = '+'; |
995 | else quad[i] = '/'; | 995 | else quad[i] = '/'; |
996 | } | 996 | } |
997 | // now output 'quad' with appropriate whitespace and line ending | 997 | // now output 'quad' with appropriate whitespace and line ending |
998 | appendsOFile(fp, (numQuads == 0 ? " " : "")); | 998 | appendsOFile(fp, (numQuads == 0 ? " " : "")); |
999 | appendsOFile(fp, quad); | 999 | appendsOFile(fp, quad); |
1000 | appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : ""))); | 1000 | appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : ""))); |
1001 | numQuads = (numQuads + 1) % MAXQUADS; | 1001 | numQuads = (numQuads + 1) % MAXQUADS; |
1002 | } | 1002 | } |
1003 | appendcOFile(fp,'\n'); | 1003 | appendcOFile(fp,'\n'); |
1004 | 1004 | ||
1005 | return 1; | 1005 | return 1; |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | static const char *replaceChar(unsigned char c) | 1008 | static const char *replaceChar(unsigned char c) |
1009 | { | 1009 | { |
1010 | if (c == '\n') { | 1010 | if (c == '\n') { |
1011 | return "=0A=\n"; | 1011 | return "=0A=\n"; |
1012 | } else if ( | 1012 | } else if ( |
1013 | (c >= 'A' && c <= 'Z') | 1013 | (c >= 'A' && c <= 'Z') |
1014 | || | 1014 | || |
1015 | (c >= 'a' && c <= 'z') | 1015 | (c >= 'a' && c <= 'z') |
1016 | || | 1016 | || |
1017 | (c >= '0' && c <= '9') | 1017 | (c >= '0' && c <= '9') |
1018 | || | 1018 | || |
1019 | (c >= '\'' && c <= ')') | 1019 | (c >= '\'' && c <= ')') |
1020 | || | 1020 | || |
1021 | (c >= '+' && c <= '-') | 1021 | (c >= '+' && c <= '-') |
1022 | || | 1022 | || |
1023 | (c == '/') | 1023 | (c == '/') |
1024 | || | 1024 | || |
1025 | (c == '?') | 1025 | (c == '?') |
1026 | || | 1026 | || |
1027 | (c == ' ')) | 1027 | (c == ' ')) |
1028 | { | 1028 | { |
1029 | return 0; | 1029 | return 0; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | static char trans[4]; | 1032 | static char trans[4]; |
1033 | trans[0] = '='; | 1033 | trans[0] = '='; |
1034 | trans[3] = '\0'; | 1034 | trans[3] = '\0'; |
1035 | int rem = c % 16; | 1035 | int rem = c % 16; |
1036 | int div = c / 16; | 1036 | int div = c / 16; |
1037 | 1037 | ||
1038 | if (div < 10) | 1038 | if (div < 10) |
1039 | trans[1] = '0' + div; | 1039 | trans[1] = '0' + div; |
1040 | else | 1040 | else |
1041 | trans[1] = 'A' + (div - 10); | 1041 | trans[1] = 'A' + (div - 10); |
1042 | 1042 | ||
1043 | if (rem < 10) | 1043 | if (rem < 10) |
1044 | trans[2] = '0' + rem; | 1044 | trans[2] = '0' + rem; |
1045 | else | 1045 | else |
1046 | trans[2] = 'A' + (rem - 10); | 1046 | trans[2] = 'A' + (rem - 10); |
1047 | 1047 | ||
1048 | return trans; | 1048 | return trans; |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | static void writeQPString(OFile *fp, const char *s) | 1051 | static void writeQPString(OFile *fp, const char *s) |
1052 | { | 1052 | { |
1053 | /* | 1053 | /* |
1054 | only A-Z, 0-9 and | 1054 | only A-Z, 0-9 and |
1055 | "'" (ASCII code 39) | 1055 | "'" (ASCII code 39) |
1056 | "(" (ASCII code 40) | 1056 | "(" (ASCII code 40) |
1057 | ")" (ASCII code 41) | 1057 | ")" (ASCII code 41) |
1058 | "+" (ASCII code 43) | 1058 | "+" (ASCII code 43) |
1059 | "," (ASCII code 44) | 1059 | "," (ASCII code 44) |
1060 | "-" (ASCII code 45) | 1060 | "-" (ASCII code 45) |
1061 | "/" (ASCII code 47) | 1061 | "/" (ASCII code 47) |
1062 | "?" (ASCII code 63) | 1062 | "?" (ASCII code 63) |
1063 | 1063 | ||
1064 | should remain un-encoded. | 1064 | should remain un-encoded. |
1065 | '=' needs to be encoded as it is the escape character. | 1065 | '=' needs to be encoded as it is the escape character. |
1066 | ';' needs to be as it is a field separator. | 1066 | ';' needs to be as it is a field separator. |
1067 | 1067 | ||
1068 | */ | 1068 | */ |
1069 | const char *p = s; | 1069 | const char *p = s; |
1070 | while (*p) { | 1070 | while (*p) { |
1071 | const char *rep = replaceChar(*p); | 1071 | const char *rep = replaceChar(*p); |
1072 | if (rep) | 1072 | if (rep) |
1073 | appendsOFile(fp, rep); | 1073 | appendsOFile(fp, rep); |
1074 | else | 1074 | else |
1075 | appendcOFile(fp, *p); | 1075 | appendcOFile(fp, *p); |
1076 | p++; | 1076 | p++; |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | static bool includesUnprintable(VObject *o) | 1080 | static bool includesUnprintable(VObject *o) |
1081 | { | 1081 | { |
1082 | if (o) { | 1082 | if (o) { |
1083 | if (VALUE_TYPE(o) == VCVT_STRINGZ) { | 1083 | if (VALUE_TYPE(o) == VCVT_STRINGZ) { |
1084 | const char *p = STRINGZ_VALUE_OF(o); | 1084 | const char *p = STRINGZ_VALUE_OF(o); |
1085 | if (p) { | 1085 | if (p) { |
1086 | while (*p) { | 1086 | while (*p) { |
1087 | if (replaceChar(*p)) | 1087 | if (replaceChar(*p)) |
1088 | return TRUE; | 1088 | return TRUE; |
1089 | p++; | 1089 | p++; |
1090 | } | 1090 | } |
1091 | } | 1091 | } |
1092 | } | 1092 | } |
1093 | } | 1093 | } |
1094 | return FALSE; | 1094 | return FALSE; |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | static void writeVObject_(OFile *fp, VObject *o); | 1097 | static void writeVObject_(OFile *fp, VObject *o); |
1098 | 1098 | ||
1099 | static void writeValue(OFile *fp, VObject *o, unsigned long size) | 1099 | static void writeValue(OFile *fp, VObject *o, unsigned long size) |
1100 | { | 1100 | { |
1101 | if (o == 0) return; | 1101 | if (o == 0) return; |
1102 | switch (VALUE_TYPE(o)) { | 1102 | switch (VALUE_TYPE(o)) { |
1103 | case VCVT_STRINGZ: { | 1103 | case VCVT_STRINGZ: { |
1104 | writeQPString(fp, STRINGZ_VALUE_OF(o)); | 1104 | writeQPString(fp, STRINGZ_VALUE_OF(o)); |
1105 | break; | 1105 | break; |
1106 | } | 1106 | } |
1107 | case VCVT_UINT: { | 1107 | case VCVT_UINT: { |
1108 | char buf[16]; | 1108 | char buf[16]; |
1109 | sprintf(buf,"%u", INTEGER_VALUE_OF(o)); | 1109 | sprintf(buf,"%u", INTEGER_VALUE_OF(o)); |
1110 | appendsOFile(fp,buf); | 1110 | appendsOFile(fp,buf); |
1111 | break; | 1111 | break; |
1112 | } | 1112 | } |
1113 | case VCVT_ULONG: { | 1113 | case VCVT_ULONG: { |
1114 | char buf[16]; | 1114 | char buf[16]; |
1115 | sprintf(buf,"%lu", LONG_VALUE_OF(o)); | 1115 | sprintf(buf,"%lu", LONG_VALUE_OF(o)); |
1116 | appendsOFile(fp,buf); | 1116 | appendsOFile(fp,buf); |
1117 | break; | 1117 | break; |
1118 | } | 1118 | } |
1119 | case VCVT_RAW: { | 1119 | case VCVT_RAW: { |
1120 | appendcOFile(fp,'\n'); | 1120 | appendcOFile(fp,'\n'); |
1121 | writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); | 1121 | writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); |
1122 | break; | 1122 | break; |
1123 | } | 1123 | } |
1124 | case VCVT_VOBJECT: | 1124 | case VCVT_VOBJECT: |
1125 | appendcOFile(fp,'\n'); | 1125 | appendcOFile(fp,'\n'); |
1126 | writeVObject_(fp,VOBJECT_VALUE_OF(o)); | 1126 | writeVObject_(fp,VOBJECT_VALUE_OF(o)); |
1127 | break; | 1127 | break; |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | static void writeAttrValue(OFile *fp, VObject *o) | 1131 | static void writeAttrValue(OFile *fp, VObject *o) |
1132 | { | 1132 | { |
1133 | if (NAME_OF(o)) { | 1133 | if (NAME_OF(o)) { |
1134 | struct PreDefProp *pi; | 1134 | struct PreDefProp *pi; |
1135 | pi = lookupPropInfo(NAME_OF(o)); | 1135 | pi = lookupPropInfo(NAME_OF(o)); |
1136 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; | 1136 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; |
1137 | if ( includesUnprintable(o) ) { | 1137 | if ( includesUnprintable(o) ) { |
1138 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | 1138 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); |
1139 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | 1139 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); |
1140 | } | 1140 | } |
1141 | appendcOFile(fp,';'); | 1141 | appendcOFile(fp,';'); |
1142 | appendsOFile(fp,NAME_OF(o)); | 1142 | appendsOFile(fp,NAME_OF(o)); |
1143 | } | 1143 | } |
1144 | else | 1144 | else |
1145 | appendcOFile(fp,';'); | 1145 | appendcOFile(fp,';'); |
1146 | if (VALUE_TYPE(o)) { | 1146 | if (VALUE_TYPE(o)) { |
1147 | appendcOFile(fp,'='); | 1147 | appendcOFile(fp,'='); |
1148 | writeValue(fp,o,0); | 1148 | writeValue(fp,o,0); |
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | static void writeGroup(OFile *fp, VObject *o) | 1152 | static void writeGroup(OFile *fp, VObject *o) |
1153 | { | 1153 | { |
1154 | char buf1[256]; | 1154 | char buf1[256]; |
1155 | char buf2[256]; | 1155 | char buf2[256]; |
1156 | strcpy(buf1,NAME_OF(o)); | 1156 | strcpy(buf1,NAME_OF(o)); |
1157 | while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { | 1157 | while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { |
1158 | strcpy(buf2,STRINGZ_VALUE_OF(o)); | 1158 | strcpy(buf2,STRINGZ_VALUE_OF(o)); |
1159 | strcat(buf2,"."); | 1159 | strcat(buf2,"."); |
1160 | strcat(buf2,buf1); | 1160 | strcat(buf2,buf1); |
1161 | strcpy(buf1,buf2); | 1161 | strcpy(buf1,buf2); |
1162 | } | 1162 | } |
1163 | appendsOFile(fp,buf1); | 1163 | appendsOFile(fp,buf1); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | static int inList(const char **list, const char *s) | 1166 | static int inList(const char **list, const char *s) |
1167 | { | 1167 | { |
1168 | if (list == 0) return 0; | 1168 | if (list == 0) return 0; |
1169 | while (*list) { | 1169 | while (*list) { |
1170 | if (qstricmp(*list,s) == 0) return 1; | 1170 | if (qstricmp(*list,s) == 0) return 1; |
1171 | list++; | 1171 | list++; |
1172 | } | 1172 | } |
1173 | return 0; | 1173 | return 0; |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | static void writeProp(OFile *fp, VObject *o) | 1176 | static void writeProp(OFile *fp, VObject *o) |
1177 | { | 1177 | { |
1178 | if (NAME_OF(o)) { | 1178 | if (NAME_OF(o)) { |
1179 | struct PreDefProp *pi; | 1179 | struct PreDefProp *pi; |
1180 | VObjectIterator t; | 1180 | VObjectIterator t; |
1181 | const char **fields_ = 0; | 1181 | const char **fields_ = 0; |
1182 | pi = lookupPropInfo(NAME_OF(o)); | 1182 | pi = lookupPropInfo(NAME_OF(o)); |
1183 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { | 1183 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { |
1184 | writeVObject_(fp,o); | 1184 | writeVObject_(fp,o); |
1185 | return; | 1185 | return; |
1186 | } | 1186 | } |
1187 | if (isAPropertyOf(o,VCGroupingProp)) | 1187 | if (isAPropertyOf(o,VCGroupingProp)) |
1188 | writeGroup(fp,o); | 1188 | writeGroup(fp,o); |
1189 | else | 1189 | else |
1190 | appendsOFile(fp,NAME_OF(o)); | 1190 | appendsOFile(fp,NAME_OF(o)); |
1191 | if (pi) fields_ = pi->fields; | 1191 | if (pi) fields_ = pi->fields; |
1192 | initPropIterator(&t,o); | 1192 | initPropIterator(&t,o); |
1193 | while (moreIteration(&t)) { | 1193 | while (moreIteration(&t)) { |
1194 | const char *s; | 1194 | const char *s; |
1195 | VObject *eachProp = nextVObject(&t); | 1195 | VObject *eachProp = nextVObject(&t); |
1196 | s = NAME_OF(eachProp); | 1196 | s = NAME_OF(eachProp); |
1197 | if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) | 1197 | if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) |
1198 | writeAttrValue(fp,eachProp); | 1198 | writeAttrValue(fp,eachProp); |
1199 | } | 1199 | } |
1200 | if (fields_) { | 1200 | if (fields_) { |
1201 | int i = 0, n = 0; | 1201 | int i = 0, n = 0; |
1202 | const char** fields = fields_; | 1202 | const char** fields = fields_; |
1203 | /* output prop as fields */ | 1203 | /* output prop as fields */ |
1204 | bool printable = TRUE; | 1204 | bool printable = TRUE; |
1205 | while (*fields && printable) { | 1205 | while (*fields && printable) { |
1206 | VObject *t = isAPropertyOf(o,*fields); | 1206 | VObject *t = isAPropertyOf(o,*fields); |
1207 | if (includesUnprintable(t)) | 1207 | if (includesUnprintable(t)) |
1208 | printable = FALSE; | 1208 | printable = FALSE; |
1209 | fields++; | 1209 | fields++; |
1210 | } | 1210 | } |
1211 | fields = fields_; | 1211 | fields = fields_; |
1212 | if (!printable) { | 1212 | if (!printable) { |
1213 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | 1213 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); |
1214 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | 1214 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); |
1215 | } | 1215 | } |
1216 | appendcOFile(fp,':'); | 1216 | appendcOFile(fp,':'); |
1217 | while (*fields) { | 1217 | while (*fields) { |
1218 | VObject *t = isAPropertyOf(o,*fields); | 1218 | VObject *t = isAPropertyOf(o,*fields); |
1219 | i++; | 1219 | i++; |
1220 | if (t) n = i; | 1220 | if (t) n = i; |
1221 | fields++; | 1221 | fields++; |
1222 | } | 1222 | } |
1223 | fields = fields_; | 1223 | fields = fields_; |
1224 | for (i=0;i<n;i++) { | 1224 | for (i=0;i<n;i++) { |
1225 | writeValue(fp,isAPropertyOf(o,*fields),0); | 1225 | writeValue(fp,isAPropertyOf(o,*fields),0); |
1226 | fields++; | 1226 | fields++; |
1227 | if (i<(n-1)) appendcOFile(fp,';'); | 1227 | if (i<(n-1)) appendcOFile(fp,';'); |
1228 | } | 1228 | } |
1229 | } | 1229 | } |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | 1232 | ||
1233 | if (VALUE_TYPE(o)) { | 1233 | if (VALUE_TYPE(o)) { |
1234 | if ( includesUnprintable(o) ) { | 1234 | if ( includesUnprintable(o) ) { |
1235 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | 1235 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); |
1236 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | 1236 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); |
1237 | } | 1237 | } |
1238 | unsigned long size = 0; | 1238 | unsigned long size = 0; |
1239 | VObject *p = isAPropertyOf(o,VCDataSizeProp); | 1239 | VObject *p = isAPropertyOf(o,VCDataSizeProp); |
1240 | if (p) size = LONG_VALUE_OF(p); | 1240 | if (p) size = LONG_VALUE_OF(p); |
1241 | appendcOFile(fp,':'); | 1241 | appendcOFile(fp,':'); |
1242 | writeValue(fp,o,size); | 1242 | writeValue(fp,o,size); |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | appendcOFile(fp,'\n'); | 1245 | appendcOFile(fp,'\n'); |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | static void writeVObject_(OFile *fp, VObject *o) | 1248 | static void writeVObject_(OFile *fp, VObject *o) |
1249 | { | 1249 | { |
1250 | if (NAME_OF(o)) { | 1250 | if (NAME_OF(o)) { |
1251 | struct PreDefProp *pi; | 1251 | struct PreDefProp *pi; |
1252 | pi = lookupPropInfo(NAME_OF(o)); | 1252 | pi = lookupPropInfo(NAME_OF(o)); |
1253 | 1253 | ||
1254 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { | 1254 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { |
1255 | VObjectIterator t; | 1255 | VObjectIterator t; |
1256 | const char *begin = NAME_OF(o); | 1256 | const char *begin = NAME_OF(o); |
1257 | appendsOFile(fp,"BEGIN:"); | 1257 | appendsOFile(fp,"BEGIN:"); |
1258 | appendsOFile(fp,begin); | 1258 | appendsOFile(fp,begin); |
1259 | appendcOFile(fp,'\n'); | 1259 | appendcOFile(fp,'\n'); |
1260 | initPropIterator(&t,o); | 1260 | initPropIterator(&t,o); |
1261 | while (moreIteration(&t)) { | 1261 | while (moreIteration(&t)) { |
1262 | VObject *eachProp = nextVObject(&t); | 1262 | VObject *eachProp = nextVObject(&t); |
1263 | writeProp(fp, eachProp); | 1263 | writeProp(fp, eachProp); |
1264 | } | 1264 | } |
1265 | appendsOFile(fp,"END:"); | 1265 | appendsOFile(fp,"END:"); |
1266 | appendsOFile(fp,begin); | 1266 | appendsOFile(fp,begin); |
1267 | appendsOFile(fp,"\n\n"); | 1267 | appendsOFile(fp,"\n\n"); |
1268 | } | 1268 | } |
1269 | } | 1269 | } |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | void writeVObject(FILE *fp, VObject *o) | 1272 | void writeVObject(FILE *fp, VObject *o) |
1273 | { | 1273 | { |
1274 | OFile ofp; | 1274 | OFile ofp; |
1275 | // ##### | 1275 | // ##### |
1276 | //_setmode(_fileno(fp), _O_BINARY); | 1276 | //_setmode(_fileno(fp), _O_BINARY); |
1277 | initOFile(&ofp,fp); | 1277 | initOFile(&ofp,fp); |
1278 | writeVObject_(&ofp,o); | 1278 | writeVObject_(&ofp,o); |
1279 | } | 1279 | } |
1280 | 1280 | ||
1281 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) | 1281 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) |
1282 | { | 1282 | { |
1283 | QFileDirect f( fname); | 1283 | QFileDirect f( fname); |
1284 | if ( !f.open( IO_WriteOnly ) ) { | 1284 | if ( !f.open( IO_WriteOnly ) ) { |
1285 | qWarning("Unable to open vobject write %s", fname); | 1285 | qWarning("Unable to open vobject write %s", fname); |
1286 | return; | 1286 | return; |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | writeVObject( f.directHandle(),o ); | 1289 | writeVObject( f.directHandle(),o ); |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) | 1292 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) |
1293 | { | 1293 | { |
1294 | QFileDirect f( fname); | 1294 | QFileDirect f( fname); |
1295 | if ( !f.open( IO_WriteOnly ) ) { | 1295 | if ( !f.open( IO_WriteOnly ) ) { |
1296 | qWarning("Unable to open vobject write %s", fname); | 1296 | qWarning("Unable to open vobject write %s", fname); |
1297 | return; | 1297 | return; |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | while (list) { | 1300 | while (list) { |
1301 | writeVObject(f.directHandle(),list); | 1301 | writeVObject(f.directHandle(),list); |
1302 | list = nextVObjectInList(list); | 1302 | list = nextVObjectInList(list); |
1303 | } | 1303 | } |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | #ifndef __SHARP_COMP_ | ||
1307 | |||
1308 | // This function is not available in the Sharp ROM for SL 5500 ! | ||
1309 | // Therefore I have to move it into the header file.. (se) | ||
1310 | |||
1306 | DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) | 1311 | DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) |
1307 | { | 1312 | { |
1308 | const char *type = vObjectName( o ); | 1313 | const char *type = vObjectName( o ); |
1309 | if ( strcmp( type, "TYPE" ) == 0 ) | 1314 | if ( strcmp( type, "TYPE" ) == 0 ) |
1310 | type = vObjectStringZValue( o ); | 1315 | type = vObjectStringZValue( o ); |
1311 | return type; | 1316 | return type; |
1312 | } | 1317 | } |
1313 | 1318 | #endif | |
1314 | 1319 | ||
1315 | // end of source file vobject.c | 1320 | // end of source file vobject.c |
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index 0d0a2a8..bab22bb 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h | |||
@@ -17,390 +17,405 @@ 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 | 40 | ||
41 | The vCard/vCalendar C interface is implemented in the set | 41 | The vCard/vCalendar C interface is implemented in the set |
42 | of files as follows: | 42 | of files as follows: |
43 | 43 | ||
44 | vcc.y, yacc source, and vcc.c, the yacc output you will use | 44 | vcc.y, yacc source, and vcc.c, the yacc output you will use |
45 | implements the core parser | 45 | implements the core parser |
46 | 46 | ||
47 | vobject.c implements an API that insulates the caller from | 47 | vobject.c implements an API that insulates the caller from |
48 | the parser and changes in the vCard/vCalendar BNF | 48 | the parser and changes in the vCard/vCalendar BNF |
49 | 49 | ||
50 | port.h defines compilation environment dependent stuff | 50 | port.h defines compilation environment dependent stuff |
51 | 51 | ||
52 | vcc.h and vobject.h are header files for their .c counterparts | 52 | vcc.h and vobject.h are header files for their .c counterparts |
53 | 53 | ||
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 <qglobal.h> | 102 | #include <qglobal.h> |
103 | #if defined(Q_WS_WIN) | 103 | #if defined(Q_WS_WIN) |
104 | #define DLLEXPORT(t) __declspec(dllexport) t | 104 | #define DLLEXPORT(t) __declspec(dllexport) t |
105 | #else | 105 | #else |
106 | #define DLLEXPORT(t) t | 106 | #define DLLEXPORT(t) t |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | #ifndef FALSE | 109 | #ifndef FALSE |
110 | #define FALSE0 | 110 | #define FALSE0 |
111 | #endif | 111 | #endif |
112 | #ifndef TRUE | 112 | #ifndef TRUE |
113 | #define TRUE1 | 113 | #define TRUE1 |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | #include <stdlib.h> | 116 | #include <stdlib.h> |
117 | #include <stdio.h> | 117 | #include <stdio.h> |
118 | 118 | ||
119 | 119 | ||
120 | #define VC7bitProp "7BIT" | 120 | #define VC7bitProp "7BIT" |
121 | #define VC8bitProp "8BIT" | 121 | #define VC8bitProp "8BIT" |
122 | #define VCAAlarmProp "AALARM" | 122 | #define VCAAlarmProp "AALARM" |
123 | #define VCAdditionalNamesProp"ADDN" | 123 | #define VCAdditionalNamesProp"ADDN" |
124 | #define VCAdrProp "ADR" | 124 | #define VCAdrProp "ADR" |
125 | #define VCAgentProp "AGENT" | 125 | #define VCAgentProp "AGENT" |
126 | #define VCAIFFProp "AIFF" | 126 | #define VCAIFFProp "AIFF" |
127 | #define VCAOLProp "AOL" | 127 | #define VCAOLProp "AOL" |
128 | #define VCAppleLinkProp "APPLELINK" | 128 | #define VCAppleLinkProp "APPLELINK" |
129 | #define VCAttachProp "ATTACH" | 129 | #define VCAttachProp "ATTACH" |
130 | #define VCAttendeeProp "ATTENDEE" | 130 | #define VCAttendeeProp "ATTENDEE" |
131 | #define VCATTMailProp "ATTMAIL" | 131 | #define VCATTMailProp "ATTMAIL" |
132 | #define VCAudioContentProp "AUDIOCONTENT" | 132 | #define VCAudioContentProp "AUDIOCONTENT" |
133 | #define VCAVIProp "AVI" | 133 | #define VCAVIProp "AVI" |
134 | #define VCBase64Prop "BASE64" | 134 | #define VCBase64Prop "BASE64" |
135 | #define VCBBSProp "BBS" | 135 | #define VCBBSProp "BBS" |
136 | #define VCBirthDateProp "BDAY" | 136 | #define VCBirthDateProp "BDAY" |
137 | #define VCBMPProp "BMP" | 137 | #define VCBMPProp "BMP" |
138 | #define VCBodyProp "BODY" | 138 | #define VCBodyProp "BODY" |
139 | #define VCBusinessRoleProp "ROLE" | 139 | #define VCBusinessRoleProp "ROLE" |
140 | #define VCCalProp "VCALENDAR" | 140 | #define VCCalProp "VCALENDAR" |
141 | #define VCCaptionProp "CAP" | 141 | #define VCCaptionProp "CAP" |
142 | #define VCCardProp "VCARD" | 142 | #define VCCardProp "VCARD" |
143 | #define VCCarProp "CAR" | 143 | #define VCCarProp "CAR" |
144 | #define VCCategoriesProp "CATEGORIES" | 144 | #define VCCategoriesProp "CATEGORIES" |
145 | #define VCCellularProp "CELL" | 145 | #define VCCellularProp "CELL" |
146 | #define VCCGMProp "CGM" | 146 | #define VCCGMProp "CGM" |
147 | #define VCCharSetProp "CHARSET" | 147 | #define VCCharSetProp "CHARSET" |
148 | #define VCCIDProp "CID" | 148 | #define VCCIDProp "CID" |
149 | #define VCCISProp "CIS" | 149 | #define VCCISProp "CIS" |
150 | #define VCCityProp "L" | 150 | #define VCCityProp "L" |
151 | #define VCClassProp "CLASS" | 151 | #define VCClassProp "CLASS" |
152 | #define VCCommentProp "NOTE" | 152 | #define VCCommentProp "NOTE" |
153 | #define VCCompletedProp "COMPLETED" | 153 | #define VCCompletedProp "COMPLETED" |
154 | #define VCContentIDProp "CONTENT-ID" | 154 | #define VCContentIDProp "CONTENT-ID" |
155 | #define VCCountryNameProp "C" | 155 | #define VCCountryNameProp "C" |
156 | #define VCDAlarmProp "DALARM" | 156 | #define VCDAlarmProp "DALARM" |
157 | #define VCDataSizeProp "DATASIZE" | 157 | #define VCDataSizeProp "DATASIZE" |
158 | #define VCDayLightProp "DAYLIGHT" | 158 | #define VCDayLightProp "DAYLIGHT" |
159 | #define VCDCreatedProp "DCREATED" | 159 | #define VCDCreatedProp "DCREATED" |
160 | #define VCDeliveryLabelProp "LABEL" | 160 | #define VCDeliveryLabelProp "LABEL" |
161 | #define VCDescriptionProp "DESCRIPTION" | 161 | #define VCDescriptionProp "DESCRIPTION" |
162 | #define VCDIBProp "DIB" | 162 | #define VCDIBProp "DIB" |
163 | #define VCDisplayStringProp "DISPLAYSTRING" | 163 | #define VCDisplayStringProp "DISPLAYSTRING" |
164 | #define VCDomesticProp "DOM" | 164 | #define VCDomesticProp "DOM" |
165 | #define VCDTendProp "DTEND" | 165 | #define VCDTendProp "DTEND" |
166 | #define VCDTstartProp "DTSTART" | 166 | #define VCDTstartProp "DTSTART" |
167 | #define VCDueProp "DUE" | 167 | #define VCDueProp "DUE" |
168 | #define VCEmailAddressProp "EMAIL" | 168 | #define VCEmailAddressProp "EMAIL" |
169 | #define VCEncodingProp "ENCODING" | 169 | #define VCEncodingProp "ENCODING" |
170 | #define VCEndProp "END" | 170 | #define VCEndProp "END" |
171 | #define VCEventProp "VEVENT" | 171 | #define VCEventProp "VEVENT" |
172 | #define VCEWorldProp "EWORLD" | 172 | #define VCEWorldProp "EWORLD" |
173 | #define VCExNumProp "EXNUM" | 173 | #define VCExNumProp "EXNUM" |
174 | #define VCExpDateProp "EXDATE" | 174 | #define VCExpDateProp "EXDATE" |
175 | #define VCExpectProp "EXPECT" | 175 | #define VCExpectProp "EXPECT" |
176 | #define VCExtAddressProp "EXT ADD" | 176 | #define VCExtAddressProp "EXT ADD" |
177 | #define VCFamilyNameProp "F" | 177 | #define VCFamilyNameProp "F" |
178 | #define VCFaxProp "FAX" | 178 | #define VCFaxProp "FAX" |
179 | #define VCFullNameProp "FN" | 179 | #define VCFullNameProp "FN" |
180 | #define VCGeoProp "GEO" | 180 | #define VCGeoProp "GEO" |
181 | #define VCGeoLocationProp "GEO" | 181 | #define VCGeoLocationProp "GEO" |
182 | #define VCGIFProp "GIF" | 182 | #define VCGIFProp "GIF" |
183 | #define VCGivenNameProp "G" | 183 | #define VCGivenNameProp "G" |
184 | #define VCGroupingProp "Grouping" | 184 | #define VCGroupingProp "Grouping" |
185 | #define VCHomeProp "HOME" | 185 | #define VCHomeProp "HOME" |
186 | #define VCIBMMailProp "IBMMail" | 186 | #define VCIBMMailProp "IBMMail" |
187 | #define VCInlineProp "INLINE" | 187 | #define VCInlineProp "INLINE" |
188 | #define VCInternationalProp "INTL" | 188 | #define VCInternationalProp "INTL" |
189 | #define VCInternetProp "INTERNET" | 189 | #define VCInternetProp "INTERNET" |
190 | #define VCISDNProp "ISDN" | 190 | #define VCISDNProp "ISDN" |
191 | #define VCJPEGProp "JPEG" | 191 | #define VCJPEGProp "JPEG" |
192 | #define VCLanguageProp "LANG" | 192 | #define VCLanguageProp "LANG" |
193 | #define VCLastModifiedProp "LAST-MODIFIED" | 193 | #define VCLastModifiedProp "LAST-MODIFIED" |
194 | #define VCLastRevisedProp "REV" | 194 | #define VCLastRevisedProp "REV" |
195 | #define VCLocationProp "LOCATION" | 195 | #define VCLocationProp "LOCATION" |
196 | #define VCLogoProp "LOGO" | 196 | #define VCLogoProp "LOGO" |
197 | #define VCMailerProp "MAILER" | 197 | #define VCMailerProp "MAILER" |
198 | #define VCMAlarmProp "MALARM" | 198 | #define VCMAlarmProp "MALARM" |
199 | #define VCMCIMailProp "MCIMAIL" | 199 | #define VCMCIMailProp "MCIMAIL" |
200 | #define VCMessageProp "MSG" | 200 | #define VCMessageProp "MSG" |
201 | #define VCMETProp "MET" | 201 | #define VCMETProp "MET" |
202 | #define VCModemProp "MODEM" | 202 | #define VCModemProp "MODEM" |
203 | #define VCMPEG2Prop "MPEG2" | 203 | #define VCMPEG2Prop "MPEG2" |
204 | #define VCMPEGProp "MPEG" | 204 | #define VCMPEGProp "MPEG" |
205 | #define VCMSNProp "MSN" | 205 | #define VCMSNProp "MSN" |
206 | #define VCNamePrefixesProp "NPRE" | 206 | #define VCNamePrefixesProp "NPRE" |
207 | #define VCNameProp "N" | 207 | #define VCNameProp "N" |
208 | #define VCNameSuffixesProp "NSUF" | 208 | #define VCNameSuffixesProp "NSUF" |
209 | #define VCNoteProp "NOTE" | 209 | #define VCNoteProp "NOTE" |
210 | #define VCOrgNameProp "ORGNAME" | 210 | #define VCOrgNameProp "ORGNAME" |
211 | #define VCOrgProp "ORG" | 211 | #define VCOrgProp "ORG" |
212 | #define VCOrgUnit2Prop "OUN2" | 212 | #define VCOrgUnit2Prop "OUN2" |
213 | #define VCOrgUnit3Prop "OUN3" | 213 | #define VCOrgUnit3Prop "OUN3" |
214 | #define VCOrgUnit4Prop "OUN4" | 214 | #define VCOrgUnit4Prop "OUN4" |
215 | #define VCOrgUnitProp "OUN" | 215 | #define VCOrgUnitProp "OUN" |
216 | #define VCPagerProp "PAGER" | 216 | #define VCPagerProp "PAGER" |
217 | #define VCPAlarmProp "PALARM" | 217 | #define VCPAlarmProp "PALARM" |
218 | #define VCParcelProp "PARCEL" | 218 | #define VCParcelProp "PARCEL" |
219 | #define VCPartProp "PART" | 219 | #define VCPartProp "PART" |
220 | #define VCPCMProp "PCM" | 220 | #define VCPCMProp "PCM" |
221 | #define VCPDFProp "PDF" | 221 | #define VCPDFProp "PDF" |
222 | #define VCPGPProp "PGP" | 222 | #define VCPGPProp "PGP" |
223 | #define VCPhotoProp "PHOTO" | 223 | #define VCPhotoProp "PHOTO" |
224 | #define VCPICTProp "PICT" | 224 | #define VCPICTProp "PICT" |
225 | #define VCPMBProp "PMB" | 225 | #define VCPMBProp "PMB" |
226 | #define VCPostalBoxProp "BOX" | 226 | #define VCPostalBoxProp "BOX" |
227 | #define VCPostalCodeProp "PC" | 227 | #define VCPostalCodeProp "PC" |
228 | #define VCPostalProp "POSTAL" | 228 | #define VCPostalProp "POSTAL" |
229 | #define VCPowerShareProp "POWERSHARE" | 229 | #define VCPowerShareProp "POWERSHARE" |
230 | #define VCPreferredProp "PREF" | 230 | #define VCPreferredProp "PREF" |
231 | #define VCPriorityProp "PRIORITY" | 231 | #define VCPriorityProp "PRIORITY" |
232 | #define VCProcedureNameProp "PROCEDURENAME" | 232 | #define VCProcedureNameProp "PROCEDURENAME" |
233 | #define VCProdIdProp "PRODID" | 233 | #define VCProdIdProp "PRODID" |
234 | #define VCProdigyProp "PRODIGY" | 234 | #define VCProdigyProp "PRODIGY" |
235 | #define VCPronunciationProp "SOUND" | 235 | #define VCPronunciationProp "SOUND" |
236 | #define VCPSProp "PS" | 236 | #define VCPSProp "PS" |
237 | #define VCPublicKeyProp "KEY" | 237 | #define VCPublicKeyProp "KEY" |
238 | #define VCQPProp "QP" | 238 | #define VCQPProp "QP" |
239 | #define VCQuickTimeProp "QTIME" | 239 | #define VCQuickTimeProp "QTIME" |
240 | #define VCQuotedPrintableProp"QUOTED-PRINTABLE" | 240 | #define VCQuotedPrintableProp"QUOTED-PRINTABLE" |
241 | #define VCRDateProp "RDATE" | 241 | #define VCRDateProp "RDATE" |
242 | #define VCRegionProp "R" | 242 | #define VCRegionProp "R" |
243 | #define VCRelatedToProp "RELATED-TO" | 243 | #define VCRelatedToProp "RELATED-TO" |
244 | #define VCRepeatCountProp "REPEATCOUNT" | 244 | #define VCRepeatCountProp "REPEATCOUNT" |
245 | #define VCResourcesProp "RESOURCES" | 245 | #define VCResourcesProp "RESOURCES" |
246 | #define VCRNumProp "RNUM" | 246 | #define VCRNumProp "RNUM" |
247 | #define VCRoleProp "ROLE" | 247 | #define VCRoleProp "ROLE" |
248 | #define VCRRuleProp "RRULE" | 248 | #define VCRRuleProp "RRULE" |
249 | #define VCRSVPProp "RSVP" | 249 | #define VCRSVPProp "RSVP" |
250 | #define VCRunTimeProp "RUNTIME" | 250 | #define VCRunTimeProp "RUNTIME" |
251 | #define VCSequenceProp "SEQUENCE" | 251 | #define VCSequenceProp "SEQUENCE" |
252 | #define VCSnoozeTimeProp "SNOOZETIME" | 252 | #define VCSnoozeTimeProp "SNOOZETIME" |
253 | #define VCStartProp "START" | 253 | #define VCStartProp "START" |
254 | #define VCStatusProp "STATUS" | 254 | #define VCStatusProp "STATUS" |
255 | #define VCStreetAddressProp "STREET" | 255 | #define VCStreetAddressProp "STREET" |
256 | #define VCSubTypeProp "SUBTYPE" | 256 | #define VCSubTypeProp "SUBTYPE" |
257 | #define VCSummaryProp "SUMMARY" | 257 | #define VCSummaryProp "SUMMARY" |
258 | #define VCTelephoneProp "TEL" | 258 | #define VCTelephoneProp "TEL" |
259 | #define VCTIFFProp "TIFF" | 259 | #define VCTIFFProp "TIFF" |
260 | #define VCTimeZoneProp "TZ" | 260 | #define VCTimeZoneProp "TZ" |
261 | #define VCTitleProp "TITLE" | 261 | #define VCTitleProp "TITLE" |
262 | #define VCTLXProp "TLX" | 262 | #define VCTLXProp "TLX" |
263 | #define VCTodoProp "VTODO" | 263 | #define VCTodoProp "VTODO" |
264 | #define VCTranspProp "TRANSP" | 264 | #define VCTranspProp "TRANSP" |
265 | #define VCUniqueStringProp "UID" | 265 | #define VCUniqueStringProp "UID" |
266 | #define VCURLProp "URL" | 266 | #define VCURLProp "URL" |
267 | #define VCURLValueProp "URLVAL" | 267 | #define VCURLValueProp "URLVAL" |
268 | #define VCValueProp "VALUE" | 268 | #define VCValueProp "VALUE" |
269 | #define VCVersionProp "VERSION" | 269 | #define VCVersionProp "VERSION" |
270 | #define VCVideoProp "VIDEO" | 270 | #define VCVideoProp "VIDEO" |
271 | #define VCVoiceProp "VOICE" | 271 | #define VCVoiceProp "VOICE" |
272 | #define VCWAVEProp "WAVE" | 272 | #define VCWAVEProp "WAVE" |
273 | #define VCWMFProp "WMF" | 273 | #define VCWMFProp "WMF" |
274 | #define VCWorkProp "WORK" | 274 | #define VCWorkProp "WORK" |
275 | #define VCX400Prop "X400" | 275 | #define VCX400Prop "X400" |
276 | #define VCX509Prop "X509" | 276 | #define VCX509Prop "X509" |
277 | #define VCXRuleProp "XRULE" | 277 | #define VCXRuleProp "XRULE" |
278 | 278 | ||
279 | 279 | ||
280 | typedef struct VObject VObject; | 280 | typedef struct VObject VObject; |
281 | 281 | ||
282 | typedef struct VObjectIterator { | 282 | typedef struct VObjectIterator { |
283 | VObject* start; | 283 | VObject* start; |
284 | VObject* next; | 284 | VObject* next; |
285 | } VObjectIterator; | 285 | } VObjectIterator; |
286 | 286 | ||
287 | extern DLLEXPORT(VObject*) newVObject(const char *id); | 287 | extern DLLEXPORT(VObject*) newVObject(const char *id); |
288 | extern DLLEXPORT(void) deleteVObject(VObject *p); | 288 | extern DLLEXPORT(void) deleteVObject(VObject *p); |
289 | extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size); | 289 | extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size); |
290 | extern DLLEXPORT(void) deleteStr(const char *p); | 290 | extern DLLEXPORT(void) deleteStr(const char *p); |
291 | extern DLLEXPORT(void) unUseStr(const char *s); | 291 | extern DLLEXPORT(void) unUseStr(const char *s); |
292 | 292 | ||
293 | extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id); | 293 | extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id); |
294 | extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s); | 294 | extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s); |
295 | extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s); | 295 | extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s); |
296 | extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i); | 296 | extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i); |
297 | extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l); | 297 | extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l); |
298 | extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t); | 298 | extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t); |
299 | extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size); | 299 | extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size); |
300 | extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size); | 300 | extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size); |
301 | 301 | ||
302 | extern DLLEXPORT(const char*) vObjectName(VObject *o); | 302 | extern DLLEXPORT(const char*) vObjectName(VObject *o); |
303 | extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o); | 303 | extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o); |
304 | extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o); | 304 | extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o); |
305 | extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o); | 305 | extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o); |
306 | extern DLLEXPORT(void*) vObjectAnyValue(VObject *o); | 306 | extern DLLEXPORT(void*) vObjectAnyValue(VObject *o); |
307 | extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o); | 307 | extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o); |
308 | extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p); | 308 | extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p); |
309 | 309 | ||
310 | extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p); | 310 | extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p); |
311 | extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id); | 311 | extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id); |
312 | extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id); | 312 | extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id); |
313 | extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v); | 313 | extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v); |
314 | extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); | 314 | extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); |
315 | extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); | 315 | extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); |
316 | extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g); | 316 | extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g); |
317 | extern DLLEXPORT(void) addList(VObject **o, VObject *p); | 317 | extern DLLEXPORT(void) addList(VObject **o, VObject *p); |
318 | 318 | ||
319 | extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id); | 319 | extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id); |
320 | 320 | ||
321 | extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o); | 321 | extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o); |
322 | extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o); | 322 | extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o); |
323 | extern DLLEXPORT(int) moreIteration(VObjectIterator *i); | 323 | extern DLLEXPORT(int) moreIteration(VObjectIterator *i); |
324 | extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i); | 324 | extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i); |
325 | 325 | ||
326 | extern DLLEXPORT(const char*) lookupStr(const char *s); | 326 | extern DLLEXPORT(const char*) lookupStr(const char *s); |
327 | extern DLLEXPORT(void) cleanStrTbl(); | 327 | extern DLLEXPORT(void) cleanStrTbl(); |
328 | 328 | ||
329 | extern DLLEXPORT(void) cleanVObject(VObject *o); | 329 | extern DLLEXPORT(void) cleanVObject(VObject *o); |
330 | extern DLLEXPORT(void) cleanVObjects(VObject *list); | 330 | extern DLLEXPORT(void) cleanVObjects(VObject *list); |
331 | 331 | ||
332 | extern DLLEXPORT(const char*) lookupProp(const char* str); | 332 | extern DLLEXPORT(const char*) lookupProp(const char* str); |
333 | extern DLLEXPORT(const char*) lookupProp_(const char* str); | 333 | extern DLLEXPORT(const char*) lookupProp_(const char* str); |
334 | 334 | ||
335 | extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o); | 335 | extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o); |
336 | extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); | 336 | extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); |
337 | 337 | ||
338 | extern DLLEXPORT(int) vObjectValueType(VObject *o); | 338 | extern DLLEXPORT(int) vObjectValueType(VObject *o); |
339 | 339 | ||
340 | /* return type of vObjectValueType: */ | 340 | /* return type of vObjectValueType: */ |
341 | #define VCVT_NOVALUE0 | 341 | #define VCVT_NOVALUE0 |
342 | /* if the VObject has no value associated with it. */ | 342 | /* if the VObject has no value associated with it. */ |
343 | #define VCVT_STRINGZ1 | 343 | #define VCVT_STRINGZ1 |
344 | /* if the VObject has value set by setVObjectStringZValue. */ | 344 | /* if the VObject has value set by setVObjectStringZValue. */ |
345 | #define VCVT_UINT 2 | 345 | #define VCVT_UINT 2 |
346 | /* if the VObject has value set by setVObjectIntegerValue. */ | 346 | /* if the VObject has value set by setVObjectIntegerValue. */ |
347 | #define VCVT_ULONG 3 | 347 | #define VCVT_ULONG 3 |
348 | /* if the VObject has value set by setVObjectLongValue. */ | 348 | /* if the VObject has value set by setVObjectLongValue. */ |
349 | #define VCVT_RAW 4 | 349 | #define VCVT_RAW 4 |
350 | /* if the VObject has value set by setVObjectAnyValue. */ | 350 | /* if the VObject has value set by setVObjectAnyValue. */ |
351 | #define VCVT_VOBJECT5 | 351 | #define VCVT_VOBJECT5 |
352 | /* if the VObject has value set by setVObjectVObjectValue. */ | 352 | /* if the VObject has value set by setVObjectVObjectValue. */ |
353 | 353 | ||
354 | extern const char** fieldedProp; | 354 | extern const char** fieldedProp; |
355 | 355 | ||
356 | /*************************************************** | 356 | /*************************************************** |
357 | * The methods below are implemented in vcc.c (generated from vcc.y ) | 357 | * The methods below are implemented in vcc.c (generated from vcc.y ) |
358 | ***************************************************/ | 358 | ***************************************************/ |
359 | 359 | ||
360 | /* NOTE regarding printVObject and writeVObject | 360 | /* NOTE regarding printVObject and writeVObject |
361 | 361 | ||
362 | The functions below are not exported from the DLL because they | 362 | The functions below are not exported from the DLL because they |
363 | take a FILE* as a parameter, which cannot be passed across a DLL | 363 | take a FILE* as a parameter, which cannot be passed across a DLL |
364 | interface (at least that is my experience). Instead you can use | 364 | interface (at least that is my experience). Instead you can use |
365 | their companion functions which take file names or pointers | 365 | their companion functions which take file names or pointers |
366 | to memory. However, if you are linking this code into | 366 | to memory. However, if you are linking this code into |
367 | your build directly then you may find them a more convenient API | 367 | your build directly then you may find them a more convenient API |
368 | and you can go ahead and use them. If you try to use them with | 368 | and you can go ahead and use them. If you try to use them with |
369 | the DLL LIB you will get a link error. | 369 | the DLL LIB you will get a link error. |
370 | */ | 370 | */ |
371 | extern void writeVObject(FILE *fp, VObject *o); | 371 | extern void writeVObject(FILE *fp, VObject *o); |
372 | 372 | ||
373 | 373 | ||
374 | 374 | ||
375 | typedef void (*MimeErrorHandler)(char *); | 375 | typedef void (*MimeErrorHandler)(char *); |
376 | 376 | ||
377 | extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); | 377 | extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); |
378 | 378 | ||
379 | extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); | 379 | extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); |
380 | extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); | 380 | extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); |
381 | 381 | ||
382 | 382 | ||
383 | /* NOTE regarding Parse_MIME_FromFile | 383 | /* NOTE regarding Parse_MIME_FromFile |
384 | The function above, Parse_MIME_FromFile, comes in two flavors, | 384 | The function above, Parse_MIME_FromFile, comes in two flavors, |
385 | neither of which is exported from the DLL. Each version takes | 385 | neither of which is exported from the DLL. Each version takes |
386 | a CFile or FILE* as a parameter, neither of which can be | 386 | a CFile or FILE* as a parameter, neither of which can be |
387 | passed across a DLL interface (at least that is my experience). | 387 | passed across a DLL interface (at least that is my experience). |
388 | If you are linking this code into your build directly then | 388 | If you are linking this code into your build directly then |
389 | you may find them a more convenient API that the other flavors | 389 | you may find them a more convenient API that the other flavors |
390 | that take a file name. If you use them with the DLL LIB you | 390 | that take a file name. If you use them with the DLL LIB you |
391 | will get a link error. | 391 | will get a link error. |
392 | */ | 392 | */ |
393 | 393 | ||
394 | 394 | ||
395 | #if INCLUDEMFC | 395 | #if INCLUDEMFC |
396 | extern VObject* Parse_MIME_FromFile(CFile *file); | 396 | extern VObject* Parse_MIME_FromFile(CFile *file); |
397 | #else | 397 | #else |
398 | extern VObject* Parse_MIME_FromFile(FILE *file); | 398 | extern VObject* Parse_MIME_FromFile(FILE *file); |
399 | #endif | 399 | #endif |
400 | 400 | ||
401 | #define __SHARP_COMP_ | ||
402 | |||
403 | #ifndef __SHARP_COMP_ | ||
401 | extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o); | 404 | extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o); |
402 | 405 | ||
406 | #else | ||
407 | // This function is not available in the Sharp ROM for SL 5500 ! | ||
408 | // Therefore I have to move it into the header file.. (se) | ||
409 | |||
410 | inline const char* vObjectTypeInfo(VObject *o) | ||
411 | { | ||
412 | const char *type = vObjectName( o ); | ||
413 | if ( strcmp( type, "TYPE" ) == 0 ) | ||
414 | type = vObjectStringZValue( o ); | ||
415 | return type; | ||
416 | } | ||
417 | #endif | ||
403 | 418 | ||
404 | #endif /* __VOBJECT_H__ */ | 419 | #endif /* __VOBJECT_H__ */ |
405 | 420 | ||
406 | 421 | ||