⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uustat.c

📁 大量的汇编程序源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*--------------------------------------------------------------------*/
/*    u u s t a t . c                                                 */
/*                                                                    */
/*    Job status report for UUPC/extended                             */
/*                                                                    */
/*                                                                    */
/*    Copyright 1988 (C), Dewey Coffman                               */
/*    Changes Copyright 1991 (C), Andrew H. Derbyshire                */
/*--------------------------------------------------------------------*/

/*--------------------------------------------------------------------*/
/*         System include files                                       */
/*--------------------------------------------------------------------*/

#include <stdio.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <stdlib.h>

/*--------------------------------------------------------------------*/
/*         Local include files                                        */
/*--------------------------------------------------------------------*/

#include "lib.h"
#include "dater.h"
#include "export.h"
#include "getopt.h"
#include "getseq.h"
#include "hlib.h"
#include "hostable.h"
#include "hostatus.h"
#include "import.h"
#include "pushpop.h"
#include "readnext.h"
#include "security.h"
#include "stater.h"
#include "timestmp.h"

#define DAY (60l * 60l * 24l)
#define ALL    "all"
#define MAXL      128      // MAX LINE LENGTH

#define STRCREAT(s, s2, s3)\
   strcpy(s, s2);\
   strcat(s, s3);\

/*--------------------------------------------------------------------*/
/*                          Local data types                          */
/*--------------------------------------------------------------------*/

typedef enum {
      POLL_CALL = 'P',
      RECEIVE_CALL = 'R',
      SEND_CALL = 'S'
      } CALLTYPE;


struct data_queue {
   char name[FILENAME_MAX];
   struct data_queue *next_link;
   time_t created;
   long size;
   boolean execute;
   char type;
} ;

/*--------------------------------------------------------------------*/
/*                             Verb list                              */
/*--------------------------------------------------------------------*/

typedef enum {
   LIST_DEFAULT = 1,
   LIST_ALL,
   LIST_ACCESS,
   LIST_QUEUE,
   KILL_JOB,
   REFRESH_JOB,
   FORCE_POLL
   } COMMAND_CLASS;

/*--------------------------------------------------------------------*/
/*                Processing to be taken by open_call                 */
/*--------------------------------------------------------------------*/

typedef enum {
   JOB_STATUS = 1,
   JOB_KILL,
   JOB_REFRESH
   } CALL_ACTION;

/*--------------------------------------------------------------------*/
/*                          Global variables                          */
/*--------------------------------------------------------------------*/

currentfile();

static const char *host_status[] = {
      "(invalid - entry not properly initialized)",
      "(local host system)",
      "(host for gateway purposes only)",
      "Never called",
      "Dialing now",
      "Invalid device or speed in SYSTEMS file",
      "Device not available",
      "Conversation start-up failed",
      "Talking",
      "Callback required",
      "Modem initialization script failed",
      "Dial failed",
      "Script failed",
      "Max retry reached",
      "Retry time not reached",
      "Call succeeded",
      "Wrong machine name",
      "Unknown host",
      "Failed",
      "Wrong time to call",
      "(call successed, entry not reset)",
   } ;

/*--------------------------------------------------------------------*/
/*                        Internal prototypes                         */
/*--------------------------------------------------------------------*/

static void all( const char *system, const char *userid );

static char *is_job(const char *jobid );

static void kill_job(const char *s);

static void long_stats( const char *system );

static void short_stats( const char *system );

static CALLTYPE open_call( const char *callname,
                           const char *remote,
                                 struct data_queue **current,
                                 char *user,
                                 char *sys,
                           const CALL_ACTION action);

static void open_data(const char *file,
                            char *user,
                            char *sys,
                            char *command);

static void poll(const char *callee);

static void print_all(       char *job,
                       struct data_queue *current,
                       const char *user,
                       const char *sys);

static void refresh_job(const char *s);

static void touch( const char *fname );

static void usage( void );

/*--------------------------------------------------------------------*/
/*    m a i n                                                         */
/*                                                                    */
/*    main program                                                    */
/*--------------------------------------------------------------------*/

