* process.h (PSET): Remove.
[emacs.git] / src / w32.h
blob73d57a65a4a4e74f7c0567c1db857e5a4478f0a5
1 #ifndef EMACS_W32_H
2 #define EMACS_W32_H
4 /* Support routines for the NT version of Emacs.
5 Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc.
7 This file is part of GNU Emacs.
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 3 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23 /* File descriptor set emulation. */
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;
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))
47 #define SELECT_TYPE fd_set
49 /* ------------------------------------------------------------------------- */
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
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
65 int fd;
66 int pid;
67 HANDLE char_avail;
68 HANDLE char_consumed;
69 HANDLE thrd;
70 HWND hwnd;
71 PROCESS_INFORMATION procinfo;
72 volatile int status;
73 char chr;
74 OVERLAPPED ovl_read;
75 OVERLAPPED ovl_write;
76 } child_process;
78 #define MAXDESC FD_SETSIZE
79 #define MAX_CHILDREN MAXDESC/2
80 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
82 /* parallel array of private info on file handles */
83 typedef struct
85 unsigned flags;
86 HANDLE hnd;
87 child_process * cp;
88 } filedesc;
90 extern filedesc fd_info [ MAXDESC ];
92 /* fd_info flag definitions */
93 #define FILE_READ 0x0001
94 #define FILE_WRITE 0x0002
95 #define FILE_LISTEN 0x0004
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
102 #define FILE_NDELAY 0x0400
103 #define FILE_SERIAL 0x0800
105 extern child_process * new_child (void);
106 extern void delete_child (child_process *cp);
108 /* ------------------------------------------------------------------------- */
110 /* Equivalent of strerror for W32 error codes. */
111 extern char * w32_strerror (int error_no);
113 /* Validate a pointer. */
114 extern int w32_valid_pointer_p (void *, int);
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);
119 /* Prepare our standard handles for proper inheritance by child processes. */
120 extern void prepare_standard_handles (int in, int out,
121 int err, HANDLE handles[4]);
123 /* Reset our standard handles to their original state. */
124 extern void reset_standard_handles (int in, int out,
125 int err, HANDLE handles[4]);
127 /* Return the string resource associated with KEY of type TYPE. */
128 extern LPBYTE w32_get_resource (char * key, LPDWORD type);
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);
142 extern void syms_of_w32font (void);
143 extern void check_windows_init_file (void);
145 extern int _sys_read_ahead (int fd);
146 extern int _sys_wait_accept (int fd);
148 extern Lisp_Object Vlibrary_cache, QCloaded_from;
149 extern HMODULE w32_delayed_load (Lisp_Object, Lisp_Object);
151 #ifdef HAVE_GNUTLS
152 #include <gnutls/gnutls.h>
154 /* GnuTLS pull (read from remote) interface. */
155 extern ssize_t emacs_gnutls_pull (gnutls_transport_ptr_t p,
156 void* buf, size_t sz);
158 /* GnuTLS push (write to remote) interface. */
159 extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p,
160 const void* buf, size_t sz);
161 #endif /* HAVE_GNUTLS */
163 #endif /* EMACS_W32_H */