1 /* -*-C-*-
2 
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts
6     Institute of Technology
7 
8 This file is part of MIT/GNU Scheme.
9 
10 MIT/GNU Scheme is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or (at
13 your option) any later version.
14 
15 MIT/GNU Scheme is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with MIT/GNU Scheme; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
23 USA.
24 
25 */
26 
27 #ifndef SCM_OSIO_H
28 #define SCM_OSIO_H
29 
30 #include "os.h"
31 
32 /* Must match definition of `channel_type_names' in "prosio.c".  */
33 enum channel_type
34 {
35   channel_type_unknown,
36   channel_type_file,
37   channel_type_unix_pipe,
38   channel_type_unix_fifo,
39   channel_type_terminal,
40   channel_type_unix_pty_master,
41   channel_type_unix_stream_socket,
42   channel_type_tcp_stream_socket,
43   channel_type_tcp_server_socket,
44   channel_type_directory,
45   channel_type_unix_character_device,
46   channel_type_unix_block_device,
47   channel_type_os2_console,
48   channel_type_os2_unnamed_pipe,
49   channel_type_os2_named_pipe,
50   channel_type_win32_anonymous_pipe,
51   channel_type_win32_named_pipe
52 };
53 
54 extern Tchannel OS_channel_table_size;
55 #define NO_CHANNEL ((Tchannel) -1)
56 extern int OS_channel_open_p (Tchannel channel);
57 extern void OS_channel_close (Tchannel channel);
58 extern void OS_channel_close_noerror (Tchannel channel);
59 extern void OS_channel_close_on_abort (Tchannel channel);
60 extern void OS_channel_synchronize (Tchannel channel);
61 extern enum channel_type OS_channel_type (Tchannel channel);
62 extern size_t OS_channel_read_load_file
63   (Tchannel channel, void * buffer, size_t nbytes);
64 extern size_t OS_channel_write_dump_file
65   (Tchannel channel, const void * buffer, size_t nbytes);
66 extern long OS_channel_read
67   (Tchannel channel, void * buffer, size_t nbytes);
68 extern long OS_channel_write
69   (Tchannel channel, const void * buffer, size_t nbytes);
70 extern void OS_channel_write_string
71   (Tchannel channel, const char * string);
72 extern void OS_make_pipe
73   (Tchannel * readerp, Tchannel * writerp);
74 extern int OS_channel_nonblocking_p (Tchannel channel);
75 extern void OS_channel_nonblocking (Tchannel channel);
76 extern void OS_channel_blocking (Tchannel channel);
77 
78 /* Interface to poll(2) or select(2) */
79 
80 #ifdef __WIN32__
81 extern int OS_have_select_p;
82 #else
83 extern const int OS_have_select_p;
84 #endif
85 
86 typedef void * select_registry_t;
87 #define SELECT_MODE_READ 1
88 #define SELECT_MODE_WRITE 2
89 #define SELECT_MODE_ERROR 4
90 #define SELECT_MODE_HUP 8
91 
92 #define SELECT_INTERRUPT (-1)
93 #define SELECT_PROCESS_STATUS_CHANGE (-2)
94 
95 extern select_registry_t OS_allocate_select_registry
96   (void);
97 extern void OS_deallocate_select_registry
98   (select_registry_t registry);
99 extern void OS_add_to_select_registry
100   (select_registry_t registry, int fd, unsigned int mode);
101 extern void OS_remove_from_select_registry
102   (select_registry_t registry, int fd, unsigned int mode);
103 extern unsigned int OS_select_registry_length
104   (select_registry_t registry);
105 extern void OS_select_registry_result
106   (select_registry_t registry, unsigned int index,
107     int * fd_r, unsigned int * mode_r);
108 extern int OS_test_select_registry
109   (select_registry_t registry, int blockp);
110 extern int OS_test_select_descriptor
111   (int fd, int blockp, unsigned int mode);
112 extern int OS_pause (void);
113 
114 #endif /* SCM_OSIO_H */
115