opened
paulofaria
username_0
I'm not sure about the naming. `mfile` could be named `file`, but I think that's dangerous. The functions could be renamed to `mfopen`, `mfclose`, `mftell`, etc.. though.

Submitted under MIT/X11 license
add file wrapper
issue
created
sustrik
username_1
Merged. Thanks!

In the subsequent patch I've removed all attach/detach functions from tcp/unix/udp/file.
comment
created
sustrik
username_1
Tested on Linux, OSX and FreeBSD.
comment
created
sustrik
username_1
FYI, I've tried using stdin in non-blocking way and it seems to work ok both on Linux and FreeBSD:

```
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <poll.h>
#include <unistd.h>

int main(void) {

    int flags = fcntl(STDIN_FILENO, F_GETFL, 0);
    assert(flags != -1);
    flags |= O_NONBLOCK;
    flags = fcntl(STDIN_FILENO, F_SETFL, flags) != -1;
    assert(flags != -1);

    while(1) {
        struct pollfd pfd = {STDIN_FILENO, POLLIN, 0};
        int rc = poll(&pfd, 1, -1);
        assert(rc == 1);
        assert(pfd.revents == POLLIN);

        char buf[1024];
        ssize_t sz = read(STDIN_FILENO, buf, sizeof(buf));
        assert(sz >= 0);
        printf("%d\n", (int)sz);
        if(sz == 0)
            break;
    }
    return 0;
}
```
comment
created
sustrik
username_1
I've committed a simple implementation of mfin, mfout and mferr. Feel free to comment, complain, ridicule...
comment