Debian Codegraph @

inc/ffunistd.h

raw symbols SCIP
1 /* Copyright (C) 2024 by FontForge Authors */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef FONTFORGE_FFUNISTD_H
29 #define FONTFORGE_FFUNISTD_H
30
31 /*
32 * Cross-platform unistd.h compatibility.
33 * MSVC doesn't have unistd.h, but provides equivalent functions with
34 * different names in io.h, process.h, and direct.h.
35 */
36
37 #ifdef _MSC_VER
38
39 #include <io.h>
40 #include <process.h>
41 #include <direct.h>
42 #include <stdlib.h>
43
44 /* File access mode constants */
45 #ifndef F_OK
46 #define F_OK 0
47 #endif
48 #ifndef X_OK
49 #define X_OK 1
50 #endif
51 #ifndef W_OK
52 #define W_OK 2
53 #endif
54 #ifndef R_OK
55 #define R_OK 4
56 #endif
57
58 /* PATH_MAX - use MAX_PATH on Windows */
59 #ifndef PATH_MAX
60 #define PATH_MAX 260
61 #endif
62
63 /* Map POSIX names to MSVC equivalents */
64 #define access _access
65 #define unlink _unlink
66 #define getpid _getpid
67 #define getcwd _getcwd
68 #define chdir _chdir
69 #define rmdir _rmdir
70 #define dup _dup
71 #define dup2 _dup2
72 #define close _close
73 #define read _read
74 #define write _write
75 #define lseek _lseek
76 #define isatty _isatty
77
78 /* MSVC doesn't have fork/exec - these would need separate handling */
79 /* Files using these will need #ifndef _MSC_VER guards */
80
81 #else /* !_MSC_VER */
82
83 #include <unistd.h>
84
85 #endif /* _MSC_VER */
86
87 #endif /* FONTFORGE_FFUNISTD_H */