| 
									
										
										
										
											2018-03-04 09:16:51 -08:00
										 |  |  | // Formatting library for C++ - mocks of POSIX functions
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Copyright (c) 2012 - present, Victor Zverovich
 | 
					
						
							|  |  |  | // All rights reserved.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // For the license information refer to format.h.
 | 
					
						
							| 
									
										
										
										
											2014-05-15 07:45:44 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef FMT_POSIX_TEST_H
 | 
					
						
							|  |  |  | #define FMT_POSIX_TEST_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <errno.h>
 | 
					
						
							| 
									
										
										
										
											2014-05-15 08:58:10 -07:00
										 |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2014-05-15 07:45:44 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-06 07:29:58 -07:00
										 |  |  | #ifdef _WIN32
 | 
					
						
							| 
									
										
										
										
											2019-01-12 18:27:38 -08:00
										 |  |  | #  include <windows.h>
 | 
					
						
							| 
									
										
										
										
											2015-06-24 07:59:19 -07:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2019-01-12 18:27:38 -08:00
										 |  |  | #  include <sys/param.h>  // for FreeBSD version
 | 
					
						
							|  |  |  | #  include <sys/types.h>  // for ssize_t
 | 
					
						
							| 
									
										
										
										
											2014-09-12 11:12:22 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-06 07:29:58 -07:00
										 |  |  | #ifndef _MSC_VER
 | 
					
						
							|  |  |  | struct stat; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-15 07:45:44 -07:00
										 |  |  | namespace test { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-06 07:29:58 -07:00
										 |  |  | #ifndef _MSC_VER
 | 
					
						
							| 
									
										
										
										
											2014-05-15 08:58:10 -07:00
										 |  |  | // Size type for read and write.
 | 
					
						
							|  |  |  | typedef size_t size_t; | 
					
						
							|  |  |  | typedef ssize_t ssize_t; | 
					
						
							| 
									
										
										
										
											2019-01-12 18:27:38 -08:00
										 |  |  | int open(const char* path, int oflag, int mode); | 
					
						
							|  |  |  | int fstat(int fd, struct stat* buf); | 
					
						
							| 
									
										
										
										
											2014-05-15 07:45:44 -07:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2014-05-15 08:58:10 -07:00
										 |  |  | typedef unsigned size_t; | 
					
						
							|  |  |  | typedef int ssize_t; | 
					
						
							| 
									
										
										
										
											2019-01-12 18:27:38 -08:00
										 |  |  | errno_t sopen_s(int* pfh, const char* filename, int oflag, int shflag, | 
					
						
							|  |  |  |                 int pmode); | 
					
						
							| 
									
										
										
										
											2015-05-06 07:29:58 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _WIN32
 | 
					
						
							|  |  |  | long sysconf(int name); | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2015-03-16 08:52:23 -07:00
										 |  |  | DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); | 
					
						
							| 
									
										
										
										
											2014-05-15 07:45:44 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-15 08:58:10 -07:00
										 |  |  | int close(int fildes); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int dup(int fildes); | 
					
						
							|  |  |  | int dup2(int fildes, int fildes2); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-12 18:27:38 -08:00
										 |  |  | FILE* fdopen(int fildes, const char* mode); | 
					
						
							| 
									
										
										
										
											2014-05-15 08:58:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-12 18:27:38 -08:00
										 |  |  | ssize_t read(int fildes, void* buf, size_t nbyte); | 
					
						
							|  |  |  | ssize_t write(int fildes, const void* buf, size_t nbyte); | 
					
						
							| 
									
										
										
										
											2014-05-15 08:58:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 11:09:37 -07:00
										 |  |  | #ifndef _WIN32
 | 
					
						
							| 
									
										
										
										
											2014-05-18 10:05:29 -07:00
										 |  |  | int pipe(int fildes[2]); | 
					
						
							| 
									
										
										
										
											2014-05-18 11:09:37 -07:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2019-01-12 18:27:38 -08:00
										 |  |  | int pipe(int* pfds, unsigned psize, int textmode); | 
					
						
							| 
									
										
										
										
											2014-05-18 11:09:37 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-12 18:27:38 -08:00
										 |  |  | FILE* fopen(const char* filename, const char* mode); | 
					
						
							|  |  |  | int fclose(FILE* stream); | 
					
						
							|  |  |  | int(fileno)(FILE* stream); | 
					
						
							| 
									
										
										
										
											2014-05-15 07:45:44 -07:00
										 |  |  | }  // namespace test
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 11:09:37 -07:00
										 |  |  | #define FMT_SYSTEM(call) test::call
 | 
					
						
							| 
									
										
										
										
											2014-05-15 08:58:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-15 07:45:44 -07:00
										 |  |  | #endif  // FMT_POSIX_TEST_H
 |