static void writeValue(OFile *fp, VObject *o, unsigned long size, bool nosemi) { if (o == 0) return; switch (VALUE_TYPE(o)) { case VCVT_STRINGZ: { writeEncString(fp, STRINGZ_VALUE_OF(o), nosemi); break; } case VCVT_UINT: { char buf[16]; sprintf(buf,"%u", INTEGER_VALUE_OF(o)); appendsOFile(fp,buf); break; } case VCVT_ULONG: { char buf[16]; sprintf(buf,"%lu", LONG_VALUE_OF(o)); appendsOFile(fp,buf); break; } case VCVT_RAW: { appendcOFile(fp,'\n'); writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); break; } case VCVT_VOBJECT: appendcOFile(fp,'\n'); writeVObject_(fp,VOBJECT_VALUE_OF(o)); break; } }
char* writeMemVObject(char *s, int *len, VObject *o) { OFile ofp; initMemOFile(&ofp,s,len?*len:0); writeVObject_(&ofp,o); if (len) *len = ofp.len; appendcOFile(&ofp,0); return ofp.s; }
static void writeProp(OFile *fp, VObject *o) { int isQuoted=0; if (NAME_OF(o)) { const struct PreDefProp *pi; VObjectIterator t; const char **fields_ = 0; pi = lookupPropInfo(NAME_OF(o)); if (pi && ((pi->flags & PD_BEGIN) != 0)) { writeVObject_(fp,o); return; } if (isAPropertyOf(o,VCGroupingProp)) writeGroup(fp,o); else appendsOFile(fp,NAME_OF(o)); if (pi) fields_ = pi->fields; initPropIterator(&t,o); while (moreIteration(&t)) { const char *s; VObject *eachProp = nextVObject(&t); s = NAME_OF(eachProp); if (strcasecmp(VCGroupingProp,s) && !inList(fields_,s)) writeAttrValue(fp,eachProp); if (strcasecmp(VCQPProp,s)==0 || strcasecmp(VCQuotedPrintableProp,s)==0) isQuoted=1; } if (fields_) { int i = 0, n = 0; const char** fields = fields_; /* output prop as fields */ appendcOFile(fp,':'); while (*fields) { VObject *tl = isAPropertyOf(o,*fields); i++; if (tl) n = i; fields++; } fields = fields_; for (i=0;i<n;i++) { writeValue(fp,isAPropertyOf(o,*fields),0,isQuoted); fields++; if (i<(n-1)) appendcOFile(fp,';'); } } } if (VALUE_TYPE(o)) { unsigned long size = 0; VObject *p = isAPropertyOf(o,VCDataSizeProp); if (p) size = LONG_VALUE_OF(p); appendcOFile(fp,':'); writeValue(fp,o,size,isQuoted); } appendcOFile(fp,'\n'); }
void writeVObject(FILE *fp, VObject *o) { initVObjectEncoding(); OFile ofp; // ##### //_setmode(_fileno(fp), _O_BINARY); initOFile(&ofp,fp); writeVObject_(&ofp,o); }
char* writeMemVObjects(char *s, int *len, VObject *list) { OFile ofp; initMemOFile(&ofp,s,len?*len:0); while (list) { writeVObject_(&ofp,list); list = nextVObjectInList(list); } if (len) *len = ofp.len; appendcOFile(&ofp,0); return ofp.s; }
static void writeValue(OFile *fp, VObject *o, unsigned long size) { if (o == 0) return; switch (VALUE_TYPE(o)) { case VCVT_USTRINGZ: { char *s = fakeCString(USTRINGZ_VALUE_OF(o)); if (isAPropertyOf(o, VCQuotedPrintableProp)) writeQPString(fp, s, 1); else writeQPString(fp, s, 0); deleteStr(s); break; } case VCVT_STRINGZ: { if (isAPropertyOf(o, VCQuotedPrintableProp)) writeQPString(fp, STRINGZ_VALUE_OF(o), 1); else writeQPString(fp, STRINGZ_VALUE_OF(o), 0); break; } case VCVT_UINT: { char buf[16]; snprintf(buf,sizeof(buf),"%u", INTEGER_VALUE_OF(o)); appendsOFile(fp,buf); break; } case VCVT_ULONG: { char buf[16]; snprintf(buf,sizeof(buf),"%lu", LONG_VALUE_OF(o)); appendsOFile(fp,buf); break; } case VCVT_RAW: { appendcOFile(fp,'\n'); writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size); break; } case VCVT_VOBJECT: appendcOFile(fp,'\n'); writeVObject_(fp,VOBJECT_VALUE_OF(o)); break; } }
static void writeProp(OFile *fp, VObject *o) { if (NAME_OF(o)) { struct PreDefProp *pi; VObjectIterator t; const char **fields_ = 0; pi = lookupPropInfo(NAME_OF(o)); if (pi && ((pi->flags & PD_BEGIN) != 0)) { writeVObject_(fp,o); return; } if (isAPropertyOf(o,VCGroupingProp)) writeGroup(fp,o); else appendsOFile(fp,NAME_OF(o)); if (pi) fields_ = pi->fields; initPropIterator(&t,o); while (moreIteration(&t)) { const char *s; VObject *eachProp = nextVObject(&t); s = NAME_OF(eachProp); if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) writeAttrValue(fp,eachProp); } if (fields_) { int i = 0, n = 0; const char** fields = fields_; /* output prop as fields */ bool printable = TRUE; while (*fields && printable) { VObject *t = isAPropertyOf(o,*fields); if (includesUnprintable(t,TRUE)) printable = FALSE; fields++; } fields = fields_; if (!printable) appendsOFileEncCs(fp); appendcOFile(fp,':'); while (*fields) { VObject *t = isAPropertyOf(o,*fields); i++; if (t) n = i; fields++; } fields = fields_; for (i=0;i<n;i++) { writeValue(fp,isAPropertyOf(o,*fields),0,TRUE); fields++; if (i<(n-1)) appendcOFile(fp,';'); } } } if (VALUE_TYPE(o)) { if ( includesUnprintable(o,FALSE) ) appendsOFileEncCs(fp); unsigned long size = 0; VObject *p = isAPropertyOf(o,VCDataSizeProp); if (p) size = LONG_VALUE_OF(p); appendcOFile(fp,':'); writeValue(fp,o,size,FALSE); } appendcOFile(fp,'\n'); }
void writeVObject(FILE *fp, VObject *o) { OFile ofp; initOFile(&ofp,fp); writeVObject_(&ofp,o); }