#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <ctype.h>
#include <errno.h>
#include <time.h>
return 1;
}
+char *despace(char *str)
+{
+ int chr, spaces = 1;
+ char *src = str;
+ char *dst = str;
+ while ((chr = *src++)) {
+ if (isspace(chr))
+ spaces++;
+ else
+ spaces=0;
+ if (spaces == 0)
+ *dst++ = chr;
+ if (spaces == 1)
+ *dst++ = ' ';
+ }
+ if (dst > str && spaces)
+ dst--;
+ *dst = '\0';
+ return str;
+}
+
/* Memory functions */
void *alloc0(int size)
{
int poll_add(poll_t *poll, int fd, cb_t cb, void *data)
{
struct epoll_event ctl = {
- .events = EPOLLIN | EPOLLOUT | EPOLLERR,
+ .events = EPOLLET | EPOLLIN | EPOLLOUT | EPOLLERR,
.data.ptr = poll,
};
poll->fd = fd;
int poll_ctl(poll_t *poll, int in, int out, int err)
{
struct epoll_event ctl = {
- .events = (in ? EPOLLIN : 0)
+ .events = EPOLLET
+ | (in ? EPOLLIN : 0)
| (out ? EPOLLOUT : 0)
| (err ? EPOLLERR : 0),
.data.ptr = poll,
if (count < 0)
continue;
if (count == 0)
- continue;
+ return running;
if (!(poll = event.data.ptr))
continue;
if (!(poll->cb))