summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/vobject.cpp7
-rw-r--r--library/backend/vobject_p.h15
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
@@ -1178,138 +1178,143 @@ static void writeProp(OFile *fp, VObject *o)
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
1248static void writeVObject_(OFile *fp, VObject *o) 1248static 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
1272void writeVObject(FILE *fp, VObject *o) 1272void 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
1281DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) 1281DLLEXPORT(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
1292DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) 1292DLLEXPORT(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
1306DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) 1311DLLEXPORT(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
@@ -273,134 +273,149 @@ For example:
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
280typedef struct VObject VObject; 280typedef struct VObject VObject;
281 281
282typedef struct VObjectIterator { 282typedef struct VObjectIterator {
283 VObject* start; 283 VObject* start;
284 VObject* next; 284 VObject* next;
285 } VObjectIterator; 285 } VObjectIterator;
286 286
287extern DLLEXPORT(VObject*) newVObject(const char *id); 287extern DLLEXPORT(VObject*) newVObject(const char *id);
288extern DLLEXPORT(void) deleteVObject(VObject *p); 288extern DLLEXPORT(void) deleteVObject(VObject *p);
289extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size); 289extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size);
290extern DLLEXPORT(void) deleteStr(const char *p); 290extern DLLEXPORT(void) deleteStr(const char *p);
291extern DLLEXPORT(void) unUseStr(const char *s); 291extern DLLEXPORT(void) unUseStr(const char *s);
292 292
293extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id); 293extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id);
294extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s); 294extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s);
295extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s); 295extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s);
296extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i); 296extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i);
297extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l); 297extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l);
298extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t); 298extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t);
299extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size); 299extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size);
300extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size); 300extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size);
301 301
302extern DLLEXPORT(const char*) vObjectName(VObject *o); 302extern DLLEXPORT(const char*) vObjectName(VObject *o);
303extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o); 303extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o);
304extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o); 304extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o);
305extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o); 305extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o);
306extern DLLEXPORT(void*) vObjectAnyValue(VObject *o); 306extern DLLEXPORT(void*) vObjectAnyValue(VObject *o);
307extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o); 307extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o);
308extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p); 308extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p);
309 309
310extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p); 310extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p);
311extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id); 311extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id);
312extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id); 312extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id);
313extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v); 313extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v);
314extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); 314extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size);
315extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); 315extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size);
316extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g); 316extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g);
317extern DLLEXPORT(void) addList(VObject **o, VObject *p); 317extern DLLEXPORT(void) addList(VObject **o, VObject *p);
318 318
319extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id); 319extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id);
320 320
321extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o); 321extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o);
322extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o); 322extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o);
323extern DLLEXPORT(int) moreIteration(VObjectIterator *i); 323extern DLLEXPORT(int) moreIteration(VObjectIterator *i);
324extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i); 324extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i);
325 325
326extern DLLEXPORT(const char*) lookupStr(const char *s); 326extern DLLEXPORT(const char*) lookupStr(const char *s);
327extern DLLEXPORT(void) cleanStrTbl(); 327extern DLLEXPORT(void) cleanStrTbl();
328 328
329extern DLLEXPORT(void) cleanVObject(VObject *o); 329extern DLLEXPORT(void) cleanVObject(VObject *o);
330extern DLLEXPORT(void) cleanVObjects(VObject *list); 330extern DLLEXPORT(void) cleanVObjects(VObject *list);
331 331
332extern DLLEXPORT(const char*) lookupProp(const char* str); 332extern DLLEXPORT(const char*) lookupProp(const char* str);
333extern DLLEXPORT(const char*) lookupProp_(const char* str); 333extern DLLEXPORT(const char*) lookupProp_(const char* str);
334 334
335extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o); 335extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o);
336extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); 336extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list);
337 337
338extern DLLEXPORT(int) vObjectValueType(VObject *o); 338extern 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
354extern const char** fieldedProp; 354extern 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
362The functions below are not exported from the DLL because they 362The functions below are not exported from the DLL because they
363take a FILE* as a parameter, which cannot be passed across a DLL 363take a FILE* as a parameter, which cannot be passed across a DLL
364interface (at least that is my experience). Instead you can use 364interface (at least that is my experience). Instead you can use
365their companion functions which take file names or pointers 365their companion functions which take file names or pointers
366to memory. However, if you are linking this code into 366to memory. However, if you are linking this code into
367your build directly then you may find them a more convenient API 367your build directly then you may find them a more convenient API
368and you can go ahead and use them. If you try to use them with 368and you can go ahead and use them. If you try to use them with
369the DLL LIB you will get a link error. 369the DLL LIB you will get a link error.
370*/ 370*/
371extern void writeVObject(FILE *fp, VObject *o); 371extern void writeVObject(FILE *fp, VObject *o);
372 372
373 373
374 374
375typedef void (*MimeErrorHandler)(char *); 375typedef void (*MimeErrorHandler)(char *);
376 376
377extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); 377extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
378 378
379extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); 379extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
380extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); 380extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
381 381
382 382
383/* NOTE regarding Parse_MIME_FromFile 383/* NOTE regarding Parse_MIME_FromFile
384The function above, Parse_MIME_FromFile, comes in two flavors, 384The function above, Parse_MIME_FromFile, comes in two flavors,
385neither of which is exported from the DLL. Each version takes 385neither of which is exported from the DLL. Each version takes
386a CFile or FILE* as a parameter, neither of which can be 386a CFile or FILE* as a parameter, neither of which can be
387passed across a DLL interface (at least that is my experience). 387passed across a DLL interface (at least that is my experience).
388If you are linking this code into your build directly then 388If you are linking this code into your build directly then
389you may find them a more convenient API that the other flavors 389you may find them a more convenient API that the other flavors
390that take a file name. If you use them with the DLL LIB you 390that take a file name. If you use them with the DLL LIB you
391will get a link error. 391will get a link error.
392*/ 392*/
393 393
394 394
395#if INCLUDEMFC 395#if INCLUDEMFC
396extern VObject* Parse_MIME_FromFile(CFile *file); 396extern VObject* Parse_MIME_FromFile(CFile *file);
397#else 397#else
398extern VObject* Parse_MIME_FromFile(FILE *file); 398extern VObject* Parse_MIME_FromFile(FILE *file);
399#endif 399#endif
400 400
401#define __SHARP_COMP_
402
403#ifndef __SHARP_COMP_
401extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o); 404extern 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
410inline 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