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
|
implement Export,Mainmodule;
include "sys.m";
sys: Sys;
include "draw.m";
include "sh.m";
include "alphabet/reports.m";
reports: Reports;
Report, report: import reports;
include "alphabet.m";
alphabet: Alphabet;
Value: import alphabet;
Export: module {};
typesig(): string
{
return "ws";
}
init()
{
sys = load Sys Sys->PATH;
alphabet = load Alphabet Alphabet->PATH;
reports = load Reports Reports->PATH;
}
quit()
{
}
run(nil: ref Draw->Context, r: ref Reports->Report, nil: chan of string,
nil: list of (int, list of ref Alphabet->Value),
args: list of ref Alphabet->Value): ref Alphabet->Value
{
w := chan of ref Sys->FD;
addr := (hd args).s().i;
f := chan of ref Sys->FD;
spawn exportproc(f, (hd args).s().i, r.start("export"));
return ref Value.Vw(f);
}
exportproc(f: chan of ref Sys->FD, dir: string, errorc: chan of string)
{
f <-= nil;
fd := <-f;
if(fd == nil)
reports->quit(errorc);
errorc <-= nil;
if(sys->export(fd, dir, Sys->EXPASYNC) == -1)
report(errorc, sys->sprint("cannot export: %r"));
reports->quit(errorc);
}
|