From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 12-JAN-1990 19:05
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Re: purge dua0:[...]*.* summary. SOLUTION!

Received: From REMOTE.DCCS.UPENN.EDU by CRVAX.SRI.COM with TCP; Tue,  9 JAN 90 13:33:02 PDT
Received: from A.CHEM.UPENN.EDU by remote.dccs.upenn.edu
	id AA24197; Tue, 9 Jan 90 16:30:42 -0500
Message-Id: <9001092130.AA24197@remote.dccs.upenn.edu>
Date: Tue, 9 Jan 90 16:30 EST
From: "YATES, JOHN H." <YATES@a.chem.upenn.edu>
Subject: Re: purge dua0:[...]*.* summary. SOLUTION!
To: info-vax@crvax.sri.com
X-Vms-To: INFOVX

Lots of requests so here it is. John
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.1-004  3-AUG-1989
$!   On  9-JAN-1990 10:27:25.25   By user YATES 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. AAAREADME.1ST;1
$!       2. NOPE.C;1
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ if f$getsyi("version") .ges. "V4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete/nolog 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);x:=
ERASE_CHARACTER(1);IF g = 0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x=
"V" THEN APPEND_LINE;MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;
IF x="+" THEN g:=1;ERASE_LINE;ENDIF;ELSE IF x="-" THEN g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
X`009`009`009`009  NOPE
X
X
X`009Nope was born out of the need for a way to see what files would be
Xpurged if a purge were done, and also show how many blocks would be made
Xavailable.  Nope should be set up as a symbol thusly;
X
X`009`009NOPE :==$SYS$MANAGER:NOPE
X
X`009Note that Nope may reside in any directory and requires no
Xprivileges as long as the files to be referenced are not read protected
Xfrom the user.
X
X`009Nope works with the same file specification syntax as purge;
X
X`009`009NOPE`009`009`009Look at current directory
X`009`009NOPE `091...`093`009`009Look at current directory tree
X`009`009NOPE `091*...`093*.OBJ`009Look at all .obj on this disk
X
X`009Nope lists directories as it checks them, but if you specify any part
Xof the filename or extension (*.obj, check.*) it only lists those directorie
Vs
Xthat contained files fitting that specification.  Nope also gives a grand
Xtotal at the end, including the number of files that would be purged and
Xthe number of allocated blocks that would be freed.
X
X`009Nope has come in very handy in determining whether we should
Xschedule a global purge on our user disks.  Also, about the time you decide
Xto blindly purge a directory, you may find yourself in the wrong directory.
V  The
Xreason for the name Nope is that it is a subset of the words NOPurgE and als
Vo
XI wanted to make it very different from PURGE (somebody suggested NOPURGE, b
Vut
Xsometimes my fingers think faster than my brain!).
X
X`009I hope that DEC will see this, and will somehow incorporate a similar
Xfunction into DCL.
$ CALL UNPACK AAAREADME.1ST;1 1780032666
$ create/nolog 'f'
X/***************************************************************************
V****
X*`009NOPE - Nopurge utility.  NOPE was born out of the need for a way to
X* determine which files would be purged if a purge were done.  The user shou
Vld
X* define a symbol "NOPE :==$SYS$PRIV:NOPE" which will allow the user to use
V the
X* NOPE utility thusly;
X*`009`009`009NOPE`009`009(same as NOPE *.*;*)
X*`009`009`009NOPE `091...`093`009(same as NOPE `091...`093*.*;*)
X*`009`009`009NOPE *.C`009(examine only files with extension '.C')
X*`009`009`009NOPE DEV:`091*...`093`009(examine entire disk
X*
X*`009Each directory that has files matching the filespec are displayed, but
X* only those files which would be purged are displayed.  The allocated block
X* count is displayed for each file, and a total line is displayed at the end
V.
X*
X*`009This program is an example of the use of the RMS routines $PARSE,
X* $SEARCH, $OPEN and $CLOSE.  First, $PARSE 'sets up' for the search.  Then
V the
X* $SEARCH is performed in a loop.  Also within the loop, $OPEN and $CLOSE ar
Ve
X* invoked to determine file allocation only if necessary.
X****************************************************************************
V***/
X#include <descrip.h>
X#include <file.h>
X#include <rms.h>
X#include <iodef.h>
X#include <ssdef.h>
X
Xmain(argc,argv)
Xint argc;
Xchar *argv`091`093;
X`123
X`009struct FAB wild_fab;`009`009/* Used in wildcard search */
X`009struct NAM wild_nam;`009`009/* Used in conjunction with wild_fab */
X`009struct FAB size_fab;`009`009/* Used in retreiving file allocation */
X
X`009char template`091`093 = "*.*;*";`009/* Default template */
X`009char fullname`091256`093;`009`009/* Input file spec given by user */
X`009char expanded`091256`093;`009`009/* File spec after logical expansion */
X`009char result`091256`093;`009`009/* Result from search */
X`009char last_name`091256`093;`009`009/* Last search result */
X`009char last_dir`091256`093;
X`009char *pointer1;
X`009int tot_blocks, tot_files, this_dirlen, last_dirlen, compare_namlen;
X`009int last_namlen, this_namlen, compare_dirlen, counter;
X`009register status;
X
X/* Initialize the wildcard FAB & NAM */
X`009wild_fab = cc$rms_fab;
X`009wild_nam = cc$rms_nam;
X
X`009wild_fab.fab$l_fna = fullname;
X`009wild_fab.fab$b_fac = FAB$M_GET;
X`009wild_fab.fab$l_fop = FAB$V_NAM;
X`009wild_fab.fab$l_nam = &wild_nam;
X`009wild_fab.fab$l_dna = template;
X`009wild_fab.fab$b_dns = strlen(template);
X
X`009wild_nam.nam$l_esa = expanded;
X`009wild_nam.nam$b_ess = 255;
X`009wild_nam.nam$l_rsa = result;
X`009wild_nam.nam$b_rss = 255;
X
X/* Initialize the size FAB & NAM */
X`009size_fab = cc$rms_fab;
X
X`009size_fab.fab$l_fna = result;
X`009size_fab.fab$b_fac = FAB$M_GET;
X`009size_fab.fab$b_shr = FAB$M_SHRGET;
X
X/* First parse the file spec given to us */
X`009argv++;
X`009if (argc == 1)
X`009`009strcpy(fullname,template);
X`009    else
X`009`009sscanf(*argv,"%s",&fullname);
X`009wild_fab.fab$b_fns = strlen(fullname);
X`009if (((status = SYS$PARSE(&wild_fab)) &1) != 1)
X`009`009`123
X`009`009printf("Error %d on parse\n",status);
X`009`009exit(status);
X`009`009`125
X
X/* Main loop */
X`009for(tot_blocks = tot_files = last_namlen = last_dirlen = 0;;)
X`009`009`123
X`009`009if (((status = SYS$SEARCH(&wild_fab)) &1) != 1)
X`009`009`009`123
X`009`009`009if (status == RMS$_NMF)
X`009`009`009`009break;
X`009`009`009    else
X`009`009`009`009`123
X`009`009`009`009printf("Error %d on search\n",status);
X`009`009`009`009exit(status);
X`009`009`009`009`125
X`009`009`009`125
X
X`009`009expanded`091wild_nam.nam$b_esl`093 = 0;
X`009`009result`091wild_nam.nam$b_rsl`093 = 0;
X
X`009`009/* Establish some pointers and counters for comparison */
X`009`009for (counter=0;result`091counter`093 != 0;counter++)
X`009`009`009`123
X`009`009`009if (result`091counter`093 == '`093')
X`009`009`009`009this_dirlen = counter + 1;
X`009`009`009if (result`091counter`093 == '\;')
X`009`009`009`009`123
X`009`009`009`009this_namlen = counter - this_dirlen;
X`009`009`009`009break;
X`009`009`009`009`125
X`009`009`009`125
X`009`009pointer1 = &result`091this_dirlen`093;
X
X`009`009/* Compare directories, print if new directory */
X`009`009if (this_dirlen > last_dirlen)
X`009`009`009compare_dirlen = this_dirlen;
X`009`009    else
X`009`009`009compare_dirlen = last_dirlen;
X`009`009if (strncmp(last_dir,result,compare_dirlen) != 0)
X`009`009`009`123
X`009`009`009last_namlen = this_namlen;
X`009`009`009strncpy(last_name,pointer1,this_namlen);
X`009`009`009last_name`091this_namlen`093 = '\0';
X`009`009`009last_dirlen = this_dirlen;
X`009`009`009strncpy(last_dir,result,this_dirlen);
X`009`009`009last_dir`091this_dirlen`093 = '\0';
X`009`009`009printf("`009%s\n",last_dir);
X`009`009`009continue;
X`009`009`009`125
X`009`009`009
X`009`009/* Compare filename, print if this file would be purged */
X`009`009if (this_namlen > last_namlen)
X`009`009`009compare_namlen = this_namlen;
X`009`009    else
X`009`009`009compare_namlen = last_namlen;
X`009`009if (strncmp(last_name,pointer1,compare_namlen) == 0)
X`009`009`009`123
X`009`009`009size_fab.fab$b_fns = strlen(result);
X`009`009`009if (((status = SYS$OPEN(&size_fab)) &1) != 1)
X`009`009`009`009`123
X`009`009`009`009if (status == RMS$_FLK)
X`009`009`009`009`009`123
X`009`009`009`009`009printf("%-30s<file locked>\n",
X`009`009`009`009`009`009(strchr(result,'`093') + 1));
X`009`009`009`009`009tot_files++;
X`009`009`009`009`009continue;
X`009`009`009`009`009`125
X`009`009`009`009printf("Error %d on open\n",status);
X`009`009`009`009exit(status);
X`009`009`009`009`125
X
X`009`009`009if (((status = SYS$CLOSE(&size_fab)) &1) != 1)
X`009`009`009`009`123
X`009`009`009`009printf("Error %d on close\n",status);
X`009`009`009`009exit(status);
X`009`009`009`009`125
X
X`009`009`009printf("%-30s`009%d\n",(strchr(result,'`093') + 1),
X`009`009`009`009size_fab.fab$l_alq);
X`009`009`009tot_files++;
X`009`009`009tot_blocks += size_fab.fab$l_alq;
X`009`009`009`125
X`009`009   else
X`009`009`009`123
X`009`009`009last_namlen = this_namlen;
X`009`009`009strncpy(last_name,pointer1,this_namlen);
X`009`009`009last_name`091this_namlen`093 = '\0';
X`009`009`009`125
X`009`009`125
X
X`009printf("\n`009%d total blocks in %d files\n",
X`009`009tot_blocks,tot_files);
X`009exit(SS$_NORMAL);
X`125
$ CALL UNPACK NOPE.C;1 369392140
$ v=f$verify(v)
$ EXIT

