home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Src / LINEconsole / status.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  3.9 KB  |  152 lines

  1. /* status.c: status routines */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Src/LINEconsole/RCS/status.c,v 6.0 1991/12/18 20:26:30 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Src/LINEconsole/RCS/status.c,v 6.0 1991/12/18 20:26:30 jpo Rel $
  9.  *
  10.  * $Log: status.c,v $
  11.  * Revision 6.0  1991/12/18  20:26:30  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16. #include    "console.h"
  17.  
  18. time_t convert_time(qb)
  19. struct type_UNIV_UTCTime    *qb;
  20. {
  21.     char    *str;
  22.     time_t    temp;
  23.     if (qb == NULL)
  24.         return 0;
  25.     str = qb2str(qb);
  26.     temp = utc2time_t(str2utct(str, strlen(str)));
  27.     free(str);
  28.     return temp;
  29. }
  30.  
  31. struct procStatus    *create_status(status)
  32. struct type_Qmgr_ProcStatus    *status;
  33. {
  34.     struct procStatus    *temp;
  35.  
  36.     temp = (struct procStatus *) malloc(sizeof(*temp));
  37.  
  38.     temp->enabled = status->enabled;
  39.     temp->lastAttempt = convert_time(status->lastAttempt);
  40.     temp->cachedUntil = convert_time(status->cachedUntil);
  41.     temp->lastSuccess = convert_time(status->lastSuccess);
  42.     return temp;
  43. }
  44.  
  45. void    update_status(old, new)
  46. struct procStatus        *old;
  47. struct type_Qmgr_ProcStatus    *new;
  48. {
  49.     time_t    tmp;
  50.     old->enabled = new->enabled;
  51.  
  52.     old->lastAttempt = convert_time(new->lastAttempt);
  53.     
  54.     old->cachedUntil = convert_time(new->cachedUntil);
  55.  
  56.     if ((tmp = convert_time(new->lastSuccess)) != 0)
  57.         old->lastSuccess = tmp;
  58. }
  59.  
  60. /*   */
  61.  
  62. extern FILE    *out;
  63. extern int    connected;
  64. extern int    total_volume, total_number_messages, total_number_reports;
  65. extern char    *time_t2RFC();
  66.  
  67. time_t    boottime = 0;
  68. int    messagesIn = 0, messagesOut = 0, addrIn = 0, addrOut = 0, 
  69.     maxChans = 0, currChans = 0;
  70. double  opsPerSec = 0.0, runnableChans = 0.0, 
  71.     msgsInPerSec = 0.0, msgsOutPerSec = 0.0;
  72. int    compat = FALSE;
  73. extern int    authorised;
  74. char    *Qversion = NULLCP, *Qinformation = NULLCP;
  75. extern  char *actual_host;
  76.  
  77. print_status()
  78. {
  79.     char    buf[BUFSIZ];
  80.     openpager();
  81.     
  82.     if (connected == FALSE)
  83.         fprintf(out, "Unconnected\n");
  84.     else {
  85.         if (!compat)
  86.             my_invoke(qmgrStatus, (char **) NULL);
  87.         /* connected */
  88.         fprintf(out, "Connected to %s%s\n", (Qinformation) ? Qinformation : actual_host,
  89.             (authorised == TRUE) ? " with full access" : "");
  90.  
  91.         if (Qversion)
  92.             fprintf(out, "running %s\n",  Qversion);
  93.         if (total_volume != 0 
  94.             && (total_number_messages != 0
  95.             || total_number_reports != 0)) {
  96.             num2unit(total_volume, buf);
  97.             fprintf(out, "Total Volume = %s\n", buf);
  98.             
  99.             fprintf(out,"%d msg%s + %d report%s\n", 
  100.                 total_number_messages,
  101.                 (total_number_messages == 1) ? "" : "s",
  102.                 total_number_reports,
  103.                 (total_number_reports == 1) ? "" : "s");
  104.         }
  105.         if (!compat) {
  106. #define    NUMBUF    15
  107.             char    adIn[NUMBUF], mgIn[NUMBUF], adOut[NUMBUF], mgOut[NUMBUF], *str;
  108.             str = time_t2RFC(boottime);
  109.             num2unit(addrIn, adIn);
  110.             num2unit(messagesIn, mgIn);
  111.             num2unit(addrOut, adOut);
  112.             num2unit(messagesOut, mgOut);
  113.             fprintf(out, "running since %s\nInbound %s Message%s to %s Recipient%s\nOutbound %s Message%s to %s Recipient%s\n",
  114.                        str, mgIn, (messagesIn != 1) ? "s" : "",
  115.                        adIn, (addrIn != 1) ? "s" : "",
  116.                        mgOut, (messagesOut != 1) ? "s" : "",
  117.                        adOut, (addrOut != 1) ? "s" : "");
  118.             free(str);
  119.         } else 
  120.             fprintf(out, "Running in 5.0 compatability mode\n");
  121.     }
  122.     closepager();
  123. }
  124.  
  125. /* ARGSUSED */
  126. int qmgrStatus_result (ad, id, dummy, result, roi)
  127. int    ad,
  128.     id,
  129.     dummy;
  130. struct type_Qmgr_QmgrStatus    *result;
  131. struct RoSAPindication    *roi;
  132. {
  133.     if (result) {
  134.         if (result->boottime) 
  135.             boottime = convert_time(result->boottime);
  136.         messagesIn = result->messagesIn;
  137.         messagesOut = result->messagesOut;
  138.         addrIn = result->addrIn;
  139.         addrOut = result->addrOut;
  140.         opsPerSec = (double) result->opsPerSec;
  141.         runnableChans = (double) result->runnableChans;
  142.         msgsInPerSec = (double) result->msgsInPerSec;
  143.         msgsOutPerSec = (double) result->msgsOutPerSec;
  144.         maxChans = result->maxChans;
  145.         currChans = result->currChans;
  146.         total_volume = result->totalVolume;
  147.         total_number_messages = result->totalMsgs;
  148.         total_number_reports = result->totalDrs;
  149.     }
  150.     return OK;
  151. }
  152.