author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /libkcal/versit/vobject.h | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | libkcal/versit/vobject.h | 384 |
1 files changed, 384 insertions, 0 deletions
diff --git a/libkcal/versit/vobject.h b/libkcal/versit/vobject.h new file mode 100644 index 0000000..0ec8b31 --- a/dev/null +++ b/libkcal/versit/vobject.h | |||
@@ -0,0 +1,384 @@ | |||
1 | /*************************************************************************** | ||
2 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International | ||
3 | Business Machines Corporation and Siemens Rolm Communications Inc. | ||
4 | |||
5 | For purposes of this license notice, the term Licensors shall mean, | ||
6 | collectively, Apple Computer, Inc., AT&T Corp., International | ||
7 | Business Machines Corporation and Siemens Rolm Communications Inc. | ||
8 | The term Licensor shall mean any of the Licensors. | ||
9 | |||
10 | Subject to acceptance of the following conditions, permission is hereby | ||
11 | granted by Licensors without the need for written agreement and without | ||
12 | license or royalty fees, to use, copy, modify and distribute this | ||
13 | software for any purpose. | ||
14 | |||
15 | The above copyright notice and the following four paragraphs must be | ||
16 | reproduced in all copies of this software and any software including | ||
17 | this software. | ||
18 | |||
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 | ||
21 | MODIFICATIONS. | ||
22 | |||
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 | ||
25 | OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
26 | DAMAGE. | ||
27 | |||
28 | EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, | ||
29 | INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE | ||
30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
31 | PURPOSE. | ||
32 | |||
33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or | ||
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. | ||
36 | |||
37 | ***************************************************************************/ | ||
38 | |||
39 | /* | ||
40 | |||
41 | The vCard/vCalendar C interface is implemented in the set | ||
42 | of files as follows: | ||
43 | |||
44 | vcc.y, yacc source, and vcc.c, the yacc output you will use | ||
45 | implements the core parser | ||
46 | |||
47 | vobject.c implements an API that insulates the caller from | ||
48 | the parser and changes in the vCard/vCalendar BNF | ||
49 | |||
50 | port.h defines compilation environment dependent stuff | ||
51 | |||
52 | vcc.h and vobject.h are header files for their .c counterparts | ||
53 | |||
54 | vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions | ||
55 | which you may find useful. | ||
56 | |||
57 | test.c is a standalone test driver that exercises some of | ||
58 | the features of the APIs provided. Invoke test.exe on a | ||
59 | VCARD/VCALENDAR input text file and you will see the pretty | ||
60 | print output of the internal representation (this pretty print | ||
61 | output should give you a good idea of how the internal | ||
62 | representation looks like -- there is one such output in the | ||
63 | following too). Also, a file with the .out suffix is generated | ||
64 | to show that the internal representation can be written back | ||
65 | in the original text format. | ||
66 | |||
67 | For more information on this API see the readme.txt file | ||
68 | which accompanied this distribution. | ||
69 | |||
70 | Also visit: | ||
71 | |||
72 | http://www.versit.com | ||
73 | http://www.ralden.com | ||
74 | |||
75 | */ | ||
76 | |||
77 | |||
78 | #ifndef __VOBJECT_H__ | ||
79 | #define __VOBJECT_H__ 1 | ||
80 | |||
81 | |||
82 | #include "port.h" | ||
83 | #include <stdlib.h> | ||
84 | #include <stdio.h> | ||
85 | |||
86 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) | ||
87 | extern "C" { | ||
88 | #endif | ||
89 | |||
90 | |||
91 | #define VC7bitProp "7BIT" | ||
92 | #define VC8bitProp "8BIT" | ||
93 | #define VCAAlarmProp "AALARM" | ||
94 | #define VCAdditionalNamesProp"ADDN" | ||
95 | #define VCAdrProp "ADR" | ||
96 | #define VCAgentProp "AGENT" | ||
97 | #define VCAIFFProp "AIFF" | ||
98 | #define VCAOLProp "AOL" | ||
99 | #define VCAppleLinkProp "APPLELINK" | ||
100 | #define VCAttachProp "ATTACH" | ||
101 | #define VCAttendeeProp "ATTENDEE" | ||
102 | #define VCATTMailProp "ATTMAIL" | ||
103 | #define VCAudioContentProp "AUDIOCONTENT" | ||
104 | #define VCAVIProp "AVI" | ||
105 | #define VCBase64Prop "BASE64" | ||
106 | #define VCBBSProp "BBS" | ||
107 | #define VCBirthDateProp "BDAY" | ||
108 | #define VCBMPProp "BMP" | ||
109 | #define VCBodyProp "BODY" | ||
110 | #define VCBusinessRoleProp "ROLE" | ||
111 | #define VCCalProp "VCALENDAR" | ||
112 | #define VCCaptionProp "CAP" | ||
113 | #define VCCardProp "VCARD" | ||
114 | #define VCCarProp "CAR" | ||
115 | #define VCCategoriesProp "CATEGORIES" | ||
116 | #define VCCellularProp "CELL" | ||
117 | #define VCCGMProp "CGM" | ||
118 | #define VCCharSetProp "CS" | ||
119 | #define VCCIDProp "CID" | ||
120 | #define VCCISProp "CIS" | ||
121 | #define VCCityProp "L" | ||
122 | #define VCClassProp "CLASS" | ||
123 | #define VCCommentProp "NOTE" | ||
124 | #define VCCompletedProp "COMPLETED" | ||
125 | #define VCContentIDProp "CONTENT-ID" | ||
126 | #define VCCountryNameProp "C" | ||
127 | #define VCDAlarmProp "DALARM" | ||
128 | #define VCDataSizeProp "DATASIZE" | ||
129 | #define VCDayLightProp "DAYLIGHT" | ||
130 | #define VCDCreatedProp "DCREATED" | ||
131 | #define VCDeliveryLabelProp "LABEL" | ||
132 | #define VCDescriptionProp "DESCRIPTION" | ||
133 | #define VCDIBProp "DIB" | ||
134 | #define VCDisplayStringProp "DISPLAYSTRING" | ||
135 | #define VCDomesticProp "DOM" | ||
136 | #define VCDTendProp "DTEND" | ||
137 | #define VCDTstartProp "DTSTART" | ||
138 | #define VCDueProp "DUE" | ||
139 | #define VCEmailAddressProp "EMAIL" | ||
140 | #define VCEncodingProp "ENCODING" | ||
141 | #define VCEndProp "END" | ||
142 | #define VCEventProp "VEVENT" | ||
143 | #define VCEWorldProp "EWORLD" | ||
144 | #define VCExNumProp "EXNUM" | ||
145 | #define VCExDateProp "EXDATE" | ||
146 | #define VCExpectProp "EXPECT" | ||
147 | #define VCExtAddressProp "EXT ADD" | ||
148 | #define VCFamilyNameProp "F" | ||
149 | #define VCFaxProp "FAX" | ||
150 | #define VCFullNameProp "FN" | ||
151 | #define VCGeoProp "GEO" | ||
152 | #define VCGeoLocationProp "GEO" | ||
153 | #define VCGIFProp "GIF" | ||
154 | #define VCGivenNameProp "G" | ||
155 | #define VCGroupingProp "Grouping" | ||
156 | #define VCHomeProp "HOME" | ||
157 | #define VCIBMMailProp "IBMMail" | ||
158 | #define VCInlineProp "INLINE" | ||
159 | #define VCInternationalProp "INTL" | ||
160 | #define VCInternetProp "INTERNET" | ||
161 | #define VCISDNProp "ISDN" | ||
162 | #define VCJPEGProp "JPEG" | ||
163 | #define VCLanguageProp "LANG" | ||
164 | #define VCLastModifiedProp "LAST-MODIFIED" | ||
165 | #define VCLastRevisedProp "REV" | ||
166 | #define VCLocationProp "LOCATION" | ||
167 | #define VCLogoProp "LOGO" | ||
168 | #define VCMailerProp "MAILER" | ||
169 | #define VCMAlarmProp "MALARM" | ||
170 | #define VCMCIMailProp "MCIMAIL" | ||
171 | #define VCMessageProp "MSG" | ||
172 | #define VCMETProp "MET" | ||
173 | #define VCModemProp "MODEM" | ||
174 | #define VCMPEG2Prop "MPEG2" | ||
175 | #define VCMPEGProp "MPEG" | ||
176 | #define VCMSNProp "MSN" | ||
177 | #define VCNamePrefixesProp "NPRE" | ||
178 | #define VCNameProp "N" | ||
179 | #define VCNameSuffixesProp "NSUF" | ||
180 | #define VCNoteProp "NOTE" | ||
181 | #define VCOrgNameProp "ORGNAME" | ||
182 | #define VCOrgProp "ORG" | ||
183 | #define VCOrgUnit2Prop "OUN2" | ||
184 | #define VCOrgUnit3Prop "OUN3" | ||
185 | #define VCOrgUnit4Prop "OUN4" | ||
186 | #define VCOrgUnitProp "OUN" | ||
187 | #define VCPagerProp "PAGER" | ||
188 | #define VCPAlarmProp "PALARM" | ||
189 | #define VCParcelProp "PARCEL" | ||
190 | #define VCPartProp "PART" | ||
191 | #define VCPCMProp "PCM" | ||
192 | #define VCPDFProp "PDF" | ||
193 | #define VCPGPProp "PGP" | ||
194 | #define VCPhotoProp "PHOTO" | ||
195 | #define VCPICTProp "PICT" | ||
196 | #define VCPMBProp "PMB" | ||
197 | #define VCPostalBoxProp "BOX" | ||
198 | #define VCPostalCodeProp "PC" | ||
199 | #define VCPostalProp "POSTAL" | ||
200 | #define VCPowerShareProp "POWERSHARE" | ||
201 | #define VCPreferredProp "PREF" | ||
202 | #define VCPriorityProp "PRIORITY" | ||
203 | #define VCProcedureNameProp "PROCEDURENAME" | ||
204 | #define VCProdIdProp "PRODID" | ||
205 | #define VCProdigyProp "PRODIGY" | ||
206 | #define VCPronunciationProp "SOUND" | ||
207 | #define VCPSProp "PS" | ||
208 | #define VCPublicKeyProp "KEY" | ||
209 | #define VCQPProp "QP" | ||
210 | #define VCQuickTimeProp "QTIME" | ||
211 | #define VCQuotedPrintableProp"QUOTED-PRINTABLE" | ||
212 | #define VCRDateProp "RDATE" | ||
213 | #define VCRegionProp "R" | ||
214 | #define VCRelatedToProp "RELATED-TO" | ||
215 | #define VCRepeatCountProp "REPEATCOUNT" | ||
216 | #define VCResourcesProp "RESOURCES" | ||
217 | #define VCRNumProp "RNUM" | ||
218 | #define VCRoleProp "ROLE" | ||
219 | #define VCRRuleProp "RRULE" | ||
220 | #define VCRSVPProp "RSVP" | ||
221 | #define VCRunTimeProp "RUNTIME" | ||
222 | #define VCSequenceProp "SEQUENCE" | ||
223 | #define VCSnoozeTimeProp "SNOOZETIME" | ||
224 | #define VCStartProp "START" | ||
225 | #define VCStatusProp "STATUS" | ||
226 | #define VCStreetAddressProp "STREET" | ||
227 | #define VCSubTypeProp "SUBTYPE" | ||
228 | #define VCSummaryProp "SUMMARY" | ||
229 | #define VCTelephoneProp "TEL" | ||
230 | #define VCTIFFProp "TIFF" | ||
231 | #define VCTimeZoneProp "TZ" | ||
232 | #define VCTitleProp "TITLE" | ||
233 | #define VCTLXProp "TLX" | ||
234 | #define VCTodoProp "VTODO" | ||
235 | #define VCTranspProp "TRANSP" | ||
236 | #define VCUniqueStringProp "UID" | ||
237 | #define VCURLProp "URL" | ||
238 | #define VCURLValueProp "URLVAL" | ||
239 | #define VCValueProp "VALUE" | ||
240 | #define VCVersionProp "VERSION" | ||
241 | #define VCVideoProp "VIDEO" | ||
242 | #define VCVoiceProp "VOICE" | ||
243 | #define VCWAVEProp "WAVE" | ||
244 | #define VCWMFProp "WMF" | ||
245 | #define VCWorkProp "WORK" | ||
246 | #define VCX400Prop "X400" | ||
247 | #define VCX509Prop "X509" | ||
248 | #define VCXRuleProp "XRULE" | ||
249 | |||
250 | /* extensions for KOrganizer / KPilot */ | ||
251 | #define KPilotIdProp "X-PILOTID" | ||
252 | #define KPilotStatusProp "X-PILOTSTAT" | ||
253 | |||
254 | /* extensions for iMIP / iTIP */ | ||
255 | #define ICOrganizerProp "X-ORGANIZER" | ||
256 | #define ICMethodProp "X-METHOD" | ||
257 | #define ICRequestStatusProp "X-REQUEST-STATUS" | ||
258 | |||
259 | typedef struct VObject VObject; | ||
260 | |||
261 | typedef union ValueItem { | ||
262 | const char *strs; | ||
263 | const wchar_t *ustrs; | ||
264 | unsigned int i; | ||
265 | unsigned long l; | ||
266 | void *any; | ||
267 | VObject *vobj; | ||
268 | } ValueItem; | ||
269 | |||
270 | struct VObject { | ||
271 | VObject *next; | ||
272 | const char *id; | ||
273 | VObject *prop; | ||
274 | unsigned short valType; | ||
275 | ValueItem val; | ||
276 | }; | ||
277 | |||
278 | typedef struct StrItem StrItem; | ||
279 | |||
280 | struct StrItem { | ||
281 | StrItem *next; | ||
282 | const char *s; | ||
283 | unsigned int refCnt; | ||
284 | }; | ||
285 | |||
286 | typedef struct VObjectIterator { | ||
287 | VObject* start; | ||
288 | VObject* next; | ||
289 | } VObjectIterator; | ||
290 | |||
291 | extern VObject* newVObject(const char *id); | ||
292 | extern void deleteVObject(VObject *p); | ||
293 | extern char* dupStr(const char *s, unsigned int size); | ||
294 | extern void deleteStr(const char *p); | ||
295 | extern void unUseStr(const char *s); | ||
296 | |||
297 | extern void setVObjectName(VObject *o, const char* id); | ||
298 | extern void setVObjectStringZValue(VObject *o, const char *s); | ||
299 | extern void setVObjectStringZValue_(VObject *o, const char *s); | ||
300 | extern void setVObjectUStringZValue(VObject *o, const wchar_t *s); | ||
301 | extern void setVObjectUStringZValue_(VObject *o, const wchar_t *s); | ||
302 | extern void setVObjectIntegerValue(VObject *o, unsigned int i); | ||
303 | extern void setVObjectLongValue(VObject *o, unsigned long l); | ||
304 | extern void setVObjectAnyValue(VObject *o, void *t); | ||
305 | extern VObject* setValueWithSize(VObject *prop, void *val, unsigned int size); | ||
306 | extern VObject* setValueWithSize_(VObject *prop, void *val, unsigned int size); | ||
307 | |||
308 | extern const char* vObjectName(VObject *o); | ||
309 | extern const char* vObjectStringZValue(VObject *o); | ||
310 | extern const wchar_t* vObjectUStringZValue(VObject *o); | ||
311 | extern unsigned int vObjectIntegerValue(VObject *o); | ||
312 | extern unsigned long vObjectLongValue(VObject *o); | ||
313 | extern void* vObjectAnyValue(VObject *o); | ||
314 | extern VObject* vObjectVObjectValue(VObject *o); | ||
315 | extern void setVObjectVObjectValue(VObject *o, VObject *p); | ||
316 | |||
317 | extern VObject* addVObjectProp(VObject *o, VObject *p); | ||
318 | extern VObject* addProp(VObject *o, const char *id); | ||
319 | extern VObject* addProp_(VObject *o, const char *id); | ||
320 | extern VObject* addPropValue(VObject *o, const char *p, const char *v); | ||
321 | extern VObject* addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size); | ||
322 | extern VObject* addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size); | ||
323 | extern VObject* addGroup(VObject *o, const char *g); | ||
324 | extern void addList(VObject **o, VObject *p); | ||
325 | |||
326 | extern VObject* isAPropertyOf(VObject *o, const char *id); | ||
327 | |||
328 | extern VObject* nextVObjectInList(VObject *o); | ||
329 | extern void initPropIterator(VObjectIterator *i, VObject *o); | ||
330 | extern int moreIteration(VObjectIterator *i); | ||
331 | extern VObject* nextVObject(VObjectIterator *i); | ||
332 | |||
333 | extern char* writeMemVObject(char *s, int *len, VObject *o); | ||
334 | extern char* writeMemVObjects(char *s, int *len, VObject *list); | ||
335 | |||
336 | extern const char* lookupStr(const char *s); | ||
337 | extern void cleanStrTbl(); | ||
338 | |||
339 | extern void cleanVObject(VObject *o); | ||
340 | extern void cleanVObjects(VObject *list); | ||
341 | |||
342 | extern const char* lookupProp(const char* str); | ||
343 | extern const char* lookupProp_(const char* str); | ||
344 | |||
345 | extern wchar_t* fakeUnicode(const char *ps, int *bytes); | ||
346 | extern int uStrLen(const wchar_t *u); | ||
347 | extern char* fakeCString(const wchar_t *u); | ||
348 | |||
349 | extern void printVObjectToFile(char *fname,VObject *o); | ||
350 | extern void printVObjectsToFile(char *fname,VObject *list); | ||
351 | extern void writeVObjectToFile(char *fname, VObject *o); | ||
352 | extern void writeVObjectsToFile(char *fname, VObject *list); | ||
353 | |||
354 | extern int vObjectValueType(VObject *o); | ||
355 | |||
356 | /* return type of vObjectValueType: */ | ||
357 | #define VCVT_NOVALUE0 | ||
358 | /* if the VObject has no value associated with it. */ | ||
359 | #define VCVT_STRINGZ1 | ||
360 | /* if the VObject has value set by setVObjectStringZValue. */ | ||
361 | #define VCVT_USTRINGZ2 | ||
362 | /* if the VObject has value set by setVObjectUStringZValue. */ | ||
363 | #define VCVT_UINT 3 | ||
364 | /* if the VObject has value set by setVObjectIntegerValue. */ | ||
365 | #define VCVT_ULONG 4 | ||
366 | /* if the VObject has value set by setVObjectLongValue. */ | ||
367 | #define VCVT_RAW 5 | ||
368 | /* if the VObject has value set by setVObjectAnyValue. */ | ||
369 | #define VCVT_VOBJECT6 | ||
370 | /* if the VObject has value set by setVObjectVObjectValue. */ | ||
371 | |||
372 | extern const char** fieldedProp; | ||
373 | |||
374 | extern void printVObject(FILE *fp,VObject *o); | ||
375 | extern void writeVObject(FILE *fp, VObject *o); | ||
376 | |||
377 | |||
378 | #if defined(__CPLUSPLUS__) || defined(__cplusplus) | ||
379 | } | ||
380 | #endif | ||
381 | |||
382 | #endif /* __VOBJECT_H__ */ | ||
383 | |||
384 | |||