From 41271d632b74f5cf47c30d3b699eb6b2786f2136 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 23 Jun 2018 13:02:07 +1000 Subject: Added new type definitions - moving towards V3.0 --- src/gfile/gfile.c | 66 ++-- src/gfile/gfile.h | 718 ++++++++++++++++++++-------------------- src/gfile/gfile_fatfs_wrapper.c | 4 +- src/gfile/gfile_fs.h | 22 +- src/gfile/gfile_fs_chibios.c | 10 +- src/gfile/gfile_fs_fatfs.c | 88 ++--- src/gfile/gfile_fs_mem.c | 6 +- src/gfile/gfile_fs_native.c | 42 +-- src/gfile/gfile_fs_petitfs.c | 32 +- src/gfile/gfile_fs_rom.c | 24 +- src/gfile/gfile_printg.c | 10 +- src/gfile/gfile_scang.c | 10 +- 12 files changed, 512 insertions(+), 520 deletions(-) (limited to 'src/gfile') diff --git a/src/gfile/gfile.c b/src/gfile/gfile.c index 4bc39189..a0ef6071 100644 --- a/src/gfile/gfile.c +++ b/src/gfile/gfile.c @@ -135,7 +135,7 @@ GFILE *_gfileFindSlot(const char *mode) { * IO routines ********************************************************/ -bool_t gfileExists(const char *fname) { +gBool gfileExists(const char *fname) { const GFILEVMT * const *p; #if GFILE_ALLOW_DEVICESPECIFIC @@ -144,18 +144,18 @@ bool_t gfileExists(const char *fname) { if (p[0]->prefix == fname[0]) return p[0]->exists && p[0]->exists(fname+2); } - return FALSE; + return gFalse; } #endif for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { if (p[0]->exists && p[0]->exists(fname)) - return TRUE; + return gTrue; } - return FALSE; + return gFalse; } -bool_t gfileDelete(const char *fname) { +gBool gfileDelete(const char *fname) { const GFILEVMT **p; #if GFILE_ALLOW_DEVICESPECIFIC @@ -164,15 +164,15 @@ bool_t gfileDelete(const char *fname) { if (p[0]->prefix == fname[0]) return p[0]->del && p[0]->del(fname+2); } - return FALSE; + return gFalse; } #endif for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { if (p[0]->del && p[0]->del(fname)) - return TRUE; + return gTrue; } - return FALSE; + return gFalse; } long int gfileGetFilesize(const char *fname) { @@ -196,7 +196,7 @@ long int gfileGetFilesize(const char *fname) { return -1; } -bool_t gfileRename(const char *oldname, const char *newname) { +gBool gfileRename(const char *oldname, const char *newname) { const GFILEVMT * const *p; #if GFILE_ALLOW_DEVICESPECIFIC @@ -209,7 +209,7 @@ bool_t gfileRename(const char *oldname, const char *newname) { if (newname[0] && newname[1] == '|') { if (newname[0] != ch) // Both oldname and newname are fs specific but different ones. - return FALSE; + return gFalse; newname += 2; } } else { @@ -220,25 +220,25 @@ bool_t gfileRename(const char *oldname, const char *newname) { if (p[0]->prefix == ch) return p[0]->ren && p[0]->ren(oldname, newname); } - return FALSE; + return gFalse; } #endif for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { if (p[0]->ren && p[0]->ren(oldname,newname)) - return TRUE; + return gTrue; } - return FALSE; + return gFalse; } -static bool_t testopen(const GFILEVMT *p, GFILE *f, const char *fname) { +static gBool testopen(const GFILEVMT *p, GFILE *f, const char *fname) { // If we want write but the fs doesn't allow it then return if ((f->flags & GFILEFLG_WRITE) && !(p->flags & GFSFLG_WRITEABLE)) - return FALSE; + return gFalse; // Try to open if (!p->open || !p->open(f, fname)) - return FALSE; + return gFalse; // File is open - fill in all the details f->vmt = p; @@ -246,7 +246,7 @@ static bool_t testopen(const GFILEVMT *p, GFILE *f, const char *fname) { f->flags |= GFILEFLG_OPEN; if (p->flags & GFSFLG_SEEKABLE) f->flags |= GFILEFLG_CANSEEK; - return TRUE; + return gTrue; } GFILE *gfileOpen(const char *fname, const char *mode) { @@ -318,13 +318,13 @@ long int gfileGetPos(GFILE *f) { return f->pos; } -bool_t gfileSetPos(GFILE *f, long int pos) { +gBool gfileSetPos(GFILE *f, long int pos) { if (!f || !(f->flags & GFILEFLG_OPEN)) - return FALSE; + return gFalse; if (!f->vmt->setpos || !f->vmt->setpos(f, pos)) - return FALSE; + return gFalse; f->pos = pos; - return TRUE; + return gTrue; } long int gfileGetSize(GFILE *f) { @@ -335,50 +335,50 @@ long int gfileGetSize(GFILE *f) { return f->vmt->getsize(f); } -bool_t gfileEOF(GFILE *f) { +gBool gfileEOF(GFILE *f) { if (!f || !(f->flags & GFILEFLG_OPEN)) - return TRUE; + return gTrue; if (!f->vmt->eof) - return FALSE; + return gFalse; return f->vmt->eof(f); } -bool_t gfileMount(char fs, const char* drive) { +gBool gfileMount(char fs, const char* drive) { const GFILEVMT * const *p; // Find the correct VMT for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { if (p[0]->prefix == fs) { if (!p[0]->mount) - return FALSE; + return gFalse; return p[0]->mount(drive); } } - return FALSE; + return gFalse; } -bool_t gfileUnmount(char fs, const char* drive) { +gBool gfileUnmount(char fs, const char* drive) { const GFILEVMT * const *p; // Find the correct VMT for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { if (p[0]->prefix == fs) { if (!p[0]->mount) - return FALSE; + return gFalse; return p[0]->unmount(drive); } } - return FALSE; + return gFalse; } -bool_t gfileSync(GFILE *f) { +gBool gfileSync(GFILE *f) { if (!f->vmt->sync) - return FALSE; + return gFalse; return f->vmt->sync(f); } #if GFILE_NEED_FILELISTS - gfileList *gfileOpenFileList(char fs, const char *path, bool_t dirs) { + gfileList *gfileOpenFileList(char fs, const char *path, gBool dirs) { const GFILEVMT * const *p; gfileList * pfl; diff --git a/src/gfile/gfile.h b/src/gfile/gfile.h index 0ae2a035..65088c03 100644 --- a/src/gfile/gfile.h +++ b/src/gfile/gfile.h @@ -42,429 +42,421 @@ extern GFILE *gfileStdOut; /* External declarations. */ /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif +/** + * @brief Check if file exists + * + * @param[in] fname The file name + * + * @return gTrue if file exists, gFalse otherwise + * + * @api + */ +gBool gfileExists(const char *fname); - /** - * @brief Check if file exists - * - * @param[in] fname The file name - * - * @return TRUE if file exists, FALSE otherwise - * - * @api - */ - bool_t gfileExists(const char *fname); +/** + * @brief Delete file + * + * @param[in] fname The file name + * + * @return gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileDelete(const char *fname); - /** - * @brief Delete file - * - * @param[in] fname The file name - * - * @return TRUE on success, FALSE otherwise - * - * @api - */ - bool_t gfileDelete(const char *fname); +/** + * @brief Get the size of a file + * @note Please use @p gfileGetSize() if the file is opened + * + * @param[in] fname The file name + * + * @return File size on success, -1 on error + * + * @api + */ +long int gfileGetFilesize(const char *fname); - /** - * @brief Get the size of a file - * @note Please use @p gfileGetSize() if the file is opened - * - * @param[in] fname The file name - * - * @return File size on success, -1 on error - * - * @api - */ - long int gfileGetFilesize(const char *fname); +/** + * @brief Rename file + * + * @param[in] oldname The current file name + * @param[in] newname The new name of the file + * + * @return gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileRename(const char *oldname, const char *newname); - /** - * @brief Rename file - * - * @param[in] oldname The current file name - * @param[in] newname The new name of the file - * - * @return TRUE on success, FALSE otherwise - * - * @api - */ - bool_t gfileRename(const char *oldname, const char *newname); +/** + * @brief Open file + * @details A file must be opened before it can be accessed + * @details The resulting GFILE will be used for all functions that access the file. + * + * @param[in] fname The file name + * @param[in] mode The mode. + * + * @return Valid GFILE on success, 0 otherwise + * + * @note The modes follow the c library fopen() standard. + * The valid modes are: + * + * The following flags can also be added to the above modes:
+ * + * @note Not all file-systems support all modes. For example, write + * is not available with the ROM file-system. Similarly few platforms + * distinguish between binary and text files. + * @note Even though binary vs. text is relevant only for a small number of platforms + * the "b" flag should always be specified for binary files such as images. + * This ensures portability to other platforms. The extra flag will be ignored + * on platforms where it is not relevant. + * + * @api + */ +GFILE * gfileOpen(const char *fname, const char *mode); - /** - * @brief Open file - * @details A file must be opened before it can be accessed - * @details The resulting GFILE will be used for all functions that access the file. - * - * @param[in] fname The file name - * @param[in] mode The mode. - * - * @return Valid GFILE on success, 0 otherwise - * - * @note The modes follow the c library fopen() standard. - * The valid modes are: - * - * The following flags can also be added to the above modes:
- * - * @note Not all file-systems support all modes. For example, write - * is not available with the ROM file-system. Similarly few platforms - * distinguish between binary and text files. - * @note Even though binary vs. text is relevant only for a small number of platforms - * the "b" flag should always be specified for binary files such as images. - * This ensures portability to other platforms. The extra flag will be ignored - * on platforms where it is not relevant. - * - * @api - */ - GFILE * gfileOpen(const char *fname, const char *mode); +/** + * @brief Close file + * @details Closes a file after is has been opened using @p gfileOpen() + * + * @param[in] f The file + * + * @api + */ +void gfileClose(GFILE *f); - /** - * @brief Close file - * @details Closes a file after is has been opened using @p gfileOpen() - * - * @param[in] f The file - * - * @api - */ - void gfileClose(GFILE *f); +/** + * @brief Read from file + * @details Reads a given amount of bytes from the file + * @details The read/write cursor will not be reset when calling this function + * + * @param[in] f The file + * @param[out] buf The buffer in which to save the content that has been read from the file + * @param[in] len Amount of bytes to read + * + * @return Amount of bytes read + * + * @api + */ +size_t gfileRead(GFILE *f, void *buf, size_t len); - /** - * @brief Read from file - * @details Reads a given amount of bytes from the file - * @details The read/write cursor will not be reset when calling this function - * - * @param[in] f The file - * @param[out] buf The buffer in which to save the content that has been read from the file - * @param[in] len Amount of bytes to read - * - * @return Amount of bytes read - * - * @api - */ - size_t gfileRead(GFILE *f, void *buf, size_t len); +/** + * @brief Write to file + * @details Write a given amount of bytes to the file + * @details The read/write cursor will not be reset when calling this function + * + * @param[in] f The file + * @param[in] buf The buffer which contains the content that will be written to the file + * @param[in] len Amount of bytes to write + * + * @return Amount of bytes written + * + * @api + */ +size_t gfileWrite(GFILE *f, const void *buf, size_t len); - /** - * @brief Write to file - * @details Write a given amount of bytes to the file - * @details The read/write cursor will not be reset when calling this function - * - * @param[in] f The file - * @param[in] buf The buffer which contains the content that will be written to the file - * @param[in] len Amount of bytes to write - * - * @return Amount of bytes written - * - * @api - */ - size_t gfileWrite(GFILE *f, const void *buf, size_t len); +/** + * @brief Get the current position of the read/write cursor + * + * @param[in] f The file + * + * @return The current position in the file + * + * @api + */ +long int gfileGetPos(GFILE *f); - /** - * @brief Get the current position of the read/write cursor - * - * @param[in] f The file - * - * @return The current position in the file - * - * @api - */ - long int gfileGetPos(GFILE *f); +/** + * @brief Set the position of the read/write cursor + * + * @param[in] f The file + * @param[in] pos The position to which the cursor will be set + * + * @return gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileSetPos(GFILE *f, long int pos); + +/** + * @brief Get the size of file + * @note Please use @p gfileGetFilesize() if the file is not opened + * + * @param[in] f The file + * + * @return The size of the file + * + * @api + */ +long int gfileGetSize(GFILE *f); + +/** + * @brief Check for EOF + * @details Checks if the cursor is at the end of the file + * + * @param[in] f The file + * + * @return gTrue if EOF, gFalse otherwise + * + * @api + */ +gBool gfileEOF(GFILE *f); +/** + * @brief Mount a logical drive (aka partition) + * + * @details Not supported by every file system + * @details Currently just one drive at one is supported. + * + * @param[in] fs The file system (F for FatFS) + * @param[in] drive The logical drive prefix + * + * @return gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileMount(char fs, const char *drive); + +/** + * @brief Unmount a logical drive (aka partition) + * + * @details Does have no effect if @p gfileMount() as been called before hand + * + * @param[in] fs The file system (F for FatFS) + * @param[in] drive The logical drive prefix + * + * @return gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileUnmount(char fs, const char *drive); + +/** + * @brief Syncs the file object (flushes the buffer) + * + * @details Not supported by every file system + * + * @param[in] f The file + * + * @return gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileSync(GFILE *f); + +#if GFILE_NEED_FILELISTS || defined(__DOXYGEN__) /** - * @brief Set the position of the read/write cursor + * @brief Open a file list * - * @param[in] f The file - * @param[in] pos The position to which the cursor will be set + * @param[in] fs The file system (F for FatFS) + * @param[in] path Path information to pass to the file system + * @param[in] dirs Pass gTrue to get directories only, gFalse to get files only * - * @return TRUE on success, FALSE otherwise + * @return A pointer to a file list on success, NULL otherwise + * + * @note The path parameter is handled in a file-system specific way. It could be + * treated as a directory name, it may be treated as a file pattern, or it + * may be ignored. Passing NULL will always return the full list of files + * in at least the top level directory. + * @note For file systems that do not support directories, passing gTrue for dirs + * will return an error. + * @note You must call @p gfileCloseFileList() when you have finished with the + * file list in order to free resources. * * @api */ - bool_t gfileSetPos(GFILE *f, long int pos); + gfileList *gfileOpenFileList(char fs, const char *path, gBool dirs); /** - * @brief Get the size of file - * @note Please use @p gfileGetFilesize() if the file is not opened + * @brief Get the next file in a file list. + * + * @param[in] pfl Pointer to a file list returned by @p gfileOpenFileList() * - * @param[in] f The file + * @return A pointer to a file (or directory) name. Returns NULL if there are no more. * - * @return The size of the file + * @note The file name may contain the full directory path or may not depending + * on how the file system treats directories. + * @note The returned buffer may be destroyed by the next call to any of + * @p gfileOpenFileList(), @p gfileReadFileList() or @p gfileCloseFileList(). + * Do not use this pointer after one of those calls. * * @api */ - long int gfileGetSize(GFILE *f); + const char *gfileReadFileList(gfileList *pfl); /** - * @brief Check for EOF - * @details Checks if the cursor is at the end of the file + * @brief Close a file list. * - * @param[in] f The file - * - * @return TRUE if EOF, FALSE otherwise + * @param[in] pfl Pointer to a file list returned by @p gfileOpenFileList() * * @api */ - bool_t gfileEOF(GFILE *f); + void gfileCloseFileList(gfileList *pfl); +#endif +#if (GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS) || defined(__DOXYGEN__) /** - * @brief Mount a logical drive (aka partition) + * @brief Open file from a ChibiOS FileStream * - * @details Not supported by every file system - * @details Currently just one drive at one is supported. + * @param[in] FileStreamPtr The BaseFileStream (ChibiOS V2) or FileStream (ChibiOS V3) to open as a GFILE + * @param[in] mode The mode. * - * @param[in] fs The file system (F for FatFS) - * @param[in] drive The logical drive prefix + * @return Valid GFILE on success, 0 otherwise * - * @return TRUE on success, FALSE otherwise + * @note The modes are the same modes as in @p gfileOpen(). The + * open mode is NOT compared against the FileStream capabilities. + * @note Supported operations are: read, write, getpos, setpos, eof and getsize * * @api */ - bool_t gfileMount(char fs, const char *drive); + GFILE * gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode); + #define gfileOpenBaseFileStream(f,m) gfileOpenChibiOSFileStream(f,m) +#endif +#if GFILE_NEED_MEMFS || defined(__DOXYGEN__) /** - * @brief Unmount a logical drive (aka partition) + * @brief Open file from a memory pointer * - * @details Does have no effect if @p gfileMount() as been called before hand + * @param[in] memptr The pointer to the memory + * @param[in] mode The mode. * - * @param[in] fs The file system (F for FatFS) - * @param[in] drive The logical drive prefix + * @return Valid GFILE on success, 0 otherwise * - * @return TRUE on success, FALSE otherwise + * @note The modes are the same modes as in @p gfileOpen(). Note there is + * no concept of file-size. Be careful not to overwrite other memory or + * to read from inaccessible sections of memory. + * @note Supported operations are: read, write, getpos, setpos * * @api */ - bool_t gfileUnmount(char fs, const char *drive); + GFILE * gfileOpenMemory(void *memptr, const char *mode); +#endif +#if GFILE_NEED_STRINGS || defined(__DOXYGEN__) /** - * @brief Syncs the file object (flushes the buffer) + * @brief Open file from a null terminated C string * - * @details Not supported by every file system + * @param[in] str The pointer to the string or string buffer + * @param[in] mode The mode * - * @param[in] f The file + * @return Valid GFILE on success, 0 otherwise * - * @return TRUE on success, FALSE otherwise + * @note The modes are the same modes as in @p gfileOpen(). Note there is + * no concept of file-size. Be careful not to overwrite other memory or + * to read from inaccessible sections of memory. + * @note Reading will return EOF when the NULL character is reached. + * @note Writing will always place a NULL in the next character effectively terminating the + * string at the character just written. + * @note Supported operations are: read, write, append, getpos, setpos + * @note Be careful with setpos and getpos. They do not check for the end of the string. + * @note Reading and Writing will read/write a maximum of one character at a time. * * @api */ - bool_t gfileSync(GFILE *f); - - #if GFILE_NEED_FILELISTS || defined(__DOXYGEN__) - /** - * @brief Open a file list - * - * @param[in] fs The file system (F for FatFS) - * @param[in] path Path information to pass to the file system - * @param[in] dirs Pass TRUE to get directories only, FALSE to get files only - * - * @return A pointer to a file list on success, NULL otherwise - * - * @note The path parameter is handled in a file-system specific way. It could be - * treated as a directory name, it may be treated as a file pattern, or it - * may be ignored. Passing NULL will always return the full list of files - * in at least the top level directory. - * @note For file systems that do not support directories, passing TRUE for dirs - * will return an error. - * @note You must call @p gfileCloseFileList() when you have finished with the - * file list in order to free resources. - * - * @api - */ - gfileList *gfileOpenFileList(char fs, const char *path, bool_t dirs); - - /** - * @brief Get the next file in a file list. - * - * @param[in] pfl Pointer to a file list returned by @p gfileOpenFileList() - * - * @return A pointer to a file (or directory) name. Returns NULL if there are no more. - * - * @note The file name may contain the full directory path or may not depending - * on how the file system treats directories. - * @note The returned buffer may be destroyed by the next call to any of - * @p gfileOpenFileList(), @p gfileReadFileList() or @p gfileCloseFileList(). - * Do not use this pointer after one of those calls. - * - * @api - */ - const char *gfileReadFileList(gfileList *pfl); - - /** - * @brief Close a file list. - * - * @param[in] pfl Pointer to a file list returned by @p gfileOpenFileList() - * - * @api - */ - void gfileCloseFileList(gfileList *pfl); - #endif - - #if (GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS) || defined(__DOXYGEN__) - /** - * @brief Open file from a ChibiOS FileStream - * - * @param[in] FileStreamPtr The BaseFileStream (ChibiOS V2) or FileStream (ChibiOS V3) to open as a GFILE - * @param[in] mode The mode. - * - * @return Valid GFILE on success, 0 otherwise - * - * @note The modes are the same modes as in @p gfileOpen(). The - * open mode is NOT compared against the FileStream capabilities. - * @note Supported operations are: read, write, getpos, setpos, eof and getsize - * - * @api - */ - GFILE * gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode); - #define gfileOpenBaseFileStream(f,m) gfileOpenChibiOSFileStream(f,m) - #endif - - #if GFILE_NEED_MEMFS || defined(__DOXYGEN__) - /** - * @brief Open file from a memory pointer - * - * @param[in] memptr The pointer to the memory - * @param[in] mode The mode. - * - * @return Valid GFILE on success, 0 otherwise - * - * @note The modes are the same modes as in @p gfileOpen(). Note there is - * no concept of file-size. Be careful not to overwrite other memory or - * to read from inaccessible sections of memory. - * @note Supported operations are: read, write, getpos, setpos - * - * @api - */ - GFILE * gfileOpenMemory(void *memptr, const char *mode); - #endif - - #if GFILE_NEED_STRINGS || defined(__DOXYGEN__) - /** - * @brief Open file from a null terminated C string - * - * @param[in] str The pointer to the string or string buffer - * @param[in] mode The mode - * - * @return Valid GFILE on success, 0 otherwise - * - * @note The modes are the same modes as in @p gfileOpen(). Note there is - * no concept of file-size. Be careful not to overwrite other memory or - * to read from inaccessible sections of memory. - * @note Reading will return EOF when the NULL character is reached. - * @note Writing will always place a NULL in the next character effectively terminating the - * string at the character just written. - * @note Supported operations are: read, write, append, getpos, setpos - * @note Be careful with setpos and getpos. They do not check for the end of the string. - * @note Reading and Writing will read/write a maximum of one character at a time. - * - * @api - */ - GFILE * gfileOpenString(char *str, const char *mode); - #endif + GFILE * gfileOpenString(char *str, const char *mode); +#endif - #if GFILE_NEED_PRINTG || defined(__DOXYGEN__) - #include - - int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg); - int fnprintg(GFILE *f, int maxlen, const char *fmt, ...); - #define vfprintg(f,m,a) vfnprintg(f,0,m,a) - #define fprintg(f,m,...) fnprintg(f,0,m,__VA_ARGS__) - #define vprintg(m,a) vfnprintg(gfileStdOut,0,m,a) - #define printg(m,...) fnprintg(gfileStdOut,0,m,__VA_ARGS__) - - #if GFILE_NEED_STRINGS - int vsnprintg(char *buf, int maxlen, const char *fmt, va_list arg); - int snprintg(char *buf, int maxlen, const char *fmt, ...); - #define vsprintg(s,m,a) vsnprintg(s,0,m,a) - #define sprintg(s,m,...) snprintg(s,0,m,__VA_ARGS__) - #endif +#if GFILE_NEED_PRINTG || defined(__DOXYGEN__) + #include + + int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg); + int fnprintg(GFILE *f, int maxlen, const char *fmt, ...); + #define vfprintg(f,m,a) vfnprintg(f,0,m,a) + #define fprintg(f,m,...) fnprintg(f,0,m,__VA_ARGS__) + #define vprintg(m,a) vfnprintg(gfileStdOut,0,m,a) + #define printg(m,...) fnprintg(gfileStdOut,0,m,__VA_ARGS__) + + #if GFILE_NEED_STRINGS + int vsnprintg(char *buf, int maxlen, const char *fmt, va_list arg); + int snprintg(char *buf, int maxlen, const char *fmt, ...); + #define vsprintg(s,m,a) vsnprintg(s,0,m,a) + #define sprintg(s,m,...) snprintg(s,0,m,__VA_ARGS__) #endif +#endif - #if GFILE_NEED_SCANG || defined(__DOXYGEN__) - #include - - int vfscang(GFILE *f, const char *fmt, va_list arg); - int fscang(GFILE *f, const char *fmt, ...); - #define vscang(f,a) vfscang(gfileStdIn,f,a) - #define scang(f,...) fscang(gfileStdIn,f,__VA_ARGS__) +#if GFILE_NEED_SCANG || defined(__DOXYGEN__) + #include - #if GFILE_NEED_STRINGS - int vsscang(const char *buf, const char *fmt, va_list arg); - int sscang(const char *buf, const char *fmt, ...); - #endif - #endif + int vfscang(GFILE *f, const char *fmt, va_list arg); + int fscang(GFILE *f, const char *fmt, ...); + #define vscang(f,a) vfscang(gfileStdIn,f,a) + #define scang(f,...) fscang(gfileStdIn,f,__VA_ARGS__) - #if GFILE_NEED_STDIO && !defined(GFILE_NEED_STDIO_MUST_BE_OFF) - // Needed routines and definitions - size_t gstdioRead(void * ptr, size_t size, size_t count, GFILE *f); - size_t gstdioWrite(const void * ptr, size_t size, size_t count, GFILE *f); - int gstdioGetpos(GFILE *f, long int *pos); - int gstdioSeek(GFILE *f, size_t offset, int origin); - #define SEEK_SET 0 - #define SEEK_CUR 1 - #define SEEK_END 2 - - // Stdio emulation - #define stdin gfileStdIn - #define stdout gfileStdOut - #define stderr gfileStdErr - #define FOPEN_MAX GFILE_MAX_GFILES - #define TMP_MAX GFILE_MAX_GFILES - #define FILENAME_MAX 256 // Use a relatively small number for an embedded platform - #define L_tmpnam FILENAME_MAX - #define P_tmpdir "/tmp/" - #define FILE GFILE - #define fopen(n,m) gfileOpen(n,m) - #define fclose(f) gfileClose(f) - #define fread(p,sz,cnt,f) gstdioRead(p,sz,cnt,f) - #define fwrite(p,sz,cnt,f) gstdioWrite(p,sz,cnt,f) - #define fseek(f,ofs,org) gstdioSeek(f,ofs,org) - #define remove(n) (!gfileDelete(n)) - #define rename(o,n) (!gfileRename(o,n)) - #define fflush(f) (0) - #define ftell(f) gfileGetPos(f) - #define fpos_t long int - #define fgetpos(f,pos) gstdioGetpos(f,pos) - #define fsetpos(f, pos) (!gfileSetPos(f, *pos)) - #define rewind(f) gfileSetPos(f, 0); - #define feof(f) gfileEOF(f) - #define vfprintf(f,m,a) vfnprintg(f,0,m,a) - #define fprintf(f,m,...) fnprintg(f,0,m,__VA_ARGS__) - #define vprintf(m,a) vfnprintg(gfileStdOut,0,m,a) - #define printf(m,...) fnprintg(gfileStdOut,0,m,__VA_ARGS__) - #define vsnprintf(s,n,m,a) vsnprintg(s,n,m,a) - #define snprintf(s,n,m,...) snprintg(s,n,m,__VA_ARGS__) - #define vsprintf(s,m,a) vsnprintg(s,0,m,a) - #define sprintf(s,m,...) snprintg(s,0,m,__VA_ARGS__) - - //TODO - //void clearerr ( FILE * stream ); - //int ferror ( FILE * stream ); - //FILE * tmpfile ( void ); // Auto-deleting - //char * tmpnam ( char * str ); - //char * mktemp (char *template); - //FILE * freopen ( const char * filename, const char * mode, FILE * stream ); - //setbuf - //setvbuf - //fflush - //fgetc - //fgets - //fputc - //fputs - //getc - //getchar - //puts - //ungetc - //void perror (const char * str); + #if GFILE_NEED_STRINGS + int vsscang(const char *buf, const char *fmt, va_list arg); + int sscang(const char *buf, const char *fmt, ...); #endif +#endif -#ifdef __cplusplus -} +#if GFILE_NEED_STDIO && !defined(GFILE_NEED_STDIO_MUST_BE_OFF) + // Needed routines and definitions + size_t gstdioRead(void * ptr, size_t size, size_t count, GFILE *f); + size_t gstdioWrite(const void * ptr, size_t size, size_t count, GFILE *f); + int gstdioGetpos(GFILE *f, long int *pos); + int gstdioSeek(GFILE *f, size_t offset, int origin); + #define SEEK_SET 0 + #define SEEK_CUR 1 + #define SEEK_END 2 + + // Stdio emulation + #define stdin gfileStdIn + #define stdout gfileStdOut + #define stderr gfileStdErr + #define FOPEN_MAX GFILE_MAX_GFILES + #define TMP_MAX GFILE_MAX_GFILES + #define FILENAME_MAX 256 // Use a relatively small number for an embedded platform + #define L_tmpnam FILENAME_MAX + #define P_tmpdir "/tmp/" + #define FILE GFILE + #define fopen(n,m) gfileOpen(n,m) + #define fclose(f) gfileClose(f) + #define fread(p,sz,cnt,f) gstdioRead(p,sz,cnt,f) + #define fwrite(p,sz,cnt,f) gstdioWrite(p,sz,cnt,f) + #define fseek(f,ofs,org) gstdioSeek(f,ofs,org) + #define remove(n) (!gfileDelete(n)) + #define rename(o,n) (!gfileRename(o,n)) + #define fflush(f) (0) + #define ftell(f) gfileGetPos(f) + #define fpos_t long int + #define fgetpos(f,pos) gstdioGetpos(f,pos) + #define fsetpos(f, pos) (!gfileSetPos(f, *pos)) + #define rewind(f) gfileSetPos(f, 0); + #define feof(f) gfileEOF(f) + #define vfprintf(f,m,a) vfnprintg(f,0,m,a) + #define fprintf(f,m,...) fnprintg(f,0,m,__VA_ARGS__) + #define vprintf(m,a) vfnprintg(gfileStdOut,0,m,a) + #define printf(m,...) fnprintg(gfileStdOut,0,m,__VA_ARGS__) + #define vsnprintf(s,n,m,a) vsnprintg(s,n,m,a) + #define snprintf(s,n,m,...) snprintg(s,n,m,__VA_ARGS__) + #define vsprintf(s,m,a) vsnprintg(s,0,m,a) + #define sprintf(s,m,...) snprintg(s,0,m,__VA_ARGS__) + + //TODO + //void clearerr ( FILE * stream ); + //int ferror ( FILE * stream ); + //FILE * tmpfile ( void ); // Auto-deleting + //char * tmpnam ( char * str ); + //char * mktemp (char *template); + //FILE * freopen ( const char * filename, const char * mode, FILE * stream ); + //setbuf + //setvbuf + //fflush + //fgetc + //fgets + //fputc + //fputs + //getc + //getchar + //puts + //ungetc + //void perror (const char * str); #endif #endif /* GFX_USE_GFILE */ diff --git a/src/gfile/gfile_fatfs_wrapper.c b/src/gfile/gfile_fatfs_wrapper.c index 0156c42b..7f3a3e39 100644 --- a/src/gfile/gfile_fatfs_wrapper.c +++ b/src/gfile/gfile_fatfs_wrapper.c @@ -49,8 +49,8 @@ int ff_req_grant(_SYNC_t sobj) { if (gfxSemWait( (gfxSem*)&sobj, (delaytime_t)_FS_TIMEOUT) ) - return TRUE; - return FALSE; + return gTrue; + return gFalse; } /*------------------------------------------------------------------------*/ diff --git a/src/gfile/gfile_fs.h b/src/gfile/gfile_fs.h index c2337283..5b1f4fdc 100644 --- a/src/gfile/gfile_fs.h +++ b/src/gfile/gfile_fs.h @@ -34,7 +34,7 @@ struct GFILE { struct gfileList { const struct GFILEVMT * vmt; - bool_t dirs; + gBool dirs; }; typedef struct GFILEVMT { @@ -46,22 +46,22 @@ typedef struct GFILEVMT { #define GFSFLG_SMALL 0x0020 #define GFSFLG_TEXTMODES 0x0040 char prefix; - bool_t (*del) (const char *fname); - bool_t (*exists) (const char *fname); + gBool (*del) (const char *fname); + gBool (*exists) (const char *fname); long int (*filesize) (const char *fname); - bool_t (*ren) (const char *oldname, const char *newname); - bool_t (*open) (GFILE *f, const char *fname); + gBool (*ren) (const char *oldname, const char *newname); + gBool (*open) (GFILE *f, const char *fname); void (*close) (GFILE *f); int (*read) (GFILE *f, void *buf, int size); int (*write) (GFILE *f, const void *buf, int size); - bool_t (*setpos) (GFILE *f, long int pos); + gBool (*setpos) (GFILE *f, long int pos); long int (*getsize) (GFILE *f); - bool_t (*eof) (GFILE *f); - bool_t (*mount) (const char *drive); - bool_t (*unmount) (const char *drive); - bool_t (*sync) (GFILE *f); + gBool (*eof) (GFILE *f); + gBool (*mount) (const char *drive); + gBool (*unmount) (const char *drive); + gBool (*sync) (GFILE *f); #if GFILE_NEED_FILELISTS - gfileList * (*flopen) (const char *path, bool_t dirs); + gfileList * (*flopen) (const char *path, gBool dirs); const char *(*flread) (gfileList *pfl); void (*flclose) (gfileList *pfl); #endif diff --git a/src/gfile/gfile_fs_chibios.c b/src/gfile/gfile_fs_chibios.c index 78681a90..35b4061c 100644 --- a/src/gfile/gfile_fs_chibios.c +++ b/src/gfile/gfile_fs_chibios.c @@ -18,9 +18,9 @@ static void ChibiOSBFSClose(GFILE *f); static int ChibiOSBFSRead(GFILE *f, void *buf, int size); static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size); -static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos); +static gBool ChibiOSBFSSetpos(GFILE *f, long int pos); static long int ChibiOSBFSGetsize(GFILE *f); -static bool_t ChibiOSBFSEof(GFILE *f); +static gBool ChibiOSBFSEof(GFILE *f); static const GFILEVMT FsCHIBIOSVMT = { GFSFLG_SEEKABLE|GFSFLG_WRITEABLE, // flags @@ -52,12 +52,12 @@ static int ChibiOSBFSRead(GFILE *f, void *buf, int size) { static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size) { return fileStreamWrite(((FileStream *)f->obj), (uint8_t *)buf, size); } -static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos) { +static gBool ChibiOSBFSSetpos(GFILE *f, long int pos) { fileStreamSeek(((FileStream *)f->obj), pos); - return TRUE; + return gTrue; } static long int ChibiOSBFSGetsize(GFILE *f) { return fileStreamGetSize(((FileStream *)f->obj)); } -static bool_t ChibiOSBFSEof(GFILE *f) { return f->pos >= fileStreamGetSize(((FileStream *)f->obj)); } +static gBool ChibiOSBFSEof(GFILE *f) { return f->pos >= fileStreamGetSize(((FileStream *)f->obj)); } GFILE * gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode) { GFILE * f; diff --git a/src/gfile/gfile_fs_fatfs.c b/src/gfile/gfile_fs_fatfs.c index 7f67cd76..03c8d2e9 100644 --- a/src/gfile/gfile_fs_fatfs.c +++ b/src/gfile/gfile_fs_fatfs.c @@ -20,22 +20,22 @@ * The FAT file-system VMT ********************************************************/ -static bool_t fatfsDel(const char* fname); -static bool_t fatfsExists(const char* fname); +static gBool fatfsDel(const char* fname); +static gBool fatfsExists(const char* fname); static long int fatfsFileSize(const char* fname); -static bool_t fatfsRename(const char* oldname, const char* newname); -static bool_t fatfsOpen(GFILE* f, const char* fname); +static gBool fatfsRename(const char* oldname, const char* newname); +static gBool fatfsOpen(GFILE* f, const char* fname); static void fatfsClose(GFILE* f); static int fatfsRead(GFILE* f, void* buf, int size); static int fatfsWrite(GFILE* f, const void* buf, int size); -static bool_t fatfsSetPos(GFILE* f, long int pos); +static gBool fatfsSetPos(GFILE* f, long int pos); static long int fatfsGetSize(GFILE* f); -static bool_t fatfsEOF(GFILE* f); -static bool_t fatfsMount(const char* drive); -static bool_t fatfsUnmount(const char* drive); -static bool_t fatfsSync(GFILE* f); +static gBool fatfsEOF(GFILE* f); +static gBool fatfsMount(const char* drive); +static gBool fatfsUnmount(const char* drive); +static gBool fatfsSync(GFILE* f); #if GFILE_NEED_FILELISTS && _FS_MINIMIZE <= 1 - static gfileList *fatfsFlOpen(const char *path, bool_t dirs); + static gfileList *fatfsFlOpen(const char *path, gBool dirs); static const char *fatfsFlRead(gfileList *pfl); static void fatfsFlClose(gfileList *pfl); #endif @@ -75,7 +75,7 @@ typedef struct fatfsList { } fatfsList; // optimize these later on. Use an array to have multiple FatFS -static bool_t fatfs_mounted = FALSE; +static gBool fatfs_mounted = gFalse; static FATFS fatfs_fs; static BYTE fatfs_flags2mode(GFILE* f) @@ -95,27 +95,27 @@ static BYTE fatfs_flags2mode(GFILE* f) return mode; } -static bool_t fatfsDel(const char* fname) +static gBool fatfsDel(const char* fname) { FRESULT ferr; ferr = f_unlink( (const TCHAR*)fname ); if (ferr != FR_OK) - return FALSE; + return gFalse; - return TRUE; + return gTrue; } -static bool_t fatfsExists(const char* fname) +static gBool fatfsExists(const char* fname) { FRESULT ferr; FILINFO fno; ferr = f_stat( (const TCHAR*)fname, &fno); if (ferr != FR_OK) - return FALSE; + return gFalse; - return TRUE; + return gTrue; } static long int fatfsFileSize(const char* fname) @@ -130,34 +130,34 @@ static long int fatfsFileSize(const char* fname) return (long int)fno.fsize; } -static bool_t fatfsRename(const char* oldname, const char* newname) +static gBool fatfsRename(const char* oldname, const char* newname) { FRESULT ferr; ferr = f_rename( (const TCHAR*)oldname, (const TCHAR*)newname ); if (ferr != FR_OK) - return FALSE; + return gFalse; - return TRUE; + return gTrue; } -static bool_t fatfsOpen(GFILE* f, const char* fname) +static gBool fatfsOpen(GFILE* f, const char* fname) { FIL* fd; #if !GFILE_NEED_NOAUTOMOUNT if (!fatfs_mounted && !fatfsMount("")) - return FALSE; + return gFalse; #endif if (!(fd = gfxAlloc(sizeof(FIL)))) - return FALSE; + return gFalse; if (f_open(fd, fname, fatfs_flags2mode(f)) != FR_OK) { gfxFree(fd); f->obj = 0; - return FALSE; + return gFalse; } f->obj = (void*)fd; @@ -169,7 +169,7 @@ static bool_t fatfsOpen(GFILE* f, const char* fname) } #endif - return TRUE; + return gTrue; } static void fatfsClose(GFILE* f) @@ -201,15 +201,15 @@ static int fatfsWrite(GFILE* f, const void* buf, int size) return wr; } -static bool_t fatfsSetPos(GFILE* f, long int pos) +static gBool fatfsSetPos(GFILE* f, long int pos) { FRESULT ferr; ferr = f_lseek( (FIL*)f->obj, (DWORD)pos ); if (ferr != FR_OK) - return FALSE; + return gFalse; - return TRUE; + return gTrue; } static long int fatfsGetSize(GFILE* f) @@ -217,56 +217,56 @@ static long int fatfsGetSize(GFILE* f) return (long int)f_size( (FIL*)f->obj ); } -static bool_t fatfsEOF(GFILE* f) +static gBool fatfsEOF(GFILE* f) { if ( f_eof( (FIL*)f->obj ) != 0) - return TRUE; + return gTrue; else - return FALSE; + return gFalse; } -static bool_t fatfsMount(const char* drive) +static gBool fatfsMount(const char* drive) { FRESULT ferr; if (!fatfs_mounted) { ferr = f_mount(&fatfs_fs, drive, 1); if (ferr != FR_OK) - return FALSE; - fatfs_mounted = TRUE; - return TRUE; + return gFalse; + fatfs_mounted = gTrue; + return gTrue; } - return FALSE; + return gFalse; } -static bool_t fatfsUnmount(const char* drive) +static gBool fatfsUnmount(const char* drive) { (void)drive; if (fatfs_mounted) { // FatFS does not provide an unmount routine. - fatfs_mounted = FALSE; - return TRUE; + fatfs_mounted = gFalse; + return gTrue; } - return FALSE; + return gFalse; } -static bool_t fatfsSync(GFILE *f) +static gBool fatfsSync(GFILE *f) { FRESULT ferr; ferr = f_sync( (FIL*)f->obj ); if (ferr != FR_OK) { - return FALSE; + return gFalse; } - return TRUE; + return gTrue; } #if GFILE_NEED_FILELISTS && _FS_MINIMIZE <= 1 - static gfileList *fatfsFlOpen(const char *path, bool_t dirs) { + static gfileList *fatfsFlOpen(const char *path, gBool dirs) { fatfsList *p; (void) dirs; diff --git a/src/gfile/gfile_fs_mem.c b/src/gfile/gfile_fs_mem.c index 4aad43fe..1f6fd050 100644 --- a/src/gfile/gfile_fs_mem.c +++ b/src/gfile/gfile_fs_mem.c @@ -19,7 +19,7 @@ static int MEMRead(GFILE *f, void *buf, int size); static int MEMWrite(GFILE *f, const void *buf, int size); -static bool_t MEMSetpos(GFILE *f, long int pos); +static gBool MEMSetpos(GFILE *f, long int pos); static const GFILEVMT FsMemVMT = { GFSFLG_SEEKABLE|GFSFLG_WRITEABLE, // flags @@ -41,10 +41,10 @@ static int MEMWrite(GFILE *f, const void *buf, int size) { memcpy(((char *)f->obj)+f->pos, buf, size); return size; } -static bool_t MEMSetpos(GFILE *f, long int pos) { +static gBool MEMSetpos(GFILE *f, long int pos) { (void) f; (void) pos; - return TRUE; + return gTrue; } GFILE * gfileOpenMemory(void *memptr, const char *mode) { diff --git a/src/gfile/gfile_fs_native.c b/src/gfile/gfile_fs_native.c index d1e2a1fc..a9bc5065 100644 --- a/src/gfile/gfile_fs_native.c +++ b/src/gfile/gfile_fs_native.c @@ -22,19 +22,19 @@ #include #include -static bool_t NativeDel(const char *fname); -static bool_t NativeExists(const char *fname); +static gBool NativeDel(const char *fname); +static gBool NativeExists(const char *fname); static long int NativeFilesize(const char *fname); -static bool_t NativeRen(const char *oldname, const char *newname); -static bool_t NativeOpen(GFILE *f, const char *fname); +static gBool NativeRen(const char *oldname, const char *newname); +static gBool NativeOpen(GFILE *f, const char *fname); static void NativeClose(GFILE *f); static int NativeRead(GFILE *f, void *buf, int size); static int NativeWrite(GFILE *f, const void *buf, int size); -static bool_t NativeSetpos(GFILE *f, long int pos); +static gBool NativeSetpos(GFILE *f, long int pos); static long int NativeGetsize(GFILE *f); -static bool_t NativeEof(GFILE *f); +static gBool NativeEof(GFILE *f); #if GFILE_NEED_FILELISTS - static gfileList *NativeFlOpen(const char *path, bool_t dirs); + static gfileList *NativeFlOpen(const char *path, gBool dirs); static const char *NativeFlRead(gfileList *pfl); static void NativeFlClose(gfileList *pfl); #endif @@ -95,33 +95,33 @@ static void Native_flags2mode(char *buf, uint16_t flags) { *buf++ = 0; } -static bool_t NativeDel(const char *fname) { return remove(fname) ? FALSE : TRUE; } +static gBool NativeDel(const char *fname) { return remove(fname) ? gFalse : gTrue; } static void NativeClose(GFILE *f) { fclose((FILE *)f->obj); } static int NativeRead(GFILE *f, void *buf, int size) { return fread(buf, 1, size, (FILE *)f->obj); } static int NativeWrite(GFILE *f, const void *buf, int size) { return fwrite(buf, 1, size, (FILE *)f->obj); } -static bool_t NativeSetpos(GFILE *f, long int pos) { return fseek((FILE *)f->obj, pos, SEEK_SET) ? FALSE : TRUE; } -static bool_t NativeEof(GFILE *f) { return feof((FILE *)f->obj) ? TRUE : FALSE; } -static bool_t NativeRen(const char *oldname, const char *newname) { return rename(oldname, newname) ? FALSE : TRUE; } -static bool_t NativeExists(const char *fname) { +static gBool NativeSetpos(GFILE *f, long int pos) { return fseek((FILE *)f->obj, pos, SEEK_SET) ? gFalse : gTrue; } +static gBool NativeEof(GFILE *f) { return feof((FILE *)f->obj) ? gTrue : gFalse; } +static gBool NativeRen(const char *oldname, const char *newname) { return rename(oldname, newname) ? gFalse : gTrue; } +static gBool NativeExists(const char *fname) { // We define access this way so we don't have to include which may // (and does under windows) contain conflicting definitions for types such as uint16_t. extern int access(const char *pathname, int mode); - return access(fname, 0) ? FALSE : TRUE; + return access(fname, 0) ? gFalse : gTrue; } static long int NativeFilesize(const char *fname) { struct stat st; if (stat(fname, &st)) return -1; return st.st_size; } -static bool_t NativeOpen(GFILE *f, const char *fname) { +static gBool NativeOpen(GFILE *f, const char *fname) { FILE *fd; char mode[5]; Native_flags2mode(mode, f->flags); if (!(fd = fopen(fname, mode))) - return FALSE; + return gFalse; f->obj = (void *)fd; - return TRUE; + return gTrue; } static long int NativeGetsize(GFILE *f) { struct stat st; @@ -135,10 +135,10 @@ static long int NativeGetsize(GFILE *f) { gfileList fl; HANDLE d; WIN32_FIND_DATA f; - bool_t first; + gBool first; } NativeFileList; - static gfileList *NativeFlOpen(const char *path, bool_t dirs) { + static gfileList *NativeFlOpen(const char *path, gBool dirs) { NativeFileList *p; (void) dirs; @@ -148,7 +148,7 @@ static long int NativeGetsize(GFILE *f) { gfxFree(p); return 0; } - p->first = TRUE; + p->first = gTrue; return &p->fl; } @@ -157,7 +157,7 @@ static long int NativeGetsize(GFILE *f) { while(1) { if (!nfl->first && !FindNextFile(nfl->d, &nfl->f)) return 0; - nfl->first = FALSE; + nfl->first = gFalse; if (nfl->f.cFileName[0] == '.') continue; if (nfl->fl.dirs) { @@ -186,7 +186,7 @@ static long int NativeGetsize(GFILE *f) { struct dirent * f; } NativeFileList; - static gfileList *NativeFlOpen(const char *path, bool_t dirs) { + static gfileList *NativeFlOpen(const char *path, gBool dirs) { NativeFileList *p; (void) dirs; diff --git a/src/gfile/gfile_fs_petitfs.c b/src/gfile/gfile_fs_petitfs.c index 553c29ff..84405f25 100644 --- a/src/gfile/gfile_fs_petitfs.c +++ b/src/gfile/gfile_fs_petitfs.c @@ -16,12 +16,12 @@ #include "gfile_fs.h" #include "gfile_petitfs_wrapper.h" -static bool_t petitfsExists(const char* fname); -static bool_t petitfsOpen(GFILE* f, const char* fname); +static gBool petitfsExists(const char* fname); +static gBool petitfsOpen(GFILE* f, const char* fname); static int petitfsRead(GFILE* f, void* buf, int size); -static bool_t petitfsSetPos(GFILE* f, long int pos); +static gBool petitfsSetPos(GFILE* f, long int pos); #if GFILE_NEED_FILELISTS && _FS_MINIMIZE <= 1 - static gfileList *petitfsFlOpen(const char *path, bool_t dirs); + static gfileList *petitfsFlOpen(const char *path, gBool dirs); static const char *petitfsFlRead(gfileList *pfl); static void petitfsFlClose(gfileList *pfl); #endif @@ -58,38 +58,38 @@ typedef struct petitfsList { } petitfsList; // optimize these later on. Use an array to have multiple -static bool_t petitfs_mounted = FALSE; +static gBool petitfs_mounted = gFalse; static FATFS petitfs_fs; -static bool_t petitfsExists(const char* fname) +static gBool petitfsExists(const char* fname) { // Mount first if (!petitfs_mounted && pf_mount(&petitfs_fs) != FR_OK) - return FALSE; + return gFalse; // Open if (pf_open(fname) != FR_OK) - return FALSE; + return gFalse; - return TRUE; + return gTrue; } -static bool_t petitfsOpen(GFILE* f, const char* fname) +static gBool petitfsOpen(GFILE* f, const char* fname) { // No writing if ((f->flags & GFILEFLG_WRITE)) - return FALSE; + return gFalse; // Mount first if (!petitfs_mounted && pf_mount(&petitfs_fs) != FR_OK) - return FALSE; + return gFalse; // Open if (pf_open(fname) != FR_OK) - return FALSE; + return gFalse; f->obj = &petitfs_fs; - return TRUE; + return gTrue; } static int petitfsRead(GFILE* f, void* buf, int size) @@ -103,14 +103,14 @@ static int petitfsRead(GFILE* f, void* buf, int size) return br; } -static bool_t petitfsSetPos(GFILE* f, long int pos) +static gBool petitfsSetPos(GFILE* f, long int pos) { (void) f; return pf_lseek((DWORD)pos) == FR_OK; } #if GFILE_NEED_FILELISTS - static gfileList *petitfsFlOpen(const char *path, bool_t dirs) { + static gfileList *petitfsFlOpen(const char *path, gBool dirs) { petitfsList *p; (void) dirs; diff --git a/src/gfile/gfile_fs_rom.c b/src/gfile/gfile_fs_rom.c index ec07ec34..578a28e5 100644 --- a/src/gfile/gfile_fs_rom.c +++ b/src/gfile/gfile_fs_rom.c @@ -42,16 +42,16 @@ typedef struct ROMFileList { } ROMFileList; -static bool_t ROMExists(const char *fname); +static gBool ROMExists(const char *fname); static long int ROMFilesize(const char *fname); -static bool_t ROMOpen(GFILE *f, const char *fname); +static gBool ROMOpen(GFILE *f, const char *fname); static void ROMClose(GFILE *f); static int ROMRead(GFILE *f, void *buf, int size); -static bool_t ROMSetpos(GFILE *f, long int pos); +static gBool ROMSetpos(GFILE *f, long int pos); static long int ROMGetsize(GFILE *f); -static bool_t ROMEof(GFILE *f); +static gBool ROMEof(GFILE *f); #if GFILE_NEED_FILELISTS - static gfileList *ROMFlOpen(const char *path, bool_t dirs); + static gfileList *ROMFlOpen(const char *path, gBool dirs); static const char *ROMFlRead(gfileList *pfl); static void ROMFlClose(gfileList *pfl); #endif @@ -79,7 +79,7 @@ static const ROMFS_DIRENTRY *ROMFindFile(const char *fname) return p; } -static bool_t ROMExists(const char *fname) +static gBool ROMExists(const char *fname) { return ROMFindFile(fname) != 0; } @@ -92,13 +92,13 @@ static long int ROMFilesize(const char *fname) return p->size; } -static bool_t ROMOpen(GFILE *f, const char *fname) +static gBool ROMOpen(GFILE *f, const char *fname) { const ROMFS_DIRENTRY *p; - if (!(p = ROMFindFile(fname))) return FALSE; + if (!(p = ROMFindFile(fname))) return gFalse; f->obj = (void *)p; - return TRUE; + return gTrue; } static void ROMClose(GFILE *f) @@ -118,7 +118,7 @@ static int ROMRead(GFILE *f, void *buf, int size) return size; } -static bool_t ROMSetpos(GFILE *f, long int pos) +static gBool ROMSetpos(GFILE *f, long int pos) { return pos <= ((const ROMFS_DIRENTRY *)f->obj)->size; } @@ -128,13 +128,13 @@ static long int ROMGetsize(GFILE *f) return ((const ROMFS_DIRENTRY *)f->obj)->size; } -static bool_t ROMEof(GFILE *f) +static gBool ROMEof(GFILE *f) { return f->pos >= ((const ROMFS_DIRENTRY *)f->obj)->size; } #if GFILE_NEED_FILELISTS - static gfileList *ROMFlOpen(const char *path, bool_t dirs) { + static gfileList *ROMFlOpen(const char *path, gBool dirs) { ROMFileList * p; (void) path; diff --git a/src/gfile/gfile_printg.c b/src/gfile/gfile_printg.c index 8f9d2570..697593d3 100644 --- a/src/gfile/gfile_printg.c +++ b/src/gfile/gfile_printg.c @@ -56,7 +56,7 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) { int ret; char *p, *s, c, filler; int i, precision, width; - bool_t is_long, left_align; + gBool is_long, left_align; long l; #if GFILE_ALLOW_FLOATS float fpv; @@ -81,14 +81,14 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) { fmt++; p = s = tmpbuf; - left_align = FALSE; + left_align = gFalse; filler = ' '; width = 0; precision = 0; if (*fmt == '-') { fmt++; - left_align = TRUE; + left_align = gTrue; } if (*fmt == '0') { fmt++; @@ -119,7 +119,7 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) { } /* Long modifier.*/ if (c == 'l' || c == 'L') { - is_long = TRUE; + is_long = gTrue; if (*fmt) c = *fmt++; } @@ -194,7 +194,7 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) { i = (int)(p - s); if ((width -= i) < 0) width = 0; - if (left_align == FALSE) + if (!left_align) width = -width; if (width < 0) { if (*s == '-' && filler == '0') { diff --git a/src/gfile/gfile_scang.c b/src/gfile/gfile_scang.c index a79cc6a3..8e1ee69c 100644 --- a/src/gfile/gfile_scang.c +++ b/src/gfile/gfile_scang.c @@ -27,7 +27,7 @@ int vfscang(GFILE *f, const char *fmt, va_list arg) { int res, width, size, base; unsigned long num; char c; - bool_t assign, negate; + gBool assign, negate; char *p; for(res = 0; *fmt; fmt++) { @@ -37,15 +37,15 @@ int vfscang(GFILE *f, const char *fmt, va_list arg) { case '%': fmt++; - assign = TRUE; - negate = FALSE; + assign = gTrue; + negate = gFalse; width = 0; size = 1; num = 0; if (*fmt == '*') { fmt++; - assign = FALSE; + assign = gFalse; } while(*fmt >= '0' && *fmt <= '9') width = width * 10 + (*fmt++ - '0'); @@ -145,7 +145,7 @@ int vfscang(GFILE *f, const char *fmt, va_list arg) { break; } if (c == '-' && *fmt != 'u') { - negate = TRUE; + negate = gTrue; if ((width && !--width) || !gfileRead(f, &c, 1)) return res; } if (base == -1) { -- cgit v1.2.3