OpenVMS Source Code Demos

GETRMI_DEMO.BAS

1000	%title "getrmi_demo_xxx.bas"						!
	%ident                      "version 101.1"				! <<<---+--- these must match
	declare string constant k_version = "101.1"		,		! <<<---+			&
				k_program = "getrmi_demo"			!
	!=======================================================================
	! title  : getrmi_demo_xxx.bas
	! author : Neil Rieck (n.rieck@bell.net)
	! created: 2000.05.30
	! ver who when     what
	! --- --- -------- -----------------------------------------------------
	! 100 NSR 20120322 1. original work
	! 101 NSR 20120323 1. experiments with RMI$_DISKS
	!		   2. also added
	!
	!	remember to update k_version above
	!=======================================================================
	option type=explicit							! no kid stuff
	!
	declare long	rc%	,	&
			i%
	!
	!	pull in some stuff from STARTLET (the compiler is our friend)
	!
	%include "starlet"      %from %library "sys$library:basic$starlet"      ! system services
	%include "$ssdef"       %from %library "sys$library:basic$starlet"      ! ss$
	%include "$rmidef"      %from %library "sys$library:basic$starlet"      ! rmi$
	!
	!	create a new record called ItemRec
	!	(I did this just to show how it could be done,
	!	 it would be better if you used a predefined structure in starlet)
	!
%if %declared (%ITEMREC) = 0 %then
        record ItemRec								! structure of item record
            variant
		case
		    group one
		        word    BuffLen
		        word    ItemCode
		        long    BuffAddr
		        long    RtnLenAdr
		    end group one
		case
		    group two
		        long    List_Terminator
		        long    Junk1
		        long    Junk2
		    end group two
            end variant
        end record ItemRec
