16 #include <sys/types.h>
50 #define CP_UTF8 65001U
53 #ifndef MB_ERR_INVALID_CHARS
55 #define MB_ERR_INVALID_CHARS 0x00000008UL
58 #ifndef WC_ERR_INVALID_CHARS
60 #define WC_ERR_INVALID_CHARS 0x00000080UL
64 #define access moonlight_nxdk_ffmpeg_access
66 #define close moonlight_nxdk_ffmpeg_close
68 #define fcntl moonlight_nxdk_ffmpeg_fcntl
70 #define fdopen moonlight_nxdk_ffmpeg_fdopen
72 #define isatty moonlight_nxdk_ffmpeg_isatty
74 #define GetFullPathNameW moonlight_nxdk_ffmpeg_GetFullPathNameW
76 #define mkstemp moonlight_nxdk_ffmpeg_mkstemp
78 #define MultiByteToWideChar moonlight_nxdk_ffmpeg_MultiByteToWideChar
80 #define open moonlight_nxdk_ffmpeg_open
82 #define strerror_r moonlight_nxdk_ffmpeg_strerror_r
84 #define tempnam moonlight_nxdk_ffmpeg_tempnam
86 #define usleep moonlight_nxdk_ffmpeg_usleep
88 #define WideCharToMultiByte moonlight_nxdk_ffmpeg_WideCharToMultiByte
97 static inline int moonlight_nxdk_ffmpeg_access(
const char *path,
int mode) {
110 static inline int moonlight_nxdk_ffmpeg_close(
int fd) {
123 static inline int moonlight_nxdk_ffmpeg_fcntl(
int fd,
int cmd, ...) {
137 static inline FILE *moonlight_nxdk_ffmpeg_fdopen(
int fd,
const char *mode) {
150 static inline int moonlight_nxdk_ffmpeg_isatty(
int fd) {
160 static inline int64_t gethrtime(
void) {
173 static inline unsigned long moonlight_nxdk_ffmpeg_GetFullPathNameW(
const wchar_t *path,
unsigned long buffer_size,
wchar_t *buffer,
wchar_t **file_part) {
175 wchar_t *last_separator;
181 length = wcslen(path);
182 last_separator = NULL;
183 for (
size_t index = 0; index < length; ++index) {
184 if (path[index] == L
'\\' || path[index] == L
'/') {
185 last_separator = (
wchar_t *) &path[index + 1U];
189 if (file_part != NULL) {
190 *file_part = last_separator;
193 if (buffer == NULL || buffer_size == 0U) {
194 return (
unsigned long) (length + 1U);
197 if (length + 1U > buffer_size) {
198 if (buffer_size > 0U) {
199 wcsncpy(buffer, path, buffer_size - 1U);
200 buffer[buffer_size - 1U] = L
'\0';
202 return (
unsigned long) (length + 1U);
205 wcscpy(buffer, path);
206 return (
unsigned long) length;
215 static inline int moonlight_nxdk_ffmpeg_mkstemp(
char *pattern) {
232 static inline int moonlight_nxdk_ffmpeg_MultiByteToWideChar(
unsigned int code_page,
unsigned long flags,
const char *source,
int source_length,
wchar_t *destination,
int destination_length) {
238 if (source == NULL) {
242 length = source_length >= 0 ? (size_t) source_length : strlen(source) + 1U;
243 if (destination == NULL || destination_length <= 0) {
247 if ((
size_t) destination_length < length) {
251 for (
size_t index = 0; index < length; ++index) {
252 destination[index] = (
unsigned char) source[index];
266 static inline int moonlight_nxdk_ffmpeg_open(
const char *path,
int flags, ...) {
281 static inline int moonlight_nxdk_ffmpeg_strerror_r(
int errnum,
char *buffer,
size_t buffer_size) {
284 if (buffer == NULL || buffer_size == 0) {
289 message = strerror(errnum);
290 if (message == NULL) {
291 message =
"Unknown error";
294 strncpy(buffer, message, buffer_size - 1U);
295 buffer[buffer_size - 1U] =
'\0';
306 static inline char *moonlight_nxdk_ffmpeg_tempnam(
const char *dir,
const char *prefix) {
319 static inline int moonlight_nxdk_ffmpeg_usleep(
unsigned int usec) {
337 static inline int moonlight_nxdk_ffmpeg_WideCharToMultiByte(
unsigned int code_page,
unsigned long flags,
const wchar_t *source,
int source_length,
char *destination,
int destination_length,
const char *default_char,
int *used_default_char) {
343 if (used_default_char != NULL) {
344 *used_default_char = 0;
347 if (source == NULL) {
351 length = source_length >= 0 ? (size_t) source_length : wcslen(source) + 1U;
352 if (destination == NULL || destination_length <= 0) {
356 if ((
size_t) destination_length < length) {
360 for (
size_t index = 0; index < length; ++index) {
361 destination[index] = (char) source[index];
#define ENOSYS
Error code used when an FFmpeg compatibility operation is unsupported.
Definition ffmpeg_compat.h:25