[comp.sys.amiga] uupc patch 1

jw@sics.se (Johan Widen) (03/25/88)

Here are a number of fixes to uupc. I recommend that you apply the patches
with the program
	patch

Improved support for operation in slave mode (uupc -r0, other machines
call your machine). The current support is still not sufficient but I'm
working on it.

Spool file names are now made unique. (AmigaDOS ignores case differences).

uupc will no longer quit if 200 line errors occur. (It will still quit if
it gets to many bad packets in a row, this is a feature).

Files in the spool directory are now processed in lexicographical order.

Security: a remote master may only access files in the spool directories.
    You can still send files from other directories.

mail would delete the SEQF file when a letter was forwarded. If a letter
was then deleted, mail would remove the .signature.

pccp did not handle device names correctly.

diff -c old/README.FIXES new/README.FIXES
*** old/README.FIXES	Thu Feb 25 10:47:20 1988
--- new/README.FIXES	Fri Mar 25 03:25:02 1988
***************
*** 170,172 ****
--- 170,185 ----
  Control messages longer than 63 bytes were not handled in master mode.
  This would cause uupc to hang if it encountered lines longer than 63 bytes
  in a C file.
+ 5-MAR-88
+ 
+ The X and C files are now processed in lexicographical order. The intention
+ is that the files should be processed in FIFO order.
+ 
+ Imported spool file names are now made unique: case is significant in UNIX
+ file names but not in AmigaDOS file names.
+ 6-MAR-88
+ 
+ Changed the ordering of letters in mailbox. The oldest letters are referred to
+ by smaller numbers.
+ 
+ The 'p' command now means "display previous letter".
diff -c old/dcp.c new/dcp.c
*** old/dcp.c	Wed Feb 24 12:15:12 1988
--- new/dcp.c	Sat Mar  5 21:03:26 1988
***************
*** 16,22 ****
   * This program implements a uucico type file transfer and remote
   * execution type protocol.
   */
! #define  VERSION "1.8 Camelot"
  #include "dcp.h"
  #include <signal.h>
  /**/
--- 16,22 ----
   * This program implements a uucico type file transfer and remote
   * execution type protocol.
   */
! #define  VERSION "1.10 Camelot"
  #include "dcp.h"
  #include <signal.h>
  /**/
***************
*** 177,186 ****
  				break;
  		}
  		fclose( fsys );
! 	} else
! 	 {
! 		if (openline( device, speed ) == -1)
! 			return(FALSE);
  		state = 'L';
  		while (TRUE) {
  			printmsg( 4, "Sstate = %c", state );
--- 177,183 ----
  				break;
  		}
  		fclose( fsys );
! 	} else {
  		state = 'L';
  		while (TRUE) {
  			printmsg( 4, "Sstate = %c", state );
***************
*** 196,207 ****
  				break;
  			case 'Y':
  				state = sysend();
  				break;
! 			}
! 			if (state == 'A')
  				break;
  		}
- 		closeline();
  	}
  
  	/* fprintf( stderr, "calling dcxqt\n" ); */
--- 193,207 ----
  				break;
  			case 'Y':
  				state = sysend();
+ 				dcxqt();
  				break;
! 			case 'A':
! 			default:
! 				closeline();
! 				state = 'L';
  				break;
+ 			}
  		}
  	}
  
  	/* fprintf( stderr, "calling dcxqt\n" ); */
***************
*** 459,468 ****
  			case 'U':
  				break;
  			case 'I':
! 				strcpy( input,   &line[2] );
  				break;
  			case 'O':
! 				strcpy( output,  &line[2] );
  				break;
  			case 'C':
  				strcpy( command, &line[2] );
--- 459,468 ----
  			case 'U':
  				break;
  			case 'I':
! 				makeUniqueFileName(&line[2], input);
  				break;
  			case 'O':
! 				makeUniqueFileName(&line[2], output);
  				break;
  			case 'C':
  				strcpy( command, &line[2] );
diff -c old/dcpgpkt.c new/dcpgpkt.c
*** old/dcpgpkt.c	Wed Feb 24 14:14:48 1988
--- new/dcpgpkt.c	Mon Feb 29 15:53:36 1988
***************
*** 26,32 ****
  #define HDRSIZE         6
  #define MAXTRY          4
  
