4 /* Support routines for the NT version of XEmacs.
5 Copyright (C) 1994 Free Software Foundation, Inc.
7 This file is part of XEmacs.
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
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
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. */
24 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
25 /* Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
27 /* #define FULL_DEBUG */
30 #define DebPrint(stuff) _DebPrint stuff
32 #define DebPrint(stuff)
43 /* File descriptor set emulation. */
45 #if 0 /* These are defined in winsock.h.
46 FD_SETSIZE is defined 64. Let's not full the runtime. */
48 /* The MSVC multithreaded statically-linked runtime library has limit
49 of 256 descriptors by default (the single-threaded static library
50 has a limit of 64 descriptors, and the DLL versions both have a
51 limit of 512). Beware. Should this be set to 512? */
52 #define FD_SETSIZE 256
54 unsigned int bits[FD_SETSIZE / 32];
57 /* standard access macros */
58 #define FD_SET(n, p) \
60 if ((n) < FD_SETSIZE) { \
61 (p)->bits[(n)/32] |= (1 << (n)%32); \
64 #define FD_CLR(n, p) \
66 if ((n) < FD_SETSIZE) { \
67 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
70 #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
71 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
73 #define SELECT_TYPE fd_set
74 #define MAXDESC FD_SETSIZE
78 /* ------------------------------------------------------------------------- */
80 /* child_process.status values */
82 STATUS_READ_ERROR = -1,
84 STATUS_READ_IN_PROGRESS,
86 STATUS_READ_SUCCEEDED,
87 STATUS_READ_ACKNOWLEDGED
90 /* This structure is used for both pipes and sockets; for
91 a socket, the process handle in pi is NULL. */
92 typedef struct _child_process
100 PROCESS_INFORMATION procinfo;
105 #define MAX_CHILDREN MAXDESC/2
106 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
108 /* parallel array of private info on file handles */
116 extern filedesc fd_info [ MAXDESC ];
118 /* fd_info flag definitions */
119 #define FILE_READ 0x0001
120 #define FILE_WRITE 0x0002
121 #define FILE_BINARY 0x0010
122 #define FILE_LAST_CR 0x0020
123 #define FILE_AT_EOF 0x0040
124 #define FILE_SEND_SIGCHLD 0x0080
125 #define FILE_PIPE 0x0100
126 #define FILE_SOCKET 0x0200
128 extern child_process * new_child (void);
129 extern void delete_child (child_process *cp);
131 /* ------------------------------------------------------------------------- */
133 /* Get long (aka "true") form of file name, if it exists. */
134 extern BOOL win32_get_long_filename (char * name, char * buf, int size);
136 /* Prepare our standard handles for proper inheritance by child processes. */
137 extern void prepare_standard_handles (int in, int out,
138 int err, HANDLE handles[4]);
140 /* Reset our standard handles to their original state. */
141 extern void reset_standard_handles (int in, int out,
142 int err, HANDLE handles[4]);
144 /* Return the string resource associated with KEY of type TYPE. */
145 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
147 void set_process_dir (const char * dir);
148 time_t convert_time (FILETIME ft);
150 extern void init_ntproc ();
151 extern void term_ntproc ();