*Changed to download files under their real filename

*Small change to the download request function, added filename reading
This commit is contained in:
dimok321 2009-11-02 22:15:28 +00:00
parent 12e42498dc
commit d3d2055583
5 changed files with 717 additions and 696 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="true"></e><e p="gui\source\xml" x="false"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\ramdisc" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="true"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\themes" x="false"></e></ViewState></pd>
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="true"></e><e p="gui\source\xml" x="false"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\ramdisk" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="true"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\themes" x="false"></e></ViewState></pd>

View File

@ -99,7 +99,7 @@ bool ShutdownWC24() {
return onlinefix;
}
s32 network_request(const char * request) {
s32 network_request(const char * request, char * filename) {
char buf[1024];
char *ptr = NULL;
@ -122,6 +122,24 @@ s32 network_request(const char * request) {
/* HTTP request OK? */
if (!strstr(buf, "HTTP/1.1 200 OK"))
return -1;
if(filename)
{
/* Get filename */
ptr = strstr(buf, "filename=\"");
if(ptr)
{
ptr += sizeof("filename=\"")-1;
for(cnt = 0; ptr[cnt] != '\r' && ptr[cnt] != '\n' && ptr[cnt] != '"'; cnt++)
{
filename[cnt] = ptr[cnt];
filename[cnt+1] = '\0';
}
}
}
/* Retrieve content size */
ptr = strstr(buf, "Content-Length:");
if (!ptr)
@ -156,7 +174,7 @@ s32 network_read(u8 *buf, u32 len) {
/****************************************************************************
* Download request
***************************************************************************/
s32 download_request(const char * url) {
s32 download_request(const char * url, char * filename) {
//Check if the url starts with "http://", if not it is not considered a valid url
if (strncmp(url, "http://", strlen("http://")) != 0) {
@ -190,7 +208,7 @@ s32 download_request(const char * url) {
char header[strlen(path)+strlen(domain)+strlen(url)+100];
sprintf(header, "GET %s HTTP/1.1\r\nHost: %s\r\nReferer: %s\r\nConnection: close\r\n\r\n", path, domain, url);
s32 filesize = network_request(header);
s32 filesize = network_request(header, filename);
return filesize;
}

View File

@ -1,30 +1,30 @@
/****************************************************************************
* Network Operations
* for USB Loader GX
*
* HTTP operations
* Written by dhewg/bushing modified by dimok
****************************************************************************/
/****************************************************************************
* Network Operations
* for USB Loader GX
*
* HTTP operations
* Written by dhewg/bushing modified by dimok
****************************************************************************/
#ifndef _NETWORKOPS_H_
#define _NETWORKOPS_H_
#define NETWORKBLOCKSIZE 5*1024 //5KB
void Initialize_Network(void);
bool IsNetworkInit(void);
char * GetNetworkIP(void);
char * GetIncommingIP(void);
bool ShutdownWC24();
s32 network_request(const char * request);
s32 network_read(u8 *buf, u32 len);
s32 download_request(const char * url);
void CloseConnection();
int CheckUpdate();
void HaltNetworkThread();
void ResumeNetworkWait();
void ResumeNetworkThread();
void InitNetworkThread();
void ShutdownNetworkThread();
#define _NETWORKOPS_H_
#define NETWORKBLOCKSIZE 5*1024 //5KB
void Initialize_Network(void);
bool IsNetworkInit(void);
char * GetNetworkIP(void);
char * GetIncommingIP(void);
bool ShutdownWC24();
s32 network_request(const char * request, char * filename);
s32 network_read(u8 *buf, u32 len);
s32 download_request(const char * url, char * filename = NULL);
void CloseConnection();
int CheckUpdate();
void HaltNetworkThread();
void ResumeNetworkWait();
void ResumeNetworkThread();
void InitNetworkThread();
void ShutdownNetworkThread();
#endif

File diff suppressed because it is too large Load Diff