- #define MAXERR  200		/* Dont want to quit in a middle of a long file*/
  #define MAXBADINAROW 5		/* Max bad reads in a row */
  #define TIMEOUT 4		/* could be longer */
  #define KPKT    1024/PKTSIZE
--- 26,31 ----
***************
*** 68,74 ****
  	timeout = 10; /* want some timeout capability here */
  	gspack(7, 0, 0, 0, tmp);
  rsrt:
! 	if (badInARow >= MAXBADINAROW || nerr >= MAXERR)
  		return(-1);
  	switch (grpack(&n1, &n2, &len, tmp)) {
  	case 7:
--- 67,73 ----
  	timeout = 10; /* want some timeout capability here */
  	gspack(7, 0, 0, 0, tmp);
  rsrt:
! 	if (badInARow >= MAXBADINAROW)
  		return(-1);
  	switch (grpack(&n1, &n2, &len, tmp)) {
  	case 7:
***************
*** 218,225 ****
  	/* waiting for ACKs for swl to swu-1. Next pkt to send=swu */
  	/* rwl=expected pkt */
  	printmsg( 7, "Kbytes transfered %d errors %d\r", npkt / KPKT, nerr );
- 	if (nerr >= MAXERR)
- 		goto close;
  	dflg = 0;
  	switch (grpack(&rack, &rseq, &rlen, rdata)) {
  	case CLOSE:
--- 217,222 ----
diff -c old/dcpsys.c new/dcpsys.c
*** old/dcpsys.c	Sun Feb 14 04:58:16 1988
--- new/dcpsys.c	Sat Mar  5 19:49:54 1988
***************
*** 147,153 ****
  	closeline();
  	if ( remote == MASTER )
  		return('I');
! 	return('A');
  }
  
  
--- 147,154 ----
  	closeline();
  	if ( remote == MASTER )
  		return('I');
! 	else
! 		return('L');
  }
  
  
***************
*** 226,231 ****
--- 227,246 ----
  		if (sread(cc, 1, msgtime) < 1)
  			return(-1);
  		c = cc[0] & 0x7f;
+ 		if(syn == 1) {	/* echo character */
+ 			if(c == '\b' || c == 127) {
+ 				if(ii > 0) {
+ 					swrite("\b \b", 3);
+ 					ii -= 2;
+ 				} else
+ 					ii--;
+ 				continue;
+ 			} else {
+ 				swrite(cc, 1);
+ 				if(c == '\r')
+ 					swrite("\n", 1);
+ 			}
+ 		}
  		if (c == '\r' || c == '\n')
  			c = '\0';
  		msg[ii] = c;
***************
*** 604,610 ****
  	return('P');
  }
  
- /**/
  /*
  **
  **      slowrite
--- 619,624 ----
***************
*** 624,633 ****
  }
  */
  
- /**/
  /*
  **
  **scandir
  **
  */
  
--- 638,647 ----
  }
  */
  
  /*
  **
  **scandir
+ ** The names are delivered in lexicographical order.
  **
  */
  
***************
*** 648,714 ****
  */
  scandir()
  {
! 	int	len;
! 	char	cname[40];
  
! 	DIR *dirp;
! 	struct direct *dp;
! 
! 	if ((dirp = opendir( spooldir )) == (DIR *)NULL ) {
! 		fprintf( stderr, "couldn't open dir %s\n", spooldir );
! 		return( 'A' );
! 	}
! 	sprintf(cname, CALLFILE, rmtname);
! 	len = strlen(cname);
! 	while ((dp = readdir(dirp)) != (struct direct *)NULL) {
! 		printmsg( 4, "scandir: %s", dp->d_name );
! 		if ( strncmp( cname, dp->d_name, len ) == SAME ) {
! 			printmsg( 4, "scandir: match!!" );
! 			strcpy(cfile, dp->d_name);
! 			closedir( dirp );
! 			if ((fw = FOPEN( cfile, "r", 't' )) == (char *)NULL )
! 				return('Y');
! 			return('S');
! 		}
! 	}
! 	closedir( dirp );
! 	return('Q');
! 
  }
  
  
