From: Thadeu Lima de Souza Cascardo Date: Sat, 9 Aug 2008 18:08:44 +0000 (-0300) Subject: Added AtomPerson structure X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fatompub.git;a=commitdiff_plain;h=08735bf9a1fcc5d91dbdbd3ea77f2bc62db32f1f Added AtomPerson structure --- diff --git a/atom/Makefile.am b/atom/Makefile.am index 8b2f66b..1823945 100644 --- a/atom/Makefile.am +++ b/atom/Makefile.am @@ -1,5 +1,5 @@ lib_LTLIBRARIES = libatom.la -libatom_la_SOURCES = entry.c +libatom_la_SOURCES = entry.c person.c libatom_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) libatom_la_CFLAGS += $(XML_CFLAGS) libatom_la_LIBADD = $(GLIB_LIBS) $(XML_LIBS) diff --git a/atom/person.c b/atom/person.c new file mode 100644 index 0000000..f0f653e --- /dev/null +++ b/atom/person.c @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2008 Thadeu Lima de Souza Cascardo + * + * 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 + +#include + +struct _atom_person +{ + char *name; + IRI *uri; + char *email; +}; + +AtomPerson * +atom_person_new (char *name) +{ + AtomPerson *person; + person = g_slice_new (AtomPerson); + person->name = g_strdup (name); + person->uri = NULL; + person->email = NULL; + return person; +} + +void +atom_person_delete (AtomPerson *person) +{ + if (person->name) + g_free (person->name); + if (person->uri) + iri_delete (person->uri); + if (person->email) + g_free (person->email); + g_slice_free (AtomPerson, person); +} + +char * +atom_person_name (AtomPerson *person) +{ + return person->name; +} + +void +atom_person_name_set (AtomPerson *person, char *name) +{ + if (person->name) + g_free (person->name); + person->name = g_strdup (name); +} + +IRI * +atom_person_uri (AtomPerson *person) +{ + return person->uri; +} + +void +atom_person_uri_set (AtomPerson *person, IRI *uri) +{ + if (person->uri) + iri_delete (person->uri); + person->uri = uri; +} + +char * +atom_person_email (AtomPerson *person) +{ + return person->email; +} + +void +atom_person_email_set (AtomPerson *person, char *email) +{ + if (person->email) + g_free (person->email); + person->email = g_strdup (email); +} diff --git a/include/atompub/Makefile.am b/include/atompub/Makefile.am index 219991e..fa038bb 100644 --- a/include/atompub/Makefile.am +++ b/include/atompub/Makefile.am @@ -1,2 +1,2 @@ -pkginclude_HEADERS = atom.h config.h ctx.h entry.h error.h feed.h \ +pkginclude_HEADERS = atom.h config.h ctx.h entry.h person.h error.h feed.h \ iri.h backend.h atom-glib.h error-glib.h diff --git a/include/atompub/person.h b/include/atompub/person.h new file mode 100644 index 0000000..4ae69b4 --- /dev/null +++ b/include/atompub/person.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008 Thadeu Lima de Souza Cascardo + * + * 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 ATOM_PERSON_H +#define ATOM_PERSON_H + +typedef struct _atom_person AtomPerson; + +AtomPerson * atom_person_new (char *); +void atom_person_delete (AtomPerson *); +char * atom_person_name (AtomPerson *); +void atom_person_name_set (AtomPerson *, char *); +IRI * atom_person_uri (AtomPerson *); +void atom_person_uri_set (AtomPerson *, char *); +char * atom_person_email (AtomPerson *); +void atom_person_email_set (AtomPerson *, char *); + +#endif