make unexported funcs static
[rofl0r-rocksock.git] / rocksockserver.h
blobab36e1f13b4a2b6a778708f85939b8c4bbb69d60
1 /*
2 *
3 * author: rofl0r
4 *
5 * License: LGPL 2.1+ with static linking exception
6 *
7 *
8 */
11 #ifndef _ROCKSOCKSERVER_H_
12 #define _ROCKSOCKSERVER_H_
14 #include <netdb.h>
15 #include <sys/socket.h>
16 #include <sys/select.h>
18 #if (! defined(USER_MAX_FD)) || (USER_MAX_FD > FD_SETSIZE)
19 #undef USER_MAX_FD
20 #define USER_MAX_FD FD_SETSIZE
21 #endif
23 typedef struct {
24 fd_set master;
25 int listensocket;
26 int maxfd;
27 int numfds;
28 int signalfd;
29 void* userdata;
30 long sleeptime_us;
31 } rocksockserver;
33 void rocksockserver_set_sleeptime(rocksockserver* srv, long microsecs);
34 int rocksockserver_disconnect_client(rocksockserver* srv, int client);
35 int rocksockserver_init(rocksockserver* srv, char* listenip, unsigned short port, void* userdata);
36 void rocksockserver_watch_fd(rocksockserver* srv, int newfd);
37 void rocksockserver_set_signalfd(rocksockserver* srv, int signalfd);
38 int rocksockserver_loop(rocksockserver* srv,
39 char* buf, size_t bufsize,
40 int (*on_clientconnect) (void* userdata, struct sockaddr_storage* clientaddr, int fd),
41 int (*on_clientread) (void* userdata, int fd, size_t nread),
42 int (*on_clientwantsdata) (void* userdata, int fd),
43 int (*on_clientdisconnect) (void* userdata, int fd)
46 #endif
48 //RcB: DEP "rocksockserver*.c"