[net.sources] UNaXcess 0.4.4 REPOST -- Part 3 of 3

allbery@ncoast.UUCP (08/04/86)

#! /bin/sh
#
# Shell archive created Sat., Aug. 02, 1986 by tdi2!brandon.
# Contents:
#
#	-rw-r--r--   1 brandon  sys        17555 Aug  2 10:59 udl.c
#	-rw-r--r--   1 brandon  20          3457 Aug  2 10:58 Makefile
#	-rw-r--r--   1 brandon  sys         1568 Aug  2 11:00 Utilities/mkconf.c
#	-r--r--r--   1 brandon  sys         1286 Jul 18 21:10 Utilities/s.mkconf.c
#	-r--r--r--   1 brandon  sys         4882 Jul 18 21:10 Utilities/s.mvmsg.c
#	-r--r--r--   1 brandon  sys         7001 Jul 18 21:10 Utilities/s.uanews.c
#	-r--r--r--   1 brandon  sys          655 Jul 18 21:10 Utilities/s.udate.c
#	-r--r--r--   1 brandon  sys         1921 Jul 18 21:10 Utilities/s.uwho.c
#	-rw-r--r--   1 brandon  sys         7283 Aug  2 11:00 Utilities/uanews.c
#	-rw-r--r--   1 brandon  sys          935 Aug  2 11:00 Utilities/udate.c
#	-rw-r--r--   1 brandon  sys         2199 Aug  2 11:00 Utilities/uwho.c
#	-rw-r--r--   1 brandon  sys        14984 Aug  2 11:00 Utilities/install.sh
#	-r--r--r--   1 brandon  sys        15145 Jul 18 21:10 Utilities/s.install.sh
#	-r--r--r--   1 brandon  sys          934 Jul 18 21:10 Utilities/s.umotd.sh
#	-r--r--r--   1 brandon  sys         1034 Jul 18 21:10 Utilities/s.upost.sh
#	-rw-r--r--   1 brandon  sys          802 Aug  2 11:00 Utilities/umotd.sh
#	-rw-r--r--   1 brandon  sys          902 Aug  2 11:00 Utilities/upost.sh
#
# You may unpack this archive with sh or ksh, but not csh.
#

if test -r "udl.c"; then
	echo "File udl.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="udl.c"
	esac
else
	newname="udl.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:udl.c--' > "$newname"
X/*
X *	@(#)udl.c	1.1 (TDI) 7/18/86 21:02:01
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:02:01 by brandon
X *     Converted to SCCS 07/18/86 21:02:01
X *	@(#)Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:02:01 by brandon
X *     Converted to SCCS 07/18/86 21:02:01
X *
X *	@(#)This file is part of UNaXcess version 0.4.5.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:02:01 by brandon
X *     Converted to SCCS 07/18/86 21:02:01
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "@(#)udl.c	1.1 (TDI) 7/18/86 21:02:01";
Xstatic char _UAID_[]   = "@(#)UNaXcess version 0.4.5";
X#endif lint
X
X#include "ua.h"
X#ifdef BSD
X#include <sys/time.h>
X#else  SYS3
X#include <time.h>
X#endif BSD
X#include <varargs.h>
X
X#define A_UPLOAD	parms.ua_auc
X#define A_DOWNLOAD	parms.ua_adc
X
X#define X_UPLOAD	parms.ua_xuc
X#define X_DOWNLOAD	parms.ua_xdc
X
X#define K_UPLOAD	parms.ua_kuc
X#define K_DOWNLOAD	parms.ua_kdc
X
X#define LIBRARY		"library"
X#define DIRECTORY	"directory"
X#define STORAGE		"uploads"
X#define UPLOG		"upload-log"
X
X#define off		0
X#define on		1
X
X#define pager		__col = 0, __line = 0, __Page =
X
X#define DIRFORMAT	"%[^ ] %*1[Ff]%*1[Ii]%*1[Ll]%*1[Ee] %[^;]; %[^ ] %*1[Bb]%*1[Yy] %[^:]: %[^\n]"
X
Xjmp_buf brchloop, fileloop;
Xstatic char thisbrch[80] = "";
X
Xint __Page = on;
Xint __line = 0;
Xint __col = 0;
Xint __paws = off;
X
Xchar *whatis(), *pgetin(), *cpmform(), *upstr(), *today();
X
Xextern struct tm *localtime();
X
Xudl(branch)
Xchar *branch; {
X	int again();
X	int (*oldint)();
X	char *cp;
X
X	if (user.u_access < A_FILES) {
X		puts("\nYou will not be able to upload or download files.\nYou may, however, download File Lists.");
X		log("File Section entered; access restricted");
X	}
X	thisbrch[0] == '\0';
X	for (cp = branch; *cp != '\0'; cp++)
X		if (*cp == ' ') {
X			strcpy(thisbrch, ++cp);
X			break;
X		}
X	oldint = signal(SIGINT, again);
X	setjmp(brchloop);
X	while (libmenu())
X		;
X	msg("\n");
X	signal(SIGINT, oldint);
X}
X
Xagain() {
X	signal(SIGINT, again);
X	pager on;
X	msg("\nInterrupt\n");
X	fflush(stdout);
X	log("Interrupt");
X	if (__paws == on) {
X		talk();
X		__paws = off;
X	}
X	longjmp(brchloop, 1);
X}
X
Xlibmenu() {
X	struct direct *branch;
X	DIR *library;
X	char cmd[512], bname[512];
X	int (*oldsig)();
X	int brch_cmd();
X	char *desc;
X	
X	if ((library = opendir(LIBRARY)) == NULL) {
X		msg("The Library is closed\n");
X		return 0;
X	}
X	if (thisbrch[0] != '\0') {
X		strcpy(cmd, thisbrch);
X		thisbrch[0] == '\0';
X		goto gotbrch;
X	}
X	msg("\nThe UNaXcess File Section.  Please select one of the following\nbranches, or EXIT to leave the Library.\n\n");
X	while ((branch = readdir(library)) != NULL) {
X		if ((desc = whatis(branch->d_name, NULL)) == NULL)
X			continue;
X		msg("    %-8.8s   %s\n", upstr(branch->d_name), desc);
X	}
X	closedir(library);
X	msg("\nBranch: ");
X	if (pgetin(cmd, NULL) == NULL)
X		return 0;
X	log("Branch: %s", cmd);
X	if (s_cmp(cmd, "EXIT") == 0)
X		return 0;
X
Xgotbrch:
X	if (whatis(cmd, NULL) != NULL) {
X		library = opendir(LIBRARY);
X		while ((branch = readdir(library)) != NULL)
X			if (s_cmp(branch->d_name, cmd) == 0) {
X				closedir(library);
X				strcpy(bname, branch->d_name);
X				oldsig = signal(SIGINT, brch_cmd);
X				setjmp(fileloop);
X				while (visit(bname))
X					;
X				signal(SIGINT, oldsig);
X				return 1;
X			}
X	}
X	closedir(library);
X	msg("There is no such branch.  If you wish to open a new branch,\nleave a message to %s.\n", parms.ua_sysop);
X	return 1;
X}
X
Xvisit(branch)
Xchar *branch; {
X	char cmd[512];
X	DIR *directory;
X	
X	sprintf(cmd, "%s/%s", LIBRARY, branch);
X	if ((directory = opendir(cmd)) == NULL) {
X		msg("The %s branch is closed.\n", upstr(branch));
X		return 0;
X	}
X	closedir(directory);
X	msg("\n%s Branch\nUpload, Download, List of Files, Get File List, Exit: ", upstr(branch));
X	if (pgetin(cmd, NULL) == NULL)
X		return 0;
X	log("Branch cmd: %s", cmd);
X	switch (cmd[0]) {
X		case 'e':
X		case 'E':
X			return 0;
X		case 'U':
X		case 'u':
X			upload(branch);
X			break;
X		case 'D':
X		case 'd':
X			download(branch);
X			break;
X		case 'L':
X		case 'l':
X			filelist(branch);
X			break;
X		case 'G':
X		case 'g':
X			getlist(branch);
X			break;
X		default:
X			msg("Unrecognized command.\n");
X	}
X	return 1;
X}
X
Xbrch_cmd() {
X	pager on;
X	msg("\nInterrupt\n");
X	log("Interrupt");
X	fflush(stdout);
X	if (__paws == on) {
X		talk();
X		__paws = off;
X	}
X	signal(SIGINT, brch_cmd);
X	longjmp(fileloop, 1);
X}
X
Xfilelist(branch)
Xchar *branch; {
X	char path[512];
X	DIR *directory;
X	struct direct *file;
X	char *desc;
X
X	sprintf(path, "%s/%s", LIBRARY, branch);
X	directory = opendir(path);
X	msg("\nFile Directory for the %s Branch:\n\n", upstr(branch));
X	while ((file = readdir(directory)) != NULL) {
X		if ((desc = whatis(branch, file->d_name)) == NULL)
X			continue;
X		msg("    %-12.12s   %s\n", cpmform(file->d_name), desc);
X	}
X	msg("\n");
X	closedir(directory);
X}
X
Xgetlist(branch)
Xchar *branch; {
X	char path[512], listfile[30], cmd[512];
X	DIR *directory;
X	struct direct *file;
X	int (*oldsig)();
X	char *desc;
X	FILE *list;
X
X	sprintf(listfile, "/tmp/cli%05d", getpid());
X	if ((list = fopen(listfile, "w")) == NULL) {
X		msg("Can't open temporary list file???\n");
X		exit(5);
X	}
X	msg("\nDownload file listing from the %s branch\n\nSupported transfer protocols are: Ascii, Xmodem, and Kermit.\n\nEnter File Transfer Protocol (XMODEM default): ", upstr(branch));
X	if (pgetin(cmd, NULL) == NULL)
X		return;
X	log("List dnld mode: %s", cmd);
X	switch (cmd[0]) {
X		case 'A':
X		case 'a':
X			if (!validudl(A_DOWNLOAD)) {
X				msg("\nAscii Download is not supported.\n");
X				log("No Ascii");
X				return;
X			}
X			sprintf(cmd, A_DOWNLOAD, listfile);
X			break;
X		case 'K':
X		case 'k':
X			if (!validudl(K_DOWNLOAD)) {
X				msg("\nKermit Download is not supported.\n");
X				log("No Kermit");
X				return;
X			}
X			sprintf(cmd, K_DOWNLOAD, listfile);
X			break;
X		case 'X':
X		case 'x':
X			if (!validudl(X_DOWNLOAD)) {
X				msg("\nXModem Download is not supported.\n");
X				log("No Xmodem");
X				return;
X			}
X			sprintf(cmd, X_DOWNLOAD, listfile);
X			break;
X		case '\0':
X			cmd[0] = 'X';
X			if (!validudl(X_DOWNLOAD)) {
X				msg("\nXModem Download is not supported.\n");
X				log("No Xmodem");
X				return;
X			}
X			sprintf(cmd, X_DOWNLOAD, listfile);
X			break;
X		default:
X			msg("Invalid protocol designation.\n");
X			return;
X	}
X	sprintf(path, "%s/%s", LIBRARY, branch);
X	directory = opendir(path);
X	fprintf(list, "File Directory for the %s Branch:\r\n\r\n", upstr(branch));
X	while ((file = readdir(directory)) != NULL) {
X		if ((desc = whatis(branch, file->d_name)) == NULL)
X			continue;
X		fprintf(list, "    %-12.12s   %s\r\n", cpmform(file->d_name), desc);
X	}
X	fclose(list);
X	closedir(directory);
X	msg("You have 30 seconds to prepare for file transmission.\nPress BREAK to abort transmission.\n\n");
X	fflush(stdout);
X	sleep(30);
X	oldsig = signal(SIGINT, SIG_IGN);
X	system(cmd);
X#ifdef SYS3
X	system("stty echoe");
X#endif SYS3
X	signal(SIGINT, oldsig);
X	unlink(listfile);
X}
X
Xdownload(branch)
Xchar *branch; {
X	char path[512], filename[512], cmd[512];
X	DIR *directory;
X	struct direct *file;
X	int (*oldsig)();
X	
X	if (user.u_access < A_FILES) {
X		log("Attempted download, access denied.");
X		puts("You may not download files.");
X		return;
X	}
X	msg("\nDownload from the %s branch\n\nEnter file to download: ");
X	if (pgetin(filename, NULL) == NULL)
X		return;
X	log("Dnld file: %s", filename);
X	if (filename[0] == '.' || Index(filename, '/') != NULL) {
X		msg("No such file: \"%s\"\n", upstr(filename));
X		return;
X	}
X	if (whatis(branch, filename) != NULL) {
X		sprintf(path, "%s/%s", LIBRARY, branch);
X		directory = opendir(path);
X		while ((file = readdir(directory)) != NULL) {
X			if (s_cmp(file->d_name, filename) == 0) {
X				closedir(directory);
X				sprintf(path, "%s/%s/%s", LIBRARY, branch, file->d_name);
X				msg("Supported transfer protocols are: Ascii, Xmodem, and Kermit.\n\nEnter File Transfer Protocol (XMODEM default): ", upstr(branch));
X				if (pgetin(cmd, NULL) == NULL)
X					return;
X				switch (cmd[0]) {
X					case 'A':
X					case 'a':
X						if (!validudl(A_DOWNLOAD)) {
X							msg("\nAscii Download is not supported.\n");
X							log("No Ascii");
X							return;
X						}
X						sprintf(cmd, A_DOWNLOAD, path);
X						break;
X					case 'K':
X					case 'k':
X						if (!validudl(K_DOWNLOAD)) {
X							msg("\nKermit Download is not supported.\n");
X							log("No Kermit");
X							return;
X						}
X						sprintf(cmd, K_DOWNLOAD, path);
X						break;
X					case 'X':
X					case 'x':
X						if (!validudl(X_DOWNLOAD)) {
X							msg("\nXModem Download is not supported.\n");
X							log("No Xmodem");
X							return;
X						}
X						sprintf(cmd, X_DOWNLOAD, path);
X						break;
X					case '\0':
X						cmd[0] = 'X';
X						if (!validudl(X_DOWNLOAD)) {
X							msg("\nXModem Download is not supported.\n");
X							log("No Xmodem");
X							return;
X						}
X						sprintf(cmd, X_DOWNLOAD, path);
X						break;
X					default:
X						msg("Invalid protocol designation.\n");
X						return;
X				}
X				msg("You have 30 seconds to prepare for file transmission.\nPress BREAK to abort transmission.\n\n");
X				fflush(stdout);
X				sleep(30);
X				oldsig = signal(SIGINT, SIG_IGN);
X				system(cmd);
X#ifdef SYS3
X				system("stty echoe");
X#endif SYS3
X				signal(SIGINT, oldsig);
X				return;
X			}
X		}
X		closedir(directory);
X	}
X	msg("No such file: \"%s\"\n", upstr(filename));
X	log("No such file");
X}
X
Xupload(branch)
Xchar *branch; {
X	char path[512], filename[512], cmd[512], desc[512];
X	DIR *directory;
X	struct direct *file;
X	int (*oldsig)();
X	FILE *logf;
X	
X	if (user.u_access < A_FILES) {
X		log("Attempted upload, access denied.");
X		puts("You may not upload files.");
X		return;
X	}
X	msg("\nUpload to the %s branch\n\nEnter the name to give the new file: ");
X	if (pgetin(filename, NULL) == NULL)
X		return;
X	log("Upld file: %s", filename);
X	if (filename[0] == '.' || Index(filename, '/') != NULL || Index(filename, ';') != NULL) {
X		msg("Invalid filename: \"%s\"\n", upstr(filename));
X		log("Invalid filename");
X		return;
X	}
X	sprintf(path, "%s/%s", STORAGE, branch);
X	if ((directory = opendir(path)) == NULL) {
X		msg("The %s has denied upload ability for this branch.\n", parms.ua_sysop);
X		return;
X	}
X	while ((file = readdir(directory)) != NULL) {
X		if (s_cmp(file->d_name, filename) == 0) {
X			closedir(directory);
X			msg("That file name is used.  Please try again with a different filename.\n");
X			log("File exists");
X			return;
X		}
X	}
X	closedir(directory);
X	msg("Enter a description for the file: ");
X	if (pgetin(desc, NULL) == NULL)
X		return;
X	log("Description: %s", desc);
X	if ((logf = fopen(UPLOG, "a")) == NULL) {
X		log("Error %d opening %s", errno, UPLOG);
X		msg("Can't log the new file.\n");
X		return;
X	}
X	fprintf(logf, "%s file %s; %s by %s: %s\n", branch, filename, today(), upstr(user.u_name), desc);
X	fclose(logf);
X	sprintf(path, "%s/%s/%s", STORAGE, branch, filename);
X	msg("Supported transfer protocols are: Ascii, Xmodem, and Kermit.\nXmodem protocol uses checksums; CCITT CRC is not supported.\n\nEnter File Transfer Protocol (XMODEM default): ", upstr(branch));
X	if (pgetin(cmd, NULL) == NULL)
X		return;
X	log("Upld protocol: %s", cmd);
X	switch (cmd[0]) {
X		case 'A':
X		case 'a':
X			if (!validudl(A_UPLOAD)) {
X				msg("\nAscii Upload is not supported.\n");
X				log("No Ascii");
X				return;
X			}
X			sprintf(cmd, A_UPLOAD, path);
X			break;
X		case 'K':
X		case 'k':
X			if (!validudl(K_UPLOAD)) {
X				msg("\nKermit Upload is not supported.\n");
X				log("No Kermit");
X				return;
X			}
X			sprintf(cmd, K_UPLOAD, path);
X			break;
X		case 'X':
X		case 'x':
X			if (!validudl(X_UPLOAD)) {
X				msg("\nXModem Upload is not supported.\n");
X				log("No Xmodem");
X				return;
X			}
X			sprintf(cmd, X_UPLOAD, path);
X			break;
X		case '\0':
X			cmd[0] = 'X';
X			if (!validudl(X_UPLOAD)) {
X				msg("\nXModem Upload is not supported.\n");
X				log("No Xmodem");
X				return;
X			}
X			sprintf(cmd, X_UPLOAD, path);
X			break;
X		default:
X			msg("Invalid protocol designation.\n");
X			return;
X	}
X	msg("You have 30 seconds to prepare for file transmission.\nPress BREAK to abort transmission.\n\n");
X	fflush(stdout);
X	sleep(30);
X	oldsig = signal(SIGINT, SIG_IGN);
X	system(cmd);
X#ifdef SYS3
X	system("stty echoe");
X#endif SYS3
X	signal(SIGINT, oldsig);
X}
X
X/*VARARGS2*/
Xmsg(fmt, va_alist)
Xchar *fmt;
Xva_dcl {
X	va_list va_ptr;
X	register char *cp;
X	int lzflag, width, ext, longflag, ljflag;
X	
X	va_start(va_ptr);
X	for (cp = fmt; *cp != '\0'; cp++)
X		if (*cp != '%')
X			say(*cp);
X		else {
X			width = 0;
X			ext = 0;
X			lzflag = 0;
X			longflag = 0;
X			ljflag = 0;
X			if (*++cp == '-')
X				ljflag = 1;
X			else
X				cp--;
X			if (isdigit(*++cp)) {
X				if (*cp == '0') {
X					lzflag = 1;
X					cp++;
X				}
X				while (isdigit(*cp))
X					width *= 10 + (*cp++ - '0');
X			}
X			if (*cp == '.') {
X				while (isdigit(*++cp))
X					ext *= 10 + (*cp - '0');
X			}
X_longagain:
X			switch (*cp) {
X				case 's':
X					_fmtstr(va_arg(va_ptr, char *), width, ext, ljflag);
X					break;
X				case 'D':
X					_fmtint(va_arg(va_ptr, long), width, lzflag, 1, ljflag);
X					break;
X				case 'd':
X					_fmtint((long) va_arg(va_ptr, int), width, lzflag, longflag, ljflag);
X					break;
X				case 'c':
X					_fmtchr(va_arg(va_ptr, char), width, lzflag);
X					break;
X				case 'l':
X					longflag = 1;
X					goto _longagain;
X				default:
X					say(*cp);
X			}
X		}
X}
X
X_fmtchr(c, width, ljflag)
Xchar c; {
X	register int w;
X	
X	if (!ljflag)
X		for (w = 0; w < width - 1; w++)
X			say(' ');
X	say(c);
X	if (ljflag)
X		for (w = 0; w < width - 1; w++)
X			say(' ');
X}
X
X_fmtstr(sp, width, ext, ljflag)
Xchar *sp; {
X	register char *cp;
X	register int w;
X	
X	cp = sp;
X	if (ext == 0)
X		ext = strlen(cp);
X	if (!ljflag)
X		for (w = 0; w < width - ext; w++)
X			say(' ');
X	for (w = 0; w < ext; w++)
X		say(*cp++);
X	if (ljflag)
X		for (w = 0; w < width - ext; w++)
X			say(' ');
X}
X
X_fmtint(i, width, lzflag, longflag, ljflag)
Xlong i; {
X	long lnum;
X	register int w;
X	char *cp;
X	char ibuf[20];
X	int nospflag, nwidth;
X	
X	lnum = i;
X	nospflag = (width == 0);
X	if (width > sizeof ibuf - 2)
X		width = sizeof ibuf - 2;
X	cp = ibuf + sizeof ibuf - 1;
X	*cp-- = '\0';
X	if (lnum == 0)
X		*cp-- = '0';
X	else
X		while (lnum != 0) {
X			*cp-- = (lnum % 10) + '0';
X			lnum /= 10;
X		}
X	if (!nospflag || (!lzflag && ljflag))
X		while (cp >= ibuf + (sizeof ibuf - width - 1))
X			*cp-- = (lzflag? '0': ' ');
X	nwidth = ((long) cp) - ((long) ibuf);
X	while (*++cp != '\0')
X		say(*cp);
X	if (ljflag)
X		for (w = 0; w < width - nwidth; w++)
X			say(' ');
X}
X
Xsay(ch)
Xchar ch; {
X	ch &= 0x7f;
X	switch (ch) {
X		case '\t':
X			do {
X				say(' ');
X			} while (__col % 8);
X			break;
X		case '\n':
X			putchar('\n');
X			__col = 0;
X			if (__Page == on && ++__line == 23) {
X				paws();
X				__line = 0;
X			}
X			break;
X		case '\177':
X			msg("^?");
X			break;
X		default:
X			if (ch < ' ') {
X				say('^');
X				say(ch + '@');
X				return;
X			}
X			if (__col == user.u_llen - 1)
X				say('\n');
X			putchar(ch);
X			__col++;
X	}
X}
X
Xpaws() {
X	fputs("Type any key to continue. . .", stdout);
X	__paws = on;
X	silent();
X	getchar();
X	talk();
X	__paws = off;
X	fputs("\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b", stdout);
X}
X
Xs_cmp(s1, s2)
Xchar *s1, *s2; {
X	for (; *s1 != '\0' && ToLower(*s1) == ToLower(*s2); s1++, s2++)
X		;
X	return (!(*s1 == '\0' && *s2 == '\0'));
X}
X
Xchar *whatis(branch, file)
Xchar *branch, *file; {
X	static FILE *directory = NULL;
X	static char dent[512];
X	char tbr[512], tfi[512], date[512], who[512], desc[512];
X	
X	if (directory != NULL || (directory = fopen(DIRECTORY, "r")) != NULL) {
X		fseek(directory, 0L, 0);
X		while (fgets(dent, sizeof dent, directory) != NULL) {
X			if (dent[0] == '%' || dent[0] == '\n')
X				continue;
X			tbr[0] = '\0';
X			tfi[0] = '\0';
X			date[0] = '\0';
X			who[0] = '\0';
X			desc[0] = '\0';
X			if (sscanf(dent, DIRFORMAT, tbr, tfi, date, who, desc) != 5)
X				continue;
X			if (s_cmp(tbr, branch) == 0) {
X				if (s_cmp(tfi, (file == NULL? "branch": file)) != 0)
X					continue;
X				sprintf(dent, "%s [Created %s by %s]", desc, date, who);
X				return dent;
X			}
X		}
X	}
X	if (directory == NULL)
X		log("No download directory");
X	return NULL;
X}
X
X/* this is a stub-ified version of v1.0 COMND input module */
X
Xchar *pgetin(str, tab)
Xchar *str;
Xchar tab[]; {
X	char *ch;
X
X	fflush(stdout);
X	pager off;
X	ch = gets(str);
X	pager on;
X	if (ch == NULL) {
X		msg("^D\n");
X		log("EOF");
X		fflush(stdout);
X	}
X	return ch;
X}
X
Xchar *cpmform(fn)
Xchar *fn; {
X	static char buf[13];
X	register int cnt, scnt;
X	
X	for (scnt = 0, cnt = 0; cnt < 8 && fn[cnt] != '.' && fn[cnt] != '\0'; cnt++, scnt++)
X		buf[scnt] = ToUpper(fn[cnt]);
X	while (scnt < 8)
X		buf[scnt++] = ' ';
X	buf[scnt++] = '.';
X	while (fn[cnt] != '.' && fn[cnt] != '\0')
X		cnt++;
X	if (fn[cnt] == '.')
X		cnt++;
X	while (scnt < 12 && fn[cnt] != '\0') {
X		buf[scnt++] = ToUpper(fn[cnt]);
X		cnt++;
X	}
X	buf[scnt] = '\0';
X	return buf;
X}
X
Xchar *upstr(s)
Xchar *s; {
X	static char sbuf[512];
X	register char *cp, *dp;
X	
X	for (cp = s, dp = sbuf; *cp != '\0'; cp++, dp++)
X		*dp = ToUpper(*cp);
X	*dp = '\0';
X	return sbuf;
X}
X
Xchar *today() {
X	long now;
X	struct tm *date;
X	static char buf[11];
X	
X	time(&now);
X	date = localtime(&now);
X	sprintf(buf, "%d/%d/%d", date->tm_mon + 1, date->tm_mday, date->tm_year);
X	return buf;
X}
X
Xvalidudl(cmd)
Xchar *cmd; {
X	if (cmd[0] == '\0')
X		return 0;
X	if (Index(cmd, '%') != RIndex(cmd, '%'))
X		return 0;
X	if (Index(cmd, '%') == (char *) 0) {
X		strcat(cmd, " %s");
X		return 1;
X	}
X	if (*(Index(cmd, '%') + 1) != 's')
X		return 0;
X	return 1;
X}
--EOF:udl.c--
fi

