annotate src/nt.h @ 288:e11d67e05968 r21-0b42

Import from CVS: tag r21-0b42
author cvs
date Mon, 13 Aug 2007 10:35:54 +0200
parents 41f2f0e326e9
children 74fd4e045ea6
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> */
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
25 /* Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
26
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
27 /* #define FULL_DEBUG */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
28
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
29 #ifdef DEBUG_XEMACS
100
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
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
42 #if 0 /* These are defined in winsock.h.
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
43 FD_SETSIZE is defined 64. Let's not full the runtime. */
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
44
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
45 /* The MSVC multithreaded statically-linked runtime library has limit
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
46 of 256 descriptors by default (the single-threaded static library
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
47 has a limit of 64 descriptors, and the DLL versions both have a
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
48 limit of 512). Beware. Should this be set to 512? */
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
49 #define FD_SETSIZE 256
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
50 typedef struct {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
51 unsigned int bits[FD_SETSIZE / 32];
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
52 } fd_set;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
53
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
54 /* standard access macros */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
55 #define FD_SET(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_CLR(n, p) \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
62 do { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
63 if ((n) < FD_SETSIZE) { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
64 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
65 } \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
66 } while (0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
67 #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
68 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
69
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
70 #define SELECT_TYPE fd_set
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
71 #define MAXDESC FD_SETSIZE
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
72
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
73 #endif /* 0 */
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
74
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
75 /* ------------------------------------------------------------------------- */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
76
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
77 /* child_process.status values */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
78 enum {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
79 STATUS_READ_ERROR = -1,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
80 STATUS_READ_READY,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
81 STATUS_READ_IN_PROGRESS,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
82 STATUS_READ_FAILED,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
83 STATUS_READ_SUCCEEDED,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
84 STATUS_READ_ACKNOWLEDGED
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
85 };
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
86
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
87 /* This structure is used for both pipes and sockets; for
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
88 a socket, the process handle in pi is NULL. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
89 typedef struct _child_process
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
90 {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
91 int fd;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
92 int pid;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
93 HANDLE char_avail;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
94 HANDLE char_consumed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
95 HANDLE thrd;
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
96 HWND hwnd;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
97 PROCESS_INFORMATION procinfo;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
98 volatile int status;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
99 char chr;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
100 } child_process;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
101
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
102 #define MAX_CHILDREN MAXDESC/2
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
103 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
104
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
105 /* parallel array of private info on file handles */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
106 typedef struct
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
107 {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
108 unsigned flags;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
109 HANDLE hnd;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
110 child_process * cp;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
111 } filedesc;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
112
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
113 extern filedesc fd_info [ MAXDESC ];
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
114
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
115 /* fd_info flag definitions */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
116 #define FILE_READ 0x0001
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
117 #define FILE_WRITE 0x0002
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
118 #define FILE_BINARY 0x0010
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
119 #define FILE_LAST_CR 0x0020
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
120 #define FILE_AT_EOF 0x0040
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
121 #define FILE_SEND_SIGCHLD 0x0080
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
122 #define FILE_PIPE 0x0100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
123 #define FILE_SOCKET 0x0200
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
124
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
125 extern child_process * new_child (void);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
126 extern void delete_child (child_process *cp);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
127
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
128 /* ------------------------------------------------------------------------- */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
129
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
130 /* Get long (aka "true") form of file name, if it exists. */
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
131 extern BOOL win32_get_long_filename (char * name, char * buf, int size);
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
132
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
133 /* Prepare our standard handles for proper inheritance by child processes. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
134 extern void prepare_standard_handles (int in, int out,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
135 int err, HANDLE handles[4]);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
136
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
137 /* Reset our standard handles to their original state. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
138 extern void reset_standard_handles (int in, int out,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
139 int err, HANDLE handles[4]);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
140
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
141 /* Return the string resource associated with KEY of type TYPE. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
142 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
143
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 239
diff changeset
144 void set_process_dir (const char * dir);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 239
diff changeset
145 time_t convert_time (FILETIME ft);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 239
diff changeset
146
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
147 extern void init_ntproc ();
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
148 extern void term_ntproc ();
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
149
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
150 #endif /* _NT_H_ */