Commit | Line | Data |
---|---|---|
e588809c JR |
1 | #ifndef EMACS_W32_H |
2 | #define EMACS_W32_H | |
b3fa71dc | 3 | |
95ed0025 | 4 | /* Support routines for the NT version of Emacs. |
acaf905b | 5 | Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. |
95ed0025 RS |
6 | |
7 | This file is part of GNU Emacs. | |
8 | ||
b9b1cc14 | 9 | GNU Emacs is free software: you can redistribute it and/or modify |
95ed0025 | 10 | it under the terms of the GNU General Public License as published by |
b9b1cc14 GM |
11 | the Free Software Foundation, either version 3 of the License, or |
12 | (at your option) any later version. | |
95ed0025 RS |
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 | |
b9b1cc14 | 20 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
95ed0025 | 21 | |
7482f2ec | 22 | |
b3fa71dc GV |
23 | /* File descriptor set emulation. */ |
24 | ||
25 | /* MSVC runtime library has limit of 64 descriptors by default */ | |
26 | #define FD_SETSIZE 64 | |
27 | typedef struct { | |
28 | unsigned int bits[FD_SETSIZE / 32]; | |
29 | } fd_set; | |
30 | ||
31 | /* standard access macros */ | |
32 | #define FD_SET(n, p) \ | |
33 | do { \ | |
34 | if ((n) < FD_SETSIZE) { \ | |
35 | (p)->bits[(n)/32] |= (1 << (n)%32); \ | |
36 | } \ | |
37 | } while (0) | |
38 | #define FD_CLR(n, p) \ | |
39 | do { \ | |
40 | if ((n) < FD_SETSIZE) { \ | |
41 | (p)->bits[(n)/32] &= ~(1 << (n)%32); \ | |
42 | } \ | |
43 | } while (0) | |
44 | #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0) | |
45 | #define FD_ZERO(p) memset((p), 0, sizeof(fd_set)) | |
46 | ||
95ed0025 | 47 | #define SELECT_TYPE fd_set |
95ed0025 | 48 | |
b3fa71dc GV |
49 | /* ------------------------------------------------------------------------- */ |
50 | ||
51 | /* child_process.status values */ | |
52 | enum { | |
53 | STATUS_READ_ERROR = -1, | |
54 | STATUS_READ_READY, | |
55 | STATUS_READ_IN_PROGRESS, | |
56 | STATUS_READ_FAILED, | |
57 | STATUS_READ_SUCCEEDED, | |
58 | STATUS_READ_ACKNOWLEDGED | |
59 | }; | |
60 | ||
61 | /* This structure is used for both pipes and sockets; for | |
62 | a socket, the process handle in pi is NULL. */ | |
63 | typedef struct _child_process | |
64 | { | |
65 | int fd; | |
66 | int pid; | |
67 | HANDLE char_avail; | |
68 | HANDLE char_consumed; | |
69 | HANDLE thrd; | |
bb06745d | 70 | HWND hwnd; |
b3fa71dc GV |
71 | PROCESS_INFORMATION procinfo; |
72 | volatile int status; | |
73 | char chr; | |
d888760c GM |
74 | OVERLAPPED ovl_read; |
75 | OVERLAPPED ovl_write; | |
b3fa71dc GV |
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 | |
d18f316e | 95 | #define FILE_LISTEN 0x0004 |
ead2be98 GV |
96 | #define FILE_BINARY 0x0010 |
97 | #define FILE_LAST_CR 0x0020 | |
98 | #define FILE_AT_EOF 0x0040 | |
99 | #define FILE_SEND_SIGCHLD 0x0080 | |
100 | #define FILE_PIPE 0x0100 | |
101 | #define FILE_SOCKET 0x0200 | |
2c0c4d35 | 102 | #define FILE_NDELAY 0x0400 |
d888760c | 103 | #define FILE_SERIAL 0x0800 |
b3fa71dc GV |
104 | |
105 | extern child_process * new_child (void); | |
106 | extern void delete_child (child_process *cp); | |
107 | ||
108 | /* ------------------------------------------------------------------------- */ | |
109 | ||
7482f2ec AI |
110 | /* Equivalent of strerror for W32 error codes. */ |
111 | extern char * w32_strerror (int error_no); | |
112 | ||
0c5c0e3d EZ |
113 | /* Validate a pointer. */ |
114 | extern int w32_valid_pointer_p (void *, int); | |
115 | ||
bb06745d GV |
116 | /* Get long (aka "true") form of file name, if it exists. */ |
117 | extern BOOL w32_get_long_filename (char * name, char * buf, int size); | |
95ed0025 RS |
118 | |
119 | /* Prepare our standard handles for proper inheritance by child processes. */ | |
177c0ea7 | 120 | extern void prepare_standard_handles (int in, int out, |
95ed0025 RS |
121 | int err, HANDLE handles[4]); |
122 | ||
123 | /* Reset our standard handles to their original state. */ | |
177c0ea7 | 124 | extern void reset_standard_handles (int in, int out, |
95ed0025 RS |
125 | int err, HANDLE handles[4]); |
126 | ||
46c91229 | 127 | /* Return the string resource associated with KEY of type TYPE. */ |
fbd6baed | 128 | extern LPBYTE w32_get_resource (char * key, LPDWORD type); |
b3fa71dc | 129 | |
52c7f9ee JR |
130 | extern void init_ntproc (void); |
131 | extern void term_ntproc (void); | |
132 | extern void globals_of_w32 (void); | |
133 | extern void syms_of_w32term (void); | |
134 | extern void syms_of_w32fns (void); | |
135 | extern void globals_of_w32fns (void); | |
136 | extern void syms_of_w32select (void); | |
137 | extern void globals_of_w32select (void); | |
138 | extern void term_w32select (void); | |
139 | extern void syms_of_w32menu (void); | |
140 | extern void globals_of_w32menu (void); | |
141 | extern void syms_of_fontset (void); | |
db4f02f2 | 142 | extern void syms_of_w32font (void); |
46c91229 | 143 | |
c8b67880 KS |
144 | extern int _sys_read_ahead (int fd); |
145 | extern int _sys_wait_accept (int fd); | |
146 | ||
0898ca10 JB |
147 | extern Lisp_Object Vlibrary_cache, QCloaded_from; |
148 | extern HMODULE w32_delayed_load (Lisp_Object, Lisp_Object); | |
149 | ||
e061a11b TZ |
150 | #ifdef HAVE_GNUTLS |
151 | #include <gnutls/gnutls.h> | |
152 | ||
153 | /* GnuTLS pull (read from remote) interface. */ | |
154 | extern ssize_t emacs_gnutls_pull (gnutls_transport_ptr_t p, | |
155 | void* buf, size_t sz); | |
156 | ||
157 | /* GnuTLS push (write to remote) interface. */ | |
158 | extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p, | |
159 | const void* buf, size_t sz); | |
160 | #endif /* HAVE_GNUTLS */ | |
161 | ||
e588809c | 162 | #endif /* EMACS_W32_H */ |
ab5796a9 | 163 |