Path: utzoo!mnetor!uunet!mcvax!eutrc3!wswietse From: wswietse@eutrc3.UUCP (Wietse Venema) Newsgroups: comp.binaries.ibm.pc Subject: uucp mail for ms-dos pc's (1 of 6) Message-ID: <204@eutrc3.UUCP> Date: 20 Apr 88 13:01:56 GMT Organization: Tech. Univ. Eindhoven, Neth. Lines: 1182 With these programs you can turn your pc into a (non-routing) uucp node. This is the first of a series of six articles with shar-encoded documentation and uuencoded executables. Have fun with it. The sources will be submitted to one of the comp.sources news groups. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh README <<'END_OF_README' XThe pc-mail software provides a single user with facilities for Xcreating, sending and receiving electronic mail messages via the Xuucp network. The programs were developed under UNIX but also run Xwith MS-DOS. Sources will be submitted to one of the comp.sources Xnewsgroups. X XFor the non-technical user there is a menu-driven shell that au- Xtomatically invokes various utility programs, e.g. an editor of Xthe user's choice for editing or creating messages, a program Xthat logs in on a UNIX host to exchange files and so on. Any edi- Xtor that produces clean ASCII files can be used (wordstar files Xare also handled correctly). Other facilities: alias data base, Xbatch-mode operation. X XMore technically oriented users will want to avoid the interac- Xtive shell and use the mail data base and utility programs Xdirectly. The necessary information can be found in the implemen- Xtation documentation and the .man files. X XThe programs have been tested under MS-DOS on XT and AT clones X(MicroSoft V4 C compiler), and with Microport System-V. For the Xinteractive shell, a tiny MS-DOS termcap library is provided. It Xrequires the ANSI.SYS tty driver (or better) to work sucessfully. X XThe programs support the sending and receiving of electronic mail Xonly; no transfer of files by name and no message routing. In Xfact the pc side treats each data file it receives as a mail mes- Xsage, irrespective of its actual destination. The reason for Xthese limitations are (besides uucp security problems) that files Xcan always be sent as mail, and that a pc does not provide multi- Xuser support anyway. X XComplaints, feedback, suggestions are welcome. X X Wietse Venema uucp: mcvax!eutrc3!wswietse X bitnet: wswietse@heitue5 END_OF_README if test 1739 -ne `wc -c Implementation <<'END_OF_Implementation' XMESSAGE DATA BASE X XThe message data base resides in the mail spool directory (de- Xfined with the MAILDIR environment variable). There are various Xclasses of message files: X X - mail received from the network X X - mail ready to send over the network X X - messages in preparation X XIn addition there are administrative files (LOGFILE, alias data Xbase and communications parameters). X XEach message takes two files: a data file (with the actual mes- Xsage) and a meta file (with originator or destination addresses, Xor a one-line summary in case of a message in preparation). X XData/meta file names are constructed by concatenating a single- Xcharacter prefix with a five-digit sequence number. Corresponding Xdata and meta files have the same sequence number. The prefix Xcharacters are: X X E message in preparation X C description of message X X N message received from the net X H originator address in case of an unread message X O originator address in case of already read message X X D message ready to be sent over the net X X destination of that message. X XAdministrative files are X X LOGFILE transaction log X s00000 communications parameters X a00000 alias data base X XAll files in the mail directory are ordinary text files, with a Xpossible exception for the message in preparation (this depends Xon the editor being used). X XFiles in the mail directory are normally write-protected to Xprevent accidents. X END_OF_Implementation if test 1415 -ne `wc -c Installation <<'END_OF_Installation' XTHE UNIX SIDE OF THE CONNECTION X XThe pc-mail programs will need a UNIX host to exchange messages Xwith. This automatically gives access to other networks. I sug- Xgest the following strategy: X X - Get a uucp login, say, uuxyz on a UNIX system. This will also Xbecome the uucp-node name of the pc. The file /usr/lib/uucp/L.sys Xshould be extended with an entry, e.g. X X uuxyz Passive X X(on some systems one has to use `Never' instead of `Passive'). It Xmay also be necessary to update the /usr/lib/uucp/USERFILE. X X - Have all mail for user uuxyz forwarded to uuxyz!somebody. On XBSD UNIX systems, this is achieved by placing the address X`uuxyz!somebody' in a file ~uuxyz/.forward; on System-V one Xshould put the text `Forward to uuxyz!somebody' in the file X/usr/mail/uuxyz, which should be read/writeable by group mail. X XIn the above examples, somebody is a name that can be freely Xchosen; it will not be used by the pc. Of course, mail can be Xforwarded to uuxyz!somebody from other accounts as well. X XThe result of all this is that you can send mail to any user on Xthe UNIX host by just specifying her login name; the host name of Xyour pc will not appear in mail headers. People can send mail to Xyou by specifying an address on the UNIX host. There is no need Xto register the pc in the uucp maps. X XIf the above strategy is not what you like, you will have to Xoperate as a "real" uucp node and should #define UUCP_HOST in Xsendwork.c. You should also be registered as a uucp node. There Xis more discussion about this in sendwork.c X XAs a minimum, the UNIX host should support the standard uucp `g' Xprotocol. This protocol was developed for eight-bit data paths. XUnfortunately, modern networks often eat up XON/XOFF and other Xcontrol characters. X XTo handle non-transparent networks I have written a protocol Xcalled `k'. It has been used with the Eindhoven University Sytek Xnetwork for over two years and is part of the pc-mail distribu- Xtion. If you're really desperate (and have UNIX source) build Xthis protocol into the uucico program by adding the following Xline to struct Proto Ptbl[] in cntrl.c: X X 'k', kturnon, krdmsg, kwrmsg, krddata, kwrdata, kturnoff, X Xand linking the uucico objects with kio.c kp.h kphys.c kpres.c Xand ktrans.c. X XTHE PC SIDE OF THE CONNECTION X XTo bring pc-mail up, edit the makefile to reflect the system you Xare using (there are separate makefiles for UNIX and MS-DOS). XThe MS-DOS makefile is for a UNIX-compatible make utility posted Xto usenet near the end of 1986. There is a batch command file X(buidall.bat) for those who do not have a unix-compatible make Xutility. For testing purposes it is convenient to run this stuff Xon a UNIX host. X XSaying `make' should produce five programs: X X - mail, the menu-driven user interface X - cmail, a program that checks if there is new mail X - smail, a program that queues messages for transmission after X doing alias substitution on mail addresses X - cico, the program that performs dialups and file transfers X - rmail, extracts "From" info from mail received by cico X XThe programs access a common data base in the form of a spool Xdirectory with setup file, logfile and message files. There Xshould be no other files in the spool directory, to avoid Xconfusion. You will have to create the spool directory; the Xprograms will not do that. X XYou will have to set some environment variables before running Xthe mail program. X X - MAILDIR, the absolute path to your spool directory X - EDITOR, the name of your favourite editor program X - PATH, in order locate the executables X XThe editor command may be an MS-DOS batch file; in that case you Xshould include the '.bat' suffix in the command name. X XThe following two environment variables are optional. X X - MAILPRN, if printer output should not go to PRN X - MAILCMD, command that is executed when the mail program exits X XAlso, make sure that the limit on the number of open files is Xlarge enough (20 or so). On MS-DOS, this is handled by a line X`files=20' in the CONFIG.SYS file. X XRun the interactive mail program and choose the setup command. On XMS-DOS systems only the com1 port is supported (see file Xcomport.s). Here is my setup (some names changed) for getting Xthrough the TUE port selector: X X communications_port: com1 X baud_rate: 1200 X remote_host_name: eutwc1 X login_name: uutest X dialup_sequence: atm\r OK atdt455215\r CONNECT \0 ease: xyz\r ease: Xxyz\r choice: 1\r called: b076\r CLOSED \r X disconnect_sequence: \0 X XAll entries must be filled or the cico program will complain. XThe MS-DOS version supports the com1 port only. X XThe dial-up sequence requires some explanation. Basically it is a Xlist of words separated by whitespace. The first word is sent to Xthe comm. port. The program will wait until it receives the Xsecond word. And so on. Unlike real uucp (or kermit), there is no Xretry facility. The backslash escape sequences are stolen from Xthe c programming language, with some extensions: X X \b backspace X \f formfeed X \n linefeed X \r carriage return X \s blank X \t tab X \\ backslash X \nnn octal code for a character X XIn order to send or expect an empty string, use the \0 sequence. X XIt is not possible to send null characters. The dial-up sequence Xshould terminate when the UNIX host displays its "login:" prompt; Xthe remainder of the dialup sequence is built into the software. XThis, and having (pc node name) == (uucp login name) are to Xprevent fraud. Thus, assuming a Hayes-compatible modem, your Xdialup sequence could be as simple as: X X atm\r OK atdt455215\r CONNECT \0 X XWhen this dialup sequence succeeds, the program continues with Xits built-in sequence: X X ogin: login_name\r ssword: your_password\r X XThe disconnect sequence uses the same escape sequences as the Xdial-up sequence, but does not use the send/expect protocol. In Xthe above sequence, the disconnect sequence is an empty string. X XIf the cico program has problems communicating with the UNIX host Xyou can run it by hand, for example: X X cico -d 9 -p your_password X Xwhich will produce a lot of debugging output. Setting the Xdebugging level to less than 9 produces less output. Level 4 is Xsufficient to monitor the dial-up and login sequence. X XALIAS DATABASE X XThe user can define aliases for (groups of) mail addresses. The Xformat of the alias data base is simple: it is a text file with Xon each line: X X alias replacement part X XThe replacement part may be one or more words; words are Xseparated by blanks, tabs or commas. Whenever the smail (mail Xspooler) program recognizes an alias, it is replaced by the X`replacement' part. Aliases may be defined in terms of other Xaliases; also the order in which they appear in the alias data Xbase is not important (except when an alias is defined more than Xonce; the program remembers only the last definition of an Xalias). The alias expansion software is smart enough to detect Xinfinite loops and to suppress multiple occurrances of the same Xrecipient. Alias substitution is not case-sensitive. X XBATCH-MODE OPERATION X XThe cmail program can be run from a batch file (say each time the Xpc is turned on), contact the UNIX host, and report if there is Xnew mail. Also, you may want to auto-execute the cmail command Xwhen exiting from the interactive mail shell. See the manual page Xin the cmail.c source. X END_OF_Installation if test 7515 -ne `wc -c cico.man <<'END_OF_cico.man' X X X X CICO(1) UNIX 5.0 CICO(1) X X X X NAME X cico - uucp file transfer X X PROJECT X pc-mail X X PACKAGE X cico X X SYNOPSIS X cico -p password [-d debuglevel] X X DESCRIPTION X cico is a program that connects to a real unix host for X exchange of spool files. It is a simplified version of the X unix uucico (copy-in-copy-out) program. X X Options: X X -p password X The password that cico will use when logging in on the X unix host. X X -d debuglevel X Set the debugging level. It makes both the local cico X and the remote uucico more verbose. Default debugging X level is 0. X X FILES X cico manipulates various files in the spool directory. X See path(5) for the implementation of the message data base. X X LOGFILE transaction logging X s00000 communications parameters X X SEE ALSO X comm(5) communications parameters X status(5) error returns X X DIAGNOSTICS X The program terminates with a non-zero exit status if there X were problems. The error status codes can be translated to X meaningful messages (see status(5)). More technical X messages are written to the logfile. X X BUGS X cico only supports the functions needed for exchange of X electronic mail. Every incoming data file is treated as if X it were a mail message for the user of the pc. X X AUTHOR(S) X W.Z. Venema X X X X Page 1 (printed 4/20/88) X X X X X X X CICO(1) UNIX 5.0 CICO(1) X X X X Eindhoven University of Technology X Department of Mathematics and Computer Science X Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands X X CREATION DATE X Sat Mar 28 19:58:06 GMT+1:00 1987 X X LAST MODIFICATION X Wed Apr 6 00:18:29 MET 1988 X X VERSION/RELEASE X 1.6 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 2 (printed 4/20/88) X X X END_OF_cico.man if test 1880 -ne `wc -c cmail.man <<'END_OF_cmail.man' X X X X CMAIL(1) UNIX 5.0 CMAIL(1) X X X X NAME X cmail - report if there are unread messages X X PROJECT X pc-mail X X PACKAGE X cmail X X SYNOPSIS X cmail [-p password] X X DESCRIPTION X cmail reports if there are unread mail messages in the pc- X mail spool directory. X X If the -p option is present, cmail first invokes the cico X program to contact the mail server host. X X Typically cmail is run immediately after system startup, X while you are getting your first cup of coffee. X X The program returns a nonzero exit status if it could not X find any mail. X X COMMANDS X cico file transfer program X rmail processes new mail X X FILES X Various files in the spool directory X X LOGFILE system status messages X n mail messages X h header line of new mail X o header line of old mail X X DIAGNOSTICS X Error messages in case the environment is not properly set X up. X X BUGS X Invites people to put their mail password into the autoexec X file. X X AUTHOR(S) X W.Z. Venema X Eindhoven University of Technology X Department of Mathematics and Computer Science X Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands X X CREATION DATE X X X X Page 1 (printed 4/20/88) X X X X X X X CMAIL(1) UNIX 5.0 CMAIL(1) X X X X Sun Apr 3 19:34:57 MET 1988 X X LAST MODIFICATION X Wed Apr 6 00:18:45 MET 1988 X X VERSION/RELEASE X 1.3 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 2 (printed 4/20/88) X X X END_OF_cmail.man if test 1545 -ne `wc -c mailsh.man <<'END_OF_mailsh.man' X X X X MAILSH() UNIX 5.0 MAILSH() X X X X NAME X mailsh - visual mail-shell X X PROJECT X pc-mail X X PACKAGE X mail X X SYNOPSIS X mail X X DESCRIPTION X mail is an interactive program for reading, receiving and X producing electronic mail. Actually, most of the work is X done by programs called by the mail program. X X By default, the program presents the user display of a list X of mail messages in the form of one-line summaries. Single- X key commands are available to select and manipulate mail X messages. Mail messages are created with an editor chosen X by the user. X X The name of the spool directory, printer program and editor X are taken from the environment, or assume system-dependent X defaults. X X ENVIRONMENT X MAILDIR name of spool directory X EDITOR name of program to create mail X MAILPRN name of program/file to print with/to X MAILCMD command to execute upon termination X X COMMANDS X cico network communications program X rmail postprocessor for mail received by cico X X FILES X The mail system maintains various files in a spool directory, X as well as a logfile of all network transactions. X X SEE ALSO X path(3) system-dependent path names X X DIAGNOSTICS X Error messages should be self-explanatory. X X BUGS X The user has to explicitly tell the system to contact a X remote mail host. This is a limitation of MS-DOS, not of the X program. X X X X X Page 1 (printed 4/20/88) X X X X X X X MAILSH() UNIX 5.0 MAILSH() X X X X AUTHOR(S) X W.Z. Venema X Eindhoven University of Technology X Department of Mathematics and Computer Science X Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands X X CREATION DATE X Thu Apr 2 21:54:08 GMT+1:00 1987 X X LAST MODIFICATION X Mon Apr 4 23:44:44 MET 1988 X X VERSION/RELEASE X 1.3 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 2 (printed 4/20/88) X X X END_OF_mailsh.man if test 1973 -ne `wc -c rmail.man <<'END_OF_rmail.man' X X X X RMAIL() UNIX 5.0 RMAIL() X X X X NAME X rmail - extract originator from new mail received by cico X X PROJECT X pc-mail X X PACKAGE X rmail X X SYNOPSIS X rmail X X DESCRIPTION X rmail searches for new mail files received by cico and X extracts the originator's name, for later use by the mail X visual shell. X X Return address formats we understand (in order of X preference): X X From: address (full_name) (accept the full_name) X From: address (accept the address) X >From address (take address and keep scanning) X From address (take address and keep scanning) X X To avoid tampering, new files will have read-only X permission. X X In order to avoid corruption, control-c interrupts are X disabled. X X FILES X In the spool directory: X n received mail message X h extracted originator address X X SEE ALSO X path(5) spool directory, file names X cico(1) network process X mailsh(1) visual mail shell X X DIAGNOSTICS X Exit status zero when no errors were detected, nonzero in X case of file access errors. See status(5) for error codes. X X BUGS X Note that the format "From: full_name
" is not X recognized. The program will just pick up the first word X from full_name. X X Does not really do a good job when parsing the mail headers. X At least, not good enough to extract a return path. X X X X Page 1 (printed 4/20/88) X X X X X X X RMAIL() UNIX 5.0 RMAIL() X X X X AUTHOR(S) X W.Z. Venema X Eindhoven University of Technology X Department of Mathematics and Computer Science X Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands X X CREATION DATE X Tue Mar 31 20:14:11 GMT+1:00 1987 X X LAST MODIFICATION X Wed Apr 6 00:21:54 MET 1988 X X VERSION/RELEASE X 1.4 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 2 (printed 4/20/88) X X X END_OF_rmail.man if test 1949 -ne `wc -c smail.man <<'END_OF_smail.man' X X X X SMAIL(1) UNIX 5.0 SMAIL(1) X X X X NAME X smail - mail spooler X X PROJECT X pc-mail X X PACKAGE X smail X X SYNOPSIS X smail file destinations X X DESCRIPTION X smail makes preparations to send a copy of a text file X across the network. X X The contents of the original file are filtered in order to X get rid of control characters, high most-significant bits, X or non-standard carriage-control conventions. The filter has X no effect on ordinary flat text files, such as program X sources. X X Aliases in the list of destinations are expanded, and X multiple occurrances of the same recipient are eliminated. X The algorithms that manipulate the list of destinations are X case-insensitive. X X FILES X In the spool directory. Files that belong together have the X same sequence number in their name. X D message body (data file) X X destinations (meta file) X X SEE ALSO X ascf(3) ASCII filter X spoolfile(3) create data-file/meta-file pair X path(5) system-dependent path names X unalias(3) alias expansion and cleanup X X DIAGNOSTICS X Error messages if invoked with insufficient arguments. The X program terminates with a nonzero exit status if problems X were detected (out of memory, file access problems, loops in X the alias data base). The exit status indicates the nature X of the problem. X X AUTHOR(S) X W.Z. Venema X Eindhoven University of Technology X Department of Mathematics and Computer Science X Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands X X X X X Page 1 (printed 4/20/88) X X X X X X X SMAIL(1) UNIX 5.0 SMAIL(1) X X X X CREATION DATE X Mon Apr 6 16:58:42 GMT+1:00 1987 X X LAST MODIFICATION X Wed Apr 6 00:22:39 MET 1988 X X VERSION/RELEASE X 1.4 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 2 (printed 4/20/88) X X X END_OF_smail.man if test 1928 -ne `wc -c status.man <<'END_OF_status.man' X X X X STATUS(5) UNIX 5.0 STATUS(5) X X X X NAME X status - process termination status X X PROJECT X pc-mail X X PACKAGE X library X X SYNOPSIS X #include "status.h" X X DESCRIPTION X /* process termination status codes */ X X #define E_SUCCESS 0 /* successfull completion */ X X #define E_SYSFAIL 41 /* operating system failure */ X #define E_NOPROG 42 /* program not found */ X #define E_NOSPOOL 43 /* no spool directory */ X #define E_READERR 44 /* data file read error */ X #define E_WRITERR 45 /* data file write error */ X #define E_CONFUSED 46 /* internal error */ X #define E_UNKNOWN 47 /* unknown error */ X #define E_FILENO 48 /* cannot open enough files */ X #define E_BADSETUP 49 /* bad setup parameter */ X #define E_UNLINK 50 /* cannot remove file */ X #define E_PRINTERR 51 /* printer error */ X #define E_NOUSER 52 /* unknown user */ X #define E_OVALIAS 53 /* alias expansion overflow */ X X /* cico specific codes */ X X #define E_NOLINE 61 /* cannot reach host */ X #define E_NORESP 62 /* no ititial response */ X #define E_REJECT 63 /* rejected by host (unknown,... ) */ X #define E_LOST 64 /* link lost (timeout,...) */ X X SEE ALSO X status(3) error message implementation X X BUGS X The usual error message problem: there is hardly any context X information. A read error is a read error, no info about the X state of processing when it ocurred. X X AUTHOR(S) X W.Z. Venema X Eindhoven University of Technology X Department of Mathematics and Computer Science X Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands X X X X X Page 1 (printed 4/20/88) X X X X X X X STATUS(5) UNIX 5.0 STATUS(5) X X X X CREATION DATE X Sat Apr 11 15:45:37 GMT+1:00 1987 X X LAST MODIFICATION X Mon Apr 4 23:50:40 MET 1988 X X VERSION/RELEASE X 1.3 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Page 2 (printed 4/20/88) X X X END_OF_status.man if test 1998 -ne `wc -c