diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2013-03-21 19:18:49 +1100 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2013-03-29 21:25:59 +1100 |
commit | 5705b4d7b2c3c5311138e9f4b66658c51f3cc22b (patch) | |
tree | e96ada937e8b57189f211fea9bfd47ae1688676f /include | |
parent | 9b8fdafe3a4ba0b6272bdcb0161f921bf750ca49 (diff) | |
download | flac-5705b4d7b2c3c5311138e9f4b66658c51f3cc22b.tar.gz |
Huge Windows utf8 I/O patch.
Patch from Janne Hyvärinen <cse@sci.fi>.
Diffstat (limited to 'include')
-rw-r--r-- | include/share/compat.h | 38 | ||||
-rw-r--r-- | include/share/utf8_io.h | 34 |
2 files changed, 72 insertions, 0 deletions
diff --git a/include/share/compat.h b/include/share/compat.h index 64139a2e..5c9f3289 100644 --- a/include/share/compat.h +++ b/include/share/compat.h @@ -141,6 +141,44 @@ # endif #endif /* defined _MSC_VER */ +#ifdef FLAC__STRINGS_IN_UTF8 /* all char* strings are in UTF-8 format. Added to support Unicode files on Windows */ +#include "share/utf8_io.h" + +#define flac_printf printf_utf8 +#define flac_fprintf fprintf_utf8 +#define flac_vfprintf vfprintf_utf8 +#define flac_fopen fopen_utf8 +#define flac_stat _stat64_utf8 +#define flac_chmod chmod_utf8 +#define flac_utime utime_utf8 +#define flac_unlink unlink_utf8 +#define flac_rename rename_utf8 + +#else + +#define flac_printf printf +#define flac_fprintf fprintf +#define flac_vfprintf vfprintf +#define flac_fopen fopen +#ifdef _WIN32 +#define flac_stat _stat64 +#else +#define flac_stat stat +#endif +#define flac_chmod chmod +#define flac_utime utime +#define flac_unlink unlink +#define flac_rename rename +#endif + +#ifdef _WIN32 +#define _flac_stat _stat64 /* stat struct */ +#define flac_fstat _fstat64 +#else +#define _flac_stat stat /* stat struct */ +#define flac_fstat fstat +#endif + /* FLAC needs to compile and work correctly on systems with a norrmal ISO C99 * snprintf as well as Microsoft Visual Studio which has an non-standards diff --git a/include/share/utf8_io.h b/include/share/utf8_io.h new file mode 100644 index 00000000..1b8988a8 --- /dev/null +++ b/include/share/utf8_io.h @@ -0,0 +1,34 @@ +#ifdef FLAC__STRINGS_IN_UTF8 + +#ifndef flac__utf8_io_h +#define flac__utf8_io_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> +#include <sys/stat.h> +#include <stdarg.h> + + +int get_utf8_argv(int *argc, char ***argv); + +int printf_utf8(const char *format, ...); +int fprintf_utf8(FILE *stream, const char *format, ...); +int vfprintf_utf8(FILE *stream, const char *format, va_list argptr); + +FILE *fopen_utf8(const char *filename, const char *mode); +int stat_utf8(const char *path, struct stat *buffer); +int _stat64_utf8(const char *path, struct _stat64 *buffer); +int chmod_utf8(const char *filename, int pmode); +int utime_utf8(const char *filename, struct utimbuf *times); +int unlink_utf8(const char *filename); +int rename_utf8(const char *oldname, const char *newname); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif +#endif |