From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 30-AUG-1993 09:03:11.17
To:	EVERHART
CC:	
Subj:	Re: Lexical calls for obtaining DISKQUOTA information?

From: 00mjstum@leo.bsuvc.bsu.edu (Matthew J. Stum)
X-Newsgroups: comp.os.vms
Subject: Re: Lexical calls for obtaining DISKQUOTA information?
Message-Id: <1993Aug27.160346.21583@bsu-ucs>
Date: 27 Aug 93 21:03:46 GMT
Organization: Widget Enterprises
Lines: 122
To: Info-VAX@kl.sri.com
X-Gateway-Source-Info: USENET

green@ids.net (Andy Green) writes:
> Does anyone know if there are any DCL Lexical commands that can obtain
> information on a users disk quota?

I don't know of any lexical calls, but I wrote a VAX Pascal program I wrote
to define symbols DISK_QUOTA_LIMIT, DISK_QUOTA_USED, and DISK_QUOTA_OVERDRAFT.

If you don't have VAX Pascal you can at least get an idea of how it's done
and port it to another language.

--------------------8<--------Cut Here----------8<--------------
[inherit ('sys$library:starlet','sys$library:pascal$lib_routines')]
program get_quota(input,output);
type
  $uword = [word] 0..65535;
  v80string = varying [80] of char;
  dqf$type = record
               dqf$l_flags : unsigned;
               dqf$l_uic : unsigned;
               dqf$l_usage : unsigned;
               dqf$l_permquota : unsigned;
               dqf$l_overdraft : unsigned;
               dqf$l_reserved1 : unsigned;
               dqf$l_reserved2 : unsigned;
               dqf$l_reserved3 : unsigned;
             end;
 dqf$type_descr = record
                    Length : $uword;
                    Null : $uword;
                    Buff : unsigned;
                  end;

 fib1$type_descr = record
                     Length : $uword;
                     Null : $uword;
                     Buff : unsigned;
                   end;

var
  stat:unsigned;
  chan : $uword;
  uic : unsigned;
  quota_used,
  quota_limit,
  quota_over : unsigned;
  fib_descr : fib1$type_descr;
  fib : FIB1$TYPE;
  in_block_descr,
  out_block_descr : dqf$type_descr;
  in_block,
  out_block : dqf$type;
  line : varying [15] of char;
  command : v80string;
  username : v80string;
  disk : v80string;
  i : integer;

procedure use_current;
begin
  stat:=lib$getjpi(jpi$_uic,,,uic);
  if not(odd(stat)) then $exit(stat);

  stat := $assign('SYS$LOGIN',chan);
  if not(odd(stat)) then $exit(stat);
end;

procedure use_command(command : v80string);
begin
  i := index(command,' ');
  if i=0 then
    begin
      writeln('Command syntax: userame disk');
      $exit;
    end;
  username := substr(command,1,i-1);
  disk := substr(command,i+1,command.length-i);

  stat:=$asctoid(%stdescr username, uic);
  if not(odd(stat)) then $exit(stat);

  stat := $assign(disk,chan);
  if not(odd(stat)) then $exit(stat);
end;

begin
  stat:=lib$get_foreign(%descr command);
  if command = '' then
    use_current
   else
    use_command(command);

  fib.fib$w_cntrlfunc:=fib$c_exa_quota;
  in_block.dqf$l_flags:=zero;
  in_block.dqf$l_uic:=uic;

  in_block_descr.length:=32;
  out_block_descr.length:=32;
  in_block_descr.buff:=iaddress(in_block);
  out_block_descr.buff:=iaddress(out_block);
  fib_descr.length:=64;
  fib_descr.buff:=iaddress(fib);
  stat := $qiow(chan:=chan,
                func:=io$_acpcontrol,
                p1:=fib_descr,
                p2:=iaddress(in_block_descr),
                p4:=iaddress(out_block_descr));
 if not(odd(stat)) then $exit(stat);
 quota_used := out_block.dqf$l_usage;
 quota_limit := out_block.dqf$l_permquota;
 quota_over := out_block.dqf$l_overdraft;
 writev(line,quota_used:1);
 lib$set_symbol(%descr 'DISK_QUOTA_USED', %descr line, LIB$K_CLI_GLOBAL_SYM);
 writev(line,quota_limit:1);
 lib$set_symbol(%descr 'DISK_QUOTA_LIMIT', %descr line, LIB$K_CLI_GLOBAL_SYM);
 writev(line,quota_over:1);
 lib$set_symbol(%descr 'DISK_QUOTA_OVERDRAFT', %descr line, LIB$K_CLI_GLOBAL_SYM);
end.
--------------------8<--------Cut Here----------8<--------------

-- 
Matt Stum                    Gwydion ap Myrddin       Ball State University
00mjstum@bsuvc.bsu.edu       Shire of Afonlyn, MK     Muncie, IN  USA

