diff options
| author | Charles Forsyth <charles.forsyth@gmail.com> | 2015-04-29 17:44:33 +0100 |
|---|---|---|
| committer | Charles Forsyth <charles.forsyth@gmail.com> | 2015-04-29 17:44:33 +0100 |
| commit | fbc1184c08d18d5ac0f8763a058e015e95353341 (patch) | |
| tree | f045cdfaaf13c35295d34cb0c2ffd7f4cf2ef30d /appl/lib/smtp.b | |
| parent | 83eae27259078c96c074211a51bf38c774490544 (diff) | |
switch to Dial module
Diffstat (limited to 'appl/lib/smtp.b')
| -rw-r--r-- | appl/lib/smtp.b | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/appl/lib/smtp.b b/appl/lib/smtp.b index a1d92b8e..8e118a31 100644 --- a/appl/lib/smtp.b +++ b/appl/lib/smtp.b @@ -4,6 +4,8 @@ include "sys.m"; sys : Sys; include "bufio.m"; bufio : Bufio; +include "dial.m"; + dial: Dial; include "smtp.m"; FD, Connection: import sys; @@ -25,14 +27,17 @@ open(server : string): (int, string) if (!init) { sys = load Sys Sys->PATH; bufio = load Bufio Bufio->PATH; + dial = load Dial Dial->PATH; init = 1; } if (conn) return (-1, "connection is already open"); if (server == nil) server = "$smtp"; - (ok, c) := sys->dial ("tcp!" + server + "!25", nil); - if (ok < 0) + else + server = dial->netmkaddr(server, "tcp", "25"); + c := dial->dial(server, nil); + if (c == nil) return (-1, "dialup failed"); ibuf = bufio->fopen(c.dfd, Bufio->OREAD); obuf = bufio->fopen(c.dfd, Bufio->OWRITE); @@ -41,6 +46,7 @@ open(server : string): (int, string) cread = chan of (int, string); spawn mreader(cread); (rpid, nil) = <- cread; + ok: int; (ok, s) = mread(); if (ok < 0) return (-1, s); |