- /**/
  /*
  **
  **dscandir
  ** scan the directory
  */
  
  dscandir()
  {
! 	int	len;
! 	char	cname[40];
  
! 	DIR *dirp;
! 	struct direct *dp;
! 
! 
! 	if ((dirp = opendir( spooldir )) == (DIR *)NULL ) {
! 		fprintf( stderr, "couldn't open dir %s\n", spooldir );
! 		return(0);
! 	}
! 	sprintf(cname, XQTFILE, rmtname); /* sprintf(cname,"c%.4s",rmtname); */
! 	len = strlen(cname);
! 	while ((dp = readdir(dirp)) != (struct direct *)NULL) {
! 		printmsg( 4, "dscandir:dir file = %s cfile = %s", dp->d_name, cname );
! 		if ( strncmp( cname, dp->d_name, len ) == SAME ) {
! 			printmsg( 4, "dscandir: match!!" );
! 			strcpy(cfile, dp->d_name);
! 			closedir( dirp );
! 			return( -1 );
! 		}
! 	}
! 	closedir( dirp );
! 	return( 0 );
! 
  }
--- 662,722 ----
  */
  scandir()
  {
!     int len;
!     char cname[40];
!     DIR *dirp;
!     struct direct *dp;
  
!     if (!(dirp = opendir(spooldir))) {
! 	fprintf(stderr,"couldn't open dir %s\n", spooldir);
! 	return('A');
!     }
!     cfile[0] = 0;
!     sprintf(cname, CALLFILE, rmtname);
!     len = strlen(cname);
!     while (dp = readdir(dirp)) {
! 	if(!strncmp(cname, dp->d_name, len) &&
! 	   (!cfile[0] || strcmp(cfile, dp->d_name) == 1))
! 	    strcpy(cfile, dp->d_name);
!     }
!     closedir(dirp);
!     if(cfile[0]) {
! 	printmsg(4,"scandir: %s", cfile);
! 	if(fw = FOPEN(cfile,"r",'t'))
! 	    return('S');
! 	else
! 	    return('Y');
!     }
!     return('Q');
  }
  
  
  /*
  **
  **dscandir
  ** scan the directory
+ ** The names are delivered in lexicographical order.
  */
  
  dscandir()
  {
!     int len;
!     char cname[40];
!     DIR *dirp;
!     struct direct *dp;
  
!     if (!(dirp = opendir(spooldir))) {
! 	fprintf(stderr,"couldn't open dir %s\n",spooldir);
! 	return(0);
!     }
!     cfile[0] = 0;
!     sprintf(cname, XQTFILE, rmtname);
!     len = strlen(cname);
!     while(dp = readdir(dirp)) {
! 	if(!strncmp(cname, dp->d_name, len) &&
! 	   (!cfile[0] || strcmp(cfile, dp->d_name) == 1))
! 	    strcpy(cfile, dp->d_name);
!     }
!     closedir(dirp);
!     return(cfile[0]);
  }
diff -c old/dcpxfer.c new/dcpxfer.c
*** old/dcpxfer.c	Wed Feb 24 14:13:38 1988
--- new/dcpxfer.c	Sat Mar  5 20:56:36 1988
***************
*** 420,430 ****
  
  	printmsg( 3, "rfile: buf %d \"%s\"", len, buf );
  
- 	/* Convert upper case to lower */
- /*	for (cp = buf; *cp != '\0';cp++)
- 		if (isupper(*cp))
- 		    *cp = tolower(*cp); */
- 
  	numflds = getargs( buf, flds );
  
  	if(buf[0] == 'R') {
--- 420,425 ----
***************
*** 431,447 ****
  		cp = flds[1];
  		cp2 = flds[2];
  		printmsg( 3, "rfile: send file \"%s\"", cp );
  	} else {
  		cp = flds[2];
  		cp2 = flds[1];
  		printmsg( 3, "rfile: receive file \"%s\"", cp );
  	}
- 
- 	/* check for ~/ destination -> /usr/spool/uucppublic */
- 	if ( strncmp( cp, "~/", 2 ) == SAME )
- 		sprintf( tmpfilename, "%s%s", pubdir, cp+1);
- 	else
- 		strcpy( tmpfilename, cp );
  	if(buf[0] == 'R')
  		printmsg( 3, "rfile: send file \"%s\"", tmpfilename );
  	else
--- 426,448 ----
  		cp = flds[1];
  		cp2 = flds[2];
  		printmsg( 3, "rfile: send file \"%s\"", cp );
