XCOMM bug fixes

Chad R. Larson chad at anasaz.UUCP
Sun Oct 23 12:01:00 AEST 1988


I obtained XCOMM from usenet group alt.sources and built it on my 
machine which is a PC/AT clone running Microport System V/AT 2.2-L.  I 
discovered several bugs and typo's which I fixed.

I also added support for standard UUCP style lock files, as my machine 
is not running the HoneyDanBer uucp, and the lockfile code posted to the 
net decides the valid uucp lock files are "stale" and deletes them.  The 
choice of which kind of lock file to use is selected by a new "#define" 
in the xcomm.h file.  

I added the ability for the phonelist and script files to be located in
a common location.  A new #define in the header file specifies a
directory to be searched after the current directory and the home
directory.  On my machine this is set to /usr/local/lib/xcomm.

There was code in the xcxmdm.c file to force all xmodem file transfers
to be done with CRC checking regardless of the setting of the crc flag.
The code went to the effort of saving the state of the flag, however.  I
presume this was left over from some testing or something.  I removed
it.

Below are context diffs for each of the files that I changed.  They are
suitable for application with Larry Wall's patch program, or they could
be hacked through by hand with your favorite editor.

-------------------( begin diffs )------------------------------------

*** xcomm.h.old
--- xcomm.h
**************
*** 16,21
  #define	CAPTFILE	"capture.log"	/* Default capture file */
  #define PHFILE		".phonelist"	/* Default phonelist file */
  #define STARTUP		".xcomm"	/* XCOMM Startup Script */
  #define DRIBBLE		2		/* Text "dribble" delay */
  #define PUT_TAKE			/* include put/take code */
  #define	CIS_INIT	1		/* cismode default 1=on/0=off */
--- 17,23 -----
  #define	CAPTFILE	"capture.log"	/* Default capture file */
  #define PHFILE		".phonelist"	/* Default phonelist file */
  #define STARTUP		".xcomm"	/* XCOMM Startup Script */
+ #define LIBDIR		"/usr/local/lib/xcomm/"	/* file library name */
  #define DRIBBLE		2		/* Text "dribble" delay */
  #define PUT_TAKE			/* include put/take code */
  #define	CIS_INIT	1		/* cismode default 1=on/0=off */
**************
*** 19,24
  #define DRIBBLE		2		/* Text "dribble" delay */
  #define PUT_TAKE			/* include put/take code */
  #define	CIS_INIT	1		/* cismode default 1=on/0=off */
  
  #define HAVE_DUP2	0		/* 0 if dup2() not available */
  #define	HAVE_STRSTR	0		/* We have to define strstr() */
--- 21,27 -----
  #define DRIBBLE		2		/* Text "dribble" delay */
  #define PUT_TAKE			/* include put/take code */
  #define	CIS_INIT	1		/* cismode default 1=on/0=off */
+ #define	HDBR		0		/* 1 for HoneyDanBer locks, else 0 */
  
  #define HAVE_DUP2	0		/* 0 if dup2() not available */
  #define	HAVE_STRSTR	0		/* We have to define strstr() */

*** xcport.c.old
--- xcport.c
**************
*** 350,355
      Simple, eh?
  */
  
  char lckf[40] = "/usr/spool/locks/LCK..";
  char ltmp[40] = "/usr/spool/locks/LTMP.";
  
--- 350,356 -----
      Simple, eh?
  */
  
+ #if HDBR
  char lckf[40] = "/usr/spool/locks/LCK..";
  char ltmp[40] = "/usr/spool/locks/LTMP.";
  #else
