ReactOS 0.4.16-dev-88-ga65b6ae
sio.h
Go to the documentation of this file.
1/* sio.h */
2
3#ifndef _sio_h_
4#define _sio_h_ 1
5
6typedef struct SelectSet {
9 int maxfd;
10 int numfds;
12
13/* For SReadline */
14#ifndef _SReadlineInfo_
15#define _SReadlineInfo_ 1
16typedef 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
125
126#ifdef __cplusplus
127extern "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 */
147int PRead(int, char *const, size_t, int);
148
149/* PWrite.c */
150int PWrite(int, const char *const, size_t);
151
152/* SAcceptA.c */
153int SAcceptA(int, struct sockaddr_in *const, int);
154
155/* SAcceptS.c */
156int SAcceptS(int, struct sockaddr_in *const, int);
157
158/* SBind.c */
159int SBind(int, const int, const int, const int);
160int SListen(int, int);
161
162/* SClose.c */
163int SClose(int, int);
164
165/* SConnect.c */
166int SConnect(int, const struct sockaddr_in *const, int);
167
168/* SConnectByName.c */
169int SConnectByName(int, const char *const, const int);
170
171/* SNew.c */
172int SNewStreamClient(void);
173int SNewDatagramClient(void);
174int SNewStreamServer(const int, const int, const int, int);
175int SNewDatagramServer(const int, const int, const int);
176
177/* SRead.c */
178int SRead(int, char *const, size_t, int, int);
179
180/* SReadline.c */
182int InitSReadlineInfo(SReadlineInfo *, int, char *, size_t, int, int);
184int SReadline(SReadlineInfo *, char *const, size_t);
185
186/* SRecv.c */
187int SRecv(int, char *const, size_t, int, int, int);
188
189/* SRecvfrom.c */
190int SRecvfrom(int, char *const, size_t, int, struct sockaddr_in *const, int);
191
192/* SRecvmsg.c */
193int SRecvmsg(int, void *const, int, int);
194
195/* SSelect.c */
196void SelectSetInit(SelectSetPtr const, const double);
197void SelectSetAdd(SelectSetPtr const, const int);
198void SelectSetRemove(SelectSetPtr const, const int);
201
202/* SSend.c */
203int SSend(int, char *, size_t, int, int);
204
205/* SSendto.c */
206int SSendto(int, const char *const, size_t, int, const struct sockaddr_in *const, int);
207int Sendto(int, const char *const, size_t, const struct sockaddr_in *const);
208
209/* SSendtoByName.c */
210int SSendtoByName(int, const char *const, size_t, int, const char *const, int);
211int SendtoByName(int, const char *const, size_t, const char *const);
212
213/* SWait.c */
214int SWaitUntilReadyForReading(const int sfd, const int tlen);
215int SWaitUntilReadyForWriting(const int sfd, const int tlen);
216
217/* SWrite.c */
218int SWrite(int, const char *const, size_t, int, int);
219
220/* SocketUtil.c */
221int GetSocketBufSize(int, size_t *const, size_t *const);
222int SetSocketBufSize(int, size_t, size_t);
224int SetSocketNagleAlgorithm(const int, const int);
225int GetSocketLinger(const int, int *const);
226int SetSocketLinger(const int, const int, const int);
227
228/* StrAddr.c */
229int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int);
230char *AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in * const saddrp, int dns, const char *fmt);
231
232/* SError.c */
233const char *SError(int e);
234
235/* main.c */
236void SIOHandler(int);
237void (*SSignal(int signum, void (*handler)(int)))(int);
238
239#ifdef __cplusplus
240}
241#endif
242
243#endif /* _sio_h_ */
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLenum GLenum dst
Definition: glext.h:6340
#define e
Definition: ke_i.h:82
void SIOHandler(int)
int SetSocketBufSize(int, size_t, size_t)
int SSend(int, char *, size_t, int, int)
Definition: SSend.c:90
int SetSocketNagleAlgorithm(const int, const int)
int SAcceptA(int, struct sockaddr_in *const, int)
Definition: SAcceptA.c:9
void SelectSetRemove(SelectSetPtr const, const int)
Definition: SSelect.c:37
int SNewDatagramClient(void)
Definition: SNew.c:19
int SRecv(int, char *const, size_t, int, int, int)
Definition: SRecv.c:97
const char * SError(int e)
Definition: SError.c:141
int SConnectByName(int, const char *const, const int)
Definition: SConnectByName.c:4
void FlushSReadlineInfo(SReadlineInfo *)
Definition: SReadline.c:4
void SelectSetAdd(SelectSetPtr const, const int)
Definition: SSelect.c:23
int PWrite(int, const char *const, size_t)
Definition: PWrite.c:7
int Sendto(int, const char *const, size_t, const struct sockaddr_in *const)
Definition: SSendto.c:127
int SConnect(int, const struct sockaddr_in *const, int)
Definition: SConnect.c:9
struct SelectSet * SelectSetPtr
int SSendtoByName(int, const char *const, size_t, int, const char *const, int)
Definition: SSendtoByName.c:73
int SWrite(int, const char *const, size_t, int, int)
Definition: SWrite.c:90
int SRecvmsg(int, void *const, int, int)
int PRead(int, char *const, size_t, int)
Definition: PRead.c:19
int GetSocketBufSize(int, size_t *const, size_t *const)
int SNewDatagramServer(const int, const int, const int)
Definition: SNew.c:64
char * AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in *const saddrp, int dns, const char *fmt)
Definition: StrAddr.c:136
int SRecvfrom(int, char *const, size_t, int, struct sockaddr_in *const, int)
Definition: SRecvfrom.c:69
void DisposeSReadlineInfo(SReadlineInfo *)
Definition: SReadline.c:57
int GetSocketNagleAlgorithm(const int)
int GetSocketLinger(const int, int *const)
volatile sio_sigproc_t vsio_sigproc_t
Definition: sio.h:124
int SBind(int, const int, const int, const int)
Definition: SBind.c:4
void(*)(int) SSignal(int signum, void(*handler)(int))
Definition: sio.h:237
int SListen(int, int)
Definition: SBind.c:60
int SNewStreamClient(void)
Definition: SNew.c:4
int SendtoByName(int, const char *const, size_t, const char *const)
int SNewStreamServer(const int, const int, const int, int)
Definition: SNew.c:34
int SetSocketLinger(const int, const int, const int)
int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int)
Definition: StrAddr.c:54
int SReadline(SReadlineInfo *, char *const, size_t)
Definition: SReadline.c:76
int SClose(int, int)
Definition: SClose.c:9
int SWaitUntilReadyForReading(const int sfd, const int tlen)
Definition: SWait.c:7
int InitSReadlineInfo(SReadlineInfo *, int, char *, size_t, int, int)
Definition: SReadline.c:24
int SelectR(SelectSetPtr, SelectSetPtr)
Definition: SSelect.c:65
int SRead(int, char *const, size_t, int, int)
Definition: SRead.c:118
int gLibSio_Uses_Me_To_Quiet_Variable_Unused_Warnings
Definition: main.c:4
int SWaitUntilReadyForWriting(const int sfd, const int tlen)
Definition: SWait.c:62
void(* sio_sigproc_t)(int)
Definition: sio.h:123
int SelectW(SelectSetPtr, SelectSetPtr)
Definition: SSelect.c:51
int SAcceptS(int, struct sockaddr_in *const, int)
Definition: SAcceptS.c:4
void SelectSetInit(SelectSetPtr const, const double)
Definition: SSelect.c:4
int SSendto(int, const char *const, size_t, int, const struct sockaddr_in *const, int)
Definition: SSendto.c:68
char * bufLim
Definition: ncftp.h:103
char * bufPtr
Definition: ncftp.h:102
int timeoutLen
Definition: ncftp.h:108
size_t bufSize
Definition: ncftp.h:104
size_t bufSizeMax
Definition: ncftp.h:105
char * buf
Definition: ncftp.h:101
int requireEOLN
Definition: ncftp.h:109
int malloc
Definition: ncftp.h:106
Definition: sio.h:6
int numfds
Definition: sio.h:10
int maxfd
Definition: sio.h:9
fd_set fds
Definition: sio.h:7
Definition: winsock.h:66
Definition: dsound.c:943
Definition: dhcpd.h:245