Libical API Documentation  3.0
vobject.h
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 vcc.h and vobject.h are header files for their .c counterparts
51 
52 vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
53 which you may find useful.
54 
55 test.c is a standalone test driver that exercises some of
56 the features of the APIs provided. Invoke test.exe on a
57 VCARD/VCALENDAR input text file and you will see the pretty
58 print output of the internal representation (this pretty print
59 output should give you a good idea of how the internal
60 representation looks like -- there is one such output in the
61 following too). Also, a file with the .out suffix is generated
62 to show that the internal representation can be written back
63 in the original text format.
64 
65 For more information on this API see the readme.txt file
66 which accompanied this distribution.
67 
68  Also visit:
69 
70  http://www.versit.com
71  http://www.ralden.com
72 
73 */
74 
75 #ifndef VOBJECT_H
76 #define VOBJECT_H
77 
78 #include "libical_vcal_export.h"
79 #include <stdlib.h>
80 #include <stdio.h>
81 
82 #if defined(__CPLUSPLUS__) || defined(__cplusplus)
83 extern "C"
84 {
85 #endif
86 
87 #define VC7bitProp "7BIT"
88 #define VC8bitProp "8BIT"
89 #define VCAAlarmProp "AALARM"
90 #define VCAdditionalNamesProp "ADDN"
91 #define VCAdrProp "ADR"
92 #define VCAgentProp "AGENT"
93 #define VCAIFFProp "AIFF"
94 #define VCAOLProp "AOL"
95 #define VCAppleLinkProp "APPLELINK"
96 #define VCAttachProp "ATTACH"
97 #define VCAttendeeProp "ATTENDEE"
98 #define VCATTMailProp "ATTMAIL"
99 #define VCAudioContentProp "AUDIOCONTENT"
100 #define VCAVIProp "AVI"
101 #define VCBase64Prop "BASE64"
102 #define VCBBSProp "BBS"
103 #define VCBirthDateProp "BDAY"
104 #define VCBMPProp "BMP"
105 #define VCBodyProp "BODY"
106 #define VCBusinessRoleProp "ROLE"
107 #define VCCalProp "VCALENDAR"
108 #define VCCaptionProp "CAP"
109 #define VCCardProp "VCARD"
110 #define VCCarProp "CAR"
111 #define VCCategoriesProp "CATEGORIES"
112 #define VCCellularProp "CELL"
113 #define VCCGMProp "CGM"
114 #define VCCharSetProp "CS"
115 #define VCCIDProp "CID"
116 #define VCCISProp "CIS"
117 #define VCCityProp "L"
118 #define VCClassProp "CLASS"
119 #define VCCommentProp "NOTE"
120 #define VCCompletedProp "COMPLETED"
121 #define VCContentIDProp "CONTENT-ID"
122 #define VCCountryNameProp "C"
123 #define VCDAlarmProp "DALARM"
124 #define VCDataSizeProp "DATASIZE"
125 #define VCDayLightProp "DAYLIGHT"
126 #define VCDCreatedProp "DCREATED"
127 #define VCDeliveryLabelProp "LABEL"
128 #define VCDescriptionProp "DESCRIPTION"
129 #define VCDIBProp "DIB"
130 #define VCDisplayStringProp "DISPLAYSTRING"
131 #define VCDomesticProp "DOM"
132 #define VCDTendProp "DTEND"
133 #define VCDTstartProp "DTSTART"
134 #define VCDueProp "DUE"
135 #define VCEmailAddressProp "EMAIL"
136 #define VCEncodingProp "ENCODING"
137 #define VCEndProp "END"
138 #define VCEventProp "VEVENT"
139 #define VCEWorldProp "EWORLD"
140 #define VCExNumProp "EXNUM"
141 #define VCExpDateProp "EXDATE"
142 #define VCExpectProp "EXPECT"
143 #define VCExtAddressProp "EXT ADD"
144 #define VCFamilyNameProp "F"
145 #define VCFaxProp "FAX"
146 #define VCFullNameProp "FN"
147 #define VCGeoProp "GEO"
148 #define VCGeoLocationProp "GEO"
149 #define VCGIFProp "GIF"
150 #define VCGivenNameProp "G"
151 #define VCGroupingProp "Grouping"
152 #define VCHomeProp "HOME"
153 #define VCIBMMailProp "IBMMail"
154 #define VCInlineProp "INLINE"
155 #define VCInternationalProp "INTL"
156 #define VCInternetProp "INTERNET"
157 #define VCISDNProp "ISDN"
158 #define VCJPEGProp "JPEG"
159 #define VCLanguageProp "LANG"
160 #define VCLastModifiedProp "LAST-MODIFIED"
161 #define VCLastRevisedProp "REV"
162 #define VCLocationProp "LOCATION"
163 #define VCLogoProp "LOGO"
164 #define VCMailerProp "MAILER"
165 #define VCMAlarmProp "MALARM"
166 #define VCMCIMailProp "MCIMAIL"
167 #define VCMessageProp "MSG"
168 #define VCMETProp "MET"
169 #define VCModemProp "MODEM"
170 #define VCMPEG2Prop "MPEG2"
171 #define VCMPEGProp "MPEG"
172 #define VCMSNProp "MSN"
173 #define VCNamePrefixesProp "NPRE"
174 #define VCNameProp "N"
175 #define VCNameSuffixesProp "NSUF"
176 #define VCNoteProp "NOTE"
177 #define VCOrgNameProp "ORGNAME"
178 #define VCOrgProp "ORG"
179 #define VCOrgUnit2Prop "OUN2"
180 #define VCOrgUnit3Prop "OUN3"
181 #define VCOrgUnit4Prop "OUN4"
182 #define VCOrgUnitProp "OUN"
183 #define VCPagerProp "PAGER"
184 #define VCPAlarmProp "PALARM"
185 #define VCParcelProp "PARCEL"
186 #define VCPartProp "PART"
187 #define VCPCMProp "PCM"
188 #define VCPDFProp "PDF"
189 #define VCPGPProp "PGP"
190 #define VCPhotoProp "PHOTO"
191 #define VCPICTProp "PICT"
192 #define VCPMBProp "PMB"
193 #define VCPostalBoxProp "BOX"
194 #define VCPostalCodeProp "PC"
195 #define VCPostalProp "POSTAL"
196 #define VCPowerShareProp "POWERSHARE"
197 #define VCPreferredProp "PREF"
198 #define VCPriorityProp "PRIORITY"
199 #define VCProcedureNameProp "PROCEDURENAME"
200 #define VCProdIdProp "PRODID"
201 #define VCProdigyProp "PRODIGY"
202 #define VCPronunciationProp "SOUND"
203 #define VCPSProp "PS"
204 #define VCPublicKeyProp "KEY"
205 #define VCQPProp "QP"
206 #define VCQuickTimeProp "QTIME"
207 #define VCQuotedPrintableProp "QUOTED-PRINTABLE"
208 #define VCRDateProp "RDATE"
209 #define VCRegionProp "R"
210 #define VCRelatedToProp "RELATED-TO"
211 #define VCRepeatCountProp "REPEATCOUNT"
212 #define VCResourcesProp "RESOURCES"
213 #define VCRNumProp "RNUM"
214 #define VCRoleProp "ROLE"
215 #define VCRRuleProp "RRULE"
216 #define VCRSVPProp "RSVP"
217 #define VCRunTimeProp "RUNTIME"
218 #define VCSequenceProp "SEQUENCE"
219 #define VCSnoozeTimeProp "SNOOZETIME"
220 #define VCStartProp "START"
221 #define VCStatusProp "STATUS"
222 #define VCStreetAddressProp "STREET"
223 #define VCSubTypeProp "SUBTYPE"
224 #define VCSummaryProp "SUMMARY"
225 #define VCTelephoneProp "TEL"
226 #define VCTIFFProp "TIFF"
227 #define VCTimeZoneProp "TZ"
228 #define VCTitleProp "TITLE"
229 #define VCTLXProp "TLX"
230 #define VCTodoProp "VTODO"
231 #define VCTranspProp "TRANSP"
232 #define VCUniqueStringProp "UID"
233 #define VCURLProp "URL"
234 #define VCURLValueProp "URLVAL"
235 #define VCValueProp "VALUE"
236 #define VCVersionProp "VERSION"
237 #define VCVideoProp "VIDEO"
238 #define VCVoiceProp "VOICE"
239 #define VCWAVEProp "WAVE"
240 #define VCWMFProp "WMF"
241 #define VCWorkProp "WORK"
242 #define VCX400Prop "X400"
243 #define VCX509Prop "X509"
244 #define VCXRuleProp "XRULE"
245 
246 /* Extensions */
247 
248 #define XPilotIdProp "X-PILOTID"
249 #define XPilotStatusProp "X-PILOTSTAT"
250 
251  typedef struct VObject VObject;
252 
253  typedef struct VObjectIterator
254  {
255  VObject *start;
256  VObject *next;
257  } VObjectIterator;
258 
259  LIBICAL_VCAL_EXPORT VObject *newVObject(const char *id);
260  LIBICAL_VCAL_EXPORT void deleteVObject(VObject *p);
261  LIBICAL_VCAL_EXPORT char *dupStr(const char *s, size_t size);
262  LIBICAL_VCAL_EXPORT void deleteStr(const char *p);
263  LIBICAL_VCAL_EXPORT void unUseStr(const char *s);
264 
265  LIBICAL_VCAL_EXPORT void setVObjectName(VObject *o, const char *id);
266  LIBICAL_VCAL_EXPORT void setVObjectStringZValue(VObject *o, const char *s);
267  LIBICAL_VCAL_EXPORT void setVObjectStringZValue_(VObject *o, const char *s);
268  LIBICAL_VCAL_EXPORT void setVObjectUStringZValue(VObject *o, const wchar_t *s);
269  LIBICAL_VCAL_EXPORT void setVObjectUStringZValue_(VObject *o, const wchar_t *s);
270  LIBICAL_VCAL_EXPORT void setVObjectIntegerValue(VObject *o, unsigned int i);
271  LIBICAL_VCAL_EXPORT void setVObjectLongValue(VObject *o, unsigned long l);
272  LIBICAL_VCAL_EXPORT void setVObjectAnyValue(VObject *o, void *t);
273  LIBICAL_VCAL_EXPORT VObject *setValueWithSize(VObject *prop, void *val, unsigned int size);
274  LIBICAL_VCAL_EXPORT VObject *setValueWithSize_(VObject *prop, void *val, unsigned int size);
275 
276  LIBICAL_VCAL_EXPORT const char *vObjectName(VObject *o);
277  LIBICAL_VCAL_EXPORT const char *vObjectStringZValue(VObject *o);
278  LIBICAL_VCAL_EXPORT const wchar_t *vObjectUStringZValue(VObject *o);
279  LIBICAL_VCAL_EXPORT unsigned int vObjectIntegerValue(VObject *o);
280  LIBICAL_VCAL_EXPORT unsigned long vObjectLongValue(VObject *o);
281  LIBICAL_VCAL_EXPORT void *vObjectAnyValue(VObject *o);
282  LIBICAL_VCAL_EXPORT VObject *vObjectVObjectValue(VObject *o);
283  LIBICAL_VCAL_EXPORT void setVObjectVObjectValue(VObject *o, VObject *p);
284 
285  LIBICAL_VCAL_EXPORT VObject *addVObjectProp(VObject *o, VObject *p);
286  LIBICAL_VCAL_EXPORT VObject *addProp(VObject *o, const char *id);
287  LIBICAL_VCAL_EXPORT VObject *addPropValue(VObject *o, const char *p, const char *v);
288  LIBICAL_VCAL_EXPORT VObject *addPropSizedValue_(VObject *o, const char *p, const char *v,
289  unsigned int size);
290  LIBICAL_VCAL_EXPORT VObject *addPropSizedValue(VObject *o, const char *p, const char *v,
291  unsigned int size);
292  LIBICAL_VCAL_EXPORT VObject *addGroup(VObject *o, const char *g);
293  LIBICAL_VCAL_EXPORT void addList(VObject ** o, VObject *p);
294 
295  LIBICAL_VCAL_EXPORT VObject *isAPropertyOf(VObject *o, const char *id);
296 
297  LIBICAL_VCAL_EXPORT VObject *nextVObjectInList(VObject *o);
298  LIBICAL_VCAL_EXPORT void initPropIterator(VObjectIterator * i, VObject *o);
299  LIBICAL_VCAL_EXPORT int moreIteration(VObjectIterator * i);
300  LIBICAL_VCAL_EXPORT VObject *nextVObject(VObjectIterator * i);
301 
302  LIBICAL_VCAL_EXPORT char *writeMemVObject(char *s, int *len, VObject *o);
303  LIBICAL_VCAL_EXPORT char *writeMemVObjects(char *s, int *len, VObject *list);
304 
305  LIBICAL_VCAL_EXPORT const char *lookupStr(const char *s);
306  LIBICAL_VCAL_EXPORT void cleanStrTbl();
307 
308  LIBICAL_VCAL_EXPORT void cleanVObject(VObject *o);
309  LIBICAL_VCAL_EXPORT void cleanVObjects(VObject *list);
310 
311  LIBICAL_VCAL_EXPORT const char *lookupProp(const char *str);
312  LIBICAL_VCAL_EXPORT const char *lookupProp_(const char *str);
313 
314  LIBICAL_VCAL_EXPORT wchar_t *fakeUnicode(const char *ps, size_t *bytes);
315  LIBICAL_VCAL_EXPORT int uStrLen(const wchar_t *u);
316  LIBICAL_VCAL_EXPORT char *fakeCString(const wchar_t *u);
317 
318  LIBICAL_VCAL_EXPORT void printVObjectToFile(char *fname, VObject *o);
319  LIBICAL_VCAL_EXPORT void printVObjectsToFile(char *fname, VObject *list);
320  LIBICAL_VCAL_EXPORT void writeVObjectToFile(char *fname, VObject *o);
321  LIBICAL_VCAL_EXPORT void writeVObjectsToFile(char *fname, VObject *list);
322 
323  LIBICAL_VCAL_EXPORT int vObjectValueType(VObject *o);
324 
325 /* return type of vObjectValueType: */
326 #define VCVT_NOVALUE 0
327  /* if the VObject has no value associated with it. */
328 #define VCVT_STRINGZ 1
329  /* if the VObject has value set by setVObjectStringZValue. */
330 #define VCVT_USTRINGZ 2
331  /* if the VObject has value set by setVObjectUStringZValue. */
332 #define VCVT_UINT 3
333  /* if the VObject has value set by setVObjectIntegerValue. */
334 #define VCVT_ULONG 4
335  /* if the VObject has value set by setVObjectLongValue. */
336 #define VCVT_RAW 5
337  /* if the VObject has value set by setVObjectAnyValue. */
338 #define VCVT_VOBJECT 6
339  /* if the VObject has value set by setVObjectVObjectValue. */
340 
341  extern const char **fieldedProp;
342 
343 /* NOTE regarding printVObject and writeVObject
344 
345 The functions below are not exported from the DLL because they
346 take a FILE* as a parameter, which cannot be passed across a DLL
347 interface (at least that is my experience). Instead you can use
348 their companion functions which take file names or pointers
349 to memory. However, if you are linking this code into
350 your build directly then you may find them a more convenient API
351 and you can go ahead and use them. If you try to use them with
352 the DLL LIB you will get a link error.
353 */
354  extern void printVObject(FILE *fp, VObject *o);
355  extern void writeVObject(FILE *fp, VObject *o);
356 
357 #if defined(__CPLUSPLUS__) || defined(__cplusplus)
358 }
359 
360 #endif
361 
362 #endif /* VOBJECT_H */
Definition: vobject.c:69
Definition: vobject.h:253