-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.h
More file actions
50 lines (41 loc) · 918 Bytes
/
lib.h
File metadata and controls
50 lines (41 loc) · 918 Bytes
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
#ifndef LIB_H
#define LIB_H
#define CONCAT_IMPL( x, y ) x##y
#define MAC( x, y ) CONCAT_IMPL( x, y )
#define f(function, string) int MAC(temp_macro_var, __LINE__)[] = string;function(MAC(temp_macro_var, __LINE__))
void syssend(int[] s) {
int i = 0;
while(s[i] != 0) {
write_char(s[i]);
i = i + 1;
}
}
void sysread(int[] s, int size) {
int i = 0;
int rchar = -1;
while(rchar != 0 && i < size) {
rchar = read_char();
s[i] = rchar;
i = i + 1;
}
}
int read_short() {
return read_char() * 256 + read_char();
}
void write_short(int s) {
write_char(0);
write_char(s);
}
void sysend() {
write_char(0);
}
int cmpstr(int[] a, int[] b, int checksize) {
int ia = 0;
int ib = 0;
while(a[ia]!=0 && b[ib]!=0 && a[ia] == b[ib] && ia<checksize-1) {
ia = ia + 1;
ib = ib + 1;
}
return a[ia]-b[ib];
}
#endif