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