diff options
Diffstat (limited to 'appl/alphabet/main/export.b')
| -rw-r--r-- | appl/alphabet/main/export.b | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/appl/alphabet/main/export.b b/appl/alphabet/main/export.b new file mode 100644 index 00000000..5e9b986e --- /dev/null +++ b/appl/alphabet/main/export.b @@ -0,0 +1,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); +} |
