Debian Codegraph @

vendor/mruby-source/mrbgems/mruby-io/include/mruby/ext/io.h

raw
1 /*
2 ** io.h - IO class
3 */
4
5 #ifndef MRUBY_IO_H
6 #define MRUBY_IO_H
7
8 #include <mruby.h>
9
10 #ifdef MRB_NO_STDIO
11 # error IO and File conflicts 'MRB_NO_STDIO' in your build configuration
12 #endif
13
14 #if defined(__cplusplus)
15 extern "C" {
16 #endif
17
18 #if defined(MRB_WITHOUT_IO_PREAD_PWRITE)
19 # undef MRB_WITH_IO_PREAD_PWRITE
20 #elif !defined(MRB_WITH_IO_PREAD_PWRITE)
21 # if defined(__unix__) || defined(__MACH__)
22 # define MRB_WITH_IO_PREAD_PWRITE
23 # endif
24 #endif
25
26 #define MRB_IO_BUF_SIZE 4096
27
28 struct mrb_io_buf {
29 short start;
30 short len;
31 char mem[MRB_IO_BUF_SIZE];
32 };
33
34 struct mrb_io {
35 int fd; /* file descriptor, or -1 */
36 int fd2; /* file descriptor to write if it's different from fd, or -1 */
37 int pid; /* child's pid (for pipes) */
38 struct mrb_io_buf *buf;
39 unsigned int readable:1,
40 writable:1,
41 eof:1,
42 sync:1,
43 is_socket:1;
44 };
45
46 #define MRB_O_RDONLY 0x0000
47 #define MRB_O_WRONLY 0x0001
48 #define MRB_O_RDWR 0x0002
49 #define MRB_O_ACCMODE (MRB_O_RDONLY | MRB_O_WRONLY | MRB_O_RDWR)
50 #define MRB_O_NONBLOCK 0x0004
51 #define MRB_O_APPEND 0x0008
52 #define MRB_O_SYNC 0x0010
53 #define MRB_O_NOFOLLOW 0x0020
54 #define MRB_O_CREAT 0x0040
55 #define MRB_O_TRUNC 0x0080
56 #define MRB_O_EXCL 0x0100
57 #define MRB_O_NOCTTY 0x0200
58 #define MRB_O_DIRECT 0x0400
59 #define MRB_O_BINARY 0x0800
60 #define MRB_O_SHARE_DELETE 0x1000
61 #define MRB_O_TMPFILE 0x2000
62 #define MRB_O_NOATIME 0x4000
63 #define MRB_O_DSYNC 0x00008000
64 #define MRB_O_RSYNC 0x00010000
65
66 #define E_IO_ERROR (mrb_exc_get(mrb, "IOError"))
67 #define E_EOF_ERROR (mrb_exc_get(mrb, "EOFError"))
68
69 int mrb_io_fileno(mrb_state *mrb, mrb_value io);
70
71 #if defined(__cplusplus)
72 } /* extern "C" { */
73 #endif
74 #endif /* MRUBY_IO_H */