Diffs for new write(1): System V/Xenix

Brandon S. Allbery allbery at NCoast.ORG
Sun Dec 24 03:57:29 AEST 1989


As promised (hey, I delivered something on time for a change!), here are the
diffs for the new write(1) for System V.3 and Xenix.  I have tested them under
Xenix 2.3.2.

++Brandon

*** write.c.orig	Sat Dec 23 11:21:20 1989
--- write.c	Sat Dec 23 11:40:08 1989
***************
*** 1,6 ****
  #ifndef lint
  static char rcsid[] =
!     "@(#) $Header: write.c,v 1.24dist 89/12/18 21:04:42 jef Exp $ (LBL)";
  #endif
  /*
   * Copyright (c) 1989 The Regents of the University of California.
--- 1,6 ----
  #ifndef lint
  static char rcsid[] =
!     "@(#) $Header: write.c,v 1.24dist+usg 89/12/23 11:47:42 allbery Exp $ (LBL)";
  #endif
  /*
   * Copyright (c) 1989 The Regents of the University of California.
***************
*** 7,13 ****
   * All rights reserved.
   *
   * This code is derived from software contributed to Berkeley by
!  * Jef Poskanzer and Craig Leres.
   *
   * Redistribution and use in source and binary forms are permitted
   * provided that the above copyright notice and this paragraph are
--- 7,14 ----
   * All rights reserved.
   *
   * This code is derived from software contributed to Berkeley by
!  * Jef Poskanzer and Craig Leres.  Ported to System V by Brandon S.
!  * Allbery.
   *
   * Redistribution and use in source and binary forms are permitted
   * provided that the above copyright notice and this paragraph are
***************
*** 32,51 ****
--- 33,81 ----
  static char sccsid[] = "@(#)write.c	4.20 (Berkeley) 11/25/89";
  #endif /* not lint */
  
+ #ifdef USG
+ #include <sys/types.h>
+ #endif
  #include <sys/param.h>
+ #ifdef USG
+ #include <signal.h>
+ #else
  #include <sys/signal.h>
+ #endif
  #include <sys/stat.h>
+ #ifdef USG
+ #include <fcntl.h>
+ #include <time.h>
+ #else
  #include <sys/file.h>
  #include <sys/time.h>
+ #endif
  #include <utmp.h>
  #include <ctype.h>
  #include <pwd.h>
  #include <stdio.h>
+ #ifdef USG
+ #include <string.h>
+ #include <sys/utsname.h>
+ 
+ #define uid_t unsigned short
+ #ifdef UTMP_NAME
+ #define _PATH_UTMP UTMP_NAME
+ #else
+ #define _PATH_UTMP "/etc/utmp"
+ #endif
+ #define MAXPATHLEN 1024
+ #define MAXHOSTNAMELEN sizeof (((struct utsname *) 0)->nodename)
+ #define index strchr
+ #define rindex strrchr
+ #else
  #include <strings.h>
  
  #ifndef _PATH_UTMP
  #define _PATH_UTMP "/etc/utmp"
  #endif
+ #endif
+ 
  #ifndef UT_LINESIZE
  #define UT_LINESIZE sizeof(((struct utmp *)0)->ut_line)
  #endif
***************
*** 138,143 ****
--- 168,176 ----
  
  	while (read(ufd, (char *) &u, sizeof(u)) == sizeof(u))
  		if (strncmp(user, u.ut_name, sizeof(u.ut_name)) == 0 &&
+ #ifdef USG
+ 		    u.ut_type == USER_PROCESS &&
+ #endif
  		    strncmp(tty, u.ut_line, sizeof(u.ut_line)) == 0) {
  			(void)close(ufd);
  			return(0);
***************
*** 177,182 ****
--- 210,219 ----
  	user_is_me = 0;
  	while (read(ufd, (char *) &u, sizeof(u)) == sizeof(u))
  		if (strncmp(user, u.ut_name, sizeof(u.ut_name)) == 0) {
+ #ifdef USG
+ 			if (u.ut_type != USER_PROCESS)
+ 				continue;
+ #endif
  			++nloggedttys;
  #ifdef sun
  			if (nonuser(u))
***************
*** 255,260 ****
--- 292,300 ----
  	time_t now, time();
  	char *getlogin(), path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
  	void done();
+ #ifdef USG
+ 	struct utsname hostinfo;
+ #endif
  
  	/* Determine our login name before we reopen() stdout */
  	if ((login = getlogin()) == NULL)
***************
*** 273,280 ****
--- 313,325 ----
  	(void)signal(SIGHUP, done);
  
  	/* print greeting */
+ #ifdef USG
+ 	uname(&hostinfo);
+ 	strcpy(host, hostinfo.nodename);
+ #else
  	if (gethostname(host, sizeof(host)) < 0)
  		(void)strcpy(host, "???");
+ #endif
  	now = time((time_t *)NULL);
  	nows = ctime(&now);
  	nows[16] = '\0';
-- 
Brandon S. Allbery    allbery at NCoast.ORG, BALLBERY (MCI Mail), ALLBERY (Delphi)
uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery at hal.cwru.edu bsa at telotech.uucp
*(comp.sources.misc mail to comp-sources-misc[-request]@backbone.site, please)*
*Third party vote-collection service: send mail to allbery at uunet.uu.net (ONLY)*
expnet.all: Experiments in *net management and organization.  Mail me for info.



More information about the Alt.sources mailing list