From aa039bee0fd8f3db86fb10482345f940ce63f33b Mon Sep 17 00:00:00 2001 From: Michael Rasmussen Date: Wed, 25 Dec 2019 20:52:52 +0100 Subject: [PATCH] initialize Signed-off-by: Michael Rasmussen --- Makefile.am | 13 +++- configure.ac | 3 +- example/Makefile.am | 19 ++++++ example/vcard-example.c | 5 ++ src/Makefile.am | 17 ++--- src/vcard-example.c | 0 src/vcard-parser.h | 144 ++++++++++++++++++++++++++++++++++++++++ src/vcard.c | 30 +++++++++ src/vcard.h | 49 ++++++++++++++ 9 files changed, 267 insertions(+), 13 deletions(-) create mode 100644 example/Makefile.am create mode 100644 example/vcard-example.c delete mode 100644 src/vcard-example.c create mode 100644 src/vcard-parser.h diff --git a/Makefile.am b/Makefile.am index 2cba5ad..0800c5c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,6 +2,17 @@ AUTOMAKE_OPTIONS = gnu SUBDIRS = src +if BUILD_EXAMPLE +SUBDIRS += example +endif + ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = README COPYING AUTHORS ChangeLog INSTALL NEWS +EXTRA_DIST = \ + README \ + COPYING \ + AUTHORS \ + ChangeLog \ + INSTALL \ + NEWS \ + autogen.sh diff --git a/configure.ac b/configure.ac index d811bcf..ead011d 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,7 @@ AM_CONDITIONAL(BUILD_EXAMPLE, test x"$ac_enable_example" = "xyes") AC_CONFIG_COMMANDS( [summary], [[echo "" - echo -e "libvcard will be compiled with these settings:" + echo -e "libvCard will be compiled with these settings:" echo -e "\tCFLAGS:\t\t${CFLAGS}" echo -e "\tLIBS:\t\t${LIBS}" echo -e "\tExample:\t${EXAMPLE}" @@ -91,5 +91,6 @@ AC_CONFIG_COMMANDS( AC_OUTPUT([ Makefile + example/Makefile src/Makefile ]) diff --git a/example/Makefile.am b/example/Makefile.am new file mode 100644 index 0000000..f742448 --- /dev/null +++ b/example/Makefile.am @@ -0,0 +1,19 @@ +AUTOMAKE_OPTIONS = gnu + +AM_CPPFLAGS = \ + @GLIB_CFLAGS@ \ + -I$(top_srcdir) -I$(top_builddir) \ + -I$(top_srcdir)/src -I$(top_builddir)/src \ + -I$(top_srcdir)/example -I$(top_builddir)/example + +bin_PROGRAMS = vcard-example + +vcard_example_SOURCES = \ + vcard-example + +vcard_example_LDFLAGS = \ + -L$(top_srcdir)/src/ + +vcard_example_LDADD = \ + $(GLIB_LIBS) \ + -lvCard diff --git a/example/vcard-example.c b/example/vcard-example.c new file mode 100644 index 0000000..254bca4 --- /dev/null +++ b/example/vcard-example.c @@ -0,0 +1,5 @@ +# include + +int main() { + return 0; +} diff --git a/src/Makefile.am b/src/Makefile.am index b1191dc..e4bf932 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,22 +4,17 @@ AM_CPPFLAGS = \ @GLIB_CFLAGS@ \ -I $(top_srcdir) -lib_LTLIBRARIES = libvcard.la +lib_LTLIBRARIES = libvCard.la -libvcard_la_SOURCES = \ - vcard.c +libvCard_la_SOURCES = \ + vcard.c \ + vcard-parser.h -libvcard_la_LDFLAGS = \ +libvCard_la_LDFLAGS = \ -version-info @LIB_VERSION@ include_HEADERS = \ vcard.h -libvcard_la_LIBADD = \ +libvCard_la_LIBADD = \ @GLIB_LIBS@ -if BUILD_EXAMPLE -bin_PROGRAMS = vcard-example -vcard_example_SOURCES = vcard-example.c -vcard_example_LDADD = libvcard.la -endif - diff --git a/src/vcard-example.c b/src/vcard-example.c deleted file mode 100644 index e69de29..0000000 diff --git a/src/vcard-parser.h b/src/vcard-parser.h new file mode 100644 index 0000000..9884abb --- /dev/null +++ b/src/vcard-parser.h @@ -0,0 +1,144 @@ +/* + * 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_H__ +#define __VCARD_H__ + +#include + +G_BEGIN_DECLS + +typedef enum { + // vCard 2.1 properties and up + 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, + // vCard 3.0 properties + CATEGORIES, + SORT_STRING, + PRODID, + NICKNAME, + CLASS, // Removed in vCard 4.0 + // rfc2739 properties + FBURL, + CAPURI, + CALURI, + CALADRURI, + // rfc4770 properties + IMPP, + // vCard 4.0 properties + SOURCE, + XML, + ANNIVERSARY, + CLIENTPIDMAP, + LANG, + GENDER, + KIND, + MEMBER, + RELATED, + // rfc6474 properties + BIRTHPLACE, + DEATHPLACE, + DEATHDATE, + // rfc6715 properties + EXPERTISE, + HOBBY, + INTEREST, + ORG_DIRECTORY, + VCARD_PROPERTIES, +} Property; + +gchar* Proterties[VCARD_PROPERTIES+1] = { + "N", + "FN", + "PHOTO", + "BDAY", + "ADR", + "LABEL", + "TEL", + "EMAIL", + "MAILER", + "GEO", + "TITLE", + "ROLE", + "LOGO", + "ORG", + "NOTE", + "REV", + "SOUND", + "URL", + "UID", + "VERSION", + "KEY", + "TZ", + "CATEGORIES", + "SORT-STRING", + "PRODID", + "NICKNAME", + "CLASS", + "FBURL", + "CAPURI", + "CALURI", + "CALADRURI", + "IMPP", + "SOURCE", + "XML", + "ANNIVERSARY", + "CLIENTPIDMAP", + "LANG", + "GENDER", + "KIND", + "MEMBER", + "RELATED", + "BIRTHPLACE", + "DEATHPLACE", + "DEATHDATE", + "EXPERTISE", + "HOBBY", + "INTEREST", + "ORG-DIRECTORY", + NULL +}; + +G_END_DECLS + +gboolean vcard_parse_text(); + +#endif diff --git a/src/vcard.c b/src/vcard.c index e69de29..9a09cca 100644 --- a/src/vcard.c +++ b/src/vcard.c @@ -0,0 +1,30 @@ +/* + * vcard.c + * + * 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. + */ + +# include + +struct _VCard { + gchar *version; +}; + +int main() { + return 0; +} diff --git a/src/vcard.h b/src/vcard.h index e69de29..12bbd76 100644 --- a/src/vcard.h +++ b/src/vcard.h @@ -0,0 +1,49 @@ +/* + * vcard.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 +#include + +typedef enum { + DETECT, + VERSION_2_1, + VERSION_3_0, + VERSION_4_0, +} VCardVersion; + +typedef struct _VCard VCard; + +VCard* VCard_new(VCardVersion version); +VCard* VCard_new_from_text(const gchar* text, VCardVersion version); +VCard* VCard_new_from_file(FILE* file, VCardVersion version); +void VCard_print(VCard* object); +void VCard_print_fd(VCard* object, int fd); + +G_END_DECLS + +#endif -- 2.39.2