Unified · Split
| @@ -2,7 +2,7 @@ implement Ftpfs; · 1 unmodified line | |||
| 2 | 2 | ||
| 3 | include "sys.m"; | 3 | include "sys.m"; |
| 4 | sys: Sys; | 4 | sys: Sys; |
| 5 | FD, Connection, Dir: import Sys; | 5 | FD, Dir: import Sys; |
| 6 | 6 | ||
| 7 | include "draw.m"; | 7 | include "draw.m"; |
| 8 | 8 | ||
| @@ -23,6 +23,10 @@ include "styx.m"; · 14 unmodified lines | |||
| 23 | styx: Styx; | 23 | styx: Styx; |
| 24 | Tmsg, Rmsg: import styx; | 24 | Tmsg, Rmsg: import styx; |
| 25 | 25 | ||
| 26 | include "dial.m"; | ||
| 27 | dial: Dial; | ||
| 28 | Connection: import dial; | ||
| 29 | |||
| 26 | include "factotum.m"; | 30 | include "factotum.m"; |
| 27 | 31 | ||
| 28 | Ftpfs: module | 32 | Ftpfs: module |
| @@ -107,7 +111,7 @@ File: adt · 78 unmodified lines | |||
| 107 | createtmp: fn(f: self ref File): ref FD; | 111 | createtmp: fn(f: self ref File): ref FD; |
| 108 | }; | 112 | }; |
| 109 | 113 | ||
| 110 | ftp: Connection; | 114 | ftp: ref Connection; |
| 111 | dfid: ref FD; | 115 | dfid: ref FD; |
| 112 | dfidiob: ref Iobuf; | 116 | dfidiob: ref Iobuf; |
| 113 | buffresidue: int = 0; | 117 | buffresidue: int = 0; |
| @@ -700,7 +704,7 @@ getfullreply(echo: int): (int, int, string) · 586 unmodified lines | |||
| 700 | 704 | ||
| 701 | getreply(echo: int): (int, string) | 705 | getreply(echo: int): (int, string) |
| 702 | { | 706 | { |
| 703 | (c, code, s) := getfullreply(echo); | 707 | (c, nil, s) := getfullreply(echo); |
| 704 | return (c, s); | 708 | return (c, s); |
| 705 | } | 709 | } |
| 706 | 710 | ||
| @@ -767,15 +771,15 @@ third(cmd: string): ref FD · 60 unmodified lines | |||
| 767 | { | 771 | { |
| 768 | acquire(); | 772 | acquire(); |
| 769 | for (;;) { | 773 | for (;;) { |
| 770 | (n, data) := sys->dial(firewall, nil); | 774 | data := dial->dial(firewall, nil); |
| 771 | if (n < 0) { | 775 | if(data == nil) { |
| 772 | if (debug) | 776 | if (debug) |
| 773 | sys->print("dial %s failed: %r\n", firewall); | 777 | sys->print("dial %s failed: %r\n", firewall); |
| 774 | break; | 778 | break; |
| 775 | } | 779 | } |
| 776 | t := sys->sprint("\n%s!*\n\n%s\n%s\n1\n-1\n-1\n", proxyhost, myhost, myname); | 780 | t := sys->sprint("\n%s!*\n\n%s\n%s\n1\n-1\n-1\n", proxyhost, myhost, myname); |
| 777 | b := array of byte t; | 781 | b := array of byte t; |
| 778 | n = sys->write(data.dfd, b, len b); | 782 | n := sys->write(data.dfd, b, len b); |
| 779 | if (n < 0) { | 783 | if (n < 0) { |
| 780 | if (debug) | 784 | if (debug) |
| 781 | sys->print("firewall write failed: %r\n"); | 785 | sys->print("firewall write failed: %r\n"); |
| @@ -872,8 +876,8 @@ passive(cmd: string): ref FD · 90 unmodified lines | |||
| 872 | a := dataport(l); | 876 | a := dataport(l); |
| 873 | if (debug) | 877 | if (debug) |
| 874 | sys->print("data dial %s\n", a); | 878 | sys->print("data dial %s\n", a); |
| 875 | (s, d) := sys->dial(a, nil); | 879 | d := dial->dial(a, nil); |
| 876 | if (s < 0) | 880 | if(d == nil) |
| 877 | return nil; | 881 | return nil; |
| 878 | acquire(); | 882 | acquire(); |
| 879 | r = sendrequest(cmd, 0); | 883 | r = sendrequest(cmd, 0); |
| @@ -919,14 +923,14 @@ activate(cmd: string): ref FD · 39 unmodified lines | |||
| 919 | { | 923 | { |
| 920 | r: int; | 924 | r: int; |
| 921 | 925 | ||
| 922 | listenport, dataport: Connection; | 926 | listenport, dataport: ref Connection; |
| 923 | m: string; | 927 | m: string; |
| 924 | 928 | ||
| 925 | (r, listenport) = sys->announce("tcp!" + net + "!0"); | 929 | listenport = dial->announce("tcp!" + net + "!0"); |
| 926 | if (r < 0) | 930 | if(listenport == nil) |
| 927 | return nil; | 931 | return nil; |
| 928 | (x1, x2) := getnet(listenport.dir); | 932 | (x1, x2) := getnet(listenport.dir); |
| 929 | (x3, x4) := sys->tokenize(x1, "."); | 933 | (nil, x4) := sys->tokenize(x1, "."); |
| 930 | t := sys->sprint("PORT %s,%d,%d", commas(x4), int x2 / 256, int x2&255); | 934 | t := sys->sprint("PORT %s,%d,%d", commas(x4), int x2 / 256, int x2&255); |
| 931 | acquire(); | 935 | acquire(); |
| 932 | r = sendrequest(t, 0); | 936 | r = sendrequest(t, 0); |
| @@ -948,8 +952,8 @@ activate(cmd: string): ref FD · 15 unmodified lines | |||
| 948 | release(); | 952 | release(); |
| 949 | if (r != Extra) | 953 | if (r != Extra) |
| 950 | return nil; | 954 | return nil; |
| 951 | (r, dataport) = sys->listen(listenport); | 955 | dataport = dial->listen(listenport); |
| 952 | if (r < 0) { | 956 | if(dataport == nil) { |
| 953 | sys->fprint(stderr, "activate: listen failed: %r\n"); | 957 | sys->fprint(stderr, "activate: listen failed: %r\n"); |
| 954 | return nil; | 958 | return nil; |
| 955 | } | 959 | } |
| @@ -1488,8 +1492,8 @@ init(nil: ref Draw->Context, args: list of string) · 532 unmodified lines | |||
| 1488 | rv: int; | 1492 | rv: int; |
| 1489 | code: int; | 1493 | code: int; |
| 1490 | 1494 | ||
| 1491 | if (sys == nil) | 1495 | sys = load Sys Sys->PATH; |
| 1492 | sys = load Sys Sys->PATH; | 1496 | dial = load Dial Dial->PATH; |
| 1493 | stdin = sys->fildes(0); | 1497 | stdin = sys->fildes(0); |
| 1494 | stderr = sys->fildes(2); | 1498 | stderr = sys->fildes(2); |
| 1495 | 1499 | ||
| @@ -1549,8 +1553,8 @@ init(nil: ref Draw->Context, args: list of string) · 53 unmodified lines | |||
| 1549 | if (proxy) { | 1553 | if (proxy) { |
| 1550 | if (!quiet) | 1554 | if (!quiet) |
| 1551 | sys->print("dial firewall service %s\n", firewall); | 1555 | sys->print("dial firewall service %s\n", firewall); |
| 1552 | (rv, ftp) = sys->dial(firewall, nil); | 1556 | ftp = dial->dial(firewall, nil); |
| 1553 | if (rv < 0) { | 1557 | if(ftp == nil) { |
| 1554 | sys->print("dial %s failed: %r\n", firewall); | 1558 | sys->print("dial %s failed: %r\n", firewall); |
| 1555 | exit; | 1559 | exit; |
| 1556 | } | 1560 | } |
| @@ -1593,13 +1597,13 @@ init(nil: ref Draw->Context, args: list of string) · 36 unmodified lines | |||
| 1593 | sys->print("proxyhost %s\n", proxyhost); | 1597 | sys->print("proxyhost %s\n", proxyhost); |
| 1594 | } else { | 1598 | } else { |
| 1595 | d := "tcp!" + hostname + "!ftp"; | 1599 | d := "tcp!" + hostname + "!ftp"; |
| 1596 | (rv, ftp) = sys->dial(d, nil); | 1600 | ftp = dial->dial(d, nil); |
| 1597 | if (debug) | 1601 | if(ftp == nil) { |
| 1598 | sys->print("localdir %s\n", ftp.dir); | ||
| 1599 | if (rv < 0) { | ||
| 1600 | sys->print("dial %s failed: %r\n", d); | 1602 | sys->print("dial %s failed: %r\n", d); |
| 1601 | exit; | 1603 | exit; |
| 1602 | } | 1604 | } |
| 1605 | if(debug) | ||
| 1606 | sys->print("localdir %s\n", ftp.dir); | ||
| 1603 | dfid = ftp.dfd; | 1607 | dfid = ftp.dfd; |
| 1604 | } | 1608 | } |
| 1605 | dfidiob = bufio->fopen(dfid, sys->OREAD); | 1609 | dfidiob = bufio->fopen(dfid, sys->OREAD); |
Binary file not shown.