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