/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <time.h>
#include "uucp.h"
#ifdef V7
#define O_RDONLY 0
#endif
/* #include "logs.h" */
struct m {
char locked;
long retrytime;
} M[UUSTAT_TBL+2];
struct userdate {
};
extern long atol();
static int whattodo();
static int readperf();
static void queuetime();
static void xfertime();
static char * gmt();
static char * gmts();
static void errortn();
static void friendlytime();
static void complete();
static int state();
static int gnameflck();
static void kprocessC();
static int convert();
static int count;
static short jobcount;
static short execute;
static long inputsecs;
#ifdef ATTSV
extern void qsort(); /* qsort(3) and comparison test */
#endif /* ATTSV */
extern int machcmp();
extern int _age(); /* find the age of a file */
static long calcnum;
extern char Jobid[]; /* jobid for status or kill option */
char f[NAMESIZE];
int
char *argv[];
char **envp;
{
struct m *m, *machine();
int i, chkid;
long temp;
/* Set locale environment variables local definitions */
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
User[0] = '\0';
Rmtname[0] = '\0';
Jobid[0] = '\0';
/* set calcnum to default time in minutes */
switch(i){
case 'a':
Sysopt = 1;
break;
case 'c':
avgqueue = 1;
break;
case 'd':
Window = 1;
if (calcnum <= 0)
break;
case 'k':
Kill = 1;
break;
case 'j':
Jobcount = 1;
break;
case 'm':
break;
case 'n':
nonotf = 1;
break;
case 'p':
Psopt = 1;
break;
case 'r':
Rejuvenate = 1;
break;
case 'q':
break;
case 's':
exit(1);
}
Sysopt = 1;
break;
case 't':
Calctime = 1;
exit(1);
}
break;
case 'u':
exit(1);
}
Uopt = 1;
execute = 1;
break;
case 'x':
if (Debug <= 0)
Debug = 1;
break;
case 'S':
errortn();
exit(1);
}
State = 1;
break;
default:
errortn();
exit(1);
}
}
errortn();
exit(1);
}
/* -j only allowed with -s */
{
errortn();
exit(1);
}
/* only -u, -S and -s can be used together */
errortn();
exit(1);
}
{
errortn();
exit(1);
}
Uopt = 1;
}
errortn();
exit(1);
}
/*****************************************/
/* PROCESS THE OPTIONS */
/*****************************************/
{
complete();
}
if (Calctime) {
if (count != 0)
docalc();
}
if (Psopt) {
/* do "ps -flp" or pids in LCK files */
lckpid();
/* lckpid will not return */
}
if (Summary) {
/* Gather data for Summary option report */
continue;
m = machine(f);
continue;
continue;
*str = '\0';
}
}
if (Summary) {
/* search for LCK machines */
/* open lock directory */
/* XXX - this is disgusting... */
}
}
}
/* f will contain remote machine names */
continue;
continue;
if ( (Kill || Rejuvenate)
continue;
if (DIRECTORY(f)) {
if (chdir(f) != 0)
exit(101);
exit(101);
m = machine(f);
/* at /var/spool/uucp/remote_name */
/* gradef will contain job_grade directory names */
/* at /var/spool/uucp/remote_name/job_grade */
/* subf will contain file names */
/* files can be C. or D. or A., etc.. */
/* if file name is C. */
m->ccount++;
if (Kill || Rejuvenate)
/* go print out C. file info */
else /* get the age of the C. file */
m->c_age = i;
}
}
}
}
m->xcount++;
m->x_age = i;
}
}
}
exit(101);
} /* while more files in spooldir */
/* for Kill or Rejuvenate - will not get here unless it failed */
if (Kill) {
exit(1);
} else if (Rejuvenate) {
exit(1);
}
/* Make sure the overflow entry is null since it may be incorrect */
if (Summary) {
;
printit(m);
}
return (0);
}
/*
* uprocessC - get information about C. file
*
*/
void
{
struct stat s;
short goodRecord = 0;
int statefound = 0;
extern long fsize();
/*********************************************/
/* initialize output buffer to blanks */
/*********************************************/
return;
/* kill job - not this one */
return;
}
/* error - can't stat */
}
return;
}
}
continue;
}
goodRecord = 0;
continue;
if (first)
{
/* if the job state is requested call the
state function to determine this job's state */
if (State)
{
{
return;
}
else
{
if (statefound == 1)
else if (statefound == 2)
else if (statefound == 3)
}
}
}
else
{
}
first = 0;
if (*type == 'R')
{
}
else if (file2[0] != 'X')
{
}
}
else {
switch(buf[0]) {
case 'C':
break;
case 'U':
break;
case 'R':
break;
}
}
if (*uline_u != '\0')
if (*retaddr != '\0')
}
}
goodRecord = 1;
} /* end of while more data in buffer */
/* successful processing of a job, increment job count
counter */
if (goodRecord)
jobcount++;
return;
}
/*
* whattodo - determine what to do with current C dot file
* depending on any combination (2**3 - 1) of input
* job states
*/
static int
int inputint;
{
/* Maybe some commentary here will help explain this truth
table.
Queued |Running |Interrupted
-------------------------------------------------
X | |
-------------------------------------------------
| X |
-------------------------------------------------
| | X
-------------------------------------------------
X | X |
-------------------------------------------------
| X | X
-------------------------------------------------
X | | X
-------------------------------------------------
X | X | X
-------------------------------------------------
Now do you understand. All possible combinations have to
be evaluated to determine whether or not to print the C dot
information out or not! Well, all but 000, because if neither
of these states are input by the user we would not be
examing the C dot file anyway!
*/
return(TRUE);
return(TRUE);
return(TRUE);
return(TRUE);
return(TRUE);
else return(FALSE);
}
/*
* kprocessC - process kill or rejuvenate job
*/
static void
{
struct stat s;
short ret;
/* kill job - not this one */
return;
}
/* error - can't stat */
if(Kill) {
gettext("Can't stat:%s, errno (%d)--can't kill it!\n"),
} else {
gettext("Can't stat:%s, errno (%d)--can't rejuvenate it!\n"),
}
exit(1);
}
if(Kill) {
gettext("Can't read:%s, errno (%d)--can't kill it!\n"),
} else {
gettext("Can't read:%s, errno (%d)--can't rejuvenate it!\n"),
}
exit(1);
}
if(Kill) {
gettext("Bad format:%s, errno (%d)--can't kill it!\n"),
} else {
gettext("Bad format:%s, errno (%d)--can't rejuvenate it!\n"),
}
exit(1);
}
if (first) {
/* not allowed - not owner or root */
if(Kill)
" uucp or root - can't kill job %s\n"), Jobid);
else
" can't rejuvenate job %s\n"), Jobid);
exit(1);
}
first = 0;
}
/* remove D. file */
if (Kill)
else /* Rejuvenate */
/* program error?? */
if(Kill)
else
exit(1);
}
}
if (Kill)
else /* Rejuvenate */
if (ret != 0) {
/* program error?? */
if(Kill)
else
exit(1);
}
/* if kill done by SA then send user mail */
{
}
if (!nonotf) {
if(Kill)
else
Jobid);
}
exit(0);
}
/*
* fsize - return the size of f1 or f2 (if f1 does not exist)
* f1 is the local name
*
*/
long
{
struct stat s;
return(s.st_size);
}
return(s.st_size);
}
return(-99999);
}
void cleanup(){}
struct m *
char *name;
{
struct m *m;
/* match on overlap? */
/* use longest name */
return(m);
}
/*
* The table is set up with 2 extra entries
* When we go over by one, output error to errors log
* When more than one over, just reuse the previous entry
*/
if (m-M >= UUSTAT_TBL) {
if (m-M == UUSTAT_TBL) {
gettext("WARNING: Table Overflow--output not complete\n"));
}
else
/* use the last entry - overwrite it */
m = &M[UUSTAT_TBL];
}
m->stst[0] = '\0';
return(m);
}
void
printit(m)
struct m *m;
{
time_t t;
int minimum;
if (m->ccount == 0
&& m->xcount == 0
/*&& m->stst[0] == '\0'*/
&& m->locked == 0
&& Queue
&& m->type == 0)
return;
if (Queue) {
if (m->ccount)
else
printf(" ");
if (m->c_age)
else
printf(" ");
if (m->xcount)
else
printf(" ");
if (m->x_age)
else
printf(" ");
} else
printf(" ");
if (m->lasttime) {
printf("%2.2d/%2.2d-%2.2d:%2.2d ",
}
/* if (m->locked && m->type != SS_INPROGRESS) */
if (m->locked)
printf("Locked ");
if (m->stst[0] != '\0') {
switch (m->type) {
case SS_SEQBAD:
case SS_LOGIN_FAILED:
case SS_DIAL_FAILED:
case SS_BAD_LOG_MCH:
case SS_BADSYSTEM:
case SS_CANT_ACCESS_DEVICE:
case SS_DEVICE_FAILED:
case SS_WRONG_MCH:
case SS_RLOCKED:
case SS_RUNKNOWN:
case SS_RLOGIN:
case SS_UNKNOWN_RESPONSE:
case SS_STARTUP:
case SS_CHAT_FAILED:
(void) time(&t);
if (t > 0) {
}
if (m->count > 1)
}
}
putchar('\n');
return;
}
int
lckpid()
{
int i;
for (i=0; i<MAXLOCKS; i++)
list[i] = -1;
/* open lock directory */
/* find all lock files */
/* read LCK file */
printf("%s: ", f);
if (ret != -1) {
for(i=0; i<MAXLOCKS; i++) {
break;
if (list[i] == -1) {
break;
}
}
}
else
printf("????\n");
}
}
for (i=0; i<MAXLOCKS; i++) {
if( list[i] == -1)
break;
}
if (i > 0)
#ifdef V7
#else
#endif
exit(0);
}
/*
* get next file name from lock directory
* p -> file description of directory file to read
* filename -> address of buffer to return filename in
* must be of size NAMESIZE
* returns:
* FALSE -> end of directory read
* TRUE -> returned name
*/
static int
char *filename;
DIR *p;
{
for (;;) {
return(FALSE);
break;
}
return(TRUE);
}
int
machcmp(a,b)
char *a,*b;
{
}
/*
* _age - find the age of "file" in days
* return:
* age of file
* 0 - if stat fails
*/
int
char * file; /* the file name */
char * dir; /* system spool directory */
{
if (!ptime)
}
else
return(0);
}
/* Function: complete - find and print jobids of completed jobs for
* user.
*
* for all jobs initiated by user and print.
*
* Parameters:
*
* Username - user that initiated uustat request
*
* Returns:
*
*/
static void
complete()
{
/* Function name: complete
Author: Roland T. Conwell
Date: July 31, 1986
Naration: This function will search through
for all jobs submitted by User. If User jobs are
found the state of 'completed' will be
printed on stdout. Module called by uustat main
*/
int x;
{
return;
}
{
if (x < 6)
continue;
continue;
continue;
continue;
{
{
jobcount++;
}
}
else
{
jobcount++;
}
}
return;
}
/* Function: state - determine if Cdotfile is queued or running
*
* This function searches thru the directory jcdir for a Adotfile
* that matches the Cdotfile. If found then look for a matching
* lock file. If a Adotfile and a lock file is found then the
* job is in the running state. If no Adotfile is found then the
* job is in the queued state. If a Adotfile is found and no
* lock file is found then the job is queued.
*
* Parameters:
*
* jcdir - the job grade directory to search
* cdotfile - the Cdotfile whose state is to be determined
*
* Returns:
*
*/
static int
{
int rtnstate = 0;
foundlck = 0;
CequalA = 0;
return (0);
if (comparef[0] == 'A') {
/* now we have a C. and A. for same job */
/* check for LCK..machine.job_grade */
/* if no LCK file at this point we will */
/* print the RUNNING state */
CequalA = 1;
/* open lock directory */
{
foundlck = 1;
}
}
}
}
/* got adot, cdot and lock file */
rtnstate = 2;
rtnstate = 3;
rtnstate = 1;
return(rtnstate);
} /* end of state.c */
static int
long timerange;
{
static long size;
static float tqt;
static int jobs;
static int x;
int recordcnt;
lowerlimit[0] = '\0';
upperlimit[0] = '\0';
/* convert lowerlimit and upperlimit to HH:MM format */
{
return(0);
}
{
continue;
/* convert all '|'s to blanks for sscanf */
if (*strptr == '|')
*strptr = ' ';
&xfield);
abuf[0] = '\0';
continue;
continue;
if (x < 18)
continue;
{
totaljob++;
}
} /* while */
return(recordcnt);
} /* end of readperf */
void
docalc()
{
if (avgqueue)
queuetime();
else
xfertime();
return;
}
static int
long intime;
{
long outtime;
return(outtime);
}
static void
{
static double avgqtime;
printf("average queue time to [%s] for last [%ld] minutes: %6.2f seconds\n",Rmtname, calcnum, avgqtime);
printf("data gathered from %s:%s to %s:%s GMT\n", friendlyptr->uhour, friendlyptr->umin, friendlyptr->lhour, friendlyptr->lmin);
return;
}
static void
xfertime()
{
static double avgxrate;
printf("average transfer rate with [ %s ] for last [%ld] minutes: %6.2f bytes/sec\n", Rmtname, calcnum, avgxrate);
printf("data gathered from %s:%s to %s:%s GMT\n", friendlyptr->uhour, friendlyptr->umin, friendlyptr->lhour, friendlyptr->lmin);
return;
}
/*
* Local Function: gmts - Generate Start Time String
*
* This function returns the address to a string containing the start
* time, or upperlimit, for searching the PERFLOG.
* The start time is in GMT in the form YYMMDDhhmmss.
*
* Parameters:
*
* none
*
* Return:
*
* An address of a static character array containing the date.
*/
static char *
gmts()
{
/* inputsecs is declared global to this file */
);
return date;
}
/*
* Local Function: gmt - Generate Current Time String
*
* This function returns the address to a string containing the current
* GMT in the form YYMMDDhhmmss.
*
* Parameters:
*
* none
*
* Return:
*
* An address of a static character array containing the date.
*/
static char *
gmt()
{
);
return date;
}
static void
{
char c;
c = *(uplimit+6);
return;
}
void
char * inputargs;
{
Queued = 1;
Running = 1;
Interrupted = 1;
Complete = 1;
{
errortn();
exit(1);
}
return;
}
static void
errortn()
{
Progname);
Progname);
Progname);
return;
}