xref: /illumos-gate/usr/src/cmd/bnu/uustat.c (revision 3b296559)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23d7c57852SGary Mills  * Copyright 2017 Gary Mills
24462be471Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
28462be471Sceastha /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
29462be471Sceastha /*	  All Rights Reserved  	*/
30462be471Sceastha 
317c478bd9Sstevel@tonic-gate #include <time.h>
327c478bd9Sstevel@tonic-gate #include "uucp.h"
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	V7
357c478bd9Sstevel@tonic-gate #define O_RDONLY	0
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate #define KILLMSG "the system administrator has killed job"
387c478bd9Sstevel@tonic-gate #define USAGE1	"[-q] | [-m] | [-k JOB [-n]] | [-r JOB [-n]] | [-p]"
397c478bd9Sstevel@tonic-gate #define USAGE2	"[-a] [-s SYSTEM [-j]] [-u USER] [-S STATE]"
407c478bd9Sstevel@tonic-gate #define USAGE3  "-t SYSTEM [-d number] [-c]"
417c478bd9Sstevel@tonic-gate #define LOCK "LCK.."
427c478bd9Sstevel@tonic-gate #define STST_MAX	132
437c478bd9Sstevel@tonic-gate #define MAXDATE		12
447c478bd9Sstevel@tonic-gate #define MINTIME		60
457c478bd9Sstevel@tonic-gate #define MINUTES		60
467c478bd9Sstevel@tonic-gate #define CHAR		"a"
477c478bd9Sstevel@tonic-gate #define MAXSTATE	4
487c478bd9Sstevel@tonic-gate /* #include "logs.h" */
497c478bd9Sstevel@tonic-gate struct m {
507c478bd9Sstevel@tonic-gate 	char	mach[15];		/* machine name */
517c478bd9Sstevel@tonic-gate 	char	locked;
527c478bd9Sstevel@tonic-gate 	int	ccount, xcount;
537c478bd9Sstevel@tonic-gate 	int	count, type;
547c478bd9Sstevel@tonic-gate 	long	retrytime;
557c478bd9Sstevel@tonic-gate 	time_t lasttime;
567c478bd9Sstevel@tonic-gate 	short	c_age;			/* age of oldest C. file */
577c478bd9Sstevel@tonic-gate 	short	x_age;			/* age of oldest X. file */
587c478bd9Sstevel@tonic-gate 	char	stst[STST_MAX];
597c478bd9Sstevel@tonic-gate } M[UUSTAT_TBL+2];
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate struct userdate {
637c478bd9Sstevel@tonic-gate 	char uhour[3];
647c478bd9Sstevel@tonic-gate 	char umin[3];
657c478bd9Sstevel@tonic-gate 	char lhour[3];
667c478bd9Sstevel@tonic-gate 	char lmin[3];
677c478bd9Sstevel@tonic-gate };
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate struct userdate userformat;
7055fea89dSDan Cross struct userdate *friendlyptr = &userformat;
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate extern long atol();
737c478bd9Sstevel@tonic-gate static int whattodo();
747c478bd9Sstevel@tonic-gate static int readperf();
757c478bd9Sstevel@tonic-gate static void queuetime();
767c478bd9Sstevel@tonic-gate static void xfertime();
777c478bd9Sstevel@tonic-gate static char * gmt();
787c478bd9Sstevel@tonic-gate static char * gmts();
797c478bd9Sstevel@tonic-gate static void errortn();
807c478bd9Sstevel@tonic-gate static void friendlytime();
817c478bd9Sstevel@tonic-gate static void complete();
827c478bd9Sstevel@tonic-gate static int state();
837c478bd9Sstevel@tonic-gate static int gnameflck();
84462be471Sceastha static void kprocessC();
85462be471Sceastha static int convert();
867c478bd9Sstevel@tonic-gate void uprocessC(), printit(), docalc(), procState();
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate static short State, Queued, Running, Complete, Interrupted;
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate static char mailmsg[BUFSIZ];
917c478bd9Sstevel@tonic-gate static char outbuf[BUFSIZ+1];
927c478bd9Sstevel@tonic-gate static int count;
937c478bd9Sstevel@tonic-gate static short jobcount;
947c478bd9Sstevel@tonic-gate static short execute;
957c478bd9Sstevel@tonic-gate static char lowerlimit[MAXDATE+1], upperlimit[MAXDATE+1];
967c478bd9Sstevel@tonic-gate static float totalque, totalxfer;
977c478bd9Sstevel@tonic-gate static long totaljob, totalbytes;
987c478bd9Sstevel@tonic-gate static long inputsecs;
997c478bd9Sstevel@tonic-gate #ifdef ATTSV
1007c478bd9Sstevel@tonic-gate extern void qsort();		/* qsort(3) and comparison test */
1017c478bd9Sstevel@tonic-gate #endif /* ATTSV */
1027c478bd9Sstevel@tonic-gate int sortcnt = -1;
1037c478bd9Sstevel@tonic-gate extern int machcmp();
1047c478bd9Sstevel@tonic-gate extern int _age();		/* find the age of a file */
10555fea89dSDan Cross static long calcnum;
1067c478bd9Sstevel@tonic-gate extern char Jobid[];	/* jobid for status or kill option */
1077c478bd9Sstevel@tonic-gate short Kill;		/*  == 1 if -k specified */
1087c478bd9Sstevel@tonic-gate short Rejuvenate;	/*  == 1 for -r specified */
1097c478bd9Sstevel@tonic-gate short Uopt;		/*  == 1 if -u option specified */
1107c478bd9Sstevel@tonic-gate short Sysopt;		/*  == 1 if -s option specified */
1117c478bd9Sstevel@tonic-gate static short Calctime;   /*  == 1 if -t parameter set */
1127c478bd9Sstevel@tonic-gate short Summary;		/*  == 1 if -q or -m is specified */
1137c478bd9Sstevel@tonic-gate short Queue;		/*  == 1 if -q option set - queue summary */
1147c478bd9Sstevel@tonic-gate short Machines;		/*  == 1 if -m option set - machines summary */
1157c478bd9Sstevel@tonic-gate short Psopt;		/*  == 1 if -p option set - output "ps" of LCK pids */
1167c478bd9Sstevel@tonic-gate static short Window;    /*  == 1 if -d parameter set with -t option */
1177c478bd9Sstevel@tonic-gate static short nonotf;    /*  == 1 if -n parameter set with -k option */
1187c478bd9Sstevel@tonic-gate short avgqueue;		/*  == 1 if -c parameter set with -t option */
1197c478bd9Sstevel@tonic-gate short avgxfer;		/*  will be set to 1 if -c not specified    */
1207c478bd9Sstevel@tonic-gate short Jobcount;		/* == 1 if -j parameter set with -s option */
1217c478bd9Sstevel@tonic-gate char f[NAMESIZE];
1227c478bd9Sstevel@tonic-gate 
123462be471Sceastha int
main(int argc,char * argv[],char ** envp)124*3b296559SToomas Soome main(int argc, char *argv[], char **envp)
1257c478bd9Sstevel@tonic-gate {
1267c478bd9Sstevel@tonic-gate 	struct m *m, *machine();
1277c478bd9Sstevel@tonic-gate 	DIR *spooldir, *subdir, *machdir, *gradedir;
1287c478bd9Sstevel@tonic-gate 	char *str, *rindex();
1297c478bd9Sstevel@tonic-gate 	char subf[256], gradef[256];
1307c478bd9Sstevel@tonic-gate 	char *c, lckdir[BUFSIZ];
1317c478bd9Sstevel@tonic-gate 	char buf[BUFSIZ];
1327c478bd9Sstevel@tonic-gate 	char chkname[MAXFULLNAME];
1337c478bd9Sstevel@tonic-gate 	char *vec[7];
1347c478bd9Sstevel@tonic-gate 	int i, chkid;
1357c478bd9Sstevel@tonic-gate 	char fullpath[MAXFULLNAME];
1367c478bd9Sstevel@tonic-gate 	long temp;
13755fea89dSDan Cross 
1387c478bd9Sstevel@tonic-gate 	char arglist[MAXSTATE+1];
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 	/* Set locale environment variables local definitions */
1417c478bd9Sstevel@tonic-gate 	(void) setlocale(LC_ALL, "");
1427c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN)	/* Should be defined by cc -D */
1437c478bd9Sstevel@tonic-gate #define	TEXT_DOMAIN "SYS_TEST"	/* Use this only if it wasn't */
1447c478bd9Sstevel@tonic-gate #endif
1457c478bd9Sstevel@tonic-gate 	(void) textdomain(TEXT_DOMAIN);
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 	User[0] = '\0';
1487c478bd9Sstevel@tonic-gate 	Rmtname[0] = '\0';
1497c478bd9Sstevel@tonic-gate 	Jobid[0] = '\0';
1507c478bd9Sstevel@tonic-gate 	Psopt=Machines=Summary=Queue=Kill=Rejuvenate=Uopt=Sysopt=Jobcount=0;
1517c478bd9Sstevel@tonic-gate 	execute=avgqueue=avgxfer=Calctime=Window=0;
1527c478bd9Sstevel@tonic-gate 	jobcount=nonotf=0;
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 	/* set calcnum to default time in minutes */
1557c478bd9Sstevel@tonic-gate 	calcnum=MINTIME;
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate 	(void) strcpy(Progname, "uustat");
1587c478bd9Sstevel@tonic-gate 	Uid = getuid();
1597c478bd9Sstevel@tonic-gate 	Euid = geteuid();
1607c478bd9Sstevel@tonic-gate 	guinfo(Uid, Loginuser);
1617c478bd9Sstevel@tonic-gate 	uucpname(Myname);
1627c478bd9Sstevel@tonic-gate 	while ((i = getopt(argc, argv, "acjk:mnpr:qs:u:x:t:d:S:")) != EOF) {
1637c478bd9Sstevel@tonic-gate 		switch(i){
1647c478bd9Sstevel@tonic-gate 		case 'a':
1657c478bd9Sstevel@tonic-gate 			Sysopt = 1;
1667c478bd9Sstevel@tonic-gate 			break;
1677c478bd9Sstevel@tonic-gate 		case 'c':
1687c478bd9Sstevel@tonic-gate 			avgqueue = 1;
1697c478bd9Sstevel@tonic-gate 			break;
1707c478bd9Sstevel@tonic-gate 		case 'd':
1717c478bd9Sstevel@tonic-gate 			Window = 1;
1727c478bd9Sstevel@tonic-gate 			calcnum = atoi(optarg);
1737c478bd9Sstevel@tonic-gate 			if (calcnum <= 0)
1747c478bd9Sstevel@tonic-gate 				calcnum = MINTIME;
1757c478bd9Sstevel@tonic-gate 			break;
1767c478bd9Sstevel@tonic-gate 		case 'k':
1777c478bd9Sstevel@tonic-gate 			(void) strncpy(Jobid, optarg, NAMESIZE);
1787c478bd9Sstevel@tonic-gate 			Jobid[NAMESIZE-1] = '\0';
1797c478bd9Sstevel@tonic-gate 			Kill = 1;
1807c478bd9Sstevel@tonic-gate 			break;
1817c478bd9Sstevel@tonic-gate 		case 'j':
1827c478bd9Sstevel@tonic-gate 			Jobcount = 1;
1837c478bd9Sstevel@tonic-gate 			break;
1847c478bd9Sstevel@tonic-gate 		case 'm':
1857c478bd9Sstevel@tonic-gate 			Machines = Summary = 1;
1867c478bd9Sstevel@tonic-gate 			break;
1877c478bd9Sstevel@tonic-gate 		case 'n':
1887c478bd9Sstevel@tonic-gate 			nonotf = 1;
1897c478bd9Sstevel@tonic-gate 			break;
1907c478bd9Sstevel@tonic-gate 		case 'p':
1917c478bd9Sstevel@tonic-gate 			Psopt = 1;
1927c478bd9Sstevel@tonic-gate 			break;
1937c478bd9Sstevel@tonic-gate 		case 'r':
1947c478bd9Sstevel@tonic-gate 			(void) strncpy(Jobid, optarg, NAMESIZE);
1957c478bd9Sstevel@tonic-gate 			Jobid[NAMESIZE-1] = '\0';
1967c478bd9Sstevel@tonic-gate 			Rejuvenate = 1;
1977c478bd9Sstevel@tonic-gate 			break;
1987c478bd9Sstevel@tonic-gate 		case 'q':
1997c478bd9Sstevel@tonic-gate 			Queue = Summary = 1;
2007c478bd9Sstevel@tonic-gate 			break;
2017c478bd9Sstevel@tonic-gate 		case 's':
2027c478bd9Sstevel@tonic-gate 			(void) strncpy(Rmtname, optarg, MAXBASENAME);
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate 			Rmtname[MAXBASENAME] = '\0';
2057c478bd9Sstevel@tonic-gate 			if (versys(Rmtname)) {
2067c478bd9Sstevel@tonic-gate 				fprintf(stderr, gettext("Invalid system\n"));
2077c478bd9Sstevel@tonic-gate 				exit(1);
2087c478bd9Sstevel@tonic-gate 			}
2097c478bd9Sstevel@tonic-gate 			Sysopt = 1;
2107c478bd9Sstevel@tonic-gate 			break;
2117c478bd9Sstevel@tonic-gate 		case 't':
2127c478bd9Sstevel@tonic-gate 			Calctime = 1;
2137c478bd9Sstevel@tonic-gate 			(void) strncpy(Rmtname, optarg, MAXBASENAME);
2147c478bd9Sstevel@tonic-gate 			Rmtname[MAXBASENAME] = '\0';
2157c478bd9Sstevel@tonic-gate 			if (versys(Rmtname)) {
2167c478bd9Sstevel@tonic-gate 				fprintf(stderr, gettext("Invalid system\n"));
2177c478bd9Sstevel@tonic-gate 				exit(1);
2187c478bd9Sstevel@tonic-gate 			}
2197c478bd9Sstevel@tonic-gate 			break;
2207c478bd9Sstevel@tonic-gate 		case 'u':
2217c478bd9Sstevel@tonic-gate 			(void) strncpy(User, optarg, 8);
2227c478bd9Sstevel@tonic-gate 			User[8] = '\0';
2237c478bd9Sstevel@tonic-gate 			if(gninfo(User, &chkid, chkname)) {
2247c478bd9Sstevel@tonic-gate 				fprintf(stderr, gettext("Invalid user\n"));
2257c478bd9Sstevel@tonic-gate 				exit(1);
2267c478bd9Sstevel@tonic-gate 			}
2277c478bd9Sstevel@tonic-gate 			Uopt = 1;
2287c478bd9Sstevel@tonic-gate 			execute = 1;
2297c478bd9Sstevel@tonic-gate 			break;
2307c478bd9Sstevel@tonic-gate 		case 'x':
2317c478bd9Sstevel@tonic-gate 			Debug = atoi(optarg);
2327c478bd9Sstevel@tonic-gate 			if (Debug <= 0)
2337c478bd9Sstevel@tonic-gate 				Debug = 1;
2347c478bd9Sstevel@tonic-gate 			break;
2357c478bd9Sstevel@tonic-gate 		case 'S':
2367c478bd9Sstevel@tonic-gate 			if (strlen(optarg) > sizeof (arglist)) {
2377c478bd9Sstevel@tonic-gate 				errortn();
2387c478bd9Sstevel@tonic-gate 				exit(1);
2397c478bd9Sstevel@tonic-gate 			}
2407c478bd9Sstevel@tonic-gate 			State = 1;
2417c478bd9Sstevel@tonic-gate 			(void) strlcpy(arglist, optarg, sizeof (arglist));
2427c478bd9Sstevel@tonic-gate 			procState(arglist);
2437c478bd9Sstevel@tonic-gate 			break;
2447c478bd9Sstevel@tonic-gate 		default:
24555fea89dSDan Cross 			errortn();
2467c478bd9Sstevel@tonic-gate 			exit(1);
2477c478bd9Sstevel@tonic-gate 		}
2487c478bd9Sstevel@tonic-gate 	}
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 	if (argc != optind) {
2517c478bd9Sstevel@tonic-gate 		errortn();
2527c478bd9Sstevel@tonic-gate 		exit(1);
2537c478bd9Sstevel@tonic-gate 	}
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate 	DEBUG(9, "Progname (%s): STARTED\n", Progname);
2567c478bd9Sstevel@tonic-gate 	DEBUG(9, "User=%s, ", User);
2577c478bd9Sstevel@tonic-gate 	DEBUG(9, "Loginuser=%s, ", Loginuser);
2587c478bd9Sstevel@tonic-gate 	DEBUG(9, "Jobid=%s, ", Jobid);
2597c478bd9Sstevel@tonic-gate 	DEBUG(9, "Rmtname=%s\n", Rmtname);
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 	/* -j only allowed with -s */
2627c478bd9Sstevel@tonic-gate 	if (Jobcount && !Sysopt)
2637c478bd9Sstevel@tonic-gate 		{
2647c478bd9Sstevel@tonic-gate 		errortn();
2657c478bd9Sstevel@tonic-gate 		exit(1);
2667c478bd9Sstevel@tonic-gate 		}
2677c478bd9Sstevel@tonic-gate        if ((Calctime + Psopt + Machines + Queue + Kill + Rejuvenate + (Uopt|Sysopt |State)) >1) {
2687c478bd9Sstevel@tonic-gate 		/* only -u, -S and -s can be used together */
2697c478bd9Sstevel@tonic-gate 		errortn();
2707c478bd9Sstevel@tonic-gate 		exit(1);
2717c478bd9Sstevel@tonic-gate 	}
2727c478bd9Sstevel@tonic-gate 	if ((avgqueue | Window) & (!Calctime))
2737c478bd9Sstevel@tonic-gate 		{
2747c478bd9Sstevel@tonic-gate 		errortn();
2757c478bd9Sstevel@tonic-gate 		exit(1);
2767c478bd9Sstevel@tonic-gate 	}
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate 	if (  !(Calctime | Kill | Rejuvenate | Uopt | Sysopt | Queue| Machines | State) ) {
2797c478bd9Sstevel@tonic-gate 		(void) strcpy(User, Loginuser);
2807c478bd9Sstevel@tonic-gate 		Uopt = 1;
2817c478bd9Sstevel@tonic-gate 	}
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate 	if ( nonotf && !(Kill | Rejuvenate) ) {
2847c478bd9Sstevel@tonic-gate 		errortn();
2857c478bd9Sstevel@tonic-gate 		exit(1);
2867c478bd9Sstevel@tonic-gate 	}
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate 	/*****************************************/
2897c478bd9Sstevel@tonic-gate 	/* PROCESS THE OPTIONS                   */
2907c478bd9Sstevel@tonic-gate 	/*****************************************/
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate 	if (State && Complete)
2937c478bd9Sstevel@tonic-gate 		{
2947c478bd9Sstevel@tonic-gate 		   DEBUG(9, "calling complete %d\n",Complete);
2957c478bd9Sstevel@tonic-gate 		   complete();
2967c478bd9Sstevel@tonic-gate 		}
29755fea89dSDan Cross 
2987c478bd9Sstevel@tonic-gate 	if (Calctime) {
2997c478bd9Sstevel@tonic-gate 		count = readperf(calcnum);
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate 		if (count != 0)
3027c478bd9Sstevel@tonic-gate 			docalc();
30355fea89dSDan Cross 
3047c478bd9Sstevel@tonic-gate 	}
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate 	if (Psopt) {
3077c478bd9Sstevel@tonic-gate 		/* do "ps -flp" or pids in LCK files */
3087c478bd9Sstevel@tonic-gate 		lckpid();
3097c478bd9Sstevel@tonic-gate 		/* lckpid will not return */
3107c478bd9Sstevel@tonic-gate 	}
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	if (Summary) {
3137c478bd9Sstevel@tonic-gate 	    /*   Gather data for Summary option report  */
3147c478bd9Sstevel@tonic-gate 	    if (chdir(STATDIR) || (spooldir = opendir(STATDIR)) == NULL)
3157c478bd9Sstevel@tonic-gate 		exit(101);		/* good old code 101 */
3167c478bd9Sstevel@tonic-gate 	    while (gnamef(spooldir, f) == TRUE) {
3177c478bd9Sstevel@tonic-gate 		if (freopen(f, "r", stdin) == NULL)
3187c478bd9Sstevel@tonic-gate 			continue;
3197c478bd9Sstevel@tonic-gate 		m = machine(f);
3207c478bd9Sstevel@tonic-gate 		if (fgets(buf, sizeof(buf), stdin) == NULL)
3217c478bd9Sstevel@tonic-gate 			continue;
3227c478bd9Sstevel@tonic-gate 		if (getargs(buf, vec, 5) < 5)
3237c478bd9Sstevel@tonic-gate 			continue;
3247c478bd9Sstevel@tonic-gate 		m->type = atoi(vec[0]);
3257c478bd9Sstevel@tonic-gate 		m->count = atoi(vec[1]);
3267c478bd9Sstevel@tonic-gate 		m->lasttime = atol(vec[2]);
3277c478bd9Sstevel@tonic-gate 		m->retrytime = atol(vec[3]);
3287c478bd9Sstevel@tonic-gate 		(void) strncpy(m->stst, vec[4], STST_MAX);
3297c478bd9Sstevel@tonic-gate 		str = rindex(m->stst, ' ');
3307c478bd9Sstevel@tonic-gate 		(void) machine(++str);	/* longer name? */
3317c478bd9Sstevel@tonic-gate 		*str = '\0';
33255fea89dSDan Cross 
3337c478bd9Sstevel@tonic-gate 	    }
3347c478bd9Sstevel@tonic-gate 	    closedir(spooldir);
3357c478bd9Sstevel@tonic-gate 	}
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 	if (Summary) {
3397c478bd9Sstevel@tonic-gate 	    /*  search for LCK machines  */
3407c478bd9Sstevel@tonic-gate 	    char flck[MAXNAMESIZE];
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate 	    (void) strcpy(lckdir, LOCKPRE);
3437c478bd9Sstevel@tonic-gate 	    *strrchr(lckdir, '/') = '\0';
3447c478bd9Sstevel@tonic-gate 	    /* open lock directory */
3457c478bd9Sstevel@tonic-gate 	    if (chdir(lckdir) != 0 || (subdir = opendir(lckdir)) == NULL)
3467c478bd9Sstevel@tonic-gate 		exit(101);		/* good old code 101 */
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate 	    while (gnameflck(subdir, flck) == TRUE) {
3497c478bd9Sstevel@tonic-gate 		/* XXX - this is disgusting... */
3507c478bd9Sstevel@tonic-gate 		if (EQUALSN("LCK..", flck, 5)) {
3517c478bd9Sstevel@tonic-gate 		    if (!EQUALSN(flck + 5, "cul", 3)
3527c478bd9Sstevel@tonic-gate 		     && !EQUALSN(flck + 5, "cua", 3)
3537c478bd9Sstevel@tonic-gate 		     && !EQUALSN(flck + 5, "tty", 3)
3547c478bd9Sstevel@tonic-gate 		     && !EQUALSN(flck + 5, "dtsw", 4)
3557c478bd9Sstevel@tonic-gate 		     && !EQUALSN(flck + 5, "vadic", 5)
3567c478bd9Sstevel@tonic-gate 		     && !EQUALSN(flck + 5, "micom", 5))
3577c478bd9Sstevel@tonic-gate 			machine(flck + 5)->locked++;
3587c478bd9Sstevel@tonic-gate 		}
3597c478bd9Sstevel@tonic-gate 	    }
3607c478bd9Sstevel@tonic-gate 	}
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate 	if (chdir(SPOOL) != 0 || (spooldir = opendir(SPOOL)) == NULL)
3637c478bd9Sstevel@tonic-gate 		exit(101);		/* good old code 101 */
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate 	while (gnamef(spooldir, f) == TRUE) {
3667c478bd9Sstevel@tonic-gate 	 /* at /var/spool/uucp directory */
3677c478bd9Sstevel@tonic-gate 	 /* f will contain remote machine names */
36855fea89dSDan Cross 
3697c478bd9Sstevel@tonic-gate           if (EQUALSN("LCK..", f, 5))
3707c478bd9Sstevel@tonic-gate 		continue;
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate           if (*Rmtname && !EQUALSN(Rmtname, f, MAXBASENAME))
3737c478bd9Sstevel@tonic-gate 		continue;
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate           if ( (Kill || Rejuvenate)
3767c478bd9Sstevel@tonic-gate 	      && (!EQUALSN(f, Jobid, strlen(Jobid)-5)) )
3777c478bd9Sstevel@tonic-gate 		    continue;
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate 	  if (DIRECTORY(f))  {
3807c478bd9Sstevel@tonic-gate 		if (chdir(f) != 0)
3817c478bd9Sstevel@tonic-gate 			exit(101);
3827c478bd9Sstevel@tonic-gate 		(void) sprintf(fullpath, "%s/%s", SPOOL, f);
3837c478bd9Sstevel@tonic-gate 		machdir = opendir(fullpath);
3847c478bd9Sstevel@tonic-gate 		if (machdir == NULL)
3857c478bd9Sstevel@tonic-gate 			exit(101);
38655fea89dSDan Cross 
3877c478bd9Sstevel@tonic-gate 		m = machine(f);
3887c478bd9Sstevel@tonic-gate 		while (gnamef(machdir, gradef) == TRUE) {
3897c478bd9Sstevel@tonic-gate 			/* at /var/spool/uucp/remote_name */
3907c478bd9Sstevel@tonic-gate 			/* gradef will contain job_grade directory names */
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate 	     		if (DIRECTORY(gradef) && (gradedir = opendir(gradef))) {
3937c478bd9Sstevel@tonic-gate 				/* at /var/spool/uucp/remote_name/job_grade */
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate 		  		while (gnamef(gradedir, subf) == TRUE) {
3967c478bd9Sstevel@tonic-gate 				    /* subf will contain file names */
3977c478bd9Sstevel@tonic-gate 				    /* files can be C. or D. or A., etc.. */
3987c478bd9Sstevel@tonic-gate 
3997c478bd9Sstevel@tonic-gate 				    if (subf[1] == '.') {
4007c478bd9Sstevel@tonic-gate 		  		      if (subf[0] == CMDPRE) {
4017c478bd9Sstevel@tonic-gate 					/* if file name is C. */
4027c478bd9Sstevel@tonic-gate 					m->ccount++;
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate 					if (Kill || Rejuvenate)
4057c478bd9Sstevel@tonic-gate 					    kprocessC(gradef, subf);
40655fea89dSDan Cross 					else if (Uopt | Sysopt | Queued | Running | Interrupted)
4077c478bd9Sstevel@tonic-gate 				 	   /* go print out C. file info */
4087c478bd9Sstevel@tonic-gate 				  	   uprocessC(f ,gradef, subf);
4097c478bd9Sstevel@tonic-gate 
4107c478bd9Sstevel@tonic-gate 					else 	/* get the age of the C. file */
4117c478bd9Sstevel@tonic-gate 				 	   if ( (i = _age(gradef, subf))>m->c_age)
4127c478bd9Sstevel@tonic-gate 						m->c_age = i;
4137c478bd9Sstevel@tonic-gate 					}
4147c478bd9Sstevel@tonic-gate 		    		    }
4157c478bd9Sstevel@tonic-gate 				}
4167c478bd9Sstevel@tonic-gate 				closedir(gradedir);
4177c478bd9Sstevel@tonic-gate 			}
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate 			else if (gradef[0] == XQTPRE && gradef[1] == '.') {
4207c478bd9Sstevel@tonic-gate 			   m->xcount++;
4217c478bd9Sstevel@tonic-gate 			   if ( (i = _age(machdir, gradef)) > m->x_age)
4227c478bd9Sstevel@tonic-gate 				m->x_age = i;
4237c478bd9Sstevel@tonic-gate 			}
4247c478bd9Sstevel@tonic-gate 		}
4257c478bd9Sstevel@tonic-gate 		closedir(machdir);
42655fea89dSDan Cross 	  }
4277c478bd9Sstevel@tonic-gate 	  /* cd back to /var/spoool/uucp dir */
4287c478bd9Sstevel@tonic-gate 	  if (chdir(SPOOL) != 0)
42955fea89dSDan Cross 		exit(101);
4307c478bd9Sstevel@tonic-gate 	} /* while more files in spooldir */
4317c478bd9Sstevel@tonic-gate 	closedir(spooldir);
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate 	if (Jobcount && (jobcount != 0))
4347c478bd9Sstevel@tonic-gate 		printf("job count = %d\n",jobcount);
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate 	/* for Kill or Rejuvenate - will not get here unless it failed */
4377c478bd9Sstevel@tonic-gate 	if (Kill) {
4387c478bd9Sstevel@tonic-gate 	    printf(gettext("Can't find Job %s; Not killed\n"), Jobid);
4397c478bd9Sstevel@tonic-gate 	    exit(1);
4407c478bd9Sstevel@tonic-gate 	} else if (Rejuvenate) {
4417c478bd9Sstevel@tonic-gate 	    printf(gettext("Can't find Job %s; Not rejuvenated\n"), Jobid);
4427c478bd9Sstevel@tonic-gate 	    exit(1);
4437c478bd9Sstevel@tonic-gate 	}
4447c478bd9Sstevel@tonic-gate 
4457c478bd9Sstevel@tonic-gate 	/* Make sure the overflow entry is null since it may be incorrect */
4467c478bd9Sstevel@tonic-gate 	M[UUSTAT_TBL].mach[0] = NULLCHAR;
4477c478bd9Sstevel@tonic-gate 	if (Summary) {
44809f57adeSToomas Soome 	    for((sortcnt = 0, m = &M[0]);*(m->mach) != '\0';(sortcnt++,m++))
4497c478bd9Sstevel@tonic-gate 			;
4507c478bd9Sstevel@tonic-gate 	    qsort((char *)M, (unsigned int)sortcnt, sizeof(struct m), machcmp);
4517c478bd9Sstevel@tonic-gate 	    for (m = M; m->mach[0] != NULLCHAR; m++)
4527c478bd9Sstevel@tonic-gate 		printit(m);
4537c478bd9Sstevel@tonic-gate 	}
454462be471Sceastha 	return (0);
4557c478bd9Sstevel@tonic-gate }
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate 
4587c478bd9Sstevel@tonic-gate /*
4597c478bd9Sstevel@tonic-gate  * uprocessC - get information about C. file
4607c478bd9Sstevel@tonic-gate  *
4617c478bd9Sstevel@tonic-gate  */
4627c478bd9Sstevel@tonic-gate 
4637c478bd9Sstevel@tonic-gate void
uprocessC(machine,dir,file)4647c478bd9Sstevel@tonic-gate uprocessC(machine, dir, file)
4657c478bd9Sstevel@tonic-gate char   *machine, *dir, *file;
4667c478bd9Sstevel@tonic-gate {
4677c478bd9Sstevel@tonic-gate 	struct stat s;
468462be471Sceastha 	struct tm *tp;
4697c478bd9Sstevel@tonic-gate 	char fullname[MAXFULLNAME], buf[BUFSIZ], user[9];
4707c478bd9Sstevel@tonic-gate 	char xfullname[MAXFULLNAME];
4717c478bd9Sstevel@tonic-gate 	char file1[BUFSIZ], file2[BUFSIZ], file3[BUFSIZ], type[2], opt[256];
4727c478bd9Sstevel@tonic-gate 	short goodRecord = 0;
4737c478bd9Sstevel@tonic-gate 	FILE *fp, *xfp;
4747c478bd9Sstevel@tonic-gate 	short first = 1;
475462be471Sceastha 	int statefound = 0;
4767c478bd9Sstevel@tonic-gate 	extern long fsize();
4777c478bd9Sstevel@tonic-gate 	char format_tmp[BUFSIZ+1];
4787c478bd9Sstevel@tonic-gate 	fp=xfp=NULL;
4797c478bd9Sstevel@tonic-gate 
4807c478bd9Sstevel@tonic-gate 	/*********************************************/
4817c478bd9Sstevel@tonic-gate 	/* initialize output buffer to blanks        */
4827c478bd9Sstevel@tonic-gate 	/*********************************************/
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate 	if (Complete && !Queued && !Running && !Interrupted)
4857c478bd9Sstevel@tonic-gate 		return;
4867c478bd9Sstevel@tonic-gate 	outbuf[0] = NULLCHAR;
4877c478bd9Sstevel@tonic-gate 
4887c478bd9Sstevel@tonic-gate 	DEBUG(9, "uprocessC(%s, ", dir);
4897c478bd9Sstevel@tonic-gate 	DEBUG(9, "%s);\n", file);
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate 	if (Jobid[0] != '\0' && (!EQUALS(Jobid, &file[2])) ) {
4927c478bd9Sstevel@tonic-gate 		/* kill job - not this one */
4937c478bd9Sstevel@tonic-gate 		return;
4947c478bd9Sstevel@tonic-gate 	}
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate 	(void) sprintf(fullname, "%s/%s", dir, file);
4977c478bd9Sstevel@tonic-gate 	if (stat(fullname, &s) != 0) {
4987c478bd9Sstevel@tonic-gate 	     /* error - can't stat */
4997c478bd9Sstevel@tonic-gate 	    DEBUG(4, "Can't stat file (%s),", fullname);
5007c478bd9Sstevel@tonic-gate 	    DEBUG(4, " errno (%d) -- skip it!\n", errno);
5017c478bd9Sstevel@tonic-gate 	}
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate 	fp = fopen(fullname, "r");
5047c478bd9Sstevel@tonic-gate 	if (fp == NULL) {
5057c478bd9Sstevel@tonic-gate 		DEBUG(4, "Can't open file (%s), ", fullname);
5067c478bd9Sstevel@tonic-gate 		DEBUG(4, "errno=%d -- skip it!\n", errno);
5077c478bd9Sstevel@tonic-gate 		return;
5087c478bd9Sstevel@tonic-gate 	}
5097c478bd9Sstevel@tonic-gate 	tp = localtime(&s.st_mtime);
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate 	if (s.st_size == 0 && User[0] == '\0') { /* dummy D. for polling */
5127c478bd9Sstevel@tonic-gate 	    sprintf(format_tmp,"%-12s  %2.2d/%2.2d-%2.2d:%2.2d:%2.2d  (POLL)\n",
5137c478bd9Sstevel@tonic-gate 		&file[2], tp->tm_mon + 1, tp->tm_mday, tp->tm_hour,
5147c478bd9Sstevel@tonic-gate 		tp->tm_min, tp->tm_sec);
5157c478bd9Sstevel@tonic-gate 		(void) strcat(outbuf, format_tmp);
5167c478bd9Sstevel@tonic-gate 	}
5177c478bd9Sstevel@tonic-gate 	else while (fgets(buf, BUFSIZ, fp) != NULL) {
5187c478bd9Sstevel@tonic-gate 	    if (sscanf(buf,"%s%s%s%s%s%s", type, file1, file2,
5197c478bd9Sstevel@tonic-gate 	      user, opt, file3) <5) {
5207c478bd9Sstevel@tonic-gate 		DEBUG(4, "short line (%s)\n", buf);
5217c478bd9Sstevel@tonic-gate 		continue;
5227c478bd9Sstevel@tonic-gate 	    }
5237c478bd9Sstevel@tonic-gate 	    DEBUG(9, "type (%s), ", type);
5247c478bd9Sstevel@tonic-gate 	    DEBUG(9, "file1 (%s)", file1);
5257c478bd9Sstevel@tonic-gate 	    DEBUG(9, "file2 (%s)", file2);
5267c478bd9Sstevel@tonic-gate 	    DEBUG(9, "file3 (%s)", file3);
5277c478bd9Sstevel@tonic-gate 	    DEBUG(9, "user (%s)", user);
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate 	    goodRecord = 0;
5307c478bd9Sstevel@tonic-gate 
53155fea89dSDan Cross 	    if (User[0] != '\0' && (!EQUALS(User, user)) )
5327c478bd9Sstevel@tonic-gate 		continue;
5337c478bd9Sstevel@tonic-gate 
5347c478bd9Sstevel@tonic-gate 
5357c478bd9Sstevel@tonic-gate 	    if (first)
5367c478bd9Sstevel@tonic-gate 	       {
5377c478bd9Sstevel@tonic-gate 	        sprintf(format_tmp,"%-12s", &file[2]);
5387c478bd9Sstevel@tonic-gate 		(void) strcat(outbuf, format_tmp);
5397c478bd9Sstevel@tonic-gate 
5407c478bd9Sstevel@tonic-gate 		/* if the job state is requested call the
5417c478bd9Sstevel@tonic-gate 		   state function to determine this job's state */
5427c478bd9Sstevel@tonic-gate 
5437c478bd9Sstevel@tonic-gate 		if (State)
54455fea89dSDan Cross 		{
54555fea89dSDan Cross 		   statefound = state(dir, file);
5467c478bd9Sstevel@tonic-gate 	           DEBUG(9, "uprocessC: statefound value = %d\n", statefound);
5477c478bd9Sstevel@tonic-gate  		   if ((whattodo(statefound) != TRUE))
5487c478bd9Sstevel@tonic-gate 			{
5497c478bd9Sstevel@tonic-gate 			   outbuf[0] = NULLCHAR;
5507c478bd9Sstevel@tonic-gate 			   return;
5517c478bd9Sstevel@tonic-gate 			}
5527c478bd9Sstevel@tonic-gate 		   else
5537c478bd9Sstevel@tonic-gate 			{
5547c478bd9Sstevel@tonic-gate 			   if (statefound == 1)
5557c478bd9Sstevel@tonic-gate 				(void) strcat(outbuf, "queued");
5567c478bd9Sstevel@tonic-gate 			   else if (statefound == 2)
5577c478bd9Sstevel@tonic-gate 				(void) strcat(outbuf, "running");
5587c478bd9Sstevel@tonic-gate 			   else if (statefound == 3)
5597c478bd9Sstevel@tonic-gate 				(void) strcat(outbuf, "interrupted");
5607c478bd9Sstevel@tonic-gate 			}
5617c478bd9Sstevel@tonic-gate 		}
5627c478bd9Sstevel@tonic-gate 		sprintf(format_tmp, " %2.2d/%2.2d-%2.2d:%2.2d ",
5637c478bd9Sstevel@tonic-gate 		    tp->tm_mon + 1, tp->tm_mday, tp->tm_hour,
5647c478bd9Sstevel@tonic-gate 		    tp->tm_min);
5657c478bd9Sstevel@tonic-gate 		(void) strcat(outbuf, format_tmp);
5667c478bd9Sstevel@tonic-gate 	       }
5677c478bd9Sstevel@tonic-gate 	    else
5687c478bd9Sstevel@tonic-gate 	       {
5697c478bd9Sstevel@tonic-gate 		sprintf(format_tmp,"%-12s %2.2d/%2.2d-%2.2d:%2.2d ",
5707c478bd9Sstevel@tonic-gate 		    "", tp->tm_mon + 1, tp->tm_mday, tp->tm_hour,
5717c478bd9Sstevel@tonic-gate 		    tp->tm_min);
5727c478bd9Sstevel@tonic-gate 		(void) strcat(outbuf, format_tmp);
5737c478bd9Sstevel@tonic-gate 		}
5747c478bd9Sstevel@tonic-gate 	    first = 0;
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate 	    sprintf(format_tmp,"%s  %s  ", type, machine);
5777c478bd9Sstevel@tonic-gate 	    (void) strcat(outbuf, format_tmp);
5787c478bd9Sstevel@tonic-gate 	    if (*type == 'R')
5797c478bd9Sstevel@tonic-gate 	       {
5807c478bd9Sstevel@tonic-gate 	        sprintf(format_tmp,"%s  %s ", user, file1);
5817c478bd9Sstevel@tonic-gate 	        (void) strcat(outbuf, format_tmp);
5827c478bd9Sstevel@tonic-gate 	       }
5837c478bd9Sstevel@tonic-gate 	    else if (file2[0] != 'X')
5847c478bd9Sstevel@tonic-gate 		{
5857c478bd9Sstevel@tonic-gate 		 sprintf(format_tmp,"%s %ld %s ", user, fsize(dir, file3, file1), file1);
5867c478bd9Sstevel@tonic-gate 		 (void) strcat(outbuf, format_tmp);
5877c478bd9Sstevel@tonic-gate 		}
5887c478bd9Sstevel@tonic-gate 	    else if (*type == 'S' && file2[0] == 'X') {
5897c478bd9Sstevel@tonic-gate 		(void) sprintf(xfullname, "%s/%s", dir, file1);
5907c478bd9Sstevel@tonic-gate 		xfp = fopen(xfullname, "r");
5917c478bd9Sstevel@tonic-gate 		if (xfp == NULL) { /* program error */
5927c478bd9Sstevel@tonic-gate 		    DEBUG(4, "Can't read %s, ", xfullname);
5937c478bd9Sstevel@tonic-gate 		    DEBUG(4, "errno=%d -- skip it!\n", errno);
5947c478bd9Sstevel@tonic-gate 		    sprintf(format_tmp,"%s  ", user);
5957c478bd9Sstevel@tonic-gate 		    (void) strcat(outbuf, format_tmp);
5967c478bd9Sstevel@tonic-gate 		    (void) strcat(outbuf,"????\n");
5977c478bd9Sstevel@tonic-gate 		}
5987c478bd9Sstevel@tonic-gate 		else {
5997c478bd9Sstevel@tonic-gate 		    char command[BUFSIZ], uline_u[BUFSIZ], uline_m[BUFSIZ];
6007c478bd9Sstevel@tonic-gate 		    char retaddr[BUFSIZ], *username;
6017c478bd9Sstevel@tonic-gate 
6027c478bd9Sstevel@tonic-gate 		    *retaddr = *uline_u = *uline_m = '\0';
6037c478bd9Sstevel@tonic-gate 		    while (fgets(buf, BUFSIZ, xfp) != NULL) {
6047c478bd9Sstevel@tonic-gate 			switch(buf[0]) {
6057c478bd9Sstevel@tonic-gate 			case 'C':
6067c478bd9Sstevel@tonic-gate 				strcpy(command, buf + 2);
6077c478bd9Sstevel@tonic-gate 				break;
6087c478bd9Sstevel@tonic-gate 			case 'U':
6097c478bd9Sstevel@tonic-gate 				sscanf(buf + 2, "%s%s", uline_u, uline_m);
6107c478bd9Sstevel@tonic-gate 				break;
6117c478bd9Sstevel@tonic-gate 			case 'R':
6127c478bd9Sstevel@tonic-gate 				sscanf(buf+2, "%s", retaddr);
6137c478bd9Sstevel@tonic-gate 				break;
6147c478bd9Sstevel@tonic-gate 			}
6157c478bd9Sstevel@tonic-gate 		    }
6167c478bd9Sstevel@tonic-gate 		    username = user;
6177c478bd9Sstevel@tonic-gate 		    if (*uline_u != '\0')
6187c478bd9Sstevel@tonic-gate 			    username = uline_u;
6197c478bd9Sstevel@tonic-gate 		    if (*retaddr != '\0')
6207c478bd9Sstevel@tonic-gate 			username = retaddr;
6217c478bd9Sstevel@tonic-gate 		    if (!EQUALS(uline_m, Myname))
6227c478bd9Sstevel@tonic-gate 			printf("%s!", uline_m);
6237c478bd9Sstevel@tonic-gate 		    sprintf(format_tmp,"%s  %s", username, command);
6247c478bd9Sstevel@tonic-gate 		    (void) strcat(outbuf, format_tmp);
6257c478bd9Sstevel@tonic-gate 		}
6267c478bd9Sstevel@tonic-gate 	    }
6277c478bd9Sstevel@tonic-gate        	strcat(outbuf, "\n");
6287c478bd9Sstevel@tonic-gate 	fputs(outbuf, stdout);
6297c478bd9Sstevel@tonic-gate         outbuf[0] = NULLCHAR;
6307c478bd9Sstevel@tonic-gate 	goodRecord = 1;
6317c478bd9Sstevel@tonic-gate        } /* end of while more data in buffer */
63255fea89dSDan Cross 
6337c478bd9Sstevel@tonic-gate        /* successful processing of a job, increment job count
63455fea89dSDan Cross 	  counter */
6357c478bd9Sstevel@tonic-gate 	if (goodRecord)
6367c478bd9Sstevel@tonic-gate             jobcount++;
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate 	if (xfp != NULL)
6397c478bd9Sstevel@tonic-gate 	    fclose(xfp);
6407c478bd9Sstevel@tonic-gate 
6417c478bd9Sstevel@tonic-gate 	fclose(fp);
6427c478bd9Sstevel@tonic-gate 	return;
6437c478bd9Sstevel@tonic-gate }
6447c478bd9Sstevel@tonic-gate /*
6457c478bd9Sstevel@tonic-gate  * whattodo - determine what to do with current C dot file
64655fea89dSDan Cross  *  	     depending on any combination (2**3 - 1) of input
6477c478bd9Sstevel@tonic-gate  *	     job states
6487c478bd9Sstevel@tonic-gate  */
6497c478bd9Sstevel@tonic-gate static int
whattodo(inputint)6507c478bd9Sstevel@tonic-gate whattodo(inputint)
6517c478bd9Sstevel@tonic-gate int inputint;
6527c478bd9Sstevel@tonic-gate {
6537c478bd9Sstevel@tonic-gate 	/* Maybe some commentary here will help explain this truth
6547c478bd9Sstevel@tonic-gate 	   table.
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate 	Queued		|Running	|Interrupted
6577c478bd9Sstevel@tonic-gate 	-------------------------------------------------
6587c478bd9Sstevel@tonic-gate 		X	|		|
6597c478bd9Sstevel@tonic-gate 	-------------------------------------------------
6607c478bd9Sstevel@tonic-gate 			|	X	|
6617c478bd9Sstevel@tonic-gate 	-------------------------------------------------
6627c478bd9Sstevel@tonic-gate 			|		|      X
6637c478bd9Sstevel@tonic-gate 	-------------------------------------------------
6647c478bd9Sstevel@tonic-gate 		X	|	X	|
6657c478bd9Sstevel@tonic-gate 	-------------------------------------------------
6667c478bd9Sstevel@tonic-gate 			|	X	|      X
6677c478bd9Sstevel@tonic-gate 	-------------------------------------------------
6687c478bd9Sstevel@tonic-gate 		X	|		|      X
6697c478bd9Sstevel@tonic-gate 	-------------------------------------------------
6707c478bd9Sstevel@tonic-gate 		X	|	X	|      X
6717c478bd9Sstevel@tonic-gate 	-------------------------------------------------
6727c478bd9Sstevel@tonic-gate 
6737c478bd9Sstevel@tonic-gate 	Now do you understand.  All  possible combinations have to
6747c478bd9Sstevel@tonic-gate 	be evaluated to determine whether or not to print the C dot
6757c478bd9Sstevel@tonic-gate 	information out or not! Well, all but 000, because if neither
67655fea89dSDan Cross 	of these states are input by the user we would not be
6777c478bd9Sstevel@tonic-gate 	examing the C dot file anyway!
6787c478bd9Sstevel@tonic-gate 	*/
6797c478bd9Sstevel@tonic-gate 
6807c478bd9Sstevel@tonic-gate 	if (Queued && Running && Interrupted)
6817c478bd9Sstevel@tonic-gate 		return(TRUE);
6827c478bd9Sstevel@tonic-gate 	else if ((Queued && !Running && !Interrupted) && (inputint == 1))
6837c478bd9Sstevel@tonic-gate 		return(TRUE);
6847c478bd9Sstevel@tonic-gate 	else if ((Running && !Queued && !Interrupted) && (inputint == 2))				return(TRUE);
6857c478bd9Sstevel@tonic-gate 	else if ((Interrupted && !Queued && !Running) && (inputint == 3))				return(TRUE);
68655fea89dSDan Cross 	else if ((Queued && Running && !Interrupted) &&
6877c478bd9Sstevel@tonic-gate 		(inputint == 1 || inputint == 2))
6887c478bd9Sstevel@tonic-gate 	  		return(TRUE);
68955fea89dSDan Cross 	else if ((!Queued && Running && Interrupted) &&
6907c478bd9Sstevel@tonic-gate 		(inputint == 2 || inputint == 3))
6917c478bd9Sstevel@tonic-gate 			return(TRUE);
69255fea89dSDan Cross 	else if ((Queued && !Running && Interrupted) &&
6937c478bd9Sstevel@tonic-gate 		(inputint ==1 || inputint == 3))
6947c478bd9Sstevel@tonic-gate 			return(TRUE);
6957c478bd9Sstevel@tonic-gate 	else return(FALSE);
6967c478bd9Sstevel@tonic-gate }
6977c478bd9Sstevel@tonic-gate /*
6987c478bd9Sstevel@tonic-gate  * kprocessC - process kill or rejuvenate job
6997c478bd9Sstevel@tonic-gate  */
7007c478bd9Sstevel@tonic-gate 
701462be471Sceastha static void
kprocessC(dir,file)7027c478bd9Sstevel@tonic-gate kprocessC(dir, file)
7037c478bd9Sstevel@tonic-gate char *file, *dir;
7047c478bd9Sstevel@tonic-gate {
7057c478bd9Sstevel@tonic-gate 	struct stat s;
706462be471Sceastha 	struct tm *tp;
7077c478bd9Sstevel@tonic-gate 	extern struct tm *localtime();
7087c478bd9Sstevel@tonic-gate 	char fullname[MAXFULLNAME], buf[BUFSIZ], user[9];
7097c478bd9Sstevel@tonic-gate 	char rfullname[MAXFULLNAME];
7107c478bd9Sstevel@tonic-gate 	char file1[BUFSIZ], file2[BUFSIZ], file3[BUFSIZ], type[2], opt[256];
7117c478bd9Sstevel@tonic-gate 	FILE *fp, *xfp;
7127c478bd9Sstevel@tonic-gate  	struct utimbuf times;
7137c478bd9Sstevel@tonic-gate 	short ret;
7147c478bd9Sstevel@tonic-gate 	short first = 1;
7157c478bd9Sstevel@tonic-gate 
7167c478bd9Sstevel@tonic-gate 	DEBUG(9, "kprocessC(%s, ", dir);
7177c478bd9Sstevel@tonic-gate 	DEBUG(9, "%s);\n", file);
7187c478bd9Sstevel@tonic-gate 
7197c478bd9Sstevel@tonic-gate 	if ((!EQUALS(Jobid, &file[2])) ) {
7207c478bd9Sstevel@tonic-gate 		/* kill job - not this one */
7217c478bd9Sstevel@tonic-gate 		return;
7227c478bd9Sstevel@tonic-gate 	}
7237c478bd9Sstevel@tonic-gate 
7247c478bd9Sstevel@tonic-gate 	(void) sprintf(fullname, "%s/%s", dir, file);
7257c478bd9Sstevel@tonic-gate 	if (stat(fullname, &s) != 0) {
7267c478bd9Sstevel@tonic-gate 	     /* error - can't stat */
7277c478bd9Sstevel@tonic-gate 	    if(Kill) {
7287c478bd9Sstevel@tonic-gate 		fprintf(stderr,
7297c478bd9Sstevel@tonic-gate 		  gettext("Can't stat:%s, errno (%d)--can't kill it!\n"),
7307c478bd9Sstevel@tonic-gate 		  fullname, errno);
7317c478bd9Sstevel@tonic-gate 	    } else {
7327c478bd9Sstevel@tonic-gate 		fprintf(stderr,
7337c478bd9Sstevel@tonic-gate 		  gettext("Can't stat:%s, errno (%d)--can't rejuvenate it!\n"),
7347c478bd9Sstevel@tonic-gate 		  fullname, errno);
7357c478bd9Sstevel@tonic-gate 	    }
7367c478bd9Sstevel@tonic-gate 	    exit(1);
7377c478bd9Sstevel@tonic-gate 	}
7387c478bd9Sstevel@tonic-gate 
7397c478bd9Sstevel@tonic-gate 	fp = fopen(fullname, "r");
7407c478bd9Sstevel@tonic-gate 	if (fp == NULL) {
7417c478bd9Sstevel@tonic-gate 	    if(Kill) {
7427c478bd9Sstevel@tonic-gate 		fprintf(stderr,
7437c478bd9Sstevel@tonic-gate 		  gettext("Can't read:%s, errno (%d)--can't kill it!\n"),
7447c478bd9Sstevel@tonic-gate 		  fullname, errno);
7457c478bd9Sstevel@tonic-gate 	    } else {
7467c478bd9Sstevel@tonic-gate 		fprintf(stderr,
7477c478bd9Sstevel@tonic-gate 		  gettext("Can't read:%s, errno (%d)--can't rejuvenate it!\n"),
7487c478bd9Sstevel@tonic-gate 		  fullname, errno);
7497c478bd9Sstevel@tonic-gate 	    }
7507c478bd9Sstevel@tonic-gate 	    exit(1);
7517c478bd9Sstevel@tonic-gate 	}
7527c478bd9Sstevel@tonic-gate 
7537c478bd9Sstevel@tonic-gate  	times.actime = times.modtime = time((time_t *)NULL);
75455fea89dSDan Cross 
7557c478bd9Sstevel@tonic-gate 	while (fgets(buf, BUFSIZ, fp) != NULL) {
7567c478bd9Sstevel@tonic-gate 	    if (sscanf(buf,"%s%s%s%s%s%s", type, file1, file2,
7577c478bd9Sstevel@tonic-gate 	      user, opt, file3) <6) {
7587c478bd9Sstevel@tonic-gate 		if(Kill) {
7597c478bd9Sstevel@tonic-gate 		    fprintf(stderr,
7607c478bd9Sstevel@tonic-gate 		      gettext("Bad format:%s, errno (%d)--can't kill it!\n"),
7617c478bd9Sstevel@tonic-gate 		      fullname, errno);
7627c478bd9Sstevel@tonic-gate 		} else {
7637c478bd9Sstevel@tonic-gate 		    fprintf(stderr,
7647c478bd9Sstevel@tonic-gate 		      gettext("Bad format:%s, errno (%d)--can't rejuvenate it!\n"),
7657c478bd9Sstevel@tonic-gate 		      fullname, errno);
7667c478bd9Sstevel@tonic-gate 		}
7677c478bd9Sstevel@tonic-gate 	        exit(1);
7687c478bd9Sstevel@tonic-gate 	    }
7697c478bd9Sstevel@tonic-gate 
7707c478bd9Sstevel@tonic-gate 	    DEBUG(9, "buf in uprocessK = %s\n ", buf);
7717c478bd9Sstevel@tonic-gate 	    DEBUG(9, "fullname is %s\n",fullname);
7727c478bd9Sstevel@tonic-gate 	    DEBUG(9, "type (%s), ", type);
7737c478bd9Sstevel@tonic-gate 	    DEBUG(9, "file1 (%s)", file1);
7747c478bd9Sstevel@tonic-gate 	    DEBUG(9, "file2 (%s)", file2);
7757c478bd9Sstevel@tonic-gate 	    DEBUG(9, "file3 (%s)", file3);
7767c478bd9Sstevel@tonic-gate 	    DEBUG(9, "user (%s)", user);
7777c478bd9Sstevel@tonic-gate 
7787c478bd9Sstevel@tonic-gate 
7797c478bd9Sstevel@tonic-gate 	    if (first) {
7807c478bd9Sstevel@tonic-gate 	        if ((access(fullname, 02) != 0)
7817c478bd9Sstevel@tonic-gate 		    && !PREFIX(Loginuser, user)
7827c478bd9Sstevel@tonic-gate 		    && !PREFIX(user, Loginuser) ) {
7837c478bd9Sstevel@tonic-gate 			/* not allowed - not owner or root */
7847c478bd9Sstevel@tonic-gate 			if(Kill)
7857c478bd9Sstevel@tonic-gate 			    fprintf(stderr, gettext("Not owner,"
7867c478bd9Sstevel@tonic-gate 			      " uucp or root - can't kill job %s\n"), Jobid);
7877c478bd9Sstevel@tonic-gate 			else
7887c478bd9Sstevel@tonic-gate 			    fprintf(stderr, gettext("Not owner, uucp or root -"
7897c478bd9Sstevel@tonic-gate 			      " can't rejuvenate job %s\n"), Jobid);
7907c478bd9Sstevel@tonic-gate 		    exit(1);
7917c478bd9Sstevel@tonic-gate 		}
7927c478bd9Sstevel@tonic-gate 		first = 0;
7937c478bd9Sstevel@tonic-gate 	    }
7947c478bd9Sstevel@tonic-gate 
7957c478bd9Sstevel@tonic-gate 	    /* remove D. file */
7967c478bd9Sstevel@tonic-gate 	    (void) sprintf(rfullname, "%s/%s", dir, file3);
7977c478bd9Sstevel@tonic-gate 	    DEBUG(4, "Remove %s\n", rfullname);
79855fea89dSDan Cross 	    if (Kill)
7997c478bd9Sstevel@tonic-gate 		ret = unlink(rfullname);
8007c478bd9Sstevel@tonic-gate 	    else /* Rejuvenate */
8017c478bd9Sstevel@tonic-gate  		ret = utime(rfullname, &times);
8027c478bd9Sstevel@tonic-gate 	    if (ret != 0 && errno != ENOENT) {
8037c478bd9Sstevel@tonic-gate 		/* program error?? */
8047c478bd9Sstevel@tonic-gate 		if(Kill)
8057c478bd9Sstevel@tonic-gate 		    fprintf(stderr, gettext("Error: Can't kill,"
8067c478bd9Sstevel@tonic-gate 		      " File (%s), errno (%d)\n"), rfullname, errno);
8077c478bd9Sstevel@tonic-gate 		else
8087c478bd9Sstevel@tonic-gate 		    fprintf(stderr, gettext("Error: Can't rejuvenated,"
8097c478bd9Sstevel@tonic-gate 		      " File (%s), errno (%d)\n"), rfullname, errno);
8107c478bd9Sstevel@tonic-gate 		exit(1);
8117c478bd9Sstevel@tonic-gate 	    }
8127c478bd9Sstevel@tonic-gate 	}
8137c478bd9Sstevel@tonic-gate 
8147c478bd9Sstevel@tonic-gate 	DEBUG(4, "Remove %s\n", fullname);
8157c478bd9Sstevel@tonic-gate 	if (Kill)
8167c478bd9Sstevel@tonic-gate 	    ret = unlink(fullname);
8177c478bd9Sstevel@tonic-gate 	else /* Rejuvenate */
8187c478bd9Sstevel@tonic-gate 		ret = utime(fullname, &times);
81955fea89dSDan Cross 
8207c478bd9Sstevel@tonic-gate 	if (ret != 0) {
8217c478bd9Sstevel@tonic-gate 	    /* program error?? */
8227c478bd9Sstevel@tonic-gate 	    if(Kill)
8237c478bd9Sstevel@tonic-gate 	        fprintf(stderr, gettext("Error1: Can't kill,"
8247c478bd9Sstevel@tonic-gate 	          " File (%s), errno (%d)\n"), fullname, errno);
8257c478bd9Sstevel@tonic-gate 	    else
8267c478bd9Sstevel@tonic-gate 	        fprintf(stderr, gettext("Error1: Can't rejuvenate,"
8277c478bd9Sstevel@tonic-gate 	          " File (%s), errno (%d)\n"), fullname, errno);
8287c478bd9Sstevel@tonic-gate 	    exit(1);
8297c478bd9Sstevel@tonic-gate 	}
8307c478bd9Sstevel@tonic-gate 	/* if kill done by SA then send user mail */
8317c478bd9Sstevel@tonic-gate 	else if (!EQUALS(Loginuser, user))
8327c478bd9Sstevel@tonic-gate 	   {
8337c478bd9Sstevel@tonic-gate 		sprintf(mailmsg, "%s %s", KILLMSG, Jobid);
83455fea89dSDan Cross 		mailst(user, "job killed", mailmsg, "", "");
8357c478bd9Sstevel@tonic-gate 	   }
8367c478bd9Sstevel@tonic-gate 	fclose(fp);
8377c478bd9Sstevel@tonic-gate 	if (!nonotf) {
8387c478bd9Sstevel@tonic-gate 		if(Kill)
8397c478bd9Sstevel@tonic-gate 			printf(gettext("Job: %s successfully killed\n"), Jobid);
8407c478bd9Sstevel@tonic-gate 		else
8417c478bd9Sstevel@tonic-gate 			printf(gettext("Job: %s successfully rejuvenated\n"),
8427c478bd9Sstevel@tonic-gate 			    Jobid);
8437c478bd9Sstevel@tonic-gate 		}
8447c478bd9Sstevel@tonic-gate 	exit(0);
8457c478bd9Sstevel@tonic-gate }
8467c478bd9Sstevel@tonic-gate 
8477c478bd9Sstevel@tonic-gate /*
8487c478bd9Sstevel@tonic-gate  * fsize - return the size of f1 or f2 (if f1 does not exist)
8497c478bd9Sstevel@tonic-gate  *	f1 is the local name
8507c478bd9Sstevel@tonic-gate  *
8517c478bd9Sstevel@tonic-gate  */
8527c478bd9Sstevel@tonic-gate 
8537c478bd9Sstevel@tonic-gate long
fsize(dir,f1,f2)8547c478bd9Sstevel@tonic-gate fsize(dir, f1, f2)
8557c478bd9Sstevel@tonic-gate char *dir, *f1, *f2;
8567c478bd9Sstevel@tonic-gate {
8577c478bd9Sstevel@tonic-gate 	struct stat s;
8587c478bd9Sstevel@tonic-gate 	char fullname[BUFSIZ];
8597c478bd9Sstevel@tonic-gate 
8607c478bd9Sstevel@tonic-gate 	(void) sprintf(fullname, "%s/%s", dir, f1);
8617c478bd9Sstevel@tonic-gate 	if (stat(fullname, &s) == 0) {
8627c478bd9Sstevel@tonic-gate 	    return(s.st_size);
8637c478bd9Sstevel@tonic-gate 	}
8647c478bd9Sstevel@tonic-gate 	if (stat(f2, &s) == 0) {
8657c478bd9Sstevel@tonic-gate 	    return(s.st_size);
8667c478bd9Sstevel@tonic-gate 	}
8677c478bd9Sstevel@tonic-gate 
8687c478bd9Sstevel@tonic-gate 	return(-99999);
8697c478bd9Sstevel@tonic-gate }
8707c478bd9Sstevel@tonic-gate 
cleanup()8717c478bd9Sstevel@tonic-gate void cleanup(){}
logent()8727c478bd9Sstevel@tonic-gate void logent(){}		/* to load ulockf.c */
systat()8737c478bd9Sstevel@tonic-gate void systat(){}		/* to load utility.c */
8747c478bd9Sstevel@tonic-gate 
8757c478bd9Sstevel@tonic-gate struct m	*
machine(name)8767c478bd9Sstevel@tonic-gate machine(name)
8777c478bd9Sstevel@tonic-gate char	*name;
8787c478bd9Sstevel@tonic-gate {
8797c478bd9Sstevel@tonic-gate 	struct m *m;
8807c478bd9Sstevel@tonic-gate 	size_t	namelen;
8817c478bd9Sstevel@tonic-gate 
8827c478bd9Sstevel@tonic-gate 	DEBUG(9, "machine(%s), ", name);
8837c478bd9Sstevel@tonic-gate 	namelen = strlen(name);
8847c478bd9Sstevel@tonic-gate 	for (m = M; m->mach[0] != NULLCHAR; m++)
8857c478bd9Sstevel@tonic-gate 		/* match on overlap? */
8867c478bd9Sstevel@tonic-gate 		if (EQUALSN(name, m->mach, MAXBASENAME)) {
8877c478bd9Sstevel@tonic-gate 			/* use longest name */
8887c478bd9Sstevel@tonic-gate 			if (namelen > strlen(m->mach))
8897c478bd9Sstevel@tonic-gate 				(void) strcpy(m->mach, name);
8907c478bd9Sstevel@tonic-gate 			return(m);
8917c478bd9Sstevel@tonic-gate 		}
8927c478bd9Sstevel@tonic-gate 
8937c478bd9Sstevel@tonic-gate 	/*
8947c478bd9Sstevel@tonic-gate 	 * The table is set up with 2 extra entries
8957c478bd9Sstevel@tonic-gate 	 * When we go over by one, output error to errors log
8967c478bd9Sstevel@tonic-gate 	 * When more than one over, just reuse the previous entry
8977c478bd9Sstevel@tonic-gate 	 */
8987c478bd9Sstevel@tonic-gate 	DEBUG(9, "m-M=%d\n", m-M);
8997c478bd9Sstevel@tonic-gate 	if (m-M >= UUSTAT_TBL) {
9007c478bd9Sstevel@tonic-gate 	    if (m-M == UUSTAT_TBL) {
9017c478bd9Sstevel@tonic-gate 		errent("MACHINE TABLE FULL", "", UUSTAT_TBL,
9027c478bd9Sstevel@tonic-gate 		__FILE__, __LINE__);
9037c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr,
9047c478bd9Sstevel@tonic-gate 		    gettext("WARNING: Table Overflow--output not complete\n"));
9057c478bd9Sstevel@tonic-gate 	    }
9067c478bd9Sstevel@tonic-gate 	    else
9077c478bd9Sstevel@tonic-gate 		/* use the last entry - overwrite it */
9087c478bd9Sstevel@tonic-gate 		m = &M[UUSTAT_TBL];
9097c478bd9Sstevel@tonic-gate 	}
9107c478bd9Sstevel@tonic-gate 
9117c478bd9Sstevel@tonic-gate 	(void) strcpy(m->mach, name);
9127c478bd9Sstevel@tonic-gate 	m->c_age= m->x_age= m->lasttime= m->locked= m->ccount= m->xcount= 0;
9137c478bd9Sstevel@tonic-gate 	m->stst[0] = '\0';
9147c478bd9Sstevel@tonic-gate 	return(m);
9157c478bd9Sstevel@tonic-gate }
9167c478bd9Sstevel@tonic-gate 
9177c478bd9Sstevel@tonic-gate void
printit(m)9187c478bd9Sstevel@tonic-gate printit(m)
9197c478bd9Sstevel@tonic-gate struct m *m;
9207c478bd9Sstevel@tonic-gate {
921462be471Sceastha 	struct tm *tp;
9227c478bd9Sstevel@tonic-gate 	time_t	t;
9237c478bd9Sstevel@tonic-gate 	int	minimum;
9247c478bd9Sstevel@tonic-gate 	extern struct tm *localtime();
9257c478bd9Sstevel@tonic-gate 
9267c478bd9Sstevel@tonic-gate 	if (m->ccount == 0
9277c478bd9Sstevel@tonic-gate 	 && m->xcount == 0
9287c478bd9Sstevel@tonic-gate 	 /*&& m->stst[0] == '\0'*/
9297c478bd9Sstevel@tonic-gate 	 && m->locked == 0
9307c478bd9Sstevel@tonic-gate 	 && Queue
9317c478bd9Sstevel@tonic-gate 	 && m->type == 0)
9327c478bd9Sstevel@tonic-gate 		return;
9337c478bd9Sstevel@tonic-gate 	printf("%-10s", m->mach);
9347c478bd9Sstevel@tonic-gate 	if (Queue) {
9357c478bd9Sstevel@tonic-gate 		if (m->ccount)
9367c478bd9Sstevel@tonic-gate 			printf("%3dC", m->ccount);
9377c478bd9Sstevel@tonic-gate 		else
9387c478bd9Sstevel@tonic-gate 			printf("    ");
9397c478bd9Sstevel@tonic-gate 		if (m->c_age)
9407c478bd9Sstevel@tonic-gate 			printf("(%d)", m->c_age);
9417c478bd9Sstevel@tonic-gate 		else
9427c478bd9Sstevel@tonic-gate 			printf("   ");
9437c478bd9Sstevel@tonic-gate 		if (m->xcount)
9447c478bd9Sstevel@tonic-gate 			printf("%3dX", m->xcount);
9457c478bd9Sstevel@tonic-gate 		else
9467c478bd9Sstevel@tonic-gate 			printf("    ");
9477c478bd9Sstevel@tonic-gate 		if (m->x_age)
9487c478bd9Sstevel@tonic-gate 			printf("(%d) ", m->x_age);
9497c478bd9Sstevel@tonic-gate 		else
9507c478bd9Sstevel@tonic-gate 			printf("    ");
9517c478bd9Sstevel@tonic-gate 	} else
9527c478bd9Sstevel@tonic-gate 		printf(" ");
9537c478bd9Sstevel@tonic-gate 
9547c478bd9Sstevel@tonic-gate 	if (m->lasttime) {
9557c478bd9Sstevel@tonic-gate 	    tp = localtime(&m->lasttime);
9567c478bd9Sstevel@tonic-gate 	    printf("%2.2d/%2.2d-%2.2d:%2.2d ",
9577c478bd9Sstevel@tonic-gate 		tp->tm_mon + 1, tp->tm_mday, tp->tm_hour,
9587c478bd9Sstevel@tonic-gate 		tp->tm_min);
9597c478bd9Sstevel@tonic-gate 	}
9607c478bd9Sstevel@tonic-gate /*	if (m->locked && m->type != SS_INPROGRESS) */
9617c478bd9Sstevel@tonic-gate 	if (m->locked)
9627c478bd9Sstevel@tonic-gate 		printf("Locked ");
9637c478bd9Sstevel@tonic-gate 	if (m->stst[0] != '\0') {
9647c478bd9Sstevel@tonic-gate 		printf("%s", m->stst);
9657c478bd9Sstevel@tonic-gate 		switch (m->type) {
9667c478bd9Sstevel@tonic-gate 		case SS_SEQBAD:
9677c478bd9Sstevel@tonic-gate 		case SS_LOGIN_FAILED:
9687c478bd9Sstevel@tonic-gate 		case SS_DIAL_FAILED:
9697c478bd9Sstevel@tonic-gate 		case SS_BAD_LOG_MCH:
9707c478bd9Sstevel@tonic-gate 		case SS_BADSYSTEM:
9717c478bd9Sstevel@tonic-gate 		case SS_CANT_ACCESS_DEVICE:
9727c478bd9Sstevel@tonic-gate 		case SS_DEVICE_FAILED:
9737c478bd9Sstevel@tonic-gate 		case SS_WRONG_MCH:
9747c478bd9Sstevel@tonic-gate 		case SS_RLOCKED:
9757c478bd9Sstevel@tonic-gate 		case SS_RUNKNOWN:
9767c478bd9Sstevel@tonic-gate 		case SS_RLOGIN:
9777c478bd9Sstevel@tonic-gate 		case SS_UNKNOWN_RESPONSE:
9787c478bd9Sstevel@tonic-gate 		case SS_STARTUP:
9797c478bd9Sstevel@tonic-gate 		case SS_CHAT_FAILED:
9807c478bd9Sstevel@tonic-gate 			(void) time(&t);
9817c478bd9Sstevel@tonic-gate 			t = m->retrytime - (t - m->lasttime);
9827c478bd9Sstevel@tonic-gate 			if (t > 0) {
9837c478bd9Sstevel@tonic-gate 				minimum = (t + 59) / 60;
9847c478bd9Sstevel@tonic-gate 				printf("Retry: %d:%2.2d", minimum/60, minimum%60);
9857c478bd9Sstevel@tonic-gate 			}
9867c478bd9Sstevel@tonic-gate 			if (m->count > 1)
9877c478bd9Sstevel@tonic-gate 				printf(" Count: %d", m->count);
9887c478bd9Sstevel@tonic-gate 		}
9897c478bd9Sstevel@tonic-gate 	}
9907c478bd9Sstevel@tonic-gate 	putchar('\n');
9917c478bd9Sstevel@tonic-gate 	return;
9927c478bd9Sstevel@tonic-gate }
9937c478bd9Sstevel@tonic-gate 
9947c478bd9Sstevel@tonic-gate #define MAXLOCKS 100	/* Maximum number of lock files this will handle */
9957c478bd9Sstevel@tonic-gate 
9967c478bd9Sstevel@tonic-gate int
lckpid()9977c478bd9Sstevel@tonic-gate lckpid()
9987c478bd9Sstevel@tonic-gate {
999462be471Sceastha     int i;
10007c478bd9Sstevel@tonic-gate     int fd, ret;
10017c478bd9Sstevel@tonic-gate     pid_t pid, list[MAXLOCKS];
10027c478bd9Sstevel@tonic-gate     char alpid[SIZEOFPID+2];	/* +2 for '\n' and null */
10037c478bd9Sstevel@tonic-gate     char buf[BUFSIZ], f[MAXNAMESIZE];
10047c478bd9Sstevel@tonic-gate     char *c, lckdir[BUFSIZ];
10057c478bd9Sstevel@tonic-gate     DIR *dir;
10067c478bd9Sstevel@tonic-gate 
10077c478bd9Sstevel@tonic-gate     DEBUG(9, "lckpid() - entered\n%s", "");
10087c478bd9Sstevel@tonic-gate     for (i=0; i<MAXLOCKS; i++)
10097c478bd9Sstevel@tonic-gate 	list[i] = -1;
10107c478bd9Sstevel@tonic-gate     (void) strcpy(lckdir, LOCKPRE);
10117c478bd9Sstevel@tonic-gate     *strrchr(lckdir, '/') = '\0';
10127c478bd9Sstevel@tonic-gate     DEBUG(9, "lockdir (%s)\n", lckdir);
10137c478bd9Sstevel@tonic-gate 
10147c478bd9Sstevel@tonic-gate     /* open lock directory */
10157c478bd9Sstevel@tonic-gate     if (chdir(lckdir) != 0 || (dir = opendir(lckdir)) == NULL)
10167c478bd9Sstevel@tonic-gate 		exit(101);		/* good old code 101 */
10177c478bd9Sstevel@tonic-gate     while (gnameflck(dir, f) == TRUE) {
10187c478bd9Sstevel@tonic-gate 	/* find all lock files */
10197c478bd9Sstevel@tonic-gate 	DEBUG(9, "f (%s)\n", f);
10207c478bd9Sstevel@tonic-gate 	if (EQUALSN("LCK.", f, 4) || EQUALSN("LK.", f, 3)) {
10217c478bd9Sstevel@tonic-gate 	    /* read LCK file */
10227c478bd9Sstevel@tonic-gate 	    fd = open(f, O_RDONLY);
10237c478bd9Sstevel@tonic-gate 	    printf("%s: ", f);
10247c478bd9Sstevel@tonic-gate 	    ret = read(fd, alpid, SIZEOFPID+2); /* +2 for '\n' and null */
10257c478bd9Sstevel@tonic-gate 	    pid = strtol(alpid, (char **) NULL, 10);
10267c478bd9Sstevel@tonic-gate 	    (void) close(fd);
10277c478bd9Sstevel@tonic-gate 	    if (ret != -1) {
10287c478bd9Sstevel@tonic-gate 		printf("%ld\n", (long) pid);
10297c478bd9Sstevel@tonic-gate 		for(i=0; i<MAXLOCKS; i++) {
10307c478bd9Sstevel@tonic-gate 		    if (list[i] == pid)
10317c478bd9Sstevel@tonic-gate 			break;
10327c478bd9Sstevel@tonic-gate 		    if (list[i] == -1) {
10337c478bd9Sstevel@tonic-gate 		        list[i] = pid;
10347c478bd9Sstevel@tonic-gate 		        break;
10357c478bd9Sstevel@tonic-gate 		    }
10367c478bd9Sstevel@tonic-gate 		}
10377c478bd9Sstevel@tonic-gate 	    }
10387c478bd9Sstevel@tonic-gate 	    else
10397c478bd9Sstevel@tonic-gate 		printf("????\n");
10407c478bd9Sstevel@tonic-gate 	}
10417c478bd9Sstevel@tonic-gate     }
10427c478bd9Sstevel@tonic-gate     fflush(stdout);
10437c478bd9Sstevel@tonic-gate     *buf = NULLCHAR;
10447c478bd9Sstevel@tonic-gate     for (i=0; i<MAXLOCKS; i++) {
10457c478bd9Sstevel@tonic-gate 	if( list[i] == -1)
10467c478bd9Sstevel@tonic-gate 		break;
10477c478bd9Sstevel@tonic-gate 	(void) sprintf(&buf[strlen(buf)], "%d ", list[i]);
10487c478bd9Sstevel@tonic-gate     }
10497c478bd9Sstevel@tonic-gate 
10507c478bd9Sstevel@tonic-gate     if (i > 0)
10517c478bd9Sstevel@tonic-gate #ifdef V7
10527c478bd9Sstevel@tonic-gate 	execl("/bin/ps", "uustat-ps", buf, (char *) 0);
10537c478bd9Sstevel@tonic-gate #else
10547c478bd9Sstevel@tonic-gate 	execl("/usr/bin/ps", "ps", "-flp", buf, (char *) 0);
10557c478bd9Sstevel@tonic-gate #endif
10567c478bd9Sstevel@tonic-gate     exit(0);
10577c478bd9Sstevel@tonic-gate }
10587c478bd9Sstevel@tonic-gate 
10597c478bd9Sstevel@tonic-gate /*
10607c478bd9Sstevel@tonic-gate  * get next file name from lock directory
10617c478bd9Sstevel@tonic-gate  *	p	 -> file description of directory file to read
10627c478bd9Sstevel@tonic-gate  *	filename -> address of buffer to return filename in
10637c478bd9Sstevel@tonic-gate  *		    must be of size NAMESIZE
10647c478bd9Sstevel@tonic-gate  * returns:
10657c478bd9Sstevel@tonic-gate  *	FALSE	-> end of directory read
10667c478bd9Sstevel@tonic-gate  *	TRUE	-> returned name
10677c478bd9Sstevel@tonic-gate  */
10687c478bd9Sstevel@tonic-gate static int
gnameflck(p,filename)10697c478bd9Sstevel@tonic-gate gnameflck(p, filename)
1070462be471Sceastha char *filename;
10717c478bd9Sstevel@tonic-gate DIR *p;
10727c478bd9Sstevel@tonic-gate {
10737c478bd9Sstevel@tonic-gate 	struct dirent dentry;
1074462be471Sceastha 	struct dirent *dp = &dentry;
10757c478bd9Sstevel@tonic-gate 
10767c478bd9Sstevel@tonic-gate 	for (;;) {
10777c478bd9Sstevel@tonic-gate 		if ((dp = readdir(p)) == NULL)
10787c478bd9Sstevel@tonic-gate 			return(FALSE);
10797c478bd9Sstevel@tonic-gate 		if (dp->d_ino != 0 && dp->d_name[0] != '.')
10807c478bd9Sstevel@tonic-gate 			break;
10817c478bd9Sstevel@tonic-gate 	}
10827c478bd9Sstevel@tonic-gate 
10837c478bd9Sstevel@tonic-gate 	(void) strncpy(filename, dp->d_name, MAXNAMESIZE-1);
10847c478bd9Sstevel@tonic-gate 	filename[MAXNAMESIZE-1] = '\0';
10857c478bd9Sstevel@tonic-gate 	return(TRUE);
10867c478bd9Sstevel@tonic-gate }
10877c478bd9Sstevel@tonic-gate 
10887c478bd9Sstevel@tonic-gate int
machcmp(a,b)10897c478bd9Sstevel@tonic-gate machcmp(a,b)
10907c478bd9Sstevel@tonic-gate char *a,*b;
10917c478bd9Sstevel@tonic-gate {
10927c478bd9Sstevel@tonic-gate 	return(strcmp(((struct m *) a)->mach,((struct m *) b)->mach));
10937c478bd9Sstevel@tonic-gate }
10947c478bd9Sstevel@tonic-gate 
10957c478bd9Sstevel@tonic-gate static long _sec_per_day = 86400L;
10967c478bd9Sstevel@tonic-gate 
10977c478bd9Sstevel@tonic-gate /*
10987c478bd9Sstevel@tonic-gate  * _age - find the age of "file" in days
10997c478bd9Sstevel@tonic-gate  * return:
11007c478bd9Sstevel@tonic-gate  *	age of file
11017c478bd9Sstevel@tonic-gate  *	0 - if stat fails
11027c478bd9Sstevel@tonic-gate  */
11037c478bd9Sstevel@tonic-gate 
11047c478bd9Sstevel@tonic-gate int
_age(dir,file)11057c478bd9Sstevel@tonic-gate _age(dir, file)
11067c478bd9Sstevel@tonic-gate char * file;	/* the file name */
11077c478bd9Sstevel@tonic-gate char * dir;	/* system spool directory */
11087c478bd9Sstevel@tonic-gate {
11097c478bd9Sstevel@tonic-gate 	char fullname[MAXFULLNAME];
11107c478bd9Sstevel@tonic-gate 	static time_t ptime = 0;
11117c478bd9Sstevel@tonic-gate 	time_t time();
11127c478bd9Sstevel@tonic-gate 	struct stat stbuf;
11137c478bd9Sstevel@tonic-gate 
11147c478bd9Sstevel@tonic-gate 	if (!ptime)
11157c478bd9Sstevel@tonic-gate 		(void) time(&ptime);
11167c478bd9Sstevel@tonic-gate 	(void) sprintf(fullname, "%s/%s", dir, file);
11177c478bd9Sstevel@tonic-gate 	if (stat(fullname, &stbuf) != -1) {
11187c478bd9Sstevel@tonic-gate 		return ((int)((ptime - stbuf.st_mtime)/_sec_per_day));
11197c478bd9Sstevel@tonic-gate 	}
11207c478bd9Sstevel@tonic-gate 	else
11217c478bd9Sstevel@tonic-gate 		return(0);
11227c478bd9Sstevel@tonic-gate }
11237c478bd9Sstevel@tonic-gate /* Function:  complete - find and print jobids of completed jobs for
11247c478bd9Sstevel@tonic-gate  *		         user.
11257c478bd9Sstevel@tonic-gate  *
11267c478bd9Sstevel@tonic-gate  * Look thru the /var/uucp/.Admin/account file (if present)
11277c478bd9Sstevel@tonic-gate  * for all jobs initiated by user and print.
11287c478bd9Sstevel@tonic-gate  *
112955fea89dSDan Cross  * Parameters:
11307c478bd9Sstevel@tonic-gate  *
11317c478bd9Sstevel@tonic-gate  *		Username - user that initiated uustat request
11327c478bd9Sstevel@tonic-gate  *
11337c478bd9Sstevel@tonic-gate  * Returns:
11347c478bd9Sstevel@tonic-gate  *
11357c478bd9Sstevel@tonic-gate  */
11367c478bd9Sstevel@tonic-gate static void
complete()11377c478bd9Sstevel@tonic-gate complete()
11387c478bd9Sstevel@tonic-gate {
11397c478bd9Sstevel@tonic-gate 
11407c478bd9Sstevel@tonic-gate 	/* Function name: complete
11417c478bd9Sstevel@tonic-gate 	   Author:	  Roland T. Conwell
11427c478bd9Sstevel@tonic-gate 	   Date:	  July 31, 1986
11437c478bd9Sstevel@tonic-gate 	   Naration: This function will search through
11447c478bd9Sstevel@tonic-gate 		     /var/uucp/.Admin/account file
11457c478bd9Sstevel@tonic-gate 		     for all jobs submitted by User.  If User jobs are
11467c478bd9Sstevel@tonic-gate 		     found the state of 'completed' will be
11477c478bd9Sstevel@tonic-gate 		     printed on stdout. Module called by uustat main
11487c478bd9Sstevel@tonic-gate 
11497c478bd9Sstevel@tonic-gate 	*/
11507c478bd9Sstevel@tonic-gate char abuf[BUFSIZ];
11517c478bd9Sstevel@tonic-gate FILE *fp;
11527c478bd9Sstevel@tonic-gate char accno[15], jobid[15], system[15], loginame[15], time[20], dest[15];
11537c478bd9Sstevel@tonic-gate char size[15];
11547c478bd9Sstevel@tonic-gate char grade[2], jgrade[2];
11557c478bd9Sstevel@tonic-gate char status[2];
11567c478bd9Sstevel@tonic-gate int x;
11577c478bd9Sstevel@tonic-gate 
11587c478bd9Sstevel@tonic-gate fp = fopen(ACCOUNT, "r");
11597c478bd9Sstevel@tonic-gate if (fp == NULL)
11607c478bd9Sstevel@tonic-gate    {
11617c478bd9Sstevel@tonic-gate 	fprintf(stderr, gettext("Can't open account log\n"));
11627c478bd9Sstevel@tonic-gate 		return;
11637c478bd9Sstevel@tonic-gate    }
11647c478bd9Sstevel@tonic-gate while (fgets(abuf, BUFSIZ, fp) != NULL)
11657c478bd9Sstevel@tonic-gate    {
11667c478bd9Sstevel@tonic-gate 
11677c478bd9Sstevel@tonic-gate 	x = sscanf(abuf, "%s%s%s%s%s%s%s%s%s%s",
11687c478bd9Sstevel@tonic-gate 		accno,jobid, size, status, grade, jgrade, system, loginame,
11697c478bd9Sstevel@tonic-gate 		time, dest);
11707c478bd9Sstevel@tonic-gate 	if (x < 6)
11717c478bd9Sstevel@tonic-gate 		continue;
11727c478bd9Sstevel@tonic-gate 
11737c478bd9Sstevel@tonic-gate 	if (!EQUALS(status, "C"))
11747c478bd9Sstevel@tonic-gate 		continue;
11757c478bd9Sstevel@tonic-gate 
11767c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: accno = %s\n", accno);
11777c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: jobid = %s\n", jobid);
11787c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: size = %s\n", size);
11797c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: status = %s\n", status);
11807c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: grade = %s\n", grade);
11817c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: jgrade = %s\n", jgrade);
11827c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: system = %s\n", system);
11837c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: loginame = %s\n", loginame);
11847c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: time = %s\n", time);
11857c478bd9Sstevel@tonic-gate 	DEBUG(9, "COMPLETE: dest = %s\n", dest);
11867c478bd9Sstevel@tonic-gate 
11877c478bd9Sstevel@tonic-gate 	if (*Rmtname && !EQUALS(Rmtname, dest))
11887c478bd9Sstevel@tonic-gate 		continue;
11897c478bd9Sstevel@tonic-gate 	if (*User && !EQUALS(User, loginame))
11907c478bd9Sstevel@tonic-gate 		continue;
11917c478bd9Sstevel@tonic-gate 	if (State && !Uopt)
11927c478bd9Sstevel@tonic-gate 	  {
11937c478bd9Sstevel@tonic-gate 	   if (EQUALS(Loginuser, loginame))
11947c478bd9Sstevel@tonic-gate 		{
11957c478bd9Sstevel@tonic-gate 			printf("%s completed\n",jobid);
11967c478bd9Sstevel@tonic-gate 			jobcount++;
11977c478bd9Sstevel@tonic-gate 		}
11987c478bd9Sstevel@tonic-gate 	  }
11997c478bd9Sstevel@tonic-gate 	else
12007c478bd9Sstevel@tonic-gate 	  {
12017c478bd9Sstevel@tonic-gate 		printf("%s completed\n", jobid);
12027c478bd9Sstevel@tonic-gate 		jobcount++;
12037c478bd9Sstevel@tonic-gate 	  }
12047c478bd9Sstevel@tonic-gate    }
12057c478bd9Sstevel@tonic-gate    fclose(fp);
12067c478bd9Sstevel@tonic-gate    return;
12077c478bd9Sstevel@tonic-gate }
12087c478bd9Sstevel@tonic-gate 
12097c478bd9Sstevel@tonic-gate /* Function: state - determine if Cdotfile is queued or running
12107c478bd9Sstevel@tonic-gate  *
121155fea89dSDan Cross  * This function searches thru the directory jcdir for a Adotfile
12127c478bd9Sstevel@tonic-gate  * that matches the Cdotfile.  If found then look for a matching
12137c478bd9Sstevel@tonic-gate  * lock file.  If a Adotfile and a lock file is found then the
12147c478bd9Sstevel@tonic-gate  * job is in the running state.  If no Adotfile is found then the
12157c478bd9Sstevel@tonic-gate  * job is in the queued state.  If a Adotfile is found and no
12167c478bd9Sstevel@tonic-gate  * lock file is found then the job is queued.
121755fea89dSDan Cross  *
12187c478bd9Sstevel@tonic-gate  * Parameters:
12197c478bd9Sstevel@tonic-gate  *
12207c478bd9Sstevel@tonic-gate  *	jcdir    -   the job grade directory to search
12217c478bd9Sstevel@tonic-gate  *	cdotfile -   the Cdotfile whose state is to be determined
12227c478bd9Sstevel@tonic-gate  *
122355fea89dSDan Cross  * Returns:
12247c478bd9Sstevel@tonic-gate  *
12257c478bd9Sstevel@tonic-gate  */
12267c478bd9Sstevel@tonic-gate static int
state(jcdir,cdotfile)12277c478bd9Sstevel@tonic-gate state(jcdir, cdotfile)
12287c478bd9Sstevel@tonic-gate char *jcdir, *cdotfile;
12297c478bd9Sstevel@tonic-gate {
123055fea89dSDan Cross 	short found, foundlck, CequalA;
12317c478bd9Sstevel@tonic-gate 	char comparef[MAXBASENAME+1], afile[MAXBASENAME+1], cfile[MAXBASENAME+1];
12327c478bd9Sstevel@tonic-gate 	char lckfile[MAXBASENAME+1], lockname[MAXBASENAME+1];
12337c478bd9Sstevel@tonic-gate 	char lckdir[BUFSIZ+1];
12347c478bd9Sstevel@tonic-gate 	DIR *subjcdir, *sjcdir;
1235462be471Sceastha 	int rtnstate = 0;
12367c478bd9Sstevel@tonic-gate 	foundlck = 0;
12377c478bd9Sstevel@tonic-gate 	CequalA = 0;
12387c478bd9Sstevel@tonic-gate 	sjcdir = opendir(jcdir);
12397c478bd9Sstevel@tonic-gate 	if (sjcdir == NULL)
1240462be471Sceastha 		return (0);
12417c478bd9Sstevel@tonic-gate 
12427c478bd9Sstevel@tonic-gate 	while (gnamef(sjcdir, comparef) == TRUE) {
12437c478bd9Sstevel@tonic-gate 	    if (comparef[0] == 'A') {
12447c478bd9Sstevel@tonic-gate 
12457c478bd9Sstevel@tonic-gate 		(void) strcpy(afile, comparef);
12467c478bd9Sstevel@tonic-gate 		*strchr(afile, 'A') = ' ';
12477c478bd9Sstevel@tonic-gate 		(void) strcpy(cfile, cdotfile);
12487c478bd9Sstevel@tonic-gate 		*strchr(cfile, 'C') = ' ';
12497c478bd9Sstevel@tonic-gate 
12507c478bd9Sstevel@tonic-gate 		if (EQUALS(cfile, afile)) {
12517c478bd9Sstevel@tonic-gate 	 	    /* now we have a C. and A. for same job */
12527c478bd9Sstevel@tonic-gate 	  	    /* check for LCK..machine.job_grade     */
12537c478bd9Sstevel@tonic-gate 		    /* if no LCK file at this point we will */
12547c478bd9Sstevel@tonic-gate 		    /* print the RUNNING state	        */
12557c478bd9Sstevel@tonic-gate 			CequalA = 1;
12567c478bd9Sstevel@tonic-gate 
12577c478bd9Sstevel@tonic-gate 			(void) strcpy(lckdir, LOCKPRE);
12587c478bd9Sstevel@tonic-gate 			*strrchr(lckdir, '/') = '\0';
12597c478bd9Sstevel@tonic-gate 			/* open lock directory */
126055fea89dSDan Cross 
12617c478bd9Sstevel@tonic-gate 			subjcdir = opendir(lckdir);
12627c478bd9Sstevel@tonic-gate 			if (subjcdir == NULL)
12637c478bd9Sstevel@tonic-gate 			   exit(101); /* I know, I know! */
12647c478bd9Sstevel@tonic-gate 			(void) sprintf(lockname,"%s%s.%s",LOCK, f, jcdir);
12657c478bd9Sstevel@tonic-gate 			while (gnamef(subjcdir, lckfile) == TRUE)
12667c478bd9Sstevel@tonic-gate 			  {
12677c478bd9Sstevel@tonic-gate 			    DEBUG(9, "STATE: lockfile = %s\n",lckfile);
12687c478bd9Sstevel@tonic-gate 			    if (EQUALS(lockname, lckfile))
12697c478bd9Sstevel@tonic-gate 			          foundlck = 1;
12707c478bd9Sstevel@tonic-gate 			  }
127155fea89dSDan Cross 			closedir(subjcdir);
12727c478bd9Sstevel@tonic-gate 
12737c478bd9Sstevel@tonic-gate 			}
127455fea89dSDan Cross 		}
12757c478bd9Sstevel@tonic-gate 
12767c478bd9Sstevel@tonic-gate 	}
12777c478bd9Sstevel@tonic-gate 
12787c478bd9Sstevel@tonic-gate 	closedir(sjcdir);
12797c478bd9Sstevel@tonic-gate 	/* got adot, cdot and lock file */
12807c478bd9Sstevel@tonic-gate 
12817c478bd9Sstevel@tonic-gate 	if (Running && foundlck)
12827c478bd9Sstevel@tonic-gate 		rtnstate = 2;
12837c478bd9Sstevel@tonic-gate 	else if (Interrupted && CequalA && !foundlck)
12847c478bd9Sstevel@tonic-gate 		rtnstate = 3;
12857c478bd9Sstevel@tonic-gate 	else if (Queued && !CequalA && !foundlck)
12867c478bd9Sstevel@tonic-gate 		rtnstate = 1;
12877c478bd9Sstevel@tonic-gate 	DEBUG(9, "STATE: returning with value %d\n",rtnstate);
12887c478bd9Sstevel@tonic-gate 	return(rtnstate);
12897c478bd9Sstevel@tonic-gate 
12907c478bd9Sstevel@tonic-gate } /* end of state.c */
12917c478bd9Sstevel@tonic-gate 
12927c478bd9Sstevel@tonic-gate 
12937c478bd9Sstevel@tonic-gate 
129455fea89dSDan Cross static int
readperf(timerange)12957c478bd9Sstevel@tonic-gate readperf(timerange)
12967c478bd9Sstevel@tonic-gate long timerange;
12977c478bd9Sstevel@tonic-gate {
129855fea89dSDan Cross 
12997c478bd9Sstevel@tonic-gate 	char proto[2], jc[2], role[2];
13007c478bd9Sstevel@tonic-gate 	char rectype[5],  time[MAXDATE+1], pid[10],wmachine[10];
13017c478bd9Sstevel@tonic-gate 	char remote[10],device[10], netid[20], jobid[20];
13027c478bd9Sstevel@tonic-gate 	static float queuetime, tat;
13037c478bd9Sstevel@tonic-gate 	static long size;
130455fea89dSDan Cross         struct tm tm_tmp;
13057c478bd9Sstevel@tonic-gate 	time_t t_time, t_starttime, t_upperlimit;
13067c478bd9Sstevel@tonic-gate 
13077c478bd9Sstevel@tonic-gate 	char options[10];
13087c478bd9Sstevel@tonic-gate 	static float rst, ust, kst, xferrate, utt, ktt;
13097c478bd9Sstevel@tonic-gate 	static float rtt, wfield, xfield, yfield;
13107c478bd9Sstevel@tonic-gate 
1311462be471Sceastha 	struct perfrec *recptr;
13127c478bd9Sstevel@tonic-gate 	static float tqt;
13137c478bd9Sstevel@tonic-gate 	static int jobs;
13147c478bd9Sstevel@tonic-gate 	char abuf[BUFSIZ];
13157c478bd9Sstevel@tonic-gate 	FILE *fp;
13167c478bd9Sstevel@tonic-gate 	static int x;
13177c478bd9Sstevel@tonic-gate 	char *strptr, *startime;
13187c478bd9Sstevel@tonic-gate 	int recordcnt;
13197c478bd9Sstevel@tonic-gate 
13207c478bd9Sstevel@tonic-gate 	totalxfer=totalbytes=recordcnt=totaljob=totalque=0;
13217c478bd9Sstevel@tonic-gate 	lowerlimit[0] = '\0';
13227c478bd9Sstevel@tonic-gate 	upperlimit[0] = '\0';
132355fea89dSDan Cross 
132455fea89dSDan Cross 
13257c478bd9Sstevel@tonic-gate 	inputsecs = convert(timerange);
13267c478bd9Sstevel@tonic-gate 	startime = gmts();
13277c478bd9Sstevel@tonic-gate 	strncpy(lowerlimit, startime, MAXDATE);
13287c478bd9Sstevel@tonic-gate 	strncpy(upperlimit, gmt(), MAXDATE);
13297c478bd9Sstevel@tonic-gate 
13307c478bd9Sstevel@tonic-gate 	/* convert lowerlimit and upperlimit to HH:MM format */
13317c478bd9Sstevel@tonic-gate 	friendlytime(lowerlimit, upperlimit);
13327c478bd9Sstevel@tonic-gate 
13337c478bd9Sstevel@tonic-gate 	fp = fopen(PERFLOG, "r");
13347c478bd9Sstevel@tonic-gate 	if (fp == NULL)
13357c478bd9Sstevel@tonic-gate  	  {
13367c478bd9Sstevel@tonic-gate 		(void) fprintf(stderr, gettext("Can't open performance log\n"));
13377c478bd9Sstevel@tonic-gate 			return(0);
13387c478bd9Sstevel@tonic-gate 	   }
13397c478bd9Sstevel@tonic-gate 
13407c478bd9Sstevel@tonic-gate 
13417c478bd9Sstevel@tonic-gate 	while (fgets(abuf, BUFSIZ, fp) != NULL)
13427c478bd9Sstevel@tonic-gate 	  {
13437c478bd9Sstevel@tonic-gate 	    DEBUG(9, "READPERF: abuf before = %s\n",abuf);
13447c478bd9Sstevel@tonic-gate 
13457c478bd9Sstevel@tonic-gate 	    if (!EQUALSN(abuf, "xfer", 4))
13467c478bd9Sstevel@tonic-gate 		continue;
13477c478bd9Sstevel@tonic-gate 
13487c478bd9Sstevel@tonic-gate             /* convert all '|'s to blanks for sscanf */
13497c478bd9Sstevel@tonic-gate 	    for (strptr = abuf; *strptr != '\0'; strptr++)
13507c478bd9Sstevel@tonic-gate 		if (*strptr == '|')
13517c478bd9Sstevel@tonic-gate 		    *strptr = ' ';
13527c478bd9Sstevel@tonic-gate 	    DEBUG(9, "READPERF: abuf = %s\n",abuf);
13537c478bd9Sstevel@tonic-gate 
135455fea89dSDan Cross 	    x = sscanf(abuf, "%s%*s%s%s%s%s%s%s%*s%s%s%f%f%ld%s%f%f%f%f%f%f%f%f%f%*s",
13557c478bd9Sstevel@tonic-gate 		rectype, time, pid, wmachine, role, remote, device, netid,
13567c478bd9Sstevel@tonic-gate 		jobid, &queuetime, &tat, &size, options, &rst,
13577c478bd9Sstevel@tonic-gate 		&ust, &kst, &xferrate, &utt, &ktt, &rtt, &wfield,
13587c478bd9Sstevel@tonic-gate 		&xfield);
13597c478bd9Sstevel@tonic-gate 
13607c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: rectype = %s\n",rectype);
13617c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: time = %s\n",time);
13627c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: pid = %s\n",pid);
13637c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: remote = %s\n",remote);
13647c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: jobid = %s\n",jobid);
13657c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: queuetime = %f\n",queuetime);
13667c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: tat = %f\n",tat);
13677c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: xferrate = %f\n",xferrate);
13687c478bd9Sstevel@tonic-gate 
13697c478bd9Sstevel@tonic-gate 		abuf[0] = '\0';
137055fea89dSDan Cross 
13717c478bd9Sstevel@tonic-gate 		if (!EQUALS(Rmtname, remote))
13727c478bd9Sstevel@tonic-gate 			continue;
13737c478bd9Sstevel@tonic-gate 
13747c478bd9Sstevel@tonic-gate 		if (!EQUALS(role, "M"))
13757c478bd9Sstevel@tonic-gate 			continue;
13767c478bd9Sstevel@tonic-gate 
13777c478bd9Sstevel@tonic-gate 		if (x < 18)
13787c478bd9Sstevel@tonic-gate 			continue;
13797c478bd9Sstevel@tonic-gate 
13807c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: startime = %s\n", startime);
13817c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: lowerlimit = %s\n", lowerlimit);
13827c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: time = %s\n", time);
13837c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: upperlimit = %s\n", upperlimit);
13847c478bd9Sstevel@tonic-gate 
13857c478bd9Sstevel@tonic-gate 		strptime(time, "%y %m %d %H %M %S", &tm_tmp);
13867c478bd9Sstevel@tonic-gate 		t_time = mktime(&tm_tmp);
13877c478bd9Sstevel@tonic-gate 		strptime(startime, "%y %m %d %H %M %S", &tm_tmp);
13887c478bd9Sstevel@tonic-gate 		t_starttime = mktime(&tm_tmp);
13897c478bd9Sstevel@tonic-gate 		strptime(upperlimit, "%y %m %d %H %M %S", &tm_tmp);
13907c478bd9Sstevel@tonic-gate 		t_upperlimit = mktime(&tm_tmp);
13917c478bd9Sstevel@tonic-gate 
13927c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: t_time = %d\n", t_time);
13937c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: t_starttime = %d\n", t_starttime);
13947c478bd9Sstevel@tonic-gate 		DEBUG(9, "READPERF: t_upperlimit = %d\n", t_upperlimit);
13957c478bd9Sstevel@tonic-gate 		if (t_starttime <= t_time && t_upperlimit >= t_time)
13967c478bd9Sstevel@tonic-gate 		{
139755fea89dSDan Cross 			totaljob++;
13987c478bd9Sstevel@tonic-gate 			totalque = totalque + queuetime;
13997c478bd9Sstevel@tonic-gate 			totalxfer = totalxfer + xferrate;
14007c478bd9Sstevel@tonic-gate 			totalbytes = totalbytes + size;
14017c478bd9Sstevel@tonic-gate 			recordcnt = recordcnt + 1;
14027c478bd9Sstevel@tonic-gate 		DEBUG(9, "  processing recordcnt %d\n", recordcnt);
14037c478bd9Sstevel@tonic-gate 		}
14047c478bd9Sstevel@tonic-gate 	DEBUG(9, "END step 1 %d\n", recordcnt);
14057c478bd9Sstevel@tonic-gate   	 } /* while */
14067c478bd9Sstevel@tonic-gate 	DEBUG(9, "END step 2 recordcnt %d\n", recordcnt);
14077c478bd9Sstevel@tonic-gate 
14087c478bd9Sstevel@tonic-gate 	fclose(fp);
14097c478bd9Sstevel@tonic-gate 	return(recordcnt);
14107c478bd9Sstevel@tonic-gate 
14117c478bd9Sstevel@tonic-gate 
14127c478bd9Sstevel@tonic-gate } /* end of readperf */
14137c478bd9Sstevel@tonic-gate 
14147c478bd9Sstevel@tonic-gate void
docalc()14157c478bd9Sstevel@tonic-gate docalc()
14167c478bd9Sstevel@tonic-gate {
14177c478bd9Sstevel@tonic-gate    if (avgqueue)
14187c478bd9Sstevel@tonic-gate 	queuetime();
14197c478bd9Sstevel@tonic-gate    else
14207c478bd9Sstevel@tonic-gate 	xfertime();
14217c478bd9Sstevel@tonic-gate    return;
14227c478bd9Sstevel@tonic-gate }
14237c478bd9Sstevel@tonic-gate 
14247c478bd9Sstevel@tonic-gate static int
convert(intime)14257c478bd9Sstevel@tonic-gate convert(intime)
14267c478bd9Sstevel@tonic-gate long intime;
14277c478bd9Sstevel@tonic-gate {
14287c478bd9Sstevel@tonic-gate 	long outtime;
14297c478bd9Sstevel@tonic-gate 
14307c478bd9Sstevel@tonic-gate 	outtime = intime * 60;
14317c478bd9Sstevel@tonic-gate 	return(outtime);
14327c478bd9Sstevel@tonic-gate 
14337c478bd9Sstevel@tonic-gate }
14347c478bd9Sstevel@tonic-gate static void
queuetime()14357c478bd9Sstevel@tonic-gate queuetime()
14367c478bd9Sstevel@tonic-gate {
14377c478bd9Sstevel@tonic-gate  	static double avgqtime;
14387c478bd9Sstevel@tonic-gate 
14397c478bd9Sstevel@tonic-gate 	avgqtime = totalque / totaljob;
14407c478bd9Sstevel@tonic-gate 
14417c478bd9Sstevel@tonic-gate 	printf("average queue time to [%s] for last [%ld] minutes:  %6.2f seconds\n",Rmtname, calcnum, avgqtime);
14427c478bd9Sstevel@tonic-gate  	 printf("data gathered from %s:%s to %s:%s GMT\n", friendlyptr->uhour, friendlyptr->umin, friendlyptr->lhour, friendlyptr->lmin);
14437c478bd9Sstevel@tonic-gate 	return;
14447c478bd9Sstevel@tonic-gate }
14457c478bd9Sstevel@tonic-gate 
14467c478bd9Sstevel@tonic-gate 
14477c478bd9Sstevel@tonic-gate static void
xfertime()14487c478bd9Sstevel@tonic-gate xfertime()
14497c478bd9Sstevel@tonic-gate {
14507c478bd9Sstevel@tonic-gate          static double avgxrate;
14517c478bd9Sstevel@tonic-gate 
14527c478bd9Sstevel@tonic-gate 	avgxrate = totalbytes / totalxfer;
14537c478bd9Sstevel@tonic-gate 
14547c478bd9Sstevel@tonic-gate 	printf("average transfer rate with [ %s ] for last [%ld] minutes: %6.2f bytes/sec\n", Rmtname, calcnum, avgxrate);
14557c478bd9Sstevel@tonic-gate  	 printf("data gathered from %s:%s to %s:%s GMT\n", friendlyptr->uhour, friendlyptr->umin, friendlyptr->lhour, friendlyptr->lmin);
14567c478bd9Sstevel@tonic-gate 	return;
14577c478bd9Sstevel@tonic-gate }
14587c478bd9Sstevel@tonic-gate 
14597c478bd9Sstevel@tonic-gate /*
14607c478bd9Sstevel@tonic-gate  * Local Function:	gmts - Generate Start Time String
14617c478bd9Sstevel@tonic-gate  *
14627c478bd9Sstevel@tonic-gate  * This function returns the address to a string containing the start
14637c478bd9Sstevel@tonic-gate  * time, or upperlimit, for searching the PERFLOG.
14647c478bd9Sstevel@tonic-gate  * The start time is in GMT in the form YYMMDDhhmmss.
14657c478bd9Sstevel@tonic-gate  *
14667c478bd9Sstevel@tonic-gate  * Parameters:
14677c478bd9Sstevel@tonic-gate  *
14687c478bd9Sstevel@tonic-gate  *	none
14697c478bd9Sstevel@tonic-gate  *
14707c478bd9Sstevel@tonic-gate  * Return:
14717c478bd9Sstevel@tonic-gate  *
14727c478bd9Sstevel@tonic-gate  *	An address of a static character array containing the date.
14737c478bd9Sstevel@tonic-gate  */
14747c478bd9Sstevel@tonic-gate 
14757c478bd9Sstevel@tonic-gate static char *
gmts()14767c478bd9Sstevel@tonic-gate gmts()
14777c478bd9Sstevel@tonic-gate {
14787c478bd9Sstevel@tonic-gate 	static char	date[] = "YYMMDDhhmmss";
14797c478bd9Sstevel@tonic-gate 
1480462be471Sceastha 	struct tm 		*td;
14817c478bd9Sstevel@tonic-gate 	time_t			now;	/* Current time. */
14827c478bd9Sstevel@tonic-gate 	time_t			temp;
14837c478bd9Sstevel@tonic-gate 	now = time((time_t *) 0);
14847c478bd9Sstevel@tonic-gate 
14857c478bd9Sstevel@tonic-gate 	/* inputsecs is declared global to this file */
14867c478bd9Sstevel@tonic-gate 	DEBUG(9, "GMTS: now = %ld\n", now);
14877c478bd9Sstevel@tonic-gate 	DEBUG(9, "GMTS: inputsecs = %ld\n", inputsecs);
14887c478bd9Sstevel@tonic-gate 
14897c478bd9Sstevel@tonic-gate 	temp = (now - inputsecs);
14907c478bd9Sstevel@tonic-gate 	td = gmtime(&temp);
14917c478bd9Sstevel@tonic-gate 	(void) sprintf(date, "%02d%02d%02d%02d%02d%02d",
14927c478bd9Sstevel@tonic-gate 				(td->tm_year % 100),
14937c478bd9Sstevel@tonic-gate 				td->tm_mon + 1,
14947c478bd9Sstevel@tonic-gate 				td->tm_mday,
14957c478bd9Sstevel@tonic-gate 				td->tm_hour,
14967c478bd9Sstevel@tonic-gate 				td->tm_min,
14977c478bd9Sstevel@tonic-gate 				td->tm_sec
14987c478bd9Sstevel@tonic-gate 		      );
14997c478bd9Sstevel@tonic-gate 	return date;
15007c478bd9Sstevel@tonic-gate }
15017c478bd9Sstevel@tonic-gate 
15027c478bd9Sstevel@tonic-gate /*
15037c478bd9Sstevel@tonic-gate  * Local Function:	gmt - Generate Current Time String
15047c478bd9Sstevel@tonic-gate  *
15057c478bd9Sstevel@tonic-gate  * This function returns the address to a string containing the current
15067c478bd9Sstevel@tonic-gate  * GMT in the form YYMMDDhhmmss.
15077c478bd9Sstevel@tonic-gate  *
15087c478bd9Sstevel@tonic-gate  * Parameters:
15097c478bd9Sstevel@tonic-gate  *
15107c478bd9Sstevel@tonic-gate  *	none
15117c478bd9Sstevel@tonic-gate  *
15127c478bd9Sstevel@tonic-gate  * Return:
15137c478bd9Sstevel@tonic-gate  *
15147c478bd9Sstevel@tonic-gate  *	An address of a static character array containing the date.
15157c478bd9Sstevel@tonic-gate  */
15167c478bd9Sstevel@tonic-gate 
15177c478bd9Sstevel@tonic-gate static char *
gmt()15187c478bd9Sstevel@tonic-gate gmt()
15197c478bd9Sstevel@tonic-gate {
15207c478bd9Sstevel@tonic-gate 	static char	date[] = "YYMMDDhhmmss";
15217c478bd9Sstevel@tonic-gate 
1522462be471Sceastha 	struct tm	*td;
15237c478bd9Sstevel@tonic-gate 	time_t			now;	/* Current time. */
15247c478bd9Sstevel@tonic-gate 
15257c478bd9Sstevel@tonic-gate 	now = time((time_t *) 0);
15267c478bd9Sstevel@tonic-gate 	td = gmtime(&now);
15277c478bd9Sstevel@tonic-gate 	(void) sprintf(date, "%02d%02d%02d%02d%02d%02d",
15287c478bd9Sstevel@tonic-gate 				(td->tm_year % 100),
15297c478bd9Sstevel@tonic-gate 				td->tm_mon + 1,
15307c478bd9Sstevel@tonic-gate 				td->tm_mday,
15317c478bd9Sstevel@tonic-gate 				td->tm_hour,
15327c478bd9Sstevel@tonic-gate 				td->tm_min,
15337c478bd9Sstevel@tonic-gate 				td->tm_sec
15347c478bd9Sstevel@tonic-gate 		      );
15357c478bd9Sstevel@tonic-gate 	return date;
15367c478bd9Sstevel@tonic-gate }
15377c478bd9Sstevel@tonic-gate 
15387c478bd9Sstevel@tonic-gate static void
friendlytime(uplimit,lolimit)15397c478bd9Sstevel@tonic-gate friendlytime(uplimit, lolimit)
15407c478bd9Sstevel@tonic-gate char *uplimit, *lolimit;
15417c478bd9Sstevel@tonic-gate {
15427c478bd9Sstevel@tonic-gate 
15437c478bd9Sstevel@tonic-gate 	friendlyptr->uhour[0] = *(uplimit+6);
15447c478bd9Sstevel@tonic-gate 	friendlyptr->uhour[1] = *(uplimit+7);
15457c478bd9Sstevel@tonic-gate 	friendlyptr->lhour[0] = *(lolimit+6);
15467c478bd9Sstevel@tonic-gate 	friendlyptr->lhour[1] = *(lolimit+7);
15477c478bd9Sstevel@tonic-gate 	friendlyptr->umin[0]  = *(uplimit+8);
15487c478bd9Sstevel@tonic-gate 	friendlyptr->umin[1]  = *(uplimit+9);
15497c478bd9Sstevel@tonic-gate 	friendlyptr->lmin[0]  = *(lolimit+8);
15507c478bd9Sstevel@tonic-gate 	friendlyptr->lmin[1]  = *(lolimit+9);
15517c478bd9Sstevel@tonic-gate 
15527c478bd9Sstevel@tonic-gate 	friendlyptr->uhour[2] = '\0';
15537c478bd9Sstevel@tonic-gate 	friendlyptr->lhour[2] = '\0';
15547c478bd9Sstevel@tonic-gate 	friendlyptr->umin[2] = '\0';
15557c478bd9Sstevel@tonic-gate 	friendlyptr->lmin[2] = '\0';
15567c478bd9Sstevel@tonic-gate 	return;
15577c478bd9Sstevel@tonic-gate }
15587c478bd9Sstevel@tonic-gate 
15597c478bd9Sstevel@tonic-gate void
procState(inputargs)15607c478bd9Sstevel@tonic-gate procState(inputargs)
15617c478bd9Sstevel@tonic-gate char * inputargs;
15627c478bd9Sstevel@tonic-gate {
15637c478bd9Sstevel@tonic-gate 	if (strchr(inputargs, 'q') != NULL)
15647c478bd9Sstevel@tonic-gate 		Queued = 1;
15657c478bd9Sstevel@tonic-gate 	if (strchr(inputargs, 'r') != NULL)
15667c478bd9Sstevel@tonic-gate 		Running = 1;
15677c478bd9Sstevel@tonic-gate 	if (strchr(inputargs, 'i') != NULL)
15687c478bd9Sstevel@tonic-gate 		Interrupted = 1;
15697c478bd9Sstevel@tonic-gate 	if (strchr(inputargs, 'c') != NULL)
15707c478bd9Sstevel@tonic-gate 		Complete = 1;
15717c478bd9Sstevel@tonic-gate 
15727c478bd9Sstevel@tonic-gate 	if ((size_t)(Queued + Running + Interrupted + Complete) < strlen(inputargs))
15737c478bd9Sstevel@tonic-gate 		{
15747c478bd9Sstevel@tonic-gate 			errortn();
15757c478bd9Sstevel@tonic-gate 			exit(1);
15767c478bd9Sstevel@tonic-gate 		}
15777c478bd9Sstevel@tonic-gate 	return;
15787c478bd9Sstevel@tonic-gate }
15797c478bd9Sstevel@tonic-gate 
15807c478bd9Sstevel@tonic-gate static void
errortn()15817c478bd9Sstevel@tonic-gate errortn()
15827c478bd9Sstevel@tonic-gate {
15837c478bd9Sstevel@tonic-gate 
15847c478bd9Sstevel@tonic-gate 
15857c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, gettext("\tUsage: %s " USAGE1 "\n"),
15867c478bd9Sstevel@tonic-gate 	    Progname);
15877c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, gettext("or\n\tUsage: %s " USAGE2 "\n"),
15887c478bd9Sstevel@tonic-gate 	    Progname);
15897c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, gettext("or\n\tUsage: %s " USAGE3 "\n"),
15907c478bd9Sstevel@tonic-gate 	    Progname);
15917c478bd9Sstevel@tonic-gate 	return;
15927c478bd9Sstevel@tonic-gate }
1593