Article 127724 of comp.os.vms:
Path: nntpd.lkg.dec.com!juggl7.zk3.dec.com!harris
From: harris@guru.zk3.dec.com (ROBERT HARRIS USG)
Newsgroups: comp.os.vms
Subject: Re: VMS C Source wanted
Date: 23 Aug 1995 16:40:27 GMT
Organization: Digital Equipment Corporation
Lines: 143
Distribution: world
Message-ID: <41fllr$b4p@nntpd.lkg.dec.com>
References: <1995Aug23.200348.40240@waikato.ac.nz> <41fjsq$fbm@nntpd.lkg.dec.com>
Reply-To: harris@zk3.dec.com
NNTP-Posting-Host: juggl7.zk3.dec.com
X-Newsreader: mxrn 6.18-5
Originator: harris@juggl7.zk3.dec.com


In article <1995Aug23.200348.40240@waikato.ac.nz>, spt@waikato.ac.nz
(Simon Travaglia, Analyst/Programmer) writes:
> :
> :Anyone got any ftpable C source to do the following things
> :SYSUAF reading and manipulatoin
> :Quota file manipulation

    The following short program shows how to get quota information.
    Modifying it is just a variation.  You will need to read the I/O User's
    Guild, Chapter 1 on the ACP-QIO interface to expand on this example.
    However, once you can access any of the quota information the rest is
    easy.

					Bob Harris


/*---------------------------------------------------------------------------
   SHOW_QUOTA.C - quick program to demonstrate fetching Disk Quota values
      using the XQP QIO interface.
-----------------------------------------------------------------------------*/
#include <stdio.h>
#include <iodef.h>
#include <ssdef.h>
#include <fibdef.h>

typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long longword;



usage()
{
#define FP(_s) fprintf( stderr, "%s\n", _s )

 FP( "Usage: SHOW_QUOTA :== $disk:[dir]DIRSEQ.EXE" );
 FP( "       SHOW_QUOTA device [ggg,mmm]" );
 FP( "" );
 FP( "       device - disk to look for quota information on" );
 FP( "       ggg - UIC Group (Octal)" );
 FP( "       mmm - UIC Member (Octal)" );
 exit( 0x12 );
}



main( int ac, char **av )
{
    longword status;
    longword d_dev[2];
    longword d_fib[2];
    longword d_in[2];
    longword d_out[2];
    longword grp;
    longword mem;
    longword uic;
    word iosb[4];
    word chan;
    word outlen;
    struct fibdef fib;
    
    struct z_quota {
        longword flags;
        longword uic;
        longword usage;
        longword permquota;
        longword overdraft;
        longword future_1;
        longword future_2;
        longword future_3;
    };
    struct z_quota in_quota;
    struct z_quota out_quota;
    
/*---------------------------------------------------------------------------*/

    if ( ac != 3 )
       usage();
/*
  Assign a channel to the specified device.
*/
    d_dev[0] = strlen(av[1]);
    d_dev[1] = av[1];
    status = sys$assign( d_dev, &chan, 0, 0 );
    if ( !(status & 1) )
        lib$stop( status );
/*
  convert the UIC for our use
*/
    sscanf( av[2], "[%o,%o]", &grp, &mem );
    uic = (grp << 16) | mem;
/*
  Initialize the File Information Block used by the XQP
*/
    d_fib[0] = sizeof(fib);
    d_fib[1] = &fib;
    
    memset( &fib, 0, sizeof(fib) );
    fib.fib$r_exctl_overlay.fib$w_exctl = FIB$C_EXA_QUOTA;
/*
  Initialize the quota file transfer blocks.
*/
    memset( &in_quota, 0, sizeof(in_quota) );
    d_in[0] = sizeof(in_quota);
    d_in[1] = &in_quota;
    
    in_quota.uic = uic;
    
    memset( &out_quota, 0, sizeof(out_quota) );
    d_out[0] = sizeof(out_quota);
    d_out[1] = &out_quota;
/*
  Fetch the disk quota for the specified UIC
*/
    status = sys$qiow( 0, chan, IO$_ACPCONTROL, iosb, 0, 0, 
					d_fib, d_in, &outlen, d_out, 0, 0 );
    if ( (status & 1) )
       status = iosb[0];
    if ( !(status & 1) )
       lib$stop( status );
/*
  Display the Quota information.
*/
    printf( "[%o,%o] Usage:%d PermQuota:%d Overdraft:%d\n",
       ((out_quota.uic >> 16) & 0x0000ffff),
       (out_quota.uic & 0x0000ffff),
       out_quota.usage,
       out_quota.permquota,
       out_quota.overdraft );
/*
  Free the channel.
*/    
    status = sys$dassgn( chan );
    if ( !(status & 1) )
        lib$stop( status );
}

-- 
|                                       Bob Harris
|
|   "I don't get to tell me What to do, I only get to tell me How to do it."
|      Comments expressed here are my own and _NOT_ those of my employer.


