Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 2nd, 2012  |  syntax: None  |  size: 3.29 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. theme urls---
  3. http://wii.spiffy360.com/themes.php?xml=1&category=1&adult=1
  4. http://wii.spiffy360.com/themes.php?xml=1&category=1&adult=0
  5.  
  6.  
  7. #include "xml/xml.h"
  8.  
  9. int numthemes = 0;
  10. int numberFromline(const char *filename)
  11. {
  12.         FILE *fp = fopen(filename,"r");
  13.         if (!fp)return -1;
  14.         char in[50] ={0};
  15.         while (fgets(in, sizeof(in), fp))
  16.         {
  17.                 if (strcasestr(in,"<totalthemes>"))
  18.                 {
  19.                         //gprintf("\n\tfound the line with the count on it");
  20.                         break;
  21.                 }
  22.         }
  23.         fclose(fp);
  24.  
  25.         char tmp[50] = {0};
  26.         int z=0;
  27.         for (u8 i=0;i<strlen(in);i++)
  28.         {
  29.                 z=i;
  30.                 if (in[i-1]=='>')break;
  31.         }
  32.         for (u8 i=0;i<strlen(in)-z && in[i+z]!='<';i++)
  33.         {
  34.                 tmp[i]=in[i+z];
  35.         }
  36.         //gprintf("\n\ttmp:\"%s\"",tmp);
  37.         return atoi(tmp);
  38.  
  39.  
  40. }
  41. //Theme_Info themeList[numthemes];
  42. bool LoadthemeXML(char *filename) {
  43.     gprintf("\nLoadthemeXML(%s)",filename);
  44.         //gprintf("\n\t");
  45.         gprintf("\n\t()%s",MemInfo());
  46.         char element_text[100];
  47.         mxml_node_t *nodetree=NULL;
  48.         mxml_node_t *nodedata=NULL;
  49.         mxml_node_t *nodeid=NULL;
  50.         mxml_index_t *nodeindex=NULL;
  51.        
  52.         //see how many themes there are
  53.         numthemes = numberFromline(filename);
  54.         if (numthemes<1)return false;
  55.         Theme_Info themeList[numthemes];
  56.         //load that shit
  57.     FILE *filexml;
  58.     filexml = fopen(filename, "rb");
  59.     if (!filexml)
  60.         {
  61.                 gprintf("\n\tfile not found");
  62.         return false;
  63.         }
  64.         gprintf("\n\t()%s",MemInfo());
  65.        
  66.         nodetree = mxmlLoadFile(NULL, filexml, MXML_OPAQUE_CALLBACK);
  67.     fclose(filexml);
  68. gprintf("\n\t()%s",MemInfo());
  69.        
  70.     if (nodetree == NULL)
  71.         {
  72.                 gprintf("\n\tfail :(");
  73.         return false;
  74.         }
  75.  
  76.     nodedata = mxmlFindElement(nodetree, nodetree, "themes", NULL, NULL, MXML_DESCEND);
  77.     if (nodedata == NULL)
  78.         {
  79.                 gprintf("\n\tfail");
  80.         return false;
  81.     }
  82.         gprintf("\n\t()%s",MemInfo());
  83.        
  84.         /* index all IDs */
  85.     nodeindex = mxmlIndexNew(nodedata,"name", NULL);
  86.     nodeid = mxmlIndexReset(nodeindex);
  87.     *element_text = 0;
  88.         //gprintf("\n\tIndexed shit ok,  starting loop");
  89.     gprintf("\n\t()%s",MemInfo());
  90.  
  91.        
  92.         for (int i=0;i<numthemes;i++)
  93.         {
  94.                 nodeid = mxmlIndexFind(nodeindex,"name", NULL);
  95.         if (nodeid != NULL) {
  96.                         get_textXML(nodeid, element_text, sizeof(element_text));
  97.             strlcpy(themeList[i].themetitle,element_text,sizeof(themeList[i].themetitle));
  98.                         GetTextFromNode(nodeid, nodedata, "creator", NULL, NULL, MXML_NO_DESCEND, themeList[i].author,sizeof(themeList[i].author));
  99.                         GetTextFromNode(nodeid, nodedata, "thumbpath", NULL, NULL, MXML_NO_DESCEND, themeList[i].imagelink,sizeof(themeList[i].imagelink));
  100.                         GetTextFromNode(nodeid, nodedata, "downloadpath", NULL, NULL, MXML_NO_DESCEND, themeList[i].downloadlink,sizeof(themeList[i].downloadlink));
  101.                         //gprintf("\n\t[%d]::%s:\t%s\t:%s\t:%s",i,themeList[i].themetitle,themeList[i].author,themeList[i].imagelink,themeList[i].downloadlink);
  102.                 }
  103.                 else {
  104.                 gprintf("\n\tLoop broke early %d/%d",i,numthemes);
  105.             break;
  106.         }
  107.         }
  108.         //gprintf("\n\tSet Vars to null");
  109.         gprintf("\n()%s",MemInfo());
  110.         nodetree=NULL;
  111.         nodedata=NULL;
  112.         nodeid=NULL;
  113.         nodeindex=NULL;
  114.         gprintf("\n()%s",MemInfo());
  115.         gprintf("\n\tDelete shit");
  116.     mxmlIndexDelete(nodeindex);
  117.         free(nodetree);
  118.         free(nodedata);
  119.         free(nodeid);
  120.         gprintf("\n()%s",MemInfo());
  121.         //free(nodeindex);
  122.         gprintf("\n\tdone / /( . Y . )\\ \\");
  123.    
  124.     return true;
  125. }