home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / flshow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-25  |  4.0 KB  |  173 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: flshow.c,v 1.11 1995/10/25 15:51:02 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    flshow.c ("show" commands for FLIST)
  7.  * Author:    T.E.Dickey
  8.  * Created:    04 May 1985 (from main program)
  9.  * Last update:
  10.  *        25 Oct 1995, long/unsigned/DATENT fixes
  11.  *        18 Mar 1995, prototypes
  12.  *        04 Nov 1988, added expired date
  13.  *        12 Nov 1985, added "?OWNER"
  14.  *        05 Oct 1985, added key-argument to 'flist_help'.  Use it here.
  15.  *        24 Sep 1985, don't need to uppercase 'xdcl_' stuff.
  16.  *        13 Aug 1985, broke out "?FIND" to 'flfind_show'
  17.  *        25 Jul 1985, added "?READ" command
  18.  *        04 Jul 1985, cleanup 'filelist' definition.
  19.  *        10 Jun 1985, added "?FIND" command
  20.  *        14 May 1985, forgot to remove trace
  21.  *        04 May 1985
  22.  */
  23.  
  24. #include    <ctype.h>
  25. #include    <string.h>
  26. #include    <unixlib.h>    /* for 'getuid()' */
  27.  
  28. #include    <starlet.h>
  29. #include    <lib$routines.h>
  30. #include    <descrip.h>
  31. #include    <stsdef.h>
  32.  
  33. #include    "flist.h"
  34.  
  35. #include    "dirent.h"
  36. #include    "dircmd.h"
  37. #include    "dds.h"
  38.  
  39. #include    "sysutils.h"
  40.  
  41. extern    int    more(int argc, char **argv);
  42. extern    char    *dired_release(void);
  43. extern    void    shoquota(char *);
  44.  
  45. import(filelist);    import(numfiles);
  46.  
  47. import(AnyXAB);        import(A_opt);        import(D_opt);
  48. import(M_opt);        import(P_opt);        import(V_opt);
  49. import(dateflag);    import(datechek);
  50. import(readlist);    import(readllen);
  51.  
  52. static    void    flshow_lis (int curfile);
  53.  
  54. tDIRCMD(flshow)
  55. {
  56. #define    len_date    21
  57.     DATENT    date;
  58.     int    j;
  59.     unsigned total, total2;    /* misc variables used in commands */
  60.     char    bfr[CRT_COLS+MAX_PATH];
  61.  
  62.     switch (xdcl_->dcl_text[0])
  63.     {
  64.     case 'C':        /* Display screen format    */
  65.         flcols_show ();
  66.         break;
  67.  
  68.     case 'D':        /* Display current date, time    */
  69.         sys$gettim (&date);
  70.         sysasctim (bfr, &date, len_date);
  71.         flist_tell ("Current date: %s", bfr);
  72.         break;
  73.  
  74.     case 'F':
  75.         flfind_show ();
  76.         break;
  77.  
  78.     case 'L':        /* Display current level number    */
  79.         flist_tell ("Current level: %d", flist_nest());
  80.         break;
  81.  
  82.     case 'M':        /* Display dynamic memory usage    */
  83.         lib$show_vm (0, &flist_tell_dsc);
  84.         break;
  85.  
  86.     case 'O':        /* Display owner/uid of current process */
  87.         flist_tell ("Your uid is [%03o,%03o]", getgid(), getuid());
  88.         break;
  89.  
  90.     case 'Q':        /* Display current disk quota, etc.*/
  91.         shoquota (bfr);
  92.         flist_tell ("%s", bfr);
  93.         break;
  94.  
  95.     case 'R':        /* Display read-list and pertinent options */
  96.         flist_lis ("Options in effect:");
  97.         if (dateflag[0])
  98.         {
  99.             sysasctim (bfr, &datechek, 18);
  100.             flist_lis ("    /%s=%s",
  101.                 dateflag[0] > 0 ? "AFTER" : "BEFORE", bfr);
  102.             switch (dateflag[1])
  103.             {
  104.             case 4:    flist_lis ("    /EXPIRED");    break;
  105.             case 3:    flist_lis ("    /MODIFIED");    break;
  106.             case 2:    flist_lis ("    /BACKUP");    break;
  107.             default:flist_lis ("    /CREATED");
  108.             }
  109.         }
  110.         if (P_opt)    flist_lis ("    /ALL");
  111.         if (D_opt)    flist_lis ("    /DATE");
  112.         if (!AnyXAB)    flist_lis ("    /FAST");
  113.         if (M_opt)    flist_lis ("    /PROTECTION");
  114.         if (A_opt)    flist_lis ("    /SIZE");
  115.         flist_lis ("    /%sVERSIONS", V_opt ? "" : "NO");
  116.         flist_lis ("\nRead-List:");
  117.         for (j = 0; j < readllen; j++)
  118.         {
  119.             dirent_glue (bfr, &readlist[j]);
  120.             flist_lis ("    %s", bfr);
  121.         }
  122.         flshow_lis (*curfile_);
  123.         break;
  124.  
  125.     case 'S':        /* Display total number of blocks */
  126.         for (j = 0, total = total2 = 0; j < numfiles; j++)
  127.             if (!DELETED(j))
  128.             {
  129.                 total += FK(j).fsize;
  130.                 total2 += FK(j).fallc;
  131.             }
  132.         flist_tell ("Total blocks: %d (%d allocated)",
  133.             total, total2);
  134.         break;
  135.  
  136.     case 'V':        /* Display current version    */
  137.         flist_tell ("%s", dired_release());
  138.         break;
  139.  
  140.     case 'T':        /* Display cpu time, etc.    */
  141.         sysfom (bfr);
  142.         flist_tell ("%s", bfr);
  143.         if (!strchr(xcmd_, '?'))    /* "/TIMER"    */
  144.             sysfom (nullC);        /* Reset timer    */
  145.         break;
  146.     default:
  147.         for (*bfr = EOS, xdcl_ = xdcl_->dcl_next;
  148.             xdcl_;
  149.                 xdcl_ = xdcl_->dcl_next)
  150.         {
  151.             strcat (bfr, xdcl_->dcl_text);
  152.             strcat (bfr, " ");
  153.         }
  154.         flist_help (*curfile_, bfr);
  155.     }
  156. }
  157.  
  158. /* <flshow_lis>:
  159.  * Close and browse the listing file.
  160.  */
  161. static
  162. void    flshow_lis (int curfile)
  163. {
  164.     char    *argv[3];
  165.  
  166.     argv[0]    =
  167.     argv[1]    = "BROWSE";
  168.     argv[2]    = flist_lis(0);
  169.  
  170.     more (3, argv);
  171.     if (!didwarn())    dds_all (-1, curfile);
  172. }
  173.