if test -r "Makefile"; then
	echo "File Makefile exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Makefile"
	esac
else
	newname="Makefile"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Makefile--' > "$newname"
X#
X# Makefile for UNaXcess
X#
X
XSHELL = /bin/sh
X# make on sys3 is not very nice when it comes to standard shell interfaces...
X
X# ``make SYSTEM=(SYS3|SYS5|V7|BSD|XENIX|XENIX3|XENIX5) all''
X# Use V7     for V7, XENIX 2.x, and BSD pre-4.2 (+ bastardizations of same)
X#     BSD    for BSD 4.2 and 4.3
X#     SYS3   for real AT&T System III
X#     SYS5   for real AT&T System V revisions 1 and 2
X#     XENIX3 for Xenix v3.x, Unisoft System III, and other bastardized V7's
X#     XENIX5 for Xenix V5.x and other bastardized V7's with System V libraries
X# You're on your own if it's a really odd combo.
X# Pyramid 90x:  use either universe.  SYS5 is best tested; BSD has bigger
X# conference names and many performance pluses (extra-fast conference
X# creation; I don't know if the 4.2 directory stuff is implemented in kernel
X# or not, so I don't know if you gain -- but libndir is SLOW!).
X
XCFLAGS = -D${SYSTEM} -O
X
XOBJS = ua.o msg.o conf.o date.o bull.o sys.o user.o dir.o param.o udl.o
XSRCS = ua.c msg.c conf.c date.c bull.c sys.c user.c dir.c param.c udl.c \
X       ua.h user.h dir.h sys.h README \
X       Utilities/install.sh Utilities/mkconf.c Utilities/uanews.c \
X       Utilities/udate.c Utilities/umotd.sh Utilities/upost.sh \
X       Utilities/uwho.c
XSRC  = ua.c msg.c conf.c date.c bull.c sys.c user.c dir.c param.c udl.c \
X       ua.h user.h dir.h sys.h README
XUTIL = install.sh mkconf.c uanews.c udate.c umotd.sh upost.sh uwho.c
X
Xall: ua uwho udate mkconf mvmsg uanews
X
Xuwho: Utilities/uwho
Xudate: Utilities/udate
Xmkconf: Utilities/mkconf
Xmvmsg: Utilities/mvmsg
Xuanews: Utilities/uanews
X
Xua: $(OBJS)
X	${CC} -o ua $(OBJS)
X
X$(OBJS): ua.h user.h dir.h sys.h
X
XUtilities/mkconf: Utilities/mkconf.o
X	${CC} Utilities/mkconf.o -o Utilities/mkconf
X
XUtilities/mvmsg: Utilities/mvmsg.o
X	${CC} Utilities/mvmsg.o -o Utilities/mvmsg
X
XUtilities/uanews: Utilities/uanews.o
X	${CC} Utilities/uanews.o -o Utilities/uanews
X
XUtilities/udate: Utilities/udate.o date.o
X	${CC} Utilities/udate.o date.o -o Utilities/udate
X
XUtilities/uwho: Utilities/uwho.o
X	${CC} -o Utilities/uwho Utilities/uwho.o
X
XUtilities/mkconf.o: Utilities/mkconf.c
X	${CC} ${CFLAGS} -c Utilities/mkconf.c
X	mv mkconf.o Utilities/mkconf.o
X
XUtilities/udate.o: Utilities/udate.c
X	${CC} ${CFLAGS} -c Utilities/udate.c
X	mv udate.o Utilities/udate.o
X
XUtilities/uwho.o: Utilities/uwho.c
X	${CC} ${CFLAGS} -c Utilities/uwho.c
X	mv uwho.o Utilities/uwho.o
X
XUtilities/mvmsg.o: Utilities/mvmsg.c
X	${CC} ${CFLAGS} -c Utilities/mvmsg.c
X	mv mvmsg.o Utilities/mvmsg.o
X
XUtilities/uanews.o: Utilities/uanews.c
X	${CC} ${CFLAGS} -c Utilities/uanews.c
X	mv uanews.o Utilities/uanews.o
X
Xclean:
X	rm -f ua Utilities/uwho Utilities/udate Utilities/upost \
X		Utilities/mkconf Utilities/umotd *.o Utilities/*.o tags core \
X		shar? Utilities/mvmsg Utilities/uanews
X
Xtags:
X	ctags *.[ch] Utilities/*.c
X
Xshar:
X	for file in $(SRC); do release $$file; done
X	cd Utilities; for file in $(UTIL); do release $$file; done
X	shar -dv ua.c date.c bull.c sys.c user.c param.c dir.c > shar1
X	shar -dv msg.c conf.c ua.h user.h dir.h sys.h README > shar2
X	shar -dv udl.c Makefile Utilities/*.c Utilities/*.sh > shar3
X	rm $(SRC); cd Utilities; rm $(UTIL)
X
Xtar:
X	tar cvf unaxcess.tar README *.[ch] Makefile Utilities/*.c \
X		Utilities/*.sh
X
Xedall: %edall
X	for file in *.[ch] Makefile Utilities/*.c Utilities/*.sh; do\
X		sh %edall $$file;\
X	done
X	
Xupdate:
X	if test -z "$(VERSION)"; then exit 1; fi
X	for file in $(SRCS); do \
X		admin -fq"$(VERSION)" s.$file \
X	done
--EOF:Makefile--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/mkconf.c"; then
	echo "File Utilities/mkconf.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/mkconf.c"
	esac
else
	newname="Utilities/mkconf.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/mkconf.c--' > "$newname"
X/*
X *	@(#)mkconf.c	1.1 (TDI) 7/18/86 21:10:32
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:32 by brandon
X *     Converted to SCCS 07/18/86 21:10:31
X *	@(#)Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:32 by brandon
X *     Converted to SCCS 07/18/86 21:10:31
X *
X *	@(#)This file is part of UNaXcess version 0.4.5.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:32 by brandon
X *     Converted to SCCS 07/18/86 21:10:31
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "@(#)mkconf.c	1.1 (TDI) 7/18/86 21:10:32";
Xstatic char _UAID_[]   = "@(#)UNaXcess version 0.4.5";
X#endif lint
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/dir.h>
X
Xchar line[256];
X
X#ifdef SYS5
X#  define SYS3
X#endif SYS5
X
X#ifdef SYS3
X#  define RIndex	strrchr
X#else
X#  ifdef XENIX3
X#    define RIndex	strrchr
X#  else
X#    ifdef XENIX5
X#      define RIndex	strrchr
X#    else
X#      define RIndex	rindex
X#    endif XENIX5
X#  endif XENIX3
X#endif SYS3
X
Xchar *RIndex();
X
Xmain(argc, argv)
X    char **argv;
X    {
X    if (argc != 3)
X	exit(1);
X    mknod(argv[1], S_IFDIR|0755, 0);
X    chown(argv[1], atoi(argv[2]), 50);
X    sprintf(line, "%s/.", argv[1]);
X    link(argv[1], line);
X    *RIndex(argv[1], '/') = '\0';
X    strcat(line, ".");
X    link(argv[1], line);
X    }
--EOF:Utilities/mkconf.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/s.mkconf.c"; then
	echo "File Utilities/s.mkconf.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/s.mkconf.c"
	esac
else
	newname="Utilities/s.mkconf.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/s.mkconf.c--' > "$newname"
Xh27408
Xs 00055/00000/00000
Xd D 1.1 86/07/18 21:10:32 brandon 1 0
Xc Converted to SCCS 07/18/86 21:10:31
Xe
Xu
XU
Xf b 
Xf q 0.4.5
Xf t UNaXcess
Xt
XT
XI 1
X/*
X *	%W% (TDI) %G% %U%
X *	%Z%Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X *	%Z%This file is part of %Y% version %Q%.
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "%W% (TDI) %G% %U%";
Xstatic char _UAID_[]   = "%Z%%Y% version %Q%";
X#endif lint
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/dir.h>
X
Xchar line[256];
X
X#ifdef SYS5
X#  define SYS3
X#endif SYS5
X
X#ifdef SYS3
X#  define RIndex	strrchr
X#else
X#  ifdef XENIX3
X#    define RIndex	strrchr
X#  else
X#    ifdef XENIX5
X#      define RIndex	strrchr
X#    else
X#      define RIndex	rindex
X#    endif XENIX5
X#  endif XENIX3
X#endif SYS3
X
Xchar *RIndex();
X
Xmain(argc, argv)
X    char **argv;
X    {
X    if (argc != 3)
X	exit(1);
X    mknod(argv[1], S_IFDIR|0755, 0);
X    chown(argv[1], atoi(argv[2]), 50);
X    sprintf(line, "%s/.", argv[1]);
X    link(argv[1], line);
X    *RIndex(argv[1], '/') = '\0';
X    strcat(line, ".");
X    link(argv[1], line);
X    }
XE 1
--EOF:Utilities/s.mkconf.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/s.mvmsg.c"; then
	echo "File Utilities/s.mvmsg.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/s.mvmsg.c"
	esac
else
	newname="Utilities/s.mvmsg.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/s.mvmsg.c--' > "$newname"
Xh39705
Xs 00191/00000/00000
Xd D 1.1 86/07/18 21:10:34 brandon 1 0
Xc Converted to SCCS 07/18/86 21:10:33
Xe
Xu
XU
Xf b 
Xf q 0.4.5
Xf t UNaXcess
Xt
XT
XI 1
X/*
X *	%W% (TDI) %G% %U%
X *	%Z%Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X *	%Z%This file is part of %Y% version %Q%.
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "%W% (TDI) %G% %U%";
Xstatic char _UAID_[]   = "%Z%%Y% version %Q%";
X#endif lint
X
X#include <stdio.h>
X#include <pwd.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X#ifndef SYS3
X#  ifdef XENIX3
X#    define RIndex(s,c) strrchr(s, c)
X#    define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#  else  XENIX3
X#    ifdef XENIX5
X#      define RIndex(s,c) strrchr(s, c)
X#      define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#    else  XENIX5
X#      define RIndex(s,c) rindex(s,c)
X#      define Index(s,c) index(s,c)
Xextern char *rindex(), *index();
X#    endif XENIX5
X#  endif XENIX3
X#else
X#  define RIndex(s,c) strrchr(s, c)
X#  define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#endif
X
Xextern long atol();
Xextern struct passwd *getpwuid();
X
Xmain(argc, argv)
Xchar **argv; {
X	char msgdir[256], conf[33];
X	long msg;
X	char *cp, *dp;
X	int status;
X
X	if (argc != 3) {
X		fprintf(stderr, "Usage: mvmsg conf[/n] conf\n");
X		exit(1);
X	}
X	strcpy(msgdir, getpwuid(geteuid())->pw_dir);
X	strcat(msgdir, "/msgdir");
X	for (cp = argv[1], dp = conf; *cp != '/' && *cp != '\0'; cp++, dp++)
X		*dp = *cp;
X	*dp = '\0';
X	if (*cp == '\0') {
X		FILE *fp;
X		char tmp[512];
X		long limit, cnt;
X		
X		sprintf(tmp, "%s/%s/himsg", msgdir, conf);
X		if ((fp = fopen(tmp, "r")) == (FILE *) 0) {
X			fprintf(stderr, "Conference %s: missing himsg...\n", conf);
X			exit(7);
X		}
X		fgets(tmp, sizeof tmp, fp);
X		fclose(fp);
X		if ((limit = atol(tmp)) <= 0) {
X			fprintf(stderr, "Conference %s: invalid himsg...\n", conf);
X			exit(8);
X		}
X		for (cnt = 0, msg = 1; msg <= limit; msg++)
X			if ((status = mvmsg(msgdir, conf, msg, argv[2])) > 0)
X				exit(status);
X			else if (status == 0)
X				cnt++;
X		printf("%ld messages moved from %s to %s.\n", cnt, conf, argv[2]);
X		sprintf(tmp, "%s/%s/himsg", msgdir, conf);
X		if (unlink(tmp) != 0)
X			exit(12);
X		sprintf(tmp, "%s/%s", msgdir, conf);
X		if (rmdir(tmp) != 0)
X			exit(13);
X		exit(cnt == 0? 9: 0);
X	}
X	msg = atol(++cp);
X	if (Index(argv[2], '/') != (char *) 0) {
X		fprintf(stderr, "Usage: mvmsg conf[/n] conf\n");
X		exit(1);
X	}
X	if ((status = mvmsg(msgdir, conf, msg, argv[2])) == -1)
X		fprintf(stderr, "Couldn't read %s/%ld\n", conf, msg);
X	exit(status);
X}
X
Xmvmsg(base, conf, msg, dest)
Xchar *base, *conf, *dest;
Xlong msg; {
X	char path[512], temp[512];
X	long newmsg;
X	FILE *ifp, *ofp;
X	struct stat sbuf;
X	
X	sprintf(path, "%s/%s/%ld", base, conf, msg);
X	if (stat(path, &sbuf) < 0)
X		return -1;	/* likely to be common... */
X	sprintf(path, "%s/%s/himsg", base, dest);
X	if ((ifp = fopen(path, "r")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: missing himsg...\n", dest);
X		return 2;
X	}
X	fgets(temp, sizeof temp, ifp);
X	fclose(ifp);
X	if ((newmsg = atol(temp)) <= 0) {
X		fprintf(stderr, "Conference %s: invalid himsg...\n", dest);
X		return 2;
X	}
X	newmsg++;
X	sprintf(path, "%s/%s/%ld", base, conf, msg);
X	if ((ifp = fopen(path, "r")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: check permissions on message %ld\n", conf, msg);
X		return 3;
X	}
X	sprintf(path, "%s/%s/%ld", base, dest, newmsg);
X	if (stat(path, &sbuf) == 0) {
X		fprintf(stderr, "Conference %s: corrupted (himsg incorrect)\n", dest);
X		fclose(ifp);
X		return 4;
X	}
X	if ((ofp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: check permissions (can't create message)\n", dest);
X		fclose(ifp);
X		return 5;
X	}
X	while (fgets(temp, sizeof temp, ifp) != (char *) 0) {
X		fputs(temp, ofp);
X		if (ferror(ofp)) {
X			fprintf(stderr, "Write error on %s/%ld\n", dest, newmsg);
X			exit(5);	/* fatal! */
X		}
X	}
X	if (ferror(ifp)) {
X		fprintf(stderr, "Read error on %s/%ld\n", conf, msg);
X		fclose(ifp);
X		fclose(ofp);
X		return 6;
X	}
X	fclose(ifp);
X	fclose(ofp);
X	sprintf(path, "%s/%s/himsg", base, dest);
X	if ((ifp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: check permissions on himsg...\n", dest);
X		return 2;
X	}
X	fprintf(ifp, "%ld\n", newmsg);
X	fclose(ifp);
X	sprintf(path, "%s/%s/%ld", base, conf, msg);
X	if (unlink(path) < 0)
X		return 10;
X	return 0;
X}
X
X#ifndef BSD
X
X/* Berkeley has a rmdir() system call!  Heaven!  But I'm on sys3 (boo hiss) */
X
Xrmdir(path)
Xchar *path; {
X	int pid, status;
X	
X	switch (pid = fork()) {
X		case -1:
X			return -1;
X		case 0:
X			execl("/bin/rmdir", "rmdir", path, 0);
X			exit(-100);
X		default:
X			while (wait(&status) != pid)
X				;
X			return status;
X	}
X}
X
X#endif BSD
XE 1
--EOF:Utilities/s.mvmsg.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/s.uanews.c"; then
	echo "File Utilities/s.uanews.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/s.uanews.c"
	esac
else
	newname="Utilities/s.uanews.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/s.uanews.c--' > "$newname"
Xh60012
Xs 00263/00000/00000
Xd D 1.1 86/07/18 21:10:36 brandon 1 0
Xc Converted to SCCS 07/18/86 21:10:35
Xe
Xu
XU
Xf b 
Xf q 0.4.5
Xf t UNaXcess
Xt
XT
XI 1
X/*
X *	%W% (TDI) %G% %U%
X *	%Z%Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X *	%Z%This file is part of %Y% version %Q%.
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "%W% (TDI) %G% %U%";
Xstatic char _UAID_[]   = "%Z%%Y% version %Q%";
X#endif lint
X
X#include <stdio.h>
X#include <pwd.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X#define NEWSRC		"%newslink"	/* simplified .newsrc */
X#define ACTIVE		"/usr/lib/news/active"
X#define NEWSDIR		"/usr/spool/news"
X/* no need to define special if you're 2.10.2; we can intuit the new active file */
X
X#ifndef SYS3
X#  ifdef XENIX3
X#    define RIndex(s,c) strrchr(s, c)
X#    define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#  else  XENIX3
X#    ifdef XENIX5
X#      define RIndex(s,c) strrchr(s, c)
X#      define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#    else  XENIX5
X#      define RIndex(s,c) rindex(s,c)
X#      define Index(s,c) index(s,c)
Xextern char *rindex(), *index();
X#    endif XENIX5
X#  endif XENIX3
X#else
X#  define RIndex(s,c) strrchr(s, c)
X#  define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#endif
X
Xextern long atol();
Xextern struct passwd *getpwuid();
X
Xextern int errno;
X
Xchar *headers[] = {
X	"From: ",
X	"Reply-To: ",
X	"Date: ",
X	"Subject: ",
X	"Newsgroups: ",
X	NULL,
X};
X
Xmain(argc, argv)
Xchar **argv; {
X	char msgdir[256], conf[33];
X	long msg;
X	char *cp, *dp;
X	int status;
X
X	if (argc != 3) {
X		fprintf(stderr, "Usage: uanews newsgroup[/article] conf\n");
X		exit(1);
X	}
X#ifdef NOAUTOPATH
X	strcpy(msgdir, NOAUTOPATH);
X#else
X	strcpy(msgdir, getpwuid(geteuid())->pw_dir);
X#endif NOAUTOPATH
X	strcat(msgdir, "/msgdir");
X	for (cp = argv[1], dp = conf; *cp != '/' && *cp != '\0'; cp++, dp++)
X		*dp = *cp;
X	*dp = '\0';
X	if (*cp == '\0') {
X		FILE *fp;
X		char tmp[512], ng[512];
X		long limit, cnt, minact;
X		
X		if ((fp = fopen(ACTIVE, "r")) == (FILE *) 0) {
X			fprintf(stderr, "Not a Usenet site (no active file)...\n", conf);
X			exit(7);
X		}
X		while (fgets(tmp, sizeof tmp, fp) != NULL) {
X			if (sscanf(tmp, "%s %ld %ld", ng, &limit, &minact) == 2)
X				minact = 1;	/* < 2.10.2 */
X			if (strcmp(ng, conf) == 0)
X				break;
X		}
X		fclose(fp);
X		if (strcmp(ng, conf) != 0) {
X			fprintf(stderr, "I can't find a newsgroup called %s.\n", conf);
X			exit(13);
X		}
X		if (minact == limit) {
X			fprintf(stderr, "Newsgroup %s is empty.\n", conf);
X			exit(14);
X		}
X		sprintf(tmp, "%s/%s/%s", msgdir, argv[2], NEWSRC);
X		if ((fp = fopen(tmp, "r")) != (FILE *) 0) {
X			char tmp2[512];
X
X			while (fgets(tmp, sizeof tmp, fp) != (char *) 0) {
X				sscanf(tmp, "%[^:]: %ld", tmp2, &cnt);
X				if (strcmp(tmp2, ng) == 0)
X					break;
X			}
X			if (strcmp(tmp2, ng) == 0)
X				minact = cnt + 1;
X			fclose(fp);
X		}
X		printf("News articles %d to %d\n", minact, limit);
X		for (cnt = 0, msg = minact; msg <= limit; msg++) {
X			if ((status = copynews(msgdir, conf, msg, argv[2])) > 0)
X				exit(status);
X			else if (status == 0)
X				cnt++;
X		}
X		printf("%ld news articles posted from %s to %s.\n", cnt, conf, argv[2]);
X		exit(cnt == 0? 9: 0);
X	}
X	msg = atol(++cp);
X	if (Index(argv[2], '/') != (char *) 0) {
X		fprintf(stderr, "Usage: uanews newsgroup[/article] conf\n");
X		exit(1);
X	}
X	if ((status = copynews(msgdir, conf, msg, argv[2])) == -1)
X		fprintf(stderr, "Couldn't read article %ld of %s\n", msg, conf);
X	exit(status);
X}
X
Xcopynews(base, ng, art, dest)
Xchar *base, *ng, *dest;
Xlong art; {
X	char path[512], temp[1024], ngpath[512];
X	int cnt, inhdr;
X	long newmsg;
X	FILE *ifp, *ofp;
X	struct stat sbuf;
X	char *cp, *dp;
X	
X	for (cp = ng, dp = ngpath; *cp != '\0'; cp++, dp++)
X		if (*cp == '.')
X			*dp = '/';
X		else
X			*dp = *cp;
X	sprintf(path, "%s/%s/%ld", NEWSDIR, ngpath, art);
X	if (stat(path, &sbuf) < 0)
X		return -1;	/* likely to be common... */
X	sprintf(path, "%s/%s/himsg", base, dest);
X	if ((ifp = fopen(path, "r")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: missing himsg...\n", dest);
X		return 2;
X	}
X	fgets(temp, sizeof temp, ifp);
X	fclose(ifp);
X	if ((newmsg = atol(temp)) < 0) {
X		fprintf(stderr, "Conference %s: invalid himsg...\n", dest);
X		return 2;
X	}
X	newmsg++;
X	sprintf(path, "%s/%s/%ld", NEWSDIR, ngpath, art);
X	if ((ifp = fopen(path, "r")) == (FILE *) 0) {
X		fprintf(stderr, "Are you certain that you have permission to access news?\n");
X		return 3;
X	}
X	sprintf(path, "%s/%s/%ld", base, dest, newmsg);
X	if (stat(path, &sbuf) == 0) {
X		fprintf(stderr, "Conference %s: corrupted (himsg incorrect)\n", dest);
X		fclose(ifp);
X		return 4;
X	}
X	if ((ofp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: check permissions (can't create message)\n", dest);
X		fclose(ifp);
X		return 5;
X	}
X	inhdr = 1;
X	while (fgets(temp, sizeof temp, ifp) != (char *) 0) {
X		if (temp[0] == '\n')
X			inhdr = 0;
X		if (inhdr) {
X			for (cnt = 0; headers[cnt] != NULL; cnt++)
X				if (strncmp(temp, headers[cnt], strlen(headers[cnt])) == 0)
X					break;
X			if (headers[cnt] == NULL)
X				continue;
X		}
X		fputs(temp, ofp);
X		if (ferror(ofp)) {
X			fprintf(stderr, "Write error on %s/%ld\n", dest, newmsg);
X			exit(5);	/* fatal! */
X		}
X	}
X	if (ferror(ifp)) {
X		fprintf(stderr, "Read error on %s/%ld\n", ng, art);
X		fclose(ifp);
X		fclose(ofp);
X		return 6;
X	}
X	fclose(ifp);
X	fclose(ofp);
X	sprintf(path, "%s/%s/himsg", base, dest);
X	if ((ifp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: check permissions on himsg...\n", dest);
X		return 2;
X	}
X	fprintf(ifp, "%ld\n", newmsg);
X	fclose(ifp);
X	sprintf(path, "/tmp/uan%05d", getpid());
X	if ((ofp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Who moved /tmp?!\n");
X		return 16;
X	}
X	sprintf(path, "%s/%s/%s", base, dest, NEWSRC);
X	dp = "-";
X	if ((ifp = fopen(path, "r")) != (FILE *) 0) {
X		while (fgets(temp, sizeof temp, ifp) != (char *) 0) {
X			for (cp = temp; *cp != '\n' && *cp != ':'; cp++)
X				;
X			if (*cp == '\n')
X				continue;	/* silent cleanup */
X			else
X				*cp = '\0';
X			if (strcmp(temp, ng) == 0) {
X				sprintf(temp, "%s: %ld\n", ng, art);
X				dp = "#";
X			}
X			else
X				*cp = ':';
X			fputs(temp, ofp);
X		}
X		fclose(ifp);
X	}
X	if (*dp != '#')
X		fprintf(ofp, "%s: %ld\n", ng, art);
X	fclose(ofp);
X	sprintf(path, "/tmp/uan%05d", getpid());
X	if ((ifp = fopen(path, "r")) == (FILE *) 0) {
X		fprintf(stderr, "Can't reopen temp file, aborting...\n");
X		return 16;
X	}
X	sprintf(path, "%s/%s/%s", base, dest, NEWSRC);
X	if ((ofp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: can't update news link file (E:%d)\n", dest, errno);
X		return 17;
X	}
X	while (fgets(temp, sizeof temp, ifp) != (char *) 0)
X		fputs(temp, ofp);
X	fclose(ofp);
X	fclose(ifp);
X	sprintf(path, "/tmp/uan%05d", getpid());
X	unlink(path);	/* not a tragedy if this fails... */
X	return 0;
X}
XE 1
--EOF:Utilities/s.uanews.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/s.udate.c"; then
	echo "File Utilities/s.udate.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/s.udate.c"
	esac
else
	newname="Utilities/s.udate.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/s.udate.c--' > "$newname"
Xh47109
Xs 00019/00000/00000
Xd D 1.1 86/07/18 21:10:38 brandon 1 0
Xc Converted to SCCS 07/18/86 21:10:37
Xe
Xu
XU
Xf b 
Xf q 0.4.5
Xf t UNaXcess
Xt
XT
XI 1
X/*
X *	%W% (TDI) %G% %U%
X *	%Z%Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X *	%Z%This file is part of %Y% version %Q%.
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "%W% (TDI) %G% %U%";
Xstatic char _UAID_[]   = "%Z%%Y% version %Q%";
X#endif lint
X
Xmain() {
X	puts(longdate());
X}
XE 1
--EOF:Utilities/s.udate.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/s.uwho.c"; then
	echo "File Utilities/s.uwho.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/s.uwho.c"
	esac
else
	newname="Utilities/s.uwho.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/s.uwho.c--' > "$newname"
Xh11807
Xs 00081/00000/00000
Xd D 1.1 86/07/18 21:10:40 brandon 1 0
Xc Converted to SCCS 07/18/86 21:10:39
Xe
Xu
XU
Xf b 
Xf q 0.4.5
Xf t UNaXcess
Xt
XT
XI 1
X/*
X *	%W% (TDI) %G% %U%
X *	%Z%Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X *	%Z%This file is part of %Y% version %Q%.
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "%W% (TDI) %G% %U%";
Xstatic char _UAID_[]   = "%Z%%Y% version %Q%";
X#endif lint
X
X#include <stdio.h>
X#include <pwd.h>
X#include <sys/types.h>
X#include <utmp.h>
X
X#ifndef NOAUTOPATH
Xstruct passwd *getpwuid();
X#endif  NOAUTOPATH
X
X#define TTYLIST "/etc/utmp"
X
Xmain(argc, argv)
Xchar **argv; {
X	int cnt, flg, users;
X	struct utmp user;
X	char tty[16];
X
X	if ((users = open(TTYLIST, "r")) < 0) {
X		fprintf(stderr, "%s: can't open %s\n", argv[0], TTYLIST);
X		exit(1);
X	}
X	flg = 0;
X	while (read(users, &user, sizeof user) > 0) {
X#ifdef SYS5
X		if (user.ut_type != USER_PROCESS)
X			continue;
X#else  SYS5
X		if (user.ut_name[0] == '\0')
X			continue;
X#endif SYS5
X		sprintf(tty, "/dev/%.*s", sizeof user.ut_line, user.ut_line);
X		if (argc < 2)
X			showme(tty);
X		else
X			for (cnt = 1; argv[cnt] != NULL; cnt++)
X				if (strcmp(&tty[5], argv[cnt]) == 0) {
X					showme(tty);
X					break;
X				}
X	}
X	exit(0);
X}
X
Xshowme(ttyf)
Xchar *ttyf;
X{
X	FILE *fp;
X	char line[1024];
X#ifndef NOAUTOPATH
X	static char home[1024] = "";
X#endif NOAUTOPATH
X
X#ifdef NOAUTOPATH
X	sprintf(line, "%s/%s", NOAUTOPATH, ttyf);
X#else
X	if (home[0] == '\0')
X		strcpy(home, getpwuid(geteuid())->pw_dir);
X	sprintf(line, "%s/%s", home, ttyf);
X#endif NOAUTOPATH
X	if ((fp = fopen(line, "r")) == NULL)	/* not in use on this tty */
X		return;
X	fgets(line, 1024, fp);
X	printf("%s: %s", ttyf, line);		/* line already has newline */
X	fclose(fp);
X}
XE 1
--EOF:Utilities/s.uwho.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/uanews.c"; then
	echo "File Utilities/uanews.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/uanews.c"
	esac
else
	newname="Utilities/uanews.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/uanews.c--' > "$newname"
X/*
X *	@(#)uanews.c	1.1 (TDI) 7/18/86 21:10:36
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:36 by brandon
X *     Converted to SCCS 07/18/86 21:10:35
X *	@(#)Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:36 by brandon
X *     Converted to SCCS 07/18/86 21:10:35
X *
X *	@(#)This file is part of UNaXcess version 0.4.5.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:36 by brandon
X *     Converted to SCCS 07/18/86 21:10:35
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "@(#)uanews.c	1.1 (TDI) 7/18/86 21:10:36";
Xstatic char _UAID_[]   = "@(#)UNaXcess version 0.4.5";
X#endif lint
X
X#include <stdio.h>
X#include <pwd.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X#define NEWSRC		"%newslink"	/* simplified .newsrc */
X#define ACTIVE		"/usr/lib/news/active"
X#define NEWSDIR		"/usr/spool/news"
X/* no need to define special if you're 2.10.2; we can intuit the new active file */
X
X#ifndef SYS3
X#  ifdef XENIX3
X#    define RIndex(s,c) strrchr(s, c)
X#    define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#  else  XENIX3
X#    ifdef XENIX5
X#      define RIndex(s,c) strrchr(s, c)
X#      define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#    else  XENIX5
X#      define RIndex(s,c) rindex(s,c)
X#      define Index(s,c) index(s,c)
Xextern char *rindex(), *index();
X#    endif XENIX5
X#  endif XENIX3
X#else
X#  define RIndex(s,c) strrchr(s, c)
X#  define Index(s,c) strchr(s, c)
Xextern char *strrchr(), *strchr();
X#endif
X
Xextern long atol();
Xextern struct passwd *getpwuid();
X
Xextern int errno;
X
Xchar *headers[] = {
X	"From: ",
X	"Reply-To: ",
X	"Date: ",
X	"Subject: ",
X	"Newsgroups: ",
X	NULL,
X};
X
Xmain(argc, argv)
Xchar **argv; {
X	char msgdir[256], conf[33];
X	long msg;
X	char *cp, *dp;
X	int status;
X
X	if (argc != 3) {
X		fprintf(stderr, "Usage: uanews newsgroup[/article] conf\n");
X		exit(1);
X	}
X#ifdef NOAUTOPATH
X	strcpy(msgdir, NOAUTOPATH);
X#else
X	strcpy(msgdir, getpwuid(geteuid())->pw_dir);
X#endif NOAUTOPATH
X	strcat(msgdir, "/msgdir");
X	for (cp = argv[1], dp = conf; *cp != '/' && *cp != '\0'; cp++, dp++)
X		*dp = *cp;
X	*dp = '\0';
X	if (*cp == '\0') {
X		FILE *fp;
X		char tmp[512], ng[512];
X		long limit, cnt, minact;
X		
X		if ((fp = fopen(ACTIVE, "r")) == (FILE *) 0) {
X			fprintf(stderr, "Not a Usenet site (no active file)...\n", conf);
X			exit(7);
X		}
X		while (fgets(tmp, sizeof tmp, fp) != NULL) {
X			if (sscanf(tmp, "%s %ld %ld", ng, &limit, &minact) == 2)
X				minact = 1;	/* < 2.10.2 */
X			if (strcmp(ng, conf) == 0)
X				break;
X		}
X		fclose(fp);
X		if (strcmp(ng, conf) != 0) {
X			fprintf(stderr, "I can't find a newsgroup called %s.\n", conf);
X			exit(13);
X		}
X		if (minact == limit) {
X			fprintf(stderr, "Newsgroup %s is empty.\n", conf);
X			exit(14);
X		}
X		sprintf(tmp, "%s/%s/%s", msgdir, argv[2], NEWSRC);
X		if ((fp = fopen(tmp, "r")) != (FILE *) 0) {
X			char tmp2[512];
X
X			while (fgets(tmp, sizeof tmp, fp) != (char *) 0) {
X				sscanf(tmp, "%[^:]: %ld", tmp2, &cnt);
X				if (strcmp(tmp2, ng) == 0)
X					break;
X			}
X			if (strcmp(tmp2, ng) == 0)
X				minact = cnt + 1;
X			fclose(fp);
X		}
X		printf("News articles %d to %d\n", minact, limit);
X		for (cnt = 0, msg = minact; msg <= limit; msg++) {
X			if ((status = copynews(msgdir, conf, msg, argv[2])) > 0)
X				exit(status);
X			else if (status == 0)
X				cnt++;
X		}
X		printf("%ld news articles posted from %s to %s.\n", cnt, conf, argv[2]);
X		exit(cnt == 0? 9: 0);
X	}
X	msg = atol(++cp);
X	if (Index(argv[2], '/') != (char *) 0) {
X		fprintf(stderr, "Usage: uanews newsgroup[/article] conf\n");
X		exit(1);
X	}
X	if ((status = copynews(msgdir, conf, msg, argv[2])) == -1)
X		fprintf(stderr, "Couldn't read article %ld of %s\n", msg, conf);
X	exit(status);
X}
X
Xcopynews(base, ng, art, dest)
Xchar *base, *ng, *dest;
Xlong art; {
X	char path[512], temp[1024], ngpath[512];
X	int cnt, inhdr;
X	long newmsg;
X	FILE *ifp, *ofp;
X	struct stat sbuf;
X	char *cp, *dp;
X	
X	for (cp = ng, dp = ngpath; *cp != '\0'; cp++, dp++)
X		if (*cp == '.')
X			*dp = '/';
X		else
X			*dp = *cp;
X	sprintf(path, "%s/%s/%ld", NEWSDIR, ngpath, art);
X	if (stat(path, &sbuf) < 0)
X		return -1;	/* likely to be common... */
X	sprintf(path, "%s/%s/himsg", base, dest);
X	if ((ifp = fopen(path, "r")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: missing himsg...\n", dest);
X		return 2;
X	}
X	fgets(temp, sizeof temp, ifp);
X	fclose(ifp);
X	if ((newmsg = atol(temp)) < 0) {
X		fprintf(stderr, "Conference %s: invalid himsg...\n", dest);
X		return 2;
X	}
X	newmsg++;
X	sprintf(path, "%s/%s/%ld", NEWSDIR, ngpath, art);
X	if ((ifp = fopen(path, "r")) == (FILE *) 0) {
X		fprintf(stderr, "Are you certain that you have permission to access news?\n");
X		return 3;
X	}
X	sprintf(path, "%s/%s/%ld", base, dest, newmsg);
X	if (stat(path, &sbuf) == 0) {
X		fprintf(stderr, "Conference %s: corrupted (himsg incorrect)\n", dest);
X		fclose(ifp);
X		return 4;
X	}
X	if ((ofp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: check permissions (can't create message)\n", dest);
X		fclose(ifp);
X		return 5;
X	}
X	inhdr = 1;
X	while (fgets(temp, sizeof temp, ifp) != (char *) 0) {
X		if (temp[0] == '\n')
X			inhdr = 0;
X		if (inhdr) {
X			for (cnt = 0; headers[cnt] != NULL; cnt++)
X				if (strncmp(temp, headers[cnt], strlen(headers[cnt])) == 0)
X					break;
X			if (headers[cnt] == NULL)
X				continue;
X		}
X		fputs(temp, ofp);
X		if (ferror(ofp)) {
X			fprintf(stderr, "Write error on %s/%ld\n", dest, newmsg);
X			exit(5);	/* fatal! */
X		}
X	}
X	if (ferror(ifp)) {
X		fprintf(stderr, "Read error on %s/%ld\n", ng, art);
X		fclose(ifp);
X		fclose(ofp);
X		return 6;
X	}
X	fclose(ifp);
X	fclose(ofp);
X	sprintf(path, "%s/%s/himsg", base, dest);
X	if ((ifp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: check permissions on himsg...\n", dest);
X		return 2;
X	}
X	fprintf(ifp, "%ld\n", newmsg);
X	fclose(ifp);
X	sprintf(path, "/tmp/uan%05d", getpid());
X	if ((ofp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Who moved /tmp?!\n");
X		return 16;
X	}
X	sprintf(path, "%s/%s/%s", base, dest, NEWSRC);
X	dp = "-";
X	if ((ifp = fopen(path, "r")) != (FILE *) 0) {
X		while (fgets(temp, sizeof temp, ifp) != (char *) 0) {
X			for (cp = temp; *cp != '\n' && *cp != ':'; cp++)
X				;
X			if (*cp == '\n')
X				continue;	/* silent cleanup */
X			else
X				*cp = '\0';
X			if (strcmp(temp, ng) == 0) {
X				sprintf(temp, "%s: %ld\n", ng, art);
X				dp = "#";
X			}
X			else
X				*cp = ':';
X			fputs(temp, ofp);
X		}
X		fclose(ifp);
X	}
X	if (*dp != '#')
X		fprintf(ofp, "%s: %ld\n", ng, art);
X	fclose(ofp);
X	sprintf(path, "/tmp/uan%05d", getpid());
X	if ((ifp = fopen(path, "r")) == (FILE *) 0) {
X		fprintf(stderr, "Can't reopen temp file, aborting...\n");
X		return 16;
X	}
X	sprintf(path, "%s/%s/%s", base, dest, NEWSRC);
X	if ((ofp = fopen(path, "w")) == (FILE *) 0) {
X		fprintf(stderr, "Conference %s: can't update news link file (E:%d)\n", dest, errno);
X		return 17;
X	}
X	while (fgets(temp, sizeof temp, ifp) != (char *) 0)
X		fputs(temp, ofp);
X	fclose(ofp);
X	fclose(ifp);
X	sprintf(path, "/tmp/uan%05d", getpid());
X	unlink(path);	/* not a tragedy if this fails... */
X	return 0;
X}
--EOF:Utilities/uanews.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/udate.c"; then
	echo "File Utilities/udate.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/udate.c"
	esac
else
	newname="Utilities/udate.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/udate.c--' > "$newname"
X/*
X *	@(#)udate.c	1.1 (TDI) 7/18/86 21:10:38
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:38 by brandon
X *     Converted to SCCS 07/18/86 21:10:37
X *	@(#)Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:38 by brandon
X *     Converted to SCCS 07/18/86 21:10:37
X *
X *	@(#)This file is part of UNaXcess version 0.4.5.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:38 by brandon
X *     Converted to SCCS 07/18/86 21:10:37
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "@(#)udate.c	1.1 (TDI) 7/18/86 21:10:38";
Xstatic char _UAID_[]   = "@(#)UNaXcess version 0.4.5";
X#endif lint
X
Xmain() {
X	puts(longdate());
X}
--EOF:Utilities/udate.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/uwho.c"; then
	echo "File Utilities/uwho.c exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/uwho.c"
	esac
else
	newname="Utilities/uwho.c"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/uwho.c--' > "$newname"
X/*
X *	@(#)uwho.c	1.1 (TDI) 7/18/86 21:10:40
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:40 by brandon
X *     Converted to SCCS 07/18/86 21:10:39
X *	@(#)Copyright (C) 1984, 85, 86 by Brandon S. Allbery.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:40 by brandon
X *     Converted to SCCS 07/18/86 21:10:39
X *
X *	@(#)This file is part of UNaXcess version 0.4.5.
X *
X * Modification History:
X *
X *   Ver. 1.1 created 07/18/86 at 21:10:40 by brandon
X *     Converted to SCCS 07/18/86 21:10:39
X *
X *	Permission is hereby granted to copy and distribute this program
X *	freely.  Permission is NOT given to modify this program or distribute
X *	it at cost, except for charging a reasonable media/copying fee.
X */
X
X#ifndef lint
Xstatic char _FileID_[] = "@(#)uwho.c	1.1 (TDI) 7/18/86 21:10:40";
Xstatic char _UAID_[]   = "@(#)UNaXcess version 0.4.5";
X#endif lint
X
X#include <stdio.h>
X#include <pwd.h>
X#include <sys/types.h>
X#include <utmp.h>
X
X#ifndef NOAUTOPATH
Xstruct passwd *getpwuid();
X#endif  NOAUTOPATH
X
X#define TTYLIST "/etc/utmp"
X
Xmain(argc, argv)
Xchar **argv; {
X	int cnt, flg, users;
X	struct utmp user;
X	char tty[16];
X
X	if ((users = open(TTYLIST, "r")) < 0) {
X		fprintf(stderr, "%s: can't open %s\n", argv[0], TTYLIST);
X		exit(1);
X	}
X	flg = 0;
X	while (read(users, &user, sizeof user) > 0) {
X#ifdef SYS5
X		if (user.ut_type != USER_PROCESS)
X			continue;
X#else  SYS5
X		if (user.ut_name[0] == '\0')
X			continue;
X#endif SYS5
X		sprintf(tty, "/dev/%.*s", sizeof user.ut_line, user.ut_line);
X		if (argc < 2)
X			showme(tty);
X		else
X			for (cnt = 1; argv[cnt] != NULL; cnt++)
X				if (strcmp(&tty[5], argv[cnt]) == 0) {
X					showme(tty);
X					break;
X				}
X	}
X	exit(0);
X}
X
Xshowme(ttyf)
Xchar *ttyf;
X{
X	FILE *fp;
X	char line[1024];
X#ifndef NOAUTOPATH
X	static char home[1024] = "";
X#endif NOAUTOPATH
X
X#ifdef NOAUTOPATH
X	sprintf(line, "%s/%s", NOAUTOPATH, ttyf);
X#else
X	if (home[0] == '\0')
X		strcpy(home, getpwuid(geteuid())->pw_dir);
X	sprintf(line, "%s/%s", home, ttyf);
X#endif NOAUTOPATH
X	if ((fp = fopen(line, "r")) == NULL)	/* not in use on this tty */
X		return;
X	fgets(line, 1024, fp);
X	printf("%s: %s", ttyf, line);		/* line already has newline */
X	fclose(fp);
X}
--EOF:Utilities/uwho.c--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/install.sh"; then
	echo "File Utilities/install.sh exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/install.sh"
	esac
else
	newname="Utilities/install.sh"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/install.sh--' > "$newname"
Xecho ""
Xecho "UNaXcess V0.4.5 Installation Script"
Xecho "By Brandon S. Allbery"
Xecho ""
Xecho "You are free to copy, modify, etc. this installation script as much as you"
Xecho "wish; it's bound to come in handy if anyone on your system does programming."
Xecho "This script should run on most Unix-based systems.  If it doesn't, PLEASE let"
Xecho "me know at ...decvax!cwruecmp!ncoast!allbery."
Xecho ""
Xecho "I will be asking you for information as I install UNaXcess.  When I do, I'll"
Xecho "let you know by ending the question with two arrows, like this:  -> ->"
Xecho "When I do this, it's a signal for you to tell me something.  Usually, pressing"
Xecho "RETURN will do something reasonable."
Xecho ""
X:
X: Note to hackers -- the original idea for this script hails from lwall@sdcrdcf
X: but this script is entirely mine.  To see the original, ask anyone with rn
X: sources.
X:
X: Yes, the "-> ->" business is copped from Unify.  I sincerely doubt that it is
X: copyrighted, and it is fairly obvious.
X:
X
Xgrep NOAUTOPATH Makefile > /dev/null 2>&1
Xcase "$#" in
X0)	autopath=y
X	;;
X1)	autopath=n
X	UAHOME="`grep NOAUTOPATH Makefile | sed -n 's/.*[ 	]-DAUTOPATH=[^-A-Za-z\/.]*\([-A-Za-z\/.][-A-Za-z\/.]*\).*$/\1/p`"
X	if test ! -w "$UAHOME"; then
X		echo "I can't write in $UAHOME.  Please check your NOAUTOPATH definition"
X		echo "in the Makefile and recompile, or create the directory."
X		exit 1
X	fi
X	UAOWNER=${LOGNAME:-${USER:?'Who are you?'}}
X	;;
X2)	echo "I'm not being run from the UNaXcess distribution directory."
X	echo "Please re-run install.sh from the installation directory."
X	exit 1
X	;;
X*)	echo "Your grep does funny things.  You'll have to install UNaXcess by hand."
X	exit 1
X	;;
Xesac
Xcase $autopath in
Xy)	if test ! -w /etc/passwd; then
X		echo "I'm not running as root.  Please ask a system administrator to run this install"
X		echo "script as root, as I need to create directories and possibly even a user name."
X		exit 1
X	fi
X	: end of test for root.  This is about as portable as you get.
X	echo "Please enter the username of the owner of this UNaXcess system.  -> ->"
X	read UAOWNER
X	case "$UAOWNER" in
X	"")	echo "I hope you wanted to abort, because you just did."
X		exit 1
X	esac
X	if grep "^$UAOWNER:" /etc/passwd >/dev/null 2>&1; then
X		echo "I see $UAOWNER already exists.  Do you want to use him?  -> ->"
X		read yesno
X		case "$yesno" in
X		y*|Y*)	echo "Okay, we use $UAOWNER as the owner of UNaXcess."
X			;;
X		*)	echo "Then we'll start again from scratch."
X			exec sh Utilities/install.sh
X		esac
X	else
X		echo "I don't see a user named $UAOWNER on this system.  Should I create one?  -> ->"
X		read yesno
X		case "$yesno" in
X		y*|Y*)	echo "Okay, we make him."
X			;;
X		*)	echo "Then we'll start again from scratch."
X			exec sh Utilities/install.sh
X		esac
X		UAUID=`sed 's/^[^:]*:[^:]*:\([^:]*\):.*$/\1/' < /etc/passwd | sort -n | tail -1`
X		UAUID=`expr $UAUID + 1`
X		echo "I'm going to call $UAOWNER's home directory /usr/$UAOWNER."
X		echo "If you have a better idea, please tell me what it is.  -> ->"
X		read home
X		case "$home" in
X		"")	echo "Ok, we use /usr/$UAOWNER."
X			home=/usr/$UAOWNER
X		esac
X		if test -r $home; then
X			echo "It seems that this particular name's in use.  Let's try again."
X			exec sh Utilities/install.sh
X		fi
X		echo "$UAOWNER::$UAUID:1:UNaXcess Control Login:$home:" >> /etc/passwd
X		mkdir $home
X		chown $UAOWNER $home
X		echo "Now give $UAOWNER a password.  DON'T LEAVE IT UNPROTECTED!!!"
X		passwd $UAOWNER
X	fi
X	echo ""
X	UAHOME="`sed -n '/^'$UAOWNER':/s=^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*\$=\1=p' < /etc/passwd`"
X	;;
Xn)	;;
Xesac
X
Xecho "UNaXcess will be installed in $UAHOME.  Is this okay?  -> ->"
Xread yesno
Xcase "$yesno" in
Xy*|Y*)	echo "Then we'll proceed with the installation."
X	;;
X*)	echo "Please check /etc/passwd for $UAOWNER's home directory, and fix it."
X	echo "Then type 'sh Utilities/install.sh' to try installation again."
X	exit 1
Xesac
Xchmod 711 $UAHOME || echo "Please inspect the permissions on $UAHOME; they should be -rwx--x--x."
X: now we know the home and owner of UNaXcess
X
Xif test ! -d $UAHOME/msgdir; then
X	echo "Creating $UAHOME/msgdir..."
X	rm -rf $UAHOME/msgdir
X	mkdir $UAHOME/msgdir
X	chown $UAOWNER $UAHOME/msgdir
Xfi
Xif test ! -d $UAHOME/motd; then
X	echo "Creating $UAHOME/motd..."
X	rm -rf $UAHOME/motd
X	mkdir $UAHOME/motd
X	chown $UAOWNER $UAHOME/motd
Xfi
Xif test ! -d $UAHOME/library; then
X	echo "Creating $UAHOME/library..."
X	rm -rf $UAHOME/library
X	mkdir $UAHOME/library
X	chown $UAOWNER $UAHOME/library
Xfi
Xif test ! -d $UAHOME/uploads; then
X	echo "Creating $UAHOME/uploads..."
X	rm -rf $UAHOME/uploads
X	mkdir $UAHOME/uploads
X	chown $UAOWNER $UAHOME/uploads
Xfi
Xecho "Creating $UAHOME/Logfile..."
Xrm -f $UAHOME/Logfile
Xchown $UAOWNER $UAHOME/Logfile > $UAHOME/Logfile
Xif test ! -f $UAHOME/userind; then
X	echo "Creating $UAHOME/userind..."
X	rm -rf $UAHOME/userind
X	chown $UAOWNER $UAHOME/userind > $UAHOME/userind
Xfi
Xif test ! -d $UAHOME/msgdir/general; then
X	echo "Creating conference general..."
X	rm -rf $UAHOME/msgdir/general
X	mkdir $UAHOME/msgdir/general
X	chown $UAOWNER $UAHOME/msgdir/general
X	echo 1 > $UAHOME/msgdir/general/himsg
X	chown $UAOWNER $UAHOME/msgdir/general/himsg
X	cat << --general/1-- > $UAHOME/msgdir/general/1
XDate: `Utilities/udate`
XFrom: The UNaXcess System Operator
XTo: All
XSubject: This BBS
X
XWelcome to UNaXcess V0.04.04 -- a computer bulletin board system designed for
Xthe UNIX(tm) operating system.  You are using the ONLY BBS which is designed
Xto USE Unix's unique features to their fullest potential.
X
XThis conference is the general-purpose conference.  Use it for discussions
Xthat don't fit in any of the existing conferences.  But if it's liable to be
Xlarge, consider making a new conference for it.
X
XThe basic UNaXcess commands are:
X
X	r	Read messages.  You may specify a message number on the
X		command line, or you will be asked how to read messages.
X	
X	n	Read all new messages in all conferences.
X	
X	e	Enter a new message.  You can specify the recipient's
X		name on the command line, like "e John Doe".
X	
X	j	Join a different conference.  You can also create a new
X		conference with this command.  You can specify the new
X		conference on the command line:  "j discussion".
X	
X	g	Exit UNaXcess.
X	
X	f	Enter the File Section.  UNaXcess is capable of file
X		uploading and downloading with ASCII, Xmodem and Kermit
X		(not all maybe available on all systems).
X
XPress BREAK (or DEL or CONTROL C, depending on the system) to stop a command.
XPress CONTROL-\ (CONTROL plus backslash) for a fast logout.
X
X--general/1--
Xfi
Xif test ! -d $UAHOME/msgdir/guest; then
X	echo "Creating conference guest..."
X	rm -rf $UAHOME/msgdir/guest
X	mkdir $UAHOME/msgdir/guest
X	chown $UAOWNER $UAHOME/msgdir/guest
X	echo 1 > $UAHOME/msgdir/guest/himsg
X	chown $UAOWNER $UAHOME/msgdir/guest/himsg
X	cat << --guest/1-- > $UAHOME/msgdir/guest/1
XDate: `Utilities/udate`
XFrom: The UNaXcess System Operator
XTo: All
XSubject: This conference
X
XThis conference is for any and all users of UNaXcess.  ANYONE may post
Xmessages to the guest conference at any time.
X
X--guest/1--
Xfi
X: end of system files build, for the most part
X
Xecho "Where do you want the programs to go?  ENTER defaults to /usr/bin.  -> ->"
Xread BIN
Xcase "$BIN" in
X"")	echo "I'll use /usr/bin, then."
X	BIN=/bin
X	;;
X*)	echo "Ok, I'll put them in $BIN."
X	;;
Xesac
Xif test ! -d $BIN; then
X	echo "I can't find $BIN.  Please start over after you make it."
X	exit 1
Xfi
Xecho "What do you want to call UNaXcess?  ENTER defaults to ua.  -> ->"
Xread ua
Xcase "$ua" in
X"")	ua="ua"
Xesac
Xecho "What do you want to call the user lister?  ENTER defaults to uwho.  -> ->"
Xread uwho
Xcase "$uwho" in
X"")	uwho="uwho"
Xesac
Xecho "What do you want to call the date printer?  Enter defaults to udate.  -> ->"
Xread udate
Xcase "$udate" in
X"")	udate="udate"
Xesac
Xecho "Creating $BIN/$ua..."
Xcp ua $BIN/$ua
Xcase $autopath in
Xy)	chown $UAOWNER $BIN/$ua
X	chmod 4711 $BIN/$ua
X	;;
Xesac
Xecho "Creating $BIN/$udate..."
Xcp Utilities/udate $BIN/$udate
Xchown $UAOWNER $BIN/$udate
Xchmod 711 $BIN/$udate
Xecho "Creating $BIN/$uwho..."
Xcp Utilities/uwho $BIN/$uwho
Xcase $autopath in
Xy)	chown $UAOWNER $BIN/$uwho
X	chmod 4711 $BIN/$uwho
X	echo "Creating $UAHOME/mkconf..."
X	cp Utilities/mkconf $UAHOME/mkconf
X	chown root $UAHOME/mkconf
X	chmod 4711 $UAHOME/mkconf
X	;;
Xesac
X: end of binary installation
X
Xecho "What do you want to call the shell message poster?  ENTER defaults to upost."
Xecho "  -> ->"
Xread upost
Xcase "$upost" in
X"")	upost="upost"
Xesac
Xecho "Creating $BIN/$upost..."
Xsed -e "s;@UAOWNER@;${UAOWNER};" -e "s;@udate@;BIN/${udate};" < Utilities/upost.sh > $BIN/$upost
Xchown $UAOWNER $BIN/$upost
Xchmod 755 $BIN/$upost
Xecho "What do you want to call the shell bulletin poster?  ENTER defaults to umotd."
Xecho "  -> ->"
Xread umotd
Xcase "$umotd" in
X"")	umotd="umotd"
Xesac
Xecho "Creating $BIN/$umotd..."
Xsed -e "s;@UAOWNER@;${UAOWNER};" -e "s;@udate@;$BIN/${udate};" < Utilities/umotd.sh > $BIN/$umotd
Xchown $UAOWNER $BIN/$umotd
Xchmod 755 $BIN/$umotd
Xecho "What do you want to call the message mover?  ENTER defaults to mvmsg."
Xecho "  -> ->"
Xread mvmsg
Xcase "$mvmsg" in
X"")	mvmsg="mvmsg"
Xesac
Xecho "Creating $BIN/$mvmsg..."
Xcp Utilities/mvmsg $BIN/$mvmsg
Xchown $UAOWNER $BIN/$mvmsg
Xchmod 4700 $BIN/$mvmsg
Xecho "Do you want to install the USENET News Transfer Facility?  ENTER defaults"
Xecho " to NO.  -> ->"
Xread instnews
Xcase "$instnews" in
Xy*|Y*)	echo "What do you want to call the transfer program?  ENTER defaults to"
X	echo "uanews.  -> ->"
X	read uanews
X	case "$uanews" in
X	"")	uanews="uanews"
X	esac
X	echo "Creating $BIN/$uanews..."
X	cp Utilities/uanews $BIN/$uanews
X	case $autopath in
X	y)	chown $UAOWNER $BIN/$uanews
X		chmod 4700 $BIN/$uanews
X		;;
X	esac
Xesac
X: end of shell utilities installation
X
Xecho ""
Xecho "Now I'm going to create the runtime configuration file for UNaXcess.  This"
Xecho "file allows you to decide what features of UNaXcess are allowed in your BBS"
Xecho "system."
Xecho ""
Xecho "I suggest you read the UNaXcess README file before doing this, so you'll"
Xecho "know what I'm talking about."
Xecho ""
Xecho "Do you want to allow READ-ONLY conferences?  Press RETURN for YES.  -> ->"
Xread yesno
Xcase "$yesno" in
X""|y*|Y*)
X	readonly=YES
X	;;
X*)	readonly=NO
Xesac
Xecho "Do you want to allow RESTRICTED (X-Rated) conferences?  Press RETURN for NO."
Xecho "  -> ->"
Xread yesno
Xcase "$yesno" in
Xy*|Y*)
X	xrated=YES
X	;;
X*)	xrated=NO
Xesac
Xecho "What is the editor to be run?  The default is the internal editor.  -> ->"
Xread editor
Xcase "$editor" in
X"")	editor=ua-edit
Xesac
Xecho "What is the shell to be run by the COMMAND option?  The default is /bin/sh."
Xecho "  -> ->"
Xread shell
Xcase "$shell" in
X"")	shell=/bin/sh
Xesac
Xecho "Do you want to have UNaXcess check the user's shell and editor preferences"
Xecho "via the EDITOR and SHELL environment variables?  The default is YES.  -> ->"
Xread env
Xcase "$env" in
XN*|n*)	env=NO
X	;;
X*)	env=YES
Xesac
Xecho "What is the login name of the user who can't log directly into UNaXcess?"
Xecho "RETURN if all users can log in directly  -> ->"
Xread bbsuser
Xecho "What is the time limit on UnaXcess, in minutes?  -> ->"
Xread tlimit
Xcase "$tlimit" in
X"")	tlimit=0
Xesac
Xecho "What is the system operator's UNaXcess login to be?  RETURN for SYSOP  -> ->"
Xread sysop
Xcase "$sysop" in
X"")	sysop="sysop"
Xesac
Xecho "Do you want to allow private messages?  RETURN for YES  -> ->"
Xread private
Xcase "$private" in
XN*|n*)	private=NO
X	;;
X*)	private=YES
Xesac
Xecho "Do you want to enable logging?  RETURN for YES  -> ->"
Xread logging
Xcase "$logging" in
XN*|n*)	logging=NO
X	;;
X*)	logging=YES
Xesac
Xecho "Please specify one of the following choices:"
Xecho "    nopause     Don't pause after 16 lines of output"
Xecho "    ask         Ask each user whether he wants puses or not"
Xecho "    pause       Pause after 16 lines of output always"
Xecho "Please select one, or press RETURN for ASK:  -> ->"
Xread pauses
Xcase "$pauses" in
XN*|n*)	pauses=2
X	;;
XP*|p*)	pauses=0
X	;;
X*)	pauses=1
Xesac
Xecho "How many tries should a user get to log in?  RETURN for 3  -> ->"
Xread logtries
Xcase "$logtries" in
X"")	logtries=3
Xesac
Xecho ""
Xecho "Creating $UAHOME/ua-config..."
Xcat << --CONFIG-- > $UAHOME/ua-config
Xreadonly	$readonly
Xx-rated		$xrated
Xeditor		$editor
Xshell		$shell
Xread-env	$env
Xbbs-user	$bbsuser
Xtime-limit	$tlimit
Xsysop		"$sysop"
Xprivate-msgs	$private
Xlogging		$logging
Xbanner		""
Xlogin-msg	""
Xpauses		$pauses
Xlogin-tries	$logtries
X--CONFIG--
Xchown $UAOWNER $UAHOME/ua-config
Xchmod 644 $UAHOME/ua-config
Xecho ""
Xecho "You can edit the config file yourself to change these and other options."
X: end of config file generation
X
Xecho ""
Xif test ! -f $UAHOME/userfile; then
X	echo "Creating $UAHOME/userfile..."
X	rm -rf $UAHOME/userfile
X	cat << --USERFILE-- > $UAHOME/userfile
X$sysop::5::80:0:
Xnew::6::2:0:
Xguest::1::40:0:
X--USERFILE--
X	chown $UAOWNER $UAHOME/userfile
X	chmod 644 $UAHOME/userfile
Xfi
X: end of userfile installation
X
Xecho ""
Xif test ! -d $UAHOME/lock; then
X	echo "Making lock directory..."
X	rm -rf $UAHOME/lock
X	mkdir $UAHOME/lock
X	chown $UAOWNER $UAHOME/lock
X	chmod 777 $UAHOME/lock
Xfi
Xif test ! -r $UAHOME/directory; then
X	rm -rf $UAHOME/directory
X	today="`date | sed -e 's/^... \(...\)  *\([0-9][0-9]*\) [^ ][^ ]* 19\(..\)$/\1\/\2\/\3/'`"
X	today="`echo $today | sed -e s/Jan/1/ -e s/Feb/2/ -e s/Mar/3/ -e s/Apr/4/ -e s/May/5/ -e s/Jun/6/`"
X	today="`echo $today | sed -e s/Jul/7/ -e s/Aug/8/ -e s/Sep/9/ -e s/Oct/10/ -e s/Nov/11/ -e s/Dec/12/`"
X	echo "Creating $UAHOME/directory..."
X	cat << --LIBCATLG-- > $UAHOME/directory
XGENERAL file branch; $today by $sysop: General up/downloading
X--LIBCATLG--
X	chown $UAOWNER $UAHOME/directory
X	chmod 644 $UAHOME/directory
Xfi
Xif test ! -f $UAHOME/upload-log; then
X	rm -rf $UAHOME/upload-log
X	echo "Creating $UAHOME/upload-log..."
X	cp /dev/null $UAHOME/upload-log
X	chown $UAOWNER $UAHOME/upload-log
X	chmod 644 $UAHOME/upload-log
Xfi
X: end of directory installation
X
Xif test ! -f $UAHOME/NewMessage; then
X	echo ""
X	echo "I am going to create a simple new-user bulletin.  It is your job to change it"
X	echo "to say what you want it to say."
X	echo ""
X	echo "Creating $UAHOME/NewMessage..."
Xcat << --NEWMESSAGE-- > $UAHOME/NewMessage
X
XWelcome to the UNaXcess System, Copyright (C) 1984, 1985 by Brandon S. Allbery.
XThis UNaXcess was installed `Utilities/udate`.
X
X--NEWMESSAGE--
X	chown $UAOWNER $UAHOME/NewMessage
X	chmod 644 $UAHOME/NewMessage
Xfi
Xif test ! -f $UAHOME/motd/himotd; then
X	echo "Creating $UAHOME/motd/himotd..."
X	echo 0 > $UAHOME/motd/himotd
X	chown $UAOWNER $UAHOME/motd/himotd
X	chmod 644 $UAHOME/motd/himotd
Xfi
Xecho ""
Xecho "Now you must create the main bulletin.  I will run the $umotd program"
Xecho "for you -- you will simply enter the bulletin.  I hope you have EDITOR set"
Xecho "up correctly!"
Xecho ""
X$BIN/$umotd
X: end of bulletin installation
X
Xecho ""
Xecho "Congratulations!  You have just successfully installed the UNaXcess System."
Xecho "Before you use it, I suggest you put a password on the '$sysop' login,"
Xecho "so nobody else can make trouble with it."
Xecho ""
X$BIN/$udate
Xecho "UNaXcess Version 0.04.04 has been installed."
--EOF:Utilities/install.sh--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/s.install.sh"; then
	echo "File Utilities/s.install.sh exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/s.install.sh"
	esac
