summaryrefslogtreecommitdiff
path: root/appl
diff options
context:
space:
mode:
authorCharles Forsyth <charles.forsyth@gmail.com>2015-04-29 15:09:38 +0100
committerCharles Forsyth <charles.forsyth@gmail.com>2015-04-29 15:09:38 +0100
commit170ff9d45744c9a94d26be32709fb3f616ba141a (patch)
tree2e729b710b4f627d2c0e22e31a1884b373418e22 /appl
parent384c797555910dfba6362bec98a74a6564fb3478 (diff)
convert to use Dial module
Diffstat (limited to 'appl')
-rw-r--r--appl/grid/cpupool.b15
-rw-r--r--appl/grid/lib/announce.b8
-rw-r--r--appl/grid/lib/browser.b12
-rw-r--r--appl/grid/lib/fbrowse.b5
-rw-r--r--appl/grid/lib/srvbrowse.b2
-rw-r--r--appl/grid/register.b25
-rw-r--r--appl/grid/reglisten.b31
-rw-r--r--appl/grid/regstyxlisten.b36
-rw-r--r--appl/grid/remotelogon.b7
9 files changed, 70 insertions, 71 deletions
diff --git a/appl/grid/cpupool.b b/appl/grid/cpupool.b
index 0c3af3f6..dc7e7a73 100644
--- a/appl/grid/cpupool.b
+++ b/appl/grid/cpupool.b
@@ -17,6 +17,8 @@ include "styxservers.m";
nametree: Nametree;
Tree: import nametree;
include "draw.m";
+include "dial.m";
+ dial: Dial;
include "sh.m";
include "arg.m";
include "registries.m";
@@ -74,6 +76,9 @@ init(nil : ref Draw->Context, argv: list of string)
daytime = load Daytime Daytime->PATH;
if (daytime == nil)
badmod(Daytime->PATH);
+ dial = load Dial Dial->PATH;
+ if (dial == nil)
+ badmod(Dial->PATH);
styx = load Styx Styx->PATH;
if (styx == nil)
badmod(Styx->PATH);
@@ -149,7 +154,7 @@ init(nil : ref Draw->Context, argv: list of string)
poolchanin = chan of string;
poolchanout = chan of int;
userchan := chan of int;
- spawn listener(*c);
+ spawn listener(c);
spawn cpupoolloop(poolchanin, poolchanout);
}
@@ -428,13 +433,13 @@ badmod(path: string)
exit;
}
-listener(c: Sys->Connection)
+listener(c: ref Sys->Connection)
{
for (;;) {
- (n, nc) := sys->listen(c);
- if (n == -1)
+ nc := dial->listen(c);
+ if (nc == nil)
error(sys->sprint("listen failed: %r"));
- dfd := sys->open(nc.dir + "/data", Sys->ORDWR);
+ dfd := dial->accept(nc);
if (dfd != nil) {
sync := chan of int;
sys->print("got new connection!\n");
diff --git a/appl/grid/lib/announce.b b/appl/grid/lib/announce.b
index b29dfe42..54438b59 100644
--- a/appl/grid/lib/announce.b
+++ b/appl/grid/lib/announce.b
@@ -1,6 +1,8 @@
implement Announce;
include "sys.m";
sys: Sys;
+include "dial.m";
+ dial: Dial;
include "grid/announce.m";
init()
@@ -11,8 +13,8 @@ init()
announce(): (string, ref Sys->Connection)
{
sysname := readfile("/dev/sysname");
- (ok, c) := sys->announce("tcp!*!0");
- if(ok == -1)
+ c := dial->announce("tcp!*!0");
+ if(c == nil)
return (nil, nil);
local := readfile(c.dir + "/local");
if(local == nil)
@@ -25,7 +27,7 @@ announce(): (string, ref Sys->Connection)
return (nil, nil);
if(port[len port - 1] == '\n')
port = port[0:len port - 1];
- return ("tcp!" + sysname + "!" + port, ref c);
+ return ("tcp!" + sysname + "!" + port, c);
}
diff --git a/appl/grid/lib/browser.b b/appl/grid/lib/browser.b
index c6de92cf..4fc0b2bc 100644
--- a/appl/grid/lib/browser.b
+++ b/appl/grid/lib/browser.b
@@ -62,8 +62,6 @@ Browse.new(top: ref Tk->Toplevel, tkchanname, root, rlabel: string, nopanes: int
tkcmds(top, pane1scr);
tkcmd(top, "bind .fbrowse.lmov <Button-1> {send "+b.tkchan+" movdiv %X}");
- size := tkcmd(top, "grid size .fbrowse");
- p := isat(size, " ");
tkcmd(top, "label .fbrowse.l -text { } -anchor w -width 0" +
" -font /fonts/charon/plain.normal.font");
tkcmd(top, ".fbrowse.l configure -height "+tkcmd(top, ".fbrowse.l cget -height"));
@@ -179,8 +177,8 @@ Browse.changeview(b: self ref Browse, nopanes: int)
{
if (b.nopanes == nopanes)
return;
- w := int tkcmd(b.top, ".fbrowse cget -actwidth");
- ws := int tkcmd(b.top, ".fbrowse.sy1 cget -width");
+# w := int tkcmd(b.top, ".fbrowse cget -actwidth");
+# ws := int tkcmd(b.top, ".fbrowse.sy1 cget -width");
if (nopanes == 1) {
b.pane0width = tkcmd(b.top, ".fbrowse.c1 cget -actwidth") + " " +
tkcmd(b.top, ".fbrowse.c2 cget -actwidth");
@@ -270,8 +268,6 @@ Browse.gotopath(b: self ref Browse, file: File, openfinal: int): (File, string)
trackbacklist : list of (string, list of string, list of string) = nil;
trackback := 0;
enddir := "";
- endfile := "";
- filetkpath := "";
if (file.path[len file.path - 1] != '/') {
# i.e. is not a directory
p := isatback(file.path, "/");
@@ -369,7 +365,6 @@ Browse.getpath(b: self ref Browse, f: string): ref File
tkpath := ".fbrowse.fl.f0";
path := b.root;
lst = tl tl lst;
- started := 0;
# sys->print("getpath: %s %s\n",tkpath, path);
qid := "";
for (; lst != nil; lst = tl lst) {
@@ -1041,8 +1036,6 @@ Select.defaultaction(s: self ref Select, lst: list of string)
Select.getselected(s: self ref Select, fname: string): string
{
- retlist : list of (int, list of ref Parameter) = nil;
- row := 1;
f := getframe(s, fname);
return f.selected;
}
@@ -1058,7 +1051,6 @@ Select.getselection(s: self ref Select, fname: string): list of (string, list of
if (slaves == nil || slaves[0] == '!')
break;
(nil, lst) := sys->tokenize(slaves, " ");
- pos := isatback(hd lst, "l");
tkpath := hd lst;
lst = tl lst;
lp : list of ref Parameter = nil;
diff --git a/appl/grid/lib/fbrowse.b b/appl/grid/lib/fbrowse.b
index bde88e62..d1310386 100644
--- a/appl/grid/lib/fbrowse.b
+++ b/appl/grid/lib/fbrowse.b
@@ -89,8 +89,6 @@ init(ctxt : ref Draw->Context, title, root, currdir: string): string
released := 1;
title = "";
- menudata := ("", "");
-
tkclient->onscreen(top, nil);
resize(top, ctxt.display.image);
tkclient->startinput(top, "kbd"::"ptr"::nil);
@@ -272,7 +270,6 @@ openfile(ctxt: ref draw->Context, file, title: string, writeable: int)
(w,h) := fopensize;
if (w != "" && h != "")
tkcmd(top, ". configure -width "+w+" -height "+h);
- errors := 0;
killpid := -1;
fd := sys->open(file, sys->OREAD);
if (fd != nil) {
@@ -369,7 +366,7 @@ actionbutton(top: ref Tk->Toplevel, path, tkpath: string)
getext(file: string): string
{
- (n, lst) := sys->tokenize(file, ".");
+ (nil, lst) := sys->tokenize(file, ".");
for (; tl lst != nil; lst = tl lst)
;
return hd lst;
diff --git a/appl/grid/lib/srvbrowse.b b/appl/grid/lib/srvbrowse.b
index eec8f56e..943ea18e 100644
--- a/appl/grid/lib/srvbrowse.b
+++ b/appl/grid/lib/srvbrowse.b
@@ -114,7 +114,7 @@ find(filter: list of list of (string, string)): list of ref Service
else {
for (; filter != nil; filter = tl filter) {
attr := hd filter;
- (s, err) := reg.find(attr);
+ (s, nil) := reg.find(attr);
for (; s != nil; s = tl s)
lsrv = hd s :: lsrv;
}
diff --git a/appl/grid/register.b b/appl/grid/register.b
index bd0d8265..219b19c9 100644
--- a/appl/grid/register.b
+++ b/appl/grid/register.b
@@ -9,6 +9,8 @@ include "sys.m";
sys: Sys;
include "draw.m";
include "sh.m";
+include "dial.m";
+ dial: Dial;
include "registries.m";
registries: Registries;
Registry, Attributes, Service: import registries;
@@ -26,6 +28,9 @@ init(ctxt: ref Draw->Context, argv: list of string)
{
sys = load Sys Sys->PATH;
sys->pctl(sys->FORKNS | sys->NEWPGRP, nil);
+ dial = load Dial Dial->PATH;
+ if (dial == nil)
+ badmod(Dial->PATH);
registries = load Registries Registries->PATH;
if (registries == nil)
badmod(Registries->PATH);
@@ -75,18 +80,18 @@ init(ctxt: ref Draw->Context, argv: list of string)
if (reg == nil)
error(sys->sprint("Could not find registry: %r\nMake sure that ndb/cs has been started and there is a registry announcing on the machine specified in /lib/ndb/local"));
- c : sys->Connection;
+ c : ref Sys->Connection;
if (myaddr == nil) {
(addr, conn) := announce->announce();
if (addr == nil)
error(sys->sprint("cannot announce: %r"));
myaddr = addr;
- c = *conn;
+ c = conn;
}
else {
n: int;
- (n, c) = sys->announce(myaddr);
- if (n == -1)
+ c = dial->announce(myaddr);
+ if (c == nil)
error(sys->sprint("cannot announce: %r"));
(n, nil) = sys->tokenize(myaddr, "*");
if (n > 1) {
@@ -107,16 +112,16 @@ init(ctxt: ref Draw->Context, argv: list of string)
spawn listener(c, mountfd, maxusers);
}
-listener(c: Sys->Connection, mountfd: ref sys->FD, maxusers: int)
+listener(c: ref Sys->Connection, mountfd: ref sys->FD, maxusers: int)
{
for (;;) {
- (n, nc) := sys->listen(c);
- if (n == -1)
+ nc := dial->listen(c);
+ if (nc == nil)
error(sys->sprint("listen failed: %r"));
- dfd := sys->open(nc.dir + "/data", Sys->ORDWR);
- if (maxusers != -1 && nusers >= maxusers)
+ if (maxusers != -1 && nusers >= maxusers) {
sys->fprint(stderr(), "register: maxusers (%d) exceeded!\n", nusers);
- else if (dfd != nil) {
+ dial->reject(nc, "server overloaded");
+ }else if ((dfd := dial->accept(nc)) != nil) {
sync := chan of int;
addr := readfile(nc.dir + "/remote");
if (addr == nil)
diff --git a/appl/grid/reglisten.b b/appl/grid/reglisten.b
index 45776237..e2c7f059 100644
--- a/appl/grid/reglisten.b
+++ b/appl/grid/reglisten.b
@@ -10,6 +10,8 @@ include "draw.m";
include "arg.m";
include "keyring.m";
keyring: Keyring;
+include "dial.m";
+ dial: Dial;
include "security.m";
auth: Auth;
include "sh.m";
@@ -44,6 +46,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);
arg := load Arg Arg->PATH;
if (arg == nil)
badmodule(Arg->PATH);
@@ -169,8 +174,8 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
ctxt := Context.new(drawctxt);
- (ok, acon) := sys->announce(addr);
- if (ok == -1) {
+ acon := dial->announce(addr);
+ if (acon == nil) {
sys->fprint(stderr(), "listen: failed to announce on '%s': %r\n", addr);
sync <-= "cannot announce";
exit;
@@ -195,12 +200,12 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
sync <-= nil;
- listench := chan of (int, Sys->Connection);
- authch := chan of (string, Sys->Connection);
+ listench := chan of (int, ref Sys->Connection);
+ authch := chan of (string, ref Sys->Connection);
spawn listener(listench, acon, addr);
for (;;) {
user := "";
- ccon: Sys->Connection;
+ ccon: ref Sys->Connection;
alt {
(lok, c) := <-listench =>
if (lok == -1)
@@ -229,11 +234,11 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
}
-listener(listench: chan of (int, Sys->Connection), c: Sys->Connection, addr: string)
+listener(listench: chan of (int, ref Sys->Connection), c: ref Sys->Connection, addr: string)
{
for (;;) {
- (ok, nc) := sys->listen(c);
- if (ok == -1) {
+ nc := dial->listen(c);
+ if (nc == nil) {
sys->fprint(stderr(), "listen: listen error on '%s': %r\n", addr);
listench <-= (-1, nc);
exit;
@@ -241,16 +246,16 @@ listener(listench: chan of (int, Sys->Connection), c: Sys->Connection, addr: str
if (verbose)
sys->fprint(stderr(), "listen: got connection on %s from %s",
addr, readfile(nc.dir + "/remote"));
- nc.dfd = sys->open(nc.dir + "/data", Sys->ORDWR);
+ nc.dfd = dial->accept(nc);
if (nc.dfd == nil)
- sys->fprint(stderr(), "listen: cannot open %s: %r\n", nc.dir + "/data");
+ sys->fprint(stderr(), "listen: cannot accept: %r\n");
else
- listench <-= (ok, nc);
+ listench <-= (0, nc);
}
}
-authenticator(authch: chan of (string, Sys->Connection),
- c: Sys->Connection, algs: list of string, addr: string)
+authenticator(authch: chan of (string, ref Sys->Connection),
+ c: ref Sys->Connection, algs: list of string, addr: string)
{
err: string;
(c.dfd, err) = auth->server(algs, serverkey, c.dfd, 0);
diff --git a/appl/grid/regstyxlisten.b b/appl/grid/regstyxlisten.b
index 43c70708..feba9c5f 100644
--- a/appl/grid/regstyxlisten.b
+++ b/appl/grid/regstyxlisten.b
@@ -14,6 +14,8 @@ include "security.m";
include "registries.m";
registries: Registries;
Registry, Service, Attributes: import registries;
+include "dial.m";
+ dial: Dial;
include "arg.m";
include "sh.m";
@@ -41,6 +43,9 @@ init(ctxt: ref Draw->Context, argv: list of string)
keyring = load Keyring Keyring->PATH;
if (keyring == nil)
badmodule(Keyring->PATH);
+ dial = load Dial Dial->PATH;
+ if (dial == nil)
+ badmodule(Dial->PATH);
arg := load Arg Arg->PATH;
if (arg == nil)
@@ -61,7 +66,7 @@ init(ctxt: ref Draw->Context, argv: list of string)
'v' =>
verbose = 1;
'a' =>
- alg := arg->earg() :: algs;
+ algs = arg->earg() :: algs;
'f' =>
keyfile = arg->earg();
if (! (keyfile[0] == '/' || (len keyfile > 2 && keyfile[0:2] == "./")))
@@ -91,7 +96,7 @@ init(ctxt: ref Draw->Context, argv: list of string)
if (doauth && algs == nil)
algs = getalgs();
- addr := netmkaddr(hd argv, "tcp", "styx");
+ addr := dial->netmkaddr(hd argv, "tcp", "styx");
cmd := tl argv;
authinfo: ref Keyring->Authinfo;
@@ -103,8 +108,8 @@ init(ctxt: ref Draw->Context, argv: list of string)
error(sys->sprint("cannot read %s: %r", keyfile));
}
- (ok, c) := sys->announce(addr);
- if (ok == -1)
+ c := dial->announce(addr);
+ if (dial == nil)
error(sys->sprint("cannot announce on %s: %r", addr));
if(regattrs != nil){
@@ -130,17 +135,17 @@ init(ctxt: ref Draw->Context, argv: list of string)
spawn listener(c, popen(ctxt, cmd, lsync), authinfo, algs, lsync);
}
-listener(c: Sys->Connection, mfd: ref Sys->FD, authinfo: ref Keyring->Authinfo, algs: list of string, lsync: chan of int)
+listener(c: ref Sys->Connection, mfd: ref Sys->FD, authinfo: ref Keyring->Authinfo, algs: list of string, lsync: chan of int)
{
lsync <-= sys->pctl(0, nil);
for (;;) {
- (n, nc) := sys->listen(c);
- if (n == -1)
+ nc := dial->listen(c);
+ if (nc == nil)
error(sys->sprint("listen failed: %r"));
if (verbose)
sys->fprint(stderr(), "styxlisten: got connection from %s",
readfile(nc.dir + "/remote"));
- dfd := sys->open(nc.dir + "/data", Sys->ORDWR);
+ dfd := dial->accept(nc);
if (dfd != nil) {
if (algs == nil) {
sync := chan of int;
@@ -262,18 +267,3 @@ stderr(): ref Sys->FD
{
return sys->fildes(2);
}
-
-netmkaddr(addr, net, svc: string): string
-{
- if(net == nil)
- net = "net";
- (n, l) := sys->tokenize(addr, "!");
- if(n <= 1){
- if(svc== nil)
- return sys->sprint("%s!%s", net, addr);
- return sys->sprint("%s!%s!%s", net, addr, svc);
- }
- if(svc == nil || n > 2)
- return addr;
- return sys->sprint("%s!%s", addr, svc);
-}
diff --git a/appl/grid/remotelogon.b b/appl/grid/remotelogon.b
index 89c1953f..ff8751d1 100644
--- a/appl/grid/remotelogon.b
+++ b/appl/grid/remotelogon.b
@@ -18,6 +18,8 @@ include "tkclient.m";
tkclient: Tkclient;
include "arg.m";
include "sh.m";
+include "dial.m";
+ dial: Dial;
include "newns.m";
include "keyring.m";
keyring: Keyring;
@@ -95,6 +97,7 @@ init(ctxt: ref Draw->Context, argv: list of string)
tkclient->init();
login = checkload(load Login Login->PATH, Login->PATH);
keyring = checkload(load Keyring Keyring->PATH, Keyring->PATH);
+ dial = checkload(load Dial Dial->PATH, Dial->PATH);
registries = checkload(load Registries Registries->PATH, Registries->PATH);
registries->init();
@@ -251,8 +254,8 @@ createuser(top: ref Tk->Toplevel, user, passwd: string, signerpkhash: string): i
return 0;
}
addr := (hd svcs).addr;
- (ok, c) := sys->dial(addr, nil);
- if(ok == -1){
+ c := dial->dial(addr, nil);
+ if(c == nil){
notice(top, sys->sprint("cannot dial %s: %r", addr));
return 0;
}