home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------*/
- /* u u s t a t . c */
- /* */
- /* Report summary of UUPC activity */
- /* */
- /* Copyright (C) 1991, Andrew H. Derbyshire */
- /*--------------------------------------------------------------------*/
-
- #include <assert.h>
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
-
- #include "lib.h"
- #include "hostable.h"
- #include "dater.h"
- #include "hostatus.h"
- #include "security.h"
- #include "timestmp.h"
-
- /*--------------------------------------------------------------------*/
- /* Local macros */
- /*--------------------------------------------------------------------*/
-
- #define line( a, b, c, d, e, f, g, h, i, j ) \
- printf("%-8.8s %-6.6s %-11.11s %-11.11s %5.5s %5.5s %5.5s %5.5s %5.5s %5.5s\n" ,\
- a, b, c, d, e, f, g, h, i ,j )
-
- /*--------------------------------------------------------------------*/
- /* Internal prototypes */
- /*--------------------------------------------------------------------*/
-
- static void showhost( struct HostTable *host);
- static char *when( time_t t );
- static char *status( hostatus current_status );
- static char *format( long l);
-
- /*--------------------------------------------------------------------*/
- /* Global variables */
- /*--------------------------------------------------------------------*/
-
- static char output[10 * 12];
- static size_t column ;
-
- currentfile();
-
- /*--------------------------------------------------------------------*/
- /* main program */
- /*--------------------------------------------------------------------*/
-
- #ifdef __TURBOC__
- #pragma argsused
- #endif
-
- void main( int argc , char **argv)
- {
-
- struct HostTable *host;
- boolean firsthost = TRUE;
- static const char *dashes = "-----------";
-
- /*--------------------------------------------------------------------*/
- /* Announce ourselves to a waiting world */
- /*--------------------------------------------------------------------*/
-
- debuglevel = 0;
-
- #if defined(__CORE__)
- copywrong = strdup(copyright);
- checkref(copywrong);
- #endif
- banner( argv );
-
- /*--------------------------------------------------------------------*/
- /* Load system configuration and then the UUPC host stats */
- /*--------------------------------------------------------------------*/
-
- assert (configure( B_UUCP ));
- HostStatus();
-
- printf("Host information collected since %s\n",ctime( &start_stats ));
-
- line("Host","Host ", "Date Last", "Last Conn","Secs" , "Bytes", "Bytes",
- "Files", "Files", "Total");
- line("Name","Status ","Connected ","Attempt", "Conn", "Sent", "Recvd",
- "Sent", "Recvd", "Errs");
- line(dashes,dashes,dashes,dashes,dashes,dashes,dashes,dashes,
- dashes,dashes);
-
- while ((host = nexthost( firsthost , aliasof )) != BADHOST)
- {
- firsthost = FALSE;
- showhost ( host );
- } /* while */
-
- } /* main */
-
- /*--------------------------------------------------------------------*/
- /* s h o w h o s t */
- /* */
- /* Display information on a single host */
- /*--------------------------------------------------------------------*/
-
- static void showhost( struct HostTable *host)
- {
- column = 0;
- checkref( host->hstats );
- line( host->hostname,
- status( host->hstatus ),
- when( host->hstats->lconnect ),
- when( host->hstats->ltime ),
- format( host->hstats->connect ),
- format( host->hstats->bsent ),
- format( host->hstats->breceived ),
- format( host->hstats->fsent ),
- format( host->hstats->freceived ),
- format( host->hstats->errors ));
- }
-
- /*--------------------------------------------------------------------*/
- /* Subroutines */
- /*--------------------------------------------------------------------*/
-
- static char *when( time_t t )
- {
- column += 13;
- return dater( t, &output[column]);
- }
-
- static char *format( long l)
- {
- if (l == 0)
- return "";
-
- column += 12;
- if ( l <= 99999)
- sprintf( &output[ column ], "%ld", l);
- else if ( (l/1000) <= 9999)
- sprintf( &output[ column ], "%ldK", l / 1000);
- else
- sprintf( &output[ column ], "%ldM", l / 1000000);
- return &output[column];
- }
-
- static char *status( hostatus current_status )
- {
- switch ( current_status )
- {
- default:
- return "??????";
-
- case phantom: /* Entry not fully initialized */
- return "noinit";
-
- case localhost: /* This entry is for ourselves */
- return "local";
-
- case routed: /* This entry is actually a path */
- return "routed";
-
- case gatewayed: /* This entry is delivered to via */
- /* an external program on local sys */
- return "gatway";
-
- case aliasof: /* This entry is alias of VIA system*/
- return "alias";
-
- case nocall: /* real host: never called */
- return "NEVER";
-
- case inprogress: /* Call now active */
- return "INPROG";
-
- case callback_req: /* System must call us back */
- return "CALLBK";
-
- case dial_failed: /* Hardcoded auto-dial failed */
- return "NODIAL";
-
- case script_failed: /* script in L.SYS failed */
- return "NSCRPT";
-
- case max_retry: /* Have given up calling this sys */
- return "MAXTRY";
-
- case too_soon: /* In retry mode: too soon to call */
- return "TOSOON";
-
- case succeeded: /* self-explanatory */
- return "SUCESS";
-
- case wrong_host: /* Call out failed: wrong system */
- return "WRGHST";
-
- case unknown_host: /* Call in cailed: unknown system */
- return "UNKNWN";
-
- case wrong_time: /* Unable to call because of time */
- return "WRGTIM";
- }
- }
-