Differences From
Artifact [247977844e]:
1 1 #ifndef KIio
2 2 #define KIio
3 +/* <k/io.h>
4 + * ~ lexi hale <lexi@hale.su>
5 + * this header declares IO primitive functions and
6 + * structures. it is the same for all platforms.
7 + * platform-specific code is found in the *.platform.h
8 + * files.
9 + */
10 +
11 +#include <k/type.h>
12 +
13 +typedef enum kiostream_kind {
14 + kiostream_closed,
15 + // this kiostream cannot be written to
16 + kiostream_file,
17 + // this kiostream represents a file
18 + kiostream_sock,
19 + // this kiostream is attached to a socket,
20 + // UNIX, IP, or otherwise
21 + kiostream_term,
22 + // this socket is being used to communicate
23 + // directly with a human being
24 + kiostream_ansi,
25 + // like kiostream_term, but can also understand
26 + // ANSI control codes
27 + kiostream_other
28 + // no fuckin idea
29 +} kiostream_kind;
30 +
31 +typedef struct kiostream {
32 + kiostream_kind kind;
33 + #include "kiostream.platform.h"
34 +} kiostream;
35 +
36 +typedef struct kiochan {
37 + kiostream in;
38 + // text can be read from this stream
39 + kiostream out;
40 + // text can be written to this stream
41 +} kiochan;
42 +
43 +unsigned long long kiosend(kiochan); // send data to a channel
44 +unsigned long long kiorecv(kiochan); // receive data from a channel
45 +
46 +typedef enum kiocond {
47 + kiocond_ok,
48 + // success
49 + kiocond_fail,
50 + // action failed
51 +} kiocond;
3 52
4 53 #endif