2013-09-30 19:37:13 -07:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (c) 2013 by Hugh Bailey <obs.jim@gmail.com>
|
|
|
|
|
|
|
|
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.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-10-14 04:21:15 -07:00
|
|
|
#pragma once
|
2013-09-30 19:37:13 -07:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "c99defs.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Platform-independent functions for Accessing files, encoding, DLLs,
|
|
|
|
* sleep, timer, and timing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EXPORT FILE *os_wfopen(const wchar_t *path, const char *mode);
|
|
|
|
EXPORT FILE *os_fopen(const char *path, const char *mode);
|
|
|
|
EXPORT off_t os_fgetsize(FILE *file);
|
|
|
|
|
|
|
|
EXPORT size_t os_fread_mbs(FILE *file, char **pstr);
|
|
|
|
EXPORT size_t os_fread_utf8(FILE *file, char **pstr);
|
|
|
|
|
|
|
|
/* functions purely for convenience */
|
|
|
|
EXPORT char *os_quick_read_utf8_file(const char *path);
|
|
|
|
EXPORT bool os_quick_write_utf8_file(const char *path, const char *str,
|
|
|
|
size_t len, bool marker);
|
2013-10-17 17:21:42 -07:00
|
|
|
EXPORT char *os_quick_read_mbs_file(const char *path);
|
|
|
|
EXPORT bool os_quick_write_mbs_file(const char *path, const char *str,
|
|
|
|
size_t len);
|
2013-09-30 19:37:13 -07:00
|
|
|
|
|
|
|
EXPORT size_t os_mbs_to_wcs(const char *str, size_t len, wchar_t **pstr);
|
|
|
|
EXPORT size_t os_utf8_to_wcs(const char *str, size_t len, wchar_t **pstr);
|
|
|
|
EXPORT size_t os_wcs_to_mbs(const wchar_t *str, size_t len, char **pstr);
|
|
|
|
EXPORT size_t os_wcs_to_utf8(const wchar_t *str, size_t len, char **pstr);
|
|
|
|
|
|
|
|
EXPORT size_t os_utf8_to_mbs(const char *str, size_t len, char **pstr);
|
|
|
|
EXPORT size_t os_mbs_to_utf8(const char *str, size_t len, char **pstr);
|
|
|
|
|
|
|
|
EXPORT void *os_dlopen(const char *path);
|
|
|
|
EXPORT void *os_dlsym(void *module, const char *func);
|
|
|
|
EXPORT void os_dlclose(void *module);
|
|
|
|
|
|
|
|
EXPORT void os_sleepto_ns(uint64_t time_target);
|
|
|
|
EXPORT void os_sleep_ms(uint32_t duration);
|
|
|
|
|
|
|
|
EXPORT uint64_t os_gettime_ns(void);
|
|
|
|
EXPORT uint64_t os_gettime_ms(void);
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
EXPORT int fseeko(FILE *stream, off_t offset, int whence);
|
|
|
|
EXPORT off_t ftello(FILE *stream);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define strtoll _strtoi64
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|