vobject.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. /***************************************************************************
  2. (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
  3. Business Machines Corporation and Siemens Rolm Communications Inc.
  4. For purposes of this license notice, the term Licensors shall mean,
  5. collectively, Apple Computer, Inc., AT&T Corp., International
  6. Business Machines Corporation and Siemens Rolm Communications Inc.
  7. The term Licensor shall mean any of the Licensors.
  8. Subject to acceptance of the following conditions, permission is hereby
  9. granted by Licensors without the need for written agreement and without
  10. license or royalty fees, to use, copy, modify and distribute this
  11. software for any purpose.
  12. The above copyright notice and the following four paragraphs must be
  13. reproduced in all copies of this software and any software including
  14. this software.
  15. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
  16. ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
  17. MODIFICATIONS.
  18. IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
  19. INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
  20. OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  21. DAMAGE.
  22. EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
  23. INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
  24. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  25. PURPOSE.
  26. The software is provided with RESTRICTED RIGHTS. Use, duplication, or
  27. disclosure by the government are subject to restrictions set forth in
  28. DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
  29. ***************************************************************************/
  30. /*
  31. The vCard/vCalendar C interface is implemented in the set
  32. of files as follows:
  33. vcc.y, yacc source, and vcc.c, the yacc output you will use
  34. implements the core parser
  35. vobject.c implements an API that insulates the caller from
  36. the parser and changes in the vCard/vCalendar BNF
  37. vcc.h and vobject.h are header files for their .c counterparts
  38. vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
  39. which you may find useful.
  40. test.c is a standalone test driver that exercises some of
  41. the features of the APIs provided. Invoke test.exe on a
  42. VCARD/VCALENDAR input text file and you will see the pretty
  43. print output of the internal representation (this pretty print
  44. output should give you a good idea of how the internal
  45. representation looks like -- there is one such output in the
  46. following too). Also, a file with the .out suffix is generated
  47. to show that the internal representation can be written back
  48. in the original text format.
  49. For more information on this API see the readme.txt file
  50. which accompanied this distribution.
  51. Also visit:
  52. http://www.versit.com
  53. http://www.ralden.com
  54. */
  55. #ifndef VOBJECT_H
  56. #define VOBJECT_H
  57. #include "libical_vcal_export.h"
  58. #include <stdlib.h>
  59. #include <stdio.h>
  60. #if defined(__CPLUSPLUS__) || defined(__cplusplus)
  61. extern "C"
  62. {
  63. #endif
  64. #define VC7bitProp "7BIT"
  65. #define VC8bitProp "8BIT"
  66. #define VCAAlarmProp "AALARM"
  67. #define VCAdditionalNamesProp "ADDN"
  68. #define VCAdrProp "ADR"
  69. #define VCAgentProp "AGENT"
  70. #define VCAIFFProp "AIFF"
  71. #define VCAOLProp "AOL"
  72. #define VCAppleLinkProp "APPLELINK"
  73. #define VCAttachProp "ATTACH"
  74. #define VCAttendeeProp "ATTENDEE"
  75. #define VCATTMailProp "ATTMAIL"
  76. #define VCAudioContentProp "AUDIOCONTENT"
  77. #define VCAVIProp "AVI"
  78. #define VCBase64Prop "BASE64"
  79. #define VCBBSProp "BBS"
  80. #define VCBirthDateProp "BDAY"
  81. #define VCBMPProp "BMP"
  82. #define VCBodyProp "BODY"
  83. #define VCBusinessRoleProp "ROLE"
  84. #define VCCalProp "VCALENDAR"
  85. #define VCCaptionProp "CAP"
  86. #define VCCardProp "VCARD"
  87. #define VCCarProp "CAR"
  88. #define VCCategoriesProp "CATEGORIES"
  89. #define VCCellularProp "CELL"
  90. #define VCCGMProp "CGM"
  91. #define VCCharSetProp "CS"
  92. #define VCCIDProp "CID"
  93. #define VCCISProp "CIS"
  94. #define VCCityProp "L"
  95. #define VCClassProp "CLASS"
  96. #define VCCommentProp "NOTE"
  97. #define VCCompletedProp "COMPLETED"
  98. #define VCContentIDProp "CONTENT-ID"
  99. #define VCCountryNameProp "C"
  100. #define VCDAlarmProp "DALARM"
  101. #define VCDataSizeProp "DATASIZE"
  102. #define VCDayLightProp "DAYLIGHT"
  103. #define VCDCreatedProp "DCREATED"
  104. #define VCDeliveryLabelProp "LABEL"
  105. #define VCDescriptionProp "DESCRIPTION"
  106. #define VCDIBProp "DIB"
  107. #define VCDisplayStringProp "DISPLAYSTRING"
  108. #define VCDomesticProp "DOM"
  109. #define VCDTendProp "DTEND"
  110. #define VCDTstartProp "DTSTART"
  111. #define VCDueProp "DUE"
  112. #define VCEmailAddressProp "EMAIL"
  113. #define VCEncodingProp "ENCODING"
  114. #define VCEndProp "END"
  115. #define VCEventProp "VEVENT"
  116. #define VCEWorldProp "EWORLD"
  117. #define VCExNumProp "EXNUM"
  118. #define VCExpDateProp "EXDATE"
  119. #define VCExpectProp "EXPECT"
  120. #define VCExtAddressProp "EXT ADD"
  121. #define VCFamilyNameProp "F"
  122. #define VCFaxProp "FAX"
  123. #define VCFullNameProp "FN"
  124. #define VCGeoProp "GEO"
  125. #define VCGeoLocationProp "GEO"
  126. #define VCGIFProp "GIF"
  127. #define VCGivenNameProp "G"
  128. #define VCGroupingProp "Grouping"
  129. #define VCHomeProp "HOME"
  130. #define VCIBMMailProp "IBMMail"
  131. #define VCInlineProp "INLINE"
  132. #define VCInternationalProp "INTL"
  133. #define VCInternetProp "INTERNET"
  134. #define VCISDNProp "ISDN"
  135. #define VCJPEGProp "JPEG"
  136. #define VCLanguageProp "LANG"
  137. #define VCLastModifiedProp "LAST-MODIFIED"
  138. #define VCLastRevisedProp "REV"
  139. #define VCLocationProp "LOCATION"
  140. #define VCLogoProp "LOGO"
  141. #define VCMailerProp "MAILER"
  142. #define VCMAlarmProp "MALARM"
  143. #define VCMCIMailProp "MCIMAIL"
  144. #define VCMessageProp "MSG"
  145. #define VCMETProp "MET"
  146. #define VCModemProp "MODEM"
  147. #define VCMPEG2Prop "MPEG2"
  148. #define VCMPEGProp "MPEG"
  149. #define VCMSNProp "MSN"
  150. #define VCNamePrefixesProp "NPRE"
  151. #define VCNameProp "N"
  152. #define VCNameSuffixesProp "NSUF"
  153. #define VCNoteProp "NOTE"
  154. #define VCOrgNameProp "ORGNAME"
  155. #define VCOrgProp "ORG"
  156. #define VCOrgUnit2Prop "OUN2"
  157. #define VCOrgUnit3Prop "OUN3"
  158. #define VCOrgUnit4Prop "OUN4"
  159. #define VCOrgUnitProp "OUN"
  160. #define VCPagerProp "PAGER"
  161. #define VCPAlarmProp "PALARM"
  162. #define VCParcelProp "PARCEL"
  163. #define VCPartProp "PART"
  164. #define VCPCMProp "PCM"
  165. #define VCPDFProp "PDF"
  166. #define VCPGPProp "PGP"
  167. #define VCPhotoProp "PHOTO"
  168. #define VCPICTProp "PICT"
  169. #define VCPMBProp "PMB"
  170. #define VCPostalBoxProp "BOX"
  171. #define VCPostalCodeProp "PC"
  172. #define VCPostalProp "POSTAL"
  173. #define VCPowerShareProp "POWERSHARE"
  174. #define VCPreferredProp "PREF"
  175. #define VCPriorityProp "PRIORITY"
  176. #define VCProcedureNameProp "PROCEDURENAME"
  177. #define VCProdIdProp "PRODID"
  178. #define VCProdigyProp "PRODIGY"
  179. #define VCPronunciationProp "SOUND"
  180. #define VCPSProp "PS"
  181. #define VCPublicKeyProp "KEY"
  182. #define VCQPProp "QP"
  183. #define VCQuickTimeProp "QTIME"
  184. #define VCQuotedPrintableProp "QUOTED-PRINTABLE"
  185. #define VCRDateProp "RDATE"
  186. #define VCRegionProp "R"
  187. #define VCRelatedToProp "RELATED-TO"
  188. #define VCRepeatCountProp "REPEATCOUNT"
  189. #define VCResourcesProp "RESOURCES"
  190. #define VCRNumProp "RNUM"
  191. #define VCRoleProp "ROLE"
  192. #define VCRRuleProp "RRULE"
  193. #define VCRSVPProp "RSVP"
  194. #define VCRunTimeProp "RUNTIME"
  195. #define VCSequenceProp "SEQUENCE"
  196. #define VCSnoozeTimeProp "SNOOZETIME"
  197. #define VCStartProp "START"
  198. #define VCStatusProp "STATUS"
  199. #define VCStreetAddressProp "STREET"
  200. #define VCSubTypeProp "SUBTYPE"
  201. #define VCSummaryProp "SUMMARY"
  202. #define VCTelephoneProp "TEL"
  203. #define VCTIFFProp "TIFF"
  204. #define VCTimeZoneProp "TZ"
  205. #define VCTitleProp "TITLE"
  206. #define VCTLXProp "TLX"
  207. #define VCTodoProp "VTODO"
  208. #define VCTranspProp "TRANSP"
  209. #define VCUniqueStringProp "UID"
  210. #define VCURLProp "URL"
  211. #define VCURLValueProp "URLVAL"
  212. #define VCValueProp "VALUE"
  213. #define VCVersionProp "VERSION"
  214. #define VCVideoProp "VIDEO"
  215. #define VCVoiceProp "VOICE"
  216. #define VCWAVEProp "WAVE"
  217. #define VCWMFProp "WMF"
  218. #define VCWorkProp "WORK"
  219. #define VCX400Prop "X400"
  220. #define VCX509Prop "X509"
  221. #define VCXRuleProp "XRULE"
  222. /* Extensions */
  223. #define XPilotIdProp "X-PILOTID"
  224. #define XPilotStatusProp "X-PILOTSTAT"
  225. typedef struct VObject VObject;
  226. typedef struct VObjectIterator
  227. {
  228. VObject *start;
  229. VObject *next;
  230. } VObjectIterator;
  231. LIBICAL_VCAL_EXPORT VObject *newVObject(const char *id);
  232. LIBICAL_VCAL_EXPORT void deleteVObject(VObject *p);
  233. LIBICAL_VCAL_EXPORT char *dupStr(const char *s, size_t size);
  234. LIBICAL_VCAL_EXPORT void deleteStr(const char *p);
  235. LIBICAL_VCAL_EXPORT void unUseStr(const char *s);
  236. LIBICAL_VCAL_EXPORT void setVObjectName(VObject *o, const char *id);
  237. LIBICAL_VCAL_EXPORT void setVObjectStringZValue(VObject *o, const char *s);
  238. LIBICAL_VCAL_EXPORT void setVObjectStringZValue_(VObject *o, const char *s);
  239. LIBICAL_VCAL_EXPORT void setVObjectUStringZValue(VObject *o, const wchar_t *s);
  240. LIBICAL_VCAL_EXPORT void setVObjectUStringZValue_(VObject *o, const wchar_t *s);
  241. LIBICAL_VCAL_EXPORT void setVObjectIntegerValue(VObject *o, unsigned int i);
  242. LIBICAL_VCAL_EXPORT void setVObjectLongValue(VObject *o, unsigned long l);
  243. LIBICAL_VCAL_EXPORT void setVObjectAnyValue(VObject *o, void *t);
  244. LIBICAL_VCAL_EXPORT VObject *setValueWithSize(VObject *prop, void *val, unsigned int size);
  245. LIBICAL_VCAL_EXPORT VObject *setValueWithSize_(VObject *prop, void *val, unsigned int size);
  246. LIBICAL_VCAL_EXPORT const char *vObjectName(VObject *o);
  247. LIBICAL_VCAL_EXPORT const char *vObjectStringZValue(VObject *o);
  248. LIBICAL_VCAL_EXPORT const wchar_t *vObjectUStringZValue(VObject *o);
  249. LIBICAL_VCAL_EXPORT unsigned int vObjectIntegerValue(VObject *o);
  250. LIBICAL_VCAL_EXPORT unsigned long vObjectLongValue(VObject *o);
  251. LIBICAL_VCAL_EXPORT void *vObjectAnyValue(VObject *o);
  252. LIBICAL_VCAL_EXPORT VObject *vObjectVObjectValue(VObject *o);
  253. LIBICAL_VCAL_EXPORT void setVObjectVObjectValue(VObject *o, VObject *p);
  254. LIBICAL_VCAL_EXPORT VObject *addVObjectProp(VObject *o, VObject *p);
  255. LIBICAL_VCAL_EXPORT VObject *addProp(VObject *o, const char *id);
  256. LIBICAL_VCAL_EXPORT VObject *addPropValue(VObject *o, const char *p, const char *v);
  257. LIBICAL_VCAL_EXPORT VObject *addPropSizedValue_(VObject *o, const char *p, const char *v,
  258. unsigned int size);
  259. LIBICAL_VCAL_EXPORT VObject *addPropSizedValue(VObject *o, const char *p, const char *v,
  260. unsigned int size);
  261. LIBICAL_VCAL_EXPORT VObject *addGroup(VObject *o, const char *g);
  262. LIBICAL_VCAL_EXPORT void addList(VObject ** o, VObject *p);
  263. LIBICAL_VCAL_EXPORT VObject *isAPropertyOf(VObject *o, const char *id);
  264. LIBICAL_VCAL_EXPORT VObject *nextVObjectInList(VObject *o);
  265. LIBICAL_VCAL_EXPORT void initPropIterator(VObjectIterator * i, VObject *o);
  266. LIBICAL_VCAL_EXPORT int moreIteration(VObjectIterator * i);
  267. LIBICAL_VCAL_EXPORT VObject *nextVObject(VObjectIterator * i);
  268. LIBICAL_VCAL_EXPORT char *writeMemVObject(char *s, int *len, VObject *o);
  269. LIBICAL_VCAL_EXPORT char *writeMemVObjects(char *s, int *len, VObject *list);
  270. LIBICAL_VCAL_EXPORT const char *lookupStr(const char *s);
  271. LIBICAL_VCAL_EXPORT void cleanStrTbl();
  272. LIBICAL_VCAL_EXPORT void cleanVObject(VObject *o);
  273. LIBICAL_VCAL_EXPORT void cleanVObjects(VObject *list);
  274. LIBICAL_VCAL_EXPORT const char *lookupProp(const char *str);
  275. LIBICAL_VCAL_EXPORT const char *lookupProp_(const char *str);
  276. LIBICAL_VCAL_EXPORT wchar_t *fakeUnicode(const char *ps, size_t *bytes);
  277. LIBICAL_VCAL_EXPORT int uStrLen(const wchar_t *u);
  278. LIBICAL_VCAL_EXPORT char *fakeCString(const wchar_t *u);
  279. LIBICAL_VCAL_EXPORT void printVObjectToFile(char *fname, VObject *o);
  280. LIBICAL_VCAL_EXPORT void printVObjectsToFile(char *fname, VObject *list);
  281. LIBICAL_VCAL_EXPORT void writeVObjectToFile(char *fname, VObject *o);
  282. LIBICAL_VCAL_EXPORT void writeVObjectsToFile(char *fname, VObject *list);
  283. LIBICAL_VCAL_EXPORT int vObjectValueType(VObject *o);
  284. /* return type of vObjectValueType: */
  285. #define VCVT_NOVALUE 0
  286. /* if the VObject has no value associated with it. */
  287. #define VCVT_STRINGZ 1
  288. /* if the VObject has value set by setVObjectStringZValue. */
  289. #define VCVT_USTRINGZ 2
  290. /* if the VObject has value set by setVObjectUStringZValue. */
  291. #define VCVT_UINT 3
  292. /* if the VObject has value set by setVObjectIntegerValue. */
  293. #define VCVT_ULONG 4
  294. /* if the VObject has value set by setVObjectLongValue. */
  295. #define VCVT_RAW 5
  296. /* if the VObject has value set by setVObjectAnyValue. */
  297. #define VCVT_VOBJECT 6
  298. /* if the VObject has value set by setVObjectVObjectValue. */
  299. extern const char **fieldedProp;
  300. /* NOTE regarding printVObject and writeVObject
  301. The functions below are not exported from the DLL because they
  302. take a FILE* as a parameter, which cannot be passed across a DLL
  303. interface (at least that is my experience). Instead you can use
  304. their companion functions which take file names or pointers
  305. to memory. However, if you are linking this code into
  306. your build directly then you may find them a more convenient API
  307. and you can go ahead and use them. If you try to use them with
  308. the DLL LIB you will get a link error.
  309. */
  310. extern void printVObject(FILE *fp, VObject *o);
  311. extern void writeVObject(FILE *fp, VObject *o);
  312. #if defined(__CPLUSPLUS__) || defined(__cplusplus)
  313. }
  314. #endif
  315. #endif /* VOBJECT_H */