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