/* * vcard-parser.h * * Copyright 2019 Michael Rasmussen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ #ifndef __VCARD_PARSER_H__ #define __VCARD_PARSER_H__ #include G_BEGIN_DECLS #include typedef enum { // vCard 2.1 properties and up // https://github.com/emacsmirror/addressbook/blob/master/vcard-21.txt N = 0, FN, PHOTO, BDAY, ADR, LABEL, // Removed in vCard 4.0 TEL, EMAIL, MAILER, // Removed in vCard 4.0 GEO, TITLE, ROLE, LOGO, ORG, NOTE, REV, SOUND, URL, UID, VERSION, KEY, TZ, SOURCE, AGENT, // Removed in vCard 4.0 PROFILE, // Removed in vCard 4.0 // vCard 3.0 properties // https://tools.ietf.org/html/rfc2426 CATEGORIES, SORT_STRING, PRODID, NICKNAME, NAME, // Removed in vCard 4.0 CLASS, // Removed in vCard 4.0 // rfc2739 properties FBURL, CAPURI, CALURI, CALADRURI, // rfc4770 properties IMPP, // vCard 4.0 properties // https://tools.ietf.org/html/rfc6350 XML, ANNIVERSARY, CLIENTPIDMAP, LANG, GENDER, KIND, MEMBER, RELATED, // rfc6474 properties BIRTHPLACE, DEATHPLACE, DEATHDATE, // rfc6715 properties EXPERTISE, HOBBY, INTEREST, ORG_DIRECTORY, VCARD_PROPERTIES, } Property; typedef enum { VCARD_PARSER_OK, VCARD_PARSER_VERSION_MISSING, VCARD_PARSER_VERSION_MISMATCH, VCARD_PARSER_ATTRIBUTE_VERSION_MISMATCH, VCARD_PARSER_BAD_FORMAT, VCARD_PARSER_ERROR, } VCardParserResponse; typedef struct { gchar* name; gchar* value; } VCardProperty; VCardVersion str_2_vcard_version(const gchar* version); gchar* vcard_version_2_str(VCardVersion version); Property vcard_max_property(VCardVersion version); VCardParserResponse vcard_parse_text(const gchar* text, VCardVersion* version, GHashTable** vcard); void init_g_hash_table(GHashTable** ht, VCardVersion version); void destroy_hash_table(GHashTable* ht); G_END_DECLS #endif