-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathio.c
62 lines (52 loc) · 832 Bytes
/
io.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* PLATOTERM for Plan 9
*
* A PLATO terminal for services such as
* CYBER1.ORG and IRATA.ONLINE
*
* Author: Thomas Cherryhomes
*
* License: GPL 3.0
*
* io.c - I/O functions
*/
#include <u.h>
#include <libc.h>
#include "io.h"
#include "protocol.h"
#define TRUE 1
#define FALSE 0
int buflen;
int net;
extern int done;
/**
* io_init() - Set-up the I/O
*/
void io_init(char* hostname, char* port)
{
net = dial(netmkaddr(hostname,"tcp",port),0,0,0);
if (net < 0)
done=TRUE;
}
/**
* io_send_byte(b) - Send specified byte out
*/
void io_send_byte(unsigned char b)
{
write(net, &b, 1);
}
/**
* io_main() - The IO event
*/
void io_main(uchar *data, int n)
{
ShowPLATO((padByte *)data,n);
}
/**
* io_done() - Called to close I/O
*/
void io_done()
{
close(net);
}