**************
*** 352,357
  
  char lckf[40] = "/usr/spool/locks/LCK..";
  char ltmp[40] = "/usr/spool/locks/LTMP.";
  
  lock_tty()
  {
--- 353,362 -----
  #if HDBR
  char lckf[40] = "/usr/spool/locks/LCK..";
  char ltmp[40] = "/usr/spool/locks/LTMP.";
+ #else
+ char lckf[40] = "/usr/spool/uucp/LCK..";
+ char ltmp[40] = "/usr/spool/uucp/LTMP.";
+ #endif /* HDBR */
  
  lock_tty()
  {
**************
*** 355,361
  
  lock_tty()
  {
!     int pid, lckpid, lfd;
      char pidstr[20];
      char lckpidstr[20];
      char *modemname;
--- 360,366 -----
  
  lock_tty()
  {
!     int pid, lfd;
      char pidstr[20];
      char *modemname;
  #if HDBR
**************
*** 357,363
  {
      int pid, lckpid, lfd;
      char pidstr[20];
-     char lckpidstr[20];
      char *modemname;
      extern int errno;
  
--- 362,367 -----
  {
      int pid, lfd;
      char pidstr[20];
      char *modemname;
  #if HDBR
      char lckpidstr[20];
**************
*** 359,365
      char pidstr[20];
      char lckpidstr[20];
      char *modemname;
!     extern int errno;
  
      /*
       * Get our PID, and initialize the filename strings.
--- 363,372 -----
      int pid, lfd;
      char pidstr[20];
      char *modemname;
! #if HDBR
!     char lckpidstr[20];
!     int lckpid;
! #endif /* HDBR */
  
      /*
       * Get our PID, and initialize the filename strings.
**************
*** 385,390
      /*
       * Attempt to link directly - if it works, we're done.
       */
    relink:
      if (link(ltmp, lckf) == 0) {
  	unlink(ltmp);
--- 392,398 -----
      /*
       * Attempt to link directly - if it works, we're done.
       */
+ #if HDBR
    relink:
  #endif /* HDBR */
      if (link(ltmp, lckf) == 0) {
**************
*** 386,391
       * Attempt to link directly - if it works, we're done.
       */
    relink:
      if (link(ltmp, lckf) == 0) {
  	unlink(ltmp);
          return 0;
--- 394,400 -----
       */
  #if HDBR
    relink:
+ #endif /* HDBR */
      if (link(ltmp, lckf) == 0) {
  	unlink(ltmp);
          return 0;
**************
*** 389,394
      if (link(ltmp, lckf) == 0) {
  	unlink(ltmp);
          return 0;
      }
  
      /*
--- 398,404 -----
      if (link(ltmp, lckf) == 0) {
  	unlink(ltmp);
          return 0;
+ #if HDBR
      }
  
      /*
**************
*** 411,416
       */
      if (unlink(lckf)) {
  	fprintf(stderr, "Can't unlink(2) stale LCK?\r\n");
  	unlink(ltmp);
  	return -1;
      }
--- 421,430 -----
       */
      if (unlink(lckf)) {
  	fprintf(stderr, "Can't unlink(2) stale LCK?\r\n");
+ #else
+     } else {
+ 	fprintf(stderr, "%s unavailable, locked.\r\n", port);
+ #endif /* HDBR */
  	unlink(ltmp);
  	return -1;
      }
**************
*** 414,419
  	unlink(ltmp);
  	return -1;
      }
      goto relink;
      /*NOTREACHED*/
  }
--- 428,434 -----
  	unlink(ltmp);
  	return -1;
      }
+ #if HDBR
      goto relink;
      /*NOTREACHED*/
  #endif /* HDBR */
**************
*** 416,421
      }
      goto relink;
      /*NOTREACHED*/
  }
  
  unlock_tty()
--- 431,437 -----
  #if HDBR
      goto relink;
      /*NOTREACHED*/
+ #endif /* HDBR */
  }
  
  unlock_tty()

*** xcterm.c.old
--- xcterm.c
**************
*** 195,204
  
      if (home = (char *) getenv("HOME")) {
  	sprintf(fullname, "%s/%s", home, name);
! 	return fopen(fullname, "r");
!     } else
! 	return NULL;
! }
  
  /*
      Select a script file.  If the file exists, execute it, otherwise
--- 197,205 -----
  
      if (home = (char *) getenv("HOME")) {
  	sprintf(fullname, "%s/%s", home, name);
! 	if (fp = fopen(fullname, "r"))
! 	    return fp;
!     }
  
      strcpy(fullname, LIBDIR);
      strcat(fullname, name);
**************
*** 200,205
  	return NULL;
  }
  
  /*
      Select a script file.  If the file exists, execute it, otherwise
      exit with a non-zero return.
--- 201,211 -----
  	    return fp;
      }
  
+     strcpy(fullname, LIBDIR);
+     strcat(fullname, name);
+     return fopen(fullname, "r");
+ }
+ 
  /*
      Select a script file.  If the file exists, execute it, otherwise
      exit with a non-zero return.
**************
*** 242,249
      int c, i;
  
      if ((fp = openfile(phonefile)) == NULL) {
! 	fprintf(tfp,"Phonelist file '%s' not in current or home directory\r\n",
! 		phonefile);
  	return;
      }
  
--- 248,254 -----
      int c, i;
  
      if ((fp = openfile(phonefile)) == NULL) {
! 	fprintf(tfp,"Phonelist file '%s' not found\r\n", phonefile);
  	return;
      }
  
*** xcxmdm.c.old
--- xcxmdm.c
**************
*** 42,48
  static unsigned short updcrc();
  
  static void newsigint();		/* Our SIGINT handler */
- static int  save_crc;			/* Saved crcheck value */
  static jmp_buf our_env;
  
  xreceive(c)
--- 42,47 -----
  static unsigned short updcrc();
  
  static void newsigint();		/* Our SIGINT handler */
  static jmp_buf our_env;
  
  xreceive(c)
**************
*** 54,60
      }
  
      xc_setxon(0);				/* turn off XON/XOFF */
-     save_crc = crcheck;
      signal(SIGINT, newsigint);			/* Install our handler */
  
      if (!setmode(c)) {
--- 53,58 -----
      }
  
      xc_setxon(0);				/* turn off XON/XOFF */
      signal(SIGINT, newsigint);			/* Install our handler */
  
      if (!setmode(c)) {
**************
*** 59,65
  
      if (!setmode(c)) {
  	if (setjmp (our_env) == 0) {
- 	    crcheck = 0xff;
  	    do_xreceive(word);
  	}
      }
--- 57,62 -----
  
      if (!setmode(c)) {
  	if (setjmp (our_env) == 0) {
  	    do_xreceive(word);
  	}
      }
**************
*** 65,71
      }
  
      signal(SIGINT, SIG_IGN);			/* Reinstall old handler */
-     crcheck = save_crc;
      restmode();
  }
  
--- 62,67 -----
      }
  
      signal(SIGINT, SIG_IGN);			/* Reinstall old handler */
      restmode();
  }
  
