From f28e502af3f49854a2a5771e19eda6e22dd18aef Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 20 Jun 2018 14:44:30 +0200 Subject: [PATCH] Fix filetypes --- include/fs/CFile.hpp | 28 ++++++++++++++-------------- include/fs/DirList.h | 30 +++++++++++++++--------------- include/fs/FSUtils.h | 8 ++++---- include/fs/disc_io.h | 12 ++++++------ include/language/gettext.h | 4 +++- include/network/net.h | 12 ++++++------ include/system/AsyncDeleter.h | 6 +++--- include/system/CMutex.h | 2 +- include/system/CThread.h | 14 +++++++------- include/utils/StringTools.h | 16 ++++++++-------- include/utils/TCPServer.hpp | 26 +++++++++++++------------- include/utils/elf_utils.h | 6 +++--- src/fs/CFile.cpp | 32 ++++++++++++++++---------------- src/fs/DirList.cpp | 30 +++++++++++++++--------------- src/fs/FSUtils.cpp | 28 ++++++++++++++-------------- src/language/gettext.cpp | 18 +++++++++--------- src/network/net.c | 30 +++++++++++++++--------------- src/utils/StringTools.cpp | 22 +++++++++++----------- src/utils/TCPServer.cpp | 6 +++--- src/utils/elf_utils.cpp | 20 ++++++++++---------- 20 files changed, 176 insertions(+), 174 deletions(-) diff --git a/include/fs/CFile.hpp b/include/fs/CFile.hpp index c078720..8816a49 100644 --- a/include/fs/CFile.hpp +++ b/include/fs/CFile.hpp @@ -19,13 +19,13 @@ public: CFile(); CFile(const std::string & filepath, eOpenTypes mode); - CFile(const u8 * memory, s32 memsize); + CFile(const uint8_t * memory, int32_t memsize); virtual ~CFile(); - s32 open(const std::string & filepath, eOpenTypes mode); - s32 open(const u8 * memory, s32 memsize); + int32_t open(const std::string & filepath, eOpenTypes mode); + int32_t open(const uint8_t * memory, int32_t memsize); - bool isOpen() const { + BOOL isOpen() const { if(iFd >= 0) return true; @@ -37,14 +37,14 @@ public: void close(); - s32 read(u8 * ptr, size_t size); - s32 write(const u8 * ptr, size_t size); - s32 fwrite(const char *format, ...); - s32 seek(long int offset, s32 origin); - u64 tell() { + int32_t read(uint8_t * ptr, size_t size); + int32_t write(const uint8_t * ptr, size_t size); + int32_t fwrite(const char *format, ...); + int32_t seek(long int offset, int32_t origin); + uint64_t tell() { return pos; }; - u64 size() { + uint64_t size() { return filesize; }; void rewind() { @@ -52,10 +52,10 @@ public: }; protected: - s32 iFd; - const u8 * mem_file; - u64 filesize; - u64 pos; + int32_t iFd; + const uint8_t * mem_file; + uint64_t filesize; + uint64_t pos; }; #endif diff --git a/include/fs/DirList.h b/include/fs/DirList.h index e4325ed..64072df 100644 --- a/include/fs/DirList.h +++ b/include/fs/DirList.h @@ -33,7 +33,7 @@ typedef struct { char * FilePath; - bool isDir; + BOOL isDir; } DirEntry; class DirList { @@ -43,39 +43,39 @@ public: //!\param path Path from where to load the filelist of all files //!\param filter A fileext that needs to be filtered //!\param flags search/filter flags from the enum - DirList(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs, u32 maxDepth = 0xffffffff); + DirList(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff); //!Destructor virtual ~DirList(); //! Load all the files from a directory - bool LoadPath(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs, u32 maxDepth = 0xffffffff); + BOOL LoadPath(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff); //! Get a filename of the list //!\param list index - const char * GetFilename(s32 index) const; + const char * GetFilename(int32_t index) const; //! Get the a filepath of the list //!\param list index - const char *GetFilepath(s32 index) const { + const char *GetFilepath(int32_t index) const { if (!valid(index)) return ""; else return FileInfo[index].FilePath; } //! Get the a filesize of the list //!\param list index - u64 GetFilesize(s32 index) const; + uint64_t GetFilesize(int32_t index) const; //! Is index a dir or a file //!\param list index - bool IsDir(s32 index) const { + BOOL IsDir(int32_t index) const { if(!valid(index)) return false; return FileInfo[index].isDir; }; //! Get the filecount of the whole list - s32 GetFilecount() const { + int32_t GetFilecount() const { return FileInfo.size(); }; //! Sort list by filepath void SortList(); //! Custom sort command for custom sort functions definitions - void SortList(bool (*SortFunc)(const DirEntry &a, const DirEntry &b)); + void SortList(BOOL (*SortFunc)(const DirEntry &a, const DirEntry &b)); //! Get the index of the specified filename - s32 GetFileIndex(const char *filename) const; + int32_t GetFileIndex(const char *filename) const; //! Enum for search/filter flags enum { Files = 0x01, @@ -84,18 +84,18 @@ public: }; protected: // Internal parser - bool InternalLoadPath(std::string &path); + BOOL InternalLoadPath(std::string &path); //!Add a list entrie - void AddEntrie(const std::string &filepath, const char * filename, bool isDir); + void AddEntrie(const std::string &filepath, const char * filename, BOOL isDir); //! Clear the list void ClearList(); //! Check if valid pos is requested - inline bool valid(u32 pos) const { + inline BOOL valid(uint32_t pos) const { return (pos < FileInfo.size()); }; - u32 Flags; - u32 Depth; + uint32_t Flags; + uint32_t Depth; const char *Filter; std::vector FileInfo; }; diff --git a/include/fs/FSUtils.h b/include/fs/FSUtils.h index 6d09708..b589a44 100644 --- a/include/fs/FSUtils.h +++ b/include/fs/FSUtils.h @@ -5,12 +5,12 @@ class FSUtils { public: - static s32 LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size); + static int32_t LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size); //! todo: C++ class - static s32 CreateSubfolder(const char * fullpath); - static s32 CheckFile(const char * filepath); - static bool saveBufferToFile(const char * path, void * buffer, u32 size); + static int32_t CreateSubfolder(const char * fullpath); + static int32_t CheckFile(const char * filepath); + static BOOL saveBufferToFile(const char * path, void * buffer, uint32_t size); }; #endif // __FS_UTILS_H_ diff --git a/include/fs/disc_io.h b/include/fs/disc_io.h index be277cb..6636641 100644 --- a/include/fs/disc_io.h +++ b/include/fs/disc_io.h @@ -43,12 +43,12 @@ typedef uint32_t sec_t; -typedef bool (* FN_MEDIUM_STARTUP)(void) ; -typedef bool (* FN_MEDIUM_ISINSERTED)(void) ; -typedef bool (* FN_MEDIUM_READSECTORS)(sec_t sector, sec_t numSectors, void* buffer) ; -typedef bool (* FN_MEDIUM_WRITESECTORS)(sec_t sector, sec_t numSectors, const void* buffer) ; -typedef bool (* FN_MEDIUM_CLEARSTATUS)(void) ; -typedef bool (* FN_MEDIUM_SHUTDOWN)(void) ; +typedef BOOL (* FN_MEDIUM_STARTUP)(void) ; +typedef BOOL (* FN_MEDIUM_ISINSERTED)(void) ; +typedef BOOL (* FN_MEDIUM_READSECTORS)(sec_t sector, sec_t numSectors, void* buffer) ; +typedef BOOL (* FN_MEDIUM_WRITESECTORS)(sec_t sector, sec_t numSectors, const void* buffer) ; +typedef BOOL (* FN_MEDIUM_CLEARSTATUS)(void) ; +typedef BOOL (* FN_MEDIUM_SHUTDOWN)(void) ; struct DISC_INTERFACE_STRUCT { unsigned long ioType ; diff --git a/include/language/gettext.h b/include/language/gettext.h index 9e598a6..4a5bded 100644 --- a/include/language/gettext.h +++ b/include/language/gettext.h @@ -17,6 +17,8 @@ #ifndef _GETTEXT_H_ #define _GETTEXT_H_ +#include + #ifdef __cplusplus extern "C" { @@ -25,7 +27,7 @@ extern "C" #define tr(s) gettext(s) #define trNOOP(s) s -bool gettextLoadLanguage(const char* langFile); +BOOL gettextLoadLanguage(const char* langFile); void gettextCleanUp(void); /* * input msg = a text in ASCII diff --git a/include/network/net.h b/include/network/net.h index e94fbf6..5f577df 100644 --- a/include/network/net.h +++ b/include/network/net.h @@ -7,12 +7,12 @@ extern "C" { #include -s32 recvwait(s32 sock, void *buffer, s32 len); -u8 recvbyte(s32 sock); -u32 recvword(s32 sock); -s32 checkbyte(s32 sock); -s32 sendwait(s32 sock, const void *buffer, s32 len); -s32 sendbyte(s32 sock, unsigned char byte); +int32_t recvwait(int32_t sock, void *buffer, int32_t len); +uint8_t recvbyte(int32_t sock); +uint32_t recvword(int32_t sock); +int32_t checkbyte(int32_t sock); +int32_t sendwait(int32_t sock, const void *buffer, int32_t len); +int32_t sendbyte(int32_t sock, unsigned char byte); #ifdef __cplusplus } diff --git a/include/system/AsyncDeleter.h b/include/system/AsyncDeleter.h index b5b1dc0..fc5dfea 100644 --- a/include/system/AsyncDeleter.h +++ b/include/system/AsyncDeleter.h @@ -43,14 +43,14 @@ public: deleterInstance->deleteElements.push(e); } - static bool deleteListEmpty() { + static BOOL deleteListEmpty() { if(!deleterInstance) { return true; } return deleterInstance->deleteElements.empty(); } - static bool realListEmpty() { + static BOOL realListEmpty() { if(!deleterInstance) { return true; } @@ -67,7 +67,7 @@ private: void executeThread(void); - bool exitApplication; + BOOL exitApplication; std::queue deleteElements; std::queue realDeleteElements; CMutex deleteMutex; diff --git a/include/system/CMutex.h b/include/system/CMutex.h index fecd54c..76f23ac 100644 --- a/include/system/CMutex.h +++ b/include/system/CMutex.h @@ -43,7 +43,7 @@ public: if(pMutex) OSUnlockMutex(pMutex); } - bool tryLock(void) { + BOOL tryLock(void) { if(!pMutex) return false; diff --git a/include/system/CThread.h b/include/system/CThread.h index ebc008d..21a1700 100644 --- a/include/system/CThread.h +++ b/include/system/CThread.h @@ -28,7 +28,7 @@ public: typedef void (* Callback)(CThread *thread, void *arg); //! constructor - CThread(s32 iAttr, s32 iPriority = 16, s32 iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL) + CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL) : pThread(NULL) , pThreadStack(NULL) , pCallback(callback) @@ -38,7 +38,7 @@ public: //! allocate the thread pThread = (OSThread*)memalign(8, sizeof(OSThread)); //! allocate the stack - pThreadStack = (u8 *) memalign(0x20, iStackSize); + pThreadStack = (uint8_t *) memalign(0x20, iStackSize); //! create the thread if(pThread && pThreadStack) OSCreateThread(pThread, &CThread::threadCallback, 1, (char*)this, pThreadStack+iStackSize, iStackSize, iPriority, iAttributes); @@ -49,7 +49,7 @@ public: shutdownThread(); } - static CThread *create(CThread::Callback callback, void *callbackArg, s32 iAttr = eAttributeNone, s32 iPriority = 16, s32 iStackSize = 0x8000) { + static CThread *create(CThread::Callback callback, void *callbackArg, int32_t iAttr = eAttributeNone, int32_t iPriority = 16, int32_t iStackSize = 0x8000) { return ( new CThread(iAttr, iPriority, iStackSize, callback, callbackArg) ); } @@ -77,17 +77,17 @@ public: if(pThread) OSSetThreadPriority(pThread, prio); } //! Check if thread is suspended - virtual bool isThreadSuspended(void) const { + virtual BOOL isThreadSuspended(void) const { if(pThread) return OSIsThreadSuspended(pThread); return false; } //! Check if thread is terminated - virtual bool isThreadTerminated(void) const { + virtual BOOL isThreadTerminated(void) const { if(pThread) return OSIsThreadTerminated(pThread); return false; } //! Check if thread is running - virtual bool isThreadRunning(void) const { + virtual BOOL isThreadRunning(void) const { return !isThreadSuspended() && !isThreadRunning(); } //! Shutdown thread @@ -125,7 +125,7 @@ private: } int iAttributes; OSThread *pThread; - u8 *pThreadStack; + uint8_t *pThreadStack; Callback pCallback; void *pCallbackArg; }; diff --git a/include/utils/StringTools.h b/include/utils/StringTools.h index 972fb8f..c648f4c 100644 --- a/include/utils/StringTools.h +++ b/include/utils/StringTools.h @@ -32,16 +32,16 @@ class StringTools{ public: - static bool EndsWith(const std::string& a, const std::string& b); - static const char * byte_to_binary(s32 x); + static BOOL EndsWith(const std::string& a, const std::string& b); + static const char * byte_to_binary(int32_t x); static std::string removeCharFromString(std::string& input,char toBeRemoved); static const char * fmt(const char * format, ...); static const wchar_t * wfmt(const char * format, ...); - static s32 strprintf(std::string &str, const char * format, ...); + static int32_t strprintf(std::string &str, const char * format, ...); static std::string strfmt(const char * format, ...); - static bool char2wchar_t(const char * src, wchar_t * dest); - static s32 strtokcmp(const char * string, const char * compare, const char * separator); - static s32 strextcmp(const char * string, const char * extension, char seperator); + static BOOL char2wchar_t(const char * src, wchar_t * dest); + static int32_t strtokcmp(const char * string, const char * compare, const char * separator); + static int32_t strextcmp(const char * string, const char * extension, char seperator); static const char * FullpathToFilename(const char *path){ if(!path) return path; @@ -61,10 +61,10 @@ class StringTools{ } static void RemoveDoubleSlashs(std::string &str){ - u32 length = str.size(); + uint32_t length = str.size(); //! clear path of double slashes - for(u32 i = 1; i < length; ++i) + for(uint32_t i = 1; i < length; ++i) { if(str[i-1] == '/' && str[i] == '/') { diff --git a/include/utils/TCPServer.hpp b/include/utils/TCPServer.hpp index d4d35c0..a0fff84 100644 --- a/include/utils/TCPServer.hpp +++ b/include/utils/TCPServer.hpp @@ -1,7 +1,7 @@ #ifndef _TCPSERVER_H_ #define _TCPSERVER_H_ -#include +#include #include #include @@ -12,22 +12,22 @@ class TCPServer { public: - TCPServer(s32 port, s32 priority); + TCPServer(int32_t port, int32_t priority); virtual ~TCPServer(); - bool isConnected() { + BOOL isConnected() { return connected; } protected: - bool shouldExit() { + BOOL shouldExit() { return (exitThread == 1); } - s32 getClientFD() { + int32_t getClientFD() { return clientfd; } - s32 getSocketFD() { + int32_t getSocketFD() { return sockfd; } @@ -41,7 +41,7 @@ private: static void DoTCPThread(CThread *thread, void *arg); virtual void DoTCPThreadInternal(); - virtual bool acceptConnection() = 0; + virtual BOOL acceptConnection() = 0; virtual void onConnectionClosed(){ DEBUG_FUNCTION_LINE("Default onConnectionClosed \n"); @@ -50,16 +50,16 @@ private: /** Called when a connection has be accepted. **/ - virtual bool whileLoop() = 0; + virtual BOOL whileLoop() = 0; struct sockaddr_in sock_addr; - volatile s32 sockfd = -1; - volatile s32 clientfd = -1; + volatile int32_t sockfd = -1; + volatile int32_t clientfd = -1; - s32 port = 0; - volatile bool connected = false; + int32_t port = 0; + volatile BOOL connected = false; - volatile s32 exitThread = 0; + volatile int32_t exitThread = 0; CThread *pThread = NULL; }; diff --git a/include/utils/elf_utils.h b/include/utils/elf_utils.h index 64d4455..bf4188f 100644 --- a/include/utils/elf_utils.h +++ b/include/utils/elf_utils.h @@ -11,11 +11,11 @@ extern "C" { unsigned int elf_get_section(unsigned char *data, const char *name, unsigned int * size, unsigned int * addr, int fail_on_not_found); -bool elf_copy_section(unsigned char * elf_data, const char * section_name, bool errorOnFailure); +BOOL elf_copy_section(unsigned char * elf_data, const char * section_name, BOOL errorOnFailure); -u32 elf_copy_common_sections(unsigned char * elf_data); +uint32_t elf_copy_common_sections(unsigned char * elf_data); -u32 elf_get_entry_addr(unsigned char * elf_data); +uint32_t elf_get_entry_addr(unsigned char * elf_data); #ifdef __cplusplus } diff --git a/src/fs/CFile.cpp b/src/fs/CFile.cpp index ce92d94..c9348aa 100644 --- a/src/fs/CFile.cpp +++ b/src/fs/CFile.cpp @@ -16,7 +16,7 @@ CFile::CFile(const std::string & filepath, eOpenTypes mode) { this->open(filepath, mode); } -CFile::CFile(const u8 * mem, s32 size) { +CFile::CFile(const uint8_t * mem, int32_t size) { iFd = -1; this->open(mem, size); } @@ -25,10 +25,10 @@ CFile::~CFile() { this->close(); } -s32 CFile::open(const std::string & filepath, eOpenTypes mode) { +int32_t CFile::open(const std::string & filepath, eOpenTypes mode) { this->close(); - s32 openMode = 0; + int32_t openMode = 0; switch(mode) { default: @@ -61,7 +61,7 @@ s32 CFile::open(const std::string & filepath, eOpenTypes mode) { return 0; } -s32 CFile::open(const u8 * mem, s32 size) { +int32_t CFile::open(const uint8_t * mem, int32_t size) { this->close(); mem_file = mem; @@ -80,17 +80,17 @@ void CFile::close() { pos = 0; } -s32 CFile::read(u8 * ptr, size_t size) { +int32_t CFile::read(uint8_t * ptr, size_t size) { if(iFd >= 0) { - s32 ret = ::read(iFd, ptr,size); + int32_t ret = ::read(iFd, ptr,size); if(ret > 0) pos += ret; return ret; } - s32 readsize = size; + int32_t readsize = size; - if(readsize > (s64) (filesize-pos)) + if(readsize > (int64_t) (filesize-pos)) readsize = filesize-pos; if(readsize <= 0) @@ -105,11 +105,11 @@ s32 CFile::read(u8 * ptr, size_t size) { return -1; } -s32 CFile::write(const u8 * ptr, size_t size) { +int32_t CFile::write(const uint8_t * ptr, size_t size) { if(iFd >= 0) { size_t done = 0; while(done < size) { - s32 ret = ::write(iFd, ptr, size - done); + int32_t ret = ::write(iFd, ptr, size - done); if(ret <= 0) return ret; @@ -123,9 +123,9 @@ s32 CFile::write(const u8 * ptr, size_t size) { return -1; } -s32 CFile::seek(long int offset, s32 origin) { - s32 ret = 0; - s64 newPos = pos; +int32_t CFile::seek(long int offset, int32_t origin) { + int32_t ret = 0; + int64_t newPos = pos; if(origin == SEEK_SET) { newPos = offset; @@ -153,15 +153,15 @@ s32 CFile::seek(long int offset, s32 origin) { return ret; } -s32 CFile::fwrite(const char *format, ...) { +int32_t CFile::fwrite(const char *format, ...) { char tmp[512]; tmp[0] = 0; - s32 result = -1; + int32_t result = -1; va_list va; va_start(va, format); if((vsprintf(tmp, format, va) >= 0)) { - result = this->write((u8 *)tmp, strlen(tmp)); + result = this->write((uint8_t *)tmp, strlen(tmp)); } va_end(va); diff --git a/src/fs/DirList.cpp b/src/fs/DirList.cpp index 51e6702..6b98c49 100644 --- a/src/fs/DirList.cpp +++ b/src/fs/DirList.cpp @@ -42,7 +42,7 @@ DirList::DirList() { Depth = 0; } -DirList::DirList(const std::string & path, const char *filter, u32 flags, u32 maxDepth) { +DirList::DirList(const std::string & path, const char *filter, uint32_t flags, uint32_t maxDepth) { this->LoadPath(path, filter, flags, maxDepth); this->SortList(); } @@ -51,7 +51,7 @@ DirList::~DirList() { ClearList(); } -bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags, u32 maxDepth) { +BOOL DirList::LoadPath(const std::string & folder, const char *filter, uint32_t flags, uint32_t maxDepth) { if(folder.empty()) return false; Flags = flags; @@ -59,7 +59,7 @@ bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags Depth = maxDepth; std::string folderpath(folder); - u32 length = folderpath.size(); + uint32_t length = folderpath.size(); //! clear path of double slashes StringTools::RemoveDoubleSlashs(folderpath); @@ -76,7 +76,7 @@ bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags return InternalLoadPath(folderpath); } -bool DirList::InternalLoadPath(std::string &folderpath) { +BOOL DirList::InternalLoadPath(std::string &folderpath) { if(folderpath.size() < 3) return false; @@ -88,7 +88,7 @@ bool DirList::InternalLoadPath(std::string &folderpath) { return false; while ((dirent = readdir(dir)) != 0) { - bool isDir = dirent->d_type & DT_DIR; + BOOL isDir = dirent->d_type & DT_DIR; const char *filename = dirent->d_name; if(isDir) { @@ -96,7 +96,7 @@ bool DirList::InternalLoadPath(std::string &folderpath) { continue; if((Flags & CheckSubfolders) && (Depth > 0)) { - s32 length = folderpath.size(); + int32_t length = folderpath.size(); if(length > 2 && folderpath[length-1] != '/') { folderpath += '/'; } @@ -130,11 +130,11 @@ bool DirList::InternalLoadPath(std::string &folderpath) { return true; } -void DirList::AddEntrie(const std::string &filepath, const char * filename, bool isDir) { +void DirList::AddEntrie(const std::string &filepath, const char * filename, BOOL isDir) { if(!filename) return; - s32 pos = FileInfo.size(); + int32_t pos = FileInfo.size(); FileInfo.resize(pos+1); @@ -149,7 +149,7 @@ void DirList::AddEntrie(const std::string &filepath, const char * filename, bool } void DirList::ClearList() { - for(u32 i = 0; i < FileInfo.size(); ++i) { + for(uint32_t i = 0; i < FileInfo.size(); ++i) { if(FileInfo[i].FilePath) { free(FileInfo[i].FilePath); FileInfo[i].FilePath = NULL; @@ -160,14 +160,14 @@ void DirList::ClearList() { std::vector().swap(FileInfo); } -const char * DirList::GetFilename(s32 ind) const { +const char * DirList::GetFilename(int32_t ind) const { if (!valid(ind)) return ""; return StringTools::FullpathToFilename(FileInfo[ind].FilePath); } -static bool SortCallback(const DirEntry & f1, const DirEntry & f2) { +static BOOL SortCallback(const DirEntry & f1, const DirEntry & f2) { if(f1.isDir && !(f2.isDir)) return true; if(!(f1.isDir) && f2.isDir) return false; @@ -185,12 +185,12 @@ void DirList::SortList() { std::sort(FileInfo.begin(), FileInfo.end(), SortCallback); } -void DirList::SortList(bool (*SortFunc)(const DirEntry &a, const DirEntry &b)) { +void DirList::SortList(BOOL (*SortFunc)(const DirEntry &a, const DirEntry &b)) { if(FileInfo.size() > 1) std::sort(FileInfo.begin(), FileInfo.end(), SortFunc); } -u64 DirList::GetFilesize(s32 index) const { +uint64_t DirList::GetFilesize(int32_t index) const { struct stat st; const char *path = GetFilepath(index); @@ -200,11 +200,11 @@ u64 DirList::GetFilesize(s32 index) const { return st.st_size; } -s32 DirList::GetFileIndex(const char *filename) const { +int32_t DirList::GetFileIndex(const char *filename) const { if(!filename) return -1; - for (u32 i = 0; i < FileInfo.size(); ++i) { + for (uint32_t i = 0; i < FileInfo.size(); ++i) { if (strcasecmp(GetFilename(i), filename) == 0) return i; } diff --git a/src/fs/FSUtils.cpp b/src/fs/FSUtils.cpp index 0cb69ef..ba59544 100644 --- a/src/fs/FSUtils.cpp +++ b/src/fs/FSUtils.cpp @@ -7,28 +7,28 @@ #include #include -s32 FSUtils::LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size) { +int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) { //! always initialze input *inbuffer = NULL; if(size) *size = 0; - s32 iFd = open(filepath, O_RDONLY); + int32_t iFd = open(filepath, O_RDONLY); if (iFd < 0) return -1; - u32 filesize = lseek(iFd, 0, SEEK_END); + uint32_t filesize = lseek(iFd, 0, SEEK_END); lseek(iFd, 0, SEEK_SET); - u8 *buffer = (u8 *) malloc(filesize); + uint8_t *buffer = (uint8_t *) malloc(filesize); if (buffer == NULL) { close(iFd); return -2; } - u32 blocksize = 0x4000; - u32 done = 0; - s32 readBytes = 0; + uint32_t blocksize = 0x4000; + uint32_t done = 0; + int32_t readBytes = 0; while(done < filesize) { if(done + blocksize > filesize) { @@ -58,7 +58,7 @@ s32 FSUtils::LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size) { return filesize; } -s32 FSUtils::CheckFile(const char * filepath) { +int32_t FSUtils::CheckFile(const char * filepath) { if(!filepath) return 0; @@ -81,16 +81,16 @@ s32 FSUtils::CheckFile(const char * filepath) { return 0; } -s32 FSUtils::CreateSubfolder(const char * fullpath) { +int32_t FSUtils::CreateSubfolder(const char * fullpath) { if(!fullpath) return 0; - s32 result = 0; + int32_t result = 0; char dirnoslash[strlen(fullpath)+1]; strcpy(dirnoslash, fullpath); - s32 pos = strlen(dirnoslash)-1; + int32_t pos = strlen(dirnoslash)-1; while(dirnoslash[pos] == '/') { dirnoslash[pos] = '\0'; pos--; @@ -129,15 +129,15 @@ s32 FSUtils::CreateSubfolder(const char * fullpath) { return 1; } -bool FSUtils::saveBufferToFile(const char * path, void * buffer, u32 size) { - s32 res = open(path, O_CREAT | O_TRUNC | O_WRONLY); +BOOL FSUtils::saveBufferToFile(const char * path, void * buffer, uint32_t size) { + int32_t res = open(path, O_CREAT | O_TRUNC | O_WRONLY); close(res); CFile file(path, CFile::WriteOnly); if (!file.isOpen()) { DEBUG_FUNCTION_LINE("Failed to open %s\n",path); return false; } - file.write((const u8*) buffer,size); + file.write((const uint8_t*) buffer,size); file.close(); return true; } diff --git a/src/language/gettext.cpp b/src/language/gettext.cpp index e744d31..a321600 100644 --- a/src/language/gettext.cpp +++ b/src/language/gettext.cpp @@ -39,7 +39,7 @@ char* strdup (const char* s) } typedef struct _MSG { - u32 id; + uint32_t id; char* msgstr; struct _MSG *next; } MSG; @@ -50,16 +50,16 @@ static MSG *baseMSG = 0; /* Defines the so called `hashpjw' function by P.J. Weinberger [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, 1986, 1987 Bell Telephone Laboratories, Inc.] */ -static inline u32 hash_string(const char *str_param) { - u32 hval, g; +static inline uint32_t hash_string(const char *str_param) { + uint32_t hval, g; const char *str = str_param; /* Compute the hash value for the given string. */ hval = 0; while (*str != '\0') { hval <<= 4; - hval += (u8) *str++; - g = hval & ((u32) 0xf << (HASHWORDBITS - 4)); + hval += (uint8_t) *str++; + g = hval & ((uint32_t) 0xf << (HASHWORDBITS - 4)); if (g != 0) { hval ^= g >> (HASHWORDBITS - 8); hval ^= g; @@ -158,7 +158,7 @@ terminate: return retval; } -static MSG *findMSG(u32 id) { +static MSG *findMSG(uint32_t id) { MSG *msg; for (msg = baseMSG; msg; msg = msg->next) { if (msg->id == id) return msg; @@ -167,7 +167,7 @@ static MSG *findMSG(u32 id) { } static MSG *setMSG(const char *msgid, const char *msgstr) { - u32 id = hash_string(msgid); + uint32_t id = hash_string(msgid); MSG *msg = findMSG(id); if (!msg) { msg = (MSG *) malloc(sizeof(MSG)); @@ -196,7 +196,7 @@ extern "C" void gettextCleanUp(void) { } } -extern "C" bool gettextLoadLanguage(const char* langFile) { +extern "C" BOOL gettextLoadLanguage(const char* langFile) { char *lastID = NULL; gettextCleanUp(); @@ -206,7 +206,7 @@ extern "C" bool gettextLoadLanguage(const char* langFile) { std::string strBuffer; strBuffer.resize(file.size()); - file.read((u8 *) &strBuffer[0], strBuffer.size()); + file.read((uint8_t *) &strBuffer[0], strBuffer.size()); file.close(); //! remove all windows crap signs diff --git a/src/network/net.c b/src/network/net.c index 9ce8bc1..80232c3 100644 --- a/src/network/net.c +++ b/src/network/net.c @@ -4,18 +4,18 @@ #include #include -static u32 hostIpAddress __attribute__((section(".data"))) = 0; +static uint32_t hostIpAddress __attribute__((section(".data"))) = 0; static volatile int socket_lock __attribute__((section(".data"))) = 0; -void initNetwork(){ - +void initNetwork(){ + } -s32 recvwait(s32 sock, void *buffer, s32 len) { +int32_t recvwait(int32_t sock, void *buffer, int32_t len) { while(socket_lock) { OSSleepTicks(OSMicrosecondsToTicks(1000)); } - s32 ret; + int32_t ret; while (len > 0) { ret = recv(sock, buffer, len, 0); if(ret < 0) { @@ -29,30 +29,30 @@ s32 recvwait(s32 sock, void *buffer, s32 len) { return 0; } -u8 recvbyte(s32 sock) { +uint8_t recvbyte(int32_t sock) { unsigned char buffer[1]; - s32 ret; + int32_t ret; ret = recvwait(sock, buffer, 1); if (ret < 0) return ret; return buffer[0]; } -u32 recvword(s32 sock) { - u32 result; - s32 ret; +uint32_t recvword(int32_t sock) { + uint32_t result; + int32_t ret; ret = recvwait(sock, &result, 4); if (ret < 0) return ret; return result; } -s32 checkbyte(s32 sock) { +int32_t checkbyte(int32_t sock) { while(socket_lock) { OSSleepTicks(OSMicrosecondsToTicks(1000)); } unsigned char buffer[1]; - s32 ret; + int32_t ret; ret = recv(sock, buffer, 1, MSG_DONTWAIT); socket_lock = 0; @@ -61,11 +61,11 @@ s32 checkbyte(s32 sock) { return buffer[0]; } -s32 sendwait(s32 sock, const void *buffer, s32 len) { +int32_t sendwait(int32_t sock, const void *buffer, int32_t len) { while(socket_lock) { OSSleepTicks(OSMicrosecondsToTicks(1000)); } - s32 ret; + int32_t ret; while (len > 0) { // For some reason the send blocks/crashes if the buffer is too big.. int cur_length = len <= 0x30 ? len : 0x30; @@ -81,7 +81,7 @@ s32 sendwait(s32 sock, const void *buffer, s32 len) { return 0; } -s32 sendbyte(s32 sock, unsigned char byte) { +int32_t sendbyte(int32_t sock, unsigned char byte) { unsigned char buffer[1]; buffer[0] = byte; return sendwait(sock, buffer, 1); diff --git a/src/utils/StringTools.cpp b/src/utils/StringTools.cpp index fbd9ad2..c1d672a 100644 --- a/src/utils/StringTools.cpp +++ b/src/utils/StringTools.cpp @@ -36,16 +36,16 @@ #include -bool StringTools::EndsWith(const std::string& a, const std::string& b) { +BOOL StringTools::EndsWith(const std::string& a, const std::string& b) { if (b.size() > a.size()) return false; return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin()); } -const char * StringTools::byte_to_binary(s32 x) { +const char * StringTools::byte_to_binary(int32_t x) { static char b[9]; b[0] = '\0'; - s32 z; + int32_t z; for (z = 128; z > 0; z >>= 1) { strcat(b, ((x & z) == z) ? "1" : "0"); } @@ -71,7 +71,7 @@ const char * StringTools::fmt(const char * format, ...) { va_list va; va_start(va, format); - if((vsprintf(strChar, format, va) >= 0)) { + if((vsprintf(strChar, format, va) >= 0)) { va_end(va); return (const char *) strChar; } @@ -96,7 +96,7 @@ const wchar_t * StringTools::wfmt(const char * format, ...) { va_start(va, format); if((vsprintf(tmp, format, va) >= 0)) { int bt; - s32 strlength = strlen(tmp); + int32_t strlength = strlen(tmp); bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512 ); if(bt > 0) { @@ -109,10 +109,10 @@ const wchar_t * StringTools::wfmt(const char * format, ...) { return NULL; } -s32 StringTools::strprintf(std::string &str, const char * format, ...) { +int32_t StringTools::strprintf(std::string &str, const char * format, ...) { static char tmp[512]; tmp[0] = 0; - s32 result = 0; + int32_t result = 0; va_list va; va_start(va, format); @@ -140,7 +140,7 @@ std::string StringTools::strfmt(const char * format, ...) { return str; } -bool StringTools::char2wchar_t(const char * strChar, wchar_t * dest) { +BOOL StringTools::char2wchar_t(const char * strChar, wchar_t * dest) { if(!strChar || !dest) return false; @@ -154,7 +154,7 @@ bool StringTools::char2wchar_t(const char * strChar, wchar_t * dest) { return false; } -s32 StringTools::strtokcmp(const char * string, const char * compare, const char * separator) { +int32_t StringTools::strtokcmp(const char * string, const char * compare, const char * separator) { if(!string || !compare) return -1; @@ -174,7 +174,7 @@ s32 StringTools::strtokcmp(const char * string, const char * compare, const char return -1; } -s32 StringTools::strextcmp(const char * string, const char * extension, char seperator) { +int32_t StringTools::strextcmp(const char * string, const char * extension, char seperator) { if(!string || !extension) return -1; @@ -190,7 +190,7 @@ std::vector StringTools::stringSplit(const std::string & inValue, c std::string value = inValue; std::vector result; while (true) { - u32 index = value.find(splitter); + uint32_t index = value.find(splitter); if (index == std::string::npos) { result.push_back(value); break; diff --git a/src/utils/TCPServer.cpp b/src/utils/TCPServer.cpp index bf4d965..301a00a 100644 --- a/src/utils/TCPServer.cpp +++ b/src/utils/TCPServer.cpp @@ -8,7 +8,7 @@ #define wiiu_errno (*__gh_errno_ptr()) -TCPServer::TCPServer(s32 port,s32 priority) { +TCPServer::TCPServer(int32_t port,int32_t priority) { this->port = port; this->sockfd = -1; this->clientfd = -1; @@ -51,7 +51,7 @@ void TCPServer::ErrorHandling() { } void TCPServer::DoTCPThreadInternal() { - s32 ret; + int32_t ret; socklen_t len; connected = false; while (1) { @@ -68,7 +68,7 @@ void TCPServer::DoTCPThreadInternal() { ErrorHandling(); continue; } - s32 enable = 1; + int32_t enable = 1; setsockopt(this->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); diff --git a/src/utils/elf_utils.cpp b/src/utils/elf_utils.cpp index f451073..53bad20 100644 --- a/src/utils/elf_utils.cpp +++ b/src/utils/elf_utils.cpp @@ -5,7 +5,7 @@ #include -u32 elf_get_section(u8 *data, const char *name, u32 * size, u32 * addr, int fail_on_not_found) { +uint32_t elf_get_section(uint8_t *data, const char *name, uint32_t * size, uint32_t * addr, int fail_on_not_found) { Elf32_Ehdr *ehdr = (Elf32_Ehdr *) data; if ( !data @@ -37,12 +37,12 @@ u32 elf_get_section(u8 *data, const char *name, u32 * size, u32 * addr, int fail return 0; } -bool elf_copy_section(u8 * elf_data, const char * section_name) { - u32 section_addr = 0; - u32 section_len = 0; - u32 section_offset = elf_get_section(elf_data, section_name, §ion_len, §ion_addr, false); +BOOL elf_copy_section(uint8_t * elf_data, const char * section_name) { + uint32_t section_addr = 0; + uint32_t section_len = 0; + uint32_t section_offset = elf_get_section(elf_data, section_name, §ion_len, §ion_addr, false); if(section_offset > 0) { - u8 *main_section = elf_data + section_offset; + uint8_t *main_section = elf_data + section_offset; memcpy((void*) section_addr,(void*) main_section, section_len); DCFlushRange((void*)section_addr, section_len); @@ -52,7 +52,7 @@ bool elf_copy_section(u8 * elf_data, const char * section_name) { return false; } -u32 elf_copy_common_sections(u8 * elf_data) { +uint32_t elf_copy_common_sections(uint8_t * elf_data) { Elf32_Ehdr *ehdr = (Elf32_Ehdr *) elf_data; if ( !elf_data || !IS_ELF (*ehdr) @@ -61,7 +61,7 @@ u32 elf_copy_common_sections(u8 * elf_data) { return 0; } - bool error = false; + BOOL error = false; if(!elf_copy_section(elf_data, ".text")) { return 0; @@ -74,7 +74,7 @@ u32 elf_copy_common_sections(u8 * elf_data) { return elf_get_entry_addr(elf_data); } -u32 elf_get_entry_addr(u8 * elf_data) { +uint32_t elf_get_entry_addr(uint8_t * elf_data) { Elf32_Ehdr *ehdr = (Elf32_Ehdr *) elf_data; if ( !elf_data || !IS_ELF (*ehdr) @@ -82,6 +82,6 @@ u32 elf_get_entry_addr(u8 * elf_data) { || (ehdr->e_machine != EM_PPC)) { return 0; } - u8 * source_addr = (u8 *) elf_data; + uint8_t * source_addr = (uint8_t *) elf_data; return ehdr->e_entry; }