[comp.sources.misc] uupc.st.8.5

Stuart.Lynne@van-bc.UUCP (Stuart Lynne) (08/17/87)

>From uucp Wed Aug 12 02:51 PDT 1987
>From slynne  Wed Aug 12 02:51:03 1987 remote from slmac
Received: by van-bc.uucp (smail2.3)
	id AA17688; 12 Aug 87 02:51:03 PDT (Wed)
Received: by slmac.vnet.van-bc.uucp (pcmail) Wed Aug 12 02:39:38 1987
Date: Wed Aug 12 02:39:38 1987
From: Stuart Lynne - test a mac <slynne@slmac.vnet.van-bc.uucp>
Message-ID: <152@slmac.vnet.van-bc.uucp>
To: sl@van-bc
Subject: shar/uupc.st.8.5

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	st/README.ST
#	st/host.c
#	st/host.h
#	st/c.mm
#	st/cu.mm
#	st/dirsubs.c
#	st/dmymath.c
#	st/env.mm
#	st/fgets.c
#	st/genv.c
#	st/getargs.c
#	st/getenv.c
#	st/getone.c
#	st/host.c
#	st/host.h
#	st/inoutpth.c
#	st/ldcp.mm
#	st/l.mm
#	st/l1.mm
#	st/ldcp.mm
#	st/lmail.mm
#	st/ndir.c
#	st/ndir.h
#	st/printmsg.c
#	st/readme.st
#	st/shell.c
#	st/startup.mm
#	st/time.c
#	st/utar.mm
#	st/uu.mm
#	st/uuar.mm
#	st/uusup.c
#	st/zdcp.h
#	st/zgenv.h
#	st/zzgenv.h
#	st/zhost.h
#	st/zzhost.h
#	st/zmailhos.c
#	st/zzmailhost.c
#	st/zndir.h
#	st/zzndir.h
#	st/zztime.h
#	st/zuuhost.c
# This archive created: Wed Aug 12 02:03:06 1987
# By:	Stuart Lynne - test a mac ()
export PATH; PATH=/bin:$PATH
if test -f 'st/README.ST'
then
       echo shar: will not over-write existing file "'st/README.ST'"
else
cat << \SHAR_EOF > 'st/README.ST'
This file contains the Atari ST specific files.

I have done all the compilation using the Alcyon C versin 4.14a compiler.
The disks were layed out with all the sources and objects on the A drive and
the compiler on the D drive.

Problems with the Atari ST code:

	- there is a problem in the getsystem(), sysend() states such that
	  if there is more than one system in the systems file then the
	  program may bomb bomb (bus error?)

Files included in this shar script:

		On the atari these files should be placed in the
		\local directory or the .h files will need to be
		edited.

	  dirsubs.c	- file and directory name manipulation
	  dmymath.c	- dummy floating point routines to fake out linker
	  genv.c	- load enviroment strings
	  getenv.c	- get and enviroment string
	  getone.c	- get one character without echo
	  host.c	- host specific main program
	  inoutpth.c	- file name conversion
	  ndir.c	- directory manipulation routines
	  printmsg.c	- print message to log file
	  time.c	- date/time conversion routines
	  uusup.c	- uu support routines

	  The following files belong in the ./local dirctory and should
	  be moved there with the leading z stripped off.

	  zdcp.h	- main include file for uu
          zmailhost.c	- host specific mail main program
          zuuhost.c	- host specific uu main program
	  zgenv.h	- definitions for enviroment variables
	  zhost.h	- host specific definitions
	  zndir.h	- directory manipulation routines header
	  ztime.h	- time routine header

The following script files are included as examples on how to compile
the sources.  They are for the CM command shell.

	  c.mm		- compile script for alcyon C (file is in A:\)
	  cu.mm		- compile script for alcyon C (file is in A:\atari\)
	  env.mm	- define enviroment script
	  ldcp.mm	- link uu.prg
	  lmail.mm	- link mail.prg
	  uuar.mm	- create DCPLIB
	  utar.mm	- create UTLLIB

Basic procedure is to:
	- compile all the .c files into .o files
	- build the DCPLIB with uuar.mm
	- build the UTLLIB with utar.mm
	- link uu with ldcp.mm
	- link mail with lmail.mm

If you have problems feel free to drop me a line.  Though I warn you I have
a slow turn around time on questions I will try to get back to you within
a day or two.

------------------------------------------------------------------------------
UUCP:  {alberta,uw-beaver,siesmo}!ubc-vision!van-bc!nvanbc!lawrence
SNAIL: 733 Sylvan Ave., North Vancouver, B.C., Canada, V7R 2E8
PHONE: 1-604-736-9241 (09:00-17:00 PDT)

SHAR_EOF
fi # end of overwriting check
if test -f 'st/host.c'
then
       echo shar: will not over-write existing file "'st/host.c'"
else
cat << \SHAR_EOF > 'st/host.c'
#include <stdio.h>
#include <setjmp.h>
#include "genv.h"

int  chdir();
void loadenv();
void printmsg();

extern int errno;

char *curdir;
char *getcwd();
char c_curdir[256];

jmp_buf	dcpexit;


