-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
61 lines (52 loc) · 1001 Bytes
/
main.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
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <libguile.h>
#include "cell.h"
#include "board.h"
int main (int argc, char **argv) {
const char *script = NULL;
const char *entry = NULL;
SCM entry_func_symbol;
SCM entry_func;
int c;
while(1) {
static struct option long_options[] =
{
{"script", required_argument, 0, 's'},
{"entry", required_argument, 0, 'e'},
{0, 0, 0, 0}
};
int opt_index;
c = getopt_long(argc, argv, "s:e:w:h:", long_options, &opt_index);
if (c == -1) {
break;
}
switch (c) {
case 0:
break;
case 's':
script = optarg;
break;
case 'e':
entry = optarg;
break;
default:
abort();
}
}
scm_init_guile();
init_cell_type();
init_board_type();
if (script) {
scm_c_primitive_load(script);
if (entry) {
entry_func_symbol = scm_c_lookup(entry);
entry_func = scm_variable_ref(entry_func_symbol);
scm_call_0(entry_func);
}
} else {
scm_shell(argc, argv);
}
return 0;
}