else
	newname="Utilities/s.install.sh"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/s.install.sh--' > "$newname"
Xh42197
Xs 00504/00000/00000
Xd D 1.1 86/07/18 21:10:41 brandon 1 0
Xc Converted to SCCS 07/18/86 21:10:41
Xe
Xu
XU
Xf b 
Xf q 0.4.5
Xf t UNaXcess
Xt
XT
XI 1
Xecho ""
Xecho "UNaXcess V%Q% Installation Script"
Xecho "By Brandon S. Allbery"
Xecho ""
Xecho "You are free to copy, modify, etc. this installation script as much as you"
Xecho "wish; it's bound to come in handy if anyone on your system does programming."
Xecho "This script should run on most Unix-based systems.  If it doesn't, PLEASE let"
Xecho "me know at ...decvax!cwruecmp!ncoast!allbery."
Xecho ""
Xecho "I will be asking you for information as I install UNaXcess.  When I do, I'll"
Xecho "let you know by ending the question with two arrows, like this:  -> ->"
Xecho "When I do this, it's a signal for you to tell me something.  Usually, pressing"
Xecho "RETURN will do something reasonable."
Xecho ""
X:
X: Note to hackers -- the original idea for this script hails from lwall@sdcrdcf
X: but this script is entirely mine.  To see the original, ask anyone with rn
X: sources.
X:
X: Yes, the "-> ->" business is copped from Unify.  I sincerely doubt that it is
X: copyrighted, and it is fairly obvious.
X:
X
Xgrep NOAUTOPATH Makefile > /dev/null 2>&1
Xcase "$#" in
X0)	autopath=y
X	;;
X1)	autopath=n
X	UAHOME="`grep NOAUTOPATH Makefile | sed -n 's/.*[ 	]-DAUTOPATH=[^-A-Za-z\/.]*\([-A-Za-z\/.][-A-Za-z\/.]*\).*$/\1/p`"
X	if test ! -w "$UAHOME"; then
X		echo "I can't write in $UAHOME.  Please check your NOAUTOPATH definition"
X		echo "in the Makefile and recompile, or create the directory."
X		exit 1
X	fi
X	UAOWNER=${LOGNAME:-${USER:?'Who are you?'}}
X	;;
X2)	echo "I'm not being run from the UNaXcess distribution directory."
X	echo "Please re-run install.sh from the installation directory."
X	exit 1
X	;;
X*)	echo "Your grep does funny things.  You'll have to install UNaXcess by hand."
X	exit 1
X	;;
Xesac
Xcase $autopath in
Xy)	if test ! -w /etc/passwd; then
X		echo "I'm not running as root.  Please ask a system administrator to run this install"
X		echo "script as root, as I need to create directories and possibly even a user name."
X		exit 1
X	fi
X	: end of test for root.  This is about as portable as you get.
X	echo "Please enter the username of the owner of this UNaXcess system.  -> ->"
X	read UAOWNER
X	case "$UAOWNER" in
X	"")	echo "I hope you wanted to abort, because you just did."
X		exit 1
X	esac
X	if grep "^$UAOWNER:" /etc/passwd >/dev/null 2>&1; then
X		echo "I see $UAOWNER already exists.  Do you want to use him?  -> ->"
X		read yesno
X		case "$yesno" in
X		y*|Y*)	echo "Okay, we use $UAOWNER as the owner of UNaXcess."
X			;;
X		*)	echo "Then we'll start again from scratch."
X			exec sh Utilities/install.sh
X		esac
X	else
X		echo "I don't see a user named $UAOWNER on this system.  Should I create one?  -> ->"
X		read yesno
X		case "$yesno" in
X		y*|Y*)	echo "Okay, we make him."
X			;;
X		*)	echo "Then we'll start again from scratch."
X			exec sh Utilities/install.sh
X		esac
X		UAUID=`sed 's/^[^:]*:[^:]*:\([^:]*\):.*$/\1/' < /etc/passwd | sort -n | tail -1`
X		UAUID=`expr $UAUID + 1`
X		echo "I'm going to call $UAOWNER's home directory /usr/$UAOWNER."
X		echo "If you have a better idea, please tell me what it is.  -> ->"
X		read home
X		case "$home" in
X		"")	echo "Ok, we use /usr/$UAOWNER."
X			home=/usr/$UAOWNER
X		esac
X		if test -r $home; then
X			echo "It seems that this particular name's in use.  Let's try again."
X			exec sh Utilities/install.sh
X		fi
X		echo "$UAOWNER::$UAUID:1:UNaXcess Control Login:$home:" >> /etc/passwd
X		mkdir $home
X		chown $UAOWNER $home
X		echo "Now give $UAOWNER a password.  DON'T LEAVE IT UNPROTECTED!!!"
X		passwd $UAOWNER
X	fi
X	echo ""
X	UAHOME="`sed -n '/^'$UAOWNER':/s=^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*\$=\1=p' < /etc/passwd`"
X	;;
Xn)	;;
Xesac
X
Xecho "UNaXcess will be installed in $UAHOME.  Is this okay?  -> ->"
Xread yesno
Xcase "$yesno" in
Xy*|Y*)	echo "Then we'll proceed with the installation."
X	;;
X*)	echo "Please check /etc/passwd for $UAOWNER's home directory, and fix it."
X	echo "Then type 'sh Utilities/install.sh' to try installation again."
X	exit 1
Xesac
Xchmod 711 $UAHOME || echo "Please inspect the permissions on $UAHOME; they should be -rwx--x--x."
X: now we know the home and owner of UNaXcess
X
Xif test ! -d $UAHOME/msgdir; then
X	echo "Creating $UAHOME/msgdir..."
X	rm -rf $UAHOME/msgdir
X	mkdir $UAHOME/msgdir
X	chown $UAOWNER $UAHOME/msgdir
Xfi
Xif test ! -d $UAHOME/motd; then
X	echo "Creating $UAHOME/motd..."
X	rm -rf $UAHOME/motd
X	mkdir $UAHOME/motd
X	chown $UAOWNER $UAHOME/motd
Xfi
Xif test ! -d $UAHOME/library; then
X	echo "Creating $UAHOME/library..."
X	rm -rf $UAHOME/library
X	mkdir $UAHOME/library
X	chown $UAOWNER $UAHOME/library
Xfi
Xif test ! -d $UAHOME/uploads; then
X	echo "Creating $UAHOME/uploads..."
X	rm -rf $UAHOME/uploads
X	mkdir $UAHOME/uploads
X	chown $UAOWNER $UAHOME/uploads
Xfi
Xecho "Creating $UAHOME/Logfile..."
Xrm -f $UAHOME/Logfile
Xchown $UAOWNER $UAHOME/Logfile > $UAHOME/Logfile
Xif test ! -f $UAHOME/userind; then
X	echo "Creating $UAHOME/userind..."
X	rm -rf $UAHOME/userind
X	chown $UAOWNER $UAHOME/userind > $UAHOME/userind
Xfi
Xif test ! -d $UAHOME/msgdir/general; then
X	echo "Creating conference general..."
X	rm -rf $UAHOME/msgdir/general
X	mkdir $UAHOME/msgdir/general
X	chown $UAOWNER $UAHOME/msgdir/general
X	echo 1 > $UAHOME/msgdir/general/himsg
X	chown $UAOWNER $UAHOME/msgdir/general/himsg
X	cat << --general/1-- > $UAHOME/msgdir/general/1
XDate: `Utilities/udate`
XFrom: The UNaXcess System Operator
XTo: All
XSubject: This BBS
X
XWelcome to UNaXcess V0.04.04 -- a computer bulletin board system designed for
Xthe UNIX(tm) operating system.  You are using the ONLY BBS which is designed
Xto USE Unix's unique features to their fullest potential.
X
XThis conference is the general-purpose conference.  Use it for discussions
Xthat don't fit in any of the existing conferences.  But if it's liable to be
Xlarge, consider making a new conference for it.
X
XThe basic UNaXcess commands are:
X
X	r	Read messages.  You may specify a message number on the
X		command line, or you will be asked how to read messages.
X	
X	n	Read all new messages in all conferences.
X	
X	e	Enter a new message.  You can specify the recipient's
X		name on the command line, like "e John Doe".
X	
X	j	Join a different conference.  You can also create a new
X		conference with this command.  You can specify the new
X		conference on the command line:  "j discussion".
X	
X	g	Exit UNaXcess.
X	
X	f	Enter the File Section.  UNaXcess is capable of file
X		uploading and downloading with ASCII, Xmodem and Kermit
X		(not all maybe available on all systems).
X
XPress BREAK (or DEL or CONTROL C, depending on the system) to stop a command.
XPress CONTROL-\ (CONTROL plus backslash) for a fast logout.
X
X--general/1--
Xfi
Xif test ! -d $UAHOME/msgdir/guest; then
X	echo "Creating conference guest..."
X	rm -rf $UAHOME/msgdir/guest
X	mkdir $UAHOME/msgdir/guest
X	chown $UAOWNER $UAHOME/msgdir/guest
X	echo 1 > $UAHOME/msgdir/guest/himsg
X	chown $UAOWNER $UAHOME/msgdir/guest/himsg
X	cat << --guest/1-- > $UAHOME/msgdir/guest/1
XDate: `Utilities/udate`
XFrom: The UNaXcess System Operator
XTo: All
XSubject: This conference
X
XThis conference is for any and all users of UNaXcess.  ANYONE may post
Xmessages to the guest conference at any time.
X
X--guest/1--
Xfi
X: end of system files build, for the most part
X
Xecho "Where do you want the programs to go?  ENTER defaults to /usr/bin.  -> ->"
Xread BIN
Xcase "$BIN" in
X"")	echo "I'll use /usr/bin, then."
X	BIN=/bin
X	;;
X*)	echo "Ok, I'll put them in $BIN."
X	;;
Xesac
Xif test ! -d $BIN; then
X	echo "I can't find $BIN.  Please start over after you make it."
X	exit 1
Xfi
Xecho "What do you want to call UNaXcess?  ENTER defaults to ua.  -> ->"
Xread ua
Xcase "$ua" in
X"")	ua="ua"
Xesac
Xecho "What do you want to call the user lister?  ENTER defaults to uwho.  -> ->"
Xread uwho
Xcase "$uwho" in
X"")	uwho="uwho"
Xesac
Xecho "What do you want to call the date printer?  Enter defaults to udate.  -> ->"
Xread udate
Xcase "$udate" in
X"")	udate="udate"
Xesac
Xecho "Creating $BIN/$ua..."
Xcp ua $BIN/$ua
Xcase $autopath in
Xy)	chown $UAOWNER $BIN/$ua
X	chmod 4711 $BIN/$ua
X	;;
Xesac
Xecho "Creating $BIN/$udate..."
Xcp Utilities/udate $BIN/$udate
Xchown $UAOWNER $BIN/$udate
Xchmod 711 $BIN/$udate
Xecho "Creating $BIN/$uwho..."
Xcp Utilities/uwho $BIN/$uwho
Xcase $autopath in
Xy)	chown $UAOWNER $BIN/$uwho
X	chmod 4711 $BIN/$uwho
X	echo "Creating $UAHOME/mkconf..."
X	cp Utilities/mkconf $UAHOME/mkconf
X	chown root $UAHOME/mkconf
X	chmod 4711 $UAHOME/mkconf
X	;;
Xesac
X: end of binary installation
X
Xecho "What do you want to call the shell message poster?  ENTER defaults to upost."
Xecho "  -> ->"
Xread upost
Xcase "$upost" in
X"")	upost="upost"
Xesac
Xecho "Creating $BIN/$upost..."
Xsed -e "s;@UAOWNER@;${UAOWNER};" -e "s;@udate@;BIN/${udate};" < Utilities/upost.sh > $BIN/$upost
Xchown $UAOWNER $BIN/$upost
Xchmod 755 $BIN/$upost
Xecho "What do you want to call the shell bulletin poster?  ENTER defaults to umotd."
Xecho "  -> ->"
Xread umotd
Xcase "$umotd" in
X"")	umotd="umotd"
Xesac
Xecho "Creating $BIN/$umotd..."
Xsed -e "s;@UAOWNER@;${UAOWNER};" -e "s;@udate@;$BIN/${udate};" < Utilities/umotd.sh > $BIN/$umotd
Xchown $UAOWNER $BIN/$umotd
Xchmod 755 $BIN/$umotd
Xecho "What do you want to call the message mover?  ENTER defaults to mvmsg."
Xecho "  -> ->"
Xread mvmsg
Xcase "$mvmsg" in
X"")	mvmsg="mvmsg"
Xesac
Xecho "Creating $BIN/$mvmsg..."
Xcp Utilities/mvmsg $BIN/$mvmsg
Xchown $UAOWNER $BIN/$mvmsg
Xchmod 4700 $BIN/$mvmsg
Xecho "Do you want to install the USENET News Transfer Facility?  ENTER defaults"
Xecho " to NO.  -> ->"
Xread instnews
Xcase "$instnews" in
Xy*|Y*)	echo "What do you want to call the transfer program?  ENTER defaults to"
X	echo "uanews.  -> ->"
X	read uanews
X	case "$uanews" in
X	"")	uanews="uanews"
X	esac
X	echo "Creating $BIN/$uanews..."
X	cp Utilities/uanews $BIN/$uanews
X	case $autopath in
X	y)	chown $UAOWNER $BIN/$uanews
X		chmod 4700 $BIN/$uanews
X		;;
X	esac
Xesac
X: end of shell utilities installation
X
Xecho ""
Xecho "Now I'm going to create the runtime configuration file for UNaXcess.  This"
Xecho "file allows you to decide what features of UNaXcess are allowed in your BBS"
Xecho "system."
Xecho ""
Xecho "I suggest you read the UNaXcess README file before doing this, so you'll"
Xecho "know what I'm talking about."
Xecho ""
Xecho "Do you want to allow READ-ONLY conferences?  Press RETURN for YES.  -> ->"
Xread yesno
Xcase "$yesno" in
X""|y*|Y*)
X	readonly=YES
X	;;
X*)	readonly=NO
Xesac
Xecho "Do you want to allow RESTRICTED (X-Rated) conferences?  Press RETURN for NO."
Xecho "  -> ->"
Xread yesno
Xcase "$yesno" in
Xy*|Y*)
X	xrated=YES
X	;;
X*)	xrated=NO
Xesac
Xecho "What is the editor to be run?  The default is the internal editor.  -> ->"
Xread editor
Xcase "$editor" in
X"")	editor=ua-edit
Xesac
Xecho "What is the shell to be run by the COMMAND option?  The default is /bin/sh."
Xecho "  -> ->"
Xread shell
Xcase "$shell" in
X"")	shell=/bin/sh
Xesac
Xecho "Do you want to have UNaXcess check the user's shell and editor preferences"
Xecho "via the EDITOR and SHELL environment variables?  The default is YES.  -> ->"
Xread env
Xcase "$env" in
XN*|n*)	env=NO
X	;;
X*)	env=YES
Xesac
Xecho "What is the login name of the user who can't log directly into UNaXcess?"
Xecho "RETURN if all users can log in directly  -> ->"
Xread bbsuser
Xecho "What is the time limit on UnaXcess, in minutes?  -> ->"
Xread tlimit
Xcase "$tlimit" in
X"")	tlimit=0
Xesac
Xecho "What is the system operator's UNaXcess login to be?  RETURN for SYSOP  -> ->"
Xread sysop
Xcase "$sysop" in
X"")	sysop="sysop"
Xesac
Xecho "Do you want to allow private messages?  RETURN for YES  -> ->"
Xread private
Xcase "$private" in
XN*|n*)	private=NO
X	;;
X*)	private=YES
Xesac
Xecho "Do you want to enable logging?  RETURN for YES  -> ->"
Xread logging
Xcase "$logging" in
XN*|n*)	logging=NO
X	;;
X*)	logging=YES
Xesac
Xecho "Please specify one of the following choices:"
Xecho "    nopause     Don't pause after 16 lines of output"
Xecho "    ask         Ask each user whether he wants puses or not"
Xecho "    pause       Pause after 16 lines of output always"
Xecho "Please select one, or press RETURN for ASK:  -> ->"
Xread pauses
Xcase "$pauses" in
XN*|n*)	pauses=2
X	;;
XP*|p*)	pauses=0
X	;;
X*)	pauses=1
Xesac
Xecho "How many tries should a user get to log in?  RETURN for 3  -> ->"
Xread logtries
Xcase "$logtries" in
X"")	logtries=3
Xesac
Xecho ""
Xecho "Creating $UAHOME/ua-config..."
Xcat << --CONFIG-- > $UAHOME/ua-config
Xreadonly	$readonly
Xx-rated		$xrated
Xeditor		$editor
Xshell		$shell
Xread-env	$env
Xbbs-user	$bbsuser
Xtime-limit	$tlimit
Xsysop		"$sysop"
Xprivate-msgs	$private
Xlogging		$logging
Xbanner		""
Xlogin-msg	""
Xpauses		$pauses
Xlogin-tries	$logtries
X--CONFIG--
Xchown $UAOWNER $UAHOME/ua-config
Xchmod 644 $UAHOME/ua-config
Xecho ""
Xecho "You can edit the config file yourself to change these and other options."
X: end of config file generation
X
Xecho ""
Xif test ! -f $UAHOME/userfile; then
X	echo "Creating $UAHOME/userfile..."
X	rm -rf $UAHOME/userfile
X	cat << --USERFILE-- > $UAHOME/userfile
X$sysop::5::80:0:
Xnew::6::2:0:
Xguest::1::40:0:
X--USERFILE--
X	chown $UAOWNER $UAHOME/userfile
X	chmod 644 $UAHOME/userfile
Xfi
X: end of userfile installation
X
Xecho ""
Xif test ! -d $UAHOME/lock; then
X	echo "Making lock directory..."
X	rm -rf $UAHOME/lock
X	mkdir $UAHOME/lock
X	chown $UAOWNER $UAHOME/lock
X	chmod 777 $UAHOME/lock
Xfi
Xif test ! -r $UAHOME/directory; then
X	rm -rf $UAHOME/directory
X	today="`date | sed -e 's/^... \(...\)  *\([0-9][0-9]*\) [^ ][^ ]* 19\(..\)$/\1\/\2\/\3/'`"
X	today="`echo $today | sed -e s/Jan/1/ -e s/Feb/2/ -e s/Mar/3/ -e s/Apr/4/ -e s/May/5/ -e s/Jun/6/`"
X	today="`echo $today | sed -e s/Jul/7/ -e s/Aug/8/ -e s/Sep/9/ -e s/Oct/10/ -e s/Nov/11/ -e s/Dec/12/`"
X	echo "Creating $UAHOME/directory..."
X	cat << --LIBCATLG-- > $UAHOME/directory
XGENERAL file branch; $today by $sysop: General up/downloading
X--LIBCATLG--
X	chown $UAOWNER $UAHOME/directory
X	chmod 644 $UAHOME/directory
Xfi
Xif test ! -f $UAHOME/upload-log; then
X	rm -rf $UAHOME/upload-log
X	echo "Creating $UAHOME/upload-log..."
X	cp /dev/null $UAHOME/upload-log
X	chown $UAOWNER $UAHOME/upload-log
X	chmod 644 $UAHOME/upload-log
Xfi
X: end of directory installation
X
Xif test ! -f $UAHOME/NewMessage; then
X	echo ""
X	echo "I am going to create a simple new-user bulletin.  It is your job to change it"
X	echo "to say what you want it to say."
X	echo ""
X	echo "Creating $UAHOME/NewMessage..."
Xcat << --NEWMESSAGE-- > $UAHOME/NewMessage
X
XWelcome to the UNaXcess System, Copyright (C) 1984, 1985 by Brandon S. Allbery.
XThis UNaXcess was installed `Utilities/udate`.
X
X--NEWMESSAGE--
X	chown $UAOWNER $UAHOME/NewMessage
X	chmod 644 $UAHOME/NewMessage
Xfi
Xif test ! -f $UAHOME/motd/himotd; then
X	echo "Creating $UAHOME/motd/himotd..."
X	echo 0 > $UAHOME/motd/himotd
X	chown $UAOWNER $UAHOME/motd/himotd
X	chmod 644 $UAHOME/motd/himotd
Xfi
Xecho ""
Xecho "Now you must create the main bulletin.  I will run the $umotd program"
Xecho "for you -- you will simply enter the bulletin.  I hope you have EDITOR set"
Xecho "up correctly!"
Xecho ""
X$BIN/$umotd
X: end of bulletin installation
X
Xecho ""
Xecho "Congratulations!  You have just successfully installed the UNaXcess System."
Xecho "Before you use it, I suggest you put a password on the '$sysop' login,"
Xecho "so nobody else can make trouble with it."
Xecho ""
X$BIN/$udate
Xecho "UNaXcess Version 0.04.04 has been installed."
XE 1
--EOF:Utilities/s.install.sh--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/s.umotd.sh"; then
	echo "File Utilities/s.umotd.sh exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/s.umotd.sh"
	esac
