home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-01-24 | 59.5 KB | 2,341 lines |
- Newsgroups: comp.sources.misc
- subject: v10i039: PC-MAIL release 2, 7/11
- from: wswietse@lso.win.tue.nl (Wietse Venema)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 10, Issue 39
- Submitted-by: wswietse@lso.win.tue.nl (Wietse Venema)
- Archive-name: pcmail2/part07
-
- #! /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 <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 7 (of 11)."
- # Contents: main/deskutil.c main/errdisp.c main/file.c main/kphys.c
- # main/makefile.msc main/makefile.unx main/xpres.c
- # Wrapped by wswietse@tuewsa on Mon Jan 22 17:27:19 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f main/deskutil.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"main/deskutil.c\"
- else
- echo shar: Extracting \"main/deskutil.c\" \(7193 characters\)
- sed "s/^X//" >main/deskutil.c <<'END_OF_main/deskutil.c'
- X/*++
- X/* NAME
- X/* deskutil 3
- X/* SUMMARY
- X/* utility functions
- X/* PROJECT
- X/* pc-mail
- X/* PACKAGE
- X/* mail
- X/* SYNOPSIS
- X/* #include "mail.h"
- X/*
- X/* void patience()
- X/*
- X/* int when()
- X/*
- X/* int delete()
- X/*
- X/* int unspool()
- X/*
- X/* int print()
- X/*
- X/* int save()
- X/*
- X/* int filter()
- X/*
- X/* char *tstamp(ltime)
- X/* long *ltime()
- X/* DESCRIPTION
- X/* tstamp() converts absolute time to a string. If called with a
- X/* recent time argument (less than 100 days ago) the string will
- X/* be of the form "Sun Apr 17 12:50", otherwise "Sun Apr 17 1988".
- X/*
- X/* delete() gives the user another chance before a message is deleted.
- X/*
- X/* unspool() actually deletes a message. As a side effect it destroys
- X/* the current mail box display so that the next display will
- X/* reflect the actual status of the spool directory.
- X/* The affected message and meta file names are taken from the
- X/* global "message" and "commant" string variables.
- X/*
- X/* print() copies a pager file to the printer.
- X/*
- X/* save() asks where the pager file should be saved.
- X/*
- X/* filter() asks the command through which the file being shown should be
- X/* piped. The original file is used.
- X/*
- X/* when() should be called after the user has entered a mail destination
- X/* address. It informs the user that messages are not sent right away,
- X/* but after selection of the Network option in the main menu. This
- X/* function is a no-op on systems that use daemons for message transport.
- X/*
- X/* patience() prints a 'one moment please' message in the middle
- X/* screen window. As a side effect, the current pager file is set
- X/* to none.
- X/* FILES
- X/* mail header files in the spool directory
- X/* SEE ALSO
- X/* pager(3), pager(5), kbdinp(3)
- 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/* CREATION DATE
- X/* Tue May 12 15:35:20 GMT+1:00 1987
- X/* LAST MODIFICATION
- X/* 90/01/22 13:01:32
- X/* VERSION/RELEASE
- X/* 2.1
- X/*--*/
- X
- X#include <stdio.h>
- X#include <errno.h>
- X#include <time.h>
- X
- X#include "defs.h"
- X#include "pager.h"
- X#include "mail.h"
- X#include "screen.h"
- X#include "status.h"
- X
- Xextern struct tm *localtime(); /* std C library */
- X
- Xhidden int save_util();
- Xhidden int pipe_util();
- X
- X/* patience - say this will take some time */
- X
- Xpublic void patience()
- X{
- X static char *m_wait[] = {
- X "",
- X "One moment please...",
- X 0,
- X };
- X
- X register File *pp = open_pager(); /* create pager file */
- X
- X mesg_pager(pp,m_wait); /* write pager file */
- X ds_pager(); /* show on middle window */
- X close_pager(pp); /* forget pager file */
- X}
- X
- X/* delete - user wants to delete a message; ask for confirmation */
- X
- Xpublic int delete()
- X{
- X static Screen screen[] = {
- X ESCCR, "Enter", unspool,int_error,
- X 0, 0, 0,
- X "Press ESC to cancel. Confirm with ENTER",
- X };
- X
- X return(kbdinp(screen)|S_REDRAW);
- X}
- X
- X/* unspool - actually delete a message; force mail box display rebuild */
- X
- Xpublic int unspool()
- X{
- X if (((chmod(message,0666) || unlink(message)) && errno != ENOENT)
- X || ((chmod(comment,0666) || unlink(comment)) && errno != ENOENT)) {
- X errdisp(E_UNLINK); /* notify user of problem */
- X return(S_REDRAW); /* say screen has changed */
- X } else {
- X junk_desk(); /* say mail box has changed */
- X return(S_BREAK); /* no more work to do */
- X }
- X}
- X
- X/* print - print pager display on default printer */
- X
- Xpublic int print()
- X{
- X return(pr_pager() ? (errdisp(E_PRINTERR),S_REDRAW) : 0);
- X}
- X
- X/* save - ask where pager display should be copied to */
- X
- Xpublic int save()
- X{
- X static Screen screen[] = {
- X STRING, 0, save_util,int_error,
- X 0, 0, 0,
- X "Press ESC to cancel. Save to file:",
- X };
- X
- X kbdinp(screen); /* prompt for file name, then copy */
- X return(S_REDRAW); /* force screen repaint */
- X}
- X
- X/* save_util - copy pager file to ordinary file */
- X
- Xhidden int save_util(to)
- Xchar *to;
- X{
- X if (cp_pager(to)) { /* if file copy failed */
- X unlink(to); /* remove that file */
- X errdisp(E_WRITERR); /* notify the user */
- X return(S_BREAK|S_REDRAW); /* redisplay, terminate caller */
- X } else {
- X junk_file(); /* say file display maybe outdated */
- X return(S_BREAK); /* terminate caller */
- X }
- X}
- X
- X/* filter - ask command through which the pager display should be piped */
- X
- Xpublic int filter()
- X{
- X static Screen screen[] = {
- X STRING, 0, pipe_util,int_error,
- X 0, 0, 0,
- X "Press ESC to cancel. Filter through command:",
- X };
- X
- X kbdinp(screen); /* prompt for file name, then copy */
- X return(S_REDRAW); /* force screen repaint */
- X}
- X
- X/* redirect - make old refer to new, close redundant file descriptors */
- X
- Xhidden int redirect(old, new)
- Xint old;
- Xint new;
- X{
- X register int ret;
- X
- X (void) close(old);
- X ret = dup(new);
- X (void) close(new);
- X return (ret != old);
- X}
- X
- X/* pipe_util - pipe external file through command */
- X
- Xhidden int pipe_util(cmd)
- Xchar *cmd;
- X{
- X register int fd_stdin;
- X register int fd_msg;
- X
- X /*
- X * Run command with standard input redirected to the file displayed, and
- X * clean up. Note that the original file is used, not the contents of the
- X * pager. We use system(3), so that the command can be a pipeline. This
- X * code is a bit messy, since it has to run both with UNIX and MS-DOS.
- X */
- X
- X if ((fd_msg = open(message, 0)) < 0) {
- X errdisp(E_READERR);
- X } else {
- X kbdrest(); /* cooked-mode input */
- X if ((fd_stdin = dup(0)) < 0) { /* save standard input */
- X kbdinit(); /* raw-mode input */
- X errdisp(E_SYSFAIL);
- X } else {
- X (void) putchar('\n');
- X if (redirect(0, fd_msg)) /* re-direct standard input */
- X fatal("cannot re-direct standard input");
- X (void) system(cmd); /* try to execute command */
- X if (redirect(0, fd_stdin)) /* restore standard input */
- X fatal("cannot restore standard input");
- X kbdinit(); /* raw-mode input */
- X (void) printf(anykey);
- X (void) getkey();
- X junk_file(); /* file display outdated */
- X }
- X }
- X return (S_BREAK | S_REDRAW); /* terminate caller */
- X}
- X
- X/* when - say when mail will actually be sent */
- X
- Xpublic int when()
- X{
- X#ifndef DAEMON
- X static char *msg[] = {
- X "",
- X "To send messages through the network, use the Network",
- X "option in the main menu.",
- X 0,
- X };
- X File *pp = open_pager(); /* open new pager file */
- X
- X mesg_pager(pp,msg); /* fill pager file */
- X ds_pager(); /* display the file */
- X close_pager(pp); /* forget pager file */
- X#endif
- X return(0); /* don't care value */
- X}
- X
- X/* tstamp - time format as produced by the ls(1) command */
- X
- Xpublic char *tstamp(ltime)
- Xlong *ltime;
- X{
- X static char buf[25];
- X
- X /*
- X * Output from asctime() is of the form
- X *
- X * "Sun Apr 17 13:34:35 1988\n"
- X *
- X * Depending on how recent the time in question is, we supress the time or
- X * year field. The weekday field is always suppressed.
- X */
- X
- X (void) strcpy(buf, asctime(localtime(ltime)));
- X if (time((long *) 0) - *ltime > 60L * 60L * 24L * 100L) {
- X buf[24] = '\0'; /* remove the \n */
- X (void) strcpy(buf + 11, buf + 19); /* old, show year */
- X } else
- X buf[16] = '\0'; /* recent, show time */
- X return (buf + 4);
- X}
- END_OF_main/deskutil.c
- if test 7193 -ne `wc -c <main/deskutil.c`; then
- echo shar: \"main/deskutil.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f main/errdisp.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"main/errdisp.c\"
- else
- echo shar: Extracting \"main/errdisp.c\" \(8055 characters\)
- sed "s/^X//" >main/errdisp.c <<'END_OF_main/errdisp.c'
- X/*++
- X/* NAME
- X/* errdisp 3
- X/* SUMMARY
- X/* produce an error message display
- X/* PROJECT
- X/* pc-mail
- X/* PACKAGE
- X/* mail
- X/* SYNOPSIS
- X/* int errdisp(errcode);
- X/* int errcode;
- X/* DESCRIPTION
- X/* errdisp() produces an error display in the middle screen
- X/* window. The error code must be one defined in status.h.
- X/* Otherwise, an "unknown error" message is displayed.
- X/* errdisp() gives the user a chance to read it, before resuming
- X/* the program. errdisp() returns its argument, or the
- X/* value E_UNKNOWN if an unknown error code was specified.
- X/* FUNCTIONS AND MACROS
- X/* kbdinp(), open_pager(), app_pager(), ds_pager(), close_pager()
- X/* BUGS
- X/* Cannot force the user to really stop. It just recommends
- X/* to do so.
- 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/* CREATION DATE
- X/* Thu Apr 9 21:19:05 GMT+1:00 1987
- X/* LAST MODIFICATION
- X/* 90/01/22 13:01:36
- X/* VERSION/RELEASE
- X/* 2.1
- X/*--*/
- X
- X#include "defs.h"
- X#include "screen.h"
- X#include "pager.h"
- X#include "status.h"
- X#include "window.h"
- X
- X/* forward declarations */
- X
- Xhidden int ds_error();
- X
- X/* A list of error mesages */
- X
- X/* when the spool directory is not found */
- X
- Xhidden char *e_nospool[] = {
- X "",
- X "The mail program cannot access essential data files.",
- X "",
- X "Please check whether the spool directory is present",
- X "and whether the environment variable MAILDIR has been",
- X "set correctly.",
- X 0,
- X};
- X
- X/* when we cannot open as many files as we need */
- X
- Xhidden char *e_fileno[] = {
- X "",
- X#ifdef MSDOS
- X "Check your CONFIG.SYS file. It should have a line",
- X "stating (for example)",
- X " FILES = 20 .",
- X "While you're at it, also make sure that file also",
- X "has a line (for example)",
- X " DEVICE = ANSI.SYS .",
- X "If your system does not have such a file create",
- X "one with an editor and place the file in the root",
- X "directory.",
- X "Reboot after making the changes and try again.",
- X#endif
- X#ifdef unix
- X "Your UNIX is crippled (not enough file descriptors",
- X "per process). Rebuild the system or buy a better one.",
- X#endif
- X 0,
- X};
- X
- X/* when a program is not found */
- X
- Xhidden char *e_noprog[] = {
- X "",
- X "The mail program cannot execute an essential program file.",
- X "",
- X "Please make sure that the environment variable PATH has",
- X "been set to include the directories with the SMAIL, NMAIL,",
- X#ifdef DAEMON
- X "and EDITOR programs.",
- X#else
- X "CICO and EDITOR programs.",
- X#endif
- X "Also, make sure that the environment variable EDITOR has",
- X "been set to the editor of your preference, and that the",
- X "machine has enough free memory",
- X 0,
- X};
- X
- X/* when a read error ocurred, or a file could not be opened */
- X
- Xhidden char *e_readerr[] = {
- X "",
- X "The mail program cannot read a data file.",
- X "",
- X "Please check your disk. This may be a serious problem.",
- X 0,
- X};
- X
- X/* when a write error occurred */
- X
- Xhidden char *e_writerr[] = {
- X "",
- X "The mail program cannot write a data file.",
- X "",
- X "Please make sure that the disk is not write protected",
- X "and that there is sufficient free space.",
- X 0,
- X};
- X
- X/* when the program is confused */
- X
- Xhidden char *e_confused[] = {
- X "",
- X "The mail program has detected a serious internal problem.",
- X "",
- X "You are requested to leave the mail system as it is and",
- X "call an expert.",
- X 0,
- X};
- X
- X/* an unknown error (perhaps the editor returned a nonzero status) */
- X
- Xhidden char *e_unknown[] = {
- X "",
- X "The mail program has detected a unknown error. This may",
- X "not be a serious problem.",
- X 0,
- X};
- X
- X/* when the UNIX host does not ask for login/password */
- X
- Xhidden char *e_noline[] = {
- X "",
- X "The mail program is not able to exchange mail with the",
- X "network.",
- X "",
- X "Please check the password, or try again later.",
- X 0,
- X};
- X
- X/* when the UNIX host does not send initial protocol messages */
- X
- Xhidden char *e_noresp[] = {
- X "",
- X "The mail program is not able to exchange mail with the",
- X "network. Probably the password was incorrect.",
- X 0,
- X};
- X
- X/* when the UNIX host does not want to talk to us */
- X
- Xhidden char *e_reject[] = {
- X "",
- X "The mail program is not able to exchange mail with the",
- X "network. Please contact the system administrator who is",
- X "responsible for the nearest UNIX system.",
- X 0,
- X};
- X
- X/* when the link is lost (timeout,...) */
- X
- Xhidden char *e_lost[] = {
- X "",
- X "The mail program has lost contact with the network.",
- X "",
- X "We suggest that you try again at a later time.",
- X 0,
- X};
- X
- X/* the resources are exhausted */
- X
- Xhidden char *e_sysfail[] = {
- X "",
- X "The mail program cannot proceed due to the fact",
- X "that the computer system is overloaded.",
- X "",
- X "Consult your local systems manager.",
- X 0,
- X};
- X
- X/* bad setup parameter */
- X
- Xhidden char *e_badsetup[] = {
- X "",
- X "The mail program cannot communicate with the network",
- X "due to missing or invalid data in the setup.",
- X "",
- X "Check the Setup command in the main menu.",
- X 0,
- X};
- X
- X/* when a file could not be removed */
- X
- Xhidden char *e_unlink[] = {
- X "",
- X "The mail program cannot remove a data file.",
- X "",
- X "Please make sure that your disk is not write protected",
- X 0,
- X};
- X
- X/* when a file could not be printed */
- X
- Xhidden char *e_printerr[] = {
- X "",
- X "The mail programm cannot write to the printer",
- X "",
- X "Please check your default printer device",
- X 0,
- X};
- X
- Xhidden char *e_nouser[] = {
- X "",
- X "An unknown local user name was specified",
- X "",
- X "Please check the list of user names",
- X 0,
- X};
- X
- Xhidden char *e_ovalias[] = {
- X "",
- X "There probably is an error in your alias data base,",
- X "such that an alias is defined in terms of itself.",
- X "",
- X "Please check your alias data base, and then try to",
- X "send this message again.",
- X 0,
- X};
- X
- Xhidden char *e_toolong[] = {
- X "",
- X "The list of recipients is too long.",
- X "",
- X "There is no easy solution to this problem; you might",
- X "ask your UNIX system administrator to set up a mailing",
- X "list, and use the name of that mailing list instead.",
- X 0,
- X};
- X
- X/* The folowing data structure links an error code to an error message */
- X
- Xtypedef struct {
- X short code; /* error return value */
- X char **msg; /* associated message */
- X} msgmap;
- X
- Xhidden msgmap errmap[] = { /* lookup table for error codes */
- X E_UNKNOWN, e_unknown, /* don't remove this one! */
- X E_SYSFAIL, e_sysfail,
- X E_NOPROG, e_noprog, /* and error messages */
- X E_NOSPOOL, e_nospool,
- X E_READERR, e_readerr,
- X E_WRITERR, e_writerr,
- X E_CONFUSED, e_confused,
- X E_FILENO, e_fileno,
- X E_NOLINE, e_noline,
- X E_NORESP, e_noresp,
- X E_REJECT, e_reject,
- X E_LOST, e_lost,
- X E_BADSETUP, e_badsetup,
- X E_UNLINK, e_unlink,
- X E_PRINTERR, e_printerr,
- X E_NOUSER, e_nouser,
- X E_OVALIAS, e_ovalias,
- X E_TOOLONG, e_toolong,
- X 0, 0, /* terminator */
- X};
- X
- X/* errdisp - set up error pager file, return error code */
- X
- Xpublic int errdisp(code)
- Xint code;
- X{
- X static Screen screen[] = {
- X ENTER, "Enter", 0, "Resume the mail program",
- X 0, 0, ds_error,"Press ENTER to continue",
- X };
- X register msgmap *mp;
- X
- X /* linear table search; this code is not used heavily */
- X
- X for (mp = errmap; mp->code && mp->code != code; mp++)
- X /* void */ ; /* look it up in table */
- X if (mp->code == 0) {
- X return(errdisp(E_UNKNOWN)); /* unknown error code */
- X } else {
- X File *pp = open_pager(); /* open pager file */
- X mesg_pager(pp,mp->msg); /* copy to pager file */
- X beep(); /* red alert! red alert! */
- X kbdinp(screen); /* give a chance to read it */
- X close_pager(pp); /* forget screen display */
- X return(code); /* return error code */
- X }
- X}
- X
- X/* ds_error - display error window */
- X
- Xhidden int ds_error()
- X{
- X ds_pager(); /* use "current" pager file */
- X return(0); /* say screen up-to-date */
- X}
- END_OF_main/errdisp.c
- if test 8055 -ne `wc -c <main/errdisp.c`; then
- echo shar: \"main/errdisp.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f main/file.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"main/file.c\"
- else
- echo shar: Extracting \"main/file.c\" \(7309 characters\)
- sed "s/^X//" >main/file.c <<'END_OF_main/file.c'
- X/*++
- X/* NAME
- X/* file 3
- X/* SUMMARY
- X/* manipulate ordinary files
- X/* PROJECT
- X/* pc-mail
- X/* PACKAGE
- X/* mail
- X/* SYNOPSIS
- X/* int file()
- X/*
- X/* int junk_file()
- X/* DESCRIPTION
- X/* file() is called when the user selected the "file" option
- X/* in the main menu. The pager displays a directory listing on the
- X/* screen. The user may then walk through the file display and
- X/* select a file or directory.
- X/*
- X/* In case a regular file is selected the user may specify
- X/* an action (send file as mail, delete file, display
- X/* file, print file, copy file to workfile for subsequent
- X/* editing etc.).
- X/*
- X/* junk_file() should be invoked when the file display is no longer
- X/* valid.
- X/* FILES
- X/* By selecting directory files the user can walk through the whole
- X/* file system.
- X/* SEE ALSO
- X/* kbdinp(3), pager(3)
- X/* BUGS
- X/* MS-DOS has no "." or ".." entries in the root directory, and
- X/* subdirectories of an MS-DOS root directory have no ".." entry.
- X/*
- X/* Changing the current directory may cause problems if
- X/* environment variables are defined in terms of relative path names.
- X/*
- X/* There is no provision to change the "default drive" on systems
- X/* that use such abominations.
- 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/* CREATION DATE
- X/* Sun Apr 5 17:18:06 GMT+1:00 1987
- X/* LAST MODIFICATION
- X/* 90/01/22 13:01:37
- X/* VERSION/RELEASE
- X/* 2.1
- X/*--*/
- X
- X#include <stdio.h>
- X#include <time.h>
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X#include <ctype.h>
- X
- X#include "defs.h"
- X#include "screen.h"
- X#include "pager.h"
- X#include "mail.h"
- X#include "ndir.h"
- X#include "path.h"
- X#include "status.h"
- X#include "window.h"
- X
- Xextern struct tm *localtime(); /* std C library */
- X
- Xhidden File *bldlist(); /* forward declaration */
- Xhidden int show_list();
- Xhidden int pick_file();
- Xhidden int delfile();
- Xhidden int show_file();
- Xhidden int rmfile();
- X
- Xhidden File *dfile = 0; /* file listing */
- Xhidden File *dirfile = 0; /* directory listing */
- Xhidden char file_prompt[BUFSIZ]; /* prompt with directory name */
- Xhidden char file_dir[BUFSIZ]; /* prompt with directory name */
- Xhidden char prompt_fmt[] = "To display a file, select it with \
- Xthe cursor keys, then press ENTER\n(showing directory: \"%s\")";
- X
- X/* file - called from keyboard interpreter, call keyboard driver */
- X
- Xpublic int file()
- X{
- X char *getcwd();
- X char thisdir[BUFSIZ];
- X
- X static Screen screen[] = {
- X 'C', "Close",0, prevscreen,
- X 'P', "Print",print, "Print file listing",
- X 'S', "Save", save, "Save file listing to ordinary file",
- X PGUP, PgUp, pu_pager,pageup,
- X PGDN, PgDn, pd_pager,pagedn,
- X UP, "Up", up_pager,csrup,
- X DOWN, "Down", dn_pager,csrdn,
- X ENTER, "Enter",pick_file,"Display file at cursor",
- X 0, 0, show_list,
- X file_prompt,
- X };
- X
- X (void) getcwd(thisdir, sizeof(thisdir)); /* save current directory */
- X sprintf(file_prompt, prompt_fmt, thisdir); /* put cwd in prompt */
- X kbdinp(screen); /* set up dialogue */
- X close_pager(dirfile); /* deallocate pager file */
- X dirfile = 0; /* say it's gone */
- X (void) chdir(thisdir); /* restore current directory */
- X return (S_REDRAW); /* force screen update */
- X}
- X
- X/* show_list - create or refresh file listing */
- X
- Xhidden int show_list()
- X{
- X if (dirfile == 0) { /* no pager file? */
- X dirfile = bldlist(); /* create one */
- X } else {
- X set_pager(dirfile); /* select existing pager file */
- X }
- X ds_pager(); /* display the thing */
- X return (0); /* say screen is up-to-date */
- X}
- X
- X/* bldlist - build file listing display */
- X
- Xhidden File *bldlist()
- X{
- X register File *pp;
- X register DIR *dp;
- X register struct direct *de;
- X struct stat s;
- X
- X patience();
- X
- X if ((dp = opendir(THISDIR)) == 0) {
- X fatal("insufficient memory for operation");
- X /* NOTREACHED */
- X } else {
- X pp = open_pager(); /* allocate pager file */
- X
- X while (de = readdir(dp)) { /* read next file name */
- X if (stat(de->d_name, &s) == 0) { /* get file info */
- X if ((s.st_mode & S_IFMT) == S_IFDIR)
- X app_pager(pp, strcons("%-20s %9s %s", de->d_name,
- X "<dir>", tstamp(&s.st_mtime)));
- X else
- X app_pager(pp, strcons("%-20s %9ld %s", de->d_name,
- X s.st_size, tstamp(&s.st_mtime)));
- X }
- X }
- X sort_pager(pp, FORW_SORT); /* sort by file name */
- X
- X (void) getcwd(file_dir, sizeof(file_dir));
- X sprintf(file_prompt, prompt_fmt, file_dir); /* put cwd in prompt */
- X
- X closedir(dp); /* directory search done */
- X return (pp); /* current pager file */
- X }
- X}
- X/* pick_file - display selected file or change directory */
- X
- Xhidden int pick_file()
- X{
- X static char botline[80];
- X static Screen screen[] = {
- X 'C', "Close",0, "Return to file listing",
- X 'D', "Delete",delfile, "Delete this file",
- X 'M', "Mail", mailfile, "Mail a copy of this file",
- X 'P', "Print",print, "Print this file",
- X 'S', "Save", save, "Save a copy to an ordinary file",
- X 'W', "Work", makework, "Save a copy to a work file",
- X '|', "|", filter, "Filter file through command",
- X PGUP, PgUp, pu_pager, pageup,
- X PGDN, PgDn, pd_pager, pagedn,
- X UP, "Up", up_pager, csrup,
- X DOWN, "Down", dn_pager, csrdn,
- X 0, 0, show_file,
- X botline,
- X };
- X struct stat s;
- X
- X if (!sscanf(gets_pager(), "%s", message)) { /* cannot read name */
- X beep(); /* "notify" user */
- X return (0); /* nothing happened */
- X } else if (access(message, 04)
- X || stat(message, &s)) { /* cannot read file */
- X beep(); /* "notify" user */
- X return (0); /* nothing happened */
- X } else if ((s.st_mode & S_IFMT) == S_IFDIR) { /* directory file */
- X chdir(message); /* change directory */
- X close_pager(dirfile); /* purge display */
- X dirfile = bldlist(); /* new file display */
- X return (S_REDRAW); /* update display */
- X } else { /* ordinary file */
- X sprintf(botline, "(Reading file \"%s\")", message);
- X kbdinp(screen); /* look at screen */
- X close_pager(dfile); /* and forget it */
- X dfile = 0; /* say it's gone */
- X return (S_REDRAW); /* force redrawing */
- X }
- X}
- X
- X/* show_file - create or refresh display of selected file */
- X
- Xhidden int show_file()
- X{
- X if (dfile) {
- X set_pager(dfile); /* select dispay */
- X } else {
- X if (rd_pager(dfile = open_pager(),
- X message)) /* try to read file */
- X mesg_pager(dfile, m_msgread); /* read error */
- X }
- X ds_pager(); /* rewrite screen */
- X return (0); /* screen up-to-date */
- X}
- X
- X/* delfile - ask confirmation before removing a file */
- X
- Xhidden int delfile()
- X{
- X static Screen screen[] = {
- X ESCCR, 0, rmfile, int_error,
- X 0, 0, 0,
- X "Press ESC to cancel. Confirm with ENTER",
- X };
- X
- X return (kbdinp(screen) | S_REDRAW); /* "are you sure?" */
- X}
- X
- X/* rmfile - actually remove file */
- X
- Xhidden int rmfile()
- X{
- X if (unlink(message)) { /* try to remove file */
- X errdisp(E_UNLINK); /* notify the user */
- X return (S_BREAK | S_REDRAW); /* redisplay, stop caller */
- X } else {
- X junk_file(); /* say file display outdated */
- X return (S_BREAK); /* terminate caller */
- X }
- X}
- X
- X/* junk_file - directory listing is no longer up to date */
- X
- Xpublic int junk_file()
- X{
- X if (dirfile) {
- X close_pager(dirfile); /* close pager file */
- X dirfile = 0; /* say it is gone */
- X }
- X return (0); /* in case we need that */
- X}
- END_OF_main/file.c
- if test 7309 -ne `wc -c <main/file.c`; then
- echo shar: \"main/file.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f main/kphys.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"main/kphys.c\"
- else
- echo shar: Extracting \"main/kphys.c\" \(7513 characters\)
- sed "s/^X//" >main/kphys.c <<'END_OF_main/kphys.c'
- X/*++
- X/* NAME
- X/* kphys 3
- X/* SUMMARY
- X/* k protocol packet exchange
- X/* PACKAGE
- X/* uucp across the TUEnet
- X/* SYNOPSIS
- X/* #include "kp.h"
- X/*
- X/* kspack(fd,type,num,size,data)
- X/* int fd, num, size;
- X/* char type, data[MAXPACKSIZ];
- X/*
- X/* krpack(fd,num,size,data)
- X/* int fd, *num, *size;
- X/* char data[MAXPACKSIZ];
- X/* DESCRIPTION
- X/* The functions in this file take care of data framing and verification.
- X/*
- X/* Kspack() sends a packet of the specified type and number,
- X/* and with len data bytes.
- X/*
- X/* Krpack() tries to receive a packet and returns: the packet type plus
- X/* size and data, or TIME (no packet) or FAIL (bad checksum).
- X/*
- X/* The data format has been derived from kermit implementations:
- X/*
- X/* .nf
- X/* .in +5
- X/* SOH packet header, ASCII control-P
- X/* len (size of data, low 6 bits) + 32
- X/* len (size of data, high 6 bits) + 32
- X/* num (packet number mod 64) + 32
- X/* type packet type
- X/* check one-byte type-1 kermit checksum
- X/*
- X/* The header is followed by checksummed data if len >0:
- X/*
- X/* .nf
- X/* .in +5
- X/* data len data bytes
- X/* check1 (upper 2 bits of type-3 kermit 16-bit checksum) + 32
- X/* check2 (middle 6 bits of type-3 kermit 16-bit checksum) + 32
- X/* check3 (lower 6 bits of type-3 kermit 16-bit checksum) + 32
- X/*
- X/* Every packet is followed by an ASCII carriage return, which is
- X/* ignored upon reception of a packet. It prevents timeout errors
- X/* when one byte gets lost (the most common case).
- X/* BUGS
- X/* It is yet another convention for data framing.
- X/* AUTHOR(S)
- X/* Wietse 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/* CREATION DATE
- X/* Mon Feb 3 13:38:14 MET 1986
- X/* LAST MODIFICATION
- X/* 90/01/22 13:01:56
- X/* VERSION/RELEASE
- X/* 2.1
- X/*--*/
- X
- X#include <signal.h>
- X#include <setjmp.h>
- X#include "kp.h"
- X
- X#define READS(fd,ch) {if (read(fd,&ch,1) < 0) clkint(); if ((ch &= 0177) == SOH) goto SYNC;}
- X
- Xjmp_buf env; /* Environment ptr for timeout longjump */
- X
- Xclkint() /* Timer interrupt handler */
- X{
- X longjmp(env,TRUE); /* Tell krpack to give up */
- X}
- X
- Xkspack(fd,type,num,len,data)
- Xint fd;
- Xchar type, *data;
- Xint num, len;
- X{
- X char chksum, header[6], chk[3]; /* Checksums, header */
- X
- X DEBUG(7,"xmt: type %c\n",type);
- X if (len > 0)
- X DEBUG(7,"xmt: data %d\n",len);
- X
- X header[0] = SOH; /* Packet marker (SOH) */
- X header[1] = tosix(len); /* Send the character count */
- X chksum = header[1]; /* Initialize the checksum */
- X header[2] = tosix(len>>OUT); /* Send the character count */
- X chksum += header[2]; /* Update checksum */
- X header[3] = tochar(num); /* Packet number */
- X chksum += header[3]; /* Update checksum */
- X header[4] = type; /* Packet type */
- X chksum += header[4]; /* Update checksum */
- X chksum = (((chksum&0300) >> 6)+chksum)&077; /* Compute header checksum */
- X header[5] = tochar(chksum); /* Put it in the packet */
- X write(fd,header,6); /* Send the header */
- X
- X if (len > 0) { /* Make data packet */
- X write(fd,data,len); /* Send data */
- X chk3(data,len,chk); /* Compute 16-bit checksum */
- X write(fd,chk,3); /* Send checksum */
- X }
- X write(fd,"\r",1); /* Extra-packet line terminator */
- X}
- X
- Xkrpack(fd,num,len,data)
- Xint fd;
- Xint *num; /* Packet number */
- Xint *len; /* Packet length */
- Xchar *data; /* Packet data */
- X{
- X int i; /* Data character number, loop exit */
- X char t, /* Current input character */
- X type, /* Packet type */
- X rchk[3], /* Data checksum from host */
- X cchk[3], /* Data checksum computed here */
- X cchksum, /* Our (computed) checksum */
- X rchksum; /* Header checksum from other host */
- X
- X if (setjmp(env)) {
- X DEBUG(7,"rcv: timed out\n","");
- X return TIME; /* Timed out */
- X }
- X signal(SIGALRM,clkint); /* Setup the timeout */
- X alarm(TIMEOUT);
- X
- X for (;;) /* Wait for packet header */
- X READS(fd,t);
- XSYNC: /* Got SOH */
- X alarm(TIMEOUT);
- X DEBUG(7,"rcv: found sync\n","");
- X READS(fd,t); /* Get character */
- X cchksum = t; /* Start the checksum */
- X *len = unchar(t); /* Character count, low six bits */
- X
- X READS(fd,t); /* Get character */
- X cchksum += t; /* Update checksum */
- X *len += (unchar(t)<<OUT); /* Character count, high six bits */
- X
- X READS(fd,t); /* Get character */
- X cchksum += t; /* Update checksum */
- X *num = unchar(t); /* Packet number */
- X
- X READS(fd,t); /* Get character */
- X cchksum += t; /* Update checksum */
- X type = t; /* Packet type */
- X
- X READS(fd,t); /* Get header checksum */
- X rchksum = unchar(t); /* Convert to numeric */
- X /* Fold in bits 7,8 to compute */
- X cchksum = (((cchksum&0300) >> 6)+cchksum)&077; /* header checksum */
- X
- X if (cchksum != rchksum) {
- X DEBUG(7,"rcv: bad header\n","");
- X alarm(0); /* Disable the timer interrupt */
- X return FAIL;
- X }
- X DEBUG(7,"rcv: type %c\n",type);
- X
- X if ((*len > 0) && (data != NULLP))
- X {
- X for (i=0; i<*len; i++) /* The data itself, if any */
- X { /* Loop for character count */
- X READS(fd,t); /* Get character */
- X data[i] = t; /* Keep data */
- X }
- X
- X for (i=0; i<3; i++) /* 16-bit CRC checksum */
- X {
- X READS(fd,t); /* Get character */
- X rchk[i] = t; /* Keep data */
- X }
- X
- X chk3(data,*len,cchk); /* Compute CRC */
- X if (strncmp(rchk,cchk,3)) { /* Check with received CRC */
- X DEBUG(7,"rcv: bad data\n","");
- X alarm(0); /* Disable the timer interrupt */
- X return FAIL;
- X }
- X DEBUG(7,"rcv: data %d\n",*len);
- X }
- X alarm(0); /* Disable the timer interrupt */
- X return(type); /* All OK, return packet type */
- X}
- X
- X/* C H K 3 -- Compute a type-3 Kermit block check. */
- X/*
- XCalculate the 16-bit CRC of a string using a byte-oriented
- Xtableless algorithm invented by Andy Lowry (Columbia University). The
- Xmagic number 010201 is derived from the CRC-CCITT polynomial x^16+x^12+x^5+1.
- X*/
- Xstatic chk3(s,len,chk)
- Xchar *s, *chk;
- Xint len;
- X{
- X unsigned int c, q;
- X long crc = 0;
- X
- X while (len--) {
- X c = *s++;
- X q = (crc ^ c) & 017; /* Low-order nibble */
- X crc = (crc >> 4) ^ (q * 010201);
- X q = (crc ^ (c >> 4)) & 017; /* High order nibble */
- X crc = (crc >> 4) ^ (q * 010201);
- X }
- X *chk++ = tochar(((unsigned)(crc & 0170000)) >> 12);
- X *chk++ = tochar((crc & 07700) >> 6);
- X *chk++ = tochar(crc & 077);
- X}
- END_OF_main/kphys.c
- if test 7513 -ne `wc -c <main/kphys.c`; then
- echo shar: \"main/kphys.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f main/makefile.msc -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"main/makefile.msc\"
- else
- echo shar: Extracting \"main/makefile.msc\" \(8027 characters\)
- sed "s/^X//" >main/makefile.msc <<'END_OF_main/makefile.msc'
- X# @(#) makefile.msc 2.1 1/22/90 13:02:07
- X
- X# Makefile for Microsoft C and MS-DOS
- X
- X##################
- X# Beginning of configurable options
- X
- X# Choose a message-transport mechanism, and select the corresponding definition
- X# of the DAEMON and PROGRAMS macros:
- X#
- X# 1 - The UUCP file transfer software provided with pc-mail (see the DEFAULT.ins
- X# document):
- X#
- X# DAEMON =
- X# PROGRAMS= mail.exe smail.exe nmail.exe cmail.exe cico.exe
- X#
- X# 2 - Daemon processes, presumably running on a file server (see the SLAVE.ins
- X# document):
- X#
- X# DAEMON = -DDAEMON
- X# PROGRAMS= mail.exe smail.exe nmail.exe cmail.exe
- X#
- X# 3 - Message transport by GNUUCP (see the GNUUCP.ins document):
- X#
- X# DAEMON = -DDAEMON
- X# PROGRAMS= mail.exe.exe smail.exe nmail.exe cmail.exe gmail.exe lmail.exe
- X
- XDAEMON =
- XPROGRAMS= mail.exe smail.exe nmail.exe cmail.exe
- X
- X# Memory model; use large for everything but the cico program.
- X
- XMODEL = -Ml
- X
- X# End of configurable options
- X##################
- X
- XMV = ren
- XRM = del
- XCC = cl
- XCFLAGS = $(DAEMON) $(MODEL)
- XLDFLAGS = -F 2000 $(MODEL)
- X
- XTERMCAP = ..\termcap\termcap.lib
- X
- XSHOBJ1 = call.obj email.obj file.obj screen.obj mbox.obj desk.obj reply.obj
- XSHOBJ2 = create.obj kbdinp.obj pager.obj window.obj setup.obj errdisp.obj
- XSHOBJ3 = invoke.obj textcopy.obj makework.obj mailfile.obj deskutil.obj
- XSHOBJ4 = submit.obj edit.obj alias.obj snapshot.obj
- XSHLIBS = shlib1.lib shlib2.lib shlib3.lib shlib4.lib
- X
- XSMOBJ = smail.obj unalias.obj hsearch.obj
- X
- XCMOBJ = cmail.obj invoke.obj
- X
- XNMOBJ = nmail.obj
- X
- XGMOBJ = gmail.obj
- X
- XLMOBJ = lmail.obj
- X
- XCIOBJ = cico.obj comport.obj
- XCIOBJ1 = comm.obj connect.obj getwork.obj kphys.obj kpres.obj ktrans.obj
- XCIOBJ2 = logs.obj newseqno.obj protomsg.obj rmtname.obj scanwork.obj gphys.obj
- XCIOBJ3 = sendwork.obj startup.obj switcher.obj xpres.obj gpres.obj gtrans.obj
- XCILIBS = cilib1.lib cilib2.lib cilib3.lib
- X
- XGNOBJ = msd_dir.obj myalloc.obj params.obj path.obj newseqno.obj ascf.obj \
- X spoolfil.obj str.obj ms_parse.obj
- X
- X.SUFFIXES: .obj .asm
- X
- X.asm.obj:
- X masm $*.asm ;
- X
- X.c.obj:
- X $(CC) $(CFLAGS) -c $*.c
- X
- Xall: $(PROGRAMS)
- X
- Xmail.exe: mail.obj $(SHLIBS) libgen.lib
- X $(CC) $(LDFLAGS) -o $@ mail.obj -link $(SHLIBS) libgen.lib $(TERMCAP)
- X -exepack $@ junk
- X $(RM) $@
- X $(MV) junk $@
- X
- Xsmail.exe: $(SMOBJ) libgen.lib
- X $(CC) $(LDFLAGS) -o $@ $(SMOBJ) -link libgen.lib
- X -exepack $@ junk
- X $(RM) $@
- X $(MV) junk $@
- X
- Xcmail.exe: $(CMOBJ) libgen.lib
- X $(CC) $(LDFLAGS) -o $@ $(CMOBJ) -link libgen.lib
- X -exepack $@ junk
- X $(RM) $@
- X $(MV) junk $@
- X
- Xnmail.exe: $(NMOBJ) libgen.lib
- X $(CC) $(LDFLAGS) -o $@ $(NMOBJ) -link libgen.lib
- X -exepack $@ junk
- X $(RM) $@
- X $(MV) junk $@
- X
- Xgmail.exe: $(GMOBJ) libgen.lib
- X $(CC) $(LDFLAGS) -o $@ $(GMOBJ) -link libgen.lib
- X -exepack $@ junk
- X $(RM) $@
- X $(MV) junk $@
- X
- Xlmail.exe: $(LMOBJ) libgen.lib
- X $(CC) $(LDFLAGS) -o $@ $(LMOBJ) -link libgen.lib
- X -exepack $@ junk
- X $(RM) $@
- X $(MV) junk $@
- X
- Xcico.exe: $(CIOBJ) $(CILIBS) libgen.lib
- X $(CC) $(LDFLAGS) -o $@ $(CIOBJ) -link $(CILIBS) libgen.lib
- X -exepack $@ junk
- X $(RM) $@
- X $(MV) junk $@
- X
- Xshlib1.lib: $(SHOBJ1)
- X $(RM) $@
- X lib $@ $(SHOBJ1) ;
- X
- Xshlib2.lib: $(SHOBJ2)
- X $(RM) $@
- X lib $@ $(SHOBJ2) ;
- X
- Xshlib3.lib: $(SHOBJ3)
- X $(RM) $@
- X lib $@ $(SHOBJ3) ;
- X
- Xshlib4.lib: $(SHOBJ4)
- X $(RM) $@
- X lib $@ $(SHOBJ4) ;
- X
- Xlibgen.lib: $(GNOBJ)
- X $(RM) $@
- X lib libgen $(GNOBJ) ;
- X
- Xcilib1.lib: $(CIOBJ1)
- X $(RM) $@
- X lib $@ $(CIOBJ1) ;
- X
- Xcilib2.lib: $(CIOBJ2)
- X $(RM) $@
- X lib $@ $(CIOBJ2) ;
- X
- Xcilib3.lib: $(CIOBJ3)
- X $(RM) $@
- X lib $@ $(CIOBJ3) ;
- X
- Xdepend:
- X @grep '^# *include *"' *.c|sed 's/c:# *include *"\([^"]*\)".*/obj: \1/g'
- X
- Xalias.obj: defs.h
- Xalias.obj: path.h
- Xalias.obj: pager.h
- Xalias.obj: mail.h
- Xalias.obj: screen.h
- Xalias.obj: status.h
- Xascf.obj: defs.h
- Xascf.obj: ascf.h
- Xcall.obj: defs.h
- Xcall.obj: path.h
- Xcall.obj: screen.h
- Xcall.obj: pager.h
- Xcall.obj: mail.h
- Xcico.obj: defs.h
- Xcico.obj: logs.h
- Xcico.obj: params.h
- Xcico.obj: comm.h
- Xcico.obj: status.h
- Xcico.obj: path.h
- Xcmail.obj: defs.h
- Xcmail.obj: ndir.h
- Xcmail.obj: path.h
- Xcmail.obj: status.h
- Xcomm.obj: defs.h
- Xcomm.obj: params.h
- Xcomm.obj: comm.h
- Xconnect.obj: defs.h
- Xconnect.obj: params.h
- Xconnect.obj: status.h
- Xconnect.obj: comm.h
- Xconnect.obj: logs.h
- Xconnect.obj: sysdep.h
- Xcreate.obj: defs.h
- Xcreate.obj: path.h
- Xcreate.obj: mail.h
- Xcreate.obj: status.h
- Xcreate.obj: screen.h
- Xdesk.obj: defs.h
- Xdesk.obj: mail.h
- Xdesk.obj: path.h
- Xdesk.obj: ndir.h
- Xdesk.obj: pager.h
- Xdesk.obj: screen.h
- Xdesk.obj: status.h
- Xdesk.obj: window.h
- Xdesk.obj: ascf.h
- Xdesk.obj: snapshot.h
- Xdeskutil.obj: defs.h
- Xdeskutil.obj: pager.h
- Xdeskutil.obj: mail.h
- Xdeskutil.obj: screen.h
- Xdeskutil.obj: status.h
- Xedit.obj: defs.h
- Xedit.obj: path.h
- Xedit.obj: mail.h
- Xedit.obj: status.h
- Xemail.obj: defs.h
- Xemail.obj: path.h
- Xemail.obj: pager.h
- Xemail.obj: screen.h
- Xemail.obj: mail.h
- Xemail.obj: status.h
- Xerrdisp.obj: defs.h
- Xerrdisp.obj: screen.h
- Xerrdisp.obj: pager.h
- Xerrdisp.obj: status.h
- Xerrdisp.obj: window.h
- Xfile.obj: defs.h
- Xfile.obj: screen.h
- Xfile.obj: pager.h
- Xfile.obj: mail.h
- Xfile.obj: ndir.h
- Xfile.obj: path.h
- Xfile.obj: status.h
- Xfile.obj: window.h
- Xgetwork.obj: defs.h
- Xgetwork.obj: logs.h
- Xgetwork.obj: status.h
- Xgetwork.obj: work.h
- Xgetwork.obj: params.h
- Xgetwork.obj: comm.h
- Xgmail.obj: defs.h
- Xgmail.obj: ndir.h
- Xgmail.obj: path.h
- Xgphys.obj: gp.h
- Xgpres.obj: gp.h
- Xgtrans.obj: gp.h
- Xhsearch.obj: hsearch.h
- Xinvoke.obj: defs.h
- Xinvoke.obj: status.h
- Xkbdinp.obj: defs.h
- Xkbdinp.obj: mail.h
- Xkbdinp.obj: screen.h
- Xkbdinp.obj: window.h
- Xkio.obj: uucp.h
- Xkphys.obj: kp.h
- Xkpres.obj: kp.h
- Xktrans.obj: kp.h
- Xlmail.obj: defs.h
- Xlmail.obj: path.h
- Xlogs.obj: defs.h
- Xlogs.obj: logs.h
- Xlogs.obj: path.h
- Xlogs.obj: status.h
- Xmail.obj: defs.h
- Xmail.obj: path.h
- Xmail.obj: status.h
- Xmail.obj: mail.h
- Xmail.obj: window.h
- Xmailfile.obj: defs.h
- Xmailfile.obj: path.h
- Xmailfile.obj: screen.h
- Xmailfile.obj: mail.h
- Xmakework.obj: defs.h
- Xmakework.obj: path.h
- Xmakework.obj: screen.h
- Xmakework.obj: mail.h
- Xmbox.obj: defs.h
- Xmbox.obj: path.h
- Xmbox.obj: pager.h
- Xmbox.obj: screen.h
- Xmbox.obj: mail.h
- Xmbox.obj: ascf.h
- Xmbox.obj: params.h
- Xmbox.obj: ms_parse.h
- Xms_parse.obj: defs.h
- Xms_parse.obj: ms_parse.h
- Xmyalloc.obj: defs.h
- Xndir.obj: ndir.h
- Xnewseqno.obj: defs.h
- Xnewseqno.obj: path.h
- Xnewseqno.obj: ndir.h
- Xnewseqno.obj: status.h
- Xnmail.obj: defs.h
- Xnmail.obj: ndir.h
- Xnmail.obj: path.h
- Xnmail.obj: status.h
- Xnmail.obj: ms_parse.h
- Xpager.obj: defs.h
- Xpager.obj: window.h
- Xpager.obj: pager.h
- Xpager.obj: path.h
- Xpager.obj: ascf.h
- Xparams.obj: defs.h
- Xparams.obj: path.h
- Xparams.obj: params.h
- Xpath.obj: defs.h
- Xpath.obj: path.h
- Xpath.obj: status.h
- Xprotomsg.obj: defs.h
- Xprotomsg.obj: params.h
- Xprotomsg.obj: comm.h
- Xprotomsg.obj: logs.h
- Xprotomsg.obj: status.h
- Xreply.obj: defs.h
- Xreply.obj: path.h
- Xreply.obj: pager.h
- Xreply.obj: screen.h
- Xreply.obj: status.h
- Xreply.obj: mail.h
- Xreply.obj: ascf.h
- Xreply.obj: ms_parse.h
- Xrmtname.obj: defs.h
- Xrmtname.obj: params.h
- Xrmtname.obj: comm.h
- Xrmtname.obj: logs.h
- Xrmtname.obj: status.h
- Xrmtname.obj: path.h
- Xscanwork.obj: defs.h
- Xscanwork.obj: params.h
- Xscanwork.obj: comm.h
- Xscanwork.obj: work.h
- Xscanwork.obj: path.h
- Xscanwork.obj: ndir.h
- Xscanwork.obj: logs.h
- Xscreen.obj: defs.h
- Xscreen.obj: screen.h
- Xsendwork.obj: defs.h
- Xsendwork.obj: work.h
- Xsendwork.obj: logs.h
- Xsendwork.obj: status.h
- Xsendwork.obj: params.h
- Xsendwork.obj: comm.h
- Xsetup.obj: defs.h
- Xsetup.obj: path.h
- Xsetup.obj: screen.h
- Xsetup.obj: mail.h
- Xsetup.obj: pager.h
- Xsetup.obj: params.h
- Xsetup.obj: status.h
- Xsetup.obj: window.h
- Xsmail.obj: defs.h
- Xsmail.obj: path.h
- Xsmail.obj: status.h
- Xsnapshot.obj: defs.h
- Xsnapshot.obj: path.h
- Xsnapshot.obj: ndir.h
- Xsnapshot.obj: snapshot.h
- Xspoolfil.obj: defs.h
- Xspoolfil.obj: path.h
- Xspoolfil.obj: ascf.h
- Xspoolfil.obj: status.h
- Xspoolfil.obj: ms_parse.h
- Xstartup.obj: defs.h
- Xstartup.obj: params.h
- Xstartup.obj: comm.h
- Xstartup.obj: logs.h
- Xstartup.obj: status.h
- Xstartup.obj: sysdep.h
- Xstr.obj: defs.h
- Xsubmit.obj: defs.h
- Xsubmit.obj: path.h
- Xswitcher.obj: defs.h
- Xswitcher.obj: work.h
- Xswitcher.obj: params.h
- Xswitcher.obj: comm.h
- Xswitcher.obj: logs.h
- Xswitcher.obj: status.h
- Xsysdep.obj: sysdep.h
- Xtextcopy.obj: defs.h
- Xtextcopy.obj: ascf.h
- Xunalias.obj: defs.h
- Xunalias.obj: hsearch.h
- Xunalias.obj: path.h
- Xunalias.obj: ascf.h
- Xwindow.obj: defs.h
- Xwindow.obj: window.h
- Xxpres.obj: defs.h
- Xxpres.obj: params.h
- Xxpres.obj: comm.h
- Xxpres.obj: status.h
- Xxpres.obj: sysdep.h
- Xxpres.obj: logs.h
- END_OF_main/makefile.msc
- if test 8027 -ne `wc -c <main/makefile.msc`; then
- echo shar: \"main/makefile.msc\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f main/makefile.unx -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"main/makefile.unx\"
- else
- echo shar: Extracting \"main/makefile.unx\" \(9508 characters\)
- sed "s/^X//" >main/makefile.unx <<'END_OF_main/makefile.unx'
- X# @(#) makefile.unx 2.1 1/22/90 13:02:09
- X
- X# Makefile for various versions of UNIX
- X
- X##################
- X# Beginning of configurable options
- X
- X# Choose a message-transport mechanism, and select the corresponding definitions
- X# for the DAEMON and PROGRAMS macros.
- X#
- X# 1 - The UUCP file transfer software provided with pc-mail (see the DEFAULT.ins
- X# document):
- X#
- X# DAEMON =
- X# PROGRAMS = mail smail nmail cmail cico
- X#
- X# 2 - Daemon processes, presumably running on a file server (see the SLAVE.ins
- X# document):
- X#
- X# DAEMON = -DDAEMON
- X# PROGRAMS = mail smail nmail cmail
- X#
- X# 3 - Message transport by GNUUCP (see the GNUUCP.ins document):
- X#
- X# DAEMON = -DDAEMON
- X# PROGRAMS = mail smail nmail cmail gmail lmail
- X
- XDAEMON =
- XPROGRAMS= mail smail nmail cmail cico
- X
- X# Flags seen by both the c compiler and by the lint command
- X#
- X# COPTS = -DSIII -DUSENDIR for AT&T unix System-III or System-V.2
- X# COPTS = -DUSENDIR for V7
- X# COPTS = -Ddirect=dirent SunOS 4.x
- X# COPTS = for most BSD4.x versions and clones
- X
- XCOPTS = -DSIII -DUSENDIR
- X
- X# Object libraries needed for the interactive shell. The program only needs the
- X# low-level terminal control routines and does its own screen management.
- X#
- X# SHLIBS = -lcurses for SYSV.2
- X# SHLIBS = -ltermcap for V7+, BSD4.x, SunOS
- X
- XSHLIBS = -lcurses
- X
- X# Object libraries needed by most other programs, e.g. for directory access.
- X
- XLIBS =
- X
- X# Memory model, if you have to
- X
- XMODEL = -Ml
- X
- X# End of configurable options
- X##################
- X
- XSHELL = /bin/sh
- X
- XCFLAGS = -g $(COPTS) $(MODEL)
- X
- XRETRIEVE= xarch
- X
- XFILES = README ascf.c ascf.h call.c cico.c cmail.c comm.c comm.h \
- X connect.c create.c defs.h desk.c deskutil.c \
- X email.c errdisp.c file.c getwork.c gp.h \
- X gphys.c gpres.c gtrans.c invoke.c kbdinp.c kio.c kp.h \
- X kphys.c kpres.c ktrans.c logs.c logs.h mailfile.c \
- X mail.c makework.c mbox.c myalloc.c \
- X newseqno.c pager.c pager.h params.c params.h path.c path.h \
- X protomsg.c nmail.c rmtname.c scanwork.c screen.c screen.h \
- X sendwork.c setup.c smail.c spoolfil.c startup.c \
- X status.h switcher.c sysdep.h window.c window.h \
- X work.h xpres.c comport.asm str.c alias.c edit.c submit.c \
- X unalias.c hsearch.c hsearch.h clmap.h comport.h hsearch.3 \
- X kproto.ms Beware makefile.unx makefile.msc \
- X mail.h Implement msd_dir.h \
- X msd_dir.c ndir.h ndir.c ms_parse.c ms_parse.h reply.c \
- X textcopy.c snapshot.c snapshot.h gmail.c lmail.c tutorial.ms \
- X DEFAULT.ins SLAVE.ins GNUUCP.ins DEFAULT.bat SLAVE.bat GNUUCP.bat \
- X PORTING
- X
- X# Sources and objects for the interactive mail program
- X
- XSHSRC = mail.c call.c desk.c file.c screen.c mbox.c kbdinp.c \
- X pager.c window.c setup.c errdisp.c invoke.c path.c myalloc.c \
- X ndir.c params.c newseqno.c email.c spoolfil.c ascf.c \
- X makework.c mailfile.c deskutil.c str.c alias.c edit.c submit.c \
- X ms_parse.c reply.c textcopy.c snapshot.c create.c
- XSHOBJ = mail.o call.o desk.o file.o screen.o mbox.o kbdinp.o \
- X pager.o window.o setup.o errdisp.o invoke.o path.o myalloc.o \
- X ndir.o params.o newseqno.o email.o spoolfil.o ascf.o \
- X makework.o mailfile.o deskutil.o str.o alias.o edit.o submit.o \
- X ms_parse.o reply.o textcopy.o snapshot.o create.o
- X
- X# Sources and objects for the smail program
- X
- XSMSRC = smail.c path.c ndir.c newseqno.c ascf.c spoolfil.c str.c \
- X unalias.c hsearch.c ms_parse.c
- XSMOBJ = smail.o path.o ndir.o newseqno.o ascf.o spoolfil.o str.o \
- X unalias.o hsearch.o ms_parse.o
- X
- X# Sources and objects for the nmail program
- X
- XNMSRC = nmail.c path.c ndir.c str.c newseqno.c ms_parse.c
- XNMOBJ = nmail.o path.o ndir.o str.o newseqno.o ms_parse.o
- X
- X# Sources and objects for the cmail program
- X
- XCMSRC = cmail.c path.c ndir.c invoke.c str.c newseqno.c
- XCMOBJ = cmail.o path.o ndir.o invoke.o str.o newseqno.o
- X
- X# Sources and objects for the gmail program
- X
- XGMSRC = gmail.c ndir.c path.c str.c newseqno.c
- XGMOBJ = gmail.o ndir.o path.o str.o newseqno.o
- X
- X# Sources and objects for the lmail program
- X
- XLMSRC = lmail.c ndir.c path.c str.c newseqno.c
- XLMOBJ = lmail.o ndir.o path.o str.o newseqno.o
- X
- X# Sources and objects for the cico program
- X
- XCISRC = ndir.c comm.c connect.c getwork.c kphys.c kpres.c ktrans.c logs.c \
- X cico.c myalloc.c newseqno.c params.c path.c protomsg.c rmtname.c \
- X scanwork.c sendwork.c startup.c switcher.c xpres.c \
- X gpres.c gtrans.c gphys.c str.c
- XCIOBJ = ndir.o comm.o connect.o getwork.o kphys.o kpres.o ktrans.o logs.o \
- X cico.o myalloc.o newseqno.o params.o path.o protomsg.o rmtname.o \
- X scanwork.o sendwork.o startup.o switcher.o xpres.o \
- X gpres.o gtrans.o gphys.o str.o
- X
- Xall: $(PROGRAMS)
- X
- Xmail: $(SHOBJ)
- X $(CC) $(CFLAGS) -o $@ $(SHOBJ) $(SHLIBS) $(LIBS)
- X
- Xsmail: $(SMOBJ)
- X $(CC) $(CFLAGS) -o $@ $(SMOBJ) $(LIBS)
- X
- Xnmail: $(NMOBJ)
- X $(CC) $(CFLAGS) -o $@ $(NMOBJ) $(LIBS)
- X
- Xcmail: $(CMOBJ)
- X $(CC) $(CFLAGS) -o $@ $(CMOBJ) $(LIBS)
- X
- Xcico: $(CIOBJ)
- X $(CC) $(CFLAGS) -o $@ $(CIOBJ) $(LIBS)
- X
- Xgmail: $(GMOBJ)
- X $(CC) $(CFLAGS) -o $@ $(GMOBJ) $(LIBS)
- X
- Xlmail: $(LMOBJ)
- X $(CC) $(CFLAGS) -o $@ $(LMOBJ) $(LIBS)
- X
- X# Linting targets
- X
- Xmlint:
- X lint $(COPTS) $(SHSRC)
- X
- Xnlint:
- X lint $(COPTS) $(NMSRC)
- X
- Xslint:
- X lint $(COPTS) $(SMSRC)
- X
- Xclint:
- X lint $(COPTS) $(CISRC)
- X
- Xglint:
- X lint $(COPTS) $(GMSRC)
- X
- Xllint:
- X lint $(COPTS) $(LMSRC)
- X
- X# Other targets
- X
- Xtutorial.doc: tutorial.ms
- X nroff -ms $? | col -b >$@
- X
- X$(FILES):
- X $(RETRIEVE) $@
- X
- Xclean:
- X rm -f *.o core *.out
- X
- Xclobber: clean
- X rm -f mail cmail nmail smail gmail lmail cico
- X
- Xshar: $(FILES) tutorial.doc
- X shar $(FILES) tutorial.doc
- X
- Xdepend:
- X @grep '^# *include *"' *.c|sed 's/c:# *include *"\([^"]*\)".*/o: \1/g'
- X
- Xalias.o: defs.h
- Xalias.o: path.h
- Xalias.o: pager.h
- Xalias.o: mail.h
- Xalias.o: screen.h
- Xalias.o: status.h
- Xascf.o: defs.h
- Xascf.o: ascf.h
- Xcall.o: defs.h
- Xcall.o: path.h
- Xcall.o: screen.h
- Xcall.o: pager.h
- Xcall.o: mail.h
- Xcico.o: defs.h
- Xcico.o: logs.h
- Xcico.o: params.h
- Xcico.o: comm.h
- Xcico.o: status.h
- Xcico.o: path.h
- Xcmail.o: defs.h
- Xcmail.o: ndir.h
- Xcmail.o: path.h
- Xcmail.o: status.h
- Xcomm.o: defs.h
- Xcomm.o: params.h
- Xcomm.o: comm.h
- Xconnect.o: defs.h
- Xconnect.o: params.h
- Xconnect.o: status.h
- Xconnect.o: comm.h
- Xconnect.o: logs.h
- Xconnect.o: sysdep.h
- Xcreate.o: defs.h
- Xcreate.o: path.h
- Xcreate.o: mail.h
- Xcreate.o: status.h
- Xcreate.o: screen.h
- Xdesk.o: defs.h
- Xdesk.o: mail.h
- Xdesk.o: path.h
- Xdesk.o: ndir.h
- Xdesk.o: pager.h
- Xdesk.o: screen.h
- Xdesk.o: status.h
- Xdesk.o: window.h
- Xdesk.o: ascf.h
- Xdesk.o: snapshot.h
- Xdeskutil.o: defs.h
- Xdeskutil.o: pager.h
- Xdeskutil.o: mail.h
- Xdeskutil.o: screen.h
- Xdeskutil.o: status.h
- Xedit.o: defs.h
- Xedit.o: path.h
- Xedit.o: mail.h
- Xedit.o: status.h
- Xemail.o: defs.h
- Xemail.o: path.h
- Xemail.o: pager.h
- Xemail.o: screen.h
- Xemail.o: mail.h
- Xemail.o: status.h
- Xerrdisp.o: defs.h
- Xerrdisp.o: screen.h
- Xerrdisp.o: pager.h
- Xerrdisp.o: status.h
- Xerrdisp.o: window.h
- Xfile.o: defs.h
- Xfile.o: screen.h
- Xfile.o: pager.h
- Xfile.o: mail.h
- Xfile.o: ndir.h
- Xfile.o: path.h
- Xfile.o: status.h
- Xfile.o: window.h
- Xgetwork.o: defs.h
- Xgetwork.o: logs.h
- Xgetwork.o: status.h
- Xgetwork.o: work.h
- Xgetwork.o: params.h
- Xgetwork.o: comm.h
- Xgmail.o: defs.h
- Xgmail.o: ndir.h
- Xgmail.o: path.h
- Xgphys.o: gp.h
- Xgpres.o: gp.h
- Xgtrans.o: gp.h
- Xhsearch.o: hsearch.h
- Xinvoke.o: defs.h
- Xinvoke.o: status.h
- Xkbdinp.o: defs.h
- Xkbdinp.o: mail.h
- Xkbdinp.o: screen.h
- Xkbdinp.o: window.h
- Xkio.o: uucp.h
- Xkphys.o: kp.h
- Xkpres.o: kp.h
- Xktrans.o: kp.h
- Xlmail.o: defs.h
- Xlmail.o: path.h
- Xlogs.o: defs.h
- Xlogs.o: logs.h
- Xlogs.o: path.h
- Xlogs.o: status.h
- Xmail.o: defs.h
- Xmail.o: path.h
- Xmail.o: status.h
- Xmail.o: mail.h
- Xmail.o: window.h
- Xmailfile.o: defs.h
- Xmailfile.o: path.h
- Xmailfile.o: screen.h
- Xmailfile.o: mail.h
- Xmakework.o: defs.h
- Xmakework.o: path.h
- Xmakework.o: screen.h
- Xmakework.o: mail.h
- Xmbox.o: defs.h
- Xmbox.o: path.h
- Xmbox.o: pager.h
- Xmbox.o: screen.h
- Xmbox.o: mail.h
- Xmbox.o: ascf.h
- Xmbox.o: params.h
- Xmbox.o: ms_parse.h
- Xms_parse.o: defs.h
- Xms_parse.o: ms_parse.h
- Xmyalloc.o: defs.h
- Xndir.o: ndir.h
- Xnewseqno.o: defs.h
- Xnewseqno.o: path.h
- Xnewseqno.o: ndir.h
- Xnewseqno.o: status.h
- Xnmail.o: defs.h
- Xnmail.o: ndir.h
- Xnmail.o: path.h
- Xnmail.o: status.h
- Xnmail.o: ms_parse.h
- Xpager.o: defs.h
- Xpager.o: window.h
- Xpager.o: pager.h
- Xpager.o: path.h
- Xpager.o: ascf.h
- Xparams.o: defs.h
- Xparams.o: path.h
- Xparams.o: params.h
- Xpath.o: defs.h
- Xpath.o: path.h
- Xpath.o: status.h
- Xprotomsg.o: defs.h
- Xprotomsg.o: params.h
- Xprotomsg.o: comm.h
- Xprotomsg.o: logs.h
- Xprotomsg.o: status.h
- Xreply.o: defs.h
- Xreply.o: path.h
- Xreply.o: pager.h
- Xreply.o: screen.h
- Xreply.o: status.h
- Xreply.o: mail.h
- Xreply.o: ascf.h
- Xreply.o: ms_parse.h
- Xrmtname.o: defs.h
- Xrmtname.o: params.h
- Xrmtname.o: comm.h
- Xrmtname.o: logs.h
- Xrmtname.o: status.h
- Xrmtname.o: path.h
- Xscanwork.o: defs.h
- Xscanwork.o: params.h
- Xscanwork.o: comm.h
- Xscanwork.o: work.h
- Xscanwork.o: path.h
- Xscanwork.o: ndir.h
- Xscanwork.o: logs.h
- Xscreen.o: defs.h
- Xscreen.o: screen.h
- Xsendwork.o: defs.h
- Xsendwork.o: work.h
- Xsendwork.o: logs.h
- Xsendwork.o: status.h
- Xsendwork.o: params.h
- Xsendwork.o: comm.h
- Xsetup.o: defs.h
- Xsetup.o: path.h
- Xsetup.o: screen.h
- Xsetup.o: mail.h
- Xsetup.o: pager.h
- Xsetup.o: params.h
- Xsetup.o: status.h
- Xsetup.o: window.h
- Xsmail.o: defs.h
- Xsmail.o: path.h
- Xsmail.o: status.h
- Xsnapshot.o: defs.h
- Xsnapshot.o: path.h
- Xsnapshot.o: ndir.h
- Xsnapshot.o: snapshot.h
- Xspoolfil.o: defs.h
- Xspoolfil.o: path.h
- Xspoolfil.o: ascf.h
- Xspoolfil.o: status.h
- Xspoolfil.o: ms_parse.h
- Xstartup.o: defs.h
- Xstartup.o: params.h
- Xstartup.o: comm.h
- Xstartup.o: logs.h
- Xstartup.o: status.h
- Xstartup.o: sysdep.h
- Xstr.o: defs.h
- Xsubmit.o: defs.h
- Xsubmit.o: path.h
- Xswitcher.o: defs.h
- Xswitcher.o: work.h
- Xswitcher.o: params.h
- Xswitcher.o: comm.h
- Xswitcher.o: logs.h
- Xswitcher.o: status.h
- Xsysdep.o: sysdep.h
- Xtextcopy.o: defs.h
- Xtextcopy.o: ascf.h
- Xunalias.o: defs.h
- Xunalias.o: hsearch.h
- Xunalias.o: path.h
- Xunalias.o: ascf.h
- Xwindow.o: defs.h
- Xwindow.o: window.h
- Xxpres.o: defs.h
- Xxpres.o: params.h
- Xxpres.o: comm.h
- Xxpres.o: status.h
- Xxpres.o: sysdep.h
- Xxpres.o: logs.h
- END_OF_main/makefile.unx
- if test 9508 -ne `wc -c <main/makefile.unx`; then
- echo shar: \"main/makefile.unx\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f main/xpres.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"main/xpres.c\"
- else
- echo shar: Extracting \"main/xpres.c\" \(6977 characters\)
- sed "s/^X//" >main/xpres.c <<'END_OF_main/xpres.c'
- X/*++
- X/* NAME
- X/* xpres 3
- X/* SUMMARY
- X/* communications port i/o
- X/* PROJECT
- X/* pc-mail
- X/* PACKAGE
- X/* cico
- X/* SYNOPSIS
- X/* xopen()
- X/*
- X/* xclose()
- X/*
- X/* xread(dummy,buf,len)
- X/* int dummy,len;
- X/* char *buf;
- X/*
- X/* xwrite(dummy,buf,len)
- X/* int dummy,len;
- X/* char *buf;
- X/*
- X/* xioctl(flag)
- X/* int flag;
- X/* DESCRIPTION
- X/* The functions in this module perform functions analogous
- X/* to unix system calls, for the serial port of IBM-PC workalikes.
- X/*
- X/* xopen() initializes a serial port. Also needed under UNIX.
- X/*
- X/* xclose() closes a port.
- X/*
- X/* xread(), xwrite() do not use their first argument. Under UNIX
- X/* one should use the standard read() and write() system calls.
- X/*
- X/* xioctl() enables xon/xoff flow control if its argument
- X/* is nonzero. Not used under UNIX.
- X/* SEE ALSO
- X/* comport.asm, IBM-PC comm routines by Tim Pozar
- X/* DIAGNOSTICS
- X/* The read functions returns EOF in case of timeout; the write
- X/* function never detects any failure.
- X/* BUGS
- X/* The xioctl() function is utterly primitive.
- X/* AUTHOR(S)
- X/* MS-DOS parts derived from uuslave software (John Gilmore)
- X/* published on usenet early 1987. Bugs fixed & severely hacked by
- X/*
- 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/* CREATION DATE
- X/* Sat Mar 28 23:01:43 GMT+1:00 1987
- X/* LAST MODIFICATION
- X/* 90/01/22 13:02:59
- X/* VERSION/RELEASE
- X/* 2.1
- X/*--*/
- X
- X#include <stdio.h>
- X
- X#include "defs.h"
- X#include "params.h"
- X#include "comm.h" /* baud rates, tty ports,... */
- X#include "status.h"
- X#include "sysdep.h" /* other system dependencies */
- X#include "logs.h"
- X
- X#ifdef unix
- X# include <sgtty.h>
- X# include <signal.h>
- X# include <setjmp.h>
- X#endif
- X
- X#ifdef MSDOS
- X# define B(x) (115200/(x))
- Xstatic int sigint();
- Xstatic void get_time();
- X
- X#endif
- X
- Xtypedef struct { /* baud-rate lookup table */
- X char *name;
- X int code;
- X} Baud_table;
- X
- XBaud_table btable[] = {
- X#ifdef unix
- X "50", B50,
- X "75", B75,
- X "110", B110,
- X "134", B134,
- X "150", B150,
- X "300", B300,
- X "600", B600,
- X "1200", B1200,
- X "1800", B1800,
- X "2400", B2400,
- X "4800", B4800,
- X "9600", B9600,
- X#endif
- X#ifdef MSDOS
- X "50", B(50),
- X "75", B(75),
- X "110", B(110),
- X "134", B(134),
- X "150", B(150),
- X "300", B(300),
- X "600", B(600),
- X "1200", B(1200),
- X "1800", B(1800),
- X "2400", B(2400),
- X "4800", B(4800),
- X "9600", B(9600),
- X#endif
- X 0, 0,
- X};
- X
- X/* xopen - open communications port; parameters taken from setup table */
- X
- Xxopen()
- X{
- X register Baud_table *bp;
- X
- X#ifdef unix
- X struct sgttyb ttmode;
- X
- X#endif
- X
- X for (bp = btable; bp->name; bp++) /* look up baud rate */
- X if (strcmp(bp->name, COMM_RATE) == 0)
- X break;
- X if (bp->name == 0) { /* bad baud rate in setup */
- X debug(4) ("Invalid baud rate %s\n", COMM_RATE);
- X exit(E_BADSETUP);
- X }
- X#ifdef unix
- X if ((ttfd = open(COMM_LINE, 2)) < 0) { /* try to access port */
- X debug(4) ("Cannot access %s\n", COMM_LINE);
- X exit(E_BADSETUP);
- X }
- X#ifndef SIII
- X if (ioctl(ttfd, TIOCEXCL)) /* exclusive access */
- X exit(E_BADSETUP); /* not a terminal */
- X#endif
- X ioctl(ttfd, TIOCHPCL); /* hangup when done */
- X gtty(ttfd, &ttmode); /* get port status */
- X ttmode.sg_ispeed = ttmode.sg_ospeed = bp->code; /* set baud rate */
- X ttmode.sg_flags |= (RAW); /* raw mode */
- X#ifdef SIII
- X ttmode.sg_flags &= ~ECHO;
- X#else
- X ttmode.sg_flags &= ~(ECHO | TANDEM | CBREAK); /* no echo, crlf, flow
- X * control */
- X#endif
- X stty(ttfd, &ttmode);
- X#endif
- X
- X#ifdef MSDOS
- X set_tty(bp->code); /* set baud rate, DTR */
- X init_comm(); /* turn interrupts on */
- X signal(SIGINT, sigint); /* must reset tty */
- X inp_flush(); /* flush garbage */
- X sleep(3);
- X#endif
- X}
- X
- X/* xclose - release the communications port */
- X
- Xxclose()
- X{
- X#ifdef unix
- X close(ttfd);
- X#endif
- X
- X#ifdef MSDOS
- X uninit_comm();
- X#endif
- X}
- X
- X/* xread - read from the serial port */
- X
- X#ifdef MSDOS
- X
- Xxread(fd, buf, cnt)
- Xint fd;
- Xchar *buf;
- Xregister int cnt;
- X{
- X register char *p = buf;
- X register int c;
- X
- X while (cnt > 0 && (c = xgetc()) != EOF) {
- X *p++ = c;
- X cnt--;
- X }
- X return (p - buf ? p - buf : -1);
- X}
- X
- X#endif /* MSDOS xwrite() */
- X
- X/* xgetc - read one character from serial port */
- X
- X#ifdef unix
- Xjmp_buf xbuf;
- X
- Xstatic timeout()
- X{ /* aux function for xgetc */
- X longjmp(xbuf, 1);
- X}
- X
- Xxgetc()
- X{ /* return next char */
- X char ch;
- X
- X if (setjmp(xbuf)) /* in case we time out */
- X return (EOF); /* we just did */
- X signal(SIGALRM, timeout); /* set timer response */
- X alarm(BYTE_TIMEOUT); /* set timer */
- X
- X if (read(ttfd, &ch, 1) != 1) /* go wait for character */
- X return(EOF);
- X alarm(0); /* turn timer off */
- X return (ch & 0377); /* successfull termination */
- X}
- X
- X#endif /* unix xgetc() */
- X
- X#ifdef MSDOS
- X
- Xxgetc()
- X{
- X char data;
- X
- X int i;
- X unsigned s;
- X TIME n;
- X
- X i = 0;
- X get_time(&n);
- X s = n.sec;
- X
- X /*
- X * Implement timeouts by staring at the clock while we wait. When the
- X * second hand moves, bump our counter. This is a lot easier than
- X * figuring out the time when we'd time out (in hours, minutes, and
- X * seconds!) and comparing against that, which is what people tend to do
- X * in Unix where the time is just an integer number of seconds.
- X */
- X while (i < BYTE_TIMEOUT) {
- X while (s == n.sec) {
- X if (inp_cnt() != 0) {
- X data = inp_char();
- X return (data & 0xFF);
- X }
- X get_time(&n);
- X }
- X s = n.sec;
- X ++i;
- X }
- X return (EOF);
- X}
- X
- X/* xwrite - write buffer to serial port */
- X
- Xxwrite(fd, buf, ctr)
- Xint fd;
- Xregister char *buf;
- Xint ctr;
- X{
- X register int i = ctr;
- X
- X while (i-- > 0)
- X outp_char(*buf++);
- X return ctr;
- X}
- X
- X/*
- X * Routines specific to MS-DOS
- X *
- X * xioctl() enable xon/xoff
- X * get_timer() read current time
- X * sigint() clean up interrupt handler and exit
- X * sleep() unix lookalike
- X */
- X
- X/* xioctl - enable xon/xoff protocol */
- X
- Xxioctl(flag)
- Xint flag;
- X{
- X set_xoff(flag); /* Enable (flag != 0) or
- X * disable flow control */
- X}
- X
- X/* sigint - restore terminal settings on dialout line */
- X
- Xstatic int sigint()
- X{
- X uninit_comm();
- X reset_tty();
- X exit(0);
- X}
- X
- X/* get_time - read time with dos call */
- X
- Xstatic void get_time(n)
- XTIME_PTR n;
- X{
- X union REGS inregs;
- X union REGS outregs;
- X
- X inregs.h.ah = 0x2c; /* Please make a #define for
- X * this, Tim */
- X
- X int86(0x21, &inregs, &outregs); /* Please #define the 0x21
- X * too */
- X
- X n->hour = outregs.h.ch;
- X n->minute = outregs.h.cl;
- X n->sec = outregs.h.dh;
- X n->hsec = outregs.h.dl;
- X}
- X
- X#define get_sec(n) (get_time(&n),n.sec)
- X
- Xsleep(x)
- Xint x;
- X{
- X TIME n; /* current time record */
- X unsigned s = get_sec(n);
- X
- X while (x-- > 0) {
- X while (s == get_sec(n))
- X /* void */ ;
- X s = n.sec;
- X }
- X}
- X
- X#endif /* MSDOS */
- END_OF_main/xpres.c
- if test 6977 -ne `wc -c <main/xpres.c`; then
- echo shar: \"main/xpres.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo shar: End of archive 7 \(of 11\).
- cp /dev/null ark7isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 11 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-