~ubuntu-branches/ubuntu/trusty/musl/trusty-proposed

« back to all changes in this revision

Viewing changes to src/stdio/__fopen_rb_ca.c

  • Committer: Package Import Robot
  • Author(s): Kevin Bortis
  • Date: 2013-09-20 20:54:14 UTC
  • Revision ID: package-import@ubuntu.com-20130920205414-5b61trtmma18w58o
Tags: upstream-0.9.13
ImportĀ upstreamĀ versionĀ 0.9.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}