*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:
dimok321 2010-10-24 19:08:03 +00:00
parent 87755f2543
commit 71d537c1a7
14 changed files with 234 additions and 49 deletions

File diff suppressed because one or more lines are too long

View File

@ -185,7 +185,7 @@ char *DirList::GetFilepath(int ind)
unsigned int DirList::GetFilesize(int ind) unsigned int DirList::GetFilesize(int ind)
{ {
if (ind >= filecount || !filecount || !FileInfo) if (ind >= filecount || !filecount || !FileInfo)
return NULL; return 0;
else else
return FileInfo[ind].FileSize; return FileInfo[ind].FileSize;
} }

View File

@ -888,7 +888,7 @@ extern "C" void GetFolderSize(const char * folderpath, u64 * foldersize, u32 * f
} }
else else
{ {
if(filecount) *filecount++; if(filecount) *filecount += 1;
if(foldersize) *foldersize += st.st_size; if(foldersize) *foldersize += st.st_size;
} }
} }

View File

@ -76,7 +76,7 @@ bool ZipFile::ExtractAll(const char *dest)
while (!Stop) 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; = true;
if (!Stop && filename[strlen(filename) - 1] != '/') if (!Stop && filename[strlen(filename) - 1] != '/')

View File

@ -181,7 +181,7 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size)
if (*((u32*) soundChunk) == 0x4C5A3737 /*"LZ77"*/) if (*((u32*) soundChunk) == 0x4C5A3737 /*"LZ77"*/)
{ {
u32 uncSize = NULL; u32 uncSize = 0;
u8 * uncompressed_data = uncompressLZ77(soundChunk, soundChunkSize, uncSize); u8 * uncompressed_data = uncompressLZ77(soundChunk, soundChunkSize, uncSize);
if (!uncompressed_data) if (!uncompressed_data)
{ {

View File

@ -1,4 +1,5 @@
#include <string.h> #include <string.h>
#include <unistd.h>
#include <ogc/lwp_watchdog.h> #include <ogc/lwp_watchdog.h>
#include <ogc/mutex.h> #include <ogc/mutex.h>
#include <ogc/system.h> #include <ogc/system.h>
@ -50,25 +51,37 @@ int USBDevice_Init()
USBDevice_deInit(); USBDevice_deInit();
//right now mounts first FAT-partition //right now mounts first FAT-partition
if (!fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS)) //usbstorage.startup is actually not needed since it's done in libfat
return -1; //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)) if (fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS))
return -1; {
fat_usb_mount = 1;
fat_usb_sec = _FAT_startSector; fat_usb_sec = _FAT_startSector;
return (fat_usb_mount = 1);
}
return 1; __io_usbstorage.startup();
usleep(200000);
if(fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS))
{
fat_usb_sec = _FAT_startSector;
return (fat_usb_mount = 1);
}
__io_usbstorage.shutdown();
return -1;
} }
void USBDevice_deInit() void USBDevice_deInit()
{ {
//closing all open Files write back the cache and then shutdown em! //closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/"); fatUnmount("USB:/");
//only shutdown libogc usb and not the cios one
__io_usbstorage.shutdown(); __io_usbstorage.shutdown();
__io_usbstorage2.shutdown();
fat_usb_mount = 0; fat_usb_mount = 0;
fat_usb_sec = 0; fat_usb_sec = 0;

View File

@ -111,7 +111,7 @@ char * HomebrewFiles::GetFilepath(int ind)
unsigned int HomebrewFiles::GetFilesize(int ind) unsigned int HomebrewFiles::GetFilesize(int ind)
{ {
if (ind > filecount || !filecount || !FileInfo) if (ind > filecount || !filecount || !FileInfo)
return NULL; return 0;
else return FileInfo[ind].FileSize; else return FileInfo[ind].FileSize;
} }

View File

@ -2,9 +2,11 @@
* HomebrewXML Class * HomebrewXML Class
* for USB Loader GX * for USB Loader GX
***************************************************************************/ ***************************************************************************/
#include <gctypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "FileOperations/fileops.h"
#include "xml/xml.h" #include "xml/xml.h"
#include "HomebrewXML.h" #include "HomebrewXML.h"
@ -24,40 +26,54 @@ HomebrewXML::~HomebrewXML()
/* qparam filename Filepath of the XML file */ /* qparam filename Filepath of the XML file */
int HomebrewXML::LoadHomebrewXMLData(const char* filename) int HomebrewXML::LoadHomebrewXMLData(const char* filename)
{ {
mxml_node_t *nodedataHB = NULL; Name.clear();
mxml_node_t *nodetreeHB = NULL; Coder.clear();
Version.clear();
ShortDescription.clear();
LongDescription.clear();
Releasedate.clear();
/* Load XML file */ /* Load XML file */
FILE *filexml; u8 * xmlbuffer = NULL;
filexml = fopen(filename, "rb"); u64 size = 0;
if (!filexml) return -1; LoadFileToMem(filename, &xmlbuffer, &size);
nodetreeHB = mxmlLoadFile(NULL, filexml, MXML_OPAQUE_CALLBACK); if(!xmlbuffer)
fclose(filexml); 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 (!nodetree)
if (nodedataHB == NULL) return -5; 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]; 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; 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; 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; 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; 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; 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 int len = (strlen(Entrie) - 6); //length of the date string without the 200000 at the end
if (len == 8) if (len == 8)
@ -69,16 +85,17 @@ int HomebrewXML::LoadHomebrewXMLData(const char* filename)
Releasedate = Entrie; Releasedate = Entrie;
free(nodedataHB);
free(nodetreeHB);
delete[] Entrie; delete[] Entrie;
mxmlDelete(node);
mxmlDelete(nodetree);
free(xmlbuffer);
return 1; return 1;
} }
/* Get name */ /* Get name */
const char * HomebrewXML::GetName() const char * HomebrewXML::GetName() const
{ {
return Name.c_str(); return Name.c_str();
} }
@ -90,31 +107,31 @@ void HomebrewXML::SetName(char * newName)
} }
/* Get coder */ /* Get coder */
const char * HomebrewXML::GetCoder() const char * HomebrewXML::GetCoder() const
{ {
return Coder.c_str(); return Coder.c_str();
} }
/* Get version */ /* Get version */
const char * HomebrewXML::GetVersion() const char * HomebrewXML::GetVersion() const
{ {
return Version.c_str(); return Version.c_str();
} }
/* Get releasedate */ /* Get releasedate */
const char * HomebrewXML::GetReleasedate() const char * HomebrewXML::GetReleasedate() const
{ {
return Releasedate.c_str(); return Releasedate.c_str();
} }
/* Get shortdescription */ /* Get shortdescription */
const char * HomebrewXML::GetShortDescription() const char * HomebrewXML::GetShortDescription() const
{ {
return ShortDescription.c_str(); return ShortDescription.c_str();
} }
/* Get longdescription */ /* Get longdescription */
const char * HomebrewXML::GetLongDescription() const char * HomebrewXML::GetLongDescription() const
{ {
return LongDescription.c_str(); return LongDescription.c_str();
} }

