annotate src/nt.h @ 100:4be1180a9e89 r20-1b2

Import from CVS: tag r20-1b2
author cvs
date Mon, 13 Aug 2007 09:15:11 +0200
parents
children 41ff10fd062f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1 #ifndef _NT_H_
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2 #define _NT_H_
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
3
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
4 /* Support routines for the NT version of XEmacs.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
5 Copyright (C) 1994 Free Software Foundation, Inc.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
6
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
7 This file is part of XEmacs.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
8
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
12 later version.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
13
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
17 for more details.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
18
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
23
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
24 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
25
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
26 /* #define FULL_DEBUG */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
27 #define EMACSDEBUG
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
28
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
29 #ifdef EMACSDEBUG
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
30 #define DebPrint(stuff) _DebPrint stuff
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
31 #else
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
32 #define DebPrint(stuff)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
33 #endif
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
34
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
35 #define R_OK 4
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
36 #define W_OK 2
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
37 #define X_OK 1
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
38 #define F_OK 0
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
39
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
40 /* File descriptor set emulation. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
41
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
42 /* MSVC runtime library has limit of 64 descriptors by default */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
43 #define FD_SETSIZE 64
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
44 typedef struct {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
45 unsigned int bits[FD_SETSIZE / 32];
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
46 } fd_set;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
47
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
48 /* standard access macros */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
49 #define FD_SET(n, p) \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
50 do { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
51 if ((n) < FD_SETSIZE) { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
52 (p)->bits[(n)/32] |= (1 << (n)%32); \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
53 } \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
54 } while (0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
55 #define FD_CLR(n, p) \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
56 do { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
57 if ((n) < FD_SETSIZE) { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
58 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
59 } \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
60 } while (0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
61 #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
62 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
63
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
64 #define SELECT_TYPE fd_set
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
65
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
66 /* ------------------------------------------------------------------------- */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
67
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
68 /* child_process.status values */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
69 enum {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
70 STATUS_READ_ERROR = -1,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
71 STATUS_READ_READY,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
72 STATUS_READ_IN_PROGRESS,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
73 STATUS_READ_FAILED,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
74 STATUS_READ_SUCCEEDED,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
75 STATUS_READ_ACKNOWLEDGED
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
76 };
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
77
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
78 /* This structure is used for both pipes and sockets; for
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
79 a socket, the process handle in pi is NULL. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
80 typedef struct _child_process
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
81 {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
82 int fd;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
83 int pid;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
84 int is_dos_process;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
85 HANDLE char_avail;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
86 HANDLE char_consumed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
87 HANDLE thrd;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
88 PROCESS_INFORMATION procinfo;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
89 volatile int status;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
90 char chr;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
91 } child_process;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
92
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
93 #define MAXDESC FD_SETSIZE
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
94 #define MAX_CHILDREN MAXDESC/2
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
95 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
96
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
97 /* parallel array of private info on file handles */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
98 typedef struct
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
99 {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
100 unsigned flags;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
101 HANDLE hnd;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
102 child_process * cp;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
103 } filedesc;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
104
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
105 extern filedesc fd_info [ MAXDESC ];
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
106
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
107 /* fd_info flag definitions */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
108 #define FILE_READ 0x0001
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
109 #define FILE_WRITE 0x0002
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
110 #define FILE_BINARY 0x0010
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
111 #define FILE_PIPE 0x0100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
112 #define FILE_SOCKET 0x0200
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
113
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
114 extern child_process * new_child (void);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
115 extern void delete_child (child_process *cp);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
116
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
117 /* ------------------------------------------------------------------------- */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
118
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
119
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
120 /* Prepare our standard handles for proper inheritance by child processes. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
121 extern void prepare_standard_handles (int in, int out,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
122 int err, HANDLE handles[4]);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
123
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
124 /* Reset our standard handles to their original state. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
125 extern void reset_standard_handles (int in, int out,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
126 int err, HANDLE handles[4]);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
127
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
128 /* Return the string resource associated with KEY of type TYPE. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
129 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
130
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
131 extern void init_ntproc ();
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
132 extern void term_ntproc ();
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
133
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
134 #endif /* _NT_H_ */