5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2002 - 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 /****h* silcvcard/SILC VCard
24 * Implementation of the VCard 3.0 standard (RFC 2426) that can be used
25 * with Requested Attributes (in WHOIS command) to deliver personal
26 * information. All fields are not supported since some of the
27 * information are not needed in context of SILC. If such VCard is
28 * received this implementation ignores the unsupported fields.
35 /****s* silcvcard/SilcVCard/SilcVCard
39 * typedef struct { ... } SilcVCardStruct, *SilcVCard;
43 * This structure is the VCard. This holds the contents of the
44 * card. When a card is parsed it is parsed into this structure.
45 * When creating a new card application fills this structure and
46 * the library encodes the card from it. Free the allocated
47 * structure with silc_vcard_free function.
51 typedef struct SilcVCardObject {
52 char *full_name; /* full name, X.520 common name */
53 char *family_name; /* last name, string */
54 char *first_name; /* first name, string */
55 char *middle_names; /* other names, string (comma sep.) */
56 char *prefix; /* honorifix prefix (Mr., Mrs.), string */
57 char *suffix; /* honorifix suffix (MD), string (comma sep.) */
58 char *nickname; /* string (comma sep. if more than one) */
59 char *bday; /* birth day, UTC date string */
60 char *title; /* job title X.520, string */
61 char *role; /* job role X.520, string */
62 char *org_name; /* organization name, string */
63 char *org_unit; /* organization unit, string */
64 char *categories; /* application category, string */
65 char *catclass; /* class (public, private, confidental), string */
66 char *url; /* home page, URI string */
67 char *label; /* formatted address label, string (same
68 format as for 'addr' but comma sep.) */
71 char *type; /* address type, string
72 (intl, dom, home, work, pref, postal, parcel) */
73 char *pbox; /* post office box, string */
74 char *ext_addr; /* extended address, string */
75 char *street_addr; /* street address, string */
76 char *city; /* city, string */
77 char *state; /* state/province, string */
78 char *code; /* postal code, string */
79 char *country; /* country name, string */
81 SilcUInt8 num_addrs; /* number of addresses */
84 char *type; /* telephone number type, string
85 (msg, voice, home, work, pref, bbs, modem, car,
86 cell, video, pager, isdn, fax) */
87 char *telnum; /* single telephone number, string */
92 char *type; /* email type, string (internet, pref, x400) */
93 char *address; /* single email address, string */
97 char *note; /* a note, string */
98 char *rev; /* revision of card, UTC date string */
100 SilcBool dynamic; /* TRUE when dynamically allocated */
101 } SilcVCardStruct, *SilcVCard;
104 /****f* silcvcard/SilcVCard/silc_vcard_encode
108 * char *silc_vcard_encode(SilcVCard vcard, SilcUInt32 *vcard_len);
112 * Encodes VCard from the SilcVCard structure indicated by `vcard'
113 * which the caller must fill before calling this function. This
114 * function encodes the card and returns allocated buffer and
115 * its length into `vcard_len'. The caller must free the returned
116 * buffer. Returns NULL on error.
119 unsigned char *silc_vcard_encode(SilcVCard vcard, SilcUInt32 *vcard_len);
121 /****f* silcvcard/SilcVCard/silc_vcard_decode
125 * SilcBool silc_vcard_decode(const unsigned char *data,
126 * SilcUInt32 data_len, SilcVCard vcard);
130 * Decodes VCard from the buffer `vcard' of length of `vcard_len' bytes
131 * and returns the parsed card into `vcard' structure. The caller must
132 * pre-allocate the structure. Returns TRUE if the `vcard' is valid
133 * vcard and was successfully parsed or FALSE on error. The structure
134 * is freed with silc_vcard_free function when it is not needed anymore.
137 SilcBool silc_vcard_decode(const unsigned char *data, SilcUInt32 data_len,
140 /****f* silcvcard/SilcVCard/silc_vcard_alloc
144 * SilcVCard silc_vcard_alloc(void);
148 * Allocate a SilcVCard context which must be freed with the
149 * silc_vcard_free function.
152 SilcVCard silc_vcard_alloc(void);
154 /****f* silcvcard/SilcVCard/silc_vcard_free
158 * void silc_vcard_free(SilcVCard vcard);
162 * Free VCard structure and all data in it.
165 void silc_vcard_free(SilcVCard vcard);
167 /****f* silcvcard/SilcVCard/silc_vcard_fprintf
171 * void silc_vcard_fprintf(SilcVCard vcard, FILE *stream);
175 * Prints the contents of the `vcard' into file stream `stream' in
176 * the correct VCard format.
179 void silc_vcard_fprintf(SilcVCard vcard, FILE *stream);
181 #endif /* SILCVCARD_H */