**************
*** 78,84
      }
  
      xc_setxon(0);				/* turn off XON/XOFF */
-     save_crc = crcheck;
      signal(SIGINT, newsigint);			/* Install our handler */
  
      if (!setmode(c)) {
--- 74,79 -----
      }
  
      xc_setxon(0);				/* turn off XON/XOFF */
      signal(SIGINT, newsigint);			/* Install our handler */
  
      if (!setmode(c)) {
**************
*** 83,89
  
      if (!setmode(c)) {
  	if (setjmp (our_env) == 0) {
- 	    crcheck = 0xff;
  	    do_xsend(word);
  	}
      }
--- 78,83 -----
  
      if (!setmode(c)) {
  	if (setjmp (our_env) == 0) {
  	    do_xsend(word);
  	}
      }
**************
*** 89,95
      }
  
      signal(SIGINT, SIG_IGN);			/* Reinstall old handler */
-     crcheck = save_crc;
      restmode();
  }
  
--- 83,88 -----
      }
  
      signal(SIGINT, SIG_IGN);			/* Reinstall old handler */
      restmode();
  }
  
**************
*** 141,147
  
      if (!mungmode && !access(name, 0)) {
          canit();
! 	fprintf(tfp,"Receive of %s aborted due to pre-exsistence.\r\n");
          return(ERROR);
      }
  
--- 134,140 -----
  
      if (!mungmode && !access(name, 0)) {
          canit();
! 	fprintf(tfp,"Receive of %s aborted due to pre-existence.\r\n", name);
          return(ERROR);
      }
  
**************
*** 147,153
  
      if ((xfp = fopen(name, "w")) == NULL) {
          canit();
! 	fprintf(tfp,"Receive of %s aborted due to inabilty to open.\r\n");
          return(ERROR);
      }
      firstsec = TRUE;
--- 140,146 -----
  
      if ((xfp = fopen(name, "w")) == NULL) {
          canit();
! 	fprintf(tfp,"Receive of %s aborted due to inabilty to open.\r\n", name);
          return(ERROR);
      }
      firstsec = TRUE;
**************
*** 329,335
  	    fprintf(tfp,"\r\nTimeout\r\n");
              break;
          }
! 	fprintf(tfp,"\r\nTrying again on ths sector.\r\n");
          purge();
          if (firstsec)
              sendbyte(crcheck ? WANTCRC : NAK);
--- 322,328 -----
  	    fprintf(tfp,"\r\nTimeout\r\n");
              break;
          }
! 	fprintf(tfp,"\r\nTrying again on this sector.\r\n");
          purge();
          if (firstsec)
              sendbyte(crcheck ? WANTCRC : NAK);
**************
*** 439,445
  {
      register int i;
  
!     for(i = 0; i < 20; i++)
          sendbyte(CAN);
  }
  
--- 432,438 -----
  {
      register int i;
  
!     for(i = 0; i < 10; i++)
          sendbyte(CAN);
  }
  

---------------
"All the young dudes carry the news"  --David Bowie
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| DCF, Inc.               | UUCP: ...ncar!noao!nud!anasaz!dcfinc!chad   |
| 14623 North 49th Place  | Ma Bell: (602) 953-1392                     |
| Scottsdale, AZ 85254    | Loran: N-33deg37min20sec W-111deg58min26sec |
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|         Disclaimer: These ARE the opinions of my employer!            |
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



More information about the Alt.sources mailing list