1 #ifndef EMACS_W32_H
2 #define EMACS_W32_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #ifdef CYGWIN
23 #error "w32.h is not compatible with Cygwin"
24 #endif
25
26 #include <windows.h>
27
28
29
30
31
32 #define FD_SETSIZE 64
33 typedef struct {
34 unsigned int bits[FD_SETSIZE / 32];
35 } fd_set;
36
37
38 #define FD_SET(n, p) \
39 do { \
40 if ((n) < FD_SETSIZE) { \
41 (p)->bits[(n)/32] |= (1 << (n)%32); \
42 } \
43 } while (0)
44 #define FD_CLR(n, p) \
45 do { \
46 if ((n) < FD_SETSIZE) { \
47 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
48 } \
49 } while (0)
50 #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
51 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
52
53 #define SELECT_TYPE fd_set
54
55
56
57
58 enum {
59 STATUS_READ_ERROR = -1,
60 STATUS_READ_READY,
61 STATUS_READ_IN_PROGRESS,
62 STATUS_READ_FAILED,
63 STATUS_READ_SUCCEEDED,
64 STATUS_READ_ACKNOWLEDGED,
65 STATUS_CONNECT_FAILED
66 };
67
68
69
70 typedef struct _child_process
71 {
72
73
74 int fd;
75
76 int pid;
77
78
79
80
81 HANDLE char_avail;
82
83
84 HANDLE char_consumed;
85
86
87 HANDLE thrd;
88
89
90 HWND hwnd;
91
92
93
94
95
96 PROCESS_INFORMATION procinfo;
97
98
99 volatile int status;
100
101 volatile int errcode;
102
103
104 char chr;
105
106 OVERLAPPED ovl_read;
107
108 OVERLAPPED ovl_write;
109 } child_process;
110
111 #define MAXDESC FD_SETSIZE
112 #define MAX_CHILDREN MAXDESC/2
113 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
114
115
116 typedef struct
117 {
118 unsigned flags;
119 HANDLE hnd;
120 child_process * cp;
121 } filedesc;
122
123 extern filedesc fd_info [ MAXDESC ];
124
125
126 #define FILE_READ 0x0001
127 #define FILE_WRITE 0x0002
128 #define FILE_LISTEN 0x0004
129 #define FILE_CONNECT 0x0008
130 #define FILE_BINARY 0x0010
131 #define FILE_LAST_CR 0x0020
132 #define FILE_AT_EOF 0x0040
133 #define FILE_SEND_SIGCHLD 0x0080
134 #define FILE_PIPE 0x0100
135 #define FILE_SOCKET 0x0200
136 #define FILE_NDELAY 0x0400
137 #define FILE_SERIAL 0x0800
138 #define FILE_DONT_CLOSE 0x1000
139
140 extern child_process * new_child (void);
141 extern void delete_child (child_process *cp);
142
143
144
145
146 extern char * w32_strerror (int error_no);
147
148
149 extern int w32_valid_pointer_p (void *, int);
150
151
152 extern BOOL w32_get_long_filename (const char * name, char * buf, int size);
153
154
155 extern unsigned int w32_get_short_filename (const char *, char *, int);
156
157
158 extern void prepare_standard_handles (int in, int out,
159 int err, HANDLE handles[3]);
160
161
162 extern void reset_standard_handles (int in, int out,
163 int err, HANDLE handles[3]);
164
165
166
167 extern LPBYTE w32_get_resource (const char * key, const char * name, LPDWORD type);
168
169 extern void release_listen_threads (void);
170 extern void init_ntproc (int);
171 extern void term_ntproc (int);
172 extern HANDLE maybe_load_unicows_dll (void);
173 extern void globals_of_w32 (void);
174
175 extern void term_timers (void);
176 extern void init_timers (void);
177
178 extern int _sys_read_ahead (int fd);
179 extern int _sys_wait_accept (int fd);
180 extern int _sys_wait_connect (int fd);
181
182 extern HMODULE w32_delayed_load (Lisp_Object);
183
184 typedef int (WINAPI *MultiByteToWideChar_Proc)(UINT,DWORD,LPCSTR,int,LPWSTR,int);
185 typedef int (WINAPI *WideCharToMultiByte_Proc)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL);
186 extern MultiByteToWideChar_Proc pMultiByteToWideChar;
187 extern WideCharToMultiByte_Proc pWideCharToMultiByte;
188 extern DWORD multiByteToWideCharFlags;
189
190 extern char *w32_my_exename (void);
191 extern const char *w32_relocate (const char *);
192 extern char *realpath (const char *, char *);
193
194 extern void init_environment (char **);
195 extern void check_windows_init_file (void);
196 extern void syms_of_ntproc (void);
197 extern void syms_of_ntterm (void);
198 extern void dostounix_filename (register char *);
199 extern void unixtodos_filename (register char *);
200 extern const char *map_w32_filename (const char *, const char **);
201 extern int filename_from_ansi (const char *, char *);
202 extern int filename_to_ansi (const char *, char *);
203 extern int filename_from_utf16 (const wchar_t *, char *);
204 extern int filename_to_utf16 (const char *, wchar_t *);
205 extern Lisp_Object w32_get_internal_run_time (void);
206 extern void w32_init_file_name_codepage (void);
207 extern int codepage_for_filenames (CPINFO *);
208 extern Lisp_Object ansi_encode_filename (Lisp_Object);
209 extern int w32_copy_file (const char *, const char *, int, int, int);
210 extern int w32_accessible_directory_p (const char *, ptrdiff_t);
211 extern void w32_init_current_directory (void);
212
213 extern BOOL init_winsock (int load_now);
214 extern void srandom (int);
215 extern int random (void);
216
217 extern int fchmod (int, mode_t);
218 extern int sys_rename_replace (char const *, char const *, BOOL);
219 extern int pipe2 (int *, int);
220 extern void register_aux_fd (int);
221
222 extern void set_process_dir (const char *);
223 extern int sys_spawnve (int, char *, char **, char **);
224 extern void register_child (pid_t, int);
225
226 extern void sys_sleep (int);
227 extern int sys_link (const char *, const char *);
228 extern int openat (int, const char *, int, int);
229 extern int fchmodat (int, char const *, mode_t, int);
230 extern int lchmod (char const *, mode_t);
231 extern bool symlinks_supported (const char *);
232
233
234
235 extern int w32_memory_info (unsigned long long *, unsigned long long *,
236 unsigned long long *, unsigned long long *);
237
238
239 extern int w32_compare_strings (const char *, const char *, char *, int);
240
241
242 extern unsigned w32_get_nproc (void);
243
244
245 extern int w32_init_random (void *, ptrdiff_t);
246
247 extern Lisp_Object w32_read_registry (HKEY, Lisp_Object, Lisp_Object);
248
249
250 extern int w32_reexec_emacs (char *, const char *);
251
252 #ifdef HAVE_GNUTLS
253 #include <gnutls/gnutls.h>
254
255
256 extern ssize_t emacs_gnutls_pull (gnutls_transport_ptr_t p,
257 void* buf, size_t sz);
258
259
260 extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p,
261 const void* buf, size_t sz);
262 #endif
263
264 #endif