Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
99:2d83cbd90d8d | 100:4be1180a9e89 |
---|---|
1 #ifndef _NT_H_ | |
2 #define _NT_H_ | |
3 | |
4 /* Support routines for the NT version of XEmacs. | |
5 Copyright (C) 1994 Free Software Foundation, Inc. | |
6 | |
7 This file is part of XEmacs. | |
8 | |
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 | |
12 later version. | |
13 | |
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 | |
17 for more details. | |
18 | |
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. */ | |
23 | |
24 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */ | |
25 | |
26 /* #define FULL_DEBUG */ | |
27 #define EMACSDEBUG | |
28 | |
29 #ifdef EMACSDEBUG | |
30 #define DebPrint(stuff) _DebPrint stuff | |
31 #else | |
32 #define DebPrint(stuff) | |
33 #endif | |
34 | |
35 #define R_OK 4 | |
36 #define W_OK 2 | |
37 #define X_OK 1 | |
38 #define F_OK 0 | |
39 | |
40 /* File descriptor set emulation. */ | |
41 | |
42 /* MSVC runtime library has limit of 64 descriptors by default */ | |
43 #define FD_SETSIZE 64 | |
44 typedef struct { | |
45 unsigned int bits[FD_SETSIZE / 32]; | |
46 } fd_set; | |
47 | |
48 /* standard access macros */ | |
49 #define FD_SET(n, p) \ | |
50 do { \ | |
51 if ((n) < FD_SETSIZE) { \ | |
52 (p)->bits[(n)/32] |= (1 << (n)%32); \ | |
53 } \ | |
54 } while (0) | |
55 #define FD_CLR(n, p) \ | |
56 do { \ | |
57 if ((n) < FD_SETSIZE) { \ | |
58 (p)->bits[(n)/32] &= ~(1 << (n)%32); \ | |
59 } \ | |
60 } while (0) | |
61 #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0) | |
62 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set)) | |
63 | |
64 #define SELECT_TYPE fd_set | |
65 | |
66 /* ------------------------------------------------------------------------- */ | |
67 | |
68 /* child_process.status values */ | |
69 enum { | |
70 STATUS_READ_ERROR = -1, | |
71 STATUS_READ_READY, | |
72 STATUS_READ_IN_PROGRESS, | |
73 STATUS_READ_FAILED, | |
74 STATUS_READ_SUCCEEDED, | |
75 STATUS_READ_ACKNOWLEDGED | |
76 }; | |
77 | |
78 /* This structure is used for both pipes and sockets; for | |
79 a socket, the process handle in pi is NULL. */ | |
80 typedef struct _child_process | |
81 { | |
82 int fd; | |
83 int pid; | |
84 int is_dos_process; | |
85 HANDLE char_avail; | |
86 HANDLE char_consumed; | |
87 HANDLE thrd; | |
88 PROCESS_INFORMATION procinfo; | |
89 volatile int status; | |
90 char chr; | |
91 } child_process; | |
92 | |
93 #define MAXDESC FD_SETSIZE | |
94 #define MAX_CHILDREN MAXDESC/2 | |
95 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL) | |
96 | |
97 /* parallel array of private info on file handles */ | |
98 typedef struct | |
99 { | |
100 unsigned flags; | |
101 HANDLE hnd; | |
102 child_process * cp; | |
103 } filedesc; | |
104 | |
105 extern filedesc fd_info [ MAXDESC ]; | |
106 | |
107 /* fd_info flag definitions */ | |
108 #define FILE_READ 0x0001 | |
109 #define FILE_WRITE 0x0002 | |
110 #define FILE_BINARY 0x0010 | |
111 #define FILE_PIPE 0x0100 | |
112 #define FILE_SOCKET 0x0200 | |
113 | |
114 extern child_process * new_child (void); | |
115 extern void delete_child (child_process *cp); | |
116 | |
117 /* ------------------------------------------------------------------------- */ | |
118 | |
119 | |
120 /* Prepare our standard handles for proper inheritance by child processes. */ | |
121 extern void prepare_standard_handles (int in, int out, | |
122 int err, HANDLE handles[4]); | |
123 | |
124 /* Reset our standard handles to their original state. */ | |
125 extern void reset_standard_handles (int in, int out, | |
126 int err, HANDLE handles[4]); | |
127 | |
128 /* Return the string resource associated with KEY of type TYPE. */ | |
129 extern LPBYTE nt_get_resource (char * key, LPDWORD type); | |
130 | |
131 extern void init_ntproc (); | |
132 extern void term_ntproc (); | |
133 | |
134 #endif /* _NT_H_ */ |