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)
40 /* File descriptor set emulation. */
42 #if 0 /* These are defined in winsock.h.
43 FD_SETSIZE is defined 64. Let's not full the runtime. */
45 /* The MSVC multithreaded statically-linked runtime library has limit
46 of 256 descriptors by default (the single-threaded static library
47 has a limit of 64 descriptors, and the DLL versions both have a
48 limit of 512). Beware. Should this be set to 512? */
49 #define FD_SETSIZE 256
51 unsigned int bits[FD_SETSIZE / 32];
54 /* standard access macros */
55 #define FD_SET(n, p) \
57 if ((n) < FD_SETSIZE) { \
58 (p)->bits[(n)/32] |= (1 << (n)%32); \
61 #define FD_CLR(n, p) \
63 if ((n) < FD_SETSIZE) { \
64 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
67 #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
68 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
70 #define SELECT_TYPE fd_set
71 #define MAXDESC FD_SETSIZE
75 /* ------------------------------------------------------------------------- */
77 /* child_process.status values */
79 STATUS_READ_ERROR = -1,
81 STATUS_READ_IN_PROGRESS,
83 STATUS_READ_SUCCEEDED,
84 STATUS_READ_ACKNOWLEDGED
87 /* This structure is used for both pipes and sockets; for
88 a socket, the process handle in pi is NULL. */
89 typedef struct _child_process
97 PROCESS_INFORMATION procinfo;
102 #define MAX_CHILDREN MAXDESC/2
103 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
105 /* parallel array of private info on file handles */
113 extern filedesc fd_info [ MAXDESC ];
115 /* fd_info flag definitions */
116 #define FILE_READ 0x0001
117 #define FILE_WRITE 0x0002
118 #define FILE_BINARY 0x0010
119 #define FILE_LAST_CR 0x0020
120 #define FILE_AT_EOF 0x0040
121 #define FILE_SEND_SIGCHLD 0x0080
122 #define FILE_PIPE 0x0100
123 #define FILE_SOCKET 0x0200
125 extern child_process * new_child (void);
126 extern void delete_child (child_process *cp);
128 /* ------------------------------------------------------------------------- */
130 /* Get long (aka "true") form of file name, if it exists. */
131 extern BOOL win32_get_long_filename (char * name, char * buf, int size);
133 /* Prepare our standard handles for proper inheritance by child processes. */
134 extern void prepare_standard_handles (int in, int out,
135 int err, HANDLE handles[4]);
137 /* Reset our standard handles to their original state. */
138 extern void reset_standard_handles (int in, int out,
139 int err, HANDLE handles[4]);
141 /* Return the string resource associated with KEY of type TYPE. */
142 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
144 void set_process_dir (const char * dir);
145 time_t convert_time (FILETIME ft);
147 extern void init_ntproc ();
148 extern void term_ntproc ();