diff options
| author | Charles Forsyth <charles.forsyth@gmail.com> | 2015-04-29 15:09:58 +0100 |
|---|---|---|
| committer | Charles Forsyth <charles.forsyth@gmail.com> | 2015-04-29 15:09:58 +0100 |
| commit | 1ac9729e9325d84db36c04b5cda3b5b1bc0d041f (patch) | |
| tree | 9437907d92b84f72b1d94686396d1b068f68bb60 /appl | |
| parent | 170ff9d45744c9a94d26be32709fb3f616ba141a (diff) | |
convert to use Dial module
Diffstat (limited to 'appl')
| -rw-r--r-- | appl/cmd/dial.b | 15 | ||||
| -rw-r--r-- | appl/lib/dhcpclient.b | 8 |
2 files changed, 16 insertions, 7 deletions
diff --git a/appl/cmd/dial.b b/appl/cmd/dial.b index c562a570..254c48e9 100644 --- a/appl/cmd/dial.b +++ b/appl/cmd/dial.b @@ -1,4 +1,4 @@ -implement Dial; +implement Dialc; include "sys.m"; sys: Sys; include "draw.m"; @@ -7,11 +7,13 @@ include "keyring.m"; keyring: Keyring; include "security.m"; auth: Auth; +include "dial.m"; + dial: Dial; include "sh.m"; sh: Sh; Context: import sh; -Dial: module { +Dialc: module { init: fn(nil: ref Draw->Context, argv: list of string); }; @@ -38,6 +40,9 @@ init(drawctxt: ref Draw->Context, argv: list of string) sh = load Sh Sh->PATH; if (sh == nil) badmodule(Sh->PATH); + dial = load Dial Dial->PATH; + if (dial == nil) + badmodule(Dial->PATH); auth->init(); alg: string; @@ -87,9 +92,9 @@ init(drawctxt: ref Draw->Context, argv: list of string) } } - (ok, c) := sys->dial(addr, nil); - if (ok == -1) { - sys->fprint(stderr(), "dial: cannot dial %s:: %r\n", addr); + c := dial->dial(addr, nil); + if (c == nil) { + sys->fprint(stderr(), "dial: cannot dial %s: %r\n", addr); raise "fail:errors"; } user: string; diff --git a/appl/lib/dhcpclient.b b/appl/lib/dhcpclient.b index 3912a086..0b9d4519 100644 --- a/appl/lib/dhcpclient.b +++ b/appl/lib/dhcpclient.b @@ -17,6 +17,9 @@ include "ip.m"; include "keyring.m"; include "security.m"; # for Random +include "dial.m"; + dial: Dial; + include "dhcp.m"; debug := 0; @@ -32,6 +35,7 @@ init() else xidgen = sys->pctl(0, nil)*sys->millisec(); random = nil; + dial = load Dial Dial->PATH; ip = load IP IP->PATH; ip->init(); } @@ -435,8 +439,8 @@ udpannounce(net: string): (ref Sys->FD, string) { if(net == nil) net = "/net"; - (ok, conn) := sys->announce(net+"/udp!*!68"); - if(ok < 0) + conn := dial->announce(net+"/udp!*!68"); + if(conn == nil) return (nil, sys->sprint("can't announce dhcp port: %r")); if(sys->fprint(conn.cfd, "headers") < 0) return (nil, sys->sprint("can't set headers mode on dhcp port: %r")); |
