Commit | Line | Data |
---|---|---|
e588809c JR |
1 | #ifndef EMACS_W32_H |
2 | #define EMACS_W32_H | |
b3fa71dc | 3 | |
95ed0025 RS |
4 | /* Support routines for the NT version of Emacs. |
5 | Copyright (C) 1994 Free Software Foundation, Inc. | |
6 | ||
7 | This file is part of GNU Emacs. | |
8 | ||
9 | GNU Emacs is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2, or (at your option) | |
12 | any later version. | |
13 | ||
14 | GNU Emacs is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with GNU Emacs; see the file COPYING. If not, write to | |
3b7ad313 EN |
21 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 | Boston, MA 02111-1307, USA. */ | |
95ed0025 | 23 | |
7482f2ec | 24 | |
b3fa71dc GV |
25 | /* File descriptor set emulation. */ |
26 | ||
27 | /* MSVC runtime library has limit of 64 descriptors by default */ | |
28 | #define FD_SETSIZE 64 | |
29 | typedef struct { | |
30 | unsigned int bits[FD_SETSIZE / 32]; | |
31 | } fd_set; | |
32 | ||
33 | /* standard access macros */ | |
34 | #define FD_SET(n, p) \ | |
35 | do { \ | |
36 | if ((n) < FD_SETSIZE) { \ | |
37 | (p)->bits[(n)/32] |= (1 << (n)%32); \ | |
38 | } \ | |
39 | } while (0) | |
40 | #define FD_CLR(n, p) \ | |
41 | do { \ | |
42 | if ((n) < FD_SETSIZE) { \ | |
43 | (p)->bits[(n)/32] &= ~(1 << (n)%32); \ | |
44 | } \ | |
45 | } while (0) | |
46 | #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0) | |
47 | #define FD_ZERO(p) memset((p), 0, sizeof(fd_set)) | |
48 | ||
95ed0025 | 49 | #define SELECT_TYPE fd_set |
95ed0025 | 50 | |
b3fa71dc GV |
51 | /* ------------------------------------------------------------------------- */ |
52 | ||
53 | /* child_process.status values */ | |
54 | enum { | |
55 | STATUS_READ_ERROR = -1, | |
56 | STATUS_READ_READY, | |
57 | STATUS_READ_IN_PROGRESS, | |
58 | STATUS_READ_FAILED, | |
59 | STATUS_READ_SUCCEEDED, | |
60 | STATUS_READ_ACKNOWLEDGED | |
61 | }; | |
62 | ||
63 | /* This structure is used for both pipes and sockets; for | |
64 | a socket, the process handle in pi is NULL. */ | |
65 | typedef struct _child_process | |
66 | { | |
67 | int fd; | |
68 | int pid; | |
69 | HANDLE char_avail; | |
70 | HANDLE char_consumed; | |
71 | HANDLE thrd; | |
bb06745d | 72 | HWND hwnd; |
b3fa71dc GV |
73 | PROCESS_INFORMATION procinfo; |
74 | volatile int status; | |
75 | char chr; | |
76 | } child_process; | |
77 | ||
78 | #define MAXDESC FD_SETSIZE | |
79 | #define MAX_CHILDREN MAXDESC/2 | |
80 | #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL) | |
81 | ||
82 | /* parallel array of private info on file handles */ | |
83 | typedef struct | |
84 | { | |
85 | unsigned flags; | |
86 | HANDLE hnd; | |
87 | child_process * cp; | |
88 | } filedesc; | |
89 | ||
90 | extern filedesc fd_info [ MAXDESC ]; | |
91 | ||
92 | /* fd_info flag definitions */ | |
ead2be98 GV |
93 | #define FILE_READ 0x0001 |
94 | #define FILE_WRITE 0x0002 | |
95 | #define FILE_BINARY 0x0010 | |
96 | #define FILE_LAST_CR 0x0020 | |
97 | #define FILE_AT_EOF 0x0040 | |
98 | #define FILE_SEND_SIGCHLD 0x0080 | |
99 | #define FILE_PIPE 0x0100 | |
100 | #define FILE_SOCKET 0x0200 | |
2c0c4d35 | 101 | #define FILE_NDELAY 0x0400 |
b3fa71dc GV |
102 | |
103 | extern child_process * new_child (void); | |
104 | extern void delete_child (child_process *cp); | |
105 | ||
106 | /* ------------------------------------------------------------------------- */ | |
107 | ||
7482f2ec AI |
108 | /* Equivalent of strerror for W32 error codes. */ |
109 | extern char * w32_strerror (int error_no); | |
110 | ||
bb06745d GV |
111 | /* Get long (aka "true") form of file name, if it exists. */ |
112 | extern BOOL w32_get_long_filename (char * name, char * buf, int size); | |
95ed0025 RS |
113 | |
114 | /* Prepare our standard handles for proper inheritance by child processes. */ | |
177c0ea7 | 115 | extern void prepare_standard_handles (int in, int out, |
95ed0025 RS |
116 | int err, HANDLE handles[4]); |
117 | ||
118 | /* Reset our standard handles to their original state. */ | |
177c0ea7 | 119 | extern void reset_standard_handles (int in, int out, |
95ed0025 RS |
120 | int err, HANDLE handles[4]); |
121 | ||
46c91229 | 122 | /* Return the string resource associated with KEY of type TYPE. */ |
fbd6baed | 123 | extern LPBYTE w32_get_resource (char * key, LPDWORD type); |
b3fa71dc GV |
124 | |
125 | extern void init_ntproc (); | |
126 | extern void term_ntproc (); | |
9785d95b | 127 | extern void globals_of_w32 (); |
f60ae425 BK |
128 | extern void syms_of_w32term (); |
129 | extern void syms_of_w32fns (); | |
9785d95b | 130 | extern void globals_of_w32fns (); |
f60ae425 BK |
131 | extern void syms_of_w32select (); |
132 | extern void syms_of_w32menu (); | |
9785d95b | 133 | extern void globals_of_w32menu (); |
f60ae425 | 134 | extern void syms_of_fontset (); |
46c91229 | 135 | |
e588809c | 136 | #endif /* EMACS_W32_H */ |
ab5796a9 MB |
137 | |
138 | /* arch-tag: 02c36b00-312b-4c4d-a1d9-f905c5e968f0 | |
139 | (do not change this comment) */ |