From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  3-AUG-1989 11:26
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Re: Lexical for show quota ?

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu,  3 AUG 89 07:18:17 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Thu, 3 Aug 89 07:16:27 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.37)
	id AA03828; Thu, 3 Aug 89 07:12:04 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 3 Aug 89 14:04:01 GMT
From: tewksbur@bu-cs.bu.edu  (Chip Tewksbury)
Organization: Boston University
Subject: Re: Lexical for show quota ?
Message-Id: <35767@bu-cs.BU.EDU>
References: <89Jul31.102529edt.57399@ugw.utcs.utoronto.ca>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <89Jul31.102529edt.57399@ugw.utcs.utoronto.ca> TIRVENGA@UWPG02.BITNET (AJ) writes:
>Hello,
>
>Does anyone know of a lexical function or another method of obtaining
>the quota a user has ? What I mean is the value one would get with
>$Show quota. Instead of having the whole message, just the amount of
>free diskquota, used diskquota is what I'm really after.
>
>Thanks in Advance
>
>========================
>
>AJ TIRVENGADUM


	Here's something that I whipped-up last month to do what you're
looking for (i think.)

	Chip Tewksbury, Distributed Systems Group, Boston University,
	     111 Cummington Street, Boston, MA  02215, USA (617) 353-2780
	INTERNET:   tewksbur@bu-it.bu.edu        BITNET:  TEWKSBUR@BUENGA

-------------------cut here-----------------------

	.TITLE /DISKQUOTA/
	.LIBRARY	/SYS$LIBRARY:LIB.MLB/
	.IDENT	/V1.0-1/
;
;
;	This program will take a username and return it's diskquota.
;	It does this by determining the disk and uic from the UAF then
;	qio-ing the disk for the uic in the quota control block.
;	The info is returned in the same qcb and the usage is extracted.
;
;	Return:	Local symbol string (DISK_QUOTA_QUOTA) containing diskquota
;		in use on user's SYS$LOGIN disk.
;
;	BUGS:   If an error occurs it is reported; however, the local
;		symbol (if previously defined) is not changed.
;
;	Call the program as:
;
;	$ DQ :=$dev:[dir]DISKQUOTA
;	$ DQ username
;	$ IF .NOT. $STATUS THEN GOTO ERROR_GETTING_DISKQUOTA_FOR_USER.
;
;;	Author:	Chip Tewksbury,		Created: 11-JUL-1989
;
;Modification History:
;
;12-JUL-89, CT:	Changed symbol name to DISK_QUOTA_LOCAL and added CHK_IOSB.
;
;--------------------------------------------------------------------------

	$UAIDEF
      	$FIBDEF
	$DQFDEF   
;---------------------------------------------------------------------------
;
; Macro for checking status of routine calls
;
	.MACRO	CHK_STS ?L1
		BLBS	R0, L1
		$EXIT_S	R0
	L1:
		.ENDM	CHK_STS

	.MACRO	CHK_IOSB ?L1
		BLBS	IOSB,L1
		$EXIT_S	IOSB
	L1:
		.ENDM CHK_IOSB

	MAX_DEV_LENGTH = 32			;device is 31 + size byte.
	MAX_UNAME_LENGTH = 12                   ;Username is 12 chars
	MAX_DIGITS = 8				;Max disk size is 99,999,999
