100
|
1 #ifndef _NT_H_
|
|
2 #define _NT_H_
|
|
3
|
|
4 /* Support routines for the NT version of XEmacs.
|
|
5 Copyright (C) 1994 Free Software Foundation, Inc.
|
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
|
209
|
25 /* Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
|
100
|
26
|
|
27 /* #define FULL_DEBUG */
|
|
28 #define EMACSDEBUG
|
|
29
|
|
30 #ifdef EMACSDEBUG
|
|
31 #define DebPrint(stuff) _DebPrint stuff
|
|
32 #else
|
|
33 #define DebPrint(stuff)
|
|
34 #endif
|
|
35
|
|
36 #define R_OK 4
|
|
37 #define W_OK 2
|
|
38 #define X_OK 1
|
|
39 #define F_OK 0
|
|
40
|
|
41 /* File descriptor set emulation. */
|
|
42
|
|
43 /* MSVC runtime library has limit of 64 descriptors by default */
|
|
44 #define FD_SETSIZE 64
|
|
45 typedef struct {
|
|
46 unsigned int bits[FD_SETSIZE / 32];
|
|
47 } fd_set;
|
|
48
|
|
49 /* standard access macros */
|
|
50 #define FD_SET(n, p) \
|
|
51 do { \
|
|
52 if ((n) < FD_SETSIZE) { \
|
|
53 (p)->bits[(n)/32] |= (1 << (n)%32); \
|
|
54 } \
|
|
55 } while (0)
|
|
56 #define FD_CLR(n, p) \
|
|
57 do { \
|
|
58 if ((n) < FD_SETSIZE) { \
|
|
59 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
|
|
60 } \
|
|
61 } while (0)
|
|
62 #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
|
|
63 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
|
|
64
|
|
65 #define SELECT_TYPE fd_set
|
|
66
|
|
67 /* ------------------------------------------------------------------------- */
|
|
68
|
|
69 /* child_process.status values */
|
|
70 enum {
|
|
71 STATUS_READ_ERROR = -1,
|
|
72 STATUS_READ_READY,
|
|
73 STATUS_READ_IN_PROGRESS,
|
|
74 STATUS_READ_FAILED,
|
|
75 STATUS_READ_SUCCEEDED,
|
|
76 STATUS_READ_ACKNOWLEDGED
|
|
77 };
|
|
78
|
|
79 /* This structure is used for both pipes and sockets; for
|
|
80 a socket, the process handle in pi is NULL. */
|
|
81 typedef struct _child_process
|
|
82 {
|
|
83 int fd;
|
|
84 int pid;
|
|
85 HANDLE char_avail;
|
|
86 HANDLE char_consumed;
|
|
87 HANDLE thrd;
|
209
|
88 HWND hwnd;
|
100
|
89 PROCESS_INFORMATION procinfo;
|
|
90 volatile int status;
|
|
91 char chr;
|
|
92 } child_process;
|
|
93
|
|
94 #define MAXDESC FD_SETSIZE
|
|
95 #define MAX_CHILDREN MAXDESC/2
|
|
96 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
|
|
97
|
|
98 /* parallel array of private info on file handles */
|
|
99 typedef struct
|
|
100 {
|
|
101 unsigned flags;
|
|
102 HANDLE hnd;
|
|
103 child_process * cp;
|
|
104 } filedesc;
|
|
105
|
|
106 extern filedesc fd_info [ MAXDESC ];
|
|
107
|
|
108 /* fd_info flag definitions */
|
|
109 #define FILE_READ 0x0001
|
|
110 #define FILE_WRITE 0x0002
|
|
111 #define FILE_BINARY 0x0010
|
209
|
112 #define FILE_LAST_CR 0x0020
|
|
113 #define FILE_AT_EOF 0x0040
|
|
114 #define FILE_SEND_SIGCHLD 0x0080
|
100
|
115 #define FILE_PIPE 0x0100
|
|
116 #define FILE_SOCKET 0x0200
|
|
117
|
|
118 extern child_process * new_child (void);
|
|
119 extern void delete_child (child_process *cp);
|
|
120
|
|
121 /* ------------------------------------------------------------------------- */
|
|
122
|
209
|
123 /* Get long (aka "true") form of file name, if it exists. */
|
|
124 extern BOOL win32_get_long_filename (char * name, char * buf, int size);
|
100
|
125
|
|
126 /* Prepare our standard handles for proper inheritance by child processes. */
|
|
127 extern void prepare_standard_handles (int in, int out,
|
|
128 int err, HANDLE handles[4]);
|
|
129
|
|
130 /* Reset our standard handles to their original state. */
|
|
131 extern void reset_standard_handles (int in, int out,
|
|
132 int err, HANDLE handles[4]);
|
|
133
|
|
134 /* Return the string resource associated with KEY of type TYPE. */
|
|
135 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
|
|
136
|
|
137 extern void init_ntproc ();
|
|
138 extern void term_ntproc ();
|
|
139
|
|
140 #endif /* _NT_H_ */
|