Initial import of libucore

This commit is contained in:
Nils O. Selåsdal
2012-10-29 23:07:32 +01:00
commit ed3866e49a
79 changed files with 6181 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#include <stdio.h>
#include <unistd.h>
#include "iomux.h"
extern struct IOMuxFD s_fd;
void stdin_read_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
{
char buf[64];
ssize_t len = read(fd->fd, buf, sizeof buf);
printf("Read %d bytes\n", len);
iomux_unregister_fd(mux, fd);
if(len > 0) {
s_fd.what = MUX_EV_READ;
iomux_register_fd(mux, &s_fd);
}
}
struct IOMuxFD s_fd = {
.fd = 0,
.what = MUX_EV_READ,
.callback = stdin_read_cb,
};
int main(int argc, char *argv[])
{
struct IOMux *mux = iomux_create(IOMUX_TYPE_DEFAULT);
iomux_register_fd(mux, &s_fd);
iomux_run(mux);
return 0;
}