+ 		/* Security: only files in ~/ may be fetched */
+ 		if ( strncmp( cp, "~/", 2 ) == SAME )
+ 			sprintf( tmpfilename, "%s%s", pubdir, cp+1);
+ 		else
+ 			return('A');
  	} else {
  		cp = flds[2];
  		cp2 = flds[1];
  		printmsg( 3, "rfile: receive file \"%s\"", cp );
+ 		/* Security: only ~/... D... and X... allowed */
+ 		if ( strncmp( cp, "~/", 2 ) == SAME )
+ 			sprintf( tmpfilename, "%s%s", pubdir, cp+1);
+ 		else if(!strnicmp(cp,"D.", 2) || !strnicmp(cp,"X.", 2)) {
+ 			makeUniqueFileName(cp, tmpfilename);
+ 		} else
+ 			return('A');
  	}
  	if(buf[0] == 'R')
  		printmsg( 3, "rfile: send file \"%s\"", tmpfilename );
  	else
diff -c old/lmail.c new/lmail.c
*** old/lmail.c	Fri Feb 12 12:45:48 1988
--- new/lmail.c	Sun Mar 13 18:36:10 1988
***************
*** 60,65 ****
--- 60,66 ----
  
  static FILE   *mailfile;
  static FILE   *tempfile;
+ static FILE   *sigfile;
  
  static char	buf[BUFSIZ];
  static char	miscBuf[100];
***************
*** 72,77 ****
--- 73,79 ----
  
  static char	tfilename[100];
  extern char	mfilename[];
+ static char	sfilename[100];
  static char	mailsent[100];
  
  static char 	remotes[BUFSIZ];
***************
*** 144,149 ****
--- 146,152 ----
  		fprintf(tempfile,"%ld\n", (sequence+1)%10000);
  		fclose(tempfile);
  	}
+ 	tfilename[0] = 0;
  
  	if(!(inFileName = inname)) {
  	 	sprintf(miscBuf, TFILENAME, sequence);
***************
*** 174,191 ****
  		}
  	}
  	/* append signature */
! 	mkfilename(mfilename, home, SIGFILE);
  
  	if (debuglevel > 4)
! 		fprintf(stderr,"pcmail: opening sigfile %s\n", mfilename);
! 	if(mailfile = FOPEN(mfilename,"r", 't')) {
  		fputs("\n---\n", tempfile);
  		buf[sizeof(buf) - 2] = '\n'; buf[sizeof(buf) - 1] = 0;
! 		while (fgets(buf, sizeof(buf) - 2, mailfile)) {
  			if(buf[0])
  				fputs(buf, tempfile);
  		}
! 		fclose(mailfile);
   	}
  
   	fclose(tempfile);
--- 177,194 ----
  		}
  	}
  	/* append signature */
! 	mkfilename(sfilename, home, SIGFILE);
  
  	if (debuglevel > 4)
! 		fprintf(stderr,"pcmail: opening sigfile %s\n", sfilename);
! 	if(sigfile = FOPEN(sfilename,"r", 't')) {
  		fputs("\n---\n", tempfile);
  		buf[sizeof(buf) - 2] = '\n'; buf[sizeof(buf) - 1] = 0;
! 		while (fgets(buf, sizeof(buf) - 2, sigfile)) {
  			if(buf[0])
  				fputs(buf, tempfile);
  		}
! 		fclose(sigfile);
   	}
  
   	fclose(tempfile);
***************
*** 242,248 ****
  	   fprintf(stderr,"pcmail: copfile = %s\n", mailsent);
  	sendone(argc, argv, mailsent, FALSE); */
  
! 	unlink(tfilename);
  	chdir(mcurdir);
  	return(0);
  }
--- 245,252 ----
  	   fprintf(stderr,"pcmail: copfile = %s\n", mailsent);
  	sendone(argc, argv, mailsent, FALSE); */
  
! 	if(tfilename[0])
! 	    unlink(tfilename);
  	chdir(mcurdir);
  	return(0);
  }
