Debian Codegraph @

externs.h

raw
1 /**************************************************************************
2 * This program is Copyright (C) 1986-2002 by Jonathan Payne. JOVE is *
3 * provided by Jonathan and Jovehacks without charge and without *
4 * warranty. You may copy, modify, and/or distribute JOVE, provided that *
5 * this notice is included in all the source files and documentation. *
6 **************************************************************************/
7
8 /* As of 5.x, Jove requires C89 and POSIX.1-conforming prototyped headers */
9
10 #ifdef EWOULDBLOCK
11 # define RETRY_ERRNO(e) ((e) == EINTR || (e) == EAGAIN || (e) == EWOULDBLOCK)
12 #else
13 /* older Unix, e.g. V7 */
14 # define RETRY_ERRNO(e) ((e) == EINTR || (e) == EAGAIN)
15 #endif
16
17 #ifdef MSFILESYSTEM
18 # include <io.h>
19 #else
20 # include <unistd.h>
21 # include <fcntl.h>
22 #endif
23
24 #ifndef F_OK /* Usually in POSIX <unistd.h> */
25 # define F_OK 0 /* does file exist? */
26 # define X_OK 1 /* is it executable by caller? */
27 # define W_OK 2 /* writable by caller? */
28 # define R_OK 4 /* readable by caller? */
29 #endif
30
31 #ifndef O_RDONLY /* Usually in POSIX <fcntl.h> or Unix <sys/file.h> */
32 # define O_RDONLY 0
33 # define O_WRONLY 1
34 # define O_RDWR 2
35 #endif
36
37 #if defined(WIN32)
38 # define JSSIZE_T int
39 # define JRWSIZE_T unsigned int /* MSVC for 64bit uses this, not size_t */
40 #else
41 # define JSSIZE_T ssize_t
42 # define JRWSIZE_T size_t
43 #endif
44
45 #ifndef O_BINARY /* needed for MSDOS and perhaps others */
46 # define O_BINARY 0 /* fake if missing with value harmless when ORed */
47 #endif
48 #ifndef O_CLOEXEC
49 # define O_CLOEXEC 0
50 #endif
51
52 #if defined(IBMPCDOS) || defined(WIN32)
53 /*
54 * At least as of 2007, perhaps earlier, the Microsoft runtime has
55 * no X_OK and considers a value of 1 to be invalid, e.g see
56 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30972
57 * https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
58 * Older runtimes may have accepted it, but VS 2019, in Win 7 Pro,
59 * crashes the program.
60 */
61 # define J_X_OK F_OK
62 #else
63 # define J_X_OK X_OK
64 #endif
65
66 /* termcap */
67 #ifdef TERMCAP
68 # ifdef JTC
69 #define DEFINE_PC_BC_UP_OSPEED 1 /* curses declares these, jtc does not! should it?*/
70 extern char *jtcarg1(const char *, int /* parm */);
71 extern char *jtcarg2(const char *, int /*destcol*/, int /*destline*/);
72 # define targ1(s, i) jtcarg1(s, i)
73 # define targ2(s, c, l) jtcarg2(s, c, l)
74 # else /* !JTC */
75 # ifdef TERMINFO
76 extern char *tparm(const char *, ...); /* SysV/POSIX curses.h or term.h */
77 # define targ1(s, i) tparm(s, i)
78 # define targ2(s, c, l) tparm(s, l, c)
79 # else /* !TERMINFO */
80 extern char *tgoto(const char *, int /*destcol*/, int /*destline*/); /* BSD termcap */
81 # define targ1(s, i) tgoto(s, 0, i)
82 # define targ2(s, c, l) tgoto(s, c, l)
83 # endif /* TERMINFO */
84 # endif /* JTC */
85 #endif /* TERMCAP */
86
87 /* originally sysprocs.h, simpler to just incorporate it here */
88
89 /* The diversity of process management is complicated and difficult to handle.
90 * - In some systems (noteably POSIX), a process id has type "pid_t"
91 * - V7 only has wait. POSIX has waitpid (with options). BSD has
92 * wait3. Someone has wait2.
93 * - The status result set by wait and used by WIF* has type
94 * "union wait" in BSD, but "int" everywhere else.
95 * - The WIF* functions are defined in <sys/wait.h> by BSD and POSIX.
96 * - WTERMSIG seems to be a creation of POSIX
97 * - Some systems have vfork(1) and perform better if it is used
98 * in place of fork(1).
99 *
100 * This header attempts to span this diversity. We provide:
101 * - POSIX pid_t
102 * - wait_opt, to accept options (and use them, if possible).
103 * - wait_status_t
104 * - WIF*
105 * - WTERMSIG
106 */
107
108 typedef int wait_status_t; /* used to be union in some UNIX once */
109
110 #ifdef MSDOS_PROCS
111 # include <process.h>
112 #endif
113
114 #if defined(POSIX_PROCS) || defined(PIPEPROCS)
115 # include <sys/wait.h>
116 # define wait_opt(stat_loc, options) waitpid(-1, stat_loc, options)
117 # define NEWPG() setpgid(0, getpid())
118 #endif /*!MSDOS_PROCS*/
119