;---------------------------------------------------------------------------
;
	DQ_DESC:	.WORD DQF$K_LENGTH	;diskquota control block desc.
			.WORD 0
			.ADDRESS DQ_BUF
	DQ_BUF:		.BLKB DQF$K_LENGTH
                                 
	CHAN:		.BLKW	1		;Channel for $asssign and $qio
	IOSB:		.BLKQ	1		;IOSB for $qio
	FIBDESC:	.LONG FIB$K_LENGTH	;FIB for $qio. Just a dummy.
			.ADDRESS FIB
	FIB:		.BLKB	FIB$K_LENGTH   

	ITMLST:		.WORD MAX_DEV_LENGTH	;Item list for  $getuai
			.WORD UAI$_DEFDEV	;Get the default device
			.ADDRESS DEV_BUF
			.LONG 0
			.WORD 4
			.WORD	UAI$_UIC	;Get the uic too.
			.ADDRESS	UIC
			.LONG 0
			.LONG 0			;End of list

	DEV_DESC:	.WORD MAX_DEV_LENGTH	;Desc. for the device string
		  	.WORD 0
			.ADDRESS DEV_BUF
	DEV_BUF:  	.BLKB MAX_DEV_LENGTH

	UIC:		.BLKL 1			;Uic is returned as a long
						;  with mem in lob, grp in hob.

	USRNAM:		.WORD MAX_UNAME_LENGTH	;Username from command line
			.WORD 0
			.ADDRESS .+4
			.BLKB	MAX_UNAME_LENGTH

	PROMPT:		.ASCID /_Username: /	;Prompt if not on com line
	QUOTA_SYMBOL:	.ASCID /DISK_QUOTA_LOCAL/ ;Local Symbol to return 
	LENGTH:		.BLKW 1			;For various descriptors
	CTRSTR:		.ASCID /!UL/		;Control string for $FAO
	FAO_DESC:	.WORD	MAX_DIGITS	;Store the asci-ed number
			.WORD 0
			.ADDRESS FAOBUF
	FAOBUF:		.BLKB MAX_DIGITS

;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
	.ENTRY DISKQUOTA ^M<IV>

    	PUSHAB	LENGTH
	PUSHAB	PROMPT
	PUSHAB	USRNAM
	CALLS	#3,G^LIB$GET_FOREIGN		;Get the username from com line
	CHK_STS

	MOVW	LENGTH, USRNAM			;Fix descriptor length

	$GETUAI_S	ITMLST = ITMLST, -	;Get the defdev & uic from UAF
			USRNAM = USRNAM
	CHK_STS
    
	CVTBW	DEV_BUF, DEV_DESC		;The defdev contains the length
						;of the string in the first 
						;byte of the string.  So we
						;copy that into the descriptor
						;Then delete that byte.
						;-
	CVTWL	DEV_DESC, R6			;Copy length of string for MOVC
	MOVC3	R6, DEV_BUF+1, DEV_BUF		;Delete byte  and copy the
						;string into itself. byte1 gone.

	MOVAB	DQ_BUF, R7        		;Move address of quota block
						;into register
	MOVAB	FIB, R8				;Save FIB's address in reg.

	MOVW	#FIB$C_EXA_QUOTA,-             
		 FIB$W_CNTRLFUNC(R8)            ;Want to examine quota.  Only
						; thing neede in FIB.        

						
	MOVL	UIC, DQF$L_UIC(R7)		;Put the uic to be queried
						;in the qcb.
	
	$ASSIGN_S	CHAN = CHAN, -		;Get a channel to the disk
			DEVNAM = DEV_DESC
	CHK_STS
        $QIOW_S		CHAN = CHAN,-		;Q the ACP.
			FUNC = #IO$_ACPCONTROL,-
			IOSB = IOSB,-
			P1 = FIBDESC, -
			P2 = #DQ_DESC,-
			P3 = #LENGTH,-
			P4 = #DQ_DESC
	CHK_STS
	CHK_IOSB

	MOVL		DQF$L_USAGE(R7), R10	;Extract the usage field.

	$FAO_S		CTRSTR = CTRSTR, -	;Format usage into asci string.
			OUTLEN = LENGTH,-
			OUTBUF = FAO_DESC,-
			P1 = R10
	CHK_STS

	MOVW	LENGTH, FAO_DESC		;Fix the descriptor
	PUSHAB	FAO_DESC
	PUSHAB	QUOTA_SYMBOL
	CALLS	#2,G^LIB$SET_SYMBOL		;Set the symbol
	CHK_STS
		
	$EXIT_S					;and leave.

	.END DISKQUOTA