else
	newname="Utilities/s.umotd.sh"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/s.umotd.sh--' > "$newname"
Xh04092
Xs 00027/00000/00000
Xd D 1.1 86/07/18 21:10:44 brandon 1 0
Xc Converted to SCCS 07/18/86 21:10:43
Xe
Xu
XU
Xf b 
Xf q 0.4.5
Xf t UNaXcess
Xt
XT
XI 1
X:
X: "%W% (TDI) %G% %U%"
X: "%Z%Copyright (C) 1984, 85, 86 by Brandon S. Allbery."
X:
X: "%Z%This file is part of %Y% version %Q%."
X:
X: "Permission is hereby granted to copy and distribute this program"
X: "freely.  Permission is NOT given to modify this program or distribute"
X: "it at cost, except for charging a reasonable media/copying fee."
X:
X
XUADIR="`sed -n 's/^@UAOWNER@:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):[^:]*$/\1/p' < /etc/passwd`"
X
Xmsgnum=`cat $UADIR/motd/himotd`
Xcase "$msgnum" in
X[0-9]*)	;;
X*)	echo "$msgnum" >&2
X	exit 1
Xesac
Xmsgnum=`expr $msgnum + 1`
Xif echo "UNaXcess V0.04.04 -- `@udate@`
X" > $UADIR/motd/$msgnum 2>/dev/null
Xthen	${EDITOR-vi} $UADIR/motd/$msgnum
X	echo $msgnum > $UADIR/motd/himotd
Xelse	echo "$0: could not make new bulletin $msgnum"
X	exit 1
Xfi
XE 1
--EOF:Utilities/s.umotd.sh--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/s.upost.sh"; then
	echo "File Utilities/s.upost.sh exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/s.upost.sh"
	esac
