4 /* Support routines for the NT version of Emacs.
5 Copyright (C) 1994 Free Software Foundation, Inc.
7 This file is part of GNU Emacs.
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)
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.
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
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 /* File descriptor set emulation. */
26 /* MSVC runtime library has limit of 64 descriptors by default */
29 unsigned int bits
[FD_SETSIZE
/ 32];
32 /* standard access macros */
33 #define FD_SET(n, p) \
35 if ((n) < FD_SETSIZE) { \
36 (p)->bits[(n)/32] |= (1 << (n)%32); \
39 #define FD_CLR(n, p) \
41 if ((n) < FD_SETSIZE) { \
42 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
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))
48 #define SELECT_TYPE fd_set
50 /* ------------------------------------------------------------------------- */
52 /* child_process.status values */
54 STATUS_READ_ERROR
= -1,
56 STATUS_READ_IN_PROGRESS
,
58 STATUS_READ_SUCCEEDED
,
59 STATUS_READ_ACKNOWLEDGED
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
72 PROCESS_INFORMATION procinfo
;
77 #define MAXDESC FD_SETSIZE
78 #define MAX_CHILDREN MAXDESC/2
79 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
81 /* parallel array of private info on file handles */
89 extern filedesc fd_info
[ MAXDESC
];
91 /* fd_info flag definitions */
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
101 extern child_process
* new_child (void);
102 extern void delete_child (child_process
*cp
);
104 /* ------------------------------------------------------------------------- */
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
);
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]);
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]);
117 /* Return the string resource associated with KEY of type TYPE. */
118 extern LPBYTE
w32_get_resource (char * key
, LPDWORD type
);
120 extern void init_ntproc ();
121 extern void term_ntproc ();