FILE *fdopen_unlocked(int filedes, const char *mode) { int f=0; /* O_RDONLY, O_WRONLY or O_RDWR */ f=__stdio_parse_mode(mode); if (filedes<0) { errno=EBADF; return 0; } return __stdio_init_file(filedes,0,f); }
FILE *fopen_unlocked(const char *path, const char *mode) { int f=0; /* O_RDONLY, O_WRONLY or O_RDWR */ int fd; f=__stdio_parse_mode(mode); if ((fd=__libc_open(path,f,0666))<0) return 0; return __stdio_init_file(fd,1,f); }
FILE *fopen(const char *path, const char *mode) { // int f=0; /* O_RDONLY, O_WRONLY or O_RDWR */ int fd; // f=__stdio_parse_mode(mode); // if ((fd=open(path,f,0666)) < 0) if ((fd = open(path, 0)) < 0) return 0; return __stdio_init_file(fd, 1); }
FILE *fdopen(int filedes, const char *mode) { // int f=0; /* O_RDONLY, O_WRONLY or O_RDWR */ // f=__stdio_parse_mode(mode); if (filedes < 0) { // errno=EBADF; // TODO implement errno return 0; } return __stdio_init_file(filedes, 0); }
FILE *fsetopen( int fd, int flags, ssize_t (*_read)(int fd, void *buf, size_t sz), ssize_t (*_write)(int fd, const void *buf, size_t sz), ssize_t (*_seek)(int fd, long offset, int whence), int (*_close)(int fd) ) { FILE *fp = __stdio_init_file(fd, 1, flags); if(!fp) return 0; fsetread(fp, _read); fsetwrite(fp, _write); fsetseek(fp, _seek); fsetclose(fp, _close); return fp; }