]> jfr.im git - irc/quakenet/snircd.git/blame - include/ircd_osdep.h
forward port of asuka-check.patch to .12
[irc/quakenet/snircd.git] / include / ircd_osdep.h
CommitLineData
189935b1 1/** @file ircd_osdep.h
2 * @brief Public definitions and APIs for OS-dependent operations.
3 * @version $Id: ircd_osdep.h,v 1.7 2004/09/30 03:18:15 entrope Exp $
4 */
5#ifndef INCLUDED_ircd_osdep_h
6#define INCLUDED_ircd_osdep_h
7
8struct Client;
9struct irc_sockaddr;
10struct MsgQ;
11
12/** Result of an input/output operation. */
13typedef enum IOResult {
14 IO_FAILURE = -1, /**< Serious I/O error (not due to blocking). */
15 IO_BLOCKED = 0, /**< I/O could not start because it would block. */
16 IO_SUCCESS = 1 /**< I/O succeeded. */
17} IOResult;
18
19/*
20 * NOTE: osdep.c files should never need to know the actual size of a
21 * Client struct. When passed as a parameter, the pointer just needs
22 * to be forwarded to the enumeration function.
23 */
24/** Callback function to show rusage information.
25 * @param cptr Client to receive the message.
26 * @param msg Text message to send to user.
27 */
28typedef void (*EnumFn)(struct Client* cptr, const char* msg);
29
30extern int os_disable_options(int fd);
31extern int os_get_rusage(struct Client* cptr, int uptime, EnumFn enumerator);
32extern int os_get_sockerr(int fd);
33extern int os_get_sockname(int fd, struct irc_sockaddr* sin_out);
34extern int os_get_peername(int fd, struct irc_sockaddr* sin_out);
35extern int os_socket(const struct irc_sockaddr* local, int type, const char* port_name);
36extern int os_accept(int fd, struct irc_sockaddr* peer);
37extern IOResult os_sendto_nonb(int fd, const char* buf, unsigned int length,
38 unsigned int* length_out, unsigned int flags,
39 const struct irc_sockaddr* peer);
40extern IOResult os_recv_nonb(int fd, char* buf, unsigned int length,
41 unsigned int* length_out);
42extern IOResult os_send_nonb(int fd, const char* buf, unsigned int length,
43 unsigned int* length_out);
44extern IOResult os_sendv_nonb(int fd, struct MsgQ* buf,
45 unsigned int* len_in, unsigned int* len_out);
46extern IOResult os_recvfrom_nonb(int fd, char* buf, unsigned int len,
47 unsigned int* length_out,
48 struct irc_sockaddr* from_out);
49extern IOResult os_connect_nonb(int fd, const struct irc_sockaddr* sin);
50extern int os_set_fdlimit(unsigned int max_descriptors);
51extern int os_set_listen(int fd, int backlog);
52extern int os_set_nonblocking(int fd);
53extern int os_set_reuseaddr(int fd);
54extern int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize);
55extern int os_set_tos(int fd,int tos);
56
57#endif /* INCLUDED_ircd_osdep_h */
58