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 #error "w32.h is not compatible with Cygwin"
29 /* File descriptor set emulation. */
31 /* MSVC runtime library has limit of 64 descriptors by default */
34 unsigned int bits
[FD_SETSIZE
/ 32];
37 /* standard access macros */
38 #define FD_SET(n, p) \
40 if ((n) < FD_SETSIZE) { \
41 (p)->bits[(n)/32] |= (1 << (n)%32); \
44 #define FD_CLR(n, p) \
46 if ((n) < FD_SETSIZE) { \
47 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
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))
53 #define SELECT_TYPE fd_set
55 /* ------------------------------------------------------------------------- */
57 /* child_process.status values */
59 STATUS_READ_ERROR
= -1,
61 STATUS_READ_IN_PROGRESS
,
63 STATUS_READ_SUCCEEDED
,
64 STATUS_READ_ACKNOWLEDGED
67 /* This structure is used for both pipes and sockets; for
68 a socket, the process handle in pi is NULL. */
69 typedef struct _child_process
77 PROCESS_INFORMATION procinfo
;
84 #define MAXDESC FD_SETSIZE
85 #define MAX_CHILDREN MAXDESC/2
86 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
88 /* parallel array of private info on file handles */
96 extern filedesc fd_info
[ MAXDESC
];
98 /* fd_info flag definitions */
99 #define FILE_READ 0x0001
100 #define FILE_WRITE 0x0002
101 #define FILE_LISTEN 0x0004
102 #define FILE_BINARY 0x0010
103 #define FILE_LAST_CR 0x0020
104 #define FILE_AT_EOF 0x0040
105 #define FILE_SEND_SIGCHLD 0x0080
106 #define FILE_PIPE 0x0100
107 #define FILE_SOCKET 0x0200
108 #define FILE_NDELAY 0x0400
109 #define FILE_SERIAL 0x0800
111 extern child_process
* new_child (void);
112 extern void delete_child (child_process
*cp
);
114 /* ------------------------------------------------------------------------- */
116 /* Equivalent of strerror for W32 error codes. */
117 extern char * w32_strerror (int error_no
);
119 /* Validate a pointer. */
120 extern int w32_valid_pointer_p (void *, int);
122 /* Get long (aka "true") form of file name, if it exists. */
123 extern BOOL
w32_get_long_filename (char * name
, char * buf
, int size
);
125 /* Prepare our standard handles for proper inheritance by child processes. */
126 extern void prepare_standard_handles (int in
, int out
,
127 int err
, HANDLE handles
[4]);
129 /* Reset our standard handles to their original state. */
130 extern void reset_standard_handles (int in
, int out
,
131 int err
, HANDLE handles
[4]);
133 /* Return the string resource associated with KEY of type TYPE. */
134 extern LPBYTE
w32_get_resource (char * key
, LPDWORD type
);
136 extern void init_ntproc (int);
137 extern void term_ntproc (int);
138 extern void globals_of_w32 (void);
140 extern void term_timers (void);
141 extern void init_timers (void);
143 extern int _sys_read_ahead (int fd
);
144 extern int _sys_wait_accept (int fd
);
146 extern Lisp_Object QCloaded_from
;
147 extern HMODULE
w32_delayed_load (Lisp_Object
);
149 extern void init_environment (char **);
150 extern void check_windows_init_file (void);
151 extern void syms_of_ntproc (void);
152 extern void syms_of_ntterm (void);
153 extern void dostounix_filename (register char *);
154 extern void unixtodos_filename (register char *);
155 extern BOOL
init_winsock (int load_now
);
156 extern void srandom (int);
157 extern int random (void);
159 extern int sys_pipe (int *);
161 extern void set_process_dir (char *);
162 extern int sys_spawnve (int, char *, char **, char **);
163 extern void register_child (int, int);
165 extern void sys_sleep (int);
166 extern char *getwd (char *);
167 extern int sys_link (const char *, const char *);
172 #include <gnutls/gnutls.h>
174 /* GnuTLS pull (read from remote) interface. */
175 extern ssize_t
emacs_gnutls_pull (gnutls_transport_ptr_t p
,
176 void* buf
, size_t sz
);
178 /* GnuTLS push (write to remote) interface. */
179 extern ssize_t
emacs_gnutls_push (gnutls_transport_ptr_t p
,
180 const void* buf
, size_t sz
);
181 #endif /* HAVE_GNUTLS */
183 #endif /* EMACS_W32_H */