blob: 9542711e2901478b72b55cbc288cdd61f8f2b6df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <pthread.h>
#include "dietstdio.h"
int __stdio_parse_mode(const char *mode) {
int f=0;
for (;;) {
switch (*mode) {
case 0: return f;
case 'b': break;
case 'r': f=O_RDONLY; break;
case 'w': f=O_WRONLY|O_CREAT|O_TRUNC; break;
case 'a': f=O_WRONLY|O_CREAT|O_APPEND; break;
case '+': f=(f&(~O_WRONLY))|O_RDWR; break;
}
++mode;
}
}
|