comparison dep/fmt/test/posix-mock.h @ 343:1faa72660932

*: transfer back to cmake from autotools autotools just made lots of things more complicated than they should have and many things broke (i.e. translations)
author Paper <paper@paper.us.eu.org>
date Thu, 20 Jun 2024 05:56:06 -0400
parents
children
comparison
equal deleted inserted replaced
342:adb79bdde329 343:1faa72660932
1 // Formatting library for C++ - mocks of POSIX functions
2 //
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
7
8 #ifndef FMT_POSIX_TEST_H
9 #define FMT_POSIX_TEST_H
10
11 #include <errno.h>
12 #include <locale.h>
13 #include <stdio.h>
14 #ifdef __APPLE__
15 # include <xlocale.h>
16 #endif
17
18 #ifdef _WIN32
19 # include <windows.h>
20 #else
21 # include <sys/param.h> // for FreeBSD version
22 # include <sys/types.h> // for ssize_t
23 #endif
24
25 #ifndef _MSC_VER
26 struct stat;
27 #endif
28
29 namespace test {
30
31 #ifndef _MSC_VER
32 // Size type for read and write.
33 using size_t = size_t;
34 using ssize_t = ssize_t;
35 int open(const char* path, int oflag, int mode);
36 int fstat(int fd, struct stat* buf);
37 #else
38 using size_t = unsigned;
39 using ssize_t = int;
40 #endif
41
42 #ifndef _WIN32
43 long sysconf(int name);
44 #else
45 DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
46 #endif
47
48 int close(int fildes);
49
50 int dup(int fildes);
51 int dup2(int fildes, int fildes2);
52
53 FILE* fdopen(int fildes, const char* mode);
54
55 ssize_t read(int fildes, void* buf, size_t nbyte);
56 ssize_t write(int fildes, const void* buf, size_t nbyte);
57
58 #ifndef _WIN32
59 int pipe(int fildes[2]);
60 #else
61 int pipe(int* pfds, unsigned psize, int textmode);
62 #endif
63
64 FILE* fopen(const char* filename, const char* mode);
65 int fclose(FILE* stream);
66 int(fileno)(FILE* stream);
67
68 #if defined(FMT_LOCALE) && !defined(_WIN32)
69 locale_t newlocale(int category_mask, const char* locale, locale_t base);
70 #endif
71 } // namespace test
72
73 #define FMT_SYSTEM(call) test::call
74
75 #endif // FMT_POSIX_TEST_H