main( argc, argv )
int argc;
char **argv;
{
	/* host specific prolog */
	loadenv();
	curdir = getcwd( c_curdir, 0 );
	if (chdir( spooldir ) != 0)
	{
	   return(errno);
	}

	/* setup longjmp for error exit's */
	if ( setjmp( dcpexit ) == 0 ) {

		MAIN(argc, argv );

	}
	

	/* host specific epilog */
	if (chdir( curdir ) != 0)
	{
	   return(errno);
	}
	return(0);
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/host.h'
then
       echo shar: will not over-write existing file "'st/host.h'"
else
cat << \SHAR_EOF > 'st/host.h'
/* Atari ST, Alcyon C Version 4.14a					*/
/* Host specific defines for uu and mail				*/

#include <setjmp.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <osbind.h>
#include <time.h>
#include "genv.h"

#define XENIX		/* don't send debugging info in startup message	*/
#define fgets Fgets	/* use our own fgets to fix problem in runtime	*/
#define mkdir Dcreate	/* create directory				*/

#define ATARIST

#define strchr  index
#define strrchr rindex
#define FILEMODE(f)

#define SEPCHAR		'\\'	/* path separater character		*/
#define XQTFILE 	"X_"	/* prefix for execute files		*/
#define CALLFILE	"C_"	/* prefix for call files		*/
#define TFILENAME	"TM.%03ld"	/* template for temporary files	*/
#define SFILENAME	"SEQF"	/* name of the sequence file		*/
#define SIGFILE		"WHOAMI"	/* file containing signature	*/
#define COPYFILE	"MAIL\\MAILSENT"	/* copy of sent mail	*/
#define NEWSDIR		"\\spool\\rnews\\%02d%02d%02d%02d.%03d"	/* format for news name	*/
#define HOSTINIT		/* name of function used to initialize	*/

/* Rsconf() defines */

#define RSR		(-1)		/* leave as is			*/
#define TSR		(-1)		/* " "     " "			*/
#define SCR		(-1)		/* " "     " "			*/
#define UCR		(0x98)		/* 8-bits, no parity, 2 stops	*/
#define NOFLOW		(0)		/* no flow control		*/

#define B19200		(0)		/* 19200 baud			*/
#define B9600		(1)		/* 9600 baud			*/
#define B4800		(2)		/* 4800 baud			*/
#define B2400		(4)		/* 2400 baud			*/
#define B1200		(7)		/* 1200 baud			*/
#define B300		(9)		/*  300 baud			*/

/* misc. defines */

#ifndef TRUE
#define FALSE		(0)
#define TRUE		(-1)
#endif

#ifndef SAME
#define SAME		(0)
#endif

#define AUX		(1)		/* rs232 port			*/
#define CON		(2)		/* console			*/

#define CTRL(X)		(X & 037)	/* get a control character	*/

#define	IBUFSIZ		(0x1000)
#define	OBUFSIZ		(0x1000)

/* typedef for Iorec() stuff (modified & improved by Martin Minow) */
	
struct iorec
  {
    char	*ibuf;		/* Pointer to input buffer */
    int		ibufsize;	/* Size of input buffer    */
    int		ibufhd;		/* Head index              */
    int		ibuftl;		/* Tail index		   */
    int		ibuflow;	/* Low water mark	   */
    int		ibufhi;		/* Hi water mark	   */
  };
    
typedef struct {
    struct iorec in;			/*  0 Input buffer		*/
    struct iorec out;			/* 14 Output buffer		*/
} IOREC;


/*
 * Rsconf() returns the "old" parameters in a longword encoded as follows:
 * bits		value
 * 31-24	UCR
 * 23-16	RSR
 * 15- 8	TSR
 *  8- 0	SCR
 *
 * Note that we must redefine the Rsconf() macro.
 */


#define	RS_UCR_SHIFT	24
#define RS_RSR_SHIFT	16
#define RS_TSR_SHIFT	 8
#define RS_SCR_SHIFT	 0

extern int errno;


SHAR_EOF
fi # end of overwriting check
if test -f 'st/c.mm'
then
       echo shar: will not over-write existing file "'st/c.mm'"
else
cat << \SHAR_EOF > 'st/c.mm'
d:cp68 -I a:\ a:\$1.c $1.i
d:c068 $1.i $1.1 $1.2 $1.3 -f
del $1.i
d:c168 $1.1 $1.2 $1.s
del $1.1
del $1.2
d:as68 -l -u $1.s
del $1.s
copy $1.o a:
del $1.o

SHAR_EOF
fi # end of overwriting check
if test -f 'st/cu.mm'
then
       echo shar: will not over-write existing file "'st/cu.mm'"
else
cat << \SHAR_EOF > 'st/cu.mm'
d:cp68 -I a:\ a:\local\$1.c $1.i
d:c068 $1.i $1.1 $1.2 $1.3 -f
del $1.i
d:c168 $1.1 $1.2 $1.s
del $1.1
del $1.2
d:as68 -l -u $1.s
del $1.s
copy $1.o a:\local\
del $1.o

SHAR_EOF
fi # end of overwriting check
if test -f 'st/dirsubs.c'
then
       echo shar: will not over-write existing file "'st/dirsubs.c'"
else
cat << \SHAR_EOF > 'st/dirsubs.c'
/*
 * getcwd(), chdir()
 */
#include <osbind.h>
#define NULL 0

extern char *malloc();
extern char errno;

char *getcwd( pnbuf, maxlen )
char *pnbuf;
int  maxlen;
{
	int drive;

	if ( pnbuf == (char *)NULL )
	{
	   if ( (pnbuf = malloc( 64 )) == (char *)NULL )
	   {
	      printf( "getcwd: malloc failure\n" );
	      exit(-1);
	   }
	}

	drive = Dgetdrv();	/* get the current drive */
	pnbuf[0] = (char)('A'+drive);
	pnbuf[1] = ':';

	Dgetpath( &pnbuf[2], 0 ); /* get current directory for current drive */

	return( pnbuf );
}

int chdir( path )
char *path;
{
	int status;
	/*
	 * Change current drive if the path has a drive specified
	 */
	if ( path[1] == ':' )
	   Dsetdrv( (int)(path[0]-'A') );

	status = Dsetpath( path );	/* set current path */
	if ( status == 0 ) return(0);
	printf("chdir: failed with error %d\n", status);
	errno = status;
	return(-1);
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/dmymath.c'
then
       echo shar: will not over-write existing file "'st/dmymath.c'"
else
cat << \SHAR_EOF > 'st/dmymath.c'
/*
 * ftoa, etoa, atof - Dummy routines so linker does not complain.
 * Will report error and exit should they actually be called.
 */

double atof( nptr )
char *nptr;
{
	printf(" atof: Not implemented\n" );
	exit(-1);
}

char *etoa( fval, buf, prec )
double fval;
char *buf;
int prec;
{
	printf(" etoa: Not implemented\n" );
	exit(-1);
}

char *ftoa( fval, buf, prec )
double fval;
char *buf;
int prec;
{
	printf(" ftoa: Not implemented\n" );
	exit(-1);
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/env.mm'
then
       echo shar: will not over-write existing file "'st/env.mm'"
else
cat << \SHAR_EOF > 'st/env.mm'
remenv A:\
setenv CONFDIR A:\lib
setenv MAILDIR A:\spool\mail
setenv PUBDIR A:\spool\uucppubl
setenv SPOOLDIR A:\spool\uucp
setenv RNEWSDIR A:\spool\rnews
setenv HOME A:\lawrence
setenv NODENAME lhst
setenv MAILSERVICE nvanbc
setenv USERNAME lawrence
setenv SPEED 1200
setenv DEVICE CON:

SHAR_EOF
fi # end of overwriting check
if test -f 'st/fgets.c'
then
       echo shar: will not over-write existing file "'st/fgets.c'"
else
cat << \SHAR_EOF > 'st/fgets.c'
#include <stdio.h>
#include <osbind.h>
#include <ctype.h>

#define CR '\015'
#define LF '\012'
#define BS '\010'
#define CD '\004'
#define CU '\025'
#define CX '\030'
#define CZ '\032'

static char backsp[] = "\010 \010";
static char newline[]= "\015\012";

/*
 * Fgets() - A replacement for fgets() that does its own console I/O
 * 	     since the library version seems not to work.
 *	     If the I/O is not to the console then we just call the
 *	     real fgets().
 *
 *	To use you must define fgets as Fgets either at the top of your
 *	source file or in a common header file.
 */

char *Fgets( buf, n, stream )
char *buf;
int n;
FILE *stream;
{
	static int eof = FALSE;
	int fd,eol;
	char *s = buf;
	char c;

	eol = FALSE;
	n  -= 1;	/* Leave room for the null character */

	fd = fileno( stream );
	if ( isatty( fd ) )
	{
	   /*
	    * If the user typed ^Z last time then report EOF on this call.
	    * Clear EOF as well so that future calls to the console will
	    * work.
	    */
	   if ( eof )
	   {
	      eof = FALSE;
	      return( (char *)NULL );
	   }
	   /*
	    * Not EOF so read up to n character and return the line.
	    */
	   while ( ( s - buf ) < n )
	   {
	       c = ( Crawcin() & 0xFF );
	       /*
	        * If its a printing character then just echo it
	        */
	       if (isprint( c ))
	       {
	          Cconout( c );
	          *s++ = c;
	          continue;
	       }
	       /*
	        * It must be a control character, either process it or
	        * ignore it.
	        */
	       switch (c)
	       {
	          case CD:
	          case CZ:
	             eof = eol = TRUE;
	             if ( s == buf ) break;
	          case CR:
	          case LF:
	             eol = TRUE;
	             *s++ = LF;
	             if ( ( s - buf ) < n ) *s++ = '\0';
	             Cconws( newline );
	             break;
	          case BS:
	             if ( s != buf )
	             {
	                s--;
	                Cconws( backsp );
	             }
	             break;
	          case CU:
	          case CX:
	             while ( s != buf )
	             {
	                s--;
	                Cconws( backsp );
	             }
	          default:
	             break;
	      }
	      if ( eol ) break;
	   }
	   if ( eof && s == buf )
	   {
	      eof = FALSE;
	      return( (char *)NULL );
	   }
	   return( buf );
	}
	/*
	 * Was not console so call regular fgets() since it seems to
	 * work for everything else.
	 */
	return( fgets( buf, n, stream ) );
}

#ifdef DEB_Fgets

extern int errno;
char buf[200];

#define fgets Fgets /* Use our own fgets routine */

main ( argc, argv )
int argc;
char **argv;
{

	char *s;

	while ( ( s = fgets( buf, 20, stdin ) ) != (char *)NULL )
	{
	   puts(">>");
	   puts( s );
	   puts("<<");
	}
	return( errno );
}
#endif


SHAR_EOF
fi # end of overwriting check
if test -f 'st/genv.c'
then
       echo shar: will not over-write existing file "'st/genv.c'"
else
cat << \SHAR_EOF > 'st/genv.c'
/*	genv.c
 
 
 
	copyright (C) 1987 Stuart Lynne
 
	Copying and use of this program are controlled by the terms of the
	Free Software Foundations GNU Emacs General Public License.
 
 
	version		0.1		March 31/1987
 
 
 
*/
 
#include <stdio.h>

#ifndef NULL
#define NULL 0
#endif
 
#include "genv.h"

#define DMAILBOX	"mailbox"
#define	DNAME		"noname"
#define	DDOMAIN		"pc.uucp"
#define	DMAILDIR	"\\usr\\spool\\mail"
#define DHOME		"\\usr\\noname"
#define	DCONFDIR	"\\usr\\lib\\uucp"
#define	DSPOOLDIR	"\\usr\\spool\\uucp"
#define DLOGDIR		"\\usr\\spool\\uucp"
#define DPUBDIR		"\\usr\\spool\\uucppublic"
#define DNEWSSDIR	"\\usr\\spool\\rnews"
#define DTEMPDIR	"\\tmp"
#define	DMAILSERVICE	"host"
#define	DNODENAME	"noname"
#define	DDEVICE		"AUX:"
#define	DSPEED		"1200"

 
#define	TFILENAME	"tmpfile"
#define	FILENAME 	"%s\\%s"

char *getenv();
char *malloc();
void genv();

extern int debuglevel;

#ifdef NOMALLOC
char	rmailbox[64];
char	rname[64];
char	rdomain[64];
char	rmaildir[64];
char	rhome[64];
char	rconfdir[64];
char	rlogdir[64];
char	rspooldir[64];
char	rpubdir[64];
char	rnewssdir[64];
char	rtempdir[64];
char	rmailserv[16];
char 	rnodename[16];
char 	rdevice[16];
char 	rspeed[8];

char	*mailbox = rmailbox;
char	*name = rname;
char	*domain = rdomain;
char	*maildir = rmaildir;
char	*home = rhome;
char	*confdir = rconfdir;
char	*spooldir = rspooldir;
char	*pubdir = rpubdir;
char	*logdir = rlogdir;
char	*newssdir = rnewssdir;
char	*tempdir = rtempdir;
char	*mailserv = rmailserv;
char 	*nodename = rnodename;
char 	*device = rdevice;
char 	*speed = rspeed;
#else
char	*mailbox;
char	*name;
char	*domain;
char	*maildir;
char	*home;
char	*confdir;
char	*spooldir;
char	*logdir;
char	*pubdir;
char	*newssdir;
char	*tempdir;
char	*mailserv;
char 	*nodename;
char 	*device;
char 	*speed;
#endif
 
void genv(thename, envname, dflt)
char **thename;
char *envname;
char *dflt;
{
	char *temp;
	
	if ((temp = getenv( envname )) == (char *)NULL) {
	   if ( debuglevel > 0 )
	      fprintf( stderr, "genv: %s not found, using %s\n",
	                       envname, dflt );
	   temp = dflt;
	}
	*thename = malloc( strlen( temp ) + 1 );
	strcpy( *thename, temp );
	if ( debuglevel > 0 )
	   fprintf( stderr, "genv: %s = %s\n", envname, *thename );
}

void loadenv()
{
	/* get environment var's */
	genv( &name, NAME, DNAME );
	genv( &mailbox, MAILBOX, DMAILBOX );
	genv( &domain, DOMAIN, DDOMAIN );
	genv( &maildir, MAILDIR, DMAILDIR );
	genv( &confdir, CONFDIR, DCONFDIR );
	genv( &spooldir, SPOOLDIR, DSPOOLDIR );
	genv( &logdir, LOGDIR, DLOGDIR );
	genv( &home, HOME, DHOME );
	genv( &pubdir, PUBDIR, DPUBDIR );
	genv( &newssdir, NEWSSDIR, DNEWSSDIR );
	genv( &tempdir, TEMPDIR, DTEMPDIR );
	genv( &mailserv, MAILSERVICE, DMAILSERVICE );
	genv( &nodename, NODENAME, DNODENAME );
	genv( &device, DEVICE, DDEVICE );
	genv( &speed, SPEED, DSPEED );
}
 
void mkfilename( filename, dirname, name )
char *filename;
char *dirname;
char *name;
{
	sprintf( filename, FILENAME, dirname, name );	
	if ( debuglevel > 5 )
	   fprintf( stderr, "genv: New filename %s\n", filename );
}


#ifdef TEST
main()
{
	loadenv();
}
#endif


SHAR_EOF
fi # end of overwriting check
if test -f 'st/getargs.c'
then
       echo shar: will not over-write existing file "'st/getargs.c'"
else
cat << \SHAR_EOF > 'st/getargs.c'
#include <ctype.h>

int getargs( line, flds )
char *line;
char **flds;
{
	int i = 0;
	char *s;

	while ( (*line != '\0') && (*line != '\n') )
	{
	   if ( isspace(*line) )
	   {
	      line++;
	      continue;
	   }
	   *flds++ = line;
	   i++;
	   while( (isspace(*line) == 0) && (*line != '\0') ) line++;
	   if (isspace(*line)) *line++ = '\0';
	}
	return(i);
}

#ifdef TEST

char comline[64] = "this is a test\n";

main(argc, argv)
int argc;
char *argv;
{
	char *flds[60];
	int  i,j;

	i = getargs( comline, flds );

	printf( "Num args = %d\n", i );

	for (j=0; j<i; j++)
	  printf( "Arg[%d] = %d %s\n", j, strlen(flds[j]), flds[j] );
}
#endif



SHAR_EOF
fi # end of overwriting check
if test -f 'st/getenv.c'
then
       echo shar: will not over-write existing file "'st/getenv.c'"
else
cat << \SHAR_EOF > 'st/getenv.c'
/*
 * char *getenv( s )
 *
 */
#include <string.h>
#define strchr index
#define strrchr rindex

extern char *_base;		/* pointer to base page */

#ifndef NULL
#define NULL 0
#endif

char *getenv( s )
char *s;
{
   char *envp;
   int  n;

   envp = *(char **)(_base + 44);	/* pointer to enviroment strings */

/*printf( "Base address = %lx, Enviroment = %lx\n", _base, envp ); /* */

   if ( *envp == '\0' ) return (char *)NULL;

   while ( *envp != '\0' )
   {

/*printf( "Checking %s\n", envp ); /* */

      n = strlen(s);

      if ( strncmp( envp, s, n ) != 0 )
      {
         while ( *envp++ != '\0' );
/*printf( "Failed match, next string at %lx\n", envp ); /* */
         continue;
      }
/*printf( "Matched %s\n", envp ); /* */
      envp += n;			  /* skip over variable name */
      if ( *envp != '=' )
      {
         envp = strchr( envp, '\0' ) + 1; /* skip this string */
         continue;
      }
      break;
   }
   return ( ( *envp != '=' ) ? (char *)NULL : ++envp );
}

#ifdef TEST

main( argc, argv )
int argc;
char **argv;
{
	char *s;

	argc--;			/* skip program name */
	argv++;

	while ( argc-- )
	{
	  s = *argv;
	  while ( *s != '\0' )
	  {
	    if ( *s >= 'a' && *s <= 'z' ) *s = *s - 32;
	    *s++;
	  }
	  s = getenv( *argv );
	  if (s == (char *)NULL)
	    printf( "%s is not defined\n", *argv );
	  else
	    printf( "%s = %s\n", *argv, s );
	  argv++;
	}
}
#endif


SHAR_EOF
fi # end of overwriting check
if test -f 'st/getone.c'
then
       echo shar: will not over-write existing file "'st/getone.c'"
else
cat << \SHAR_EOF > 'st/getone.c'
#include <osbind.h>

int get_one()
{
	int c;

	c = Crawcin() & 0xFF;
	if ( c == '\r' ) c = '\n';
	return( c );
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/host.c'
then
       echo shar: will not over-write existing file "'st/host.c'"
else
cat << \SHAR_EOF > 'st/host.c'
#include <stdio.h>
#include <setjmp.h>
#include "genv.h"

int  chdir();
void loadenv();
void printmsg();

extern int errno;

char *curdir;
char *getcwd();
char c_curdir[256];

jmp_buf	dcpexit;


main( argc, argv )
int argc;
char **argv;
{
	/* host specific prolog */
	loadenv();
	curdir = getcwd( c_curdir, 0 );
	if (chdir( spooldir ) != 0)
	{
	   return(errno);
	}

	/* setup longjmp for error exit's */
	if ( setjmp( dcpexit ) == 0 ) {

		MAIN(argc, argv );

	}
	

	/* host specific epilog */
	if (chdir( curdir ) != 0)
	{
	   return(errno);
	}
	return(0);
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/host.h'
then
       echo shar: will not over-write existing file "'st/host.h'"
else
cat << \SHAR_EOF > 'st/host.h'
/* Atari ST, Alcyon C Version 4.14a					*/
/* Host specific defines for uu and mail				*/

#include <setjmp.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <osbind.h>
#include <time.h>
#include "genv.h"

#define XENIX		/* don't send debugging info in startup message	*/
#define fgets Fgets	/* use our own fgets to fix problem in runtime	*/
#define mkdir Dcreate	/* create directory				*/

#define ATARIST

#define strchr  index
#define strrchr rindex
#define FILEMODE(f)

#define SEPCHAR		'\\'	/* path separater character		*/
#define XQTFILE 	"X_"	/* prefix for execute files		*/
#define CALLFILE	"C_"	/* prefix for call files		*/
#define TFILENAME	"TM.%03ld"	/* template for temporary files	*/
#define SFILENAME	"SEQF"	/* name of the sequence file		*/
#define SIGFILE		"WHOAMI"	/* file containing signature	*/
#define COPYFILE	"MAIL\\MAILSENT"	/* copy of sent mail	*/
#define NEWSDIR		"\\spool\\rnews\\%02d%02d%02d%02d.%03d"	/* format for news name	*/
#define HOSTINIT		/* name of function used to initialize	*/

/* Rsconf() defines */

#define RSR		(-1)		/* leave as is			*/
#define TSR		(-1)		/* " "     " "			*/
#define SCR		(-1)		/* " "     " "			*/
#define UCR		(0x98)		/* 8-bits, no parity, 2 stops	*/
#define NOFLOW		(0)		/* no flow control		*/

#define B19200		(0)		/* 19200 baud			*/
#define B9600		(1)		/* 9600 baud			*/
#define B4800		(2)		/* 4800 baud			*/
#define B2400		(4)		/* 2400 baud			*/
#define B1200		(7)		/* 1200 baud			*/
#define B300		(9)		/*  300 baud			*/

/* misc. defines */

#ifndef TRUE
#define FALSE		(0)
#define TRUE		(-1)
#endif

#ifndef SAME
#define SAME		(0)
#endif

#define AUX		(1)		/* rs232 port			*/
#define CON		(2)		/* console			*/

#define CTRL(X)		(X & 037)	/* get a control character	*/

#define	IBUFSIZ		(0x1000)
#define	OBUFSIZ		(0x1000)

/* typedef for Iorec() stuff (modified & improved by Martin Minow) */
	
struct iorec
  {
    char	*ibuf;		/* Pointer to input buffer */
    int		ibufsize;	/* Size of input buffer    */
    int		ibufhd;		/* Head index              */
    int		ibuftl;		/* Tail index		   */
    int		ibuflow;	/* Low water mark	   */
    int		ibufhi;		/* Hi water mark	   */
  };
    
typedef struct {
    struct iorec in;			/*  0 Input buffer		*/
    struct iorec out;			/* 14 Output buffer		*/
} IOREC;


/*
 * Rsconf() returns the "old" parameters in a longword encoded as follows:
 * bits		value
 * 31-24	UCR
 * 23-16	RSR
 * 15- 8	TSR
 *  8- 0	SCR
 *
 * Note that we must redefine the Rsconf() macro.
 */


#define	RS_UCR_SHIFT	24
#define RS_RSR_SHIFT	16
#define RS_TSR_SHIFT	 8
#define RS_SCR_SHIFT	 0

extern int errno;


SHAR_EOF
fi # end of overwriting check
if test -f 'st/inoutpth.c'
then
       echo shar: will not over-write existing file "'st/inoutpth.c'"
else
cat << \SHAR_EOF > 'st/inoutpth.c'
#include <string.h>
#include <ctype.h>

#define NULL 0
#define strchr index
#define strrchr rindex

#define min(x,y) (((x) < (y)) ? (x) : (y))
/*
 *                  Canonical name conversion routines
 *
 * These routines convert file name between canonical form which is defined
 * as a 'unix' style pathname and whatever format the host system can
 * handle.
 */

/*
 * importpath( host, canon )
 *
 * Convert a canonical name to a format the host can handle
 *
 * Mung the canonical file name as follows:
 *   1 - strip any path from the canonical name
 *   2 - copy up to 8 character from the canonical name converting . to _
 *   3 - if the name was longer than 8 character copy a . to the host name
 *       and then copy the up to three characters from the tail of the
 *	 canonical name to the host name.
 */
char *importpath( host, canon )
char *host, *canon;
{
	char *s,*out,c;
	int  i,j,l;

	out  = host;

	/*
	 * get a pointer to the last component of the path
	 */

	if ( (s = strrchr( canon, '/' )) == (char *)NULL ) s = canon;
	else s++;

	j = min(l = strlen(s),8);

	for (i=0; i<j; i++)
	{
	   c = *s++;
	   *out++ = (c == '.') ? '_' : c;
	}
	*out = '\0';

	while (*s != '\0') s++;

	if (l>8)
	   for (i=0; i<3; i++)
	      if (*--s == '.') { s++; break; }

	if (*s != '\0')
	{

	   strcat( out, "." );
	   strcat( out, s );
	}

	return( host );
}

/*
 * exportpath( canon, host )
 *
 * Convert a host name into canonical name
 *
 * Copy file name from host to canon converting an underscore in the second
 * character to a dot and any other dots into the letter B.
 *
 */
exportpath( canon, host )
char *host, *canon;
{
	register char c;
	register char *s = canon;
	do
	{
	   c = *s = tolower( *host );
	   if ( c == '.' ) *s = 'B';
	   s++;
	} while ( *host++ != '\0' );

	*canon = toupper( *canon );
	if ( canon[1] == '_' )
	   canon[1] = '.';
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/ldcp.mm'
then
       echo shar: will not over-write existing file "'st/ldcp.mm'"
else
cat << \SHAR_EOF > 'st/ldcp.mm'
del uu.prg
a:link68 [s,tem[d:]] uu.68k=gemstart,uuhost,uusup,rmail,dcplib,utllib,lib,osbind,gemlib,dmymath
d:relmod uu
del uu.68K


SHAR_EOF
fi # end of overwriting check
if test -f 'st/l.mm'
then
       echo shar: will not over-write existing file "'st/l.mm'"
else
cat << \SHAR_EOF > 'st/l.mm'
a:link68 [s,tem[d:]] $1.68k=gemstart,$1.o,osbind,gemlib
d:relmod $1
del $1.68K


SHAR_EOF
fi # end of overwriting check
if test -f 'st/l1.mm'
then
       echo shar: will not over-write existing file "'st/l1.mm'"
else
cat << \SHAR_EOF > 'st/l1.mm'
a:link68 [s,tem[d:]] x.68k=gemstart,uuatari,dcp,dcpsys,dcpgpkt,dcpxfer,util.a,osbind,gemlib


SHAR_EOF
fi # end of overwriting check
if test -f 'st/ldcp.mm'
then
       echo shar: will not over-write existing file "'st/ldcp.mm'"
else
cat << \SHAR_EOF > 'st/ldcp.mm'
del uu.prg
a:link68 [s,tem[d:]] uu.68k=gemstart,uuhost,uusup,rmail,dcplib,utllib,lib,osbind,gemlib,dmymath
d:relmod uu
del uu.68K


SHAR_EOF
fi # end of overwriting check
if test -f 'st/lmail.mm'
then
       echo shar: will not over-write existing file "'st/lmail.mm'"
else
cat << \SHAR_EOF > 'st/lmail.mm'
a:link68 [s,tem[d:]] mail.68k=gemstart,mailhost,mail,lmail,utllib,osbind,gemlib,dmymath
d:relmod mail
del mail.68K


SHAR_EOF
fi # end of overwriting check
if test -f 'st/ndir.c'
then
       echo shar: will not over-write existing file "'st/ndir.c'"
else
cat << \SHAR_EOF > 'st/ndir.c'
/*
 * Program: ndir.c
 * Facility: 
 *	Directory reading support for the atari st
 */

#define DEF_NDIR

#include <osbind.h>
#include <stdio.h>
#include <ndir.h>

#ifndef TRUE
#define TRUE	(-1)
#define FALSE	(0)
#endif

#define BSLASH	'\\'
#define SLASH	'/'

DIR    DtaBuff;			/* used by GEMDOS for Fsfirst/Fsnext */
short  FirstSearch;		/* used to first call to readdir     */
struct direct dentry;		/* portable directory structure      */

DIR *opendir( filename )
char *filename;
{
	int status;
	char *cp1,*cp2;

	Fsetdta( &DtaBuff );
	FirstSearch = TRUE;

	/*
	 * Copy filename into FilePath buffer and convert forward slashs
	 * to backward slashes.
	 * Also make sure path terminates in a back slash
	 */
	cp1 = DtaBuff.FilePath;
	cp2 = filename;
	while (*cp2 != '\0')
	{
	  *cp1++ = (*cp2 == SLASH) ? BSLASH : *cp2;
	  cp2++;
	}
	if ( *(cp1-1) != BSLASH )	/* enforce trailing back slash */
	{
	  *cp1++ = BSLASH;
	}
	*cp1   = '\0';			/* add trailing zero */
	strcat( DtaBuff.FilePath, "*.*" );

	status = Fsfirst( DtaBuff.FilePath, 0 );
	if ( status != 0 ) return( (DIR *)NULL );
	return( &DtaBuff );
}

struct direct *readdir( dirp )
DIR *dirp;
{
	int status;

	if ( FirstSearch )
	{
	  FirstSearch     = FALSE;
	  dentry.d_ino    = 0L;
	  dentry.d_reclen = 264;
	  dentry.d_namlen = strlen( dirp->FileName );
	  strcpy( dentry.d_name, dirp->FileName );
	  return( &dentry );
	}
	Fsetdta( dirp );
	if (( status = Fsnext() ) != 0 )
	  return( (struct direct *)NULL );
	dentry.d_ino    = 0L;
	dentry.d_reclen = 264;
	dentry.d_namlen = strlen( dirp->FileName );
	strcpy( dentry.d_name, dirp->FileName );
	return( &dentry );
}

void closedir( dirp )
DIR *dirp;
{
	return;
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/ndir.h'
then
       echo shar: will not over-write existing file "'st/ndir.h'"
else
cat << \SHAR_EOF > 'st/ndir.h'
/* @(#)ndir.h	1.4	4/16/85 */
/* Modified for the atari st series 5/4/87 */
#ifndef DEV_BSIZE
#define	DEV_BSIZE	512
#endif
#define DIRBLKSIZ	DEV_BSIZE
#define	MAXNAMLEN	255

struct	direct {
	long	d_ino;			/* inode number of entry */
	short	d_reclen;		/* length of this record */ 
	short	d_namlen;		/* length of string in d_name */
	char	d_name[MAXNAMLEN + 1];	/* name must be no longer than this */
};

/*
 * The DIRSIZ macro gives the minimum record length which will hold
 * the directory entry.  This requires the amount of space in struct direct
 * without the d_name field, plus enough space for the name with a terminating
 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
 */

#ifdef DIRSIZ
#undef DIRSIZ
#endif
#define DIRSIZ(dp) \
    ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))

/*
 * Definitions for library routines operating on directories.
 */

/* Structure of a directory entry under GEMDOS */

typedef struct _dirdesc
  {
    char	Reserved[21];
    char	FileAttr;
    int		CreateTime;
    int		CreateDate;
    long	FileSize;
    char	FileName[14];
    char	FilePath[256];
  } DIR;

#ifndef NULL
#define NULL 0L
#endif

#ifndef DEF_NDIR
extern	DIR *opendir();
extern	struct direct *readdir();
extern	void closedir();
#endif

SHAR_EOF
fi # end of overwriting check
if test -f 'st/printmsg.c'
then
       echo shar: will not over-write existing file "'st/printmsg.c'"
else
cat << \SHAR_EOF > 'st/printmsg.c'
#include <stdio.h>
#include <string.h>
extern FILE *logfile;
extern int debuglevel;
extern int remote;

#define MASTER 1

/**/
/*
 *  p r i n t m s g
 *
 *  Print error message on standard output if not remote.
 */
/*VARARGS1*/
printmsg(level, fmt, a1, a2, a3, a4, a5)
int 	level;
char	*fmt;
char	*a1, *a2, *a3, *a4, *a5;
{
	char	msg[256];

	if ( debuglevel > level ) {
		sprintf( msg, fmt, a1, a2, a3, a4, a5 );
		strcat( msg, "\n" );
		if ( remote == MASTER ) 
			fputs( msg, stdout );
		fputs( msg, logfile );
	}
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/readme.st'
then
       echo shar: will not over-write existing file "'st/readme.st'"
else
cat << \SHAR_EOF > 'st/readme.st'
This file contains the Atari ST specific files.

I have done all the compilation using the Alcyon C versin 4.14a compiler.
The disks were layed out with all the sources and objects on the A drive and
the compiler on the D drive.

Problems with the Atari ST code:

	- there is a problem in the getsystem(), sysend() states such that
	  if there is more than one system in the systems file then the
	  program may bomb bomb (bus error?)

Files included in this shar script:

		On the atari these files should be placed in the
		\local directory or the .h files will need to be
		edited.

	  dirsubs.c	- file and directory name manipulation
	  dmymath.c	- dummy floating point routines to fake out linker
	  genv.c	- load enviroment strings
	  getenv.c	- get and enviroment string
	  getone.c	- get one character without echo
	  host.c	- host specific main program
	  inoutpth.c	- file name conversion
	  ndir.c	- directory manipulation routines
	  printmsg.c	- print message to log file
	  time.c	- date/time conversion routines
	  uusup.c	- uu support routines

	  The following files belong in the ./local dirctory and should
	  be moved there with the leading z stripped off.

	  zdcp.h	- main include file for uu
          zmailhost.c	- host specific mail main program
          zuuhost.c	- host specific uu main program
	  zgenv.h	- definitions for enviroment variables
	  zhost.h	- host specific definitions
	  zndir.h	- directory manipulation routines header
	  ztime.h	- time routine header

The following script files are included as examples on how to compile
the sources.  They are for the CM command shell.

	  c.mm		- compile script for alcyon C (file is in A:\)
	  cu.mm		- compile script for alcyon C (file is in A:\atari\)
	  env.mm	- define enviroment script
	  ldcp.mm	- link uu.prg
	  lmail.mm	- link mail.prg
	  uuar.mm	- create DCPLIB
	  utar.mm	- create UTLLIB

Basic procedure is to:
	- compile all the .c files into .o files
	- build the DCPLIB with uuar.mm
	- build the UTLLIB with utar.mm
	- link uu with ldcp.mm
	- link mail with lmail.mm

If you have problems feel free to drop me a line.  Though I warn you I have
a slow turn around time on questions I will try to get back to you within
a day or two.

------------------------------------------------------------------------------
UUCP:  {alberta,uw-beaver,siesmo}!ubc-vision!van-bc!nvanbc!lawrence
SNAIL: 733 Sylvan Ave., North Vancouver, B.C., Canada, V7R 2E8
PHONE: 1-604-736-9241 (09:00-17:00 PDT)

SHAR_EOF
fi # end of overwriting check
if test -f 'st/shell.c'
then
       echo shar: will not over-write existing file "'st/shell.c'"
else
cat << \SHAR_EOF > 'st/shell.c'


SHAR_EOF
fi # end of overwriting check
if test -f 'st/startup.mm'
then
       echo shar: will not over-write existing file "'st/startup.mm'"
else
cat << \SHAR_EOF > 'st/startup.mm'
remenv A:\
setenv CONFDIR A:\LIB
setenv MAILDIR A:\SPOOL\MAIL
setenv PUBDIR A:\SPOOL\UUCPPUBL
setenv SPOOLDIR A:\SPOOL\UUCP
setenv NODENAME test
setenv USERNAME lawerence
setenv SPEED 9600
setenv DEVICE AUX:

SHAR_EOF
fi # end of overwriting check
if test -f 'st/time.c'
then
       echo shar: will not over-write existing file "'st/time.c'"
else
cat << \SHAR_EOF > 'st/time.c'
/*
 * time(), ctime(), localtime(), sleep()
 *
 */
#include <osbind.h>
#include <time.h>
#define NULL 0

long *_hz200 = (long *)0x0004ba;	/* address of system 200 hz clk	*/
long _prtime;

/*
 * read200hz() - read the system 200hz clock
 *
 * Must be a separate routine since it is called in supervisor mode
 *
 */
void _read200hz()
{
	_prtime = *_hz200;
}

long time( tloc )
long *tloc;
{
	long t;
	Supexec( _read200hz );
	t = _prtime / 200L;
	if ( tloc != (long *)NULL ) *tloc = t;
	return( t );
}
/*
 * ctime(clock) - Return the time as DDD MMM dd hh:mm:ss YYYY\n\0
 *
 * Since I don't have a working time() call just now I ignore the clock
 * and simply return the current date and time.  This is all that this
 * program requires anyway.
 */
char _timearr[26];
char *_Months =
	"Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec\0";

char *ctime( clock )
long *clock;
{
	short date;
	short time;

	date = Tgetdate();	/* Get date from DOS */
	time = Tgettime();	/* Get time from DOS */

	sprintf( _timearr, "%.3s %.3s %02d %02d:%02d:%02d %04d\n",
			"   ",
			_Months + ((((date>>5) & 0xF) - 1) << 2),
			(date & 0x1F),
			(time >> 10), (time >> 4) & 0x3F, (time & 0xF) << 1,
			(date >> 9) + 1980 );
	return( _timearr );
}

/*
 * localtime() - Return tm structure.
 *
 * Since I don't have a working time() call just now I ignore the clock
 * and simply return the current date and time.  This is all that this
 * program requires anyway.  Note: wday, yday and idist not implemented.
 */

struct tm _TMstruct;

struct tm *localtime( clock )
long *clock;
{
	unsigned short date;
	unsigned short time;

	date = Tgetdate();	/* Get date from DOS */
	time = Tgettime();	/* Get time from DOS */

	_TMstruct.tm_sec = ( time & 0xF ) << 1;
	_TMstruct.tm_min = ( time >> 4 ) & 0x3F;
	_TMstruct.tm_hour= ( time >> 10) & 0x0F;
	_TMstruct.tm_mday= ( date & 0x1F );
	_TMstruct.tm_mon = ( date >> 5 ) & 0xF;
	_TMstruct.tm_year= ( date >> 9 ) + 80;
	_TMstruct.tm_wday= 0;
	_TMstruct.tm_yday= 0;
	_TMstruct.tm_isdst= 0;
	return( &_TMstruct );
}

/*
 * sleep() - wait n seconds
 *
 * Simply delay until n seconds have passed
 *
 */

void sleep(n)
unsigned int n;
{
	unsigned long i;

	i = (unsigned long)time((long *)NULL);
	while ( ( (unsigned long)time((long *)NULL) - i ) < n ) ;
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/utar.mm'
then
       echo shar: will not over-write existing file "'st/utar.mm'"
else
cat << \SHAR_EOF > 'st/utar.mm'
a:ar68 rv d:\utllib dirsubs.o genv.o printmsg.o ndir.o getenv.o fgets.o getone.o inoutpth.o shell.o time.o

SHAR_EOF
fi # end of overwriting check
if test -f 'st/uu.mm'
then
       echo shar: will not over-write existing file "'st/uu.mm'"
else
cat << \SHAR_EOF > 'st/uu.mm'
D:UU -R1 -X10 -SVAN-BC

SHAR_EOF
fi # end of overwriting check
if test -f 'st/uuar.mm'
then
       echo shar: will not over-write existing file "'st/uuar.mm'"
else
cat << \SHAR_EOF > 'st/uuar.mm'
del d:dcplib
a:ar68 rv d:\dcplib dcp.o dcpsys.o dcpgpkt.o dcpxfer.o
del a:dcplib
copy d:dcplib a:
del d:dcplib

SHAR_EOF
fi # end of overwriting check
if test -f 'st/uusup.c'
then
       echo shar: will not over-write existing file "'st/uusup.c'"
else
cat << \SHAR_EOF > 'st/uusup.c'
/*
 * atari st system specific subroutines for uu
 *
 * these are included into uuhost.c during compile
 */
#include <dcp.h>

struct
   {
      char	*baud;
      int	baudidx;
   } BaudStr[] = { "300", B300,
		   "1200", B1200,
		   "2400", B2400,
		   "4800", B4800,
		   "9600", B9600,
		   "19200", B19200,
		   "-1", -1
		 };

/* some global variables */

char st_ibuf[IBUFSIZ];			/* our own input buffer		*/
char st_obuf[OBUFSIZ];			/* and our own output buffer	*/

/* most of the Iorec() stuff was redone by Martin Minow (thanks) */

IOREC *st_sysr;				/* ptr to system rs232 record	*/
IOREC st_savr;				/* to save system rs232 record	*/
IOREC st_myiorec;

unsigned long	old_rsconf;
int		old_ucr, old_rsr, old_tsr, old_scr;
int		st_baud = B9600;	/* default baud rate */

/*
 * r_count_remaining() - Access the i/o structures and find out how many
 * characters there are in the input ring buffer.
 */

int r_count_remaining()
{
	IOREC *ReadPort;
	int Diff;

	ReadPort = (IOREC *)Iorec(0);
	Diff = ReadPort->in.ibuftl - ReadPort->in.ibufhd;
	if ( Diff < 0 )
	  Diff = IBUFSIZ - abs( Diff );
	return( Diff );
}

/*
 *                      Read/Write I/O processing
 */

/*
 * openline - Open the communication line for use with dcp.
 */

openline( name, baud )
    char	*name, *baud;
{

     register int i;


     st_myiorec.in.ibuf = st_ibuf;
     st_myiorec.in.ibufsize = IBUFSIZ;
     st_myiorec.in.ibufhd = st_myiorec.in.ibuftl = 0;
     st_myiorec.in.ibuflow = IBUFSIZ / 4;
     st_myiorec.in.ibuflow = (IBUFSIZ / 4 ) * 3;

     st_myiorec.out.ibuf = st_ibuf;
     st_myiorec.out.ibufsize = OBUFSIZ;
     st_myiorec.out.ibufhd = st_myiorec.out.ibuftl = 0;
     st_myiorec.out.ibuflow = OBUFSIZ / 4;
     st_myiorec.out.ibuflow = (OBUFSIZ / 4 ) * 3;

     for (i=0; 	BaudStr[i].baudidx != -1; i++ )
       if ( strcmp( baud, BaudStr[i].baud) == 0 )
	 {
	   st_baud = BaudStr[i].baudidx;
	   break;
	  }
/* 
 *	set up our own rs232 input and output buffers
 */
    st_sysr = (IOREC *)Iorec(0);
    st_savr = *st_sysr;			/* Save system buffer	*/
    *st_sysr = st_myiorec;		/* Set my io buffer	*/

/*
 * Saving the old Rsconf() parameters, and
 * adding the 2 Vsync() calls was done by Martin Minow.
 *
 * Rsconf(baud, ctrl, usr, rsr, tsr, scr):
 * baud	New line speed
 * ctrl	UART control register: 2 stop bits, match speed
 * rsr	Receiver on
 * tsr	Transmitter on
 * scr	Synchronous register ignored.
 * Rsconf returns the "old" values.
 */

    printf("Setting Com port - speed = %d\n", st_baud);
    old_rsconf = Rsconf(st_baud, NOFLOW, UCR, RSR, TSR, SCR);
    old_ucr = (old_rsconf >> RS_UCR_SHIFT) & 0xFF;
    old_rsr = (old_rsconf >> RS_RSR_SHIFT) & 0xFF;
    old_tsr = (old_rsconf >> RS_TSR_SHIFT) & 0xFF;
    old_scr = (old_rsconf >> RS_SCR_SHIFT) & 0xFF;
/*
 * Magic.
 */
    Vsync();			/* Short delay while	*/
    Vsync();			/* The UART settles	*/
    return ( 0 );
}

/*
 * closeline - Restore the communication line to the way we found it.
 */

void closeline()
{
	/* restore the system's i/o record				*/
	*st_sysr = st_savr;

	/* Replace old RS232 parameters				*/
	Rsconf(B9600, 1, old_ucr, old_rsr, old_tsr, old_scr);
}

/*
 * sread( buf, num, timeout ) - Read num characters within timeout
 */

int sread( buf, num, timeout )
char *buf;
int  num, timeout;
{
	int count,test;
	unsigned char *cp;

	if (debuglevel > 13)
	  fputc( '[', stderr );
	printmsg(15, "sread: num: %d  timeout: %d", num, timeout );

	count = xread( buf, num, timeout );

	printmsg(15, "sread: read: %d ", count);

	if (debuglevel > 13 && count > 0)
	{
	  test = count;
	  cp = buf;
	  while (test--)
	    fprintf( stderr, isprint(*cp)? "[%c]":"[%02x]", *cp++ );
	}
	if (debuglevel > 13)
	  fputc( ']', stderr );
	return( count );
}

/*
 * swrite( buf, num ) - Write num characters to the output port
 */

int swrite( buf, num )
int  num;
char *buf;
{
	int  count;
	char *cp;

	if (debuglevel > 14)
	{
	  fputc( '{', stderr );
	  count = num;
	  cp = buf;
	  while ( count-- )
	    fprintf( stderr, isprint(*cp)? "{%c}":"{%02x}", *cp++ );
	  fputc( '}', stderr );
	}
	count = xwrite( buf, num );
	return( count );
}

/*
 * read buffer - low level
 */

int xread( buf, num, timeout )
char buf[];
int  num, timeout;
{
	long jtime;
	int i,jj,jd;

	jtime = time((long *)NULL);
	while (TRUE)
	{
	  jj = r_count_remaining();
	  if ( jj >= num )
	  {
	    for ( i=0; i < num; i++ )
	    {
	      buf[i] = Bconin(AUX) & 0xFF;
	    }
	  return( jj );
	  }
	  else
	  {
	    jd = time((long *)NULL) - jtime;
	    if ( jd >= timeout )
	      return( jj );
	  }
	}
}

/*
 * xwrite( buf, n ) - Write n bytes froum the buffer to the port
 */

int xwrite( buf, n )
char buf[];
int  n;
{
	register int i;

	for ( i=0; i<n; i++ )
	{
	  Bconout( AUX, buf[i] );
	}
	return( n );
}

void SIOSpeed( s )
char *s;
{
	return;
}
/*
 *                  Command shell processing
 *
 * Pass a command the the host operating system to execute.
 *
 */
/* 		shell


*/
notimp( argc, argv )
int argc;
char **argv;
{
	printf( "%s not implemented\n", argv[0]);
}

shell( command, inname, outname, errname )
char * command;
char * inname;
char * outname;
char * errname;
{

	char	*argvec[50];	/* array of pointers to make up arg list */
	char	hostname[32];	/* place to put munged file name */
	char	curdir[64];	/* place to remember current directory */

	int	rmail();	/* mail program */
	int	rnews();	/* news program */
	int	(*proto)();	/* variable containing program pointer */
	
	int 	argc;		/* will contain the number of args */
	char	**argv;		/* will contain pointer to arg vector */

	int	args;		/* temporary for copy of argc */
	
	/*
	 * Break up the command line into an argument vector
	 */
	argc = getargs( command, argvec );
	argv = argvec;

	if ( debuglevel > 5 )
	{
	   args = argc;
	   while ( args ) 
	      fprintf( stderr, "arg: %d  %s\n", args--, *argv++ );
	   argv = argvec;
	}
	/*
	 * Initialize to function which will print 'not implemented
	 * then see if the command is one we know about and if so set
	 * up out function pointer.
	 */
	proto = notimp;

	if ( strcmp( *argv, "rmail" ) == SAME )
	   proto = rmail;
	else if ( strcmp( *argv, "rnews" ) == SAME ) {
	   proto = rnews;
	}

	*hostname = '\0';
	if ( *inname != '\0' )
	   importpath( hostname, inname );
		
	if ( *hostname != '\0' ) {
	   fprintf( stderr, "reopening stdin as %s\n", hostname);
	   fprintf( stderr, "curdir: %s\n", getcwd(curdir, 0)); /* */
	   fclose( stdin );
	   if ( fopen( hostname, "r" ) == (FILE *)NULL ) /* */
/*	   if ( freopen( hostname, "r", stdin ) == (FILE *)NULL ) /* */
	   {
	      fprintf( stderr, "Couldn't open %s, %d\n", hostname, errno );
	      exit(-1);
	   }
	}
	(proto)( argc, argv );

	chdir( curdir );

	fclose( stdin );
	if ( fopen(  "CON:", "r" ) == (FILE *)NULL )
	{
	   fprintf( stderr, "Couldn't reopen CON:" );
	}
/*	freopen( "CON:", "r", stdin ); /* */

}


/**/
/*
 *
 *      login (for slave in PC mode)
 * Real dumb login handshake
*/
login()
{
	char	logmsg[132];
lretry:
	msgtime = 9999;
	rmsg(logmsg, 0); /* wait for a <CR> or <NL> */
	msgtime = 2 * MSGTIME;
	wmsg("Username:", 0);
	rmsg(logmsg, 0);
	printmsg( 0, "Username = %s", logmsg );
	wmsg("Password:", 0);
	rmsg(logmsg, 0);
	printmsg( 14, "Password = %s", logmsg );
	if (strcmp(logmsg, "uucp") != 0) 
		goto lretry;
	return('I');
}


SHAR_EOF
fi # end of overwriting check
if test -f 'st/zdcp.h'
then
       echo shar: will not over-write existing file "'st/zdcp.h'"
else
cat << \SHAR_EOF > 'st/zdcp.h'
/* DCP a uucp clone. Copyright Richard H. Lamb 1985,1986,1987 */
#include <stdio.h>		/* Standard UNIX  definitions */
#include "host.h"		/* Host specific definitions */

FILE * FOPEN();
int CREAT();

#define SYSTEMS		"systems"
#define LOGFILE		"LOGFILE"
#define SYSLOG		"SYSLOG"

#define MSGTIME         20
#define MAXPACK         256

#define ACK     4       /*      general definitions     */
#define NAK     2
#define DATA    0
#define CLOSE   1
#define ERROR   10
#define EMPTY   11



#define	SLAVE	0
#define	MASTER	1

#ifndef TRUE
#define TRUE   (-1)
#define FALSE   0
#endif

#define SAME	0
#define FAILED	-1
#define OK		0


/* L.sys field defines */

#define	FLD_REMOTE	0
#define	FLD_CCTIME	1
#define	FLD_DEVICE	2
#define	FLD_TYPE	3
#define	FLD_SPEED	4
#define	FLD_PROTO	5
#define	FLD_EXPECT	6
#define FLD_SEND	7

/**/
typedef int	(*procref)();

typedef struct {
	char	type;
	procref a;
	procref b;
	procref c;
	procref d;
} Proto;

/* the various protocols available. Add here for others */
extern procref          getpkt, sendpkt, openpk, closepk;

extern int	ggetpkt(), gsendpkt(), gopenpk(), gclosepk();
/*
extern int	kgetpkt(), ksendpkt(), kopenpk(), kclosepk();
extern int	rgetpkt(), rsendpkt(), ropenpk(), rclosepk();
extern int	tgetpkt(), tsendpkt(), topenpk(), tclosepk();
*/

/**/
extern int	pktsize;                /* packet size for this pro*/
extern FILE	*logfile;            	/* system log file */
extern FILE	*syslog;            	/* system log file */
extern FILE	*fw;           		/* cfile pointer */
extern char	cfile[80];              /* work file pointer */
extern int	remote;                 /* -1 means we're remote*/
extern int	findwork;
extern int	msgtime;                /* timout setting */
extern char	fromfile[132];
extern char	hostfile[132];		/* host version of fromfile */
extern char	tofile[132];
extern char	state;                  /* present state */
extern int	fp;                     /* current disk file ptr */
extern int	size;                   /* nbytes in buff */
extern FILE	*fsys;
extern char	Rmtname[20];
extern char	rmtname[20];
extern char	*cctime;
extern char	proto[5];

extern char sysline[BUFSIZ];
extern char s_systems[64];
extern char s_logfile[64];
extern char s_syslog[64];
extern char *flds[60];
extern int  kflds;

extern int	debuglevel;		/* debugging flag */
extern unsigned int	checksum();
extern char *index();
extern char *rindex();

extern	char *curdir;




SHAR_EOF
fi # end of overwriting check
if test -f 'st/zgenv.h'
then
       echo shar: will not over-write existing file "'st/zgenv.h'"
else
cat << \SHAR_EOF > 'st/zgenv.h'
/*	genv.c
 
 
 
	copyright (C) 1987 Stuart Lynne
 
	Copying and use of this program are controlled by the terms of the
	Free Software Foundations GNU Emacs General Public License.
 
 
	version		0.1		March 31/1987
 
	
 
environment variables
 
	The following evironment variables are defined:
 
	MAILBOX		current user's mailbox, 	"sl"
	NAME		current user's name, 		"Stuart Lynne"
	DOMAIN		domain of this machine, 	"mac.van-bc.can"
	MAILDIR		where mail is kept,		"/usr/mail"
	CONFDIR		where config data is  kept,	"/usr/lib/uucp"
	SPOOLDIR	where spooled files are 	"/usr/spool/uucp"
	LOGDIR		where log file are placed	"/usr/spool/uucp"
	PUBDIR		public spool directory		"/usr/spool/uucppublic"
	NEWSSDIR	news spool directory		"/usr/spool/rnews"
	TEMPDIR		where temp files are created	"/tmp"
	HOME		where uses private files are	"/usr/sl"
	MAILSERVICE	who do we send remote mail	"van-bc"
	NODENAME	what is our local nodename	"slmac"
	DEVICE		what is the default device	".a"
	SPEED		what is the default speed	"1200"
 
*/
 

#define	MAILBOX		"MAILBOX"
#define	NAME		"NAME"
#define	DOMAIN		"DOMAIN"
#define	MAILDIR		"MAILDIR"
#define HOME		"HOME"

#define	CONFDIR		"CONFDIR"
#define SPOOLDIR	"SPOOLDIR"
#define LOGDIR		"LOGDIR"
#define	PUBDIR		"PUBDIR"
#define	NEWSSDIR	"RNEWSDIR"
#define TEMPDIR		"TEMPDIR"
#define	MAILSERVICE	"MAILSERVICE"

#define NODENAME	"NODENAME"
#define	DEVICE		"DEVICE"
#define	SPEED		"SPEED"
 
extern char	*mailbox;
extern char	*name;
extern char	*domain;
extern char	*maildir;
extern char	*home;

extern char	*confdir;
extern char	*spooldir;
extern char	*newssdir;
extern char	*pubdir;
extern char	*tempdir;
extern char	*mailserv;

extern char	*nodename;
extern char	*device;
extern char	*speed;

void loadenv();
void genv();
void mkfilename();


SHAR_EOF
fi # end of overwriting check
if test -f 'st/zzgenv.h'
then
       echo shar: will not over-write existing file "'st/zzgenv.h'"
else
cat << \SHAR_EOF > 'st/zzgenv.h'
/*	genv.c
 
 
 
	copyright (C) 1987 Stuart Lynne
 
	Copying and use of this program are controlled by the terms of the
	Free Software Foundations GNU Emacs General Public License.
 
 
	version		0.1		March 31/1987
 
	
 
environment variables
 
	The following evironment variables are defined:
 
	MAILBOX		current user's mailbox, 	"sl"
	NAME		current user's name, 		"Stuart Lynne"
	DOMAIN		domain of this machine, 	"mac.van-bc.can"
	MAILDIR		where mail is kept,		"/usr/mail"
	CONFDIR		where config data is  kept,	"/usr/lib/uucp"
	SPOOLDIR	where spooled files are 	"/usr/spool/uucp"
	LOGDIR		where log file are placed	"/usr/spool/uucp"
	PUBDIR		public spool directory		"/usr/spool/uucppublic"
	NEWSSDIR	news spool directory		"/usr/spool/rnews"
	TEMPDIR		where temp files are created	"/tmp"
	HOME		where uses private files are	"/usr/sl"
	MAILSERVICE	who do we send remote mail	"van-bc"
	NODENAME	what is our local nodename	"slmac"
	DEVICE		what is the default device	".a"
	SPEED		what is the default speed	"1200"
 
*/
 

#define	MAILBOX		"MAILBOX"
#define	NAME		"NAME"
#define	DOMAIN		"DOMAIN"
#define	MAILDIR		"MAILDIR"
#define HOME		"HOME"

#define	CONFDIR		"CONFDIR"
#define SPOOLDIR	"SPOOLDIR"
#define LOGDIR		"LOGDIR"
#define	PUBDIR		"PUBDIR"
#define	NEWSSDIR	"RNEWSDIR"
#define TEMPDIR		"TEMPDIR"
#define	MAILSERVICE	"MAILSERVICE"

#define NODENAME	"NODENAME"
#define	DEVICE		"DEVICE"
#define	SPEED		"SPEED"
 
extern char	*mailbox;
extern char	*name;
extern char	*domain;
extern char	*maildir;
extern char	*home;

extern char	*confdir;
extern char	*spooldir;
extern char	*newssdir;
extern char	*pubdir;
extern char	*tempdir;
extern char	*mailserv;

extern char	*nodename;
extern char	*device;
extern char	*speed;

void loadenv();
void genv();
void mkfilename();

SHAR_EOF
fi # end of overwriting check
if test -f 'st/zhost.h'
then
       echo shar: will not over-write existing file "'st/zhost.h'"
else
cat << \SHAR_EOF > 'st/zhost.h'
/*		host.h

*/

#include "local\host.h"


SHAR_EOF
fi # end of overwriting check
if test -f 'st/zzhost.h'
then
       echo shar: will not over-write existing file "'st/zzhost.h'"
else
cat << \SHAR_EOF > 'st/zzhost.h'
/*
 * host.h
 */

#include "atari\host.h"

SHAR_EOF
fi # end of overwriting check
if test -f 'st/zmailhos.c'
then
       echo shar: will not over-write existing file "'st/zmailhos.c'"
else
cat << \SHAR_EOF > 'st/zmailhos.c'
/*		mailhost.c

*/
#define	MAIN	mailmain
#include	"local\host.c"

SHAR_EOF
fi # end of overwriting check
if test -f 'st/zzmailhost.c'
then
       echo shar: will not over-write existing file "'st/zzmailhost.c'"
else
cat << \SHAR_EOF > 'st/zzmailhost.c'
/*		mailhost.c

*/
#define	MAIN	mailmain
#include	"atari\host.c"

SHAR_EOF
fi # end of overwriting check
if test -f 'st/zndir.h'
then
       echo shar: will not over-write existing file "'st/zndir.h'"
else
cat << \SHAR_EOF > 'st/zndir.h'
/* @(#)ndir.h	1.4	4/16/85 */
#include "local\ndir.h"



SHAR_EOF
fi # end of overwriting check
if test -f 'st/zzndir.h'
then
       echo shar: will not over-write existing file "'st/zzndir.h'"
else
cat << \SHAR_EOF > 'st/zzndir.h'
/* @(#)ndir.h	1.4	4/16/85 */
/* Modified for the atari st series 5/4/87 */
#ifndef DEV_BSIZE
#define	DEV_BSIZE	512
#endif
#define DIRBLKSIZ	DEV_BSIZE
#define	MAXNAMLEN	255

struct	direct {
	long	d_ino;			/* inode number of entry */
	short	d_reclen;		/* length of this record */ 
	short	d_namlen;		/* length of string in d_name */
	char	d_name[MAXNAMLEN + 1];	/* name must be no longer than this */
};

/*
 * The DIRSIZ macro gives the minimum record length which will hold
 * the directory entry.  This requires the amount of space in struct direct
 * without the d_name field, plus enough space for the name with a terminating
 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
 */

#ifdef DIRSIZ
#undef DIRSIZ
#endif
#define DIRSIZ(dp) \
    ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))

/*
 * Definitions for library routines operating on directories.
 */

/* Structure of a directory entry under GEMDOS */

typedef struct _dirdesc
  {
    char	Reserved[21];
    char	FileAttr;
    int		CreateTime;
    int		CreateDate;
    long	FileSize;
    char	FileName[14];
    char	FilePath[256];
  } DIR;

#ifndef NULL
#define NULL 0L
#endif

#ifndef DEF_NDIR
extern	DIR *opendir();
extern	struct direct *readdir();
extern	void closedir();
#endif

SHAR_EOF
fi # end of overwriting check
if test -f 'st/zztime.h'
then
       echo shar: will not over-write existing file "'st/zztime.h'"
else
cat << \SHAR_EOF > 'st/zztime.h'
/* time.h */

struct tm {
	int	tm_sec;		/* time of day, seconds */
	int	tm_min;		/* time of day, minutes */
	int	tm_hour;	/* time of day, hours (24 hour clock) */
	int	tm_mday;	/* day of month (1-31) */
	int	tm_mon;		/* month of year (0-11) */
	int	tm_year;	/* year - 1900 */
	int	tm_wday;	/* day of week (Sunday = 0) */
	int	tm_yday;	/* day of year (0-365) */
	int	tm_isdst;	/* non-0 if DST in effect */
};
extern struct tm *localtime();
extern char *ctime();

SHAR_EOF
fi # end of overwriting check
if test -f 'st/zuuhost.c'
then
       echo shar: will not over-write existing file "'st/zuuhost.c'"
else
cat << \SHAR_EOF > 'st/zuuhost.c'
/*		uuhost.c

*/
#define	MAIN	dcpmain
#define CWDSPOOL
#include	"local\host.c"


SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0

--
{ubc-vision,uunet}!van-bc!sl				Stuart.Lynne@van-bc.uucp