*forgot that i wanted to fix the beta updater

The beta updates will work now. You will have to update to this revision manually though.
This commit is contained in:
dimok321 2010-05-30 07:00:29 +00:00
parent 095d09eb93
commit 1e9951f586
5 changed files with 346 additions and 85 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r933</version>
<release_date>201005291607</release_date>
<version>1.0 r934</version>
<release_date>201005300653</release_date>
<short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,196 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* HTML_Stream Class
*
* for WiiXplorer 2010
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "HTML_Stream.h"
#include "networkops.h"
#include "http.h"
#define htmlstringcompare(text, cmp, pos) strncasecmp((const char*) &text[pos], (const char*) cmp, strlen((const char*) cmp))
HTML_Stream::HTML_Stream()
{
HTML_File = NULL;
position = 0;
filesize = 0;
}
HTML_Stream::HTML_Stream(const char * url)
{
HTML_File = NULL;
position = 0;
filesize = 0;
LoadLink(url);
}
HTML_Stream::~HTML_Stream()
{
if(HTML_File)
free(HTML_File);
}
bool HTML_Stream::LoadLink(const char * url)
{
if (!IsNetworkInit())
return false;
struct block file = downloadfile(url);
if (!file.data || !file.size)
return false;
if(HTML_File)
free(HTML_File);
HTML_File = (char *) file.data;
filesize = file.size;
position = 0;
return true;
}
const char * HTML_Stream::FindStringStart(const char * string)
{
if (!HTML_File)
return NULL;
while((u32) position < filesize)
{
if(htmlstringcompare(HTML_File, string, position) == 0)
break;
position++;
}
return &HTML_File[position];
}
const char * HTML_Stream::FindStringEnd(const char * string)
{
if (!HTML_File)
return NULL;
while((u32) position < filesize)
{
if(htmlstringcompare(HTML_File, string, position) == 0)
break;
position++;
}
if((u32) position >= filesize)
{
return NULL;
}
position += strlen(string);
return &HTML_File[position];
}
char * HTML_Stream::CopyString(const char * stopat)
{
if(!stopat || !HTML_File)
return NULL;
u32 blocksize = 1024;
u32 counter = 0;
u32 allocatedsize = 0;
char * outtext = (char*) malloc(blocksize);
if(!outtext)
return NULL;
allocatedsize = blocksize;
memset(outtext, 0, blocksize);
while ((htmlstringcompare(HTML_File, stopat, position) != 0) && (position+strlen(stopat) < filesize))
{
if(counter > blocksize)
{
blocksize += 1024;
char * tmpblock = (char*) realloc(outtext, blocksize);
if(!tmpblock)
{
free(outtext);
outtext = NULL;
free(tmpblock);
return NULL;
}
outtext = tmpblock;
}
outtext[counter] = HTML_File[position];
position++;
counter++;
}
outtext[counter] = '\0';
outtext = (char*) realloc(outtext, counter+1);
return outtext;
}
int HTML_Stream::Seek(u32 pos, int origin)
{
if(!HTML_File)
return -1;
switch(origin)
{
case SEEK_SET:
position = pos;
break;
case SEEK_CUR:
position += pos;
break;
case SEEK_END:
position = filesize+pos;
break;
}
return 0;
}
void HTML_Stream::Rewind()
{
if(!HTML_File)
return;
position = 0;
}
int HTML_Stream::GetPosition()
{
return position;
}

View File

@ -0,0 +1,68 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* HTML_Stream Class
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef ___HTML_STREAM_H_
#define ___HTML_STREAM_H_
#include <gctypes.h>
class HTML_Stream
{
public:
//!Constructor
HTML_Stream();
//!\param url from where to the HTML file
HTML_Stream(const char * url);
//!Destructor
~HTML_Stream();
//!Load url
bool LoadLink(const char * url);
//! Find start of a string from current position in the html
//!\param string to find
const char * FindStringStart(const char * string);
//! Find end of a string from current position in the html
//!\param string to find
const char * FindStringEnd(const char * string);
//!CopyString from current position in html till stopat string
//!\param stopat string before which to stop copying (e.g. </html>)
//!\param outtext variable is allocated with malloc and must be set 0 before
char * CopyString(const char * stopat);
//!Seek position in file
//!\param position seeked
//!\param seek origin (SEEK_SET, SEEK_CUR, SEEK_END)
int Seek(u32 pos, int origin);
//!Rewind to the start of the html
void Rewind();
//!Get current position
int GetPosition();
protected:
int position;
u32 filesize;
char * HTML_File;
};
#endif

View File

@ -1,82 +1,79 @@
/***************************************************************************
* Copyright (C) 2009
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* update.cpp
*
* Update operations
* for Wii-Xplorer 2009
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include <ogcsys.h>
#include "http.h"
#include "networkops.h"
#include "URL_List.h"
/****************************************************************************
* Checking if an Update is available
***************************************************************************/
int CheckForBetaUpdate()
{
int revnumber = 0;
URL_List URLs("http://code.google.com/p/usbloader-gui/downloads/list");
int urlcount = URLs.GetURLCount();
for(int i = 0; i < urlcount; i++)
{
char *tmp = URLs.GetURL(i);
if(tmp)
{
char *fileext = strrchr(tmp, '.');
if(fileext)
{
if(strcasecmp(fileext, ".dol") == 0 || strcasecmp(fileext, ".wad") == 0)
{
char *DownloadLink = (char *) malloc(strlen(tmp)+1);
sprintf(DownloadLink, "%s", tmp);
int rev = 0;
char revtxt[80];
char *filename = strrchr(DownloadLink, '/')+2;
u8 n = 0;
for (n = 0; n < strlen(filename)-2; n++)
revtxt[n] = filename[n];
revtxt[n] = 0;
rev = atoi(revtxt);
if(rev > revnumber) {
revnumber = rev;
}
if(DownloadLink)
free(DownloadLink);
DownloadLink = NULL;
}
}
}
}
return revnumber;
}
/***************************************************************************
* Copyright (C) 2009
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* update.cpp
*
* Update operations
* for Wii-Xplorer 2009
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include <ogcsys.h>
#include "http.h"
#include "networkops.h"
#include "HTML_Stream.h"
/****************************************************************************
* Checking if an Update is available
***************************************************************************/
int CheckForBetaUpdate()
{
int revnumber = 0;
HTML_Stream HTML("http://code.google.com/p/usbloader-gui/downloads/list");
const char * HTML_Pos = NULL;
do
{
HTML_Pos = HTML.FindStringEnd("href='");
char * tmpLink = HTML.CopyString("'\"");
if(tmpLink)
{
char *fileext = strrchr(tmpLink, '.');
if(fileext)
{
if(strcasecmp(fileext, ".dol") == 0)
{
char revtxt[80];
char *filename = strrchr(tmpLink, '/')+2;
u8 n = 0;
for (n = 0; n < strlen(filename)-2; n++)
revtxt[n] = filename[n];
revtxt[n] = 0;
int fileRev = atoi(revtxt);
if(fileRev > revnumber)
{
revnumber = fileRev;
}
}
}
free(tmpLink);
}
}
while(HTML_Pos != NULL);
return revnumber;
}