Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- theme urls---
- http://wii.spiffy360.com/themes.php?xml=1&category=1&adult=1
- http://wii.spiffy360.com/themes.php?xml=1&category=1&adult=0
- #include "xml/xml.h"
- int numthemes = 0;
- int numberFromline(const char *filename)
- {
- FILE *fp = fopen(filename,"r");
- if (!fp)return -1;
- char in[50] ={0};
- while (fgets(in, sizeof(in), fp))
- {
- if (strcasestr(in,"<totalthemes>"))
- {
- //gprintf("\n\tfound the line with the count on it");
- break;
- }
- }
- fclose(fp);
- char tmp[50] = {0};
- int z=0;
- for (u8 i=0;i<strlen(in);i++)
- {
- z=i;
- if (in[i-1]=='>')break;
- }
- for (u8 i=0;i<strlen(in)-z && in[i+z]!='<';i++)
- {
- tmp[i]=in[i+z];
- }
- //gprintf("\n\ttmp:\"%s\"",tmp);
- return atoi(tmp);
- }
- //Theme_Info themeList[numthemes];
- bool LoadthemeXML(char *filename) {
- gprintf("\nLoadthemeXML(%s)",filename);
- //gprintf("\n\t");
- gprintf("\n\t()%s",MemInfo());
- char element_text[100];
- mxml_node_t *nodetree=NULL;
- mxml_node_t *nodedata=NULL;
- mxml_node_t *nodeid=NULL;
- mxml_index_t *nodeindex=NULL;
- //see how many themes there are
- numthemes = numberFromline(filename);
- if (numthemes<1)return false;
- Theme_Info themeList[numthemes];
- //load that shit
- FILE *filexml;
- filexml = fopen(filename, "rb");
- if (!filexml)
- {
- gprintf("\n\tfile not found");
- return false;
- }
- gprintf("\n\t()%s",MemInfo());
- nodetree = mxmlLoadFile(NULL, filexml, MXML_OPAQUE_CALLBACK);
- fclose(filexml);
- gprintf("\n\t()%s",MemInfo());
- if (nodetree == NULL)
- {
- gprintf("\n\tfail :(");
- return false;
- }
- nodedata = mxmlFindElement(nodetree, nodetree, "themes", NULL, NULL, MXML_DESCEND);
- if (nodedata == NULL)
- {
- gprintf("\n\tfail");
- return false;
- }
- gprintf("\n\t()%s",MemInfo());
- /* index all IDs */
- nodeindex = mxmlIndexNew(nodedata,"name", NULL);
- nodeid = mxmlIndexReset(nodeindex);
- *element_text = 0;
- //gprintf("\n\tIndexed shit ok, starting loop");
- gprintf("\n\t()%s",MemInfo());
- for (int i=0;i<numthemes;i++)
- {
- nodeid = mxmlIndexFind(nodeindex,"name", NULL);
- if (nodeid != NULL) {
- get_textXML(nodeid, element_text, sizeof(element_text));
- strlcpy(themeList[i].themetitle,element_text,sizeof(themeList[i].themetitle));
- GetTextFromNode(nodeid, nodedata, "creator", NULL, NULL, MXML_NO_DESCEND, themeList[i].author,sizeof(themeList[i].author));
- GetTextFromNode(nodeid, nodedata, "thumbpath", NULL, NULL, MXML_NO_DESCEND, themeList[i].imagelink,sizeof(themeList[i].imagelink));
- GetTextFromNode(nodeid, nodedata, "downloadpath", NULL, NULL, MXML_NO_DESCEND, themeList[i].downloadlink,sizeof(themeList[i].downloadlink));
- //gprintf("\n\t[%d]::%s:\t%s\t:%s\t:%s",i,themeList[i].themetitle,themeList[i].author,themeList[i].imagelink,themeList[i].downloadlink);
- }
- else {
- gprintf("\n\tLoop broke early %d/%d",i,numthemes);
- break;
- }
- }
- //gprintf("\n\tSet Vars to null");
- gprintf("\n()%s",MemInfo());
- nodetree=NULL;
- nodedata=NULL;
- nodeid=NULL;
- nodeindex=NULL;
- gprintf("\n()%s",MemInfo());
- gprintf("\n\tDelete shit");
- mxmlIndexDelete(nodeindex);
- free(nodetree);
- free(nodedata);
- free(nodeid);
- gprintf("\n()%s",MemInfo());
- //free(nodeindex);
- gprintf("\n\tdone / /( . Y . )\\ \\");
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement