History

20091214-1943

forsyth committed 16 years ago

Commit 89d0b5e1 parent a5bc64423 files · +115 −174Browse files

Unified · Split

23 files
  1. CHANGES +3 −0
  2. appl/cmd/auxi/mangaload.b +7 −19
  3. appl/cmd/cddb.b +7 −18
  4. appl/cmd/import.b +5 −18
  5. appl/cmd/ip/ping.b +7 −18
  6. appl/cmd/ip/rip.b +8 −3
  7. appl/cmd/lockfs.b +42 −51
  8. appl/cmd/ndb/dns.b +10 −4
  9. appl/cmd/styxchat.b +13 −24
  10. appl/cmd/telnet.b +12 −25
  11. appl/cmd/webgrab.b +8 −3
  12. dis/auxi/mangaload.dis +0 −0
  13. dis/cddb.dis +0 −0
  14. dis/import.dis +0 −0
  15. dis/ip/ping.dis +0 −0
  16. dis/ip/rip.dis +0 −0
  17. dis/lockfs.dis +0 −0
  18. dis/ndb/dns.dis +0 −0
  19. dis/styxchat.dis +0 −0
  20. dis/telnet.dis +0 −0
  21. dis/webgrab.dis +0 −0
  22. emu/Linux/emu-g +2 −0
  23. include/version.h +1 −1
CHANGES+3−0
@@ -1,3 +1,6 @@
1+20091214
2+ switch more commands to use dial(2)
3+ change emu/Linux/emu-g not to require X11 libs (again)
14 20091213
25 temper the tendancy of port/dis.c to yield during idle gc: it's compensating for os scheduling, but yield less often
36 20091208
appl/cmd/auxi/mangaload.b+7−19
@@ -16,6 +16,9 @@ include "timers.m"; · 15 unmodified lines
1616 timers: Timers;
1717 Timer: import timers;
1818
19+include "dial.m";
20+ dial: Dial;
21+
1922 include "arg.m";
2023
2124 Mangaload: module
@@ -88,6 +91,7 @@ init(nil: ref Draw->Context, args: list of string) · 66 unmodified lines
8891 {
8992 sys = load Sys Sys->PATH;
9093 timers = load Timers Timers->PATH;
94+ dial = load Dial Dial->PATH;
9195 ip = load IP IP->PATH;
9296 ip->init();
9397
@@ -137,9 +141,9 @@ init(nil: ref Draw->Context, args: list of string) · 43 unmodified lines
137141 filesize := int d.length;
138142
139143 port := sys->sprint("%d", 16r8695);
140− addr := netmkaddr(hd args, "icmp", port);
141− (rok, c) := sys->dial(addr, port);
142− if(rok < 0){
144+ addr := dial->netmkaddr(hd args, "icmp", port);
145+ c := dial->dial(addr, port);
146+ if(c == nil){
143147 sys->fprint(sys->fildes(2), "mangaload: can't dial %s: %r\n", addr);
144148 raise "fail:dial";
145149 }
@@ -182,7 +186,6 @@ init(nil: ref Draw->Context, args: list of string) · 36 unmodified lines
182186 last := 0;
183187 while((n := sys->read(fd, buf, len buf)) >= 0 && !last){
184188 last = n != len buf;
185− nretry := 0;
186189 Retry:
187190 for(;;){
188191 if(++nsent%10 == 0){ # probe
@@ -345,18 +348,3 @@ Icmp.unpack(b: array of byte): ref Icmp · 156 unmodified lines
345348 ic.data = b[Odata:];
346349 return ic;
347350 }
348−
349−netmkaddr(addr, net, svc: string): string
350−{
351− if(net == nil)
352− net = "net";
353− (n, nil) := sys->tokenize(addr, "!");
354− if(n <= 1){
355− if(svc== nil)
356− return sys->sprint("%s!%s", net, addr);
357− return sys->sprint("%s!%s!%s", net, addr, svc);
358− }
359− if(svc == nil || n > 2)
360− return addr;
361− return sys->sprint("%s!%s", addr, svc);
362−}
appl/cmd/cddb.b+7−18
@@ -14,6 +14,9 @@ include "bufio.m"; · 13 unmodified lines
1414 include "string.m";
1515 str: String;
1616
17+include "dial.m";
18+ dial: Dial;
19+
1720 include "arg.m";
1821
1922 Cddb: module
@@ -66,8 +69,8 @@ dumpcddb(t: ref Toc) · 46 unmodified lines
6669
6770 cddbfilltoc(t: ref Toc): int
6871 {
69− (ok, conn) := sys->dial(netmkaddr(server, "tcp", "888"), nil);
70− if(ok < 0) {
72+ conn := dial->dial(dial->netmkaddr(server, "tcp", "888"), nil);
73+ if(conn == nil){
7174 sys->fprint(sys->fildes(2), "cddb: cannot dial %s: %r\n", server);
7275 return -1;
7376 }
@@ -149,7 +152,7 @@ cddbfilltoc(t: ref Toc): int · 75 unmodified lines
149152 DPRINT(2, sys->sprint("cddb %s\n", p));
150153 if(len p >= 7 && p[0:7] == "DTITLE=")
151154 t.title += p[7:];
152− else if(len p >= 6 && p[0:6] == "TTITLE"&& isdigit(p[6])) {
155+ else if(len p >= 7 && p[0:6] == "TTITLE"&& isdigit(p[6])) {
153156 i = atoi(p[6:]);
154157 if(i < t.ntrack) {
155158 p = p[6:];
@@ -200,6 +203,7 @@ init(nil: ref Draw->Context, args: list of string) · 44 unmodified lines
200203 sys = load Sys Sys->PATH;
201204 bufio = load Bufio Bufio->PATH;
202205 str = load String String->PATH;
206+ dial = load Dial Dial->PATH;
203207
204208 arg := load Arg Arg->PATH;
205209 arg->init(args);
@@ -237,21 +241,6 @@ init(nil: ref Draw->Context, args: list of string) · 31 unmodified lines
237241 dumpcddb(toc);
238242 }
239243
240−netmkaddr(addr, net, svc: string): string
241−{
242− if(net == nil)
243− net = "net";
244− (n, nil) := sys->tokenize(addr, "!");
245− if(n <= 1){
246− if(svc== nil)
247− return sys->sprint("%s!%s", net, addr);
248− return sys->sprint("%s!%s!%s", net, addr, svc);
249− }
250− if(svc == nil || n > 2)
251− return addr;
252− return sys->sprint("%s!%s", addr, svc);
253−}
254−
255244 atoi(s: string): int
256245 {
257246 return int s;
appl/cmd/import.b+5−18
@@ -4,6 +4,7 @@ include "sys.m"; · 3 unmodified lines
44 sys: Sys;
55
66 include "draw.m";
7+include "dial.m";
78 include "keyring.m";
89 include "security.m";
910 include "factotum.m";
@@ -35,6 +36,7 @@ init(nil: ref Draw->Context, args: list of string) · 25 unmodified lines
3536 if(factotum == nil)
3637 nomod(Factotum->PATH);
3738 factotum->init();
39+ dial := load Dial Dial->PATH;
3840
3941 arg := load Arg Arg->PATH;
4042 if(arg == nil)
@@ -80,9 +82,9 @@ init(nil: ref Draw->Context, args: list of string) · 39 unmodified lines
8082 if(facfd == nil)
8183 fail("factotum", sys->sprint("can't open %s: %r", factotumfile));
8284
83− dest := netmkaddr(addr, "net", "exportfs");
84− (ok, c) := sys->dial(dest, nil);
85− if(ok < 0)
85+ dest := dial->netmkaddr(addr, "net", "exportfs");
86+ c := dial->dial(dest, nil);
87+ if(c == nil)
8688 fail("dial failed", sys->sprint("can't dial %s: %r", dest));
8789 ai := factotum->proxy(c.dfd, facfd, "proto=p9any role=client "+keyspec);
8890 if(ai == nil)
@@ -161,18 +163,3 @@ pushssl(fd: ref Sys->FD, secretin, secretout: array of byte, alg: string): (ref · 72 unmodified lines
161163
162164 return (c.dfd, nil);
163165 }
164−
165−netmkaddr(addr, net, svc: string): string
166−{
167− if(net == nil)
168− net = "net";
169− (n, nil) := sys->tokenize(addr, "!");
170− if(n <= 1){
171− if(svc== nil)
172− return sys->sprint("%s!%s", net, addr);
173− return sys->sprint("%s!%s!%s", net, addr, svc);
174− }
175− if(svc == nil || n > 2)
176− return addr;
177− return sys->sprint("%s!%s", addr, svc);
178−}
appl/cmd/ip/ping.b+7−18
@@ -16,6 +16,9 @@ include "timers.m"; · 15 unmodified lines
1616 include "rand.m";
1717 rand: Rand;
1818
19+include "dial.m";
20+ dial: Dial;
21+
1922 include "arg.m";
2023
2124 Ping: module
@@ -74,6 +77,7 @@ init(nil: ref Draw->Context, args: list of string) · 52 unmodified lines
7477 sys = load Sys Sys->PATH;
7578 rand = load Rand Rand->PATH;
7679 timers = load Timers Timers->PATH;
80+ dial = load Dial Dial->PATH;
7781 ip = load IP IP->PATH;
7882 ip->init();
7983
@@ -117,9 +121,9 @@ init(nil: ref Draw->Context, args: list of string) · 37 unmodified lines
117121 opentime();
118122 rand->init(int(nsec()/big 1000));
119123
120− addr := netmkaddr(hd args, "icmp", "1");
121− (ok, c) := sys->dial(addr, nil);
122− if(ok < 0){
124+ addr := dial->netmkaddr(hd args, "icmp", "1");
125+ c := dial->dial(addr, nil);
126+ if(c == nil){
123127 sys->fprint(sys->fildes(2), "ip/ping: can't dial %s: %r\n", addr);
124128 raise "fail:dial";
125129 }
@@ -333,21 +337,6 @@ Icmp.unpack(b: array of byte): ref Icmp · 207 unmodified lines
333337 return ic;
334338 }
335339
336−netmkaddr(addr, net, svc: string): string
337−{
338− if(net == nil)
339− net = "net";
340− (n, l) := sys->tokenize(addr, "!");
341− if(n <= 1){
342− if(svc== nil)
343− return sys->sprint("%s!%s", net, addr);
344− return sys->sprint("%s!%s!%s", net, addr, svc);
345− }
346− if(svc == nil || n > 2)
347− return addr;
348− return sys->sprint("%s!%s", addr, svc);
349−}
350−
351340 timefd: ref Sys->FD;
352341
353342 opentime()
appl/cmd/ip/rip.b+8−3
@@ -15,6 +15,10 @@ include "bufio.m"; · 14 unmodified lines
1515 include "daytime.m";
1616 daytime: Daytime;
1717
18+include "dial.m";
19+ dial: Dial;
20+
21+
1822 include "ip.m";
1923 ip: IP;
2024 IPaddr, Ifcaddr, Udphdr: import ip;
@@ -105,6 +109,7 @@ init(nil: ref Draw->Context, args: list of string) · 84 unmodified lines
105109 sys = load Sys Sys->PATH;
106110 bufio = load Bufio Bufio->PATH;
107111 daytime = load Daytime Daytime->PATH;
112+ dial = load Dial Dial->PATH;
108113 ip = load IP IP->PATH;
109114 ip->init();
110115
@@ -420,7 +425,7 @@ sendroutes(ifc: ref Ifcaddr, dst: IPaddr, op: int, changes: int) · 309 unmodified lines
420425 buf[o+2] = byte 0;
421426 buf[o+3] = byte 0;
422427 o += Riphdrlen;
423− rips := buf[IP->Udphdrlen+Riphdrlen:];
428+# rips := buf[IP->Udphdrlen+Riphdrlen:];
424429 if(op == OpRequest){
425430 buf[o:] = zeroentry;
426431 ip->put4(buf, o+Ometric, HopLimit);
@@ -602,8 +607,8 @@ Gateway.contains(g: self ref Gateway, a: IPaddr): int · 175 unmodified lines
602607 riplisten(): ref Sys->FD
603608 {
604609 addr := sys->sprint("%s/udp!*!rip", netdir);
605− (ok, c) := sys->announce(addr);
606− if(ok < 0)
610+ c := dial->announce(addr);
611+ if(c == nil)
607612 fatal(sys->sprint("can't announce %s: %r", addr));
608613 if(sys->fprint(c.cfd, "headers") < 0)
609614 fatal(sys->sprint("can't set udp headers: %r"));
appl/cmd/lockfs.b+42−51
@@ -16,6 +16,8 @@ include "keyring.m"; · 15 unmodified lines
1616 keyring: Keyring;
1717 include "security.m";
1818 auth: Auth;
19+include "dial.m";
20+ dial: Dial;
1921
2022 Lockfs: module {
2123 init: fn(nil: ref Draw->Context, argv: list of string);
@@ -71,19 +73,12 @@ Uproc: type chan of (ref Ureq, chan of (ref Sys->FD, string)); · 49 unmodified lines
7173 maxqidpath := big 1;
7274 locks: list of ref Lockfile;
7375 lockdir: string;
74−authinfo: ref Keyring->Authinfo;
7576 timefd: ref Sys->FD;
7677
7778 MAXCONN: con 20;
7879
7980 verbose := 0;
8081
81−usage()
82−{
83− sys->fprint(stderr, "usage: lockfs [-A] [-a alg]... [-p addr] dir [mountpoint]\n");
84− raise "fail:usage";
85−}
86−
8782 badmodule(p: string)
8883 {
8984 sys->fprint(stderr, "lockfs: cannot load %s: %r\n", p);
@@ -105,6 +100,9 @@ init(nil: ref Draw->Context, argv: list of string) · 15 unmodified lines
105100 devgen = load Dirgenmod "$self";
106101 if (devgen == nil)
107102 badmodule("self as Dirgenmod");
103+ dial = load Dial Dial->PATH;
104+ if(dial == nil)
105+ badmodule(Dial->PATH);
108106 timefd = sys->open("/dev/time", sys->OREAD);
109107 if (timefd == nil) {
110108 sys->fprint(stderr, "lockfs: cannot open /dev/time: %r\n");
@@ -114,55 +112,52 @@ init(nil: ref Draw->Context, argv: list of string) · 3 unmodified lines
114112 if (arg == nil)
115113 badmodule(Arg->PATH);
116114 arg->init(argv);
115+ arg->setusage("lockfs [-A] [-e 'crypt hash'] ... [-k keyspec] [-p addr] dir [mountpoint]");
117116
118117 addr := "";
119118 doauth := 1;
120119 algs: list of string;
120+ keyspec: string;
121121 while ((opt := arg->opt()) != 0) {
122122 case opt {
123123 'p' =>
124− addr = arg->arg();
125− 'a' =>
126− alg := arg->arg();
127− if (alg == nil)
128− usage();
129− algs = alg :: algs;
124+ addr = arg->earg();
125+ 'k' =>
126+ addr = arg->earg();
127+ 'a' or 'e' =>
128+ algs = arg->earg() :: algs;
130129 'A' =>
131130 doauth = 0;
132131 'v' =>
133132 verbose = 1;
134133 * =>
135− usage();
134+ arg->usage();
136135 }
137136 }
138137 argv = arg->argv();
139138 if (argv == nil || (addr != nil && tl argv != nil))
140− usage();
139+ arg->usage();
141140 if (addr == nil)
142141 doauth = 0; # no authentication necessary for local mount
143142 if (doauth) {
144143 auth = load Auth Auth->PATH;
145144 if (auth == nil)
146145 badmodule(Auth->PATH);
147− if ((e := auth->init()) != nil) {
148− sys->fprint(stderr, "lockfs: cannot init auth: %s\n", e);
149− raise "fail:errors";
150− }
151− keyring = load Keyring Keyring->PATH;
152− if (keyring == nil)
153− badmodule(Keyring->PATH);
154− authinfo = keyring->readauthinfo("/usr/" + user() + "/keyring/default");
146+ auth->init();
155147 }
156148
157149 mountpoint := lockdir = hd argv;
158150 if (tl argv != nil)
159151 mountpoint = hd tl argv;
160152 if (addr != nil) {
161− if (doauth && algs == nil)
162− algs = "none" :: nil; # XXX is this default a bad idea?
153+ if (doauth){
154+ if(algs == nil)
155+ algs = "none" :: nil; # XXX is this default a bad idea?
156+ keyspec += " :alg='"+flatten(algs, ' ')+"'";
157+ }
163158 srvrq := chan of (ref Sys->FD, string, Uproc);
164159 srvsync := chan of (int, string);
165− spawn listener(addr, srvrq, srvsync, algs);
160+ spawn listener(addr, keyspec, srvrq, srvsync, algs);
166161 (srvpid, err) := <-srvsync;
167162 srvsync = nil;
168163 if (srvpid == -1) {
@@ -633,28 +628,28 @@ revrqlist(ls: list of ref Openreq) : list of ref Openreq · 464 unmodified lines
633628 }
634629
635630 # addr should be, e.g. tcp!*!2345
636−listener(addr: string, ch: chan of (ref Sys->FD, string, Uproc),
631+listener(addr: string, keyspec: string, ch: chan of (ref Sys->FD, string, Uproc),
637632 sync: chan of (int, string), algs: list of string)
638633 {
639− addr = netmkaddr(addr, "tcp", "33234");
640− (ok, c) := sys->announce(addr);;
641− if (ok == -1) {
634+ addr = dial->netmkaddr(addr, "tcp", "33234");
635+ c := dial->announce(addr);
636+ if(c == nil) {
642637 sync <-= (-1, sys->sprint("cannot anounce on %s: %r", addr));
643638 return;
644639 }
645640 sync <-= (sys->pctl(0, nil), nil);
646641 for (;;) {
647− (n, nc) := sys->listen(c);
648− if (n == -1) {
642+ nc := dial->listen(c);
643+ if (nc == nil) {
649644 ch <-= (nil, sys->sprint("listen failed: %r"), nil);
650645 return;
651646 }
652− dfd := sys->open(nc.dir + "/data", Sys->ORDWR);
647+ dfd := dial->accept(nc);
653648 if (dfd != nil) {
654649 if (algs == nil)
655650 ch <-= (dfd, nil, nil);
656651 else
657− spawn authenticator(dfd, ch, algs);
652+ spawn authenticator(dfd, keyspec, ch);
658653 }
659654 }
660655 }
@@ -662,9 +657,9 @@ listener(addr: string, ch: chan of (ref Sys->FD, string, Uproc), · 1 unmodified line
662657 # authenticate a connection, setting the user id appropriately,
663658 # and then act as a server, performing file operations
664659 # on behalf of the central process.
665−authenticator(dfd: ref Sys->FD, ch: chan of (ref Sys->FD, string, Uproc), algs: list of string)
660+authenticator(dfd: ref Sys->FD, keyspec: string, ch: chan of (ref Sys->FD, string, Uproc))
666661 {
667− (fd, err) := auth->server(algs, authinfo, dfd, 1);
662+ (fd, err) := auth->auth(keyspec, dfd, 1);
668663 if (fd == nil) {
669664 if (verbose)
670665 sys->fprint(stderr, "lockfs: authentication failed: %s\n", err);
@@ -730,21 +725,6 @@ doreq(greq: ref Ureq): (ref Sys->FD, string) · 59 unmodified lines
730725 return (fd, err);
731726 }
732727
733−netmkaddr(addr, net, svc: string): string
734−{
735− if(net == nil)
736− net = "net";
737− (n, nil) := sys->tokenize(addr, "!");
738− if(n <= 1){
739− if(svc== nil)
740− return sys->sprint("%s!%s", net, addr);
741− return sys->sprint("%s!%s!%s", net, addr, svc);
742− }
743− if(svc == nil || n > 2)
744− return addr;
745− return sys->sprint("%s!%s", addr, svc);
746−}
747−
748728 user(): string
749729 {
750730 fd := sys->open("/dev/user", sys->OREAD);
@@ -771,3 +751,14 @@ now(): int · 20 unmodified lines
771751 return 0;
772752 return int (big string buf[0:n] / big 1000000);
773753 }
754+
755+flatten(l: list of string, sep: int): string
756+{
757+ s := "";
758+ for(; l != nil; l = tl l){
759+ if(s != "")
760+ s[len s] = sep;
761+ s += hd l;
762+ }
763+ return s;
764+}
appl/cmd/ndb/dns.b+10−4
@@ -46,6 +46,9 @@ include "keyring.m"; · 45 unmodified lines
4646 include "security.m";
4747 random: Random;
4848
49+include "dial.m";
50+ dial: Dial;
51+
4952 DNS: module
5053 {
5154 init: fn(nil: ref Draw->Context, nil: list of string);
@@ -85,6 +88,9 @@ init(nil: ref Draw->Context, args: list of string) · 33 unmodified lines
8588 arg := load Arg Arg->PATH;
8689 if(arg == nil)
8790 cantload(Arg->PATH);
91+ dial = load Dial Dial->PATH;
92+ if(dial == nil)
93+ cantload(Dial->PATH);
8894 arg->init(args);
8995 arg->setusage("dns [-Drh] [-f dnsfile] [-x mntpt]");
9096 svcname := "#sdns";
@@ -1778,8 +1784,8 @@ kill(pid: int) · 1687 unmodified lines
17781784
17791785 udpport(): ref Sys->FD
17801786 {
1781− (ok, conn) := sys->announce(mntpt+"/udp!*!0");
1782− if(ok < 0)
1787+ conn := dial->announce(mntpt+"/udp!*!0");
1788+ if(conn == nil)
17831789 return nil;
17841790 if(sys->fprint(conn.cfd, "headers") < 0){
17851791 sys->fprint(stderr, "dns: can't set headers mode: %r\n");
@@ -1802,8 +1808,8 @@ tcpquery(query: array of byte): (ref DNSmsg, string) · 16 unmodified lines
18021808
18031809 ipa := query[Udpraddr+IPv4off:];
18041810 addr := sys->sprint("tcp!%d.%d.%d.%d!%d", int ipa[0], int ipa[1], int ipa[2], int ipa[3], DNSport);
1805− (ok, conn) := sys->dial(addr, nil);
1806− if(ok < 0)
1811+ conn := dial->dial(addr, nil);
1812+ if(conn == nil)
18071813 return (nil, sys->sprint("can't dial %s: %r", addr));
18081814 query = query[Udphdrsize-2:];
18091815 put2(query, 0, len query-2); # replace UDP header by message length
appl/cmd/styxchat.b+13−24
@@ -20,6 +20,9 @@ include "bufio.m"; · 19 unmodified lines
2020 bufio: Bufio;
2121 Iobuf: import bufio;
2222
23+include "dial.m";
24+ dial: Dial;
25+
2326 include "arg.m";
2427
2528 Styxchat: module
@@ -39,6 +42,7 @@ init(nil: ref Draw->Context, args: list of string) · 13 unmodified lines
3942 styx = load Styx Styx->PATH;
4043 str = load String String->PATH;
4144 bufio = load Bufio Bufio->PATH;
45+ dial = load Dial Dial->PATH;
4246 styx->init();
4347
4448 client := 1;
@@ -74,21 +78,21 @@ init(nil: ref Draw->Context, args: list of string) · 29 unmodified lines
7478 stdin = sys->fildes(0);
7579 dest := hd args;
7680 if(addr){
77− dest = netmkaddr(dest, "net", "styx");
81+ dest = dial->netmkaddr(dest, "net", "styx");
7882 if (client){
79− (rc, c) := sys->dial(dest, nil);
80− if(rc < 0)
83+ c := dial->dial(dest, nil);
84+ if(c == nil)
8185 err(sys->sprint("can't dial %s: %r", dest));
8286 fd = c.dfd;
8387 }else{
84− (rlc, lc) := sys->announce(dest);
85− if (rlc < 0)
88+ lc := dial->announce(dest);
89+ if(lc == nil)
8690 err(sys->sprint("can't announce %s: %r", dest));
87− (rc, c) := sys->listen(lc);
88− if (rc < 0)
91+ c := dial->listen(lc);
92+ if(c == nil)
8993 err(sys->sprint("can't listen on %s: %r", dest));
90− fd = sys->open(c.dir + "/data", Sys->ORDWR);
91− if (fd == nil)
94+ fd = dial->accept(c);
95+ if(fd == nil)
9296 err(sys->sprint("can't open %s/data: %r", c.dir));
9397 }
9498 }else{
@@ -107,21 +111,6 @@ init(nil: ref Draw->Context, args: list of string) · 12 unmodified lines
107111 }
108112 }
109113
110−netmkaddr(addr, net, svc: string): string
111−{
112− if(net == nil)
113− net = "net";
114− (n, nil) := sys->tokenize(addr, "!");
115− if(n <= 1){
116− if(svc== nil)
117− return sys->sprint("%s!%s", net, addr);
118− return sys->sprint("%s!%s!%s", net, addr, svc);
119− }
120− if(svc == nil || n > 2)
121− return addr;
122− return sys->sprint("%s!%s", addr, svc);
123−}
124−
125114 quit(e: int)
126115 {
127116 fd := sys->open("/prog/"+string sys->pctl(0, nil)+"/ctl", Sys->OWRITE);
appl/cmd/telnet.b+12−25
@@ -2,11 +2,12 @@ implement Telnet; · 1 unmodified line
22
33 include "sys.m";
44 sys: Sys;
5− Connection: import sys;
65
76 include "draw.m";
8− draw: Draw;
9− Context: import draw;
7+
8+include "dial.m";
9+ dial: Dial;
10+ Connection: import dial;
1011
1112 Telnet: module
1213 {
@@ -34,7 +35,7 @@ BSL: con 21; # ^u backspace line · 21 unmodified lines
3435 EOT: con 4; # ^d end of file
3536 ESC: con 27; # hold mode
3637
37−net: Connection;
38+net: ref Connection;
3839 stdin, stdout, stderr: ref Sys->FD;
3940
4041 # control characters
@@ -99,12 +100,13 @@ usage() · 58 unmodified lines
99100 raise "fail:usage";
100101 }
101102
102−init(nil: ref Context, argv: list of string)
103+init(nil: ref Draw->Context, argv: list of string)
103104 {
104105 sys = load Sys Sys->PATH;
105106 stderr = sys->fildes(2);
106107 stdout = sys->fildes(1);
107108 stdin = sys->fildes(0);
109+ dial = load Dial Dial->PATH;
108110
109111 if (len argv < 2)
110112 usage();
@@ -120,11 +122,11 @@ init(nil: ref Context, argv: list of string) · 9 unmodified lines
120122 ccfd: ref Sys->FD;
121123 connect(addr: string, port: string)
122124 {
123− ok: int;
124− (ok, net) = sys->dial(netmkaddr(addr, "tcp", port), nil);
125− if(ok < 0) {
126− sys->fprint(stderr, "telnet: %r\n");
127− return;
125+ dest := dial->netmkaddr(addr, "tcp", port);
126+ net = dial->dial(dest, nil);
127+ if(net == nil) {
128+ sys->fprint(stderr, "telnet: can't dial %s: %r\n", dest);
129+ raise "fail:dial";
128130 }
129131 sys->fprint(stderr, "telnet: connected to %s\n", addr);
130132
@@ -465,18 +467,3 @@ raw(on: int) · 334 unmodified lines
465467 else
466468 sys->fprint(ccfd, "rawoff");
467469 }
468−
469−netmkaddr(addr, net, svc: string): string
470−{
471− if(net == nil)
472− net = "net";
473− (n, nil) := sys->tokenize(addr, "!");
474− if(n <= 1){
475− if(svc== nil)
476− return sys->sprint("%s!%s", net, addr);
477− return sys->sprint("%s!%s!%s", net, addr, svc);
478− }
479− if(svc == nil || n > 2)
480− return addr;
481− return sys->sprint("%s!%s", addr, svc);
482−}
appl/cmd/webgrab.b+8−3
@@ -31,6 +31,9 @@ include "daytime.m"; · 30 unmodified lines
3131 include "bufio.m";
3232 B: Bufio;
3333
34+include "dial.m";
35+ D: Dial;
36+
3437 include "arg.m";
3538
3639 Webgrab: module
@@ -52,6 +55,7 @@ init(nil: ref Draw->Context, args: list of string) · 15 unmodified lines
5255 S = load String String->PATH;
5356 U = load Url Url->PATH;
5457 DT = load Daytime Daytime->PATH;
58+ D = load Dial Dial->PATH;
5559 B = load Bufio Bufio->PATH;
5660 arg := load Arg Arg->PATH;
5761 if(S == nil || U == nil || DT == nil || B == nil || arg == nil)
@@ -381,9 +385,10 @@ httpget(u: ref ParsedUrl) : (string, array of byte, ref Sys->FD, ref ParsedUrl) · 323 unmodified lines
381385 dialhost = u.host;
382386 port = u.port;
383387 }
384− (ok, net) := sys->dial("tcp!" + dialhost + "!" + port, nil);
385− if(ok < 0)
386− return (sys->sprint("can't dial %s: %r", dialhost), nil, nil, nil);
388+ dest := D->netmkaddr(dialhost, "tcp", port);
389+ net := D->dial(dest, nil);
390+ if(net == nil)
391+ return (sys->sprint("can't dial %s: %r", dest), nil, nil, nil);
387392
388393 # prepare request
389394 if(u.query != ""){
dis/auxi/mangaload.dis+0−0

Binary file not shown.

dis/cddb.dis+0−0

Binary file not shown.

dis/import.dis+0−0

Binary file not shown.

dis/ip/ping.dis+0−0

Binary file not shown.

dis/ip/rip.dis+0−0

Binary file not shown.

dis/lockfs.dis+0−0

Binary file not shown.

dis/ndb/dns.dis+0−0

Binary file not shown.

dis/styxchat.dis+0−0

Binary file not shown.

dis/telnet.dis+0−0

Binary file not shown.

dis/webgrab.dis+0−0

Binary file not shown.

emu/Linux/emu-g+2−0
@@ -1,3 +1,5 @@
1+env
2+ X11LIBS=
13 dev
24 root
35 cons
include/version.h+1−1
@@ -1 +1 @@
1−#define VERSION "Fourth Edition (20091213)"
1+#define VERSION "Fourth Edition (20091214)"