%let %ITEMREC = 1
%end %if
	!
	!	create a new datatype called RmiRec
	!
	record RmiRec								! structure of Rmi Record
	   ItemRec ItemVar(39)							! 0 -> 39 items (increase as necessary)
	   long    list_term							! for end-of-list marker
	end record RmiRec							!
	!
	!	now use the new datatype in a declaration statement
	!
	declare	RmiRec	RmiBuf							! Now declare a variable using it
	!
	!	Storage for info returned by GETRMI
	!
	MAP(rmi)long	v_RMI$_BLKAST		,&
		long	v_RMI$_BUFIO		,&
			v_RMI$_DEQ		,&
			v_RMI$_DIRIO		,&
			v_RMI$_DLCKSRCH		,&
			v_RMI$_DLCKFND		,&
			v_RMI$_DZROFLTS		,&
			v_RMI$_ENQCVT		,&
			v_RMI$_ENQNEW		,&
			v_RMI$_ENQNOTQD		,&
			v_RMI$_ENQWAIT		,&
			v_RMI$_FAULTS		,&
			v_RMI$_FCPCALLS		,&
			v_RMI$_FCPCACHE		,&
			v_RMI$_FCPCPU		,&
			v_RMI$_FCPFAULT		,&
			v_RMI$_FCPHIT		,&
			v_RMI$_FCPREAD		,&
			v_RMI$_FCPSPLIT		,&
			v_RMI$_FCPWRITE		,&
			v_RMI$_FREFLTS		,&
			v_RMI$_FRLIST		,&
			v_RMI$_GVALFLTS		,&
			v_RMI$_ISWPCNT		,&
			v_RMI$_LOGNAM		,&
			v_RMI$_MBREADS		,&
			v_RMI$_MBWRITES		,&
			v_RMI$_MODLIST		,&
			v_RMI$_MFYFLTS		,&
			v_RMI$_NUMLOCKS		,&
			v_RMI$_NUMRES		,&
			v_RMI$_PREADIO		,&
			v_RMI$_PREADS		,&
			v_RMI$_PWRITES		,&
			v_RMI$_PWRITIO		,&
			v_RMI$_SYSFAULTS	,&
			v_RMI$_WRTINPROG	,&
			v_RMI$_DISKS		,&
			l_RMI$_DISKS		,&
			v_RMI$_SCS		,&
			l_RMI$_SCS		,&
			v_RMI$_PROCS 		,&
			l_RMI$_PROCS 		!
	!
	!=======================================================================
	!	Main
	!=======================================================================
	main:
	print k_program +"_"+ k_version
	print string$(len(k_program +"_"+ k_version), asc("="))			! what will the optimizer do with this?
	!
	!	now data-fill the request list
	!	note: we'll do the first one this way just to show how
	!
	RmiBuf::ItemVar(0)::BuffLen	= 4					! byte-size of data buffer (v_RMI$_BLKAST is LONG)
	RmiBuf::ItemVar(0)::ItemCode	= RMI$_BLKAST				! requested data or operation
	RmiBuf::ItemVar(0)::BuffAddr	= LOC( v_RMI$_BLKAST)			! address of our storage location
	RmiBuf::ItemVar(0)::RtnLenAdr	= 0					! address of bytes written (0=don't care)
	!
	!	we'll fill the other 39 this way
	!
	for i% = 1 to 39							!
	    RmiBuf::ItemVar(i%)::BuffLen   = 4					! appears to always be long
	    RmiBuf::ItemVar(i%)::RtnLenAdr = 0					! set to don't care
	next i%									!
	!
	RmiBuf::ItemVar( 1)::ItemCode	= RMI$_BUFIO				!
	RmiBuf::ItemVar( 1)::BuffAddr	= LOC(v_RMI$_BUFIO)			! address of our storage location
	!
	RmiBuf::ItemVar( 2)::ItemCode	= RMI$_DEQ				!
	RmiBuf::ItemVar( 2)::BuffAddr	= LOC(v_RMI$_DEQ)			! address of our storage location
	!
	RmiBuf::ItemVar( 3)::ItemCode	= RMI$_DIRIO				!
	RmiBuf::ItemVar( 3)::BuffAddr	= LOC(v_RMI$_DIRIO)			! address of our storage location
	!
	RmiBuf::ItemVar( 4)::ItemCode	= RMI$_DLCKSRCH				!
	RmiBuf::ItemVar( 4)::BuffAddr	= LOC(v_RMI$_DLCKSRCH)			! address of our storage location
	!
	RmiBuf::ItemVar( 5)::ItemCode	= RMI$_DLCKFND				!
	RmiBuf::ItemVar( 5)::BuffAddr	= LOC(v_RMI$_DLCKFND)			! address of our storage location
	!
	RmiBuf::ItemVar( 6)::ItemCode	= RMI$_DZROFLTS				!
	RmiBuf::ItemVar( 6)::BuffAddr	= LOC(v_RMI$_DZROFLTS)			! address of our storage location
	!
	RmiBuf::ItemVar( 7)::ItemCode	= RMI$_ENQCVT				!
	RmiBuf::ItemVar( 7)::BuffAddr	= LOC(v_RMI$_ENQCVT)			! address of our storage location
	!
	RmiBuf::ItemVar( 8)::ItemCode	= RMI$_ENQNEW				!
	RmiBuf::ItemVar( 8)::BuffAddr	= LOC(v_RMI$_ENQNEW)			! address of our storage location
	!
	RmiBuf::ItemVar( 9)::ItemCode	= RMI$_ENQNOTQD				!
	RmiBuf::ItemVar( 9)::BuffAddr	= LOC(v_RMI$_ENQNOTQD)			! address of our storage location
	!
	RmiBuf::ItemVar(10)::ItemCode	= RMI$_ENQWAIT				!
	RmiBuf::ItemVar(10)::BuffAddr	= LOC(v_RMI$_ENQWAIT)			! address of our storage location
	!
	RmiBuf::ItemVar(11)::ItemCode	= RMI$_FAULTS				!
	RmiBuf::ItemVar(11)::BuffAddr	= LOC(v_RMI$_FAULTS)			! address of our storage location
	!
	RmiBuf::ItemVar(12)::ItemCode	= RMI$_FCPCALLS				!
	RmiBuf::ItemVar(12)::BuffAddr	= LOC(v_RMI$_FCPCALLS)			! address of our storage location
	!
	RmiBuf::ItemVar(13)::ItemCode	= RMI$_FCPCACHE				!
	RmiBuf::ItemVar(13)::BuffAddr	= LOC(v_RMI$_FCPCACHE)			! address of our storage location
	!
	RmiBuf::ItemVar(14)::ItemCode	= RMI$_FCPCPU				!
	RmiBuf::ItemVar(14)::BuffAddr	= LOC(v_RMI$_FCPCPU)			! address of our storage location
	!
	RmiBuf::ItemVar(15)::ItemCode	= RMI$_FCPFAULT				!
	RmiBuf::ItemVar(15)::BuffAddr	= LOC(v_RMI$_FCPFAULT)			! address of our storage location
	!
	RmiBuf::ItemVar(16)::ItemCode	= RMI$_FCPHIT				!
	RmiBuf::ItemVar(16)::BuffAddr	= LOC(v_RMI$_FCPHIT)			! address of our storage location
	!
	RmiBuf::ItemVar(17)::ItemCode	= RMI$_FCPREAD				!
	RmiBuf::ItemVar(17)::BuffAddr	= LOC(v_RMI$_FCPREAD)			! address of our storage location
	!
	RmiBuf::ItemVar(18)::ItemCode	= RMI$_FCPSPLIT				!
	RmiBuf::ItemVar(18)::BuffAddr	= LOC(v_RMI$_FCPSPLIT)			! address of our storage location
	!
	RmiBuf::ItemVar(19)::ItemCode	= RMI$_FCPWRITE				!
	RmiBuf::ItemVar(19)::BuffAddr	= LOC(v_RMI$_FCPWRITE)			! address of our storage location
	!
	RmiBuf::ItemVar(20)::ItemCode	= RMI$_FREFLTS				!
	RmiBuf::ItemVar(20)::BuffAddr	= LOC(v_RMI$_FREFLTS)			! address of our storage location
	!
	RmiBuf::ItemVar(21)::ItemCode	= RMI$_FRLIST				!
	RmiBuf::ItemVar(21)::BuffAddr	= LOC(v_RMI$_FRLIST)			! address of our storage location
	!
	RmiBuf::ItemVar(22)::ItemCode	= RMI$_GVALFLTS				!
	RmiBuf::ItemVar(22)::BuffAddr	= LOC(v_RMI$_GVALFLTS)			! address of our storage location
	!
	RmiBuf::ItemVar(23)::ItemCode	= RMI$_ISWPCNT				!
	RmiBuf::ItemVar(23)::BuffAddr	= LOC(v_RMI$_ISWPCNT)			! address of our storage location
	!
	RmiBuf::ItemVar(24)::ItemCode	= RMI$_LOGNAM				!
	RmiBuf::ItemVar(24)::BuffAddr	= LOC(v_RMI$_LOGNAM)			! address of our storage location
	!
	RmiBuf::ItemVar(25)::ItemCode	= RMI$_MBREADS				!
	RmiBuf::ItemVar(25)::BuffAddr	= LOC(v_RMI$_MBREADS)			! address of our storage location
	!
	RmiBuf::ItemVar(26)::ItemCode	= RMI$_MBWRITES				!
	RmiBuf::ItemVar(26)::BuffAddr	= LOC(v_RMI$_MBWRITES)			! address of our storage location
	!
	RmiBuf::ItemVar(27)::ItemCode	= RMI$_MODLIST				!
	RmiBuf::ItemVar(27)::BuffAddr	= LOC(v_RMI$_MODLIST)			! address of our storage location
	!
	RmiBuf::ItemVar(28)::ItemCode	= RMI$_MFYFLTS				!
	RmiBuf::ItemVar(28)::BuffAddr	= LOC(v_RMI$_MFYFLTS)			! address of our storage location
	!
	RmiBuf::ItemVar(29)::ItemCode	= RMI$_NUMLOCKS				!
	RmiBuf::ItemVar(29)::BuffAddr	= LOC(v_RMI$_NUMLOCKS)			! address of our storage location
	!
	RmiBuf::ItemVar(30)::ItemCode	= RMI$_NUMRES				!
	RmiBuf::ItemVar(30)::BuffAddr	= LOC(v_RMI$_NUMRES)			! address of our storage location
	!
	RmiBuf::ItemVar(31)::ItemCode	= RMI$_PREADIO				!
	RmiBuf::ItemVar(31)::BuffAddr	= LOC(v_RMI$_PREADIO)			! address of our storage location
	!
	RmiBuf::ItemVar(32)::ItemCode	= RMI$_PREADS				!
	RmiBuf::ItemVar(32)::BuffAddr	= LOC(v_RMI$_PREADS)			! address of our storage location
	!
	RmiBuf::ItemVar(33)::ItemCode	= RMI$_PWRITES				!
	RmiBuf::ItemVar(33)::BuffAddr	= LOC(v_RMI$_PWRITES)			! address of our storage location
	!
	RmiBuf::ItemVar(34)::ItemCode	= RMI$_PWRITIO				!
	RmiBuf::ItemVar(34)::BuffAddr	= LOC(v_RMI$_PWRITIO)			! address of our storage location
	!
	RmiBuf::ItemVar(35)::ItemCode	= RMI$_SYSFAULTS			!
	RmiBuf::ItemVar(35)::BuffAddr	= LOC(v_RMI$_SYSFAULTS)			! address of our storage location
	!
	RmiBuf::ItemVar(36)::ItemCode	= RMI$_WRTINPROG			!
	RmiBuf::ItemVar(36)::BuffAddr	= LOC(v_RMI$_WRTINPROG)			! address of our storage location
	!
	!	although these item codes can be found in STARLET,
	!	they appear to be no longer supported (at least not on OpenVMS-8.4)
	!
	RmiBuf::ItemVar(37)::BuffLen	= 4					! byte-size of our data buffer
	RmiBuf::ItemVar(37)::ItemCode	= RMI$_DISKS				! requested data or operation
	RmiBuf::ItemVar(37)::BuffAddr	= LOC( v_RMI$_DISKS)			! address of our storage location
	RmiBuf::ItemVar(37)::RtnLenAdr	= loc( L_RMI$_DISKS)			! address of actual returned data
	!
	RmiBuf::ItemVar(38)::BuffLen	= 4					! byte-size of our data buffer
	RmiBuf::ItemVar(38)::ItemCode	= RMI$_SCS				! requested data or operation
	RmiBuf::ItemVar(38)::BuffAddr	= LOC( v_RMI$_SCS)			! address of our storage location
	RmiBuf::ItemVar(38)::RtnLenAdr	= loc( L_RMI$_SCS)			! address of actual returned data
	!
	RmiBuf::ItemVar(39)::BuffLen	= 4					! byte-size of our data buffer
	RmiBuf::ItemVar(39)::ItemCode	= RMI$_PROCS				! requested data or operation
	RmiBuf::ItemVar(39)::BuffAddr	= LOC( v_RMI$_PROCS)			! address of our storage location
	RmiBuf::ItemVar(39)::RtnLenAdr	= loc( L_RMI$_PROCS)			! address of actual returned data
	!
	RmiBuf::LIST_TERM		= Rmi$C_ListEnd				! end of list
	!
	!	Okay, now make the call
	!
	!	SYS$GETRMI [efn] [,nullarg] [,nullarg] ,itmlst [,iosb] [,astadr] [,astprm]
	!
	rc% = sys$GetRmi(,,,RmiBuf,,,)						!
	!
	!	Okay, now display the results
	!
	print " getRmi-rc:     "+ str$(rc%)					!
	print " RMI$_BLKAST    "; v_RMI$_BLKAST
	print " RMI$_BUFIO     "; v_RMI$_BUFIO
	print " RMI$_DEQ       "; v_RMI$_DEQ
	print " RMI$_DIRIO     "; v_RMI$_DIRIO
	print " RMI$_DLCKSRCH  "; v_RMI$_DLCKSRCH
	print " RMI$_DLCKFND   "; v_RMI$_DLCKFND
	print " RMI$_DZROFLTS  "; v_RMI$_DZROFLTS
	print " RMI$_ENQCVT    "; v_RMI$_ENQCVT
	print " RMI$_ENQNEW    "; v_RMI$_ENQNEW
	print " RMI$_ENQNOTQD  "; v_RMI$_ENQNOTQD
	print " RMI$_ENQWAIT   "; v_RMI$_ENQWAIT
	print " RMI$_FAULTS    "; v_RMI$_FAULTS
	print " RMI$_FCPCALLS  "; v_RMI$_FCPCALLS
	print " RMI$_FCPCACHE  "; v_RMI$_FCPCACHE
	print " RMI$_FCPCPU    "; v_RMI$_FCPCPU
	print " RMI$_FCPFAULT  "; v_RMI$_FCPFAULT
	print " RMI$_FCPHIT    "; v_RMI$_FCPHIT
	print " RMI$_FCPREAD   "; v_RMI$_FCPREAD
	print " RMI$_FCPSPLIT  "; v_RMI$_FCPSPLIT
	print " RMI$_FCPWRITE  "; v_RMI$_FCPWRITE
	print " RMI$_FREFLTS   "; v_RMI$_FREFLTS
	print " RMI$_FRLIST    "; v_RMI$_FRLIST
	print " RMI$_GVALFLTS  "; v_RMI$_GVALFLTS
	print " RMI$_ISWPCNT   "; v_RMI$_ISWPCNT
	print " RMI$_LOGNAM    "; v_RMI$_LOGNAM
	print " RMI$_MBREADS   "; v_RMI$_MBREADS
	print " RMI$_MBWRITES  "; v_RMI$_MBWRITES
	print " RMI$_MODLIST   "; v_RMI$_MODLIST
	print " RMI$_MFYFLTS   "; v_RMI$_MFYFLTS
	print " RMI$_NUMLOCKS  "; v_RMI$_NUMLOCKS
	print " RMI$_NUMRES    "; v_RMI$_NUMRES
	print " RMI$_PREADIO   "; v_RMI$_PREADIO
	print " RMI$_PREADS    "; v_RMI$_PREADS
	print " RMI$_PWRITES   "; v_RMI$_PWRITES
	print " RMI$_PWRITIO   "; v_RMI$_PWRITIO
	print " RMI$_SYSFAULTS "; v_RMI$_SYSFAULTS
	print " RMI$_WRTINPROG "; v_RMI$_WRTINPROG
	print " RMI$_DISKS     "; v_RMI$_DISKS; " length: "; L_RMI$_DISKS
	print " RMI$_SCS       "; v_RMI$_SCS;   " length: "; L_RMI$_SCS
	print " RMI$_PROCS     "; v_RMI$_PROCS; " length: "; L_RMI$_PROCS
	!
	end