! ----- DISK_QUOTA.FUN ----- ! ! ----- FUNCTION TO PERFORM QUOTA OPERATIONS FOR A USER ----- ! ! ---------- PASSED: ---------- ! ! ----- QUOTA_ACTION = "ADD" to add an infinite disk quota for ! ----- this user (do not abort if any error) ! ! ----- = "ADD_ABORT" to add an infinite disk quota ! ----- for this user (abort if any error) ! ! ----- = "DELETE" to remove any disk quota for ! ----- this user (will display msg if ! ----- successful) (abort if any error) ! ! ----- = "DELETE_NOMSG" to remove any disk quota ! ----- for this user (no msg if successful) ! ----- (abort if any error) ! ! ----- THE_DEVICE = Disk device name to be accessed ! ! ----- DEVICE_LENGTH = Length of THE_DEVICE ! ! ---------- RETURNED: ---------- ! ! ----- DISK_QUOTA = TRUE if any error, FALSE if successful ! ! ----- Last Change 07/09/93 by Brian Lomasky ----- ! FUNCTION WORD DISK_QUOTA(STRING QUOTA_ACTION) %INCLUDE "NUSER.INC" %INCLUDE "$FIBDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB" %INCLUDE "$IODEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB" ! ----- SYSTEM SERVICE ERROR CODES AND FUNCTION VALUES ----- EXTERNAL LONG CONSTANT SS$_DUPDSKQUOTA ! DUPLICATE DISK QUOTA EXTERNAL LONG CONSTANT SS$_NODISKQUOTA ! NO DISK QUOTA FOR UIC EXTERNAL LONG CONSTANT SS$_QFNOTACT ! QUOTAS NOT ACTIVE RECORD QUOTA_DEF ! QUOTA FILE TRANSFER BLOCK LONG FLAGS LONG UIC LONG USAGE LONG PERMQUOTA LONG OVERDRAFT LONG UNUSED(2%) END RECORD QUOTA_DEF DECLARE WORD CHAN ! I/O CHANNEL TO USE DECLARE STRING ERR_DSC ! LOCAL ERROR DESCRIPTION DIM WORD IOSB(3%) ! I/O STATUS BLOCK DECLARE LONG LOCAL_STATUS ! LOCAL SYSTEM SERVICE EXIT STAT DECLARE WORD QUOTA_BLOCK_LEN ! LENGTH OF QUOTA BLOCK DECLARE LONG SAVED_STATUS ! SAVED SYSTEM SERVICE EXIT STAT DECLARE STRING TEMP_STRING ! TEMPORARY STRING MAP (DQFIB) FIBDEF1 FIB_REC ! FIB MAP (DQFIB) STRING FIB_STR = 28%! FOR PASSING ENTIRE FIB... MAP (DQQUO) QUOTA_DEF QUOTA_REC ! QUOTA FILE TRANSFER BLOCK MAP (DQQUO) STRING QUOTA_STR = 32% ! FOR PASSING ENTIRE MAP... EXTERNAL LONG FUNCTION & SYS$ASSIGN ! ASSIGN I/O CHANNEL TO A DEVICE EXTERNAL LONG FUNCTION & SYS$DASSGN ! DEASSIGN I/O CHANNEL EXTERNAL LONG FUNCTION SYS$QIOW ! QUEUE I/O REQUEST AND WAIT DISK_QUOTA = TRUE ! ASSUME ERROR STATUS ! ----- STORE DEFAULT DEVICE TO BE ACCESSED ----- ERROR_DESC = "Store default device" TEMP_STRING = LEFT(THE_DEVICE, DEVICE_LENGTH) SELECT QUOTA_ACTION CASE "ADD", "ADD_ABORT" ! ADD AN "INFINITE" DISK QUOTA ! ----- SPECIFY THE DESIRED DISK QUOTA FUNCTION ----- ! ----- IN THE 12TH WORD OF THE FIB STRUCTURE ----- ! ----- (FIB$W_CNTRLFUNC) ----- FIB_REC::FIB$W_CNTRLFUNC = FIB$C_ADD_QUOTA ERR_DSC = "add" CASE "DELETE", "DELETE_NOMSG" ! REMOVE ANY DISK QUOTA FOR USER ! ----- SPECIFY THE DESIRED DISK QUOTA FUNCTION ----- ! ----- IN THE 12TH WORD OF THE FIB STRUCTURE ----- ! ----- (FIB$W_CNTRLFUNC) ----- FIB_REC::FIB$W_CNTRLFUNC = FIB$C_REM_QUOTA ERR_DSC = "delete" CASE ELSE PRINT PRINT "Error - Invalid Disk Quota Action: " + & QUOTA_ACTION + BEL IF QUOTA_ACTION <> "ADD" THEN CALL SYS$EXIT(ERROR_WITH_NO_PUTMSG BY VALUE) END IF EXIT FUNCTION END SELECT ! ----- ASSIGN A CHANNEL TO THE DEVICE ----- ERROR_DESC = "SYS$ASSIGN" IF DEBUG_MODE THEN PRINT "DEBUG>DISK_QUOTA Assign chnl" END IF LOCAL_STATUS = SYS$ASSIGN(TEMP_STRING, CHAN, , , ) IF (LOCAL_STATUS AND 1%) = 0% THEN PRINT "Error " + NUM1$(LOCAL_STATUS) + & " occurred at SYS$ASSIGN" + & " while trying to " + ERR_DSC + & " disk quota" + BEL IF QUOTA_ACTION <> "ADD" THEN CALL SYS$EXIT(LOCAL_STATUS BY VALUE) END IF EXIT FUNCTION END IF SAVED_STATUS = SS$_NORMAL ! ASSUME NO ERROR OCCURRED QUOTA_REC::UIC = UIC ! UIC TO BE STORED QUOTA_REC::USAGE = 0% ! INIT THE USAGE VALUE QUOTA_REC::PERMQUOTA = 9999999% ! STORE PERMANENT QUOTA QUOTA_REC::OVERDRAFT = 500% ! STORE OVERDRAFT VALUE ! ----- CALL THE ACP QIO WITH THE IO$_ACPCONTROL FUNCTION ----- ! ----- CODE ----- IF DEBUG_MODE THEN PRINT "DEBUG>DISK_QUOTA QIOW" END IF ERROR_DESC = "SYS$QIOW" LOCAL_STATUS = SYS$QIOW(, & CHAN BY VALUE, & IO$_ACPCONTROL BY VALUE,! DISK QUOTA FUNCTIONS & IOSB() BY REF, , , & FIB_STR BY DESC, & QUOTA_STR BY DESC, ! QUOTA INFO SENT TO ACP& QUOTA_BLOCK_LEN BY REF, ! RETURNED DATA LENGTH & QUOTA_STR BY DESC, , ) ! QUOTA INFO GOT FROM ACP ! ----- CHECK THE IOSB STATUS TO SEE IF EVERYTHING WORKED ----- LOCAL_STATUS = IOSB(0%) IF (LOCAL_STATUS AND 1%) = 1% SAVED_STATUS = LOCAL_STATUS IF (LOCAL_STATUS AND 1%) = 0% ! ----- DEASSIGN THE I/O CHANNEL ----- IF DEBUG_MODE THEN PRINT "DEBUG>DISK_QUOTA Deassign" END IF LOCAL_STATUS = SYS$DASSGN(CHAN BY VALUE) ! ----- RESTORE ANY PREVIOUS ERROR STATUS ----- IF SAVED_STATUS <> SS$_NORMAL THEN ERROR_DESC = "SYS$QIOW" LOCAL_STATUS = SAVED_STATUS ELSE ERROR_DESC = "SYS$DASSGN" END IF IF (LOCAL_STATUS AND 1%) = 0% THEN ! ----- SEE IF QUOTAS NOT ACTIVE ----- SELECT LOCAL_STATUS CASE SS$_DUPDSKQUOTA CASE SS$_NODISKQUOTA IF DEBUG_MODE THEN PRINT "DEBUG>No Disk Quota" END IF CASE SS$_QFNOTACT PRINT "Warning - Disk quotas not" + & " enabled on " + & LEFT(THE_DEVICE, DEVICE_LENGTH) CASE ELSE PRINT "Error " + NUM1$(LOCAL_STATUS) + & " occurred at " + & TRM$(ERROR_DESC) + & " while trying to " + ERR_DSC + & " disk quota" + BEL IF QUOTA_ACTION <> "ADD" THEN CALL SYS$EXIT(LOCAL_STATUS BY VALUE) END IF END SELECT EXIT FUNCTION END IF ERROR_DESC = "EXIT" SELECT QUOTA_ACTION CASE "ADD", "ADD_ABORT" ! ADD AN "INFINITE" DISK QUOTA PRINT "Added disk quota..." CASE "DELETE" ! REMOVE ANY DISK QUOTA FOR USER PRINT "Removed disk quota..." END SELECT DISK_QUOTA = FALSE ! RETURN SUCCESS STATUS END FUNCTION