annotate src/nt.h @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents e11d67e05968
children b8cc9ab3f761
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 /* Support routines for the NT version of XEmacs.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2 Copyright (C) 1994 Free Software Foundation, Inc.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
3
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
4 This file is part of XEmacs.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
5
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
9 later version.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
10
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
14 for more details.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
15
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
20
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
21 /* 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
22 /* 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
23
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
24 /* #define FULL_DEBUG */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
25
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
26 #ifndef INCLUDED_nt_h_
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
27 #define INCLUDED_nt_h_
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
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
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
37 #ifdef X_OK
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
38 #undef X_OK
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
39 #endif
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
40 #define X_OK 1
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
41 #define F_OK 0
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
42
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
43 /* File descriptor set emulation. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
44
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
45 #if 0 /* These are defined in winsock.h.
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
46 FD_SETSIZE is defined 64. Let's not full the runtime. */
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
47
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
48 /* The MSVC multithreaded statically-linked runtime library has limit
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
49 of 256 descriptors by default (the single-threaded static library
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
50 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
51 limit of 512). Beware. Should this be set to 512? */
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
52 #define FD_SETSIZE 256
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
53 typedef struct {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
54 unsigned int bits[FD_SETSIZE / 32];
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
55 } fd_set;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
56
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
57 /* standard access macros */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
58 #define FD_SET(n, p) \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
59 do { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
60 if ((n) < FD_SETSIZE) { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
61 (p)->bits[(n)/32] |= (1 << (n)%32); \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
62 } \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
63 } while (0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
64 #define FD_CLR(n, p) \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
65 do { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
66 if ((n) < FD_SETSIZE) { \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
67 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
68 } \
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
69 } while (0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
70 #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
71 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
72
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
73 #define SELECT_TYPE fd_set
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
74 #define MAXDESC FD_SETSIZE
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
75
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 211
diff changeset
76 #endif /* 0 */
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
77
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
78 /* ------------------------------------------------------------------------- */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
79
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
80 /* child_process.status values */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
81 enum {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
82 STATUS_READ_ERROR = -1,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
83 STATUS_READ_READY,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
84 STATUS_READ_IN_PROGRESS,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
85 STATUS_READ_FAILED,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
86 STATUS_READ_SUCCEEDED,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
87 STATUS_READ_ACKNOWLEDGED
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
88 };
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
89
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
90 /* This structure is used for both pipes and sockets; for
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
91 a socket, the process handle in pi is NULL. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
92 typedef struct _child_process
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
93 {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
94 int fd;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
95 int pid;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
96 HANDLE char_avail;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
97 HANDLE char_consumed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
98 HANDLE thrd;
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
99 HWND hwnd;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
100 PROCESS_INFORMATION procinfo;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
101 volatile int status;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
102 char chr;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
103 } child_process;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
104
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
105 #define MAX_CHILDREN MAXDESC/2
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
106 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
107
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
108 /* parallel array of private info on file handles */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
109 typedef struct
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
110 {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
111 unsigned flags;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
112 HANDLE hnd;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
113 child_process * cp;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
114 } filedesc;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
115
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
116 extern filedesc fd_info [ MAXDESC ];
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
117
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
118 /* fd_info flag definitions */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
119 #define FILE_READ 0x0001
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
120 #define FILE_WRITE 0x0002
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
121 #define FILE_BINARY 0x0010
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
122 #define FILE_LAST_CR 0x0020
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
123 #define FILE_AT_EOF 0x0040
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
124 #define FILE_SEND_SIGCHLD 0x0080
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
125 #define FILE_PIPE 0x0100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
126 #define FILE_SOCKET 0x0200
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
127
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
128 extern child_process * new_child (void);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
129 extern void delete_child (child_process *cp);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
130
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
131 /* ------------------------------------------------------------------------- */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
132
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
133 /* Get long (aka "true") form of file name, if it exists. */
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 100
diff changeset
134 extern BOOL win32_get_long_filename (char * name, char * buf, int size);
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
135
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
136 /* Prepare our standard handles for proper inheritance by child processes. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
137 extern void prepare_standard_handles (int in, int out,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
138 int err, HANDLE handles[4]);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
139
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
140 /* Reset our standard handles to their original state. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
141 extern void reset_standard_handles (int in, int out,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
142 int err, HANDLE handles[4]);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
143
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
144 /* Return the string resource associated with KEY of type TYPE. */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
145 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
146
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 239
diff changeset
147 void set_process_dir (const char * dir);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 239
diff changeset
148 time_t convert_time (FILETIME ft);
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 239
diff changeset
149
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
150 extern void init_ntproc ();
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
151 extern void term_ntproc ();
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
152
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
153 #endif /* INCLUDED_nt_h_ */