View File

@ -15,13 +15,13 @@ class HomebrewXML
int LoadHomebrewXMLData(const char* filename); int LoadHomebrewXMLData(const char* filename);
const char * GetName(); const char * GetName() const;
void SetName(char * newName); void SetName(char * newName);
const char * GetCoder(); const char * GetCoder() const;
const char * GetVersion(); const char * GetVersion() const;
const char * GetReleasedate(); const char * GetReleasedate() const;
const char * GetShortDescription(); const char * GetShortDescription() const;
const char * GetLongDescription(); const char * GetLongDescription() const;
protected: protected:
std::string Name; std::string Name;

View File

@ -525,7 +525,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
} }
WPAD_ScanPads(); WPAD_ScanPads();
u8 cnt, buttons = NULL; u8 cnt, buttons = 0;
/* Get pressed buttons */ /* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++) for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt); buttons |= WPAD_ButtonsHeld(cnt);
@ -563,7 +563,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
} }
WPAD_ScanPads(); WPAD_ScanPads();
u8 cnt, buttons = NULL; u8 cnt, buttons = 0;
/* Get pressed buttons */ /* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++) for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt); buttons |= WPAD_ButtonsHeld(cnt);

View File

@ -241,7 +241,7 @@ const u32 Resources::GetFileSize(const char * filename)
} }
} }
return NULL; return 0;
} }
GuiImageData * Resources::GetImageData(const char * filename) GuiImageData * Resources::GetImageData(const char * filename)

View File

@ -289,7 +289,7 @@ int get_fs_type(u8 *buff)
wbfs_head_t *head = (wbfs_head_t *) buff; wbfs_head_t *head = (wbfs_head_t *) buff;
if (head->magic == wbfs_htonl( WBFS_MAGIC )) return FS_TYPE_WBFS; if (head->magic == wbfs_htonl( WBFS_MAGIC )) return FS_TYPE_WBFS;
// 55AA // 55AA
if (buff[0x1FE] == 0x55 && buff[0x1FF] == 0xAA) if(*((u16 *) (buff + 0x1FE)) == 0x55AA)
{ {
// FAT // FAT
if (memcmp(buff + 0x36, "FAT", 3) == 0) return FS_TYPE_FAT16; if (memcmp(buff + 0x36, "FAT", 3) == 0) return FS_TYPE_FAT16;

113
source/utils/wifi_gecko.c Normal file
View 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
View 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