📄 uustat.c
字号:
/*--------------------------------------------------------------------*/
/* Examine all of the files in the spool directory for this host */
/*--------------------------------------------------------------------*/
while( readnext(fname , hostp->hostname, "C", NULL, <ime, &size) )
{
boolean display = equali( userid, ALL );
struct data_queue *data_link = NULL;
char user[MAXL];
char sys[MAXL];
strcpy(user,userid); // Nice default for the user
/* Generates more output if
straight copies in the queue */
strcpy(sys, E_nodename); // Nice default for node as well
printmsg(1,"ALL(%s)", fname);
exportpath(canon, fname, hostp->hostname);
/*--------------------------------------------------------------------*/
/* Determine what kind of Call file it is */
/*--------------------------------------------------------------------*/
switch(open_call(fname, hostp->hostname,
&data_link, user, sys, JOB_STATUS))
{
case POLL_CALL:
if ( display )
{
hit = TRUE;
printf( "%s %s %s\n",canon+2,dater(ltime, NULL),
"(POLL)");
}
break;
case SEND_CALL:
case RECEIVE_CALL:
if( equal(userid , ALL) || equali(userid, user))
display = TRUE;
if(display)
{
hit = TRUE;
print_all( canon + 2, data_link, user,
hostp->hostname );
}
break;
} /* switch */
} /* while */
/*--------------------------------------------------------------------*/
/* If processing all hosts, step to the next host in the queue */
/*--------------------------------------------------------------------*/
if( equal( system , ALL ))
hostp = nexthost( FALSE );
else
hostp = BADHOST;
} /* while */
if ( !hit )
printf("uustat: No jobs queued for system %s by user %s\n",
system , userid );
} /* all */
/*--------------------------------------------------------------------*/
/* p o l l */
/* */
/* Write a dummy call file to request a poll of a host */
/*--------------------------------------------------------------------*/
static void poll(const char *callee)
{
char tmfile[15]; // Call file, UNIX format name
char msname[FILENAME_MAX];
FILE *stream;
static char *spool_fmt = SPOOLFMT; // spool file name
struct HostTable *hostp;
/*--------------------------------------------------------------------*/
/* Determine first (only?) host to process */
/*--------------------------------------------------------------------*/
if ( equal(callee,ALL) )
hostp = nexthost( TRUE );
else
hostp = checkreal( callee );
/*--------------------------------------------------------------------*/
/* Scan one or all host directories */
/*--------------------------------------------------------------------*/
while (hostp != BADHOST )
{
printmsg(1,"POLL(%s)", hostp->hostname);
sprintf(tmfile,"%.8s",hostp->hostname);
if ( ValidDOSName( tmfile, FALSE ) || !equal(callee, ALL))
{
sprintf(tmfile, spool_fmt, 'C', hostp->hostname,'Z' ,
"000");
importpath( msname, tmfile, hostp->hostname);
if ( access( msname , 0 )) // Does the host file exist?
{
stream = FOPEN( msname ,"w", BINARY_MODE);
if ( stream == NULL )
{
printerr( msname );
printmsg(0,"uustat: problem creating poll file %s (%s)",
tmfile, msname);
panic();
}
fclose( stream );
printmsg(0,"Created dummy job %s (%s) for system %s",
tmfile, msname, hostp->hostname );
} /* if */
else
printmsg(0,"Dummy job %s (%s) already exists for system %s",
tmfile, msname, hostp->hostname );
} /* if ( ValidDOSName( tmfile ) || !equal(callee, ALL)) */
else {
printmsg(0,"%s is not a valid host name, skipping",
hostp->hostname);
} /* else */
/*--------------------------------------------------------------------*/
/* If processing all hosts, step to the next host in the queue */
/*--------------------------------------------------------------------*/
if( equal( callee , ALL ))
hostp = nexthost( FALSE );
else
hostp = BADHOST;
} /* while (hostp != BADHOST ) */
} /* poll */
/*--------------------------------------------------------------------*/
/* l o n g _ s t a t s */
/* */
/* Report full information on jobs for a host */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* fifi 1C 03/30-16:34 LOGIN FAILED Retry: 22:39 Count: 130 */
/* helps 2C 03/30-16:32 SUCCESSFUL */
/* im4u 5C(1) 03/30-06:50 LOGIN FAILED Retry: 11:15 Count: 9 */
/* irasun 03/30-16:23 TALKING */
/* killer 5C(6) 03/29-11:13 WRONG TIME TO CALL */
/* radian 18C 03/30-16:42 WRONG TIME TO CALL */
/* shemp 1C 03/30-14:43 LOGIN FAILED Retry: 20:48 Count: 107 */
/* unisec 2C(1) 03/30-16:50 WRONG TIME TO CALL */
/* ut-emx 1X 03/30-16:50 SUCCESSFUL */
/*--------------------------------------------------------------------*/
static void long_stats( const char *system )
{
struct HostTable *hostp;
time_t now = time( NULL );
boolean hit = FALSE;
time_t ltime;
long size;
char buf[BUFSIZ];
HostStatus(); // Load the host status table info
/*--------------------------------------------------------------------*/
/* Get the first system to process */
/*--------------------------------------------------------------------*/
if ( equal(system,ALL) )
hostp = nexthost( TRUE );
else
hostp = checkreal( system );
/*--------------------------------------------------------------------*/
/* Begin loop to display status of systems */
/*--------------------------------------------------------------------*/
while(hostp != BADHOST )
{
char fname[FILENAME_MAX];
// Get list of files in the directory
size_t jobs = 0; // Declare, reset counter
time_t oldest_file = now; // Make the "oldest" file new
/*--------------------------------------------------------------------*/
/* Inner loop to count files and determine oldest */
/*--------------------------------------------------------------------*/
while( readnext(fname, hostp->hostname, "C", NULL, <ime, &size) != NULL )
{
if ((ltime > -1) && (ltime < oldest_file ))
oldest_file = ltime;
jobs++;
} /* while */
/*--------------------------------------------------------------------*/
/* We have all the information for this system; summary and display */
/*--------------------------------------------------------------------*/
if ( jobs > 0 )
{
if (oldest_file + DAY < now) // File older than 24 hours?
sprintf( buf , "(%d)", (now - oldest_file) / DAY );
// Yes --> Format info
else
*buf = '\0'; // No --> No, empty display
printf("%-8.8s %3dC%-4s %s %s\n", hostp->hostname, jobs , buf,
dater( hostp->hstats->lconnect , NULL ),
hostp->hstatus < last_status ?
host_status[ hostp->hstatus ] :
"*** INVALID/UNDOCUMENTED STATUS ***");
hit = TRUE;
} /* if ( jobs > 0 ) */
if (equal(system, ALL))
hostp = nexthost( FALSE );
else
hostp = BADHOST;
} /* while */
if ( !hit )
printf("uustat: No jobs queued for system %s\n", system );
} /* long_stats */
/*--------------------------------------------------------------------*/
/* s h o r t _ s t a t s */
/* */
/* Report access to a system */
/*--------------------------------------------------------------------*/
static void short_stats( const char *system )
{
struct HostTable *hostp;
HostStatus(); // Load the host status table info
/*--------------------------------------------------------------------*/
/* Get the first system to process */
/*--------------------------------------------------------------------*/
if ( equal(system,ALL) )
hostp = nexthost( TRUE );
else
hostp = checkreal( system );
/*--------------------------------------------------------------------*/
/* Begin loop to display status of systems */
/*--------------------------------------------------------------------*/
while(hostp != BADHOST )
{
printf("%-8.8s %s %s\n", hostp->hostname,
dater( hostp->hstats->lconnect , NULL ),
hostp->hstatus < last_status ?
host_status[ hostp->hstatus ] :
"*** INVALID/UNDOCUMENTED STATUS ***");
if (equal(system, ALL))
hostp = nexthost( FALSE );
else
hostp = BADHOST;
} /* while */
} /* short_stats */
/*--------------------------------------------------------------------*/
/* k i l l _ j o b */
/* */
/* Kill a queued UUPC/extended job */
/*--------------------------------------------------------------------*/
static void kill_job(const char *jobid)
{
char *system; // System name returned by is_job()
char host[FILENAME_MAX];
char canon[FILENAME_MAX];
char user[FILENAME_MAX];
char sys[FILENAME_MAX];
strcpy(canon,"C.");
strcat(canon,jobid);
strcpy( user, "uucp");
system = is_job( canon ); // Never returns if an error occurs
importpath( host, canon, system );
// Get the local name of the file
open_call(host, system, NULL, user, sys, JOB_KILL);
unlink( host );
printf("Deleted file %s (%s)\n", canon, host);
printf("Killed job %s (%s) queued for host %s by %s\n",
jobid, host, system, user);
} /* kill_job */
/*--------------------------------------------------------------------*/
/* r e f r e s h _ j o b */
/* */
/* Refresh a job in the spool */
/*--------------------------------------------------------------------*/
static void refresh_job(const char *jobid)
{
char *system; // System name returned by is_job()
char host[FILENAME_MAX];
char canon[FILENAME_MAX];
char user[FILENAME_MAX];
char sys[FILENAME_MAX];
strcpy(canon,"C.");
strcat(canon,jobid);
strcpy( user, "uucp");
system = is_job( canon ); // Never returns if an error occurs
importpath( host, canon, system );
// Get the local name of the file
open_call(host, system, NULL, user, sys, JOB_REFRESH);
touch( host );
printf("Rejuvenated job %s (%s) queued for host %s by %s\n",
jobid, host, system, user);
} /* refresh_job */
/*--------------------------------------------------------------------*/
/* o p e n _ c a l l */
/* */
/* Process a call file */
/*--------------------------------------------------------------------*/
static CALLTYPE open_call( const char *callname,
const char *remote,
struct data_queue **top,
char *user,
char *sys,
const CALL_ACTION action )
{
FILE *stream;
char buf[BUFSIZ];
struct data_queue *current = NULL;
CALLTYPE this_call = POLL_CALL;
char host[FILENAME_MAX];
char type[FILENAME_MAX], fname[FILENAME_MAX], tname[FILENAME_MAX];
char flgs[FILENAME_MAX], dname[FILENAME_MAX];
/*--------------------------------------------------------------------*/
/* Open the file for processing */
/*--------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -