From: LAURI@DCD00.FNAL.GOV (Laurelin of Middle Earth, x2214)
Newsgroups: comp.os.vms
Subject: SETPQL  1/9
Date: 13 Nov 92 17:15:04 GMT
Distribution: world
Organization: The Internet

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On 13-NOV-1992 10:55:48.53   By user LAURI 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 9 PARTS, TO KEEP EACH PART
$!  BELOW 30 BLOCKS
$!
$! 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. [.SETPQL_V2_0]AAAREADME.TXT;3
$!       2. [.SETPQL_V2_0]BUILD.COM;1
$!       3. [.SETPQL_V2_0]SETPQL.C;1
$!       4. [.SETPQL_V2_0]SETPQL.HLP;1
$!       5. [.SETPQL_V2_0]SETPQL_CLD.CLD;1
$!       6. [.SETPQL_V2_0]SETPQL_MSG.MSG;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 = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.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 '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 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ 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");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);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 IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X   Product name : SETPQL
X        Version : 2.0
X           Date : November 1992
X  Origin/Author : L. Loebel, Computing Division, Fermilab (lauri@fnal.fnal.g
Vov)
X
XDescription:
X
X        SETPQL is a utility designed for system managers in order to make
X        sure that all users in the SYSUAF file have the minimum recommended
X        process quota limits.  Frequently a new release of VMS or other
X        layered products will require that certain quotas be raised.  The
X        system manager may modify the DEFAULT account, but not each
X        individual user.  Or, the system manager may know that some users
X        already exceed this minimum value, and do not wish to do a global
X        change for all users lest some have their quotas reduced.  SETPQL is
X        designed so that it will only RAISE PQL values, never lower them.
X
X        SYSUAF uses $RMS calls to read the SYSUAF file to obtain each
X        username on the system.  (Unfortunately, there is no "supported"
X        wildcard method of obtaining this list via system service calls).`20
X        $GETUAI and $SETUAI are used to read/modify the process quotas for
X        users who do NOT meet the minimum specified on the command line (or
X        in the DEFAULT account).  The /NOMODIFY qualifier may be used if you
X        wish to only *look* at the account quotas, i.e., to check things
X        before you actually make changes.
X`20
X        The file BUILD.COM may be used to compile and link the modules that
X        form the SETPQL.EXE image.  SETPQL is written in VAX-C and requires
X        a C compiler.`20
X`20
X        The file SETPQL.HLP contains all of the information on the options
X        available with the SETPQL command.  This is the most complete
X        documentation source.
X
XUsage:
X`09$ SETPQL :== "$ dev:`5Bdir`5DSETPQL.EXE"`09! wherever it is located
X`09$ SETPQL `5B/options`5D
X
X
XFiles included in this VMS_SHARE kit:
X
X`09AAAREADME.TXT          - this file.
X`09BUILD.COM              - creates the .EXE from the source modules.
X`09SETPQL.C               - primary C source code file.
X`09SETPQL_CLD.CLD         - command language definition module.
X`09SETPQL_MSG.MSG         - error message definition module.
X`09SETPQL.HLP             - primary documentation source.
X
$ CALL UNPACK [.SETPQL_V2_0]AAAREADME.TXT;3 394231135
$ create 'f'
X$!
X$! build the SETPQL images from scratch
X$! in the current directory.
X$!
X$ set verify
X$ on warning then goto exit
X$ message setpql_msg`09`09`09! error message definition
X$ set command setpql_cld/object`09`09! command language definition
X$ cc setpql`09`09`09`09! source code
X$ link/notrace -`09`09`09! prevent stack dumps on warning msg.
X`09setpql, setpql_cld, setpql_msg, sys$input/options
X`09sys$share:vaxcrtl/share
X$ exit:
X$ exit`09! 'f$verify(0)
$ CALL UNPACK [.SETPQL_V2_0]BUILD.COM;1 1362640472
$ create 'f'
X/***************************************************************************
V***/
X/*                                SETPQL.C
V                                    */
X/***************************************************************************
V***/
X/* Author: Lauri Loebel, Computing Division, Fermilab
V                         */
X/***************************************************************************
V***/
X/****************************Copyright Notice*******************************
V***/
X/*             Copyright `A91991 Universities Research Association, Inc.
V        */
X/*                         All Rights Reserved
V                                */
X/***************************************************************************
V***/
X/***********************Government Sponsorship Notice***********************
V***/
X/*This material resulted from work developed under a Government Contract and
V  */
X/*is subject to the following license:  The Government retains a paid-up,
V     */
X/*nonexclusive, irrevocable worldwide license to reproduce, prepare derivati
Vve*/
X/*works, perform publicly and display publicly by or for the Government,
V      */
X/*including the right to distribute to other Government contractors.  Neithe
Vr */
X/*the United States nor the United States Department of Energy, nor any of
V    */
X/*their employees, makes any warrenty, express or implied, or assumes any
V     */
X/*legal liability or responsibility for the accuracy, completeness, or
V        */
X/*usefulness of any information, apparatus, product, or process disclosed, o
Vr */
X/*represents that its use would not infringe privately owned rights.
V          */
X/***************************************************************************
V***/
X/*
X/* General description: Purpose, Usage, Algorithm.
X/*
X/* Purpose:
X/*
X/* To make sure that all accounts in the SYSUAF file meet minimum Process
X/* Quota Limits (specified by the person running the SETPQL program).`20
X/* Frequently, VMS upgrades recommend that the various process quota limits
X/* (ASTLM, MAXDETACH, BYTLM, etc.) for all accounts be raised to some new
X/* value; or the addition of a new software package will require that PQL
X/* values be raised.  Some records in the SYSUAF file may (for whatever
X/* reason) already exceed the minimum recommendatations; therefore, a
X/* wildcard MODIFY within AUTHORIZE may not be wise (it will REDUCE pql
X/* values for those accounts which already exceeded the given value).  This
X/* program is designed to ONLY RAISE, never lower, process quota limits for
X/* specified accounts in SYSUAF.  The default is to check *all* accounts.
X/*
X/* The minimum values for the various process quota limits are taken either
X/* from:
X/* `09- explicit values entered on the command line
X/* `09- values given in SYSUAF for the DEFAULT account
X/* Command line values take precedence over the DEFAULT account values.
X/*
X/* Usage:
X/*
X/* To use the SETPQL.EXE excutable, define a foreign command symbol which
X/* points to the location of the executable image:
X/*
X/* `09`09$ setpql :== "$ device:`5Bdir`5Dsetpql.exe"
X/*
X/* The command is then invoked:
X/*
X/*`09`09$ setpql `5B/qualifiers`5D  `5Buserlist`5D
X/*
X/* where userlist is the list of usernames you wish to check.  Wildcards are
X/* allowed; the default if no userlist is specified is to check all users`20
X/* (i.e., default userlist = "*").
X/*
X/* The legal qualifiers with this command are:
X/*
X/* /`5BNO`5DEXCLUDE
X/*`09/EXCLUDE=( `5BFILE `5B=exclude-file`5D`5D `5B,USER=(userlist)`5D )
X/*`09`09- Do `5BNOT`5D exclude certain accounts from the scan.
X/*`09`09  Default is /EXCLUDE=FILE=SETPQL_EXCLUDE.  The SETPQL_EXCLUDE
X/*`09`09  file will be selected based on:
X/*`09`09`09a) a logical name which points to a file, if this
X/*`09`09`09   exists,`20
X/*`09`09`09b) a SETPQL_EXCLUDE.DAT file in the current default
X/*`09`09`09   directory, if this exists,
X/*`09`09`09c) a SETPQL_EXCLUDE.DAT file in the current user's
X/*`09`09`09   SYS$LOGIN directory, if this exists.
X/*`09`09  If no SETPQL_EXCLUDE file is found, the program will`20
X/*`09`09  issue an information message and continue.
X/*
X/*`09`09  The SETPQL_EXCLUDE file may contain comments (anything
X/*`09`09  following the "!" character).  It should contain a list
X/*`09`09  of USERNAMEs which should be excluded from the scan.
X/*`09`09  The list may contain wildcards.  You may include more
X/*`09`09  than one username per line, delimited by spaces or
X/*`09`09  commas.  NOTE that these must be userNAMEs, not
X/*`09`09  UIC specifications.
X/*
X/*`09`09  You may also explicitly exclude usernames with the
X/*`09`09  form /EXCLUDE=USER=(userlist).  This list may contain
X/*`09`09  wildcards.  Users may be specified by name or by UIC
X/*`09`09  specification.
X/*
X/*`09`09  You may combine these two, as in:
X/*`09`09    $ SETPQL/EXCLUDE=( FILE,  -
X/*`09`09`09`09 `09USER=( *$SERVER, `5BSYS*,*`5D ) )
X/*
X/*
X/* /`5BNO`5DLOG`09- Do `5BNOT`5D log to the SYS$OUTPUT device any informatio
Vn
X/* `09`09  regarding the status of accounts (e.g., which accounts
X/* `09`09  would be modified and how).
X/* `09`09  Default is /LOG.
X/*
X/* /`5BNO`5DMODIFY`09- Do `5BNOT`5D modify the SYSUAF file, merely tell us w
Vhat
X/* `09`09  *WOULD* have been changed.
X/* `09`09  Default is /MODIFY.
X/*
X/* /`5BNO`5DALL`09- Examine all of the PQL parameters.  /NOALL is the defaul
Vt;
X/* `09`09  it implies that only those parameters specifically listed
X/* `09`09  on the command line should be examined.
X/*
X/* Additionally, each PQL in the SYSUAF file has it's own qualifier.  One
X/* example will suffice:
X/*
X/* /`5BNO`5DASTLM`5B=astvalue`5D
X/* `09`09- The /NOASTLM qualifier would specifically request that
X/* `09`09  the ASTLM field be excluded from examination, i.e.,`20
X/* `09`09  ASTLM would be ignored completely.
X/* `09`09  The /ASTLM qualifier by itself would request that`20
X/* `09`09  the specified users' ASTLM be raised (if necessary) to the value
X/* `09`09  of ASTLM for the DEFAULT account.
X/* `09`09  If an astvalue is specified, as in /ASTLM=500, then
X/* `09`09  the value of 500 will be used for all accounts,
X/* `09`09  overriding the DEFAULT account ASTLM.
X/*
X/* The following qualifiers operate in the same manner:
X/* /BIOLM, /BYTLM, /CPUTIME, /DIOLM, /ENQLM, /FILLM, /JTQUOTA, /MAXACCTJOBS,
X/* /MAXDETACH, /MAXJOBS, /PBYTLM, /PGFLQUOTA, /PRCLM, /PRIO, /QUEPRIO,`20
X/* /SHRFILLM, /TQELM, /WSDEFAULT, /WSEXTENT, /WSQUOTA
X/*
X/* NOTE that /CPUTIME is specified as a DELTA-TIME, that is, in the standard
X/* VMS format of "dddd-hh:mm:ss.cc".
X/*
X/* NOTE also that in some cases, a value of 0 implies that the PQL is actual
Vly
X/* infinite.  These are considered; that is, 0 is taken to be a higher value
X/* than any other positive value for these quotas.
X/*
X/* Algorithm:
X/*  `20
X/* A structure to hold all of the various PQL values is declared.  Because
X/* of the different data types of PQL values, the variables within this stru
Vcture
X/* are of different data types (short, long, char, etc.).  For this reason,
V the
X/* values cannot merely be placed in an array.
X/*  `20
X/* An array of addresses which point to the PQL values is declared.  This is
X/* actually a union of different pointer types (short *, long *, char *).`20
X/* these addresses point to the actual PQL values.
X/*
X/* An auxiliary array structure, Info, is declared.  This contains
X/* information on: the textual description of each parameter, whether or not
X/* it was specified on the command line and should be examined, the value
X/* specified on the command line, the data type of each particular process
X/* quota value.  It also holds any flags for special processing of certain
X/* parameters (e.g., cputime or uic).
X/*
X/* The command line is parsed.  The $GETUAI system service is used to
X/* determine the pql values for the DEFAULT account.  These values are
X/* compared with the values entered on the command line; the higher of the
X/* two values is used.  The MasterValue structure is populated with the PQL
X/* values which are to be used.  NOTE that only those PQL values which were
X/* specified on the command line are examined; the others are ignored.
X/*
X/* The SYSUAF file is opened for indexed read access.  A DO-LOOP is entered:
X/* Read the next SYSUAF file to get the next username.  Call $GETUAI to
X/* determine all of this user's PQL values.  For those that we were instruct
Ved
X/* to examine, compare with the MasterValues and select the highest value.
X/* (For those that were not specified on the command line, do nothing, leave
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-