-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestscript.c
54 lines (47 loc) · 1.24 KB
/
testscript.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
#include <stdio.h> // fopen & co
#include <stdlib.h> // free
#include <assert.h>
#include "log.h"
#include "entrelacs/entrelacs.h"
#include "entrelacs/entrelacsm.h"
static Arrow printCB(Arrow arrow, Arrow context) {
fprintf(stderr, "%O\n", arrow);
return arrow;
}
int main(int argc, char **argv) {
FILE* fd;
char buffer[1024];
log_init(NULL, "server,session,machine,space=debug");
xl_init();
xl_begin();
DEFATOM(root);
DEFATOM(childrenOf);
DEFATOM(unroot);
fd = fopen("testrc", "r");
assert(fd);
while (fgets(buffer, 1024, fd)) {
Arrow a = uri(buffer);
fprintf(stderr, "%s assimilated as %O\n", buffer, a);
Arrow command = head(a);
Arrow arg = tail(a);
if (command == root) {
fprintf(stderr, "rooting %O\n", arg);
root(arg);
commit();
} else if (command == unroot) {
fprintf(stderr, "unrooting %O\n", arg);
unroot(arg);
commit();
} else if (command == childrenOf) {
fprintf(stderr, "childrenOf %O\n", arg);
fprintf(stderr, " ==> {\n");
childrenOfCB(arg, printCB, EVE);
fprintf(stderr, "}\n");
} else {
fprintf(stderr, "Unknown command: %O", command);
assert(1);
}
}
xl_over();
return EXIT_SUCCESS;
}