1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate /* 26*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 27*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 28*7c478bd9Sstevel@tonic-gate */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate #include <time.h> 32*7c478bd9Sstevel@tonic-gate #include "uucp.h" 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifdef V7 35*7c478bd9Sstevel@tonic-gate #define O_RDONLY 0 36*7c478bd9Sstevel@tonic-gate #endif 37*7c478bd9Sstevel@tonic-gate #define KILLMSG "the system administrator has killed job" 38*7c478bd9Sstevel@tonic-gate #define USAGE1 "[-q] | [-m] | [-k JOB [-n]] | [-r JOB [-n]] | [-p]" 39*7c478bd9Sstevel@tonic-gate #define USAGE2 "[-a] [-s SYSTEM [-j]] [-u USER] [-S STATE]" 40*7c478bd9Sstevel@tonic-gate #define USAGE3 "-t SYSTEM [-d number] [-c]" 41*7c478bd9Sstevel@tonic-gate #define LOCK "LCK.." 42*7c478bd9Sstevel@tonic-gate #define STST_MAX 132 43*7c478bd9Sstevel@tonic-gate #define MAXDATE 12 44*7c478bd9Sstevel@tonic-gate #define MINTIME 60 45*7c478bd9Sstevel@tonic-gate #define MINUTES 60 46*7c478bd9Sstevel@tonic-gate #define CHAR "a" 47*7c478bd9Sstevel@tonic-gate #define MAXSTATE 4 48*7c478bd9Sstevel@tonic-gate /* #include "logs.h" */ 49*7c478bd9Sstevel@tonic-gate struct m { 50*7c478bd9Sstevel@tonic-gate char mach[15]; /* machine name */ 51*7c478bd9Sstevel@tonic-gate char locked; 52*7c478bd9Sstevel@tonic-gate int ccount, xcount; 53*7c478bd9Sstevel@tonic-gate int count, type; 54*7c478bd9Sstevel@tonic-gate long retrytime; 55*7c478bd9Sstevel@tonic-gate time_t lasttime; 56*7c478bd9Sstevel@tonic-gate short c_age; /* age of oldest C. file */ 57*7c478bd9Sstevel@tonic-gate short x_age; /* age of oldest X. file */ 58*7c478bd9Sstevel@tonic-gate char stst[STST_MAX]; 59*7c478bd9Sstevel@tonic-gate } M[UUSTAT_TBL+2]; 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate struct userdate { 63*7c478bd9Sstevel@tonic-gate char uhour[3]; 64*7c478bd9Sstevel@tonic-gate char umin[3]; 65*7c478bd9Sstevel@tonic-gate char lhour[3]; 66*7c478bd9Sstevel@tonic-gate char lmin[3]; 67*7c478bd9Sstevel@tonic-gate }; 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate struct userdate userformat; 70*7c478bd9Sstevel@tonic-gate struct userdate *friendlyptr = &userformat; 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate extern long atol(); 73*7c478bd9Sstevel@tonic-gate static int whattodo(); 74*7c478bd9Sstevel@tonic-gate static int readperf(); 75*7c478bd9Sstevel@tonic-gate static void queuetime(); 76*7c478bd9Sstevel@tonic-gate static void xfertime(); 77*7c478bd9Sstevel@tonic-gate static char * gmt(); 78*7c478bd9Sstevel@tonic-gate static char * gmts(); 79*7c478bd9Sstevel@tonic-gate static void errortn(); 80*7c478bd9Sstevel@tonic-gate static void friendlytime(); 81*7c478bd9Sstevel@tonic-gate static void complete(); 82*7c478bd9Sstevel@tonic-gate static int state(); 83*7c478bd9Sstevel@tonic-gate static int gnameflck(); 84*7c478bd9Sstevel@tonic-gate void uprocessC(), printit(), docalc(), procState(); 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate static short State, Queued, Running, Complete, Interrupted; 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate static char mailmsg[BUFSIZ]; 89*7c478bd9Sstevel@tonic-gate static char outbuf[BUFSIZ+1]; 90*7c478bd9Sstevel@tonic-gate static int count; 91*7c478bd9Sstevel@tonic-gate static short jobcount; 92*7c478bd9Sstevel@tonic-gate static short execute; 93*7c478bd9Sstevel@tonic-gate static char lowerlimit[MAXDATE+1], upperlimit[MAXDATE+1]; 94*7c478bd9Sstevel@tonic-gate static float totalque, totalxfer; 95*7c478bd9Sstevel@tonic-gate static long totaljob, totalbytes; 96*7c478bd9Sstevel@tonic-gate static long inputsecs; 97*7c478bd9Sstevel@tonic-gate #ifdef ATTSV 98*7c478bd9Sstevel@tonic-gate extern void qsort(); /* qsort(3) and comparison test */ 99*7c478bd9Sstevel@tonic-gate #endif /* ATTSV */ 100*7c478bd9Sstevel@tonic-gate int sortcnt = -1; 101*7c478bd9Sstevel@tonic-gate extern int machcmp(); 102*7c478bd9Sstevel@tonic-gate extern int _age(); /* find the age of a file */ 103*7c478bd9Sstevel@tonic-gate static long calcnum; 104*7c478bd9Sstevel@tonic-gate extern char Jobid[]; /* jobid for status or kill option */ 105*7c478bd9Sstevel@tonic-gate short Kill; /* == 1 if -k specified */ 106*7c478bd9Sstevel@tonic-gate short Rejuvenate; /* == 1 for -r specified */ 107*7c478bd9Sstevel@tonic-gate short Uopt; /* == 1 if -u option specified */ 108*7c478bd9Sstevel@tonic-gate short Sysopt; /* == 1 if -s option specified */ 109*7c478bd9Sstevel@tonic-gate static short Calctime; /* == 1 if -t parameter set */ 110*7c478bd9Sstevel@tonic-gate short Summary; /* == 1 if -q or -m is specified */ 111*7c478bd9Sstevel@tonic-gate short Queue; /* == 1 if -q option set - queue summary */ 112*7c478bd9Sstevel@tonic-gate short Machines; /* == 1 if -m option set - machines summary */ 113*7c478bd9Sstevel@tonic-gate short Psopt; /* == 1 if -p option set - output "ps" of LCK pids */ 114*7c478bd9Sstevel@tonic-gate static short Window; /* == 1 if -d parameter set with -t option */ 115*7c478bd9Sstevel@tonic-gate static short nonotf; /* == 1 if -n parameter set with -k option */ 116*7c478bd9Sstevel@tonic-gate short avgqueue; /* == 1 if -c parameter set with -t option */ 117*7c478bd9Sstevel@tonic-gate short avgxfer; /* will be set to 1 if -c not specified */ 118*7c478bd9Sstevel@tonic-gate short Jobcount; /* == 1 if -j parameter set with -s option */ 119*7c478bd9Sstevel@tonic-gate char f[NAMESIZE]; 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate main(argc, argv, envp) 122*7c478bd9Sstevel@tonic-gate char *argv[]; 123*7c478bd9Sstevel@tonic-gate char **envp; 124*7c478bd9Sstevel@tonic-gate { 125*7c478bd9Sstevel@tonic-gate struct m *m, *machine(); 126*7c478bd9Sstevel@tonic-gate DIR *spooldir, *subdir, *machdir, *gradedir; 127*7c478bd9Sstevel@tonic-gate char *str, *rindex(); 128*7c478bd9Sstevel@tonic-gate char subf[256], gradef[256]; 129*7c478bd9Sstevel@tonic-gate char *c, lckdir[BUFSIZ]; 130*7c478bd9Sstevel@tonic-gate char buf[BUFSIZ]; 131*7c478bd9Sstevel@tonic-gate char chkname[MAXFULLNAME]; 132*7c478bd9Sstevel@tonic-gate char *vec[7]; 133*7c478bd9Sstevel@tonic-gate int i, chkid; 134*7c478bd9Sstevel@tonic-gate char fullpath[MAXFULLNAME]; 135*7c478bd9Sstevel@tonic-gate long temp; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate char arglist[MAXSTATE+1]; 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate /* Set locale environment variables local definitions */ 140*7c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 141*7c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ 142*7c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ 143*7c478bd9Sstevel@tonic-gate #endif 144*7c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate User[0] = '\0'; 147*7c478bd9Sstevel@tonic-gate Rmtname[0] = '\0'; 148*7c478bd9Sstevel@tonic-gate Jobid[0] = '\0'; 149*7c478bd9Sstevel@tonic-gate Psopt=Machines=Summary=Queue=Kill=Rejuvenate=Uopt=Sysopt=Jobcount=0; 150*7c478bd9Sstevel@tonic-gate execute=avgqueue=avgxfer=Calctime=Window=0; 151*7c478bd9Sstevel@tonic-gate jobcount=nonotf=0; 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate /* set calcnum to default time in minutes */ 154*7c478bd9Sstevel@tonic-gate calcnum=MINTIME; 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate (void) strcpy(Progname, "uustat"); 157*7c478bd9Sstevel@tonic-gate Uid = getuid(); 158*7c478bd9Sstevel@tonic-gate Euid = geteuid(); 159*7c478bd9Sstevel@tonic-gate guinfo(Uid, Loginuser); 160*7c478bd9Sstevel@tonic-gate uucpname(Myname); 161*7c478bd9Sstevel@tonic-gate while ((i = getopt(argc, argv, "acjk:mnpr:qs:u:x:t:d:S:")) != EOF) { 162*7c478bd9Sstevel@tonic-gate switch(i){ 163*7c478bd9Sstevel@tonic-gate case 'a': 164*7c478bd9Sstevel@tonic-gate Sysopt = 1; 165*7c478bd9Sstevel@tonic-gate break; 166*7c478bd9Sstevel@tonic-gate case 'c': 167*7c478bd9Sstevel@tonic-gate avgqueue = 1; 168*7c478bd9Sstevel@tonic-gate break; 169*7c478bd9Sstevel@tonic-gate case 'd': 170*7c478bd9Sstevel@tonic-gate Window = 1; 171*7c478bd9Sstevel@tonic-gate calcnum = atoi(optarg); 172*7c478bd9Sstevel@tonic-gate if (calcnum <= 0) 173*7c478bd9Sstevel@tonic-gate calcnum = MINTIME; 174*7c478bd9Sstevel@tonic-gate break; 175*7c478bd9Sstevel@tonic-gate case 'k': 176*7c478bd9Sstevel@tonic-gate (void) strncpy(Jobid, optarg, NAMESIZE); 177*7c478bd9Sstevel@tonic-gate Jobid[NAMESIZE-1] = '\0'; 178*7c478bd9Sstevel@tonic-gate Kill = 1; 179*7c478bd9Sstevel@tonic-gate break; 180*7c478bd9Sstevel@tonic-gate case 'j': 181*7c478bd9Sstevel@tonic-gate Jobcount = 1; 182*7c478bd9Sstevel@tonic-gate break; 183*7c478bd9Sstevel@tonic-gate case 'm': 184*7c478bd9Sstevel@tonic-gate Machines = Summary = 1; 185*7c478bd9Sstevel@tonic-gate break; 186*7c478bd9Sstevel@tonic-gate case 'n': 187*7c478bd9Sstevel@tonic-gate nonotf = 1; 188*7c478bd9Sstevel@tonic-gate break; 189*7c478bd9Sstevel@tonic-gate case 'p': 190*7c478bd9Sstevel@tonic-gate Psopt = 1; 191*7c478bd9Sstevel@tonic-gate break; 192*7c478bd9Sstevel@tonic-gate case 'r': 193*7c478bd9Sstevel@tonic-gate (void) strncpy(Jobid, optarg, NAMESIZE); 194*7c478bd9Sstevel@tonic-gate Jobid[NAMESIZE-1] = '\0'; 195*7c478bd9Sstevel@tonic-gate Rejuvenate = 1; 196*7c478bd9Sstevel@tonic-gate break; 197*7c478bd9Sstevel@tonic-gate case 'q': 198*7c478bd9Sstevel@tonic-gate Queue = Summary = 1; 199*7c478bd9Sstevel@tonic-gate break; 200*7c478bd9Sstevel@tonic-gate case 's': 201*7c478bd9Sstevel@tonic-gate (void) strncpy(Rmtname, optarg, MAXBASENAME); 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate Rmtname[MAXBASENAME] = '\0'; 204*7c478bd9Sstevel@tonic-gate if (versys(Rmtname)) { 205*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Invalid system\n")); 206*7c478bd9Sstevel@tonic-gate exit(1); 207*7c478bd9Sstevel@tonic-gate } 208*7c478bd9Sstevel@tonic-gate Sysopt = 1; 209*7c478bd9Sstevel@tonic-gate break; 210*7c478bd9Sstevel@tonic-gate case 't': 211*7c478bd9Sstevel@tonic-gate Calctime = 1; 212*7c478bd9Sstevel@tonic-gate (void) strncpy(Rmtname, optarg, MAXBASENAME); 213*7c478bd9Sstevel@tonic-gate Rmtname[MAXBASENAME] = '\0'; 214*7c478bd9Sstevel@tonic-gate if (versys(Rmtname)) { 215*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Invalid system\n")); 216*7c478bd9Sstevel@tonic-gate exit(1); 217*7c478bd9Sstevel@tonic-gate } 218*7c478bd9Sstevel@tonic-gate break; 219*7c478bd9Sstevel@tonic-gate case 'u': 220*7c478bd9Sstevel@tonic-gate (void) strncpy(User, optarg, 8); 221*7c478bd9Sstevel@tonic-gate User[8] = '\0'; 222*7c478bd9Sstevel@tonic-gate if(gninfo(User, &chkid, chkname)) { 223*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Invalid user\n")); 224*7c478bd9Sstevel@tonic-gate exit(1); 225*7c478bd9Sstevel@tonic-gate } 226*7c478bd9Sstevel@tonic-gate Uopt = 1; 227*7c478bd9Sstevel@tonic-gate execute = 1; 228*7c478bd9Sstevel@tonic-gate break; 229*7c478bd9Sstevel@tonic-gate case 'x': 230*7c478bd9Sstevel@tonic-gate Debug = atoi(optarg); 231*7c478bd9Sstevel@tonic-gate if (Debug <= 0) 232*7c478bd9Sstevel@tonic-gate Debug = 1; 233*7c478bd9Sstevel@tonic-gate break; 234*7c478bd9Sstevel@tonic-gate case 'S': 235*7c478bd9Sstevel@tonic-gate if (strlen(optarg) > sizeof (arglist)) { 236*7c478bd9Sstevel@tonic-gate errortn(); 237*7c478bd9Sstevel@tonic-gate exit(1); 238*7c478bd9Sstevel@tonic-gate } 239*7c478bd9Sstevel@tonic-gate State = 1; 240*7c478bd9Sstevel@tonic-gate (void) strlcpy(arglist, optarg, sizeof (arglist)); 241*7c478bd9Sstevel@tonic-gate procState(arglist); 242*7c478bd9Sstevel@tonic-gate break; 243*7c478bd9Sstevel@tonic-gate default: 244*7c478bd9Sstevel@tonic-gate errortn(); 245*7c478bd9Sstevel@tonic-gate exit(1); 246*7c478bd9Sstevel@tonic-gate } 247*7c478bd9Sstevel@tonic-gate } 248*7c478bd9Sstevel@tonic-gate 249*7c478bd9Sstevel@tonic-gate if (argc != optind) { 250*7c478bd9Sstevel@tonic-gate errortn(); 251*7c478bd9Sstevel@tonic-gate exit(1); 252*7c478bd9Sstevel@tonic-gate } 253*7c478bd9Sstevel@tonic-gate 254*7c478bd9Sstevel@tonic-gate DEBUG(9, "Progname (%s): STARTED\n", Progname); 255*7c478bd9Sstevel@tonic-gate DEBUG(9, "User=%s, ", User); 256*7c478bd9Sstevel@tonic-gate DEBUG(9, "Loginuser=%s, ", Loginuser); 257*7c478bd9Sstevel@tonic-gate DEBUG(9, "Jobid=%s, ", Jobid); 258*7c478bd9Sstevel@tonic-gate DEBUG(9, "Rmtname=%s\n", Rmtname); 259*7c478bd9Sstevel@tonic-gate 260*7c478bd9Sstevel@tonic-gate /* -j only allowed with -s */ 261*7c478bd9Sstevel@tonic-gate if (Jobcount && !Sysopt) 262*7c478bd9Sstevel@tonic-gate { 263*7c478bd9Sstevel@tonic-gate errortn(); 264*7c478bd9Sstevel@tonic-gate exit(1); 265*7c478bd9Sstevel@tonic-gate } 266*7c478bd9Sstevel@tonic-gate if ((Calctime + Psopt + Machines + Queue + Kill + Rejuvenate + (Uopt|Sysopt |State)) >1) { 267*7c478bd9Sstevel@tonic-gate /* only -u, -S and -s can be used together */ 268*7c478bd9Sstevel@tonic-gate errortn(); 269*7c478bd9Sstevel@tonic-gate exit(1); 270*7c478bd9Sstevel@tonic-gate } 271*7c478bd9Sstevel@tonic-gate if ((avgqueue | Window) & (!Calctime)) 272*7c478bd9Sstevel@tonic-gate { 273*7c478bd9Sstevel@tonic-gate errortn(); 274*7c478bd9Sstevel@tonic-gate exit(1); 275*7c478bd9Sstevel@tonic-gate } 276*7c478bd9Sstevel@tonic-gate 277*7c478bd9Sstevel@tonic-gate if ( !(Calctime | Kill | Rejuvenate | Uopt | Sysopt | Queue| Machines | State) ) { 278*7c478bd9Sstevel@tonic-gate (void) strcpy(User, Loginuser); 279*7c478bd9Sstevel@tonic-gate Uopt = 1; 280*7c478bd9Sstevel@tonic-gate } 281*7c478bd9Sstevel@tonic-gate 282*7c478bd9Sstevel@tonic-gate if ( nonotf && !(Kill | Rejuvenate) ) { 283*7c478bd9Sstevel@tonic-gate errortn(); 284*7c478bd9Sstevel@tonic-gate exit(1); 285*7c478bd9Sstevel@tonic-gate } 286*7c478bd9Sstevel@tonic-gate 287*7c478bd9Sstevel@tonic-gate /*****************************************/ 288*7c478bd9Sstevel@tonic-gate /* PROCESS THE OPTIONS */ 289*7c478bd9Sstevel@tonic-gate /*****************************************/ 290*7c478bd9Sstevel@tonic-gate 291*7c478bd9Sstevel@tonic-gate if (State && Complete) 292*7c478bd9Sstevel@tonic-gate { 293*7c478bd9Sstevel@tonic-gate DEBUG(9, "calling complete %d\n",Complete); 294*7c478bd9Sstevel@tonic-gate complete(); 295*7c478bd9Sstevel@tonic-gate } 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate if (Calctime) { 298*7c478bd9Sstevel@tonic-gate count = readperf(calcnum); 299*7c478bd9Sstevel@tonic-gate 300*7c478bd9Sstevel@tonic-gate if (count != 0) 301*7c478bd9Sstevel@tonic-gate docalc(); 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate } 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate if (Psopt) { 306*7c478bd9Sstevel@tonic-gate /* do "ps -flp" or pids in LCK files */ 307*7c478bd9Sstevel@tonic-gate lckpid(); 308*7c478bd9Sstevel@tonic-gate /* lckpid will not return */ 309*7c478bd9Sstevel@tonic-gate } 310*7c478bd9Sstevel@tonic-gate 311*7c478bd9Sstevel@tonic-gate if (Summary) { 312*7c478bd9Sstevel@tonic-gate /* Gather data for Summary option report */ 313*7c478bd9Sstevel@tonic-gate if (chdir(STATDIR) || (spooldir = opendir(STATDIR)) == NULL) 314*7c478bd9Sstevel@tonic-gate exit(101); /* good old code 101 */ 315*7c478bd9Sstevel@tonic-gate while (gnamef(spooldir, f) == TRUE) { 316*7c478bd9Sstevel@tonic-gate if (freopen(f, "r", stdin) == NULL) 317*7c478bd9Sstevel@tonic-gate continue; 318*7c478bd9Sstevel@tonic-gate m = machine(f); 319*7c478bd9Sstevel@tonic-gate if (fgets(buf, sizeof(buf), stdin) == NULL) 320*7c478bd9Sstevel@tonic-gate continue; 321*7c478bd9Sstevel@tonic-gate if (getargs(buf, vec, 5) < 5) 322*7c478bd9Sstevel@tonic-gate continue; 323*7c478bd9Sstevel@tonic-gate m->type = atoi(vec[0]); 324*7c478bd9Sstevel@tonic-gate m->count = atoi(vec[1]); 325*7c478bd9Sstevel@tonic-gate m->lasttime = atol(vec[2]); 326*7c478bd9Sstevel@tonic-gate m->retrytime = atol(vec[3]); 327*7c478bd9Sstevel@tonic-gate (void) strncpy(m->stst, vec[4], STST_MAX); 328*7c478bd9Sstevel@tonic-gate str = rindex(m->stst, ' '); 329*7c478bd9Sstevel@tonic-gate (void) machine(++str); /* longer name? */ 330*7c478bd9Sstevel@tonic-gate *str = '\0'; 331*7c478bd9Sstevel@tonic-gate 332*7c478bd9Sstevel@tonic-gate } 333*7c478bd9Sstevel@tonic-gate closedir(spooldir); 334*7c478bd9Sstevel@tonic-gate } 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate 337*7c478bd9Sstevel@tonic-gate if (Summary) { 338*7c478bd9Sstevel@tonic-gate /* search for LCK machines */ 339*7c478bd9Sstevel@tonic-gate char flck[MAXNAMESIZE]; 340*7c478bd9Sstevel@tonic-gate 341*7c478bd9Sstevel@tonic-gate (void) strcpy(lckdir, LOCKPRE); 342*7c478bd9Sstevel@tonic-gate *strrchr(lckdir, '/') = '\0'; 343*7c478bd9Sstevel@tonic-gate /* open lock directory */ 344*7c478bd9Sstevel@tonic-gate if (chdir(lckdir) != 0 || (subdir = opendir(lckdir)) == NULL) 345*7c478bd9Sstevel@tonic-gate exit(101); /* good old code 101 */ 346*7c478bd9Sstevel@tonic-gate 347*7c478bd9Sstevel@tonic-gate while (gnameflck(subdir, flck) == TRUE) { 348*7c478bd9Sstevel@tonic-gate /* XXX - this is disgusting... */ 349*7c478bd9Sstevel@tonic-gate if (EQUALSN("LCK..", flck, 5)) { 350*7c478bd9Sstevel@tonic-gate if (!EQUALSN(flck + 5, "cul", 3) 351*7c478bd9Sstevel@tonic-gate && !EQUALSN(flck + 5, "cua", 3) 352*7c478bd9Sstevel@tonic-gate && !EQUALSN(flck + 5, "tty", 3) 353*7c478bd9Sstevel@tonic-gate && !EQUALSN(flck + 5, "dtsw", 4) 354*7c478bd9Sstevel@tonic-gate && !EQUALSN(flck + 5, "vadic", 5) 355*7c478bd9Sstevel@tonic-gate && !EQUALSN(flck + 5, "micom", 5)) 356*7c478bd9Sstevel@tonic-gate machine(flck + 5)->locked++; 357*7c478bd9Sstevel@tonic-gate } 358*7c478bd9Sstevel@tonic-gate } 359*7c478bd9Sstevel@tonic-gate } 360*7c478bd9Sstevel@tonic-gate 361*7c478bd9Sstevel@tonic-gate if (chdir(SPOOL) != 0 || (spooldir = opendir(SPOOL)) == NULL) 362*7c478bd9Sstevel@tonic-gate exit(101); /* good old code 101 */ 363*7c478bd9Sstevel@tonic-gate 364*7c478bd9Sstevel@tonic-gate while (gnamef(spooldir, f) == TRUE) { 365*7c478bd9Sstevel@tonic-gate /* at /var/spool/uucp directory */ 366*7c478bd9Sstevel@tonic-gate /* f will contain remote machine names */ 367*7c478bd9Sstevel@tonic-gate 368*7c478bd9Sstevel@tonic-gate if (EQUALSN("LCK..", f, 5)) 369*7c478bd9Sstevel@tonic-gate continue; 370*7c478bd9Sstevel@tonic-gate 371*7c478bd9Sstevel@tonic-gate if (*Rmtname && !EQUALSN(Rmtname, f, MAXBASENAME)) 372*7c478bd9Sstevel@tonic-gate continue; 373*7c478bd9Sstevel@tonic-gate 374*7c478bd9Sstevel@tonic-gate if ( (Kill || Rejuvenate) 375*7c478bd9Sstevel@tonic-gate && (!EQUALSN(f, Jobid, strlen(Jobid)-5)) ) 376*7c478bd9Sstevel@tonic-gate continue; 377*7c478bd9Sstevel@tonic-gate 378*7c478bd9Sstevel@tonic-gate if (DIRECTORY(f)) { 379*7c478bd9Sstevel@tonic-gate if (chdir(f) != 0) 380*7c478bd9Sstevel@tonic-gate exit(101); 381*7c478bd9Sstevel@tonic-gate (void) sprintf(fullpath, "%s/%s", SPOOL, f); 382*7c478bd9Sstevel@tonic-gate machdir = opendir(fullpath); 383*7c478bd9Sstevel@tonic-gate if (machdir == NULL) 384*7c478bd9Sstevel@tonic-gate exit(101); 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate m = machine(f); 387*7c478bd9Sstevel@tonic-gate while (gnamef(machdir, gradef) == TRUE) { 388*7c478bd9Sstevel@tonic-gate /* at /var/spool/uucp/remote_name */ 389*7c478bd9Sstevel@tonic-gate /* gradef will contain job_grade directory names */ 390*7c478bd9Sstevel@tonic-gate 391*7c478bd9Sstevel@tonic-gate if (DIRECTORY(gradef) && (gradedir = opendir(gradef))) { 392*7c478bd9Sstevel@tonic-gate /* at /var/spool/uucp/remote_name/job_grade */ 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate while (gnamef(gradedir, subf) == TRUE) { 395*7c478bd9Sstevel@tonic-gate /* subf will contain file names */ 396*7c478bd9Sstevel@tonic-gate /* files can be C. or D. or A., etc.. */ 397*7c478bd9Sstevel@tonic-gate 398*7c478bd9Sstevel@tonic-gate if (subf[1] == '.') { 399*7c478bd9Sstevel@tonic-gate if (subf[0] == CMDPRE) { 400*7c478bd9Sstevel@tonic-gate /* if file name is C. */ 401*7c478bd9Sstevel@tonic-gate m->ccount++; 402*7c478bd9Sstevel@tonic-gate 403*7c478bd9Sstevel@tonic-gate if (Kill || Rejuvenate) 404*7c478bd9Sstevel@tonic-gate kprocessC(gradef, subf); 405*7c478bd9Sstevel@tonic-gate else if (Uopt | Sysopt | Queued | Running | Interrupted) 406*7c478bd9Sstevel@tonic-gate /* go print out C. file info */ 407*7c478bd9Sstevel@tonic-gate uprocessC(f ,gradef, subf); 408*7c478bd9Sstevel@tonic-gate 409*7c478bd9Sstevel@tonic-gate else /* get the age of the C. file */ 410*7c478bd9Sstevel@tonic-gate if ( (i = _age(gradef, subf))>m->c_age) 411*7c478bd9Sstevel@tonic-gate m->c_age = i; 412*7c478bd9Sstevel@tonic-gate } 413*7c478bd9Sstevel@tonic-gate } 414*7c478bd9Sstevel@tonic-gate } 415*7c478bd9Sstevel@tonic-gate closedir(gradedir); 416*7c478bd9Sstevel@tonic-gate } 417*7c478bd9Sstevel@tonic-gate 418*7c478bd9Sstevel@tonic-gate else if (gradef[0] == XQTPRE && gradef[1] == '.') { 419*7c478bd9Sstevel@tonic-gate m->xcount++; 420*7c478bd9Sstevel@tonic-gate if ( (i = _age(machdir, gradef)) > m->x_age) 421*7c478bd9Sstevel@tonic-gate m->x_age = i; 422*7c478bd9Sstevel@tonic-gate } 423*7c478bd9Sstevel@tonic-gate } 424*7c478bd9Sstevel@tonic-gate closedir(machdir); 425*7c478bd9Sstevel@tonic-gate } 426*7c478bd9Sstevel@tonic-gate /* cd back to /var/spoool/uucp dir */ 427*7c478bd9Sstevel@tonic-gate if (chdir(SPOOL) != 0) 428*7c478bd9Sstevel@tonic-gate exit(101); 429*7c478bd9Sstevel@tonic-gate } /* while more files in spooldir */ 430*7c478bd9Sstevel@tonic-gate closedir(spooldir); 431*7c478bd9Sstevel@tonic-gate 432*7c478bd9Sstevel@tonic-gate if (Jobcount && (jobcount != 0)) 433*7c478bd9Sstevel@tonic-gate printf("job count = %d\n",jobcount); 434*7c478bd9Sstevel@tonic-gate 435*7c478bd9Sstevel@tonic-gate /* for Kill or Rejuvenate - will not get here unless it failed */ 436*7c478bd9Sstevel@tonic-gate if (Kill) { 437*7c478bd9Sstevel@tonic-gate printf(gettext("Can't find Job %s; Not killed\n"), Jobid); 438*7c478bd9Sstevel@tonic-gate exit(1); 439*7c478bd9Sstevel@tonic-gate } else if (Rejuvenate) { 440*7c478bd9Sstevel@tonic-gate printf(gettext("Can't find Job %s; Not rejuvenated\n"), Jobid); 441*7c478bd9Sstevel@tonic-gate exit(1); 442*7c478bd9Sstevel@tonic-gate } 443*7c478bd9Sstevel@tonic-gate 444*7c478bd9Sstevel@tonic-gate /* Make sure the overflow entry is null since it may be incorrect */ 445*7c478bd9Sstevel@tonic-gate M[UUSTAT_TBL].mach[0] = NULLCHAR; 446*7c478bd9Sstevel@tonic-gate if (Summary) { 447*7c478bd9Sstevel@tonic-gate for((sortcnt = 0, m = &M[0]);*(m->mach) != NULL;(sortcnt++,m++)) 448*7c478bd9Sstevel@tonic-gate ; 449*7c478bd9Sstevel@tonic-gate qsort((char *)M, (unsigned int)sortcnt, sizeof(struct m), machcmp); 450*7c478bd9Sstevel@tonic-gate for (m = M; m->mach[0] != NULLCHAR; m++) 451*7c478bd9Sstevel@tonic-gate printit(m); 452*7c478bd9Sstevel@tonic-gate } 453*7c478bd9Sstevel@tonic-gate exit(0); 454*7c478bd9Sstevel@tonic-gate 455*7c478bd9Sstevel@tonic-gate /* NOTREACHED */ 456*7c478bd9Sstevel@tonic-gate } 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate 459*7c478bd9Sstevel@tonic-gate /* 460*7c478bd9Sstevel@tonic-gate * uprocessC - get information about C. file 461*7c478bd9Sstevel@tonic-gate * 462*7c478bd9Sstevel@tonic-gate */ 463*7c478bd9Sstevel@tonic-gate 464*7c478bd9Sstevel@tonic-gate void 465*7c478bd9Sstevel@tonic-gate uprocessC(machine, dir, file) 466*7c478bd9Sstevel@tonic-gate char *machine, *dir, *file; 467*7c478bd9Sstevel@tonic-gate { 468*7c478bd9Sstevel@tonic-gate struct stat s; 469*7c478bd9Sstevel@tonic-gate register struct tm *tp; 470*7c478bd9Sstevel@tonic-gate char fullname[MAXFULLNAME], buf[BUFSIZ], user[9]; 471*7c478bd9Sstevel@tonic-gate char xfullname[MAXFULLNAME]; 472*7c478bd9Sstevel@tonic-gate char file1[BUFSIZ], file2[BUFSIZ], file3[BUFSIZ], type[2], opt[256]; 473*7c478bd9Sstevel@tonic-gate short goodRecord = 0; 474*7c478bd9Sstevel@tonic-gate FILE *fp, *xfp; 475*7c478bd9Sstevel@tonic-gate short first = 1; 476*7c478bd9Sstevel@tonic-gate short statefound = 0; 477*7c478bd9Sstevel@tonic-gate extern long fsize(); 478*7c478bd9Sstevel@tonic-gate char format_tmp[BUFSIZ+1]; 479*7c478bd9Sstevel@tonic-gate fp=xfp=NULL; 480*7c478bd9Sstevel@tonic-gate 481*7c478bd9Sstevel@tonic-gate /*********************************************/ 482*7c478bd9Sstevel@tonic-gate /* initialize output buffer to blanks */ 483*7c478bd9Sstevel@tonic-gate /*********************************************/ 484*7c478bd9Sstevel@tonic-gate 485*7c478bd9Sstevel@tonic-gate if (Complete && !Queued && !Running && !Interrupted) 486*7c478bd9Sstevel@tonic-gate return; 487*7c478bd9Sstevel@tonic-gate outbuf[0] = NULLCHAR; 488*7c478bd9Sstevel@tonic-gate 489*7c478bd9Sstevel@tonic-gate DEBUG(9, "uprocessC(%s, ", dir); 490*7c478bd9Sstevel@tonic-gate DEBUG(9, "%s);\n", file); 491*7c478bd9Sstevel@tonic-gate 492*7c478bd9Sstevel@tonic-gate if (Jobid[0] != '\0' && (!EQUALS(Jobid, &file[2])) ) { 493*7c478bd9Sstevel@tonic-gate /* kill job - not this one */ 494*7c478bd9Sstevel@tonic-gate return; 495*7c478bd9Sstevel@tonic-gate } 496*7c478bd9Sstevel@tonic-gate 497*7c478bd9Sstevel@tonic-gate (void) sprintf(fullname, "%s/%s", dir, file); 498*7c478bd9Sstevel@tonic-gate if (stat(fullname, &s) != 0) { 499*7c478bd9Sstevel@tonic-gate /* error - can't stat */ 500*7c478bd9Sstevel@tonic-gate DEBUG(4, "Can't stat file (%s),", fullname); 501*7c478bd9Sstevel@tonic-gate DEBUG(4, " errno (%d) -- skip it!\n", errno); 502*7c478bd9Sstevel@tonic-gate } 503*7c478bd9Sstevel@tonic-gate 504*7c478bd9Sstevel@tonic-gate fp = fopen(fullname, "r"); 505*7c478bd9Sstevel@tonic-gate if (fp == NULL) { 506*7c478bd9Sstevel@tonic-gate DEBUG(4, "Can't open file (%s), ", fullname); 507*7c478bd9Sstevel@tonic-gate DEBUG(4, "errno=%d -- skip it!\n", errno); 508*7c478bd9Sstevel@tonic-gate return; 509*7c478bd9Sstevel@tonic-gate } 510*7c478bd9Sstevel@tonic-gate tp = localtime(&s.st_mtime); 511*7c478bd9Sstevel@tonic-gate 512*7c478bd9Sstevel@tonic-gate if (s.st_size == 0 && User[0] == '\0') { /* dummy D. for polling */ 513*7c478bd9Sstevel@tonic-gate sprintf(format_tmp,"%-12s %2.2d/%2.2d-%2.2d:%2.2d:%2.2d (POLL)\n", 514*7c478bd9Sstevel@tonic-gate &file[2], tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, 515*7c478bd9Sstevel@tonic-gate tp->tm_min, tp->tm_sec); 516*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 517*7c478bd9Sstevel@tonic-gate } 518*7c478bd9Sstevel@tonic-gate else while (fgets(buf, BUFSIZ, fp) != NULL) { 519*7c478bd9Sstevel@tonic-gate if (sscanf(buf,"%s%s%s%s%s%s", type, file1, file2, 520*7c478bd9Sstevel@tonic-gate user, opt, file3) <5) { 521*7c478bd9Sstevel@tonic-gate DEBUG(4, "short line (%s)\n", buf); 522*7c478bd9Sstevel@tonic-gate continue; 523*7c478bd9Sstevel@tonic-gate } 524*7c478bd9Sstevel@tonic-gate DEBUG(9, "type (%s), ", type); 525*7c478bd9Sstevel@tonic-gate DEBUG(9, "file1 (%s)", file1); 526*7c478bd9Sstevel@tonic-gate DEBUG(9, "file2 (%s)", file2); 527*7c478bd9Sstevel@tonic-gate DEBUG(9, "file3 (%s)", file3); 528*7c478bd9Sstevel@tonic-gate DEBUG(9, "user (%s)", user); 529*7c478bd9Sstevel@tonic-gate 530*7c478bd9Sstevel@tonic-gate goodRecord = 0; 531*7c478bd9Sstevel@tonic-gate 532*7c478bd9Sstevel@tonic-gate if (User[0] != '\0' && (!EQUALS(User, user)) ) 533*7c478bd9Sstevel@tonic-gate continue; 534*7c478bd9Sstevel@tonic-gate 535*7c478bd9Sstevel@tonic-gate 536*7c478bd9Sstevel@tonic-gate if (first) 537*7c478bd9Sstevel@tonic-gate { 538*7c478bd9Sstevel@tonic-gate sprintf(format_tmp,"%-12s", &file[2]); 539*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 540*7c478bd9Sstevel@tonic-gate 541*7c478bd9Sstevel@tonic-gate /* if the job state is requested call the 542*7c478bd9Sstevel@tonic-gate state function to determine this job's state */ 543*7c478bd9Sstevel@tonic-gate 544*7c478bd9Sstevel@tonic-gate if (State) 545*7c478bd9Sstevel@tonic-gate { 546*7c478bd9Sstevel@tonic-gate statefound = state(dir, file); 547*7c478bd9Sstevel@tonic-gate DEBUG(9, "uprocessC: statefound value = %d\n", statefound); 548*7c478bd9Sstevel@tonic-gate if ((whattodo(statefound) != TRUE)) 549*7c478bd9Sstevel@tonic-gate { 550*7c478bd9Sstevel@tonic-gate outbuf[0] = NULLCHAR; 551*7c478bd9Sstevel@tonic-gate return; 552*7c478bd9Sstevel@tonic-gate } 553*7c478bd9Sstevel@tonic-gate else 554*7c478bd9Sstevel@tonic-gate { 555*7c478bd9Sstevel@tonic-gate if (statefound == 1) 556*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, "queued"); 557*7c478bd9Sstevel@tonic-gate else if (statefound == 2) 558*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, "running"); 559*7c478bd9Sstevel@tonic-gate else if (statefound == 3) 560*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, "interrupted"); 561*7c478bd9Sstevel@tonic-gate } 562*7c478bd9Sstevel@tonic-gate } 563*7c478bd9Sstevel@tonic-gate sprintf(format_tmp, " %2.2d/%2.2d-%2.2d:%2.2d ", 564*7c478bd9Sstevel@tonic-gate tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, 565*7c478bd9Sstevel@tonic-gate tp->tm_min); 566*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 567*7c478bd9Sstevel@tonic-gate } 568*7c478bd9Sstevel@tonic-gate else 569*7c478bd9Sstevel@tonic-gate { 570*7c478bd9Sstevel@tonic-gate sprintf(format_tmp,"%-12s %2.2d/%2.2d-%2.2d:%2.2d ", 571*7c478bd9Sstevel@tonic-gate "", tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, 572*7c478bd9Sstevel@tonic-gate tp->tm_min); 573*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 574*7c478bd9Sstevel@tonic-gate } 575*7c478bd9Sstevel@tonic-gate first = 0; 576*7c478bd9Sstevel@tonic-gate 577*7c478bd9Sstevel@tonic-gate sprintf(format_tmp,"%s %s ", type, machine); 578*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 579*7c478bd9Sstevel@tonic-gate if (*type == 'R') 580*7c478bd9Sstevel@tonic-gate { 581*7c478bd9Sstevel@tonic-gate sprintf(format_tmp,"%s %s ", user, file1); 582*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 583*7c478bd9Sstevel@tonic-gate } 584*7c478bd9Sstevel@tonic-gate else if (file2[0] != 'X') 585*7c478bd9Sstevel@tonic-gate { 586*7c478bd9Sstevel@tonic-gate sprintf(format_tmp,"%s %ld %s ", user, fsize(dir, file3, file1), file1); 587*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 588*7c478bd9Sstevel@tonic-gate } 589*7c478bd9Sstevel@tonic-gate else if (*type == 'S' && file2[0] == 'X') { 590*7c478bd9Sstevel@tonic-gate (void) sprintf(xfullname, "%s/%s", dir, file1); 591*7c478bd9Sstevel@tonic-gate xfp = fopen(xfullname, "r"); 592*7c478bd9Sstevel@tonic-gate if (xfp == NULL) { /* program error */ 593*7c478bd9Sstevel@tonic-gate DEBUG(4, "Can't read %s, ", xfullname); 594*7c478bd9Sstevel@tonic-gate DEBUG(4, "errno=%d -- skip it!\n", errno); 595*7c478bd9Sstevel@tonic-gate sprintf(format_tmp,"%s ", user); 596*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 597*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf,"????\n"); 598*7c478bd9Sstevel@tonic-gate } 599*7c478bd9Sstevel@tonic-gate else { 600*7c478bd9Sstevel@tonic-gate char command[BUFSIZ], uline_u[BUFSIZ], uline_m[BUFSIZ]; 601*7c478bd9Sstevel@tonic-gate char retaddr[BUFSIZ], *username; 602*7c478bd9Sstevel@tonic-gate 603*7c478bd9Sstevel@tonic-gate *retaddr = *uline_u = *uline_m = '\0'; 604*7c478bd9Sstevel@tonic-gate while (fgets(buf, BUFSIZ, xfp) != NULL) { 605*7c478bd9Sstevel@tonic-gate switch(buf[0]) { 606*7c478bd9Sstevel@tonic-gate case 'C': 607*7c478bd9Sstevel@tonic-gate strcpy(command, buf + 2); 608*7c478bd9Sstevel@tonic-gate break; 609*7c478bd9Sstevel@tonic-gate case 'U': 610*7c478bd9Sstevel@tonic-gate sscanf(buf + 2, "%s%s", uline_u, uline_m); 611*7c478bd9Sstevel@tonic-gate break; 612*7c478bd9Sstevel@tonic-gate case 'R': 613*7c478bd9Sstevel@tonic-gate sscanf(buf+2, "%s", retaddr); 614*7c478bd9Sstevel@tonic-gate break; 615*7c478bd9Sstevel@tonic-gate } 616*7c478bd9Sstevel@tonic-gate } 617*7c478bd9Sstevel@tonic-gate username = user; 618*7c478bd9Sstevel@tonic-gate if (*uline_u != '\0') 619*7c478bd9Sstevel@tonic-gate username = uline_u; 620*7c478bd9Sstevel@tonic-gate if (*retaddr != '\0') 621*7c478bd9Sstevel@tonic-gate username = retaddr; 622*7c478bd9Sstevel@tonic-gate if (!EQUALS(uline_m, Myname)) 623*7c478bd9Sstevel@tonic-gate printf("%s!", uline_m); 624*7c478bd9Sstevel@tonic-gate sprintf(format_tmp,"%s %s", username, command); 625*7c478bd9Sstevel@tonic-gate (void) strcat(outbuf, format_tmp); 626*7c478bd9Sstevel@tonic-gate } 627*7c478bd9Sstevel@tonic-gate } 628*7c478bd9Sstevel@tonic-gate strcat(outbuf, "\n"); 629*7c478bd9Sstevel@tonic-gate fputs(outbuf, stdout); 630*7c478bd9Sstevel@tonic-gate outbuf[0] = NULLCHAR; 631*7c478bd9Sstevel@tonic-gate goodRecord = 1; 632*7c478bd9Sstevel@tonic-gate } /* end of while more data in buffer */ 633*7c478bd9Sstevel@tonic-gate 634*7c478bd9Sstevel@tonic-gate /* successful processing of a job, increment job count 635*7c478bd9Sstevel@tonic-gate counter */ 636*7c478bd9Sstevel@tonic-gate if (goodRecord) 637*7c478bd9Sstevel@tonic-gate jobcount++; 638*7c478bd9Sstevel@tonic-gate 639*7c478bd9Sstevel@tonic-gate if (xfp != NULL) 640*7c478bd9Sstevel@tonic-gate fclose(xfp); 641*7c478bd9Sstevel@tonic-gate 642*7c478bd9Sstevel@tonic-gate fclose(fp); 643*7c478bd9Sstevel@tonic-gate return; 644*7c478bd9Sstevel@tonic-gate } 645*7c478bd9Sstevel@tonic-gate /* 646*7c478bd9Sstevel@tonic-gate * whattodo - determine what to do with current C dot file 647*7c478bd9Sstevel@tonic-gate * depending on any combination (2**3 - 1) of input 648*7c478bd9Sstevel@tonic-gate * job states 649*7c478bd9Sstevel@tonic-gate */ 650*7c478bd9Sstevel@tonic-gate static int 651*7c478bd9Sstevel@tonic-gate whattodo(inputint) 652*7c478bd9Sstevel@tonic-gate int inputint; 653*7c478bd9Sstevel@tonic-gate { 654*7c478bd9Sstevel@tonic-gate /* Maybe some commentary here will help explain this truth 655*7c478bd9Sstevel@tonic-gate table. 656*7c478bd9Sstevel@tonic-gate 657*7c478bd9Sstevel@tonic-gate Queued |Running |Interrupted 658*7c478bd9Sstevel@tonic-gate ------------------------------------------------- 659*7c478bd9Sstevel@tonic-gate X | | 660*7c478bd9Sstevel@tonic-gate ------------------------------------------------- 661*7c478bd9Sstevel@tonic-gate | X | 662*7c478bd9Sstevel@tonic-gate ------------------------------------------------- 663*7c478bd9Sstevel@tonic-gate | | X 664*7c478bd9Sstevel@tonic-gate ------------------------------------------------- 665*7c478bd9Sstevel@tonic-gate X | X | 666*7c478bd9Sstevel@tonic-gate ------------------------------------------------- 667*7c478bd9Sstevel@tonic-gate | X | X 668*7c478bd9Sstevel@tonic-gate ------------------------------------------------- 669*7c478bd9Sstevel@tonic-gate X | | X 670*7c478bd9Sstevel@tonic-gate ------------------------------------------------- 671*7c478bd9Sstevel@tonic-gate X | X | X 672*7c478bd9Sstevel@tonic-gate ------------------------------------------------- 673*7c478bd9Sstevel@tonic-gate 674*7c478bd9Sstevel@tonic-gate Now do you understand. All possible combinations have to 675*7c478bd9Sstevel@tonic-gate be evaluated to determine whether or not to print the C dot 676*7c478bd9Sstevel@tonic-gate information out or not! Well, all but 000, because if neither 677*7c478bd9Sstevel@tonic-gate of these states are input by the user we would not be 678*7c478bd9Sstevel@tonic-gate examing the C dot file anyway! 679*7c478bd9Sstevel@tonic-gate */ 680*7c478bd9Sstevel@tonic-gate 681*7c478bd9Sstevel@tonic-gate if (Queued && Running && Interrupted) 682*7c478bd9Sstevel@tonic-gate return(TRUE); 683*7c478bd9Sstevel@tonic-gate else if ((Queued && !Running && !Interrupted) && (inputint == 1)) 684*7c478bd9Sstevel@tonic-gate return(TRUE); 685*7c478bd9Sstevel@tonic-gate else if ((Running && !Queued && !Interrupted) && (inputint == 2)) return(TRUE); 686*7c478bd9Sstevel@tonic-gate else if ((Interrupted && !Queued && !Running) && (inputint == 3)) return(TRUE); 687*7c478bd9Sstevel@tonic-gate else if ((Queued && Running && !Interrupted) && 688*7c478bd9Sstevel@tonic-gate (inputint == 1 || inputint == 2)) 689*7c478bd9Sstevel@tonic-gate return(TRUE); 690*7c478bd9Sstevel@tonic-gate else if ((!Queued && Running && Interrupted) && 691*7c478bd9Sstevel@tonic-gate (inputint == 2 || inputint == 3)) 692*7c478bd9Sstevel@tonic-gate return(TRUE); 693*7c478bd9Sstevel@tonic-gate else if ((Queued && !Running && Interrupted) && 694*7c478bd9Sstevel@tonic-gate (inputint ==1 || inputint == 3)) 695*7c478bd9Sstevel@tonic-gate return(TRUE); 696*7c478bd9Sstevel@tonic-gate else return(FALSE); 697*7c478bd9Sstevel@tonic-gate } 698*7c478bd9Sstevel@tonic-gate /* 699*7c478bd9Sstevel@tonic-gate * kprocessC - process kill or rejuvenate job 700*7c478bd9Sstevel@tonic-gate */ 701*7c478bd9Sstevel@tonic-gate 702*7c478bd9Sstevel@tonic-gate int 703*7c478bd9Sstevel@tonic-gate kprocessC(dir, file) 704*7c478bd9Sstevel@tonic-gate char *file, *dir; 705*7c478bd9Sstevel@tonic-gate { 706*7c478bd9Sstevel@tonic-gate struct stat s; 707*7c478bd9Sstevel@tonic-gate register struct tm *tp; 708*7c478bd9Sstevel@tonic-gate extern struct tm *localtime(); 709*7c478bd9Sstevel@tonic-gate char fullname[MAXFULLNAME], buf[BUFSIZ], user[9]; 710*7c478bd9Sstevel@tonic-gate char rfullname[MAXFULLNAME]; 711*7c478bd9Sstevel@tonic-gate char file1[BUFSIZ], file2[BUFSIZ], file3[BUFSIZ], type[2], opt[256]; 712*7c478bd9Sstevel@tonic-gate FILE *fp, *xfp; 713*7c478bd9Sstevel@tonic-gate struct utimbuf times; 714*7c478bd9Sstevel@tonic-gate short ret; 715*7c478bd9Sstevel@tonic-gate short first = 1; 716*7c478bd9Sstevel@tonic-gate 717*7c478bd9Sstevel@tonic-gate DEBUG(9, "kprocessC(%s, ", dir); 718*7c478bd9Sstevel@tonic-gate DEBUG(9, "%s);\n", file); 719*7c478bd9Sstevel@tonic-gate 720*7c478bd9Sstevel@tonic-gate if ((!EQUALS(Jobid, &file[2])) ) { 721*7c478bd9Sstevel@tonic-gate /* kill job - not this one */ 722*7c478bd9Sstevel@tonic-gate return; 723*7c478bd9Sstevel@tonic-gate } 724*7c478bd9Sstevel@tonic-gate 725*7c478bd9Sstevel@tonic-gate (void) sprintf(fullname, "%s/%s", dir, file); 726*7c478bd9Sstevel@tonic-gate if (stat(fullname, &s) != 0) { 727*7c478bd9Sstevel@tonic-gate /* error - can't stat */ 728*7c478bd9Sstevel@tonic-gate if(Kill) { 729*7c478bd9Sstevel@tonic-gate fprintf(stderr, 730*7c478bd9Sstevel@tonic-gate gettext("Can't stat:%s, errno (%d)--can't kill it!\n"), 731*7c478bd9Sstevel@tonic-gate fullname, errno); 732*7c478bd9Sstevel@tonic-gate } else { 733*7c478bd9Sstevel@tonic-gate fprintf(stderr, 734*7c478bd9Sstevel@tonic-gate gettext("Can't stat:%s, errno (%d)--can't rejuvenate it!\n"), 735*7c478bd9Sstevel@tonic-gate fullname, errno); 736*7c478bd9Sstevel@tonic-gate } 737*7c478bd9Sstevel@tonic-gate exit(1); 738*7c478bd9Sstevel@tonic-gate } 739*7c478bd9Sstevel@tonic-gate 740*7c478bd9Sstevel@tonic-gate fp = fopen(fullname, "r"); 741*7c478bd9Sstevel@tonic-gate if (fp == NULL) { 742*7c478bd9Sstevel@tonic-gate if(Kill) { 743*7c478bd9Sstevel@tonic-gate fprintf(stderr, 744*7c478bd9Sstevel@tonic-gate gettext("Can't read:%s, errno (%d)--can't kill it!\n"), 745*7c478bd9Sstevel@tonic-gate fullname, errno); 746*7c478bd9Sstevel@tonic-gate } else { 747*7c478bd9Sstevel@tonic-gate fprintf(stderr, 748*7c478bd9Sstevel@tonic-gate gettext("Can't read:%s, errno (%d)--can't rejuvenate it!\n"), 749*7c478bd9Sstevel@tonic-gate fullname, errno); 750*7c478bd9Sstevel@tonic-gate } 751*7c478bd9Sstevel@tonic-gate exit(1); 752*7c478bd9Sstevel@tonic-gate } 753*7c478bd9Sstevel@tonic-gate 754*7c478bd9Sstevel@tonic-gate times.actime = times.modtime = time((time_t *)NULL); 755*7c478bd9Sstevel@tonic-gate 756*7c478bd9Sstevel@tonic-gate while (fgets(buf, BUFSIZ, fp) != NULL) { 757*7c478bd9Sstevel@tonic-gate if (sscanf(buf,"%s%s%s%s%s%s", type, file1, file2, 758*7c478bd9Sstevel@tonic-gate user, opt, file3) <6) { 759*7c478bd9Sstevel@tonic-gate if(Kill) { 760*7c478bd9Sstevel@tonic-gate fprintf(stderr, 761*7c478bd9Sstevel@tonic-gate gettext("Bad format:%s, errno (%d)--can't kill it!\n"), 762*7c478bd9Sstevel@tonic-gate fullname, errno); 763*7c478bd9Sstevel@tonic-gate } else { 764*7c478bd9Sstevel@tonic-gate fprintf(stderr, 765*7c478bd9Sstevel@tonic-gate gettext("Bad format:%s, errno (%d)--can't rejuvenate it!\n"), 766*7c478bd9Sstevel@tonic-gate fullname, errno); 767*7c478bd9Sstevel@tonic-gate } 768*7c478bd9Sstevel@tonic-gate exit(1); 769*7c478bd9Sstevel@tonic-gate } 770*7c478bd9Sstevel@tonic-gate 771*7c478bd9Sstevel@tonic-gate DEBUG(9, "buf in uprocessK = %s\n ", buf); 772*7c478bd9Sstevel@tonic-gate DEBUG(9, "fullname is %s\n",fullname); 773*7c478bd9Sstevel@tonic-gate DEBUG(9, "type (%s), ", type); 774*7c478bd9Sstevel@tonic-gate DEBUG(9, "file1 (%s)", file1); 775*7c478bd9Sstevel@tonic-gate DEBUG(9, "file2 (%s)", file2); 776*7c478bd9Sstevel@tonic-gate DEBUG(9, "file3 (%s)", file3); 777*7c478bd9Sstevel@tonic-gate DEBUG(9, "user (%s)", user); 778*7c478bd9Sstevel@tonic-gate 779*7c478bd9Sstevel@tonic-gate 780*7c478bd9Sstevel@tonic-gate if (first) { 781*7c478bd9Sstevel@tonic-gate if ((access(fullname, 02) != 0) 782*7c478bd9Sstevel@tonic-gate && !PREFIX(Loginuser, user) 783*7c478bd9Sstevel@tonic-gate && !PREFIX(user, Loginuser) ) { 784*7c478bd9Sstevel@tonic-gate /* not allowed - not owner or root */ 785*7c478bd9Sstevel@tonic-gate if(Kill) 786*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Not owner," 787*7c478bd9Sstevel@tonic-gate " uucp or root - can't kill job %s\n"), Jobid); 788*7c478bd9Sstevel@tonic-gate else 789*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Not owner, uucp or root -" 790*7c478bd9Sstevel@tonic-gate " can't rejuvenate job %s\n"), Jobid); 791*7c478bd9Sstevel@tonic-gate exit(1); 792*7c478bd9Sstevel@tonic-gate } 793*7c478bd9Sstevel@tonic-gate first = 0; 794*7c478bd9Sstevel@tonic-gate } 795*7c478bd9Sstevel@tonic-gate 796*7c478bd9Sstevel@tonic-gate /* remove D. file */ 797*7c478bd9Sstevel@tonic-gate (void) sprintf(rfullname, "%s/%s", dir, file3); 798*7c478bd9Sstevel@tonic-gate DEBUG(4, "Remove %s\n", rfullname); 799*7c478bd9Sstevel@tonic-gate if (Kill) 800*7c478bd9Sstevel@tonic-gate ret = unlink(rfullname); 801*7c478bd9Sstevel@tonic-gate else /* Rejuvenate */ 802*7c478bd9Sstevel@tonic-gate ret = utime(rfullname, ×); 803*7c478bd9Sstevel@tonic-gate if (ret != 0 && errno != ENOENT) { 804*7c478bd9Sstevel@tonic-gate /* program error?? */ 805*7c478bd9Sstevel@tonic-gate if(Kill) 806*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Error: Can't kill," 807*7c478bd9Sstevel@tonic-gate " File (%s), errno (%d)\n"), rfullname, errno); 808*7c478bd9Sstevel@tonic-gate else 809*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Error: Can't rejuvenated," 810*7c478bd9Sstevel@tonic-gate " File (%s), errno (%d)\n"), rfullname, errno); 811*7c478bd9Sstevel@tonic-gate exit(1); 812*7c478bd9Sstevel@tonic-gate } 813*7c478bd9Sstevel@tonic-gate } 814*7c478bd9Sstevel@tonic-gate 815*7c478bd9Sstevel@tonic-gate DEBUG(4, "Remove %s\n", fullname); 816*7c478bd9Sstevel@tonic-gate if (Kill) 817*7c478bd9Sstevel@tonic-gate ret = unlink(fullname); 818*7c478bd9Sstevel@tonic-gate else /* Rejuvenate */ 819*7c478bd9Sstevel@tonic-gate ret = utime(fullname, ×); 820*7c478bd9Sstevel@tonic-gate 821*7c478bd9Sstevel@tonic-gate if (ret != 0) { 822*7c478bd9Sstevel@tonic-gate /* program error?? */ 823*7c478bd9Sstevel@tonic-gate if(Kill) 824*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Error1: Can't kill," 825*7c478bd9Sstevel@tonic-gate " File (%s), errno (%d)\n"), fullname, errno); 826*7c478bd9Sstevel@tonic-gate else 827*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Error1: Can't rejuvenate," 828*7c478bd9Sstevel@tonic-gate " File (%s), errno (%d)\n"), fullname, errno); 829*7c478bd9Sstevel@tonic-gate exit(1); 830*7c478bd9Sstevel@tonic-gate } 831*7c478bd9Sstevel@tonic-gate /* if kill done by SA then send user mail */ 832*7c478bd9Sstevel@tonic-gate else if (!EQUALS(Loginuser, user)) 833*7c478bd9Sstevel@tonic-gate { 834*7c478bd9Sstevel@tonic-gate sprintf(mailmsg, "%s %s", KILLMSG, Jobid); 835*7c478bd9Sstevel@tonic-gate mailst(user, "job killed", mailmsg, "", ""); 836*7c478bd9Sstevel@tonic-gate } 837*7c478bd9Sstevel@tonic-gate fclose(fp); 838*7c478bd9Sstevel@tonic-gate if (!nonotf) { 839*7c478bd9Sstevel@tonic-gate if(Kill) 840*7c478bd9Sstevel@tonic-gate printf(gettext("Job: %s successfully killed\n"), Jobid); 841*7c478bd9Sstevel@tonic-gate else 842*7c478bd9Sstevel@tonic-gate printf(gettext("Job: %s successfully rejuvenated\n"), 843*7c478bd9Sstevel@tonic-gate Jobid); 844*7c478bd9Sstevel@tonic-gate } 845*7c478bd9Sstevel@tonic-gate exit(0); 846*7c478bd9Sstevel@tonic-gate } 847*7c478bd9Sstevel@tonic-gate 848*7c478bd9Sstevel@tonic-gate /* 849*7c478bd9Sstevel@tonic-gate * fsize - return the size of f1 or f2 (if f1 does not exist) 850*7c478bd9Sstevel@tonic-gate * f1 is the local name 851*7c478bd9Sstevel@tonic-gate * 852*7c478bd9Sstevel@tonic-gate */ 853*7c478bd9Sstevel@tonic-gate 854*7c478bd9Sstevel@tonic-gate long 855*7c478bd9Sstevel@tonic-gate fsize(dir, f1, f2) 856*7c478bd9Sstevel@tonic-gate char *dir, *f1, *f2; 857*7c478bd9Sstevel@tonic-gate { 858*7c478bd9Sstevel@tonic-gate struct stat s; 859*7c478bd9Sstevel@tonic-gate char fullname[BUFSIZ]; 860*7c478bd9Sstevel@tonic-gate 861*7c478bd9Sstevel@tonic-gate (void) sprintf(fullname, "%s/%s", dir, f1); 862*7c478bd9Sstevel@tonic-gate if (stat(fullname, &s) == 0) { 863*7c478bd9Sstevel@tonic-gate return(s.st_size); 864*7c478bd9Sstevel@tonic-gate } 865*7c478bd9Sstevel@tonic-gate if (stat(f2, &s) == 0) { 866*7c478bd9Sstevel@tonic-gate return(s.st_size); 867*7c478bd9Sstevel@tonic-gate } 868*7c478bd9Sstevel@tonic-gate 869*7c478bd9Sstevel@tonic-gate return(-99999); 870*7c478bd9Sstevel@tonic-gate } 871*7c478bd9Sstevel@tonic-gate 872*7c478bd9Sstevel@tonic-gate void cleanup(){} 873*7c478bd9Sstevel@tonic-gate void logent(){} /* to load ulockf.c */ 874*7c478bd9Sstevel@tonic-gate void systat(){} /* to load utility.c */ 875*7c478bd9Sstevel@tonic-gate 876*7c478bd9Sstevel@tonic-gate struct m * 877*7c478bd9Sstevel@tonic-gate machine(name) 878*7c478bd9Sstevel@tonic-gate char *name; 879*7c478bd9Sstevel@tonic-gate { 880*7c478bd9Sstevel@tonic-gate struct m *m; 881*7c478bd9Sstevel@tonic-gate size_t namelen; 882*7c478bd9Sstevel@tonic-gate 883*7c478bd9Sstevel@tonic-gate DEBUG(9, "machine(%s), ", name); 884*7c478bd9Sstevel@tonic-gate namelen = strlen(name); 885*7c478bd9Sstevel@tonic-gate for (m = M; m->mach[0] != NULLCHAR; m++) 886*7c478bd9Sstevel@tonic-gate /* match on overlap? */ 887*7c478bd9Sstevel@tonic-gate if (EQUALSN(name, m->mach, MAXBASENAME)) { 888*7c478bd9Sstevel@tonic-gate /* use longest name */ 889*7c478bd9Sstevel@tonic-gate if (namelen > strlen(m->mach)) 890*7c478bd9Sstevel@tonic-gate (void) strcpy(m->mach, name); 891*7c478bd9Sstevel@tonic-gate return(m); 892*7c478bd9Sstevel@tonic-gate } 893*7c478bd9Sstevel@tonic-gate 894*7c478bd9Sstevel@tonic-gate /* 895*7c478bd9Sstevel@tonic-gate * The table is set up with 2 extra entries 896*7c478bd9Sstevel@tonic-gate * When we go over by one, output error to errors log 897*7c478bd9Sstevel@tonic-gate * When more than one over, just reuse the previous entry 898*7c478bd9Sstevel@tonic-gate */ 899*7c478bd9Sstevel@tonic-gate DEBUG(9, "m-M=%d\n", m-M); 900*7c478bd9Sstevel@tonic-gate if (m-M >= UUSTAT_TBL) { 901*7c478bd9Sstevel@tonic-gate if (m-M == UUSTAT_TBL) { 902*7c478bd9Sstevel@tonic-gate errent("MACHINE TABLE FULL", "", UUSTAT_TBL, 903*7c478bd9Sstevel@tonic-gate __FILE__, __LINE__); 904*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 905*7c478bd9Sstevel@tonic-gate gettext("WARNING: Table Overflow--output not complete\n")); 906*7c478bd9Sstevel@tonic-gate } 907*7c478bd9Sstevel@tonic-gate else 908*7c478bd9Sstevel@tonic-gate /* use the last entry - overwrite it */ 909*7c478bd9Sstevel@tonic-gate m = &M[UUSTAT_TBL]; 910*7c478bd9Sstevel@tonic-gate } 911*7c478bd9Sstevel@tonic-gate 912*7c478bd9Sstevel@tonic-gate (void) strcpy(m->mach, name); 913*7c478bd9Sstevel@tonic-gate m->c_age= m->x_age= m->lasttime= m->locked= m->ccount= m->xcount= 0; 914*7c478bd9Sstevel@tonic-gate m->stst[0] = '\0'; 915*7c478bd9Sstevel@tonic-gate return(m); 916*7c478bd9Sstevel@tonic-gate } 917*7c478bd9Sstevel@tonic-gate 918*7c478bd9Sstevel@tonic-gate void 919*7c478bd9Sstevel@tonic-gate printit(m) 920*7c478bd9Sstevel@tonic-gate struct m *m; 921*7c478bd9Sstevel@tonic-gate { 922*7c478bd9Sstevel@tonic-gate register struct tm *tp; 923*7c478bd9Sstevel@tonic-gate time_t t; 924*7c478bd9Sstevel@tonic-gate int minimum; 925*7c478bd9Sstevel@tonic-gate extern struct tm *localtime(); 926*7c478bd9Sstevel@tonic-gate 927*7c478bd9Sstevel@tonic-gate if (m->ccount == 0 928*7c478bd9Sstevel@tonic-gate && m->xcount == 0 929*7c478bd9Sstevel@tonic-gate /*&& m->stst[0] == '\0'*/ 930*7c478bd9Sstevel@tonic-gate && m->locked == 0 931*7c478bd9Sstevel@tonic-gate && Queue 932*7c478bd9Sstevel@tonic-gate && m->type == 0) 933*7c478bd9Sstevel@tonic-gate return; 934*7c478bd9Sstevel@tonic-gate printf("%-10s", m->mach); 935*7c478bd9Sstevel@tonic-gate if (Queue) { 936*7c478bd9Sstevel@tonic-gate if (m->ccount) 937*7c478bd9Sstevel@tonic-gate printf("%3dC", m->ccount); 938*7c478bd9Sstevel@tonic-gate else 939*7c478bd9Sstevel@tonic-gate printf(" "); 940*7c478bd9Sstevel@tonic-gate if (m->c_age) 941*7c478bd9Sstevel@tonic-gate printf("(%d)", m->c_age); 942*7c478bd9Sstevel@tonic-gate else 943*7c478bd9Sstevel@tonic-gate printf(" "); 944*7c478bd9Sstevel@tonic-gate if (m->xcount) 945*7c478bd9Sstevel@tonic-gate printf("%3dX", m->xcount); 946*7c478bd9Sstevel@tonic-gate else 947*7c478bd9Sstevel@tonic-gate printf(" "); 948*7c478bd9Sstevel@tonic-gate if (m->x_age) 949*7c478bd9Sstevel@tonic-gate printf("(%d) ", m->x_age); 950*7c478bd9Sstevel@tonic-gate else 951*7c478bd9Sstevel@tonic-gate printf(" "); 952*7c478bd9Sstevel@tonic-gate } else 953*7c478bd9Sstevel@tonic-gate printf(" "); 954*7c478bd9Sstevel@tonic-gate 955*7c478bd9Sstevel@tonic-gate if (m->lasttime) { 956*7c478bd9Sstevel@tonic-gate tp = localtime(&m->lasttime); 957*7c478bd9Sstevel@tonic-gate printf("%2.2d/%2.2d-%2.2d:%2.2d ", 958*7c478bd9Sstevel@tonic-gate tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, 959*7c478bd9Sstevel@tonic-gate tp->tm_min); 960*7c478bd9Sstevel@tonic-gate } 961*7c478bd9Sstevel@tonic-gate /* if (m->locked && m->type != SS_INPROGRESS) */ 962*7c478bd9Sstevel@tonic-gate if (m->locked) 963*7c478bd9Sstevel@tonic-gate printf("Locked "); 964*7c478bd9Sstevel@tonic-gate if (m->stst[0] != '\0') { 965*7c478bd9Sstevel@tonic-gate printf("%s", m->stst); 966*7c478bd9Sstevel@tonic-gate switch (m->type) { 967*7c478bd9Sstevel@tonic-gate case SS_SEQBAD: 968*7c478bd9Sstevel@tonic-gate case SS_LOGIN_FAILED: 969*7c478bd9Sstevel@tonic-gate case SS_DIAL_FAILED: 970*7c478bd9Sstevel@tonic-gate case SS_BAD_LOG_MCH: 971*7c478bd9Sstevel@tonic-gate case SS_BADSYSTEM: 972*7c478bd9Sstevel@tonic-gate case SS_CANT_ACCESS_DEVICE: 973*7c478bd9Sstevel@tonic-gate case SS_DEVICE_FAILED: 974*7c478bd9Sstevel@tonic-gate case SS_WRONG_MCH: 975*7c478bd9Sstevel@tonic-gate case SS_RLOCKED: 976*7c478bd9Sstevel@tonic-gate case SS_RUNKNOWN: 977*7c478bd9Sstevel@tonic-gate case SS_RLOGIN: 978*7c478bd9Sstevel@tonic-gate case SS_UNKNOWN_RESPONSE: 979*7c478bd9Sstevel@tonic-gate case SS_STARTUP: 980*7c478bd9Sstevel@tonic-gate case SS_CHAT_FAILED: 981*7c478bd9Sstevel@tonic-gate (void) time(&t); 982*7c478bd9Sstevel@tonic-gate t = m->retrytime - (t - m->lasttime); 983*7c478bd9Sstevel@tonic-gate if (t > 0) { 984*7c478bd9Sstevel@tonic-gate minimum = (t + 59) / 60; 985*7c478bd9Sstevel@tonic-gate printf("Retry: %d:%2.2d", minimum/60, minimum%60); 986*7c478bd9Sstevel@tonic-gate } 987*7c478bd9Sstevel@tonic-gate if (m->count > 1) 988*7c478bd9Sstevel@tonic-gate printf(" Count: %d", m->count); 989*7c478bd9Sstevel@tonic-gate } 990*7c478bd9Sstevel@tonic-gate } 991*7c478bd9Sstevel@tonic-gate putchar('\n'); 992*7c478bd9Sstevel@tonic-gate return; 993*7c478bd9Sstevel@tonic-gate } 994*7c478bd9Sstevel@tonic-gate 995*7c478bd9Sstevel@tonic-gate #define MAXLOCKS 100 /* Maximum number of lock files this will handle */ 996*7c478bd9Sstevel@tonic-gate 997*7c478bd9Sstevel@tonic-gate int 998*7c478bd9Sstevel@tonic-gate lckpid() 999*7c478bd9Sstevel@tonic-gate { 1000*7c478bd9Sstevel@tonic-gate register i; 1001*7c478bd9Sstevel@tonic-gate int fd, ret; 1002*7c478bd9Sstevel@tonic-gate pid_t pid, list[MAXLOCKS]; 1003*7c478bd9Sstevel@tonic-gate char alpid[SIZEOFPID+2]; /* +2 for '\n' and null */ 1004*7c478bd9Sstevel@tonic-gate char buf[BUFSIZ], f[MAXNAMESIZE]; 1005*7c478bd9Sstevel@tonic-gate char *c, lckdir[BUFSIZ]; 1006*7c478bd9Sstevel@tonic-gate DIR *dir; 1007*7c478bd9Sstevel@tonic-gate 1008*7c478bd9Sstevel@tonic-gate DEBUG(9, "lckpid() - entered\n%s", ""); 1009*7c478bd9Sstevel@tonic-gate for (i=0; i<MAXLOCKS; i++) 1010*7c478bd9Sstevel@tonic-gate list[i] = -1; 1011*7c478bd9Sstevel@tonic-gate (void) strcpy(lckdir, LOCKPRE); 1012*7c478bd9Sstevel@tonic-gate *strrchr(lckdir, '/') = '\0'; 1013*7c478bd9Sstevel@tonic-gate DEBUG(9, "lockdir (%s)\n", lckdir); 1014*7c478bd9Sstevel@tonic-gate 1015*7c478bd9Sstevel@tonic-gate /* open lock directory */ 1016*7c478bd9Sstevel@tonic-gate if (chdir(lckdir) != 0 || (dir = opendir(lckdir)) == NULL) 1017*7c478bd9Sstevel@tonic-gate exit(101); /* good old code 101 */ 1018*7c478bd9Sstevel@tonic-gate while (gnameflck(dir, f) == TRUE) { 1019*7c478bd9Sstevel@tonic-gate /* find all lock files */ 1020*7c478bd9Sstevel@tonic-gate DEBUG(9, "f (%s)\n", f); 1021*7c478bd9Sstevel@tonic-gate if (EQUALSN("LCK.", f, 4) || EQUALSN("LK.", f, 3)) { 1022*7c478bd9Sstevel@tonic-gate /* read LCK file */ 1023*7c478bd9Sstevel@tonic-gate fd = open(f, O_RDONLY); 1024*7c478bd9Sstevel@tonic-gate printf("%s: ", f); 1025*7c478bd9Sstevel@tonic-gate ret = read(fd, alpid, SIZEOFPID+2); /* +2 for '\n' and null */ 1026*7c478bd9Sstevel@tonic-gate pid = strtol(alpid, (char **) NULL, 10); 1027*7c478bd9Sstevel@tonic-gate (void) close(fd); 1028*7c478bd9Sstevel@tonic-gate if (ret != -1) { 1029*7c478bd9Sstevel@tonic-gate printf("%ld\n", (long) pid); 1030*7c478bd9Sstevel@tonic-gate for(i=0; i<MAXLOCKS; i++) { 1031*7c478bd9Sstevel@tonic-gate if (list[i] == pid) 1032*7c478bd9Sstevel@tonic-gate break; 1033*7c478bd9Sstevel@tonic-gate if (list[i] == -1) { 1034*7c478bd9Sstevel@tonic-gate list[i] = pid; 1035*7c478bd9Sstevel@tonic-gate break; 1036*7c478bd9Sstevel@tonic-gate } 1037*7c478bd9Sstevel@tonic-gate } 1038*7c478bd9Sstevel@tonic-gate } 1039*7c478bd9Sstevel@tonic-gate else 1040*7c478bd9Sstevel@tonic-gate printf("????\n"); 1041*7c478bd9Sstevel@tonic-gate } 1042*7c478bd9Sstevel@tonic-gate } 1043*7c478bd9Sstevel@tonic-gate fflush(stdout); 1044*7c478bd9Sstevel@tonic-gate *buf = NULLCHAR; 1045*7c478bd9Sstevel@tonic-gate for (i=0; i<MAXLOCKS; i++) { 1046*7c478bd9Sstevel@tonic-gate if( list[i] == -1) 1047*7c478bd9Sstevel@tonic-gate break; 1048*7c478bd9Sstevel@tonic-gate (void) sprintf(&buf[strlen(buf)], "%d ", list[i]); 1049*7c478bd9Sstevel@tonic-gate } 1050*7c478bd9Sstevel@tonic-gate 1051*7c478bd9Sstevel@tonic-gate if (i > 0) 1052*7c478bd9Sstevel@tonic-gate #ifdef V7 1053*7c478bd9Sstevel@tonic-gate execl("/bin/ps", "uustat-ps", buf, (char *) 0); 1054*7c478bd9Sstevel@tonic-gate #else 1055*7c478bd9Sstevel@tonic-gate execl("/usr/bin/ps", "ps", "-flp", buf, (char *) 0); 1056*7c478bd9Sstevel@tonic-gate #endif 1057*7c478bd9Sstevel@tonic-gate exit(0); 1058*7c478bd9Sstevel@tonic-gate } 1059*7c478bd9Sstevel@tonic-gate 1060*7c478bd9Sstevel@tonic-gate /* 1061*7c478bd9Sstevel@tonic-gate * get next file name from lock directory 1062*7c478bd9Sstevel@tonic-gate * p -> file description of directory file to read 1063*7c478bd9Sstevel@tonic-gate * filename -> address of buffer to return filename in 1064*7c478bd9Sstevel@tonic-gate * must be of size NAMESIZE 1065*7c478bd9Sstevel@tonic-gate * returns: 1066*7c478bd9Sstevel@tonic-gate * FALSE -> end of directory read 1067*7c478bd9Sstevel@tonic-gate * TRUE -> returned name 1068*7c478bd9Sstevel@tonic-gate */ 1069*7c478bd9Sstevel@tonic-gate static int 1070*7c478bd9Sstevel@tonic-gate gnameflck(p, filename) 1071*7c478bd9Sstevel@tonic-gate register char *filename; 1072*7c478bd9Sstevel@tonic-gate DIR *p; 1073*7c478bd9Sstevel@tonic-gate { 1074*7c478bd9Sstevel@tonic-gate struct dirent dentry; 1075*7c478bd9Sstevel@tonic-gate register struct dirent *dp = &dentry; 1076*7c478bd9Sstevel@tonic-gate 1077*7c478bd9Sstevel@tonic-gate for (;;) { 1078*7c478bd9Sstevel@tonic-gate if ((dp = readdir(p)) == NULL) 1079*7c478bd9Sstevel@tonic-gate return(FALSE); 1080*7c478bd9Sstevel@tonic-gate if (dp->d_ino != 0 && dp->d_name[0] != '.') 1081*7c478bd9Sstevel@tonic-gate break; 1082*7c478bd9Sstevel@tonic-gate } 1083*7c478bd9Sstevel@tonic-gate 1084*7c478bd9Sstevel@tonic-gate (void) strncpy(filename, dp->d_name, MAXNAMESIZE-1); 1085*7c478bd9Sstevel@tonic-gate filename[MAXNAMESIZE-1] = '\0'; 1086*7c478bd9Sstevel@tonic-gate return(TRUE); 1087*7c478bd9Sstevel@tonic-gate } 1088*7c478bd9Sstevel@tonic-gate 1089*7c478bd9Sstevel@tonic-gate int 1090*7c478bd9Sstevel@tonic-gate machcmp(a,b) 1091*7c478bd9Sstevel@tonic-gate char *a,*b; 1092*7c478bd9Sstevel@tonic-gate { 1093*7c478bd9Sstevel@tonic-gate return(strcmp(((struct m *) a)->mach,((struct m *) b)->mach)); 1094*7c478bd9Sstevel@tonic-gate } 1095*7c478bd9Sstevel@tonic-gate 1096*7c478bd9Sstevel@tonic-gate static long _sec_per_day = 86400L; 1097*7c478bd9Sstevel@tonic-gate 1098*7c478bd9Sstevel@tonic-gate /* 1099*7c478bd9Sstevel@tonic-gate * _age - find the age of "file" in days 1100*7c478bd9Sstevel@tonic-gate * return: 1101*7c478bd9Sstevel@tonic-gate * age of file 1102*7c478bd9Sstevel@tonic-gate * 0 - if stat fails 1103*7c478bd9Sstevel@tonic-gate */ 1104*7c478bd9Sstevel@tonic-gate 1105*7c478bd9Sstevel@tonic-gate int 1106*7c478bd9Sstevel@tonic-gate _age(dir, file) 1107*7c478bd9Sstevel@tonic-gate char * file; /* the file name */ 1108*7c478bd9Sstevel@tonic-gate char * dir; /* system spool directory */ 1109*7c478bd9Sstevel@tonic-gate { 1110*7c478bd9Sstevel@tonic-gate char fullname[MAXFULLNAME]; 1111*7c478bd9Sstevel@tonic-gate static time_t ptime = 0; 1112*7c478bd9Sstevel@tonic-gate time_t time(); 1113*7c478bd9Sstevel@tonic-gate struct stat stbuf; 1114*7c478bd9Sstevel@tonic-gate 1115*7c478bd9Sstevel@tonic-gate if (!ptime) 1116*7c478bd9Sstevel@tonic-gate (void) time(&ptime); 1117*7c478bd9Sstevel@tonic-gate (void) sprintf(fullname, "%s/%s", dir, file); 1118*7c478bd9Sstevel@tonic-gate if (stat(fullname, &stbuf) != -1) { 1119*7c478bd9Sstevel@tonic-gate return ((int)((ptime - stbuf.st_mtime)/_sec_per_day)); 1120*7c478bd9Sstevel@tonic-gate } 1121*7c478bd9Sstevel@tonic-gate else 1122*7c478bd9Sstevel@tonic-gate return(0); 1123*7c478bd9Sstevel@tonic-gate } 1124*7c478bd9Sstevel@tonic-gate /* Function: complete - find and print jobids of completed jobs for 1125*7c478bd9Sstevel@tonic-gate * user. 1126*7c478bd9Sstevel@tonic-gate * 1127*7c478bd9Sstevel@tonic-gate * Look thru the /var/uucp/.Admin/account file (if present) 1128*7c478bd9Sstevel@tonic-gate * for all jobs initiated by user and print. 1129*7c478bd9Sstevel@tonic-gate * 1130*7c478bd9Sstevel@tonic-gate * Parameters: 1131*7c478bd9Sstevel@tonic-gate * 1132*7c478bd9Sstevel@tonic-gate * Username - user that initiated uustat request 1133*7c478bd9Sstevel@tonic-gate * 1134*7c478bd9Sstevel@tonic-gate * Returns: 1135*7c478bd9Sstevel@tonic-gate * 1136*7c478bd9Sstevel@tonic-gate */ 1137*7c478bd9Sstevel@tonic-gate static void 1138*7c478bd9Sstevel@tonic-gate complete() 1139*7c478bd9Sstevel@tonic-gate { 1140*7c478bd9Sstevel@tonic-gate 1141*7c478bd9Sstevel@tonic-gate /* Function name: complete 1142*7c478bd9Sstevel@tonic-gate Author: Roland T. Conwell 1143*7c478bd9Sstevel@tonic-gate Date: July 31, 1986 1144*7c478bd9Sstevel@tonic-gate Naration: This function will search through 1145*7c478bd9Sstevel@tonic-gate /var/uucp/.Admin/account file 1146*7c478bd9Sstevel@tonic-gate for all jobs submitted by User. If User jobs are 1147*7c478bd9Sstevel@tonic-gate found the state of 'completed' will be 1148*7c478bd9Sstevel@tonic-gate printed on stdout. Module called by uustat main 1149*7c478bd9Sstevel@tonic-gate 1150*7c478bd9Sstevel@tonic-gate */ 1151*7c478bd9Sstevel@tonic-gate char abuf[BUFSIZ]; 1152*7c478bd9Sstevel@tonic-gate FILE *fp; 1153*7c478bd9Sstevel@tonic-gate char accno[15], jobid[15], system[15], loginame[15], time[20], dest[15]; 1154*7c478bd9Sstevel@tonic-gate char size[15]; 1155*7c478bd9Sstevel@tonic-gate char grade[2], jgrade[2]; 1156*7c478bd9Sstevel@tonic-gate char status[2]; 1157*7c478bd9Sstevel@tonic-gate int x; 1158*7c478bd9Sstevel@tonic-gate 1159*7c478bd9Sstevel@tonic-gate fp = fopen(ACCOUNT, "r"); 1160*7c478bd9Sstevel@tonic-gate if (fp == NULL) 1161*7c478bd9Sstevel@tonic-gate { 1162*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Can't open account log\n")); 1163*7c478bd9Sstevel@tonic-gate return; 1164*7c478bd9Sstevel@tonic-gate } 1165*7c478bd9Sstevel@tonic-gate while (fgets(abuf, BUFSIZ, fp) != NULL) 1166*7c478bd9Sstevel@tonic-gate { 1167*7c478bd9Sstevel@tonic-gate 1168*7c478bd9Sstevel@tonic-gate x = sscanf(abuf, "%s%s%s%s%s%s%s%s%s%s", 1169*7c478bd9Sstevel@tonic-gate accno,jobid, size, status, grade, jgrade, system, loginame, 1170*7c478bd9Sstevel@tonic-gate time, dest); 1171*7c478bd9Sstevel@tonic-gate if (x < 6) 1172*7c478bd9Sstevel@tonic-gate continue; 1173*7c478bd9Sstevel@tonic-gate 1174*7c478bd9Sstevel@tonic-gate if (!EQUALS(status, "C")) 1175*7c478bd9Sstevel@tonic-gate continue; 1176*7c478bd9Sstevel@tonic-gate 1177*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: accno = %s\n", accno); 1178*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: jobid = %s\n", jobid); 1179*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: size = %s\n", size); 1180*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: status = %s\n", status); 1181*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: grade = %s\n", grade); 1182*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: jgrade = %s\n", jgrade); 1183*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: system = %s\n", system); 1184*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: loginame = %s\n", loginame); 1185*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: time = %s\n", time); 1186*7c478bd9Sstevel@tonic-gate DEBUG(9, "COMPLETE: dest = %s\n", dest); 1187*7c478bd9Sstevel@tonic-gate 1188*7c478bd9Sstevel@tonic-gate if (*Rmtname && !EQUALS(Rmtname, dest)) 1189*7c478bd9Sstevel@tonic-gate continue; 1190*7c478bd9Sstevel@tonic-gate if (*User && !EQUALS(User, loginame)) 1191*7c478bd9Sstevel@tonic-gate continue; 1192*7c478bd9Sstevel@tonic-gate if (State && !Uopt) 1193*7c478bd9Sstevel@tonic-gate { 1194*7c478bd9Sstevel@tonic-gate if (EQUALS(Loginuser, loginame)) 1195*7c478bd9Sstevel@tonic-gate { 1196*7c478bd9Sstevel@tonic-gate printf("%s completed\n",jobid); 1197*7c478bd9Sstevel@tonic-gate jobcount++; 1198*7c478bd9Sstevel@tonic-gate } 1199*7c478bd9Sstevel@tonic-gate } 1200*7c478bd9Sstevel@tonic-gate else 1201*7c478bd9Sstevel@tonic-gate { 1202*7c478bd9Sstevel@tonic-gate printf("%s completed\n", jobid); 1203*7c478bd9Sstevel@tonic-gate jobcount++; 1204*7c478bd9Sstevel@tonic-gate } 1205*7c478bd9Sstevel@tonic-gate } 1206*7c478bd9Sstevel@tonic-gate fclose(fp); 1207*7c478bd9Sstevel@tonic-gate return; 1208*7c478bd9Sstevel@tonic-gate } 1209*7c478bd9Sstevel@tonic-gate 1210*7c478bd9Sstevel@tonic-gate /* Function: state - determine if Cdotfile is queued or running 1211*7c478bd9Sstevel@tonic-gate * 1212*7c478bd9Sstevel@tonic-gate * This function searches thru the directory jcdir for a Adotfile 1213*7c478bd9Sstevel@tonic-gate * that matches the Cdotfile. If found then look for a matching 1214*7c478bd9Sstevel@tonic-gate * lock file. If a Adotfile and a lock file is found then the 1215*7c478bd9Sstevel@tonic-gate * job is in the running state. If no Adotfile is found then the 1216*7c478bd9Sstevel@tonic-gate * job is in the queued state. If a Adotfile is found and no 1217*7c478bd9Sstevel@tonic-gate * lock file is found then the job is queued. 1218*7c478bd9Sstevel@tonic-gate * 1219*7c478bd9Sstevel@tonic-gate * Parameters: 1220*7c478bd9Sstevel@tonic-gate * 1221*7c478bd9Sstevel@tonic-gate * jcdir - the job grade directory to search 1222*7c478bd9Sstevel@tonic-gate * cdotfile - the Cdotfile whose state is to be determined 1223*7c478bd9Sstevel@tonic-gate * 1224*7c478bd9Sstevel@tonic-gate * Returns: 1225*7c478bd9Sstevel@tonic-gate * 1226*7c478bd9Sstevel@tonic-gate */ 1227*7c478bd9Sstevel@tonic-gate static int 1228*7c478bd9Sstevel@tonic-gate state(jcdir, cdotfile) 1229*7c478bd9Sstevel@tonic-gate char *jcdir, *cdotfile; 1230*7c478bd9Sstevel@tonic-gate { 1231*7c478bd9Sstevel@tonic-gate short found, foundlck, CequalA; 1232*7c478bd9Sstevel@tonic-gate char comparef[MAXBASENAME+1], afile[MAXBASENAME+1], cfile[MAXBASENAME+1]; 1233*7c478bd9Sstevel@tonic-gate char lckfile[MAXBASENAME+1], lockname[MAXBASENAME+1]; 1234*7c478bd9Sstevel@tonic-gate char lckdir[BUFSIZ+1]; 1235*7c478bd9Sstevel@tonic-gate DIR *subjcdir, *sjcdir; 1236*7c478bd9Sstevel@tonic-gate short rtnstate = 0; 1237*7c478bd9Sstevel@tonic-gate foundlck = 0; 1238*7c478bd9Sstevel@tonic-gate CequalA = 0; 1239*7c478bd9Sstevel@tonic-gate sjcdir = opendir(jcdir); 1240*7c478bd9Sstevel@tonic-gate if (sjcdir == NULL) 1241*7c478bd9Sstevel@tonic-gate return; 1242*7c478bd9Sstevel@tonic-gate 1243*7c478bd9Sstevel@tonic-gate while (gnamef(sjcdir, comparef) == TRUE) { 1244*7c478bd9Sstevel@tonic-gate if (comparef[0] == 'A') { 1245*7c478bd9Sstevel@tonic-gate 1246*7c478bd9Sstevel@tonic-gate (void) strcpy(afile, comparef); 1247*7c478bd9Sstevel@tonic-gate *strchr(afile, 'A') = ' '; 1248*7c478bd9Sstevel@tonic-gate (void) strcpy(cfile, cdotfile); 1249*7c478bd9Sstevel@tonic-gate *strchr(cfile, 'C') = ' '; 1250*7c478bd9Sstevel@tonic-gate 1251*7c478bd9Sstevel@tonic-gate if (EQUALS(cfile, afile)) { 1252*7c478bd9Sstevel@tonic-gate /* now we have a C. and A. for same job */ 1253*7c478bd9Sstevel@tonic-gate /* check for LCK..machine.job_grade */ 1254*7c478bd9Sstevel@tonic-gate /* if no LCK file at this point we will */ 1255*7c478bd9Sstevel@tonic-gate /* print the RUNNING state */ 1256*7c478bd9Sstevel@tonic-gate CequalA = 1; 1257*7c478bd9Sstevel@tonic-gate 1258*7c478bd9Sstevel@tonic-gate (void) strcpy(lckdir, LOCKPRE); 1259*7c478bd9Sstevel@tonic-gate *strrchr(lckdir, '/') = '\0'; 1260*7c478bd9Sstevel@tonic-gate /* open lock directory */ 1261*7c478bd9Sstevel@tonic-gate 1262*7c478bd9Sstevel@tonic-gate subjcdir = opendir(lckdir); 1263*7c478bd9Sstevel@tonic-gate if (subjcdir == NULL) 1264*7c478bd9Sstevel@tonic-gate exit(101); /* I know, I know! */ 1265*7c478bd9Sstevel@tonic-gate (void) sprintf(lockname,"%s%s.%s",LOCK, f, jcdir); 1266*7c478bd9Sstevel@tonic-gate while (gnamef(subjcdir, lckfile) == TRUE) 1267*7c478bd9Sstevel@tonic-gate { 1268*7c478bd9Sstevel@tonic-gate DEBUG(9, "STATE: lockfile = %s\n",lckfile); 1269*7c478bd9Sstevel@tonic-gate if (EQUALS(lockname, lckfile)) 1270*7c478bd9Sstevel@tonic-gate foundlck = 1; 1271*7c478bd9Sstevel@tonic-gate } 1272*7c478bd9Sstevel@tonic-gate closedir(subjcdir); 1273*7c478bd9Sstevel@tonic-gate 1274*7c478bd9Sstevel@tonic-gate } 1275*7c478bd9Sstevel@tonic-gate } 1276*7c478bd9Sstevel@tonic-gate 1277*7c478bd9Sstevel@tonic-gate } 1278*7c478bd9Sstevel@tonic-gate 1279*7c478bd9Sstevel@tonic-gate closedir(sjcdir); 1280*7c478bd9Sstevel@tonic-gate /* got adot, cdot and lock file */ 1281*7c478bd9Sstevel@tonic-gate 1282*7c478bd9Sstevel@tonic-gate if (Running && foundlck) 1283*7c478bd9Sstevel@tonic-gate rtnstate = 2; 1284*7c478bd9Sstevel@tonic-gate else if (Interrupted && CequalA && !foundlck) 1285*7c478bd9Sstevel@tonic-gate rtnstate = 3; 1286*7c478bd9Sstevel@tonic-gate else if (Queued && !CequalA && !foundlck) 1287*7c478bd9Sstevel@tonic-gate rtnstate = 1; 1288*7c478bd9Sstevel@tonic-gate DEBUG(9, "STATE: returning with value %d\n",rtnstate); 1289*7c478bd9Sstevel@tonic-gate return(rtnstate); 1290*7c478bd9Sstevel@tonic-gate 1291*7c478bd9Sstevel@tonic-gate } /* end of state.c */ 1292*7c478bd9Sstevel@tonic-gate 1293*7c478bd9Sstevel@tonic-gate 1294*7c478bd9Sstevel@tonic-gate 1295*7c478bd9Sstevel@tonic-gate static int 1296*7c478bd9Sstevel@tonic-gate readperf(timerange) 1297*7c478bd9Sstevel@tonic-gate long timerange; 1298*7c478bd9Sstevel@tonic-gate { 1299*7c478bd9Sstevel@tonic-gate 1300*7c478bd9Sstevel@tonic-gate char proto[2], jc[2], role[2]; 1301*7c478bd9Sstevel@tonic-gate char rectype[5], time[MAXDATE+1], pid[10],wmachine[10]; 1302*7c478bd9Sstevel@tonic-gate char remote[10],device[10], netid[20], jobid[20]; 1303*7c478bd9Sstevel@tonic-gate static float queuetime, tat; 1304*7c478bd9Sstevel@tonic-gate static long size; 1305*7c478bd9Sstevel@tonic-gate struct tm tm_tmp; 1306*7c478bd9Sstevel@tonic-gate time_t t_time, t_starttime, t_upperlimit; 1307*7c478bd9Sstevel@tonic-gate 1308*7c478bd9Sstevel@tonic-gate char options[10]; 1309*7c478bd9Sstevel@tonic-gate static float rst, ust, kst, xferrate, utt, ktt; 1310*7c478bd9Sstevel@tonic-gate static float rtt, wfield, xfield, yfield; 1311*7c478bd9Sstevel@tonic-gate 1312*7c478bd9Sstevel@tonic-gate register struct perfrec *recptr; 1313*7c478bd9Sstevel@tonic-gate static float tqt; 1314*7c478bd9Sstevel@tonic-gate static int jobs; 1315*7c478bd9Sstevel@tonic-gate char abuf[BUFSIZ]; 1316*7c478bd9Sstevel@tonic-gate FILE *fp; 1317*7c478bd9Sstevel@tonic-gate static int x; 1318*7c478bd9Sstevel@tonic-gate char *strptr, *startime; 1319*7c478bd9Sstevel@tonic-gate int recordcnt; 1320*7c478bd9Sstevel@tonic-gate 1321*7c478bd9Sstevel@tonic-gate totalxfer=totalbytes=recordcnt=totaljob=totalque=0; 1322*7c478bd9Sstevel@tonic-gate lowerlimit[0] = '\0'; 1323*7c478bd9Sstevel@tonic-gate upperlimit[0] = '\0'; 1324*7c478bd9Sstevel@tonic-gate 1325*7c478bd9Sstevel@tonic-gate 1326*7c478bd9Sstevel@tonic-gate inputsecs = convert(timerange); 1327*7c478bd9Sstevel@tonic-gate startime = gmts(); 1328*7c478bd9Sstevel@tonic-gate strncpy(lowerlimit, startime, MAXDATE); 1329*7c478bd9Sstevel@tonic-gate strncpy(upperlimit, gmt(), MAXDATE); 1330*7c478bd9Sstevel@tonic-gate 1331*7c478bd9Sstevel@tonic-gate /* convert lowerlimit and upperlimit to HH:MM format */ 1332*7c478bd9Sstevel@tonic-gate friendlytime(lowerlimit, upperlimit); 1333*7c478bd9Sstevel@tonic-gate 1334*7c478bd9Sstevel@tonic-gate fp = fopen(PERFLOG, "r"); 1335*7c478bd9Sstevel@tonic-gate if (fp == NULL) 1336*7c478bd9Sstevel@tonic-gate { 1337*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("Can't open performance log\n")); 1338*7c478bd9Sstevel@tonic-gate return(0); 1339*7c478bd9Sstevel@tonic-gate } 1340*7c478bd9Sstevel@tonic-gate 1341*7c478bd9Sstevel@tonic-gate 1342*7c478bd9Sstevel@tonic-gate while (fgets(abuf, BUFSIZ, fp) != NULL) 1343*7c478bd9Sstevel@tonic-gate { 1344*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: abuf before = %s\n",abuf); 1345*7c478bd9Sstevel@tonic-gate 1346*7c478bd9Sstevel@tonic-gate if (!EQUALSN(abuf, "xfer", 4)) 1347*7c478bd9Sstevel@tonic-gate continue; 1348*7c478bd9Sstevel@tonic-gate 1349*7c478bd9Sstevel@tonic-gate /* convert all '|'s to blanks for sscanf */ 1350*7c478bd9Sstevel@tonic-gate for (strptr = abuf; *strptr != '\0'; strptr++) 1351*7c478bd9Sstevel@tonic-gate if (*strptr == '|') 1352*7c478bd9Sstevel@tonic-gate *strptr = ' '; 1353*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: abuf = %s\n",abuf); 1354*7c478bd9Sstevel@tonic-gate 1355*7c478bd9Sstevel@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", 1356*7c478bd9Sstevel@tonic-gate rectype, time, pid, wmachine, role, remote, device, netid, 1357*7c478bd9Sstevel@tonic-gate jobid, &queuetime, &tat, &size, options, &rst, 1358*7c478bd9Sstevel@tonic-gate &ust, &kst, &xferrate, &utt, &ktt, &rtt, &wfield, 1359*7c478bd9Sstevel@tonic-gate &xfield); 1360*7c478bd9Sstevel@tonic-gate 1361*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: rectype = %s\n",rectype); 1362*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: time = %s\n",time); 1363*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: pid = %s\n",pid); 1364*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: remote = %s\n",remote); 1365*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: jobid = %s\n",jobid); 1366*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: queuetime = %f\n",queuetime); 1367*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: tat = %f\n",tat); 1368*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: xferrate = %f\n",xferrate); 1369*7c478bd9Sstevel@tonic-gate 1370*7c478bd9Sstevel@tonic-gate abuf[0] = '\0'; 1371*7c478bd9Sstevel@tonic-gate 1372*7c478bd9Sstevel@tonic-gate if (!EQUALS(Rmtname, remote)) 1373*7c478bd9Sstevel@tonic-gate continue; 1374*7c478bd9Sstevel@tonic-gate 1375*7c478bd9Sstevel@tonic-gate if (!EQUALS(role, "M")) 1376*7c478bd9Sstevel@tonic-gate continue; 1377*7c478bd9Sstevel@tonic-gate 1378*7c478bd9Sstevel@tonic-gate if (x < 18) 1379*7c478bd9Sstevel@tonic-gate continue; 1380*7c478bd9Sstevel@tonic-gate 1381*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: startime = %s\n", startime); 1382*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: lowerlimit = %s\n", lowerlimit); 1383*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: time = %s\n", time); 1384*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: upperlimit = %s\n", upperlimit); 1385*7c478bd9Sstevel@tonic-gate 1386*7c478bd9Sstevel@tonic-gate strptime(time, "%y %m %d %H %M %S", &tm_tmp); 1387*7c478bd9Sstevel@tonic-gate t_time = mktime(&tm_tmp); 1388*7c478bd9Sstevel@tonic-gate strptime(startime, "%y %m %d %H %M %S", &tm_tmp); 1389*7c478bd9Sstevel@tonic-gate t_starttime = mktime(&tm_tmp); 1390*7c478bd9Sstevel@tonic-gate strptime(upperlimit, "%y %m %d %H %M %S", &tm_tmp); 1391*7c478bd9Sstevel@tonic-gate t_upperlimit = mktime(&tm_tmp); 1392*7c478bd9Sstevel@tonic-gate 1393*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: t_time = %d\n", t_time); 1394*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: t_starttime = %d\n", t_starttime); 1395*7c478bd9Sstevel@tonic-gate DEBUG(9, "READPERF: t_upperlimit = %d\n", t_upperlimit); 1396*7c478bd9Sstevel@tonic-gate if (t_starttime <= t_time && t_upperlimit >= t_time) 1397*7c478bd9Sstevel@tonic-gate { 1398*7c478bd9Sstevel@tonic-gate totaljob++; 1399*7c478bd9Sstevel@tonic-gate totalque = totalque + queuetime; 1400*7c478bd9Sstevel@tonic-gate totalxfer = totalxfer + xferrate; 1401*7c478bd9Sstevel@tonic-gate totalbytes = totalbytes + size; 1402*7c478bd9Sstevel@tonic-gate recordcnt = recordcnt + 1; 1403*7c478bd9Sstevel@tonic-gate DEBUG(9, " processing recordcnt %d\n", recordcnt); 1404*7c478bd9Sstevel@tonic-gate } 1405*7c478bd9Sstevel@tonic-gate DEBUG(9, "END step 1 %d\n", recordcnt); 1406*7c478bd9Sstevel@tonic-gate } /* while */ 1407*7c478bd9Sstevel@tonic-gate DEBUG(9, "END step 2 recordcnt %d\n", recordcnt); 1408*7c478bd9Sstevel@tonic-gate 1409*7c478bd9Sstevel@tonic-gate fclose(fp); 1410*7c478bd9Sstevel@tonic-gate return(recordcnt); 1411*7c478bd9Sstevel@tonic-gate 1412*7c478bd9Sstevel@tonic-gate 1413*7c478bd9Sstevel@tonic-gate } /* end of readperf */ 1414*7c478bd9Sstevel@tonic-gate 1415*7c478bd9Sstevel@tonic-gate void 1416*7c478bd9Sstevel@tonic-gate docalc() 1417*7c478bd9Sstevel@tonic-gate { 1418*7c478bd9Sstevel@tonic-gate if (avgqueue) 1419*7c478bd9Sstevel@tonic-gate queuetime(); 1420*7c478bd9Sstevel@tonic-gate else 1421*7c478bd9Sstevel@tonic-gate xfertime(); 1422*7c478bd9Sstevel@tonic-gate return; 1423*7c478bd9Sstevel@tonic-gate } 1424*7c478bd9Sstevel@tonic-gate 1425*7c478bd9Sstevel@tonic-gate static int 1426*7c478bd9Sstevel@tonic-gate convert(intime) 1427*7c478bd9Sstevel@tonic-gate long intime; 1428*7c478bd9Sstevel@tonic-gate { 1429*7c478bd9Sstevel@tonic-gate long outtime; 1430*7c478bd9Sstevel@tonic-gate 1431*7c478bd9Sstevel@tonic-gate outtime = intime * 60; 1432*7c478bd9Sstevel@tonic-gate return(outtime); 1433*7c478bd9Sstevel@tonic-gate 1434*7c478bd9Sstevel@tonic-gate } 1435*7c478bd9Sstevel@tonic-gate static void 1436*7c478bd9Sstevel@tonic-gate queuetime() 1437*7c478bd9Sstevel@tonic-gate { 1438*7c478bd9Sstevel@tonic-gate static double avgqtime; 1439*7c478bd9Sstevel@tonic-gate 1440*7c478bd9Sstevel@tonic-gate avgqtime = totalque / totaljob; 1441*7c478bd9Sstevel@tonic-gate 1442*7c478bd9Sstevel@tonic-gate printf("average queue time to [%s] for last [%ld] minutes: %6.2f seconds\n",Rmtname, calcnum, avgqtime); 1443*7c478bd9Sstevel@tonic-gate printf("data gathered from %s:%s to %s:%s GMT\n", friendlyptr->uhour, friendlyptr->umin, friendlyptr->lhour, friendlyptr->lmin); 1444*7c478bd9Sstevel@tonic-gate return; 1445*7c478bd9Sstevel@tonic-gate } 1446*7c478bd9Sstevel@tonic-gate 1447*7c478bd9Sstevel@tonic-gate 1448*7c478bd9Sstevel@tonic-gate static void 1449*7c478bd9Sstevel@tonic-gate xfertime() 1450*7c478bd9Sstevel@tonic-gate { 1451*7c478bd9Sstevel@tonic-gate static double avgxrate; 1452*7c478bd9Sstevel@tonic-gate 1453*7c478bd9Sstevel@tonic-gate avgxrate = totalbytes / totalxfer; 1454*7c478bd9Sstevel@tonic-gate 1455*7c478bd9Sstevel@tonic-gate printf("average transfer rate with [ %s ] for last [%ld] minutes: %6.2f bytes/sec\n", Rmtname, calcnum, avgxrate); 1456*7c478bd9Sstevel@tonic-gate printf("data gathered from %s:%s to %s:%s GMT\n", friendlyptr->uhour, friendlyptr->umin, friendlyptr->lhour, friendlyptr->lmin); 1457*7c478bd9Sstevel@tonic-gate return; 1458*7c478bd9Sstevel@tonic-gate } 1459*7c478bd9Sstevel@tonic-gate 1460*7c478bd9Sstevel@tonic-gate /* 1461*7c478bd9Sstevel@tonic-gate * Local Function: gmts - Generate Start Time String 1462*7c478bd9Sstevel@tonic-gate * 1463*7c478bd9Sstevel@tonic-gate * This function returns the address to a string containing the start 1464*7c478bd9Sstevel@tonic-gate * time, or upperlimit, for searching the PERFLOG. 1465*7c478bd9Sstevel@tonic-gate * The start time is in GMT in the form YYMMDDhhmmss. 1466*7c478bd9Sstevel@tonic-gate * 1467*7c478bd9Sstevel@tonic-gate * Parameters: 1468*7c478bd9Sstevel@tonic-gate * 1469*7c478bd9Sstevel@tonic-gate * none 1470*7c478bd9Sstevel@tonic-gate * 1471*7c478bd9Sstevel@tonic-gate * Return: 1472*7c478bd9Sstevel@tonic-gate * 1473*7c478bd9Sstevel@tonic-gate * An address of a static character array containing the date. 1474*7c478bd9Sstevel@tonic-gate */ 1475*7c478bd9Sstevel@tonic-gate 1476*7c478bd9Sstevel@tonic-gate static char * 1477*7c478bd9Sstevel@tonic-gate gmts() 1478*7c478bd9Sstevel@tonic-gate { 1479*7c478bd9Sstevel@tonic-gate static char date[] = "YYMMDDhhmmss"; 1480*7c478bd9Sstevel@tonic-gate 1481*7c478bd9Sstevel@tonic-gate register struct tm * td; 1482*7c478bd9Sstevel@tonic-gate time_t now; /* Current time. */ 1483*7c478bd9Sstevel@tonic-gate time_t temp; 1484*7c478bd9Sstevel@tonic-gate now = time((time_t *) 0); 1485*7c478bd9Sstevel@tonic-gate 1486*7c478bd9Sstevel@tonic-gate /* inputsecs is declared global to this file */ 1487*7c478bd9Sstevel@tonic-gate DEBUG(9, "GMTS: now = %ld\n", now); 1488*7c478bd9Sstevel@tonic-gate DEBUG(9, "GMTS: inputsecs = %ld\n", inputsecs); 1489*7c478bd9Sstevel@tonic-gate 1490*7c478bd9Sstevel@tonic-gate temp = (now - inputsecs); 1491*7c478bd9Sstevel@tonic-gate td = gmtime(&temp); 1492*7c478bd9Sstevel@tonic-gate (void) sprintf(date, "%02d%02d%02d%02d%02d%02d", 1493*7c478bd9Sstevel@tonic-gate (td->tm_year % 100), 1494*7c478bd9Sstevel@tonic-gate td->tm_mon + 1, 1495*7c478bd9Sstevel@tonic-gate td->tm_mday, 1496*7c478bd9Sstevel@tonic-gate td->tm_hour, 1497*7c478bd9Sstevel@tonic-gate td->tm_min, 1498*7c478bd9Sstevel@tonic-gate td->tm_sec 1499*7c478bd9Sstevel@tonic-gate ); 1500*7c478bd9Sstevel@tonic-gate return date; 1501*7c478bd9Sstevel@tonic-gate } 1502*7c478bd9Sstevel@tonic-gate 1503*7c478bd9Sstevel@tonic-gate /* 1504*7c478bd9Sstevel@tonic-gate * Local Function: gmt - Generate Current Time String 1505*7c478bd9Sstevel@tonic-gate * 1506*7c478bd9Sstevel@tonic-gate * This function returns the address to a string containing the current 1507*7c478bd9Sstevel@tonic-gate * GMT in the form YYMMDDhhmmss. 1508*7c478bd9Sstevel@tonic-gate * 1509*7c478bd9Sstevel@tonic-gate * Parameters: 1510*7c478bd9Sstevel@tonic-gate * 1511*7c478bd9Sstevel@tonic-gate * none 1512*7c478bd9Sstevel@tonic-gate * 1513*7c478bd9Sstevel@tonic-gate * Return: 1514*7c478bd9Sstevel@tonic-gate * 1515*7c478bd9Sstevel@tonic-gate * An address of a static character array containing the date. 1516*7c478bd9Sstevel@tonic-gate */ 1517*7c478bd9Sstevel@tonic-gate 1518*7c478bd9Sstevel@tonic-gate static char * 1519*7c478bd9Sstevel@tonic-gate gmt() 1520*7c478bd9Sstevel@tonic-gate { 1521*7c478bd9Sstevel@tonic-gate static char date[] = "YYMMDDhhmmss"; 1522*7c478bd9Sstevel@tonic-gate 1523*7c478bd9Sstevel@tonic-gate register struct tm * td; 1524*7c478bd9Sstevel@tonic-gate time_t now; /* Current time. */ 1525*7c478bd9Sstevel@tonic-gate 1526*7c478bd9Sstevel@tonic-gate now = time((time_t *) 0); 1527*7c478bd9Sstevel@tonic-gate td = gmtime(&now); 1528*7c478bd9Sstevel@tonic-gate (void) sprintf(date, "%02d%02d%02d%02d%02d%02d", 1529*7c478bd9Sstevel@tonic-gate (td->tm_year % 100), 1530*7c478bd9Sstevel@tonic-gate td->tm_mon + 1, 1531*7c478bd9Sstevel@tonic-gate td->tm_mday, 1532*7c478bd9Sstevel@tonic-gate td->tm_hour, 1533*7c478bd9Sstevel@tonic-gate td->tm_min, 1534*7c478bd9Sstevel@tonic-gate td->tm_sec 1535*7c478bd9Sstevel@tonic-gate ); 1536*7c478bd9Sstevel@tonic-gate return date; 1537*7c478bd9Sstevel@tonic-gate } 1538*7c478bd9Sstevel@tonic-gate 1539*7c478bd9Sstevel@tonic-gate static void 1540*7c478bd9Sstevel@tonic-gate friendlytime(uplimit, lolimit) 1541*7c478bd9Sstevel@tonic-gate char *uplimit, *lolimit; 1542*7c478bd9Sstevel@tonic-gate { 1543*7c478bd9Sstevel@tonic-gate 1544*7c478bd9Sstevel@tonic-gate char c; 1545*7c478bd9Sstevel@tonic-gate 1546*7c478bd9Sstevel@tonic-gate c = *(uplimit+6); 1547*7c478bd9Sstevel@tonic-gate friendlyptr->uhour[0] = *(uplimit+6); 1548*7c478bd9Sstevel@tonic-gate friendlyptr->uhour[1] = *(uplimit+7); 1549*7c478bd9Sstevel@tonic-gate friendlyptr->lhour[0] = *(lolimit+6); 1550*7c478bd9Sstevel@tonic-gate friendlyptr->lhour[1] = *(lolimit+7); 1551*7c478bd9Sstevel@tonic-gate friendlyptr->umin[0] = *(uplimit+8); 1552*7c478bd9Sstevel@tonic-gate friendlyptr->umin[1] = *(uplimit+9); 1553*7c478bd9Sstevel@tonic-gate friendlyptr->lmin[0] = *(lolimit+8); 1554*7c478bd9Sstevel@tonic-gate friendlyptr->lmin[1] = *(lolimit+9); 1555*7c478bd9Sstevel@tonic-gate 1556*7c478bd9Sstevel@tonic-gate friendlyptr->uhour[2] = '\0'; 1557*7c478bd9Sstevel@tonic-gate friendlyptr->lhour[2] = '\0'; 1558*7c478bd9Sstevel@tonic-gate friendlyptr->umin[2] = '\0'; 1559*7c478bd9Sstevel@tonic-gate friendlyptr->lmin[2] = '\0'; 1560*7c478bd9Sstevel@tonic-gate return; 1561*7c478bd9Sstevel@tonic-gate } 1562*7c478bd9Sstevel@tonic-gate 1563*7c478bd9Sstevel@tonic-gate void 1564*7c478bd9Sstevel@tonic-gate procState(inputargs) 1565*7c478bd9Sstevel@tonic-gate char * inputargs; 1566*7c478bd9Sstevel@tonic-gate { 1567*7c478bd9Sstevel@tonic-gate if (strchr(inputargs, 'q') != NULL) 1568*7c478bd9Sstevel@tonic-gate Queued = 1; 1569*7c478bd9Sstevel@tonic-gate if (strchr(inputargs, 'r') != NULL) 1570*7c478bd9Sstevel@tonic-gate Running = 1; 1571*7c478bd9Sstevel@tonic-gate if (strchr(inputargs, 'i') != NULL) 1572*7c478bd9Sstevel@tonic-gate Interrupted = 1; 1573*7c478bd9Sstevel@tonic-gate if (strchr(inputargs, 'c') != NULL) 1574*7c478bd9Sstevel@tonic-gate Complete = 1; 1575*7c478bd9Sstevel@tonic-gate 1576*7c478bd9Sstevel@tonic-gate if ((size_t)(Queued + Running + Interrupted + Complete) < strlen(inputargs)) 1577*7c478bd9Sstevel@tonic-gate { 1578*7c478bd9Sstevel@tonic-gate errortn(); 1579*7c478bd9Sstevel@tonic-gate exit(1); 1580*7c478bd9Sstevel@tonic-gate } 1581*7c478bd9Sstevel@tonic-gate return; 1582*7c478bd9Sstevel@tonic-gate } 1583*7c478bd9Sstevel@tonic-gate 1584*7c478bd9Sstevel@tonic-gate static void 1585*7c478bd9Sstevel@tonic-gate errortn() 1586*7c478bd9Sstevel@tonic-gate { 1587*7c478bd9Sstevel@tonic-gate 1588*7c478bd9Sstevel@tonic-gate 1589*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("\tUsage: %s " USAGE1 "\n"), 1590*7c478bd9Sstevel@tonic-gate Progname); 1591*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("or\n\tUsage: %s " USAGE2 "\n"), 1592*7c478bd9Sstevel@tonic-gate Progname); 1593*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("or\n\tUsage: %s " USAGE3 "\n"), 1594*7c478bd9Sstevel@tonic-gate Progname); 1595*7c478bd9Sstevel@tonic-gate return; 1596*7c478bd9Sstevel@tonic-gate } 1597