From d455bafc96d1de826378c31d6646a63fa66f688d Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sat, 9 Aug 2008 15:51:51 -0300 Subject: [PATCH] Create a XML node from an AtomPerson --- atom/person.c | 14 ++++++++++++++ include/atompub/atom-xml.h | 25 +++++++++++++++++++++++++ include/atompub/person-xml.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 include/atompub/atom-xml.h create mode 100644 include/atompub/person-xml.h diff --git a/atom/person.c b/atom/person.c index 6b63ec4..62f9ed4 100644 --- a/atom/person.c +++ b/atom/person.c @@ -20,6 +20,7 @@ #include #include +#include struct _atom_person { @@ -92,3 +93,16 @@ atom_person_email_set (AtomPerson *person, char *email) g_free (person->email); person->email = g_strdup (email); } + +xmlNodePtr +atom_person_to_xmlnode (AtomPerson *person, char *elname) +{ + xmlNodePtr node; + node = xmlNewNode (NULL, elname); + xmlNewTextChild (node, NULL, "name", person->name); + if (person->uri) + xmlNewTextChild (node, NULL, "uri", iri_get_string (person->uri)); + if (person->email) + xmlNewTextChild (node, NULL, "email", person->email); + return node; +} diff --git a/include/atompub/atom-xml.h b/include/atompub/atom-xml.h new file mode 100644 index 0000000..60fe48e --- /dev/null +++ b/include/atompub/atom-xml.h @@ -0,0 +1,25 @@ +/* + * 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 ATOMPUB_ATOM_XML_H +#define ATOMPUB_ATOM_XML_H + +#include + +#endif diff --git a/include/atompub/person-xml.h b/include/atompub/person-xml.h new file mode 100644 index 0000000..69b7508 --- /dev/null +++ b/include/atompub/person-xml.h @@ -0,0 +1,29 @@ +/* + * 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_XML_H +#define ATOM_PERSON_XML_H + +#include + +#include + +xmlNodePtr atom_person_to_xmlnode (AtomPerson *, char *); + +#endif -- 2.20.1