[comp.os.vms] VERB - decompile DCL tables part 1/4

hydrovax@nmtsun.nmt.edu (M. Warner Losh) (02/02/88)

...................... Cut between dotted lines and save ......................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.03 07-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by WARNER
$! on Monday 1-FEB-1988 10:23:01.67
$!
$! ATTENTION: To keep each article below 15872 bytes, this program
$! has been transmitted in 4 parts.
$! You should concatenate ALL parts to ONE file and execute (@) that file.
$!
$! It contains the following 19 files:
$! BLURB.TXT BUFFER.MAR CLEXLIB.MAR CLITABLE.TXT COMMAND.MAR COMPILE.COM
$! DISALLOWS.MAR ENTITY.MAR EVALENTITY.MAR FIND.MAR FINDENTITY.MAR GET_TERM.MAR
$! INIT.MAR LIST.MAR README_FIRST.TXT TYPE.MAR VERB.CLD VERB.COMPILE VERB.FOR
$!=============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="BLURB.TXT"
$ Check_Sum_is=6433702
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009VERB is a program to extract verb definitions from either
Xyour process space or a command table file (such as SYS$SHARE:DCLTABLES.EXE).
XThese verb definitions can then be changed and recompiled via the command
Xdefinition utility, SET COMMAND. This program is similar to the 3.n program
XCLEX, except that it works with version 4.n command tables. This program
Xis a must if you need to change verb definitions, or if you just hate the
XDEC defaults (getting tired of HELP/PAGE, or LINK creating maps when
Xexecuted from a batch job?).
X
X`009VERB allows you to do wildcard searches for verbs (commands)
Xand lists of verbs, such as VERB A*,B*,%%% (which would return all the verb
Xdefinitions for commands that start with A, B, and all three letter commands).
X
X`009You can specify a table to search for the verb, or even to search your 
Vprocess space. The command defaults to searching your process space, but if yo
Xu
Xenter VERB/TABLE it will default to using the system command table
XSYS$SHARE:DCLTABLES, you can of course specify a table other than that, as in
XVERB/TABLE=MY_OWN_TABLE, note that it uses SYS$SHARE:DCLTABLES.EXE as the
Xdefault file name in an RMS $OPEN call.
X
X`009VERB allows you to put the output in a file, as in
XVERB/OUTPUT=filename, VERB also can list available verbs (commands), w/o
Xthe verb definition, as in VERB/LIST/ALL, and note the /ALL qualifier.
X
X
Xrestrictions:
X`009Well, it hasn't been tested with MCR tables.I wouldn't be surprised if
Xit didn't like them.
X`009When extracting several verbs at a time the verbs may reference common
VTYPE defnitions, in these cases only one is output, this only becomes a proble
Xm
Xif you cut up the output file into several smaller files.
X`009When extracting several verbs (such as BASIC,MACRO,FORTRAN) they
Xmay each reference a TYPE defnition that is different for each verb, but has
Xthe same name. Since the TYPE definitions are actually different each one will
Xbe included in the file, but the CDU will not appreciate having similarly
Xnamed TYPE definitions. In such cases simply extact the verbs into seperate
Xfiles.
$ GoSub Convert_File
$ File_is="BUFFER.MAR"
$ Check_Sum_is=1615859512
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009.title`009buffer routines
X
X; VERB Version 1.0 June 1st, 1985
X; Written  by Joe Meadows Jr.,  with thanks  to the
X; Fred Hutchinson Cancer Research Center for kindly
X; allowing  me to  use  their  computing  resources.
X;
X; If  you  have any  questions, comments, ideas, or
X; whatever, feel free to contact me via US Mail :
X;`009Joe Meadows Jr.
X;`0094841 268th Ave. N.E.
X;`009Redmond Wa. 98052
X; or via phone : (206) 827-7296
X
X`009.psect`009_clex_local`009rd,wrt,noexe
X
X_clex_desc::
X_clex_pos::
X`009.long
X`009.long`009_clex_buffer
X_clex_buffer:
X`009.blkb`009512
X
X`009.psect`009_clex_code`009rd,nowrt,exe
X
X`009.entry`009put_output,0
X
X`009tstl`009_clex_pos`009; is there really anything to output?
X`009beql`0095$`009`009; don't bother to output empty line
X
X`009pushaq`009_clex_desc
X`009calls`009#1,@clex_output`009; output the buffer
X`009blbc`009r0,10$
X`009clrl`009_clex_pos`009; clear the buffer, if successfully output
X5$:`009movl`009#1,r0
X10$:`009ret
X
X`009.entry`009add_to_buffer,^m<r2,r3,r4,r5>
X`009; 4(ap) = pointer to ascic
X`009movl`0094(ap),r4
X`009movzbl`009(r4),r5
X`009incl`009r4
X`009brb`009_add_buffer
X
X`009.entry`009add_to_buffer_trunc,^m<r2,r3,r4,r5>
X`009; 4(ap) = pointer to ascic
X`009; 8(ap) = length to truncate to
X`009movl`0094(ap),r4
X`009movzbl`009(r4),r5
X`009incl`009r4
X`009cmpl`009r5,8(ap)
X`009blss`009_add_buffer
X`009movl`0098(ap),r5
X
X_add_buffer:
X`009subl3`009_clex_pos,clex_width,r2
X`009cmpl`009r5,r2
X`009bleq`00920$
X`009calls`009#0,put_output`009; output string if it whats to be added wont fit
X`009blbc`009r0,30$
X`009brb`009_add_buffer
X20$:`009movl`009_clex_pos,r3
X`009addl`009r5,_clex_pos
X`009movc3`009r5,(r4),_clex_buffer(r3)
X`009movl`009#1,r0
X30$:`009ret
X
X`009.end
$ GoSub Convert_File
$ File_is="CLEXLIB.MAR"
$ Check_Sum_is=372992394
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009.title`009macro routines
X
X; VERB Version 1.0 June 1st, 1985
X; Written  by Joe Meadows Jr.,  with thanks  to the
X; Fred Hutchinson Cancer Research Center for kindly
X; allowing  me to  use  their  computing  resources.
X;
X; If  you  have any  questions, comments, ideas, or
X; whatever, feel free to contact me via US Mail :
X;`009Joe Meadows Jr.
X;`0094841 268th Ave. N.E.
X;`009Redmond Wa. 98052
X; or via phone : (206) 827-7296
X
X`009.macro`009add_ascic,thing
X`009pushl`009thing
X`009calls`009#1,g^add_to_buffer
X`009.endm`009add_ascic
X`009.macro`009add_ascic_trunc,thing,leng,?l1,?l2
X`009pushl`009leng
X`009pushl`009thing
X`009calls`009#2,g^add_to_buffer_trunc
X`009.endm`009add_ascic_trunc
X`009.macro`009add_string,thing
X`009push_string`009<thing>
X`009calls`009#1,g^add_to_buffer
X`009.endm`009add_string
X
X`009.macro`009case,src,displist,type=w,limit=#0,nmode=s^#,?base,?max
X`009case'type`009src,limit,nmode'<<max-base>/2-1>
Xbase:
X`009.irp`009ep,<displist>
X`009.word`009ep-base
X`009.endr
Xmax:
X`009.endm`009case
X
X`009.macro`009push_string`009text,?l1,?l2
X`009.save
X`009.psect`009_clex$strings,exe,nowrt,pic
Xl1:`009.ascic`009text
X`009.restore
X`009pushal`009l1
X`009.endm`009push_string
X
X`009.macro`009string`009text,?l1,?l2
X`009.save
X`009.psect`009_clex$strings,exe,nowrt,pic
Xl1:`009.ascic`009text
X`009.restore
X`009.long`009l1
X`009.endm`009string
$ GoSub Convert_File
$ File_is="CLITABLE.TXT"
$ Check_Sum_is=1392559510
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X!`009CLI Table Blocks
X!`009Each block begins with a standard header, as follows
X!`009`009+------------------------------+
X!`009`009| subtype | type |    length   |
X!`009`009+------------------------------+
X!`009`009| TRO Count      |    Flags    |
X!`009`009+------------------------------+
X!`009all references to other blocks are made via Table relative offsets (TRO)
X!`009the TRO count specifies how many such references there are, and the
X!`009reference longwords always follow the header immediately. The rest of
X!`009each block contains other information necessary for the definition
X!`009of the item.Following the fixed portion of the block is a variable
X!`009portion, which contains any variable length strings. Each of these
X!`009strings is referenced from the fixed portion of the block by a
X!`009word Block relative offset (BRO)
X!`009These are the valid block types starting at 1.
X!`009`009vector`009`009Vector (root) block
X!`009`009command`009`009Command block
X!`009`009type`009`009Type block
X!`009`009entity`009`009Entity block
X!`009`009expression`009Expression block
X!`009`009cdu_visited`009for CDU internal use
X!vector block
X!`009the primary vector block appears at the beginning of a CLI table,
X!`009and contains references to all other blocks and block lists.
X!
X! standard header, valid subtypes starting at 1
X!`009DCL
X!`009MCR
X!`009Verb
X!`009command
X! flags - broken into two bytes, low byte contains structure level
X!Two TRO's,
X! verbtbl`009TRO of verb name table
X! comdptr`009TRO of command block pointer table
X!the  verb name table is composed of the standard header, followed by one
X! longword for each verb or synonym, the longword contains the first
X! four characters of the verb name padded with nulls as necessary
X!the command block pointer table is composed of the standard header,
X! followed by one longword for each entry in the verb table. This
X! longword contains the TRO of the corresponding command block.
X!
X!command block
X!
X! a command block is used to define a verb or a syntax change brought about
X! by a parameter or qualifier. There is one command block for each verb
X! (but not its synonyms), and one for each syntax change within a verb
X!
X! standard header, valid subtypes starting at 1
X!`009verb
X!`009syntax
X! flags --bits, starting at zero I guess
X!`009abbrev
X!`009nostat
X!`009foreign
X!`009immed
X!`009mcrparse
X!`009parms
X!`009quals
X!`009disallows
X!TRO's --
X! parms`009`009TRO of first parameter, Entity block
X!   max parms=8
X! quals`009`009TRO of first qualifier
X! disallows`009TRO of top-level disallow boolean Expression block
X!HANDLER (byte) How does CLI handle verb (starting at 0)
X! none`009It doesn't
X! cli`009Calls a cli routine
X! user`009calls a user routine
X! image`009imvokes an image
X! same`009same handling as verb
X!PARMCNT Two nibbles (1 byte)
X! MINPARM`009first four bits
X! MAXPARM`009second four bits
X!VERBTYP (byte) Verb type code for use with old CLI interface
X!PAD (byte)
X!NAME (word) BRO of verb or syntax name
X!IMAGE (word) BRO of routine or image reference
X!OUTPUTS (word) BRO of outputs list
X!PREFIX (word) BRO of prefix string
X!  -- end of fixed portion --
X! variable section --
X! Max sizes --
X! max_name = 1+31
X! max_image= 64
X! max_outputs=1+7
X! max_prefix=1+31
X!--folowing the fixed portion, the verb names are stored as a sequence
X! of ascic strings within an overall ascic string, or the syntax name is
X! stored as a single ascic string.
X! the routine or image reference is stored as follows
X!`009CLI routine`009Routine name as ascic string
X!`009user routine`009longword routine address, then ascic string
X!`009image`009`009ascic string
X! outputs list consists of a counted sequence of bytes. each byte contains
X! either the negation of the parameter number or the qualifier number
X! the prefix string is stored as an ascic string
X!
X!TYPE block
X!
X!`009a type block is used as a header of a chain of entity blocks
X!`009that describe TYPE keywords there is one TYPE block for each
X!`009user specified type definition
X!
X! standard header, valid subtypes starting at 1
X!`009type
X!no  flags
X!TRO ..
X! keywrds`009TRO of first keyword entity block
X!NAME (word)`009BRO of type name
X!Prefix (word)`009BRO of prefix string
X!-- end of fixed --
X!-- following the fixed portion the type name is stored as ascic string,
X! so is the prefix string
X!
X!Entity block
X!
X!`009an entity block is used to define each parameter, qualifier, and data
X!`009type keyword. These blocks are liked off the command block for the
X!`009verb, in the case of parameters and qualifiers, or off of the type
X!`009block, in the case of type keywords.
X!
X! standard header, valid subtypes starting at 1
X!`009parameter
X!`009qualifier
X!`009keyword
X!flags, bits starting at 0 ..
X!`009val`009`009can take a value
X!`009neg`009`009can be replaced with no
X!`009deftrue`009`009present by default
X!`009batdef`009`009present by default if batch
X!`009valreq`009`009a value is required
X!`009list`009`009can be a list of values
X!`009concat`009`009can be a concatenated list
X!`009impcat`009`009implicit concatenated list
X!`009verb`009`009global placement
X!`009parm`009`009local placement (both means positional)
X!`009mcroptdelim`009MCR SET UIC kluge
X!`009mcrignore`009MCR ignores this entity
X!
X!TROs
X! NEXT`009`009TRO of next entity block
X! SYNTAX`009TRO of syntax change command block
X! USER_TYPE`009TRO of user defined type
X!NUMBER (byte) Entity number. Cli should only use for parameters
X!VALTYP (byte) Value type, starting at zero,
X!`009user_defined`009defined by user
X!`009infile`009`009input file spec
X!`009outfile`009`009output file spec
X!`009number`009`009decimal integer
X!`009privilege`009priv keyword
X!`009datetime`009date/time
X!`009protection`009protection spec
X!`009process`009`009process name
X!`009inlog`009`009input logical name
X!`009outlog`009`009output logical name
X!`009insym`009`009input symbol name
X!`009outsym`009`009output symbol name
X!`009node`009`009DECnet node spec
X!`009device`009`009node/device spec
X!`009dir`009`009node/dev/dir spec
X!`009uic`009`009UIC spec
X!`009restofline`009rest of command line
X!`009parenvalue`009parenthesized value
X!`009file`009`009any file spec
X!`009expression`009general DCL expression
X!`009test1`009`009Three hooks for testing
X!`009test2
X!`009test3
X!`009acl`009`009ACL spec
X!NAME (word)`009BRO of entity name
X!LABEL (word)`009BRO of label used to retrieve entity
X!PROMPT (word)`009BRO of parameter prompt
X!DEFVAL (word)`009BRO of parameter default value(s)
X! --max sizes --
X! Name=1+31
X! label=1+31
X! prompt=1+31
X! defval=1+95
X!-- end of fixed portion--
V!-- following the fixed portion are the Name, Label, Prompt and default values
X,
V! stored as ascic strings. The default values are stored as a sequence of asci
Xc
X! strings, within the overall ascic string.
X!
X!expression block
X!
X!`009an expression block is used to represent, within a boolean expression,
X!`009one operator and its operands. The operands are themselves expression
X!`009blocks, either subexpressions or paths. Paths represent the hierarchical
X!`009path to an entity whose presence is to be determined.
X!
X! standard header, valid subtypes starting at 1
X!`009path`009entity path
X!`009not`009boolean NOT
X!`009any2`009"`009ANY2
X!`009and`009"`009AND
X!`009or`009"`009OR
X!`009xor`009"`009XOR
X!`009neg`009"`009NEG
X! no flags defined
X!TR0 Count
X! operand_list character length 0 tag l
X!(max 8 entities)
$ GoSub Convert_File
$ Goto Part2

-- 
bitnet:	losh@nmt.csnet			M. Warner Losh
	warner@hydrovax.nmt.csnet    ! Don't know if this works, let me know.
csnet:	warner@hydrovax.nmt.edu
uucp:	...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!warner%hydrovax