else
	newname="Utilities/s.upost.sh"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/s.upost.sh--' > "$newname"
Xh12690
Xs 00031/00000/00000
Xd D 1.1 86/07/18 21:10:46 brandon 1 0
Xc Converted to SCCS 07/18/86 21:10:45
Xe
Xu
XU
Xf b 
Xf q 0.4.5
Xf t UNaXcess
Xt
XT
XI 1
X:
X: "%W% (TDI) %G% %U%"
X: "%Z%Copyright (C) 1984, 85, 86 by Brandon S. Allbery."
X:
X: "%Z%This file is part of %Y% version %Q%."
X:
X: "Permission is hereby granted to copy and distribute this program"
X: "freely.  Permission is NOT given to modify this program or distribute"
X: "it at cost, except for charging a reasonable media/copying fee."
X:
X
XUADIR="`sed -n 's/^@UAOWNER@:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):[^:]*$/\1/p' < /etc/passwd`"
X
Xconf=$1; shift
Xmsgnum=`cat $UADIR/msgdir/$conf/himsg`
Xcase "$msgnum" in
X[0-9]*)	;;
X*)	echo "$msgnum" >&2
X	exit 1
Xesac
Xmsgnum=`expr $msgnum + 1`
Xif echo "Date: `@udate@`
XFrom: Message Posting Daemon <${LOGNAME-daemon>
XTo: All
XSubject: $*
X" > $UADIR/msgdir/$conf/$msgnum 2>/dev/null
Xthen	cat >> $UADIR/msgdir/$conf/$msgnum
X	echo $msgnum > $UADIR/msgdir/$conf/himsg
Xelse	echo "$0: could not make new message $msgnum in $conf"
X	exit 1
Xfi
XE 1
--EOF:Utilities/s.upost.sh--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/umotd.sh"; then
	echo "File Utilities/umotd.sh exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/umotd.sh"
	esac
else
	newname="Utilities/umotd.sh"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/umotd.sh--' > "$newname"
X:
X: "@(#)umotd.sh	1.1 (TDI) 7/18/86 21:10:44"
X: "@(#)Copyright (C) 1984, 85, 86 by Brandon S. Allbery."
X:
X: "@(#)This file is part of UNaXcess version 0.4.5."
X:
X: "Permission is hereby granted to copy and distribute this program"
X: "freely.  Permission is NOT given to modify this program or distribute"
X: "it at cost, except for charging a reasonable media/copying fee."
X:
X
XUADIR="`sed -n 's/^@UAOWNER@:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):[^:]*$/\1/p' < /etc/passwd`"
X
Xmsgnum=`cat $UADIR/motd/himotd`
Xcase "$msgnum" in
X[0-9]*)	;;
X*)	echo "$msgnum" >&2
X	exit 1
Xesac
Xmsgnum=`expr $msgnum + 1`
Xif echo "UNaXcess V0.04.04 -- `@udate@`
X" > $UADIR/motd/$msgnum 2>/dev/null
Xthen	${EDITOR-vi} $UADIR/motd/$msgnum
X	echo $msgnum > $UADIR/motd/himotd
Xelse	echo "$0: could not make new bulletin $msgnum"
X	exit 1
Xfi
--EOF:Utilities/umotd.sh--
fi

