Added AtomPerson structure
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Aug 2008 18:08:44 +0000 (15:08 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Aug 2008 18:08:44 +0000 (15:08 -0300)
atom/Makefile.am
atom/person.c [new file with mode: 0644]
include/atompub/Makefile.am
include/atompub/person.h [new file with mode: 0644]

index 8b2f66b..1823945 100644 (file)
@@ -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 (file)
index 0000000..f0f653e
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ *  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 <atompub/atom.h>
+
+#include <glib.h>
+
+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);
+}
index 219991e..fa038bb 100644 (file)
@@ -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 (file)
index 0000000..4ae69b4
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ *  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