Commit | Line | Data |
---|---|---|
b3fa71dc GV |
1 | #ifndef _NT_H_ |
2 | #define _NT_H_ | |
3 | ||
95ed0025 RS |
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 | |
3b7ad313 EN |
21 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 | Boston, MA 02111-1307, USA. */ | |
95ed0025 | 23 | |
b3fa71dc GV |
24 | /* #define FULL_DEBUG */ |
25 | #define EMACSDEBUG | |
95ed0025 | 26 | |
b3fa71dc GV |
27 | #ifdef EMACSDEBUG |
28 | #define DebPrint(stuff) _DebPrint stuff | |
95ed0025 | 29 | #else |
b3fa71dc | 30 | #define DebPrint(stuff) |
95ed0025 | 31 | #endif |
b3fa71dc GV |
32 | |
33 | /* File descriptor set emulation. */ | |
34 | ||
35 | /* MSVC runtime library has limit of 64 descriptors by default */ | |
36 | #define FD_SETSIZE 64 | |
37 | typedef struct { | |
38 | unsigned int bits[FD_SETSIZE / 32]; | |
39 | } fd_set; | |
40 | ||
41 | /* standard access macros */ | |
42 | #define FD_SET(n, p) \ | |
43 | do { \ | |
44 | if ((n) < FD_SETSIZE) { \ | |
45 | (p)->bits[(n)/32] |= (1 << (n)%32); \ | |
46 | } \ | |
47 | } while (0) | |
48 | #define FD_CLR(n, p) \ | |
49 | do { \ | |
50 | if ((n) < FD_SETSIZE) { \ | |
51 | (p)->bits[(n)/32] &= ~(1 << (n)%32); \ | |
52 | } \ | |
53 | } while (0) | |
54 | #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0) | |
55 | #define FD_ZERO(p) memset((p), 0, sizeof(fd_set)) | |
56 | ||
95ed0025 | 57 | #define SELECT_TYPE fd_set |
95ed0025 | 58 | |
b3fa71dc GV |
59 | /* ------------------------------------------------------------------------- */ |
60 | ||
61 | /* child_process.status values */ | |
62 | enum { | |
63 | STATUS_READ_ERROR = -1, | |
64 | STATUS_READ_READY, | |
65 | STATUS_READ_IN_PROGRESS, | |
66 | STATUS_READ_FAILED, | |
67 | STATUS_READ_SUCCEEDED, | |
68 | STATUS_READ_ACKNOWLEDGED | |
69 | }; | |
70 | ||
71 | /* This structure is used for both pipes and sockets; for | |
72 | a socket, the process handle in pi is NULL. */ | |
73 | typedef struct _child_process | |
74 | { | |
75 | int fd; | |
76 | int pid; | |
c98e68fc | 77 | int is_dos_process; |
b3fa71dc GV |
78 | HANDLE char_avail; |
79 | HANDLE char_consumed; | |
80 | HANDLE thrd; | |
81 | PROCESS_INFORMATION procinfo; | |
82 | volatile int status; | |
83 | char chr; | |
84 | } child_process; | |
85 | ||
86 | #define MAXDESC FD_SETSIZE | |
87 | #define MAX_CHILDREN MAXDESC/2 | |
88 | #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL) | |
89 | ||
90 | /* parallel array of private info on file handles */ | |
91 | typedef struct | |
92 | { | |
93 | unsigned flags; | |
94 | HANDLE hnd; | |
95 | child_process * cp; | |
96 | } filedesc; | |
97 | ||
98 | extern filedesc fd_info [ MAXDESC ]; | |
99 | ||
100 | /* fd_info flag definitions */ | |
101 | #define FILE_READ 0x0001 | |
102 | #define FILE_WRITE 0x0002 | |
103 | #define FILE_BINARY 0x0010 | |
104 | #define FILE_PIPE 0x0100 | |
105 | #define FILE_SOCKET 0x0200 | |
106 | ||
107 | extern child_process * new_child (void); | |
108 | extern void delete_child (child_process *cp); | |
109 | ||
110 | /* ------------------------------------------------------------------------- */ | |
111 | ||
95ed0025 RS |
112 | |
113 | /* Prepare our standard handles for proper inheritance by child processes. */ | |
114 | extern void prepare_standard_handles (int in, int out, | |
115 | int err, HANDLE handles[4]); | |
116 | ||
117 | /* Reset our standard handles to their original state. */ | |
118 | extern void reset_standard_handles (int in, int out, | |
119 | int err, HANDLE handles[4]); | |
120 | ||
46c91229 | 121 | /* Return the string resource associated with KEY of type TYPE. */ |
fbd6baed | 122 | extern LPBYTE w32_get_resource (char * key, LPDWORD type); |
b3fa71dc GV |
123 | |
124 | extern void init_ntproc (); | |
125 | extern void term_ntproc (); | |
46c91229 | 126 | |
b3fa71dc | 127 | #endif /* _NT_H_ */ |