diff -c old/mail.c new/mail.c
*** old/mail.c	Fri Feb 12 13:16:34 1988
--- new/mail.c	Sun Mar  6 07:54:08 1988
***************
*** 3,9 ****
   */
  
  /* The users refers to the letters with a number between 1 and numberOfLetters,
!  * message 1 being the most recent.
   *
   * The messages are refered to internally with a number between 0 and
   * numberOfLetters - 1, with message numberOfLetters - 1 being the most recent.
--- 3,9 ----
   */
  
  /* The users refers to the letters with a number between 1 and numberOfLetters,
!  * message numberOfLetters being the most recent.
   *
   * The messages are refered to internally with a number between 0 and
   * numberOfLetters - 1, with message numberOfLetters - 1 being the most recent.
***************
*** 13,19 ****
  #include <stdio.h>
  #include "host.h"
  
! #define  VERSION "1.4 Camelot"
  
  FILE *FOPEN();
  FILE *freopen();
--- 13,19 ----
  #include <stdio.h>
  #include "host.h"
  
! #define  VERSION "1.5 Camelot"
  
  FILE *FOPEN();
  FILE *freopen();
***************
*** 122,135 ****
  	unlink( tmailbag );
  }
  
! static userToInternal( i )
  {
! 	return( numberOfLetters - i );
  }
  
! static internalToUser( i )
  {
! 	return( numberOfLetters - i );
  }
  
  showmail(argc, argv)
--- 122,135 ----
  	unlink( tmailbag );
  }
  
! static userToInternal(i)
  {
! 	return(i - 1);
  }
  
! static internalToUser(i)
  {
! 	return(i + 1);
  }
  
  showmail(argc, argv)
***************
*** 223,231 ****
  	fmailbox = FOPEN( tmailbox, "r", 'b' );
  
  	if ( printonly ) {
! 		j = numberOfLetters;
! 		while ( j > 0 )
! 			pager( --j );
  		return;
  	}
  
--- 223,230 ----
  	fmailbox = FOPEN( tmailbox, "r", 'b' );
  
  	if ( printonly ) {
! 		for(j = 0; j < numberOfLetters; j++)
! 			pager(j);
  		return;
  	}
  
***************
*** 247,256 ****
  		case '?':
  			fprintf( stderr, "q\tquit\n" );
  			fprintf( stderr, "x\texit\tmailbox restored\n" );
! 			fprintf( stderr, "p\tprint message\n" );
  			fprintf( stderr, "s [file] save message to a file (default =mbox)\n" );
  			fprintf( stderr, "w [file] save message to a file (default =mbox) without header\n" );
! 			fprintf( stderr, "-^\tprint previous message\n" );
  			fprintf( stderr, "d\tdelete current message\n" );
  			fprintf( stderr, "u\tundelete current message\n" );
  			fprintf( stderr, "+n\tprint next message\n" );
--- 246,255 ----
  		case '?':
  			fprintf( stderr, "q\tquit\n" );
  			fprintf( stderr, "x\texit\tmailbox restored\n" );
! 			fprintf( stderr, "<CR>\tprint message\n" );
  			fprintf( stderr, "s [file] save message to a file (default =mbox)\n" );
  			fprintf( stderr, "w [file] save message to a file (default =mbox) without header\n" );
! 			fprintf( stderr, "-p^\tprint previous message\n" );
  			fprintf( stderr, "d\tdelete current message\n" );
  			fprintf( stderr, "u\tundelete current message\n" );
  			fprintf( stderr, "+n\tprint next message\n" );
***************
*** 288,298 ****
  		case 'q':
  			goto donep;
  		case '\n':
- 		case 'p':
  			if(j > 0)
  				pager( userToInternal(j) );
  			break;
  		case '^':
  		case '-':
  			if(--j > 0)
  				pager( userToInternal(j) );
--- 287,297 ----
  		case 'q':
  			goto donep;
  		case '\n':
  			if(j > 0)
  				pager( userToInternal(j) );
  			break;
  		case '^':
+ 		case 'p':
  		case '-':
  			if(--j > 0)
  				pager( userToInternal(j) );
***************
*** 393,420 ****
  		*cp = '\0';
  }
  
- 
- /*
- returnaddress()
- {
- 	readaline( lp->from, line );
- 	if (
- 		( i = index( line, '<' )) != 0 &&
- 		( k = index( line, '>')) != 0 &&
- 		( k > i )
- 		)
- 	{
- 		k -= i;
- 		strncpy( from, line[i], k );
- 		from[k] = '\0';
- 	}
- 	else {
- 
- 
- 	}
- }
- */
- 
  printsub( internalIndex )
  int internalIndex;
  {
--- 392,397 ----
***************
*** 432,442 ****
  	else
  		maxk = mink = internalIndex;
  
! 	for ( k = maxk ; k >= mink ; k-- ) {
! 
  		j = internalToUser( k );
  		ld = letterN(k);
- 
   		(void)strcpy(from, "unknown");	/* default to "unknown" */
  		readaline( ld->from, line );
  		if ( strlen( line ) > 5 ) {
--- 409,417 ----
  	else
  		maxk = mink = internalIndex;
  
! 	for ( k = mink ; k <= maxk ; k++ ) {
  		j = internalToUser( k );
  		ld = letterN(k);
   		(void)strcpy(from, "unknown");	/* default to "unknown" */
  		readaline( ld->from, line );
  		if ( strlen( line ) > 5 ) {
***************
*** 529,535 ****
  	ld = letterN(n);
  	fseek( fmailbox, ld->adr, 0 );
  	bytes = ld->suc->adr - ld->adr;
- 
  	pagereset();
  	buf[sizeof(buf) - 2] = '\n'; buf[sizeof(buf) - 1] = 0;
  	while ( bytes > 0 && fgets( buf, sizeof(buf) - 2, fmailbox )) {
--- 504,509 ----
***************
*** 537,543 ****
  		if ( buf[0] && pageline( buf ) == TRUE )
  			break;
  	}
- 
  	pageline( "\n" );
  }
  
--- 511,516 ----
diff -c old/pccp.c new/pccp.c
*** old/pccp.c	Sun Feb  7 15:32:56 1988
--- new/pccp.c	Tue Mar  1 16:35:40 1988
***************
*** 54,60 ****
  #include <stdio.h>
  #include "host.h"
  
! #define VERSION "1.0 6-FEB-88"
  #define PROGRAM "pccp"
  
  /*
--- 54,60 ----
  #include <stdio.h>
  #include "host.h"
  
! #define VERSION "1.1 1-MAR-88"
  #define PROGRAM "pccp"
  
  /*
***************
*** 416,424 ****
      char *cp;
      char user[50];
  
!     if(from[0] == '/' || from[0] == ':') {
  	strcpy(to, from);
  	to[0] = ':';
      } else if(from[0] == '~') {
  	if(!(cp = strchr(from,'/'))) {
  	    strcat(from, "/");
--- 416,426 ----
      char *cp;
      char user[50];
  
!     if(from[0] == '/') {
  	strcpy(to, from);
  	to[0] = ':';
+     } else if(strchr(from,':')) {
+ 	strcpy(to, from);
      } else if(from[0] == '~') {
  	if(!(cp = strchr(from,'/'))) {
  	    strcat(from, "/");
diff -c old/ulib.c new/ulib.c
*** old/ulib.c	Wed Feb 24 11:51:32 1988
--- new/ulib.c	Sat Feb 27 14:28:44 1988
***************
*** 17,59 ****
  
  */
  
! #include <stdio.h>
! #include "host.h"
  #ifdef MANX
  #include <sgtty.h>
  #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 <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;
! #endif
! 	return('I');
  }
  
  
! char inbuf[BUFSIZ];
! char outbuf[BUFSIZ];
  
  swrite(data, num)
  int	num;
--- 17,147 ----
  
  */
  
! #include "dcp.h"
  #ifdef MANX
  #include <sgtty.h>
  #endif
  
+ char inbuf[BUFSIZ];
+ char outbuf[BUFSIZ];
  int lineIsOpen = 0;
  
  /**/
  /*
   *
!  *      login (for slave)
!  */
  login()
  {
!     char logmsg[80];
!     char inbuf[132];
!     char remoteUser[20];		/* login name of remote user */
!     int i;
!     int retVal;
! 
!     sleep(2);	/* In case we just closed the line */
!     if (openline( device, speed ) == -1) {
! 	fprintf(stderr,"login: Unable to open %s\n", device);
! 	onBreak();
!     }
!     while(TRUE) {
! 	sprintf(logmsg,"(%s) login: ", nodename);
! 	wmsg(logmsg, 0);	/* Tell the modem what speed we are using */
! 	while(rmsg(inbuf, 1) <= 0)
! 	    chkabort();
! 	for(i = 0; i < 3; i++) {
! 	    chkabort();
! 	    wmsg(logmsg, 0);
! 	    if(rmsg(inbuf, 1) <= 0)
! 		continue;
! 	    strncpy(remoteUser, inbuf, sizeof(remoteUser) - 1);
! 	    remoteUser[sizeof(remoteUser) - 1] = 0;
! 	    wmsg("password:", 0);
! 	    if(rmsg(inbuf, 0) <= 0)
! 		continue;
! 	    wmsg("\r\n", 0);
! 	    if((retVal = checkUser(remoteUser, inbuf)) == 0)
! 		continue;	/* user check failed */
! 	    else if(retVal == 1)
! 		return('I');	/* legal uucp user */
! 	    else
! 		break;		/* legal interactive user logging off */
! 	}
! 	closeAndOpenLine();
!     }
  }
  
  
! /* Break connection for a while. */
! 
! closeAndOpenLine()
! {
!     sysAbortEnd();
!     sleep(2);
!     if (openline( device, speed ) == -1) {
! 	fprintf(stderr,"closeAndOpenLine: Unable to open %s\n", device);
! 	onBreak();
!     }
! }
! 
! 
! /* remote user validation.
!  *
!  * The password file has the following format
!  *	name:password:program:comment
!  * we search for a record where name matches userName.
!  * check for password match. If failure return 0.
!  * If success and program equals "uucp" or "" then return 1.
!  * Otherwise execute program. The intention is to allow users to login to an
!  * ordinary BBS system.
!  */
! 
! checkUser(userName, password)
! char *userName, *password;
! {
!     char buf[BUFSIZ];
!     FILE *fin;
!     char *cp;
! 
!     sprintf(buf,"%s/password",confdir);
!     if(!(fin = FOPEN(buf,"r",'t'))) {
! 	fprintf(stderr,"checkUser: unable to open %s\n", buf);
! 	return(0);
!     }
!     buf[sizeof(buf) - 2] = '\n'; buf[sizeof(buf) - 1] = 0;
!     while(fgets(buf, sizeof(buf) - 2, fin)) {
! 	if(!(cp = strtok(buf,":\n")) || !*cp)
! 	    continue;
! 	if(strcmp(cp, userName))
! 	    continue;
! 	if(!(cp = strtok(NULL,":\n")) || !*cp)
! 	    break;
! 	if(strcmp(cp, password))
! 	    break;
! 	if(!(cp = strtok(NULL,":\n")))
! 	    break;
! 	fclose(fin);
! 	if(!*cp || !strcmp(cp,"uucp"))
! 	    return(1);
! 	/* execute program. Not Yet Implemented.
! 	 * What is the best way to do this?
! 	 * Possibilities:
! 	 *	Close line and hope that program will open it.
! 	 *
! 	 *	Execute("program <AUX: >AUX:")
! 	 *	  we may have to open the line in nonexclusive mode for this
! 	 *	  to work.
! 	 *
! 	 *	Other...
! 	 *
! 	 *	The quick and dirty solution: include the program here.
! 	 */
! 	return(2);
!     }
!     fclose(fin);
!     return(0);
! }
! 
  
  swrite(data, num)
  int	num;
diff -c old/uuhost.c new/uuhost.c
*** old/uuhost.c	Sun Feb 14 18:32:18 1988
--- new/uuhost.c	Sat Mar  5 21:29:16 1988
***************
*** 81,83 ****
--- 81,112 ----
  	if ( *canon == ':' )
  	   *canon = '/';
  }
+ 
+ /* AmigaDOS ignores case differences. Make a unique AmigaDOS file name.
+  * We must preserve the lexicographical order.
+  * Assumption: No need to make the prefix unique.
+  */
+ 
+ makeUniqueFileName(from, to)
+ char *from;
+ char *to;
+ {
+     register char *f, *t;
+     char *tmp;
+     register char ch;
+ 
+     t = to;
+     if(f = strrchr(from,'.')) {
+ 	f++;
+ 	for(tmp = from; tmp != f; *t++ = *tmp++);
+     } else
+ 	f = from;
+     while(ch = *f++) {
+ 	if(isupper(ch)) {
+ 	    *t++ = '_';
+ 	    *t++ = tolower(ch);
+ 	} else
+ 	    *t++ = ch;
+     }
+     *t = 0;
+ }

Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30
Internet: jw@sics.se or {mcvax,munnari,ukc,unido}!enea!sics.se!jw
-- 
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30
Internet: jw@sics.se or {mcvax,munnari,ukc,unido}!enea!sics.se!jw