+ if(!strcmp((char *)node->name, name))
+ break;
+ }
+ return(node);
+}
+
+int pubhubxmlhandler(int op, char *buf, size_t *len)
+{
+ static xmlParserCtxtPtr ctxt = NULL;
+ int i, match;
+ xmlNodePtr dr, r, cr, c, n;
+ int numcols, *cols, sortcol;
+ GType type, *types;
+ char **names, *name, *stype, *attr;
+ GtkListStore *model;
+ GtkTreeIter iter;
+
+ numcols = 0;
+ names = NULL;
+ types = NULL;
+ switch(op)
+ {
+ case PHO_INIT:
+ break;
+ case PHO_DATA:
+ if(ctxt == NULL) {
+ ctxt = xmlCreatePushParserCtxt(NULL, NULL, buf, *len, pubhubaddr);
+ *len = 0;
+ if(ctxt == NULL)
+ return(1);
+ } else {
+ xmlParseChunk(ctxt, buf, *len, 0);
+ *len = 0;
+ }
+ break;
+ case PHO_EOF:
+ xmlParseChunk(ctxt, NULL, 0, 1);
+ if(!ctxt->wellFormed)
+ {
+ msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("The hub list at %s is not valid"), pubhubaddr);
+ break;
+ }
+ dr = r = cr = NULL;
+ dr = xmlDocGetRootElement(ctxt->myDoc);
+ if(dr != NULL)
+ r = findnode(dr->children, "Hubs");
+ if(r != NULL)
+ cr = findnode(r->children, "Columns");
+ if(cr == NULL)
+ {
+ msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list at %s cannot be understood"), pubhubaddr);
+ break;
+ }
+ for(c = findnode(cr->children, "Column"); c != NULL; c = findnode(c->next, "Column"))
+ {
+ name = (char *)xmlGetProp(c, (xmlChar *)"Name");
+ stype = (char *)xmlGetProp(c, (xmlChar *)"Type");
+ type = G_TYPE_INVALID;
+ if(stype != NULL)
+ {
+ if(!strcmp(stype, "string"))
+ type = G_TYPE_STRING;
+ else if(!strcmp(stype, "int"))
+ type = G_TYPE_INT;
+ else if(!strcmp(stype, "bytes"))
+ type = G_TYPE_INT64;
+ }
+ if((name != NULL) && (type != G_TYPE_INVALID))
+ {
+ names = srealloc(names, (numcols + 1) * sizeof(*names));
+ types = srealloc(types, (numcols + 1) * sizeof(*names));
+ names[numcols] = sstrdup(name);
+ types[numcols] = type;
+ numcols++;
+ }
+ if(name != NULL)
+ xmlFree(name);
+ if(stype != NULL)
+ xmlFree(stype);
+ }
+ if(numcols == 0)
+ {
+ msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list at %s did not contain any columns"), pubhubaddr);
+ break;
+ }
+ for(i = 0; i < numcols; i++)
+ {
+ if(!strcmp(names[i], "Address"))
+ {
+ name = names[0];
+ names[0] = names[i];
+ names[i] = name;
+ type = types[0];
+ types[0] = types[i];
+ types[i] = type;
+ break;
+ }
+ }
+ if(i == numcols)
+ {
+ msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list at %s did not contain the address to any hubs"));
+ break;
+ }
+ model = gtk_list_store_newv(numcols, types);
+ for(n = findnode(r->children, "Hub"); n != NULL; n = findnode(n->next, "Hub"))