mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-24 20:26:53 +01:00
*Compile warnings fixed for devkitPPC R22
*Changed usb fat partition mount/unmount a bit *Added wifi printf for quick debugging purpose only (not used currently).
This commit is contained in:
parent
87755f2543
commit
71d537c1a7
File diff suppressed because one or more lines are too long
@ -185,7 +185,7 @@ char *DirList::GetFilepath(int ind)
|
||||
unsigned int DirList::GetFilesize(int ind)
|
||||
{
|
||||
if (ind >= filecount || !filecount || !FileInfo)
|
||||
return NULL;
|
||||
return 0;
|
||||
else
|
||||
return FileInfo[ind].FileSize;
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ extern "C" void GetFolderSize(const char * folderpath, u64 * foldersize, u32 * f
|
||||
}
|
||||
else
|
||||
{
|
||||
if(filecount) *filecount++;
|
||||
if(filecount) *filecount += 1;
|
||||
if(foldersize) *foldersize += st.st_size;
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ bool ZipFile::ExtractAll(const char *dest)
|
||||
|
||||
while (!Stop)
|
||||
{
|
||||
if (unzGetCurrentFileInfo(File, &cur_file_info, filename, sizeof(filename), NULL, NULL, NULL, NULL) != UNZ_OK) Stop
|
||||
if (unzGetCurrentFileInfo(File, &cur_file_info, filename, sizeof(filename), NULL, 0, NULL, 0) != UNZ_OK) Stop
|
||||
= true;
|
||||
|
||||
if (!Stop && filename[strlen(filename) - 1] != '/')
|
||||
|
@ -181,7 +181,7 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size)
|
||||
|
||||
if (*((u32*) soundChunk) == 0x4C5A3737 /*"LZ77"*/)
|
||||
{
|
||||
u32 uncSize = NULL;
|
||||
u32 uncSize = 0;
|
||||
u8 * uncompressed_data = uncompressLZ77(soundChunk, soundChunkSize, uncSize);
|
||||
if (!uncompressed_data)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ogc/lwp_watchdog.h>
|
||||
#include <ogc/mutex.h>
|
||||
#include <ogc/system.h>
|
||||
@ -50,25 +51,37 @@ int USBDevice_Init()
|
||||
USBDevice_deInit();
|
||||
//right now mounts first FAT-partition
|
||||
|
||||
if (!fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS))
|
||||
return -1;
|
||||
//usbstorage.startup is actually not needed since it's done in libfat
|
||||
//let's still do it before mount and wait a bit for slow ass hdds before reading from them
|
||||
__io_usbstorage2.startup();
|
||||
usleep(200000);
|
||||
|
||||
if(!fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS))
|
||||
return -1;
|
||||
if (fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS))
|
||||
{
|
||||
fat_usb_sec = _FAT_startSector;
|
||||
return (fat_usb_mount = 1);
|
||||
}
|
||||
|
||||
__io_usbstorage.startup();
|
||||
usleep(200000);
|
||||
|
||||
fat_usb_mount = 1;
|
||||
fat_usb_sec = _FAT_startSector;
|
||||
if(fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS))
|
||||
{
|
||||
fat_usb_sec = _FAT_startSector;
|
||||
return (fat_usb_mount = 1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
__io_usbstorage.shutdown();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void USBDevice_deInit()
|
||||
{
|
||||
//closing all open Files write back the cache and then shutdown em!
|
||||
fatUnmount("USB:/");
|
||||
//only shutdown libogc usb and not the cios one
|
||||
__io_usbstorage.shutdown();
|
||||
__io_usbstorage2.shutdown();
|
||||
|
||||
fat_usb_mount = 0;
|
||||
fat_usb_sec = 0;
|
||||
|
@ -111,7 +111,7 @@ char * HomebrewFiles::GetFilepath(int ind)
|
||||
unsigned int HomebrewFiles::GetFilesize(int ind)
|
||||
{
|
||||
if (ind > filecount || !filecount || !FileInfo)
|
||||
return NULL;
|
||||
return 0;
|
||||
else return FileInfo[ind].FileSize;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,11 @@
|
||||
* HomebrewXML Class
|
||||
* for USB Loader GX
|
||||
***************************************************************************/
|
||||
#include <gctypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "xml/xml.h"
|
||||
|
||||
#include "HomebrewXML.h"
|
||||
@ -24,40 +26,54 @@ HomebrewXML::~HomebrewXML()
|
||||
/* qparam filename Filepath of the XML file */
|
||||
int HomebrewXML::LoadHomebrewXMLData(const char* filename)
|
||||
{
|
||||
mxml_node_t *nodedataHB = NULL;
|
||||
mxml_node_t *nodetreeHB = NULL;
|
||||
Name.clear();
|
||||
Coder.clear();
|
||||
Version.clear();
|
||||
ShortDescription.clear();
|
||||
LongDescription.clear();
|
||||
Releasedate.clear();
|
||||
|
||||
/* Load XML file */
|
||||
FILE *filexml;
|
||||
filexml = fopen(filename, "rb");
|
||||
if (!filexml) return -1;
|
||||
u8 * xmlbuffer = NULL;
|
||||
u64 size = 0;
|
||||
LoadFileToMem(filename, &xmlbuffer, &size);
|
||||
|
||||
nodetreeHB = mxmlLoadFile(NULL, filexml, MXML_OPAQUE_CALLBACK);
|
||||
fclose(filexml);
|
||||
if(!xmlbuffer)
|
||||
return -1;
|
||||
|
||||
if (nodetreeHB == NULL) return -2;
|
||||
mxml_node_t * nodetree = mxmlLoadString(NULL, (const char *) xmlbuffer, MXML_OPAQUE_CALLBACK);
|
||||
|
||||
nodedataHB = mxmlFindElement(nodetreeHB, nodetreeHB, "app", NULL, NULL, MXML_DESCEND);
|
||||
if (nodedataHB == NULL) return -5;
|
||||
if (!nodetree)
|
||||
return -2;
|
||||
|
||||
mxml_node_t * node = mxmlFindElement(nodetree, nodetree, "app", NULL, NULL, MXML_DESCEND_FIRST);
|
||||
if (!node)
|
||||
return -5;
|
||||
|
||||
char * Entrie = new char[ENTRIE_SIZE];
|
||||
|
||||
GetTextFromNode(nodedataHB, nodedataHB, (char*) "name", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Entrie[0] = '\0';
|
||||
GetTextFromNode(node, nodetree, (char*) "name", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Name = Entrie;
|
||||
|
||||
GetTextFromNode(nodedataHB, nodedataHB, (char*) "coder", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Entrie[0] = '\0';
|
||||
GetTextFromNode(node, nodetree, (char*) "coder", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Coder = Entrie;
|
||||
|
||||
GetTextFromNode(nodedataHB, nodedataHB, (char*) "version", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Entrie[0] = '\0';
|
||||
GetTextFromNode(node, nodetree, (char*) "version", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Version = Entrie;
|
||||
|
||||
GetTextFromNode(nodedataHB, nodedataHB, (char*) "short_description", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Entrie[0] = '\0';
|
||||
GetTextFromNode(node, nodetree, (char*) "short_description", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
ShortDescription = Entrie;
|
||||
|
||||
GetTextFromNode(nodedataHB, nodedataHB, (char*) "long_description", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Entrie[0] = '\0';
|
||||
GetTextFromNode(node, nodetree, (char*) "long_description", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
LongDescription = Entrie;
|
||||
|
||||
GetTextFromNode(nodedataHB, nodedataHB, (char*) "release_date", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
Entrie[0] = '\0';
|
||||
GetTextFromNode(node, nodetree, (char*) "release_date", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE);
|
||||
|
||||
int len = (strlen(Entrie) - 6); //length of the date string without the 200000 at the end
|
||||
if (len == 8)
|
||||
@ -69,16 +85,17 @@ int HomebrewXML::LoadHomebrewXMLData(const char* filename)
|
||||
|
||||
Releasedate = Entrie;
|
||||
|
||||
free(nodedataHB);
|
||||
free(nodetreeHB);
|
||||
|
||||
delete[] Entrie;
|
||||
|
||||
mxmlDelete(node);
|
||||
mxmlDelete(nodetree);
|
||||
free(xmlbuffer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get name */
|
||||
const char * HomebrewXML::GetName()
|
||||
const char * HomebrewXML::GetName() const
|
||||
{
|
||||
return Name.c_str();
|
||||
}
|
||||
@ -90,31 +107,31 @@ void HomebrewXML::SetName(char * newName)
|
||||
}
|
||||
|
||||
/* Get coder */
|
||||
const char * HomebrewXML::GetCoder()
|
||||
const char * HomebrewXML::GetCoder() const
|
||||
{
|
||||
return Coder.c_str();
|
||||
}
|
||||
|
||||
/* Get version */
|
||||
const char * HomebrewXML::GetVersion()
|
||||
const char * HomebrewXML::GetVersion() const
|
||||
{
|
||||
return Version.c_str();
|
||||
}
|
||||
|
||||
/* Get releasedate */
|
||||
const char * HomebrewXML::GetReleasedate()
|
||||
const char * HomebrewXML::GetReleasedate() const
|
||||
{
|
||||
return Releasedate.c_str();
|
||||
}
|
||||
|
||||
/* Get shortdescription */
|
||||
const char * HomebrewXML::GetShortDescription()
|
||||
const char * HomebrewXML::GetShortDescription() const
|
||||
{
|
||||
return ShortDescription.c_str();
|
||||
}
|
||||
|
||||
/* Get longdescription */
|
||||
const char * HomebrewXML::GetLongDescription()
|
||||
const char * HomebrewXML::GetLongDescription() const
|
||||
{
|
||||
return LongDescription.c_str();
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ class HomebrewXML
|
||||
|
||||
int LoadHomebrewXMLData(const char* filename);
|
||||
|
||||
const char * GetName();
|
||||
const char * GetName() const;
|
||||
void SetName(char * newName);
|
||||
const char * GetCoder();
|
||||
const char * GetVersion();
|
||||
const char * GetReleasedate();
|
||||
const char * GetShortDescription();
|
||||
const char * GetLongDescription();
|
||||
const char * GetCoder() const;
|
||||
const char * GetVersion() const;
|
||||
const char * GetReleasedate() const;
|
||||
const char * GetShortDescription() const;
|
||||
const char * GetLongDescription() const;
|
||||
|
||||
protected:
|
||||
std::string Name;
|
||||
|
@ -525,7 +525,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
|
||||
|
||||
}
|
||||
WPAD_ScanPads();
|
||||
u8 cnt, buttons = NULL;
|
||||
u8 cnt, buttons = 0;
|
||||
/* Get pressed buttons */
|
||||
for (cnt = 0; cnt < 4; cnt++)
|
||||
buttons |= WPAD_ButtonsHeld(cnt);
|
||||
@ -563,7 +563,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
|
||||
|
||||
}
|
||||
WPAD_ScanPads();
|
||||
u8 cnt, buttons = NULL;
|
||||
u8 cnt, buttons = 0;
|
||||
/* Get pressed buttons */
|
||||
for (cnt = 0; cnt < 4; cnt++)
|
||||
buttons |= WPAD_ButtonsHeld(cnt);
|
||||
|
@ -241,7 +241,7 @@ const u32 Resources::GetFileSize(const char * filename)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
GuiImageData * Resources::GetImageData(const char * filename)
|
||||
|
@ -289,7 +289,7 @@ int get_fs_type(u8 *buff)
|
||||
wbfs_head_t *head = (wbfs_head_t *) buff;
|
||||
if (head->magic == wbfs_htonl( WBFS_MAGIC )) return FS_TYPE_WBFS;
|
||||
// 55AA
|
||||
if (buff[0x1FE] == 0x55 && buff[0x1FF] == 0xAA)
|
||||
if(*((u16 *) (buff + 0x1FE)) == 0x55AA)
|
||||
{
|
||||
// FAT
|
||||
if (memcmp(buff + 0x36, "FAT", 3) == 0) return FS_TYPE_FAT16;
|
||||
|
113
source/utils/wifi_gecko.c
Normal file
113
source/utils/wifi_gecko.c
Normal file
@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <network.h>
|
||||
|
||||
#define DESTINATION_IP "192.168.178.3"
|
||||
#define DESTINATION_PORT 4405
|
||||
|
||||
static int connection = -1;
|
||||
|
||||
void WifiGecko_Close()
|
||||
{
|
||||
if(connection >= 0)
|
||||
net_close(connection);
|
||||
|
||||
connection = -1;
|
||||
}
|
||||
|
||||
int WifiGecko_Connect()
|
||||
{
|
||||
if(!(connection < 0))
|
||||
return connection;
|
||||
|
||||
connection = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||
if (connection < 0)
|
||||
return connection;
|
||||
|
||||
struct sockaddr_in connect_addr;
|
||||
memset(&connect_addr, 0, sizeof(connect_addr));
|
||||
connect_addr.sin_family = AF_INET;
|
||||
connect_addr.sin_port = htons(DESTINATION_PORT);
|
||||
inet_aton(DESTINATION_IP, &connect_addr.sin_addr);
|
||||
|
||||
if(net_connect(connection, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0)
|
||||
{
|
||||
WifiGecko_Close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
int WifiGecko_Send(const char * data, int datasize)
|
||||
{
|
||||
if(!WifiGecko_Connect())
|
||||
return connection;
|
||||
|
||||
int ret = 0, done = 0, blocksize = 1024;
|
||||
|
||||
while (done < datasize)
|
||||
{
|
||||
if(blocksize > datasize-done)
|
||||
blocksize = datasize-done;
|
||||
|
||||
ret = net_send(connection, data+done, blocksize, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
WifiGecko_Close();
|
||||
return ret;
|
||||
}
|
||||
else if(ret == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
done += ret;
|
||||
usleep (1000);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wifi_printf(const char * format, ...)
|
||||
{
|
||||
char * tmp = NULL;
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
if((vasprintf(&tmp, format, va) >= 0) && tmp)
|
||||
{
|
||||
WifiGecko_Send(tmp, strlen(tmp));
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
if(tmp)
|
||||
free(tmp);
|
||||
}
|
42
source/utils/wifi_gecko.h
Normal file
42
source/utils/wifi_gecko.h
Normal file
@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#ifndef WIFI_GECKO_H_
|
||||
#define WIFI_GECKO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int WifiGecko_Connect();
|
||||
void WifiGecko_Close();
|
||||
int WifiGecko_Send(const char * data, int datasize);
|
||||
void wifi_printf(const char * format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user