ReactOS  0.4.14-dev-57-g333b8f1
sio.h
Go to the documentation of this file.
1 /* sio.h */
2 
3 #ifndef _sio_h_
4 #define _sio_h_ 1
5 
6 typedef struct SelectSet {
8  struct timeval timeout;
9  int maxfd;
10  int numfds;
12 
13 /* For SReadline */
14 #ifndef _SReadlineInfo_
15 #define _SReadlineInfo_ 1
16 typedef struct SReadlineInfo {
17  char *buf; /* Pointer to beginning of buffer. */
18  char *bufPtr; /* Pointer to current position in buffer. */
19  char *bufLim; /* Pointer to end of buffer. */
20  size_t bufSize; /* Current size of buffer block. */
21  size_t bufSizeMax; /* Maximum size available for buffer. */
22  int malloc; /* If non-zero, malloc() was used for buf. */
23  int fd; /* File descriptor to use for I/O. */
24  int timeoutLen; /* Timeout to use, in seconds. */
25  int requireEOLN; /* When buffer is full, continue reading and discarding until \n? */
27 #endif
28 
29 #ifndef forever
30 # define forever for ( ; ; )
31 #endif
32 
33 /* Private decl; only for use when compiling sio code. */
34 #ifdef HAVE_SIGSETJMP
35 # define SSetjmp(a) sigsetjmp(a, 1)
36 # define SLongjmp(a,b) siglongjmp(a, b)
37 # define Sjmp_buf sigjmp_buf
38 #else
39 # define SSetjmp(a) setjmp(a)
40 # define SLongjmp(a,b) longjmp(a, b)
41 # define Sjmp_buf jmp_buf
42 #endif
43 
44 /* Parameter to SBind */
45 #define kReUseAddrYes 1
46 #define kReUseAddrNo 0
47 
48 /* Parameter to SRead/SWrite */
49 #define kFullBufferNotRequired 00000
50 #define kFullBufferRequired 00001
51 #define kFullBufferRequiredExceptLast 00002
52 #define kNoFirstSelect 00010
53 
54 /* Parameter to AddrToAddrStr */
55 #define kUseDNSYes 1
56 #define kUseDNSNo 0
57 
58 #define kTimeoutErr (-2)
59 #define kBrokenPipeErr (-3)
60 
61 #define kAddrStrToAddrMiscErr (-4)
62 #define kAddrStrToAddrBadHost (-5)
63 
64 #define kSNewFailed (-6)
65 #define kSBindFailed (-7)
66 #define kSListenFailed (-8)
67 
68 #define kSrlBufSize 2048
69 
70 #define kNoTimeLimit 0
71 
72 #if 1 /* %config2% -- set by configure script -- do not modify */
73 # ifndef NO_SIGNALS
74 # define NO_SIGNALS 1
75 # endif
76 #else
77  /* #undef NO_SIGNALS */
78 #endif
79 
80 /* Don't change the following line -- it is modified by the Configure script. */
81 #define SAccept SAcceptS
82 
83 #ifndef SAccept
84 # if defined(NO_SIGNALS) || defined(WIN32) || defined(_WINDOWS)
85 # define SAccept SAcceptS
86 # else
87 # define SAccept SAcceptA
88 # endif
89 #endif
90 
91 #if !defined(ETIMEDOUT) && defined(WSAETIMEDOUT)
92 # define ETIMEDOUT WSAETIMEDOUT
93 #endif
94 
95 #if !defined(EADDRNOTAVAIL) && defined(WSAEADDRNOTAVAIL)
96 # define EADDRNOTAVAIL WSAEADDRNOTAVAIL
97 #endif
98 
99 #if !defined(EWOULDBLOCK) && defined(WSAEWOULDBLOCK)
100 # define EWOULDBLOCK WSAEWOULDBLOCK
101 #endif
102 
103 #if !defined(EINPROGRESS) && defined(WSAEINPROGRESS)
104 # define EINPROGRESS WSAEINPROGRESS
105 #endif
106 
107 #if !defined(WIN32) && !defined(_WINDOWS) && !defined(closesocket)
108 # define closesocket close
109 #endif
110 
111 #if !defined(WIN32) && !defined(_WINDOWS) && !defined(ioctlsocket)
112 # define ioctlsocket ioctl
113 #endif
114 
115 #if defined(WIN32) || defined(_WINDOWS)
116 # define SETERRNO errno = WSAGetLastError();
117 # define SETWSATIMEOUTERR WSASetLastError(WSAETIMEDOUT);
118 #else
119 # define SETERRNO
120 # define SETWSATIMEOUTERR
121 #endif
122 
123 typedef void (*sio_sigproc_t)(int);
124 typedef volatile sio_sigproc_t vsio_sigproc_t;
125 
126 #ifdef __cplusplus
127 extern "C" {
128 #endif
129 
130 #ifndef _sio_main_c
132 #endif
133 
134 #if (defined(__GNUC__)) && (__GNUC__ >= 2)
135 # ifndef UNUSED
136 # define UNUSED(a) a __attribute__ ((unused))
137 # endif
138 # define LIBSIO_USE_VAR(a)
139 #else
140 # define LIBSIO_USE_VAR(a) gLibSio_Uses_Me_To_Quiet_Variable_Unused_Warnings = (a == 0)
141 # ifndef UNUSED
142 # define UNUSED(a) a
143 # endif
144 #endif
145 
146 /* PRead.c */
147 int PRead(int, char *const, size_t, int);
148 
149 /* PWrite.c */
150 int PWrite(int, const char *const, size_t);
151 
152 /* SAcceptA.c */
153 int SAcceptA(int, struct sockaddr_in *const, int);
154 
155 /* SAcceptS.c */
156 int SAcceptS(int, struct sockaddr_in *const, int);
157 
158 /* SBind.c */
159 int SBind(int, const int, const int, const int);
160 int SListen(int, int);
161 
162 /* SClose.c */
163 int SClose(int, int);
164 
165 /* SConnect.c */
166 int SConnect(int, const struct sockaddr_in *const, int);
167 
168 /* SConnectByName.c */
169 int SConnectByName(int, const char *const, const int);
170 
171 /* SNew.c */
172 int SNewStreamClient(void);
173 int SNewDatagramClient(void);
174 int SNewStreamServer(const int, const int, const int, int);
175 int SNewDatagramServer(const int, const int, const int);
176 
177 /* SRead.c */
178 int SRead(int, char *const, size_t, int, int);
179 
180 /* SReadline.c */
182 int InitSReadlineInfo(SReadlineInfo *, int, char *, size_t, int, int);
184 int SReadline(SReadlineInfo *, char *const, size_t);
185 
186 /* SRecv.c */
187 int SRecv(int, char *const, size_t, int, int, int);
188 
189 /* SRecvfrom.c */
190 int SRecvfrom(int, char *const, size_t, int, struct sockaddr_in *const, int);
191 
192 /* SRecvmsg.c */
193 int SRecvmsg(int, void *const, int, int);
194 
195 /* SSelect.c */
196 void SelectSetInit(SelectSetPtr const, const double);
197 void SelectSetAdd(SelectSetPtr const, const int);
198 void SelectSetRemove(SelectSetPtr const, const int);
201 
202 /* SSend.c */
203 int SSend(int, char *, size_t, int, int);
204 
205 /* SSendto.c */
206 int SSendto(int, const char *const, size_t, int, const struct sockaddr_in *const, int);
207 int Sendto(int, const char *const, size_t, const struct sockaddr_in *const);
208 
209 /* SSendtoByName.c */
210 int SSendtoByName(int, const char *const, size_t, int, const char *const, int);
211 int SendtoByName(int, const char *const, size_t, const char *const);
212 
213 /* SWait.c */
214 int SWaitUntilReadyForReading(const int sfd, const int tlen);
215 int SWaitUntilReadyForWriting(const int sfd, const int tlen);
216 
217 /* SWrite.c */
218 int SWrite(int, const char *const, size_t, int, int);
219 
220 /* SocketUtil.c */
221 int GetSocketBufSize(int, size_t *const, size_t *const);
222 int SetSocketBufSize(int, size_t, size_t);
223 int GetSocketNagleAlgorithm(const int);
224 int SetSocketNagleAlgorithm(const int, const int);
225 int GetSocketLinger(const int, int *const);
226 int SetSocketLinger(const int, const int, const int);
227 
228 /* StrAddr.c */
229 int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int);
230 char *AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in * const saddrp, int dns, const char *fmt);
231 
232 /* SError.c */
233 const char *SError(int e);
234 
235 /* main.c */
236 void SIOHandler(int);
237 void (*SSignal(int signum, void (*handler)(int)))(int);
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 
243 #endif /* _sio_h_ */
void SelectSetInit(SelectSetPtr const, const double)
Definition: SSelect.c:4
void DisposeSReadlineInfo(SReadlineInfo *)
Definition: SReadline.c:57
Definition: winsock.h:66
size_t bufSizeMax
Definition: ncftp.h:105
int GetSocketBufSize(int, size_t *const, size_t *const)
int SAcceptS(int, struct sockaddr_in *const, int)
Definition: SAcceptS.c:4
int SNewStreamClient(void)
Definition: SNew.c:4
int SendtoByName(int, const char *const, size_t, const char *const)
int SClose(int, int)
Definition: SClose.c:9
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
int maxfd
Definition: sio.h:9
volatile sio_sigproc_t vsio_sigproc_t
Definition: sio.h:124
int InitSReadlineInfo(SReadlineInfo *, int, char *, size_t, int, int)
Definition: SReadline.c:24
int Sendto(int, const char *const, size_t, const struct sockaddr_in *const)
Definition: SSendto.c:127
Definition: dhcpd.h:245
struct SReadlineInfo SReadlineInfo
int SSendto(int, const char *const, size_t, int, const struct sockaddr_in *const, int)
Definition: SSendto.c:68
int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int)
Definition: StrAddr.c:54
int SWaitUntilReadyForReading(const int sfd, const int tlen)
Definition: SWait.c:7
int requireEOLN
Definition: ncftp.h:109
int SWaitUntilReadyForWriting(const int sfd, const int tlen)
Definition: SWait.c:62
void FlushSReadlineInfo(SReadlineInfo *)
Definition: SReadline.c:4
int SetSocketNagleAlgorithm(const int, const int)
#define e
Definition: ke_i.h:82
struct SelectSet * SelectSetPtr
int SWrite(int, const char *const, size_t, int, int)
Definition: SWrite.c:90
int numfds
Definition: sio.h:10
struct SelectSet SelectSet
int SReadline(SReadlineInfo *, char *const, size_t)
Definition: SReadline.c:76
int SetSocketLinger(const int, const int, const int)
int timeoutLen
Definition: ncftp.h:108
int SNewDatagramClient(void)
Definition: SNew.c:19
void SelectSetRemove(SelectSetPtr const, const int)
Definition: SSelect.c:37
int SRecvfrom(int, char *const, size_t, int, struct sockaddr_in *const, int)
Definition: SRecvfrom.c:69
int SNewStreamServer(const int, const int, const int, int)
Definition: SNew.c:34
char * bufLim
Definition: ncftp.h:103
int SListen(int, int)
Definition: SBind.c:60
const char * SError(int e)
Definition: SError.c:141
int SSend(int, char *, size_t, int, int)
Definition: SSend.c:90
int malloc
Definition: ncftp.h:106
int PRead(int, char *const, size_t, int)
Definition: PRead.c:19
Definition: sio.h:6
char * AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in *const saddrp, int dns, const char *fmt)
Definition: StrAddr.c:136
int gLibSio_Uses_Me_To_Quiet_Variable_Unused_Warnings
Definition: main.c:4
void(*)(int) SSignal(int signum, void(*handler)(int))
Definition: sio.h:237
GLenum GLenum dst
Definition: glext.h:6340
size_t bufSize
Definition: ncftp.h:104
int GetSocketLinger(const int, int *const)
char * buf
Definition: ncftp.h:101
char * bufPtr
Definition: ncftp.h:102
int SSendtoByName(int, const char *const, size_t, int, const char *const, int)
Definition: SSendtoByName.c:73
int GetSocketNagleAlgorithm(const int)
int SConnect(int, const struct sockaddr_in *const, int)
Definition: SConnect.c:9
int SetSocketBufSize(int, size_t, size_t)
int SAcceptA(int, struct sockaddr_in *const, int)
Definition: SAcceptA.c:9
void SelectSetAdd(SelectSetPtr const, const int)
Definition: SSelect.c:23
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
int SRecv(int, char *const, size_t, int, int, int)
Definition: SRecv.c:97
int SNewDatagramServer(const int, const int, const int)
Definition: SNew.c:64
int SRecvmsg(int, void *const, int, int)
int SConnectByName(int, const char *const, const int)
Definition: SConnectByName.c:4
Definition: dsound.c:943
int PWrite(int, const char *const, size_t)
Definition: PWrite.c:7
void(* sio_sigproc_t)(int)
Definition: sio.h:123
int SelectW(SelectSetPtr, SelectSetPtr)
Definition: SSelect.c:51
int SelectR(SelectSetPtr, SelectSetPtr)
Definition: SSelect.c:65
void SIOHandler(int)
int SRead(int, char *const, size_t, int, int)
Definition: SRead.c:118
int SBind(int, const int, const int, const int)
Definition: SBind.c:4
fd_set fds
Definition: sio.h:7
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31