示例#1
0
文件: file.c 项目: amitsaha/libmill
mfile mill_mferr(void) {
    static struct mill_file f = {-1, 0, 0, 0};
    if(mill_slow(f.fd < 0)) {
        mill_filetune(STDERR_FILENO);
        f.fd = STDERR_FILENO;
    }
    return &f;
}
示例#2
0
文件: file.c 项目: 0x7fffffff/Flux
mfile fileattach(int fd) {
    struct mill_file *f = malloc(sizeof(struct mill_file));
    if(!f) {
        errno = ENOMEM;
        return NULL;
    }
    mill_filetune(fd);
    f->fd = fd;
    f->ifirst = 0;
    f->ilen = 0;
    f->olen = 0;
    errno = 0;
    return f;
}
示例#3
0
文件: file.c 项目: amitsaha/libmill
mfile mfopen(const char *pathname, int flags, mode_t mode) {
    /* Open the file. */
    int fd = open(pathname, flags, mode);
    if (fd == -1)
        return NULL;
    mill_filetune(fd);

    /* Create the object. */
    struct mill_file *f = malloc(sizeof(struct mill_file));
    if(!f) {
        fdclean(fd);
        close(fd);
        errno = ENOMEM;
        return NULL;
    }
    f->fd = fd;
    f->ifirst = 0;
    f->ilen = 0;
    f->olen = 0;
    errno = 0;
    return f;
}