Path: utzoo!mnetor!uunet!husc6!uwvax!rutgers!iuvax!pur-ee!j.cc.purdue.edu!ain From: ain@j.cc.purdue.edu (Patrick White) Newsgroups: comp.sources.amiga Subject: uupc version 1.1 (part 3 of 3) Message-ID: <6745@j.cc.purdue.edu> Date: 22 Mar 88 04:19:13 GMT Organization: PUCC Land, USA Lines: 1736 Keywords: part 3 of 3, 1.1, uupc, uncompiled Approved: ain@j.cc.purdue.edu (Pat White) Program Name: uupc version 1.1 (part 3 of 3) Submitted By: Johan Widen Summary: Implements uucp for the Amiga -- allows your Amiga to become a uupc site for mail (and news?). Poster Boy: Pat White (ain@j.cc.purdue.edu) Uncompiled. NOTES: Converted the origional zoo to shars so docs, binaries & sources could be separated. I'm pretty sure this would allow one to receive news, but I remember something in the docs about it not having been tested from when I was quickly scanning them... so I'm not too sure on this. Rob has been playing with it for a while and says it works. -- Pat White (co-moderator comp.sources/binaries.amiga) UUCP: j.cc.purdue.edu!ain BITNET: PATWHITE@PURCCVM PHONE: (317) 743-8421 U.S. Mail: 320 Brown St. apt. 406, West Lafayette, IN 47906 ======================================== # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # raw.c # rmail.c # sendpacket.c # serial.c # sio.c # sleep.c # timer.c # ulib.c # uuhost.c # This archive created: Sat Mar 19 01:42:21 1988 # By: Patrick White (PUCC Land, USA) echo shar: extracting raw.c '(2393 characters)' cat << \SHAR_EOF > raw.c /* * raw.c * * This is a routine for setting a given stream to raw or cooked mode. * This is useful when you are using Lattice C to produce programs that * want to read single characters with the "getch()" or "fgetc" call. * * Written : 18-Jun-87 By Chuck McManis. * If you use it I would appreciate credit for it somewhere. */ #include #include #include #include #include #include #include #include #include #include /* New Packet in 1.2 */ /* #define ACTION_SCREEN_MODE 994L */ extern int errno; /* The error variable */ /* * Function raw() - Convert the specified file pointer to 'raw' mode. This * only works on TTY's and essentially keeps DOS from translating keys for * you, also (BIG WIN) it means getch() will return immediately rather than * wait for a return. You lose editing features though. */ long raw(fp) FILE *fp; { struct MsgPort *mp; /* The File Handle message port */ struct FileHandle *afh; struct UFB *ufb; long Arg[1],res; ufb = (struct UFB *) chkufb(fileno(fp)); /* Step one, get the file handle */ afh = (struct FileHandle *)(ufb->ufbfh); if (!IsInteractive(afh)) { /* Step two, check to see if it's a console */ errno = ENOTTY; return(-1); } /* Step three, get it's message port. */ mp = ((struct FileHandle *)(BADDR(afh)))->fh_Type; Arg[0] = -1L; res = SendPacket(mp,ACTION_SCREEN_MODE,Arg,1); /* Put it in RAW: mode */ if (res == 0) { errno = ENXIO; return(-1); } return(0); } /* * Function - cooked() this function returns the designate file pointer to * it's normal, wait for a mode. This is exactly like raw() except that * it sends a 0 to the console to make it back into a CON: from a RAW: */ long cooked(fp) FILE *fp; { struct MsgPort *mp; /* The File Handle message port */ struct FileHandle *afh; struct UFB *ufb; long Arg[1],res; ufb = (struct UFB *) chkufb(fileno(fp)); afh = (struct FileHandle *)(ufb->ufbfh); if ( ! IsInteractive(afh)) { errno = ENOTTY; return(-1); } mp = ((struct FileHandle *)(BADDR(afh)))->fh_Type; Arg[0] = 0; res = SendPacket(mp,ACTION_SCREEN_MODE,Arg,1); if (res == 0) { errno = ENXIO; return(-1); } return(0); } SHAR_EOF if test 2393 -ne "`wc -c raw.c`" then echo shar: error transmitting raw.c '(should have been 2393 characters)' fi echo shar: extracting rmail.c '(8785 characters)' cat << \SHAR_EOF > rmail.c /* rmail.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 pcmail pcmail address1 address2 ... < the.message description An 822 compatible (hopefully) mail delivery system for pc's. Designed for delivering mail on a pc based system. It will put local mail (ie, not @ or ! in address) into files in the default mail directory. If remote it will put into an outgoing mailbag in the default mail directory. Performs a simple bundling of mail messages into one file with arguments prepended as To: arg header lines. pcmail john jack jill@xyz.uucp < afile To: john, jack, jill@xyz.uucp ... ... ... It also adds the from From and Date lines. Subject: lines may be inserted by placing them at the beginning of the message. A Unix version should lock the /usr/mail/mailbag file. environment variables The following evironment variables are used: MAILBOX current user's mailbox, "stuart" NAME current user's name, "Stuart Lynne" DOMAIN domain of this machine, "slynne.mac.van-bc.can" MAILDIR where is mail kept, "mpw:mail" */ #include #include #include "host.h" char *_TZ = "GMT0"; FILE *FOPEN(); #define FORWARD "Forward to" static FILE *mailfile; static FILE *tempfile; static char buf[BUFSIZ]; static char miscbuff[100]; static char *inFileName; static long int sequence = 0; static long tloc; static char chartime[40]; /* current time in characters */ static char *thetime; static char tfilename[100]; extern char mfilename[]; static char mailsent[100]; static char remotes[BUFSIZ]; static char *uucp = "uucp"; char *fgets(); int fputs(); extern int debuglevel; extern long DOSBase; static char *mcurdir; static char s_mcurdir[128]; /* current directory path (save malloc call) */ char * getcwd(); int chdir(); rmail(argc, argv, inname) int argc; char *inname; char **argv; { register int argcount; register char **argvec; char timeBuf[40]; if (debuglevel > 5) { fprintf(stderr,"pcmail: argc %d ", argc); argcount = argc; argvec = argv; while (argcount--) fprintf(stderr," \"%s\"", *argvec++); fprintf(stderr,"\n"); time(&tloc); thetime = ctime(&tloc); sprintf(timeBuf,"%.3s, %.2s %.3s %.2s %.8s %s\n", thetime, thetime + 8, thetime + 4, thetime + 22, thetime + 11, timeZone); thetime = timeBuf; fprintf(stderr,"thetime: %s",thetime); } mcurdir = getcwd(s_mcurdir, sizeof(s_mcurdir)); chdir(spooldir); /* get sequence number */ mkfilename(tfilename, confdir, SFILENAME); if (debuglevel > 4) fprintf(stderr,"pcmail: opening %s\n", tfilename); /* */ if(tempfile = FOPEN(tfilename,"r", 't')) { fscanf(tempfile,"%ld", &sequence); fclose(tempfile); } else fprintf(stderr,"pcmail: can't find %s file, creating\n", tfilename); /* update sequence number */ if (debuglevel > 5) fprintf(stderr,"pcmail: new sequence # %ld\n", sequence); if(tempfile = FOPEN(tfilename,"w", 't')) { fprintf(tempfile,"%ld\n", (sequence+1)%10000); fclose(tempfile); } inFileName = inname; /* loop on args, copying to appropriate postbox, do remote only once remote checking is done empirically, could be better */ remotes[0] = '\0'; argcount = argc; argvec = argv; while (--argcount > 0) { argvec++; if (debuglevel > 5) fprintf(stderr,"pcmail: arg# %d %s\n", argcount, *argvec); if (strchr(*argvec, '!') || strchr(*argvec, '@') || strchr(*argvec, '%')) { if (debuglevel > 5) fprintf(stderr,"pcmail: send to remote\n"); /* can we cram one more address on line */ if((strlen(remotes) + strlen(*argvec) + 3) > sizeof(remotes)) { /* dump it then, to bad */ sendone(argc, argv, remotes, TRUE); remotes[0] = '\0'; } /* add *arvgvec to list of remotes */ strcat(remotes," "); strcat(remotes, *argvec); } else { if (debuglevel > 5) fprintf(stderr,"pcmail: calling sendone %s\n", *argvec); sendone(argc, argv, *argvec, FALSE); } } /* dump remotes if necessary */ if (remotes[0]) sendone(argc, argv, remotes, TRUE); chdir(mcurdir); return(0); } /* sendone copies file plus headers to appropriate postbox NB. we do headers here to allow flexibility later, for example in being able to do bcc, per host service processing etc. */ sendone(argc, argv, address, remote) int argc; char **argv; char *address; int remote; { register char *cp; char icfilename[32]; /* local C. copy file */ char ixfilename[32]; /* local X. xqt file */ char idfilename[32]; /* local D. data file */ char rxfilename[32]; /* remote X. xqt file */ char rdfilename[32]; /* remote D. data file */ char tmfilename[32]; /* temporary storage */ struct FILEINFO info; if (remote) { /* sprintf all required file names */ sprintf(tmfilename,"%c.%.7s%04d", 'C', mailserv, sequence); importpath(icfilename, tmfilename); sprintf(tmfilename,"%c.%.7s%04d", 'D', mailserv, sequence); importpath(idfilename, tmfilename); sprintf(tmfilename,"%c.%.7s%04d", 'D', nodename, sequence); importpath(ixfilename, tmfilename); sprintf(rdfilename,"%c.%.7s%04d", 'D', nodename, sequence); sprintf(rxfilename,"%c.%.7s%04d", 'X', nodename, sequence); } else { /* postbox file name */ if (!strchr(address, SEPCHAR)) mkfilename(idfilename, maildir, address); else strcpy(idfilename, address); } if (debuglevel > 5) fprintf(stderr,"pcmail: sendone: %s\n", idfilename); if (remote == FALSE) { if (debuglevel > 5) fprintf(stderr,"pcmail: sendone: check for remote\n"); /* check for forwarding */ if (!dfindOne(&info, idfilename, 0) && info.fib_Size > 10 && (mailfile = FOPEN(idfilename,"r", 'b'))) { cp = fgets(buf, sizeof(buf), mailfile); fclose(mailfile); if (cp && !strncmp(buf, FORWARD, 10)) { strcpy(buf, buf+11); return(sendone(argc, argv, buf, FALSE)); } } } /* open mailfile */ if (!(mailfile = FOPEN(idfilename,"a", 'b'))) { fprintf(stdout,"pcmail: cannot append to %s\n", idfilename); return(0); } if (debuglevel > 5) fprintf(stderr,"pcmail: append to mailfile\n"); time(&tloc); thetime = ctime(&tloc); sprintf(chartime,"%.3s, %.2s %.3s %.2s %.8s %s", thetime, thetime + 8, thetime + 4, thetime + 22, thetime + 11, timeZone); thetime = chartime; /* and work with our own copy */ fprintf(mailfile,"From uucp %s\n", thetime); fprintf(mailfile,"Received: by %s (pcmail) %s\n", domain, thetime); /* copy spoolfile to postbox file */ if (debuglevel > 4) fprintf(stderr,"pcmail: copy spoolfile %s to %s\n", inFileName, idfilename); if (!(tempfile = FOPEN(inFileName,"r", 'b'))) { fprintf(stdout,"pcmail: can't open %s\n", inFileName); return(0); } buf[sizeof(buf) - 2] = '\n'; buf[sizeof(buf) - 1] = 0; while (fgets(buf, sizeof(buf) - 2, tempfile)) { if (strncmp(buf,"From ", 5) == 0) fputc('>', mailfile); if(buf[0]) fputs(buf, mailfile); } /* close files */ fclose(mailfile); fclose(tempfile); /* all done unless going to remote via uucp */ /* must create the job control files */ if (remote) { /* create remote X xqt file */ if(!(mailfile = FOPEN(ixfilename,"w", 'b'))) { fprintf(stdout,"pcmail: cannot open %s\n", ixfilename); return(0); } fprintf(mailfile,"U %s %s\n", uucp, nodename); fprintf(mailfile,"F %s\n", rdfilename); fprintf(mailfile,"I %s\n", rdfilename); fprintf(mailfile,"C rmail %s\n", address); fclose(mailfile); /* create local C copy file */ if(!(mailfile = FOPEN(icfilename,"w", 't'))) { fprintf(stdout,"pcmail: cannot open %s\n", icfilename); return(0); } fprintf(mailfile,"S %s %s %s - %s 0666 %s\n", idfilename, rdfilename, uucp, idfilename, uucp); fprintf(mailfile,"S %s %s %s - %s 0666 %s\n", ixfilename, rxfilename, uucp, ixfilename, uucp); fclose(mailfile); } return(1); } #ifndef AMIGA #ifdef RMAIL rnews(argc, argv) int argc; char *argv[]; { struct tm *thetm; char filename[132]; char format[128]; FILE *f; char buf[BUFSIZ]; static int count = 0; tloc = time((long *)NULL); thetime = ctime(&tloc); tloc = time((long *)NULL); thetm = localtime(&tloc); /* mkfilename(format, spooldir, NEWSDIR); */ sprintf(filename, NEWSDIR, thetm->tm_year % 100, thetm->tm_mon, thetm->tm_mday, thetm->tm_hour, thetm->tm_min, thetm->tm_sec, count ); count++; if (debuglevel > 5) fprintf(stderr,"rnews: %s\n", filename); if ((f = FOPEN(filename,"w", 't')) == (FILE *)NULL) { fprintf(stderr,"rnews: can't open %s %d\n", filename, errno); return(-1); } while (fgets(buf, BUFSIZ, stdin) != (char *)NULL) fputs(buf, f); fclose(f); } #endif /* RMAIL */ #endif /* AMIGA */ SHAR_EOF if test 8785 -ne "`wc -c rmail.c`" then echo shar: error transmitting rmail.c '(should have been 8785 characters)' fi echo shar: extracting sendpacket.c '(2082 characters)' cat << \SHAR_EOF > sendpacket.c /* * Sendpacket.c * * An invaluable addition to your Amiga.lib file. This code sends a packet * the given message port. This makes working around DOS lots easier. * * Note, I didn't write this, those wonderful folks at CBM did. I do suggest * however that you may wish to add it to Amiga.Lib, to do so, compile it * and say 'oml lib:amiga.lib -r sendpacket.o' */ #include #include #include #include #include #include #include /* * Function - SendPacket written by Phil Lindsay, Carolyn Scheppner, and * Andy Finkel. This function will send a packet of the given type to the * Message Port supplied. */ long SendPacket(pid,action,args,nargs) struct MsgPort *pid; /* process indentifier ... (handlers message port ) */ long action, /* packet type ... (what you want handler to do ) */ args[], /* a pointer to a argument list */ nargs; /* number of arguments in list */ { struct MsgPort *replyport; struct StandardPacket *packet; long count, *pargs, res1; replyport = (struct MsgPort *) CreatePort(NULL,0); if(!replyport) return(0); /* Allocate space for a packet, make it public and clear it */ packet = (struct StandardPacket *) AllocMem((long)sizeof(struct StandardPacket),MEMF_PUBLIC|MEMF_CLEAR); if(!packet) { DeletePort(replyport); return(0); } packet->sp_Msg.mn_Node.ln_Name = (char *)&(packet->sp_Pkt); packet->sp_Pkt.dp_Link = &(packet->sp_Msg); packet->sp_Pkt.dp_Port = replyport; packet->sp_Pkt.dp_Type = action; /* copy the args into the packet */ pargs = &(packet->sp_Pkt.dp_Arg1); /* address of first argument */ for(count=0;count < nargs;count++) pargs[count]=args[count]; PutMsg(pid,packet); /* send packet */ WaitPort(replyport); GetMsg(replyport); res1 = packet->sp_Pkt.dp_Res1; FreeMem(packet,(long)sizeof(struct StandardPacket)); DeletePort(replyport); return(res1); } SHAR_EOF if test 2082 -ne "`wc -c sendpacket.c`" then echo shar: error transmitting sendpacket.c '(should have been 2082 characters)' fi echo shar: extracting serial.c '(7910 characters)' cat << \SHAR_EOF > serial.c #include #include #include #include #include #include #include #include #ifndef MANX #include #endif #include struct IOExtSer *IORreadser = NULL, *IORwriteser = NULL; struct MsgPort *serialreadport = NULL, *serialwriteport = NULL; extern struct MsgPort *CreatePort(); extern struct IORequest *CreateExtIO(); static int close_flag = 0; #define SERDATR ((USHORT *) 0xdff018) #define TBE (1 << 13) #define SERDAT ((USHORT *) 0xdff030) static UBYTE parity = 2, stopbits = 0; static UBYTE speed = 2, xonxoff = 0; static ULONG speedtab[] = {9600,4800,2400,1200,1200,300}; static UBYTE paritytab[] = {2,1,0}; static UBYTE stopbitstab[] = {1, 2}; initserial() { int error; /* SET UP the message port in the I/O request */ serialreadport = CreatePort ("Serial Read",0); serialwriteport = CreatePort ("Serial Write",0); if (serialreadport == NULL || serialwriteport == NULL) { sercleanup(); printf("\nProblems during CreatePort"); exit(100); } /* Create the request blocks for passing info to and from the serial device. */ IORreadser = (struct IOExtSer *) CreateExtIO(serialreadport,sizeof(struct IOExtSer)); IORwriteser = (struct IOExtSer *) CreateExtIO(serialwriteport,sizeof(struct IOExtSer)); if (IORreadser == NULL || IORwriteser == NULL) { sercleanup(); printf("\nProblems during CreateExtIO"); exit(101); } /* OPEN the serial.device */ if ((error = OpenDevice (SERIALNAME, 0, IORreadser, 0)) != 0) { sercleanup(); printf ("Serial device did not open 1, error = %ld\n",error); exit(102); } close_flag = TRUE; dosetparams(); *IORwriteser = *IORreadser; IORwriteser->IOSer.io_Message.mn_ReplyPort = serialwriteport; } sercleanup() { if(close_flag) { CloseDevice (IORreadser); close_flag = 0; } if(serialreadport) { DeletePort (serialreadport); serialreadport = NULL; } if(serialwriteport) { DeletePort (serialwriteport); serialwriteport = NULL; } if(IORreadser) { DeleteExtIO(IORreadser,sizeof(struct IOExtSer)); IORreadser = NULL; } if(IORwriteser) { DeleteExtIO(IORwriteser,sizeof(struct IOExtSer)); IORwriteser = NULL; } } setspeed(menusel) int menusel; { speed = menusel; } dosetparams() { ULONG rbl; ULONG brk; ULONG baud; UBYTE rwl; UBYTE wwl; UBYTE sf; ULONG t0; ULONG t1; /* SET PARAMS for the serial.device */ rbl = 4096; if(paritytab[parity]) { rwl = 0x07; wwl = 0x07; } else { rwl = 0x08; wwl = 0x08; } brk = 750000; baud = speedtab[speed]; sf = 0; if(!xonxoff) { sf = SERF_XDISABLED; } if(paritytab[parity] == 1) { sf |= SERF_PARTY_ON | SERF_PARTY_ODD; } else if(paritytab[parity] == 2) { sf |= SERF_PARTY_ON; } t0 = 0x51040303; t1 = 0x03030303; SetParams(IORreadser,rbl,rwl,wwl,stopbitstab[stopbits], brk,baud,sf,t0,t1); } /* SERIAL I/O functions */ SetParams(io,rbuf_len,rlen,wlen,stopbits,brk,baud,sf,ta0,ta1) struct IOExtSer *io; ULONG rbuf_len; UBYTE rlen; UBYTE wlen; UBYTE stopbits; ULONG brk; ULONG baud; UBYTE sf; ULONG ta0; ULONG ta1; { int error; io->io_ReadLen = rlen; io->io_BrkTime = brk; io->io_Baud = baud; io->io_WriteLen = wlen; io->io_StopBits = stopbits; io->io_RBufLen = rbuf_len; io->io_SerFlags = sf; io->IOSer.io_Command = SDCMD_SETPARAMS; io->io_TermArray.TermArray0 = ta0; io->io_TermArray.TermArray1 = ta1; if ((error = DoIO (io)) != 0) { printf ("serial.device setparams error %ld \n", error); } return (error); } ReadSer(data,length) UBYTE *data; int length; { IORreadser->IOSer.io_Data = (APTR)data; IORreadser->IOSer.io_Length = (ULONG)length; IORreadser->IOSer.io_Command = CMD_READ; SendIO(IORreadser); } kill_ReadSer() { AbortIO(IORreadser); while(GetMsg(serialreadport)); } readserresult(errno,length) int *errno, *length; { *errno = IORreadser->IOSer.io_Error; *length = IORreadser->IOSer.io_Actual; } WriteSer(data,length) UBYTE *data; int length; { IORwriteser->IOSer.io_Data = (APTR)data; IORwriteser->IOSer.io_Length = length; IORwriteser->IOSer.io_Command = CMD_WRITE; SendIO(IORwriteser); } writeserresult(errno) int *errno; { *errno = IORwriteser->IOSer.io_Error; } SendWaitWrite(data,length) UBYTE *data; int length; { int error; IORwriteser->IOSer.io_Data = (APTR)data; IORwriteser->IOSer.io_Length = length; IORwriteser->IOSer.io_Command = CMD_WRITE; if((error = DoIO(IORwriteser)) != 0) { fprintf (stderr,"serial.device write error %ld \n", error); } return ((int)IORwriteser->IOSer.io_Actual); } /* send a break to the host */ void breakSer(readActive) int readActive; { if(readActive) AbortIO(IORreadser); IORreadser->IOSer.io_Command = SDCMD_BREAK; DoIO(IORreadser); if(readActive) { IORreadser->IOSer.io_Command = CMD_READ; SendIO(IORreadser); } } #ifdef notdef /*********************************************************************** * * Exec Support Function -- Extended IO Request * ***********************************************************************/ #include #include #include #include #include #include #include #include #include #include extern APTR AllocMem(); /****** exec_support/CreateExtIO ************************************** * * NAME * CreateExtIO() -- create an Extended IO request * * SYNOPSIS * ioReq = CreateExtIO(ioReplyPort,size); * * FUNCTION * Allocates memory for and initializes a new IO request block * of a user-specified number of bytes. * * INPUTS * ioReplyPort - a pointer to an already initialized * message port to be used for this IO request's reply port. * * RESULT * Returns a pointer to the new block. Pointer is of the type * struct IORequest. * * 0 indicates inability to allocate enough memory for the request block * or not enough signals available. * * EXAMPLE * struct IORequest *myBlock; * if( (myBlock = CreateExtIO(myPort,sizeof(struct IOExtTD)) == NULL) * exit(NO_MEM_OR_SIGNALS); * * example used to allocate space for IOExtTD (trackdisk driver * IO Request block for extended IO operations). * * SEE ALSO * DeleteExtIO * ***********************************************************************/ struct IORequest *CreateExtIO(ioReplyPort,size) struct MsgPort *ioReplyPort; LONG size; { struct IORequest *ioReq; if (ioReplyPort == 0) return ((struct IORequest *) 0); ioReq = (struct IORequest *)AllocMem (size, MEMF_CLEAR | MEMF_PUBLIC); if (ioReq == 0) return ((struct IORequest *) 0); ioReq -> io_Message.mn_Node.ln_Type = NT_MESSAGE; ioReq -> io_Message.mn_Node.ln_Pri = 0; ioReq -> io_Message.mn_ReplyPort = ioReplyPort; return (ioReq); } /****** exec_support/DeleteExtIO ************************************** * * NAME * DeleteExtIO() - return memory allocated for extended IO request * * SYNOPSIS * DeleteExtIO(ioReq,size); * * FUNCTION * See summary line at NAME. Also frees the signal bit which * had been allocated by the call to CreateExtIO. * * INPUTS * A pointer to the IORequest block whose resources are to be freed. * * RESULT * Frees the memory. Returns (no error conditions shown) * * EXAMPLE * struct IORequest *myBlock; * DeleteExtIO(myBlock,(sizeof(struct IOExtTD))); * * example shows that CreateExtIO had been used to create a trackdisk * (extended) IO Request block. * * SEE ALSO * CreateExtIO * **************************************************************************/ DeleteExtIO(ioExt,size) struct IORequest *ioExt; LONG size; { ioExt -> io_Message.mn_Node.ln_Type = 0xff; ioExt -> io_Device = (struct Device *) -1; ioExt -> io_Unit = (struct Unit *) -1; FreeMem (ioExt, size); } #endif SHAR_EOF if test 7910 -ne "`wc -c serial.c`" then echo shar: error transmitting serial.c '(should have been 7910 characters)' fi echo shar: extracting sio.c '(4904 characters)' cat << \SHAR_EOF > sio.c /*------------------------------------------------------------------*/ /* Sio.c: Serial I/O for Amiga Version of PCMail */ /* Created: 27Jun87 by J.A. Lydiatt */ /* */ /* Exports the following routines required by PCMail: */ /* SIOInit(): Initialize Serial Port */ /* SIOClose(): Close and free Serial Port resources */ /* SIOSpeed(): Set bps */ /* SIORead(): read characters from serial port */ /* SIOWrite(): write characters to serial port */ /* SIOInBuffer(): Set Buffer size for read & writes. */ /* SIOOutBuffer(): (Has no effect in Amiga Version) */ /*------------------------------------------------------------------*/ #include #include #include #ifndef TRUE #define TRUE -1 #define FALSE 0 #endif /*--- SerialIO Function Declarations --- */ extern void initserial(); extern void sercleanup(); /* Return SerialIO resources */ extern void setspeed(); /* Set baud rate */ extern void dosetparams(); /* Set serial parameters */ /*--------------------------------------------------------------*/ /* getspeed/getbaud: check for valid baud parameters */ /*--------------------------------------------------------------*/ static struct { unsigned baudr; int speedcode; } speeds[] = { 300, 5, 1200, 3, 2400, 2, 4800, 1, 9600, 0, 0, }; static unsigned getspeed(code) { register n; for (n=0; speeds[n].baudr; ++n) if (speeds[n].speedcode == code) return speeds[n].baudr; return 0; } static int getbaud(code) char *code; { register n; register int Baudrate; Baudrate = atoi(code); for (n=0; speeds[n].baudr; ++n) if (speeds[n].baudr == Baudrate) return speeds[n].speedcode; return -1; } /*--------------------------------------------------------------*/ /* SIOInit: initialize serial I/O */ /*--------------------------------------------------------------*/ SIOInit ( whichport, speed ) char * whichport; char * speed; { int baud; /* fprintf( stderr, "sioinit %s %s\n", whichport, speed ); /* */ initserial(); if ( (baud = getbaud( speed )) >= 0 ) setspeed( baud ); if ( !OpenTimer() ) { fprintf( stderr, "Can't open the Timer Device\n" ); sercleanup(); return( -1 ); } dosetparams(); return( 0 ); } /*--------------------------------------------------------------*/ /* SIOSpeed: set the serial Baud rate */ /*--------------------------------------------------------------*/ SIOSpeed( speed ) char *speed; { int baud; if ( (baud = getbaud( speed )) >= 0 ) { setspeed( baud ); dosetparams(); } } /*--------------------------------------------------------------*/ /* SIOInBuffer/ SIOOutBuffer: Set Buffer Size. */ /*--------------------------------------------------------------*/ SIOInBuffer ( buf, size ) char * buf; int size; { } SIOOutBuffer ( buf, size ) char * buf; int size; { } /*--------------------------------------------------------------*/ /* SIOClose: Close Serial port. */ /*--------------------------------------------------------------*/ SIOClose ( dtr ) { sercleanup(); CloseTimer(); } /*--------------------------------------------------------------*/ /* SIOWrite: send count characters to serial port */ /*--------------------------------------------------------------*/ SIOWrite ( buf, count ) register char * buf; int count; { SendWaitWrite(buf, count); return count; } /*--------------------------------------------------------------*/ /* SIORead: read mincount <= #characters <= maxcount */ /* return # of characters read, or -1 if timed out after */ /* after tenths / 10 seconds. */ /*--------------------------------------------------------------*/ static int readOutstanding = 0; int SIORead ( buf, mincount, maxcount, tenths ) char *buf; int mincount; int maxcount; int tenths; /* timeout is in tenth's of seconds */ { ULONG signals; extern struct MsgPort *serialreadport, *timerPort; static char inBuf[512]; static int inBufPos = 0; int count, errorNumber; if(tenths < 10) tenths = 10; StartTimer(tenths/10L, 0); while(1) { if((inBufPos >= mincount) && !readOutstanding) { movmem(inBuf,buf,mincount); inBufPos -= mincount; if(inBufPos) movmem(inBuf + mincount, inBuf, inBufPos); return(mincount); } if(!readOutstanding) { ReadSer(inBuf + inBufPos, mincount - inBufPos); readOutstanding = 1; } signals = Wait((1 << timerPort->mp_SigBit) | (1 << serialreadport->mp_SigBit)); if(signals & (1 << timerPort->mp_SigBit)) { if(TimerExpired()) { return(-1); } else { getTimerMsg(); } } if(signals & (1 << serialreadport->mp_SigBit)) { readserresult(&errorNumber, &count); GetMsg(serialreadport); readOutstanding = 0; if(errorNumber) { inBufPos = 0; return(-1); } inBufPos += count; } } } void ssendbrk() { breakSer(readOutstanding); } SHAR_EOF if test 4904 -ne "`wc -c sio.c`" then echo shar: error transmitting sio.c '(should have been 4904 characters)' fi echo shar: extracting sleep.c '(287 characters)' cat << \SHAR_EOF > sleep.c /*--------------------------------------------------------------*/ /* sleep.c: Implement sleep( seconds ) on the Amiga. */ /*--------------------------------------------------------------*/ void sleep( seconds ) unsigned int seconds; { if ( seconds > 0 ) Delay( seconds*50L ); } SHAR_EOF if test 287 -ne "`wc -c sleep.c`" then echo shar: error transmitting sleep.c '(should have been 287 characters)' fi echo shar: extracting timer.c '(3078 characters)' cat << \SHAR_EOF > timer.c /* * Timer.c: Functions to invoke the Amiga timer: * * External Functions: * * OpenTimer, CloseTimer, StartTimer, TimerExpired, GetTimerSigBit * * Maintenance Notes: * 05Jul86 - Created by Jeff Lydiatt, Vancouver, Canada. */ #include #include #include #include #include #include #include #ifdef MANX #include #else #include #include #endif static struct timerequest TimerIO; struct MsgPort *timerPort = NULL; static BOOL timerON; static BOOL timerExpired; /*-------------------------------------------------------------*/ /* OpenTimer: return TRUE if timer opened OK */ /*-------------------------------------------------------------*/ BOOL OpenTimer() { register struct timerequest *t = &TimerIO; register struct MsgPort *port; timerON = FALSE; timerExpired = TRUE; if ( timerPort != NULL ) return TRUE; if ( (port = CreatePort("Timer Port", 0L)) == NULL ) return FALSE; else timerPort = port; setmem(&TimerIO, sizeof(TimerIO), 0); if (OpenDevice(TIMERNAME, UNIT_VBLANK, t, 0L) != 0) { DeletePort( port ); timerPort = NULL; return FALSE; } return TRUE; } /*-------------------------------------------------------------*/ /* CloseTimer: All Done with the timer. */ /*-------------------------------------------------------------*/ void CloseTimer() { register struct timerequest *t = &TimerIO; if (!timerPort) return; if ( timerON ) AbortIO( t ); CloseDevice( t ); DeletePort( timerPort ); timerPort = NULL; } /*-------------------------------------------------------------*/ /* GetTimerSigBit: return Timer signal bit */ /*-------------------------------------------------------------*/ int GetTimerSigBit() { return timerPort->mp_SigBit; } /*-------------------------------------------------------------*/ /* StartTimer: launch the timer. */ /*-------------------------------------------------------------*/ void StartTimer(seconds, micros) ULONG seconds, micros; { register struct timerequest *t = &TimerIO; if ( timerON ) { AbortIO( t ); while(GetMsg( timerPort )); timerON = FALSE; timerExpired = TRUE; } t->tr_time.tv_secs = seconds; t->tr_time.tv_micro = micros; t->tr_node.io_Command = TR_ADDREQUEST; /* t->tr_node.io_Flags = IOF_QUICK; t->tr_node.io_Error = 0; */ t->tr_node.io_Message.mn_ReplyPort = timerPort; SendIO( t ); timerExpired = FALSE; timerON = TRUE; } /*-------------------------------------------------------------*/ /* TimerExpired: returns TRUE if timer expired. */ /*-------------------------------------------------------------*/ BOOL TimerExpired() { if ( timerON && ( CheckIO( &TimerIO ) == NULL) ) return FALSE; while(GetMsg( timerPort )); timerExpired = TRUE; timerON = FALSE; return timerExpired; } getTimerMsg() { GetMsg( timerPort ); } SHAR_EOF if test 3078 -ne "`wc -c timer.c`" then echo shar: error transmitting timer.c '(should have been 3078 characters)' fi echo shar: extracting ulib.c '(5372 characters)' cat << \SHAR_EOF > ulib.c /* ulib.c Amiga library Things to do in uu host serial I/O directory stuff opendir, readdir, closedir prolog and epilog system call */ #include #include "host.h" #ifdef MANX #include #endif int lineIsOpen = 0; /**/ /* * * login (for slave in PC mode) * Real dumb login handshake */ login() { char logmsg[132]; #ifdef PC lretry: msgtime = 9999; rmsg(logmsg, 0); /* wait for a or */ 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; #endif return('I'); } char inbuf[BUFSIZ]; char outbuf[BUFSIZ]; swrite(data, num) int num; char *data; { int test; unsigned char * cp; if (debuglevel > 14) fputc( '{', stderr ); if (debuglevel > 14) { test = num; cp = data; while (test--) fprintf( stderr, isprint(*cp)? "{%c}":"{%02x}", *cp++ ); } test = SIOWrite( data, num ); if (debuglevel > 14) fputc( '}', stderr ); return( test ); } /* non-blocking read essential to "g" protocol */ /* see "dcpgpkt.c" for description */ /* This all changes in a mtask systems. Requests for */ /* I/O should get qued and an event flag given. Then the */ /* requesting process (e.g.gmachine()) waits for the event */ /* flag to fire processing either a read or a write. */ /* Could be implemented on VAX/VMS or DG but not MS-DOS */ sread(buf, num, timeout) char *buf; int num, timeout; { /* return( SIORead( buf, num, num, timeout*10 ) ); */ int count; int test; unsigned char * cp; if (debuglevel > 13) fputc( '[', stderr ); printmsg( 15, "sread: num: %d timeout: %d", num, timeout ); count = SIORead( buf, num, num, timeout*10 ); 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 ); } openline(name, baud) char *name, *baud; { printmsg( 3, "openline: name: \"%s\" baud: \"%s\"", name, baud ); lineIsOpen = 1; if ( SIOInit( name, baud ) ) return -1; SIOInBuffer( inbuf, BUFSIZ ); SIOOutBuffer( outbuf, BUFSIZ ); return( 0 ); } closeline() { if(lineIsOpen) { SIOClose( 1 ); lineIsOpen = 0; } } nodot(string) { } notimp( argc, argv ) char *argv[]; { /*debuglevelMsg("\Pcheck argc (08) and argv (0a) ");*/ fprintf( stderr, "shell: %s not implemented\n", *argv ); } /*------------------------------------------------------------------*/ /* RNews: my private rnews! */ /*------------------------------------------------------------------*/ static void RNews( inname ) char *inname; { extern char *newsdir; register struct tm *thetm; long tloc; char filename[132]; FILE *f, *fin; FILE *FOPEN(); char buf[BUFSIZ]; int bytesRead; static int count = 0; int len; /* inname is of form "D.jlamiBCnnnn". Pick off the nnnn. */ len = strlen( inname ) - 1; while ( len >= 0 ) { if ( '0' <= inname[len] && inname[len] <= '9' ) --len; else break; } sprintf( filename, "%s/%s", newsdir, &inname[len+1] ); if ( (f = FOPEN( filename, "r", 't' )) != NULL ) { /* Already exists, so make a timestamped one. */ fclose( f ); tloc = time( (long *)NULL ); thetm = localtime( &tloc ); sprintf( filename, "%s/%02d%02d%02d%02d%02d%02d.%03d", newsdir, thetm->tm_year % 100, thetm->tm_mon, thetm->tm_mday, thetm->tm_hour, thetm->tm_min, thetm->tm_sec, count ); ++count; } if ( (f = FOPEN( filename, "w", 't' )) == (FILE *)NULL ) { fprintf( stderr, "rnews: can't open %s\n", filename ); onBreak(); } if ( (fin = FOPEN( inname, "r", 't' )) == NULL ) { fprintf( stderr, "rnews: Couldn't open %s\n", inname ); fclose( f ); onBreak(); } while(bytesRead = fread(buf, 1, BUFSIZ, fin)) { if(fwrite(buf, bytesRead, 1, f) != 1) { fprintf(stderr,"rnews: write error on %s\n", filename); fclose(f); onBreak(); } } fclose( f ); fclose( fin ); } /* if name is of the form user@domain or domain!user and domain is either */ /* DOMAIN or NODENAME then return user. Otherwise return name. */ /* Note: this function modifies it's argument. */ static char * getLocalName(name) char *name; { char *cp; if(cp = strchr(name, '@')) { if(!strcmp(cp + 1, domain) || !strcmp(cp + 1, nodename)) *cp = 0; } else if(cp = strchr(name, '!')) { *cp = 0; if(!strcmp(name, domain) || !strcmp(name, nodename)) return(cp + 1); *cp = '!'; } return(name); } /* shell */ char * getcwd(); shell( command, inname, outname, errname ) char * command; char * inname; char * outname; { char * argvec[50]; int rmail(); int rnews(); int argcp; char **argvp; char args; argcp = 0; argcp = getargs( command, argvec ); argvp = argvec; args = argcp; if ( debuglevel > 5 ) { while ( args ) fprintf( stderr, "arg: %d %s\n", args--, *argvp++ ); argvp = argvec; args = argcp; } /* */ if ( strcmp( *argvp, "rmail" ) == SAME ) { argvec[1] = getLocalName(argvec[1]); rmail( argcp, argvp, inname ); } else if ( strcmp( *argvp, "rnews" ) == SAME ) { /* proto = rnews; */ RNews( inname ); return; } else notimp( argcp, argvp ); } SHAR_EOF if test 5372 -ne "`wc -c ulib.c`" then echo shar: error transmitting ulib.c '(should have been 5372 characters)' fi echo shar: extracting uuhost.c '(1187 characters)' cat << \SHAR_EOF > uuhost.c /* uuhost.c */ #include #include #include "host.h" char *orgDir; char *getcwd(); int chdir(); int debuglevel = 0; /* debuginglevel */ jmp_buf dcpexit; main( argc, argv ) int argc; char *argv[]; { int returnCode = 0; char orgDirBuf[100]; /* Amiga specific prolog */ loadenv(); orgDir = getcwd( orgDirBuf, sizeof(orgDirBuf) ); chdir( spooldir ); /* setup longjmp for error exit's */ if ( setjmp( dcpexit ) == 0 ) { returnCode = dcpmain( argc, argv ); } /* Amiga specific epilog */ exitenv(); chdir( orgDir ); exit( returnCode ); } /* canonical name conversion routines importpath canonical -> host exportpath host -> canonical host your local pathname format canonical unix style */ importpath( host, canon ) char * host; char * canon; { extern char *pubdir; *host = '\0'; if ( *canon == '~' ) { if ( canon[1] == '/' ) strcpy( host, pubdir ); else { strcpy( host, home ); strcat( host, "/" ); } } strcat( host, canon ); if ( *host == '/' ) *host = ':'; } exportpath( canon, host ) char * host; char * canon; { strcpy( canon, host ); if ( *canon == ':' ) *canon = '/'; } SHAR_EOF if test 1187 -ne "`wc -c uuhost.c`" then echo shar: error transmitting uuhost.c '(should have been 1187 characters)' fi # End of shell archive exit 0