1
0
mirror of https://github.com/CPunch/Laika.git synced 2025-10-14 03:20:26 +00:00

Inital commit

lib/ is just [FoxNet](https://git.openpunk.com/CPunch/FoxNet) ported to C99
This commit is contained in:
2022-01-23 21:28:16 -06:00
commit 8133a8d3cb
24 changed files with 1939 additions and 0 deletions

43
lib/include/lpolllist.h Normal file
View File

@@ -0,0 +1,43 @@
#ifndef LAIKA_POLLLIST_H
#define LAIKA_POLLLIST_H
#include "laika.h"
#include "lsocket.h"
#include "hashmap.h"
/* number of pollFDs or epollFDs we expect to start with */
#define POLLSTARTCAP 8
struct sLaika_pollEvent {
struct sLaika_socket *sock;
bool pollIn;
bool pollOut;
};
struct sLaika_pollList {
struct hashmap *sockets;
struct sLaika_pollEvent *revents;
#ifdef LAIKA_USE_EPOLL
/* epoll */
struct epoll_event ev, ep_events[MAX_EPOLL_EVENTS];
SOCKET epollfd;
#else
/* raw poll descriptor */
PollFD *fds;
int fdCapacity;
int fdCount;
#endif
int reventCapacity;
int reventCount;
};
void laikaP_initPList(struct sLaika_pollList *pList);
void laikaP_cleanPList(struct sLaika_pollList *pList); /* free's all members */
void laikaP_addSock(struct sLaika_pollList *pList, struct sLaika_socket *sock);
void laikaP_rmvSock(struct sLaika_pollList *pList, struct sLaika_socket *sock);
void laikaP_addPollOut(struct sLaika_pollList *pList, struct sLaika_socket *sock);
void laikaP_rmvPollOut(struct sLaika_pollList *pList, struct sLaika_socket *sock);
struct sLaika_pollEvent *laikaP_poll(struct sLaika_pollList *pList, int timeout, int *nevents);
#endif