1 /*	$NetBSD: iostuff.h,v 1.2 2017/02/14 01:16:49 christos Exp $	*/
2 
3 #ifndef _IOSTUFF_H_INCLUDED_
4 #define _IOSTUFF_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	iostuff 3h
9 /* SUMMARY
10 /*	miscellaneous I/O primitives
11 /* SYNOPSIS
12 /*	#include <iostuff.h>
13 /* DESCRIPTION
14 
15  /*
16   * External interface.
17   */
18 extern int non_blocking(int, int);
19 extern int close_on_exec(int, int);
20 extern int open_limit(int);
21 extern int poll_fd(int, int, int, int, int);
22 extern off_t get_file_limit(void);
23 extern void set_file_limit(off_t);
24 extern ssize_t peekfd(int);
25 extern ssize_t write_buf(int, const char *, ssize_t, int);
26 extern ssize_t timed_read(int, void *, size_t, int, void *);
27 extern ssize_t timed_write(int, const void *, size_t, int, void *);
28 extern void doze(unsigned);
29 extern void rand_sleep(unsigned, unsigned);
30 extern int duplex_pipe(int *);
31 extern int stream_recv_fd(int);
32 extern int stream_send_fd(int, int);
33 extern int unix_recv_fd(int);
34 extern int unix_send_fd(int, int);
35 extern ssize_t dummy_read(int, void *, size_t, int, void *);
36 extern ssize_t dummy_write(int, void *, size_t, int, void *);
37 
38 #define readable(fd)		poll_fd((fd), POLL_FD_READ, 0, 1, 0)
39 #define writable(fd)		poll_fd((fd), POLL_FD_WRITE, 0, 1, 0)
40 
41 #define read_wait(fd, timeout) poll_fd((fd), POLL_FD_READ, (timeout), 0, -1)
42 #define write_wait(fd, timeout) poll_fd((fd), POLL_FD_WRITE, (timeout), 0, -1)
43 
44 extern int inet_windowsize;
45 extern void set_inet_windowsize(int, int);
46 
47 #define POLL_FD_READ	0
48 #define POLL_FD_WRITE	1
49 
50 #define BLOCKING	0
51 #define NON_BLOCKING	1
52 
53 #define CLOSE_ON_EXEC	1
54 #define PASS_ON_EXEC	0
55 
56 extern int unix_pass_fd_fix;
57 extern void set_unix_pass_fd_fix(const char *);
58 
59 #define UNIX_PASS_FD_FIX_NONE		(0)
60 #define UNIX_PASS_FD_FIX_CMSG_LEN	(1<<0)
61 
62 /* LICENSE
63 /* .ad
64 /* .fi
65 /*	The Secure Mailer license must be distributed with this software.
66 /* AUTHOR(S)
67 /*	Wietse Venema
68 /*	IBM T.J. Watson Research
69 /*	P.O. Box 704
70 /*	Yorktown Heights, NY 10598, USA
71 /* CREATION DATE
72 /*	Sat Jan 25 16:54:13 EST 1997
73 /*--*/
74 
75 #endif
76