[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4104 - GNUnet/src/transports/upnp
From: |
grothoff |
Subject: |
[GNUnet-SVN] r4104 - GNUnet/src/transports/upnp |
Date: |
Fri, 29 Dec 2006 08:36:52 -0800 (PST) |
Author: grothoff
Date: 2006-12-29 08:36:49 -0800 (Fri, 29 Dec 2006)
New Revision: 4104
Modified:
GNUnet/src/transports/upnp/Makefile.am
GNUnet/src/transports/upnp/upnp.c
GNUnet/src/transports/upnp/upnp.h
GNUnet/src/transports/upnp/util.c
GNUnet/src/transports/upnp/util.h
GNUnet/src/transports/upnp/xmlnode.c
GNUnet/src/transports/upnp/xmlnode.h
Log:
removing need for glib
Modified: GNUnet/src/transports/upnp/Makefile.am
===================================================================
--- GNUnet/src/transports/upnp/Makefile.am 2006-12-29 15:50:09 UTC (rev
4103)
+++ GNUnet/src/transports/upnp/Makefile.am 2006-12-29 16:36:49 UTC (rev
4104)
@@ -14,18 +14,18 @@
init.c \
ip.c ip.h \
util.c util.h \
- xmlnode.c xmlnode.h \
- upnp.c upnp.h
+ upnp.c upnp.h \
+ xmlnode.c xmlnode.h
libgnunetmodule_upnp_la_LDFLAGS = \
-export-dynamic -avoid-version -module
libgnunetmodule_upnp_la_CFLAGS = \
-I$(top_scrdir)/include \
- @LIBCURL_CPPFLAGS@ @XML_CPPFLAGS@ @GNUNETGTK_CFLAGS@ @GTK_CFLAGS@
+ @LIBCURL_CPPFLAGS@ @XML_CPPFLAGS@
libgnunetmodule_upnp_la_LIBADD = \
- @GTK_LIBS@ @EXT_LIB_PATH@ @EXT_LIBS@ \
- @GNUNETGTK_LIBS@ @XML_LIBS@ @LIBCURL@ \
- $(top_builddir)/src/util/libgnunetutil.la
+ @EXT_LIB_PATH@ @EXT_LIBS@ @XML_LIBS@ @LIBCURL@ \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/util/cron/libgnunetutil_cron.la
check_PROGRAMS = \
upnptest
@@ -37,7 +37,6 @@
upnptest_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
Modified: GNUnet/src/transports/upnp/upnp.c
===================================================================
--- GNUnet/src/transports/upnp/upnp.c 2006-12-29 15:50:09 UTC (rev 4103)
+++ GNUnet/src/transports/upnp/upnp.c 2006-12-29 16:36:49 UTC (rev 4104)
@@ -32,6 +32,20 @@
#include <curl/curl.h>
+#define gchar char
+#define gboolean int
+#define TRUE YES
+#define FALSE NO
+#define gpointer void *
+#define g_free FREE
+#define gsize size_t
+#define g_strdup STRDUP
+#define g_strndup STRNDUP
+#define g_ascii_strcasecmp strcasecmp
+#define G_GSIZE_FORMAT "u"
+#define g_return_if_fail(a) if(!(a)) return;
+#define g_return_val_if_fail(a, val) if(!(a)) return (val);
+
/**
* The xmlnode code has a bunch of memory leaks which
* occur with malformed XML input (i.e. XML input is
@@ -133,6 +147,41 @@
+static char * g_strstr_len (const gchar *haystack,
+ int haystack_len,
+ const gchar *needle) {
+ int i;
+
+ g_return_val_if_fail (haystack != NULL, NULL);
+ g_return_val_if_fail (needle != NULL, NULL);
+
+ if (haystack_len < 0)
+ return strstr (haystack, needle);
+ else
+ {
+ const char *p = haystack;
+ int needle_len = strlen (needle);
+ const char *end = haystack + haystack_len - needle_len;
+
+ if (needle_len == 0)
+ return (char *)haystack;
+
+ while (*p && p <= end)
+ {
+ for (i = 0; i < needle_len; i++)
+ if (p[i] != needle[i])
+ goto next;
+
+ return (char *)p;
+
+ next:
+ p++;
+ }
+ }
+
+ return NULL;
+}
+
static gboolean
gaim_upnp_compare_device(const xmlnode* device,
const gchar* deviceType) {
Modified: GNUnet/src/transports/upnp/upnp.h
===================================================================
--- GNUnet/src/transports/upnp/upnp.h 2006-12-29 15:50:09 UTC (rev 4103)
+++ GNUnet/src/transports/upnp/upnp.h 2006-12-29 16:36:49 UTC (rev 4104)
@@ -28,7 +28,6 @@
#include <libxml/parser.h>
#include <string.h>
-#include <glib.h>
#include "gnunet_util.h"
#include "gnunet_util_cron.h"
@@ -57,7 +56,7 @@
*
* @return The IP address of the network, or NULL if something went wrong
*/
-const gchar * gaim_upnp_get_public_ip(void);
+const char * gaim_upnp_get_public_ip(void);
/**
* Maps Ports in a UPnP enabled IGD that sits on the local network to
@@ -75,7 +74,7 @@
struct GC_Configuration * cfg,
int do_add,
unsigned short portmap,
- const gchar* protocol);
+ const char* protocol);
#if 0 /* keep Emacsens' auto-indent happy */
{
Modified: GNUnet/src/transports/upnp/util.c
===================================================================
--- GNUnet/src/transports/upnp/util.c 2006-12-29 15:50:09 UTC (rev 4103)
+++ GNUnet/src/transports/upnp/util.c 2006-12-29 16:36:49 UTC (rev 4104)
@@ -23,94 +23,114 @@
#include "platform.h"
#include "util.h"
-#include <glib.h>
+#include "gnunet_util.h"
/* Returns a NULL-terminated string after unescaping an entity
* (eg. &, < & etc.) starting at s. Returns NULL on failure.*/
static const char *
-detect_entity(const char *text, int *length)
-{
- const char *pln;
- int len, pound;
+detect_entity(const char *text, int *length) {
+ const char *pln;
+ int len, pound;
+
+ if (!text || *text != '&')
+ return NULL;
+
+#define IS_ENTITY(s) (!strncasecmp(text, s, (len = sizeof(s) - 1)))
+
+ if(IS_ENTITY("&"))
+ pln = "&";
+ else if(IS_ENTITY("<"))
+ pln = "<";
+ else if(IS_ENTITY(">"))
+ pln = ">";
+ else if(IS_ENTITY(" "))
+ pln = " ";
+ else if(IS_ENTITY("©"))
+ pln = "\302\251"; /* or use g_unichar_to_utf8(0xa9); */
+ else if(IS_ENTITY("""))
+ pln = "\"";
+ else if(IS_ENTITY("®"))
+ pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */
+ else if(IS_ENTITY("'"))
+ pln = "\'";
+ else if(*(text+1) == '#' && (sscanf(text, "&#%u;", £) == 1) &&
+ pound != 0 && *(text+3+(int)log10(pound)) == ';') {
+ char b[7];
+ char * buf = string_convertToUtf8(NULL,
+ (const char*) £,
+ 2,
+ "UNICODE");
+ if (strlen(buf) > 6)
+ buf[6] = '\0';
+ strcpy(b, buf);
+ pln = b;
+ FREE(buf);
+ len = 2;
+ while (isdigit((int) text[len])) len++;
+ if(text[len] == ';') len++;
+ } else
+ return NULL;
+
+ if (length)
+ *length = len;
+ return pln;
+}
- if (!text || *text != '&')
- return NULL;
+char *
+g_strdup_printf(const char * fmt,
+ ...) {
+ size_t size;
+ char * buf;
+ va_list va;
-#define IS_ENTITY(s) (!g_ascii_strncasecmp(text, s, (len = sizeof(s) - 1)))
-
- if(IS_ENTITY("&"))
- pln = "&";
- else if(IS_ENTITY("<"))
- pln = "<";
- else if(IS_ENTITY(">"))
- pln = ">";
- else if(IS_ENTITY(" "))
- pln = " ";
- else if(IS_ENTITY("©"))
- pln = "\302\251"; /* or use g_unichar_to_utf8(0xa9); */
- else if(IS_ENTITY("""))
- pln = "\"";
- else if(IS_ENTITY("®"))
- pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */
- else if(IS_ENTITY("'"))
- pln = "\'";
- else if(*(text+1) == '#' && (sscanf(text, "&#%u;", £) == 1) &&
- pound != 0 && *(text+3+(gint)log10(pound)) == ';') {
- static char buf[7];
- int buflen = g_unichar_to_utf8((gunichar)pound, buf);
- buf[buflen] = '\0';
- pln = buf;
-
- len = 2;
- while(isdigit((gint) text[len])) len++;
- if(text[len] == ';') len++;
- }
- else
- return NULL;
-
- if (length)
- *length = len;
- return pln;
+ va_start(va, fmt);
+ size = VSNPRINTF(NULL, 0, fmt, va) + 1;
+ va_end(va);
+ buf = malloc(size);
+ va_start(va, fmt);
+ VSNPRINTF(buf, size, fmt, va);
+ va_end(va);
+ return buf;
}
char *
gaim_unescape_html(const char *html) {
- if (html != NULL) {
- const char *c = html;
- GString *ret = g_string_new("");
- while (*c) {
- int len;
- const char *ent;
-
- if ((ent = detect_entity(c, &len)) != NULL) {
- ret = g_string_append(ret, ent);
- c += len;
- } else if (!strncmp(c, "<br>", 4)) {
- ret = g_string_append_c(ret, '\n');
- c += 4;
- } else {
- ret = g_string_append_c(ret, *c);
- c++;
- }
- }
- return g_string_free(ret, FALSE);
- }
-
- return NULL;
+ if (html != NULL) {
+ const char *c = html;
+ char *ret = STRDUP("");
+ char *app;
+ while (*c) {
+ int len;
+ const char *ent;
+
+ if ((ent = detect_entity(c, &len)) != NULL) {
+ app = g_strdup_printf("%s%s", ret, ent);
+ FREE(ret);
+ ret = app;
+ c += len;
+ } else if (!strncmp(c, "<br>", 4)) {
+ app = g_strdup_printf("%s%s", ret, "\n");
+ FREE(ret);
+ ret = app;
+ c += 4;
+ } else {
+ app = g_strdup_printf("%s%c", ret, *c);
+ FREE(ret);
+ ret = app;
+ c++;
+ }
+ }
+ return ret;
+ }
+ return NULL;
}
-gboolean
-gaim_str_has_prefix(const char *s, const char *p)
-{
-#if GLIB_CHECK_VERSION(2,2,0)
- return g_str_has_prefix(s, p);
-#else
- g_return_val_if_fail(s != NULL, FALSE);
- g_return_val_if_fail(p != NULL, FALSE);
-
- return (!strncmp(s, p, strlen(p)));
-#endif
+int
+gaim_str_has_prefix(const char *s, const char *p) {
+ if ( (s == NULL) || (p == NULL) )
+ return 0;
+ return ! strncmp(s, p, strlen(p));
}
-
+/* end of util.c */
Modified: GNUnet/src/transports/upnp/util.h
===================================================================
--- GNUnet/src/transports/upnp/util.h 2006-12-29 15:50:09 UTC (rev 4103)
+++ GNUnet/src/transports/upnp/util.h 2006-12-29 16:36:49 UTC (rev 4104)
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <string.h>
-#include <glib.h>
#ifdef __cplusplus
extern "C" {
@@ -57,8 +56,11 @@
*
* @return TRUE if p is a prefix of s, otherwise FALSE.
*/
-gboolean gaim_str_has_prefix(const char *s, const char *p);
+int gaim_str_has_prefix(const char *s, const char *p);
+char * g_strdup_printf(const char * fmt,
+ ...);
+
#ifdef __cplusplus
}
#endif
Modified: GNUnet/src/transports/upnp/xmlnode.c
===================================================================
--- GNUnet/src/transports/upnp/xmlnode.c 2006-12-29 15:50:09 UTC (rev
4103)
+++ GNUnet/src/transports/upnp/xmlnode.c 2006-12-29 16:36:49 UTC (rev
4104)
@@ -31,6 +31,7 @@
#include "xmlnode.h"
#include "util.h"
+#include "gnunet_util.h"
#ifdef _WIN32
# define NEWLINE_S "\r\n"
@@ -38,19 +39,50 @@
# define NEWLINE_S "\n"
#endif
-static xmlnode*
-new_node(const char *name, XMLNodeType type)
-{
- xmlnode *node = g_new0(xmlnode, 1);
+#define TRUE YES
+#define FALSE NO
- node->name = g_strdup(name);
- node->type = type;
-#if 0
- GAIM_DBUS_REGISTER_POINTER(node, xmlnode);
-#endif
- return node;
+#define g_strdup STRDUP
+#define g_malloc MALLOC
+#define g_free FREE
+#define g_return_if_fail(a) if(!(a)) return;
+#define g_return_val_if_fail(a, val) if(!(a)) return (val);
+#define gsize size_t
+#define gboolean int
+#define GString char
+#define g_string_new(a) STRDUP(a)
+
+static void * g_memdup(const void * data,
+ size_t s) {
+ void * ret;
+
+ ret = MALLOC(s);
+ memcpy(ret, data, s);
+ return ret;
}
+static char * g_string_append_len(char * prefix,
+ const void * data,
+ size_t s) {
+ char * ret;
+
+ ret = g_strdup_printf("%s%.*s",
+ prefix,
+ s,
+ data);
+ FREE(prefix);
+ return ret;
+}
+
+static xmlnode*
+new_node(const char *name, XMLNodeType type) {
+ xmlnode *node = MALLOC(sizeof(xmlnode));
+
+ node->name = g_strdup(name);
+ node->type = type;
+ return node;
+}
+
xmlnode*
xmlnode_new(const char *name)
{
@@ -92,7 +124,7 @@
}
void
-xmlnode_insert_data(xmlnode *node, const char *data, gssize size)
+xmlnode_insert_data(xmlnode *node, const char *data, int size)
{
xmlnode *child;
gsize real_size;
@@ -111,7 +143,7 @@
xmlnode_insert_child(node, child);
}
-void
+static void
xmlnode_remove_attrib(xmlnode *node, const char *attr)
{
xmlnode *attr_node, *sibling = NULL;
@@ -140,35 +172,7 @@
}
-void
-xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const
char *xmlns)
-{
- xmlnode *attr_node, *sibling = NULL;
- g_return_if_fail(node != NULL);
- g_return_if_fail(attr != NULL);
-
- for(attr_node = node->child; attr_node; attr_node = attr_node->next)
- {
- if(attr_node->type == XMLNODE_TYPE_ATTRIB &&
- !strcmp(attr_node->name, attr) &&
- !strcmp(attr_node->xmlns, xmlns))
- {
- if(node->child == attr_node) {
- node->child = attr_node->next;
- } else {
- sibling->next = attr_node->next;
- }
- if (node->lastchild == attr_node) {
- node->lastchild = sibling;
- }
- xmlnode_free(attr_node);
- return;
- }
- sibling = attr_node;
- }
-}
-
void
xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value)
{
@@ -187,68 +191,15 @@
xmlnode_insert_child(node, attrib_node);
}
-void
-xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char
*xmlns, const char *value)
+static void xmlnode_set_namespace(xmlnode *node, const char *xmlns)
{
- xmlnode *attrib_node;
-
g_return_if_fail(node != NULL);
- g_return_if_fail(attr != NULL);
- g_return_if_fail(value != NULL);
- xmlnode_remove_attrib_with_namespace(node, attr, xmlns);
-
- attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB);
-
- attrib_node->data = g_strdup(value);
- attrib_node->xmlns = g_strdup(xmlns);
-
- xmlnode_insert_child(node, attrib_node);
-}
-
-const char *
-xmlnode_get_attrib(xmlnode *node, const char *attr)
-{
- xmlnode *x;
-
- g_return_val_if_fail(node != NULL, NULL);
-
- for(x = node->child; x; x = x->next) {
- if(x->type == XMLNODE_TYPE_ATTRIB && !strcmp(attr, x->name)) {
- return x->data;
- }
- }
-
- return NULL;
-}
-
-const char *
-xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr, const char
*xmlns)
-{
- xmlnode *x;
-
- g_return_val_if_fail(node != NULL, NULL);
-
- for(x = node->child; x; x = x->next) {
- if(x->type == XMLNODE_TYPE_ATTRIB &&
- !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) {
- return x->data;
- }
- }
-
- return NULL;
-}
-
-
-void xmlnode_set_namespace(xmlnode *node, const char *xmlns)
-{
- g_return_if_fail(node != NULL);
-
g_free(node->xmlns);
node->xmlns = g_strdup(xmlns);
}
-const char *xmlnode_get_namespace(xmlnode *node)
+static const char *xmlnode_get_namespace(xmlnode *node)
{
g_return_val_if_fail(node != NULL, NULL);
@@ -272,9 +223,6 @@
g_free(node->name);
g_free(node->data);
g_free(node->xmlns);
-#if 0
- GAIM_DBUS_UNREGISTER_POINTER(node);
-#endif
g_free(node);
}
@@ -288,7 +236,6 @@
xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name,
const char *ns)
{
xmlnode *x, *ret = NULL;
- char **names;
char *parent_name, *child_name;
if (parent == NULL)
@@ -296,9 +243,12 @@
if (name == NULL)
return NULL;
- names = g_strsplit(name, "/", 2);
- parent_name = names[0];
- child_name = names[1];
+ parent_name = STRDUP(name);
+ child_name = strstr(parent_name, "/");
+ if (child_name != NULL) {
+ child_name[0] = '\0';
+ child_name++;
+ }
for(x = parent->child; x; x = x->next) {
const char *xmlns = NULL;
@@ -312,10 +262,10 @@
}
}
- if(child_name && ret)
+ if (child_name && ret)
ret = xmlnode_get_child(ret, child_name);
- g_strfreev(names);
+ FREE(parent_name);
return ret;
}
@@ -339,108 +289,11 @@
if (str == NULL)
return NULL;
- return g_string_free(str, FALSE);
+ return str;
}
-static char *
-xmlnode_to_str_helper(xmlnode *node, int *len, gboolean formatting, int depth)
-{
- GString *text = g_string_new("");
- xmlnode *c;
- char *node_name, *esc, *esc2, *tab = NULL;
- gboolean need_end = FALSE, pretty = formatting;
-
- if (node == NULL)
- return NULL;
-
- if(pretty && depth) {
- tab = g_strnfill(depth, '\t');
- text = g_string_append(text, tab);
- }
-
- node_name = g_markup_escape_text(node->name, -1);
- g_string_append_printf(text, "<%s", node_name);
-
- if (node->xmlns) {
- if(!node->parent || !node->parent->xmlns || strcmp(node->xmlns,
node->parent->xmlns))
- {
- char *xmlns = g_markup_escape_text(node->xmlns, -1);
- g_string_append_printf(text, " xmlns='%s'", xmlns);
- g_free(xmlns);
- }
- }
- for(c = node->child; c; c = c->next)
- {
- if(c->type == XMLNODE_TYPE_ATTRIB) {
- esc = g_markup_escape_text(c->name, -1);
- esc2 = g_markup_escape_text(c->data, -1);
- g_string_append_printf(text, " %s='%s'", esc, esc2);
- g_free(esc);
- g_free(esc2);
- } else if(c->type == XMLNODE_TYPE_TAG || c->type ==
XMLNODE_TYPE_DATA) {
- if(c->type == XMLNODE_TYPE_DATA)
- pretty = FALSE;
- need_end = TRUE;
- }
- }
-
- if(need_end) {
- g_string_append_printf(text, ">%s", pretty ? NEWLINE_S : "");
-
- for(c = node->child; c; c = c->next)
- {
- if(c->type == XMLNODE_TYPE_TAG) {
- int esc_len;
- esc = xmlnode_to_str_helper(c, &esc_len,
pretty, depth+1);
- text = g_string_append_len(text, esc, esc_len);
- g_free(esc);
- } else if(c->type == XMLNODE_TYPE_DATA && c->data_sz >
0) {
- esc = g_markup_escape_text(c->data, c->data_sz);
- text = g_string_append(text, esc);
- g_free(esc);
- }
- }
-
- if(tab && pretty)
- text = g_string_append(text, tab);
- g_string_append_printf(text, "</%s>%s", node_name, formatting ?
NEWLINE_S : "");
- } else {
- g_string_append_printf(text, "/>%s", formatting ? NEWLINE_S :
"");
- }
-
- g_free(node_name);
-
- g_free(tab);
-
- if(len)
- *len = text->len;
-
- return g_string_free(text, FALSE);
-}
-
-char *
-xmlnode_to_str(xmlnode *node, int *len)
-{
- return xmlnode_to_str_helper(node, len, FALSE, 0);
-}
-
-char *
-xmlnode_to_formatted_str(xmlnode *node, int *len)
-{
- char *xml, *xml_with_declaration;
-
- g_return_val_if_fail(node != NULL, NULL);
-
- xml = xmlnode_to_str_helper(node, len, TRUE, 0);
- xml_with_declaration =
- g_strdup_printf("<?xml version='1.0' encoding='UTF-8' ?>"
NEWLINE_S NEWLINE_S "%s", xml);
- g_free(xml);
-
- return xml_with_declaration;
-}
-
struct _xmlnode_parser_data {
- xmlnode *current;
+ xmlnode *current;
};
static void
@@ -456,7 +309,7 @@
if(!element_name) {
return;
} else {
- if(xpd->current)
+ if(xpd->current)
node = xmlnode_new_child(xpd->current, (const char*)
element_name);
else
node = xmlnode_new((const char *) element_name);
@@ -545,7 +398,7 @@
};
xmlnode *
-xmlnode_from_str(const char *str, gssize size)
+xmlnode_from_str(const char *str, int size)
{
struct _xmlnode_parser_data *xpd;
xmlnode *ret;
@@ -554,7 +407,7 @@
g_return_val_if_fail(str != NULL, NULL);
real_size = size < 0 ? strlen(str) : size;
- xpd = g_new0(struct _xmlnode_parser_data, 1);
+ xpd = MALLOC(sizeof(struct _xmlnode_parser_data));
if (xmlSAXUserParseMemory(&xmlnode_parser_libxml, xpd, str, real_size)
< 0) {
while(xpd->current && xpd->current->parent)
@@ -569,41 +422,6 @@
}
xmlnode *
-xmlnode_copy(xmlnode *src)
-{
- xmlnode *ret;
- xmlnode *child;
- xmlnode *sibling = NULL;
-
- g_return_val_if_fail(src != NULL, NULL);
-
- ret = new_node(src->name, src->type);
- if(src->data) {
- if(src->data_sz) {
- ret->data = g_memdup(src->data, src->data_sz);
- ret->data_sz = src->data_sz;
- } else {
- ret->data = g_strdup(src->data);
- }
- }
-
- for(child = src->child; child; child = child->next) {
- if(sibling) {
- sibling->next = xmlnode_copy(child);
- sibling = sibling->next;
- } else {
- ret->child = xmlnode_copy(child);
- sibling = ret->child;
- }
- sibling->parent = ret;
- }
-
- ret->lastchild = sibling;
-
- return ret;
-}
-
-xmlnode *
xmlnode_get_next_twin(xmlnode *node)
{
xmlnode *sibling;
Modified: GNUnet/src/transports/upnp/xmlnode.h
===================================================================
--- GNUnet/src/transports/upnp/xmlnode.h 2006-12-29 15:50:09 UTC (rev
4103)
+++ GNUnet/src/transports/upnp/xmlnode.h 2006-12-29 16:36:49 UTC (rev
4104)
@@ -27,7 +27,6 @@
#include <libxml/parser.h>
#include <string.h>
-#include <glib.h>
#ifdef __cplusplus
extern "C" {
@@ -36,11 +35,10 @@
/**
* The valid types for an xmlnode
*/
-typedef enum _XMLNodeType
-{
- XMLNODE_TYPE_TAG, /**< Just a tag */
- XMLNODE_TYPE_ATTRIB, /**< Has attributes */
- XMLNODE_TYPE_DATA /**< Has data */
+typedef enum _XMLNodeType {
+ XMLNODE_TYPE_TAG, /**< Just a tag */
+ XMLNODE_TYPE_ATTRIB, /**< Has attributes */
+ XMLNODE_TYPE_DATA /**< Has data */
} XMLNodeType;
/**
@@ -49,15 +47,15 @@
typedef struct _xmlnode xmlnode;
struct _xmlnode
{
- char *name; /**< The name of the node. */
- char *xmlns; /**< The namespace of the node */
- XMLNodeType type; /**< The type of the node. */
- char *data; /**< The data for the node. */
- size_t data_sz; /**< The size of the data. */
- struct _xmlnode *parent; /**< The parent node or @c NULL.*/
- struct _xmlnode *child; /**< The child node or @c NULL.*/
- struct _xmlnode *lastchild; /**< The last child node or @c NULL.*/
- struct _xmlnode *next; /**< The next node or @c NULL. */
+ char *name; /**< The name of the node. */
+ char *xmlns; /**< The namespace of the node */
+ XMLNodeType type; /**< The type of the node. */
+ char *data; /**< The data for the node. */
+ size_t data_sz; /**< The size of the data. */
+ struct _xmlnode *parent; /**< The parent node or @c NULL.*/
+ struct _xmlnode *child; /**< The child node or @c NULL.*/
+ struct _xmlnode *lastchild; /**< The last child node or @c NULL.*/
+ struct _xmlnode *next; /**< The next node or @c NULL. */
};
/**
@@ -125,7 +123,7 @@
* @param size The size of the data to insert. If data is
* null-terminated you can pass in -1.
*/
-void xmlnode_insert_data(xmlnode *node, const char *data, gssize size);
+void xmlnode_insert_data(xmlnode *node, const char *data, int size);
/**
* Gets data from a node.
@@ -146,17 +144,8 @@
*/
void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
+#if 0
/**
- * Sets a namespaced attribute for a node
- *
- * @param node The node to set an attribute for.
- * @param attr The name of the attribute to set
- * @param xmlns The namespace of the attribute to ste
- * @param value The value of the attribute
- */
-void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const
char *xmlns, const char *value);
-
-/**
* Gets an attribute from a node.
*
* @param node The node to get an attribute from.
@@ -176,64 +165,9 @@
* @return The value of the attribute/
*/
const char *xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr,
const char *xmlns);
+#endif
/**
- * Removes an attribute from a node.
- *
- * @param node The node to remove an attribute from.
- * @param attr The attribute to remove.
- */
-void xmlnode_remove_attrib(xmlnode *node, const char *attr);
-
-/**
- * Removes a namespaced attribute from a node
- *
- * @param node The node to remove an attribute from
- * @param attr The attribute to remove
- * @param xmlns The namespace of the attribute to remove
- */
-void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr,
const char *xmlns);
-
-/**
- * Sets the namespace of a node
- *
- * @param node The node to qualify
- * @param xmlns The namespace of the node
- */
-void xmlnode_set_namespace(xmlnode *node, const char *xmlns);
-
-/**
- * Returns the namespace of a node
- *
- * @param node The node to get the namepsace from
- * @return The namespace of this node
- */
-const char *xmlnode_get_namespace(xmlnode *node);
-
-/**
- * Returns the node in a string of xml.
- *
- * @param node The starting node to output.
- * @param len Address for the size of the string.
- *
- * @return The node represented as a string. You must
- * g_free this string when finished using it.
- */
-char *xmlnode_to_str(xmlnode *node, int *len);
-
-/**
- * Returns the node in a string of human readable xml.
- *
- * @param node The starting node to output.
- * @param len Address for the size of the string.
- *
- * @return The node as human readable string including
- * tab and new line characters. You must
- * g_free this string when finished using it.
- */
-char *xmlnode_to_formatted_str(xmlnode *node, int *len);
-
-/**
* Creates a node from a string of XML. Calling this on the
* root node of an XML document will parse the entire document
* into a tree of nodes, and return the xmlnode of the root.
@@ -244,18 +178,9 @@
*
* @return The new node.
*/
-xmlnode *xmlnode_from_str(const char *str, gssize size);
+xmlnode *xmlnode_from_str(const char *str, int size);
/**
- * Creates a new node from the source node.
- *
- * @param src The node to copy.
- *
- * @return A new copy of the src node.
- */
-xmlnode *xmlnode_copy(xmlnode *src);
-
-/**
* Frees a node and all of it's children.
*
* @param node The node to free.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4104 - GNUnet/src/transports/upnp,
grothoff <=