rework langinfo code for ABI compat and for use by time code
[musl] / src / stdio / __fopen_rb_ca.c
1 #include "stdio_impl.h"
2 #include <fcntl.h>
3 #include <string.h>
4
5 FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t len)
6 {
7         memset(f, 0, sizeof *f);
8
9         f->fd = syscall(SYS_open, filename, O_RDONLY|O_LARGEFILE|O_CLOEXEC, 0);
10         if (f->fd < 0) return 0;
11
12         f->flags = F_NOWR | F_PERM;
13         f->buf = buf + UNGET;
14         f->buf_size = len - UNGET;
15         f->read = __stdio_read;
16         f->seek = __stdio_seek;
17         f->close = __stdio_close;
18         f->lock = -1;
19
20         return f;
21 }