if test ! -d "Utilities"; then
	echo "shx - Utilities (directory)"
	mkdir "Utilities"
fi
if test -r "Utilities/upost.sh"; then
	echo "File Utilities/upost.sh exists.  Enter new name or RETURN to skip.  (. to replace.)"
	read newname
	case "$newname" in
	".")	newname="Utilities/upost.sh"
	esac
else
	newname="Utilities/upost.sh"
fi
if test -z "$newname"; then
	echo "shx - $newname (skipped)"
else
	case "$newname" in
	"$sfile")
		echo "shx - $sfile (as $newname)"
		;;
	*)	echo "shx - $newname"
	esac
	sed 's/^X//' << '--EOF:Utilities/upost.sh--' > "$newname"
X:
X: "@(#)upost.sh	1.1 (TDI) 7/18/86 21:10:46"
X: "@(#)Copyright (C) 1984, 85, 86 by Brandon S. Allbery."
X:
X: "@(#)This file is part of UNaXcess version 0.4.5."
X:
X: "Permission is hereby granted to copy and distribute this program"
X: "freely.  Permission is NOT given to modify this program or distribute"
X: "it at cost, except for charging a reasonable media/copying fee."
X:
X
XUADIR="`sed -n 's/^@UAOWNER@:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):[^:]*$/\1/p' < /etc/passwd`"
X
Xconf=$1; shift
Xmsgnum=`cat $UADIR/msgdir/$conf/himsg`
Xcase "$msgnum" in
X[0-9]*)	;;
X*)	echo "$msgnum" >&2
X	exit 1
Xesac
Xmsgnum=`expr $msgnum + 1`
Xif echo "Date: `@udate@`
XFrom: Message Posting Daemon <${LOGNAME-daemon>
XTo: All
XSubject: $*
X" > $UADIR/msgdir/$conf/$msgnum 2>/dev/null
Xthen	cat >> $UADIR/msgdir/$conf/$msgnum
X	echo $msgnum > $UADIR/msgdir/$conf/himsg
Xelse	echo "$0: could not make new message $msgnum in $conf"
X	exit 1
Xfi
--EOF:Utilities/upost.sh--
fi

echo "End of archive."
exit 0


-- 
  ---------------- /--/	Brandon S. Allbery		UUCP: decvax!cwruecmp!
 /              / /|\/	Tridelta Industries, Inc.        ncoast!tdi2!brandon
----    -------- /-++	7350 Corporate Blvd.		PHONE: +1 216 974 9210
   /   / /---,  ----	Mentor, Ohio 44060		SYSOP: UNaXcess/ncoast
  /   / /    / /  /	     -- HOME --			 (216) 781-6201 24 hrs.
 /   / /    / /  /	6615 Center St. Apt. A1-105	ARPA:  ncoast!allbery%
----  -----~ ----	Mentor, Ohio 44060-4101		 case.CSNET@csnet-relay