1 
2 /*-
3  *
4  * New BSD License 2006
5  *
6  * Copyright (c) 2006, Jorgen Lundman
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are
11  * met:
12  *
13  * 1 Redistributions of source code must retain the above copyright
14  *   notice, this list of conditions and the following disclaimer.
15  * 2 Redistributions in binary form must reproduce the above
16  *   copyright notice, this list of conditions and the following
17  *   disclaimer in the documentation and/or other materials provided
18  *   with the distribution.
19  * 3 Neither the name of the stuff nor the names of its contributors
20  *   may be used to endorse or promote products derived from this
21  *   software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  */
36 
37 // $Id: io.h,v 1.10 2006/06/30 01:22:58 lundman Exp $
38 // Core input output functions, the main select() call and misc connectivity
39 // Jorgen Lundman November 9th, 1999
40 // Copyright (c) 1999 HotGen Studios Ltd <www.hotgen.com>
41 
42 #ifndef IO_H
43 #define IO_H
44 
45 
46 /* Includes */
47 
48 #include <sys/types.h>
49 #include <time.h>
50 
51 #ifdef WIN32
52 #define WINDOWS_LEAN_AND_MEAN
53 #include <winsock.h>
54 #else
55 #include <unistd.h>
56 #endif
57 
58 
59 
60 /* Defines   */
61 
62 #define  IO_TIMEOUT_USEC    0
63 #define  IO_TIMEOUT_SEC     30
64 
65 
66 #define IO_READFD  1
67 #define IO_WRITEFD 2
68 #define IO_BOTH    (IO_READFD | IO_WRITEFD)
69 
70 
71 
72 /* Variables */
73 extern time_t io_global_time;
74 
75 
76 
77 
78 //extern THREAD_SAFE time_t io_global_time;
79 THREAD_SAFE extern int io_force_loop;
80 
81 
82 /* Functions */
83 
84 int  io_add_to_fdset( int, int);
85 //int  io_loop(void);
86 void io_set_fdset( fd_set *fdset_read, fd_set *fdset_write );
87 void io_process_fdset( fd_set *fdset_read, fd_set *fdset_write );
88 
89 void io_set_fdsetread( int );
90 void io_set_fdsetwrite( int );
91 int  io_isset_fdsetread( int );
92 int  io_isset_fdsetwrite( int );
93 int  io_near_full( void );
94 
95 int  io_input           ( connection_t *);
96 int  io_getline         ( connection_t *, char **);
97 
98 int io_set_fdset_sub    ( connection_t *, void *, void *);
99 int io_process_fdset_sub( connection_t *, void *, void *);
100 int io_purge_sub        ( connection_t *, void *, void *);
101 void io_pushread(void);
102 int io_passbinary(connection_t *);
103 void io_process_rate( void );
104 
105 void io_release_all( connection_t * );
106 
107 #ifdef WIN32
108 int io_isset_fdset( connection_t *, int);
109 void io_set_fdset_win32 ( connection_t *, int);
110 
111 #endif
112 
113 
114 #endif
115 
116 
117 
118 
119