1 | /* files.h -- Header file for modules involved in file handle management
|
---|
2 | Copyright (c) 1994-1995 by Eberhard Mattes
|
---|
3 |
|
---|
4 | This file is part of emx.
|
---|
5 |
|
---|
6 | emx is free software; you can redistribute it and/or modify it
|
---|
7 | under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | emx is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with emx; see the file COPYING. If not, write to
|
---|
18 | the Free Software Foundation, 59 Temple Place - Suite 330,
|
---|
19 | Boston, MA 02111-1307, USA.
|
---|
20 |
|
---|
21 | As special exception, emx.dll can be distributed without source code
|
---|
22 | unless it has been changed. If you modify emx.dll, this exception
|
---|
23 | no longer applies and you must remove this paragraph from all source
|
---|
24 | files for emx.dll. */
|
---|
25 |
|
---|
26 |
|
---|
27 | /* Requires INCL_DOSDEVIOCTL! */
|
---|
28 |
|
---|
29 | #define ASYNC_SETEXTBAUDRATE 0x0043
|
---|
30 | #define ASYNC_GETEXTBAUDRATE 0x0063
|
---|
31 |
|
---|
32 | typedef struct
|
---|
33 | {
|
---|
34 | ULONG ulCurrentRate;
|
---|
35 | BYTE bCurrentFract;
|
---|
36 | ULONG ulMinimumRate;
|
---|
37 | BYTE bMinimumFract;
|
---|
38 | ULONG ulMaximumRate;
|
---|
39 | BYTE bMaximumFract;
|
---|
40 | } GETEXTBAUDRATE;
|
---|
41 | typedef GETEXTBAUDRATE *PGETEXTBAUDRATE;
|
---|
42 |
|
---|
43 | typedef struct
|
---|
44 | {
|
---|
45 | ULONG ulRate;
|
---|
46 | BYTE bFract;
|
---|
47 | } SETEXTBAUDRATE;
|
---|
48 | typedef SETEXTBAUDRATE *PSETEXTBAUDRATE;
|
---|
49 |
|
---|
50 |
|
---|
51 | #define SET_INVALID_FILE(handle) (handle_file[handle] = handle_count)
|
---|
52 | #define IS_VALID_FILE(handle) (handle_file[handle] < handle_count)
|
---|
53 | #define GET_FILE(handle) (&files[handle_file[handle]])
|
---|
54 |
|
---|
55 |
|
---|
56 | typedef struct
|
---|
57 | {
|
---|
58 | ULONG flags;
|
---|
59 | ULONG ref_count;
|
---|
60 |
|
---|
61 | /* termio interface */
|
---|
62 |
|
---|
63 | ULONG c_iflag;
|
---|
64 | ULONG c_oflag;
|
---|
65 | ULONG c_cflag;
|
---|
66 | ULONG c_lflag;
|
---|
67 | UCHAR c_cc[11]; /* NCC == 8, NCCS == 11 */
|
---|
68 |
|
---|
69 | /* termio implementation */
|
---|
70 |
|
---|
71 | char *tio_buf;
|
---|
72 | unsigned tio_buf_count;
|
---|
73 | unsigned tio_buf_size;
|
---|
74 | unsigned tio_buf_idx;
|
---|
75 | char tio_escape;
|
---|
76 | ULONG tio_input_handle;
|
---|
77 | ULONG tio_output_handle;
|
---|
78 |
|
---|
79 | /* Data which depends on the file type. */
|
---|
80 |
|
---|
81 | union
|
---|
82 | {
|
---|
83 | struct
|
---|
84 | {
|
---|
85 | GETEXTBAUDRATE speed;
|
---|
86 | LINECONTROL lctl;
|
---|
87 | DCBINFO dcb;
|
---|
88 | } async;
|
---|
89 | struct
|
---|
90 | {
|
---|
91 | int handle;
|
---|
92 | int fd_flags; /* FD_CLOEXEC */
|
---|
93 | } socket;
|
---|
94 | struct
|
---|
95 | {
|
---|
96 | ULONG id; /* ID returned by XF86SUP_DRVID */
|
---|
97 | HEV sem; /* Semaphore handle */
|
---|
98 | BYTE sem_open; /* Semaphore handle valid */
|
---|
99 | } xf86sup; /* xf86sup device */
|
---|
100 | } x;
|
---|
101 | } my_file;
|
---|
102 |
|
---|
103 |
|
---|
104 | extern ULONG handle_count;
|
---|
105 | extern ULONG *handle_flags;
|
---|
106 | extern ULONG *handle_file;
|
---|
107 | extern my_file *files;
|
---|
108 | extern long ino_number;
|
---|
109 | extern HMTX files_access;
|
---|
110 |
|
---|
111 |
|
---|
112 | /* Duplicate S_IREAD, S_IWRITE, and S_IEXEC bits into all three groups
|
---|
113 | of the permission mask. */
|
---|
114 |
|
---|
115 | #define MAKEPERM(x) (((x) >> 6) * 0111)
|
---|
116 |
|
---|
117 | #define IS_SOCKET(h) ((h) < handle_count && (handle_flags[h] & HF_SOCKET))
|
---|
118 |
|
---|
119 |
|
---|
120 | /* `handle_flags' array is protected by a Mutex semaphore. These
|
---|
121 | macros are used for requesting and releasing that semaphore. */
|
---|
122 |
|
---|
123 | #define LOCK_FILES request_mutex (files_access)
|
---|
124 | #define UNLOCK_FILES DosReleaseMutexSem (files_access)
|
---|
125 |
|
---|
126 | void alloc_file_description (ULONG handle);
|
---|
127 | void close_handle (ULONG handle);
|
---|
128 | void set_handle_flags (ULONG handle, ULONG flags);
|
---|
129 | int find_unused_handles (ULONG *dst, int count);
|
---|