void main(int  argc, char  **argv)
{
   int c;
   extern char *optarg;
   extern int   optind;
   COMMAND_CLASS command = LIST_DEFAULT;

   char *system = NULL;
   char *userid = NULL;
   char *job    = NULL;

/*--------------------------------------------------------------------*/
/*     Report our version number and date/time compiled               */
/*--------------------------------------------------------------------*/

   debuglevel = 0;
   banner( argv );

#if defined(__CORE__)
   copywrong = strdup(copyright);
   checkref(copywrong);
#endif

   if (!configure( B_UUSTAT ))
      exit(1);   /* system configuration failed */

/*--------------------------------------------------------------------*/
/*                   Switch to the spool directory                    */
/*--------------------------------------------------------------------*/

   tzset();                      // Set up time zone information
   PushDir( E_spooldir );
   atexit( PopDir );

/*--------------------------------------------------------------------*/
/*        Process our arguments                                       */
/*--------------------------------------------------------------------*/

   while ((c = getopt(argc, argv, "amqk:r:s:u:x:P:")) !=  EOF)
      switch(c) {
      case 'a':
         command = LIST_ALL;
         break;

      case 'm':
         command = LIST_ACCESS;
         system = optarg;
         break;

      case 'q':
         command = LIST_QUEUE;
         break;

      case 'k':
         command = KILL_JOB;
         job = optarg;
         break;

      case 'r':
         command = REFRESH_JOB;
         job = optarg;
         break;

      case 's':
         if ( system != NULL )
         {
            printmsg(0,"Invalid or duplicate option -s %s",optarg);
            usage();
         }
         system = optarg;
         break;

      case 'u':
         userid = optarg;
         break;

      case 'x':
         debuglevel = atoi( optarg );
         break;

      case 'P':
         command = FORCE_POLL;
         if ( system != NULL )
         {
            printmsg(0,"Invalid or duplicate option -P %s",optarg);
            usage();
         }
         system = optarg;
         break;

      case '?':
         usage();
   }

   if (optind != argc) {
      puts("Extra parameter(s) at end.");
      exit(2);
   }

/*--------------------------------------------------------------------*/
/*                 Determine if we have a valid host                  */
/*--------------------------------------------------------------------*/

   if( (system != NULL) && !equal( system , ALL ) )
   {
      struct HostTable *hostp = checkreal( system );

      if (hostp  ==  BADHOST)
      {
         printf("Unknown host \"%s\", program terminating.\n",
               system );
         panic();
      }
   } /* if */

/*--------------------------------------------------------------------*/
/*                   Execute the requested command                    */
/*--------------------------------------------------------------------*/

   switch ( command )
   {
      case LIST_DEFAULT:
         if ( (system == NULL ) && ( userid == NULL) )
         {
            all( ALL, E_mailbox );
            break;
         }
            /* Otherwise, fall through ... */

      case LIST_ALL:
         if ( system == NULL )
            system = ALL;
         if ( userid == NULL )
            userid = ALL;
         all( system, userid );
         break;

      case LIST_ACCESS:
         if ( system == NULL )
            system = ALL;
         short_stats( system );
         break;

      case LIST_QUEUE:
         if ( system == NULL )
            system = ALL;
         long_stats( system );
         break;

      case KILL_JOB:
         kill_job( job );
         break;

      case REFRESH_JOB:
         refresh_job( job );
         break;

      case FORCE_POLL:
         poll( system );
         break;

      default:
         panic();

   } /* switch */
   exit(0);

} /* main */

/*--------------------------------------------------------------------*/
/*    a l l                                                           */
/*                                                                    */
/*    Report on all systems                                           */
/*--------------------------------------------------------------------*/

void all( const char *system, const char *userid)
{
   char  canon[FILENAME_MAX];
   long  size, ltime;
   struct HostTable *hostp;
   boolean hit = FALSE;

   if ( equal(system,ALL) )
      hostp = nexthost( TRUE );
   else
      hostp = checkreal( system );

/*--------------------------------------------------------------------*/
/*                  Scan one or all host directories                  */
/*--------------------------------------------------------------------*/

   while  (hostp !=  BADHOST )
   {
      char fname[FILENAME_MAX];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -