source: azure_iot_hub/trunk/musl-1.1.18/src/stdio/fopen.c@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 605 bytes
Line 
1#include "stdio_impl.h"
2#include <fcntl.h>
3#include <string.h>
4#include <errno.h>
5
6FILE *fopen(const char *restrict filename, const char *restrict mode)
7{
8 FILE *f;
9 int fd;
10 int flags;
11
12 /* Check for valid initial mode character */
13 if (!strchr("rwa", *mode)) {
14 errno = EINVAL;
15 return 0;
16 }
17
18 /* Compute the flags to pass to open() */
19 flags = __fmodeflags(mode);
20
21 fd = sys_open(filename, flags, 0666);
22 if (fd < 0) return 0;
23 if (flags & O_CLOEXEC)
24 __syscall(SYS_fcntl, fd, F_SETFD, FD_CLOEXEC);
25
26 f = __fdopen(fd, mode);
27 if (f) return f;
28
29 __syscall(SYS_close, fd);
30 return 0;
31}
32
33LFS64(fopen);
Note: See TracBrowser for help on using the repository browser.