(sys_read): Clear carriage return flag.
[bpt/emacs.git] / src / w32.h
CommitLineData
b3fa71dc
GV
1#ifndef _NT_H_
2#define _NT_H_
3
95ed0025
RS
4/* Support routines for the NT version of Emacs.
5 Copyright (C) 1994 Free Software Foundation, Inc.
6
7This file is part of GNU Emacs.
8
9GNU Emacs is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2, or (at your option)
12any later version.
13
14GNU Emacs is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU Emacs; see the file COPYING. If not, write to
3b7ad313
EN
21the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22Boston, MA 02111-1307, USA. */
95ed0025 23
b3fa71dc
GV
24/* File descriptor set emulation. */
25
26/* MSVC runtime library has limit of 64 descriptors by default */
27#define FD_SETSIZE 64
28typedef struct {
29 unsigned int bits[FD_SETSIZE / 32];
30} fd_set;
31
32/* standard access macros */
33#define FD_SET(n, p) \
34 do { \
35 if ((n) < FD_SETSIZE) { \
36 (p)->bits[(n)/32] |= (1 << (n)%32); \
37 } \
38 } while (0)
39#define FD_CLR(n, p) \
40 do { \
41 if ((n) < FD_SETSIZE) { \
42 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
43 } \
44 } while (0)
45#define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
46#define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
47
95ed0025 48#define SELECT_TYPE fd_set
95ed0025 49
b3fa71dc
GV
50/* ------------------------------------------------------------------------- */
51
52/* child_process.status values */
53enum {
54 STATUS_READ_ERROR = -1,
55 STATUS_READ_READY,
56 STATUS_READ_IN_PROGRESS,
57 STATUS_READ_FAILED,
58 STATUS_READ_SUCCEEDED,
59 STATUS_READ_ACKNOWLEDGED
60};
61
62/* This structure is used for both pipes and sockets; for
63 a socket, the process handle in pi is NULL. */
64typedef struct _child_process
65{
66 int fd;
67 int pid;
68 HANDLE char_avail;
69 HANDLE char_consumed;
70 HANDLE thrd;
bb06745d 71 HWND hwnd;
b3fa71dc
GV
72 PROCESS_INFORMATION procinfo;
73 volatile int status;
74 char chr;
75} child_process;
76
77#define MAXDESC FD_SETSIZE
78#define MAX_CHILDREN MAXDESC/2
79#define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
80
81/* parallel array of private info on file handles */
82typedef struct
83{
84 unsigned flags;
85 HANDLE hnd;
86 child_process * cp;
87} filedesc;
88
89extern filedesc fd_info [ MAXDESC ];
90
91/* fd_info flag definitions */
92#define FILE_READ 0x0001
93#define FILE_WRITE 0x0002
94#define FILE_BINARY 0x0010
bb06745d 95#define FILE_LAST_CR 0x0020
b3fa71dc
GV
96#define FILE_PIPE 0x0100
97#define FILE_SOCKET 0x0200
98
99extern child_process * new_child (void);
100extern void delete_child (child_process *cp);
101
102/* ------------------------------------------------------------------------- */
103
bb06745d
GV
104/* Get long (aka "true") form of file name, if it exists. */
105extern BOOL w32_get_long_filename (char * name, char * buf, int size);
95ed0025
RS
106
107/* Prepare our standard handles for proper inheritance by child processes. */
108extern void prepare_standard_handles (int in, int out,
109 int err, HANDLE handles[4]);
110
111/* Reset our standard handles to their original state. */
112extern void reset_standard_handles (int in, int out,
113 int err, HANDLE handles[4]);
114
46c91229 115/* Return the string resource associated with KEY of type TYPE. */
fbd6baed 116extern LPBYTE w32_get_resource (char * key, LPDWORD type);
b3fa71dc
GV
117
118extern void init_ntproc ();
119extern void term_ntproc ();
46c91229 120
b3fa71dc 121#endif /* _NT_H_ */