2011-02-12 00:22:29 -05:00
|
|
|
#include "stdio_impl.h"
|
2012-11-08 16:39:41 -05:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
2011-02-12 00:22:29 -05:00
|
|
|
|
|
|
|
FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t len)
|
|
|
|
{
|
|
|
|
memset(f, 0, sizeof *f);
|
|
|
|
|
2012-09-29 17:59:50 -04:00
|
|
|
f->fd = syscall(SYS_open, filename, O_RDONLY|O_LARGEFILE|O_CLOEXEC, 0);
|
2011-02-12 00:22:29 -05:00
|
|
|
if (f->fd < 0) return 0;
|
|
|
|
|
|
|
|
f->flags = F_NOWR | F_PERM;
|
|
|
|
f->buf = buf + UNGET;
|
|
|
|
f->buf_size = len - UNGET;
|
|
|
|
f->read = __stdio_read;
|
|
|
|
f->seek = __stdio_seek;
|
|
|
|
f->close = __stdio_close;
|
2011-08-01 00:03:50 -04:00
|
|
|
f->lock = -1;
|
2011-02-12 00:22:29 -05:00
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|