-rw-r--r-- | library/backend/vobject.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index af112a7..9c2ba3b 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp | |||
@@ -1146,65 +1146,74 @@ static void writeProp(OFile *fp, VObject *o) | |||
1146 | writeValue(fp,o,size); | 1146 | writeValue(fp,o,size); |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | appendcOFile(fp,'\n'); | 1149 | appendcOFile(fp,'\n'); |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | static void writeVObject_(OFile *fp, VObject *o) | 1152 | static void writeVObject_(OFile *fp, VObject *o) |
1153 | { | 1153 | { |
1154 | if (NAME_OF(o)) { | 1154 | if (NAME_OF(o)) { |
1155 | struct PreDefProp *pi; | 1155 | struct PreDefProp *pi; |
1156 | pi = lookupPropInfo(NAME_OF(o)); | 1156 | pi = lookupPropInfo(NAME_OF(o)); |
1157 | 1157 | ||
1158 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { | 1158 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { |
1159 | VObjectIterator t; | 1159 | VObjectIterator t; |
1160 | const char *begin = NAME_OF(o); | 1160 | const char *begin = NAME_OF(o); |
1161 | appendsOFile(fp,"BEGIN:"); | 1161 | appendsOFile(fp,"BEGIN:"); |
1162 | appendsOFile(fp,begin); | 1162 | appendsOFile(fp,begin); |
1163 | appendcOFile(fp,'\n'); | 1163 | appendcOFile(fp,'\n'); |
1164 | initPropIterator(&t,o); | 1164 | initPropIterator(&t,o); |
1165 | while (moreIteration(&t)) { | 1165 | while (moreIteration(&t)) { |
1166 | VObject *eachProp = nextVObject(&t); | 1166 | VObject *eachProp = nextVObject(&t); |
1167 | writeProp(fp, eachProp); | 1167 | writeProp(fp, eachProp); |
1168 | } | 1168 | } |
1169 | appendsOFile(fp,"END:"); | 1169 | appendsOFile(fp,"END:"); |
1170 | appendsOFile(fp,begin); | 1170 | appendsOFile(fp,begin); |
1171 | appendsOFile(fp,"\n\n"); | 1171 | appendsOFile(fp,"\n\n"); |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | void writeVObject(FILE *fp, VObject *o) | 1176 | void writeVObject(FILE *fp, VObject *o) |
1177 | { | 1177 | { |
1178 | OFile ofp; | 1178 | OFile ofp; |
1179 | // ##### | 1179 | // ##### |
1180 | //_setmode(_fileno(fp), _O_BINARY); | 1180 | //_setmode(_fileno(fp), _O_BINARY); |
1181 | initOFile(&ofp,fp); | 1181 | initOFile(&ofp,fp); |
1182 | writeVObject_(&ofp,o); | 1182 | writeVObject_(&ofp,o); |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) | 1185 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) |
1186 | { | 1186 | { |
1187 | QFileDirect f( fname); | 1187 | QFileDirect f( fname); |
1188 | if ( !f.open( IO_WriteOnly ) ) { | 1188 | if ( !f.open( IO_WriteOnly ) ) { |
1189 | qWarning("Unable to open vobject write %s", fname); | 1189 | qWarning("Unable to open vobject write %s", fname); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | writeVObject( f.directHandle(),o ); | 1193 | writeVObject( f.directHandle(),o ); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) | 1196 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) |
1197 | { | 1197 | { |
1198 | QFileDirect f( fname); | 1198 | QFileDirect f( fname); |
1199 | if ( !f.open( IO_WriteOnly ) ) { | 1199 | if ( !f.open( IO_WriteOnly ) ) { |
1200 | qWarning("Unable to open vobject write %s", fname); | 1200 | qWarning("Unable to open vobject write %s", fname); |
1201 | return; | 1201 | return; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | while (list) { | 1204 | while (list) { |
1205 | writeVObject(f.directHandle(),list); | 1205 | writeVObject(f.directHandle(),list); |
1206 | list = nextVObjectInList(list); | 1206 | list = nextVObjectInList(list); |
1207 | } | 1207 | } |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) | ||
1211 | { | ||
1212 | const char *type = vObjectName( o ); | ||
1213 | if ( strcmp( type, "TYPE" ) == 0 ) | ||
1214 | type = vObjectStringZValue( o ); | ||
1215 | return type; | ||
1216 | } | ||
1217 | |||
1218 | |||
1210 | // end of source file vobject.c | 1219 | // end of source file vobject.c |