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