/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>

#include <prvdef.h>
#include <uaidef.h>
#include <descrip.h>
#include <starlet.h>

struct itemlist {
                short buflen,code;
                long *bufadr,*retlenadr;
                };

int main()
{
   long stat,id,resid,cntx,pgflq;
   short unl;
   char un[33];
   $DESCRIPTOR(undesc,un);
   long priv[2] = { PRV$M_SYSPRV,0 };
   struct itemlist uailist[2] = { {sizeof(pgflq),UAI$_PGFLQUOTA,&pgflq,0} ,
                                  {0,0,0,0} };
   stat = sys$setprv(1,priv,0,0);
   id = -1;
   cntx = 0;
   while (1) {
      undesc.dsc$w_length = sizeof(un);
      stat = sys$idtoasc(id,&unl,&undesc,&resid,0,&cntx);
      if ((stat&1)!=1) break;
      un[unl] = '\0';
      if (resid>0) {
         undesc.dsc$w_length = unl;
         stat = sys$getuai(0,0,&undesc,uailist,0,0,0);
         if ((stat&1)==1) printf("%s %d\n",un,pgflq);
      }
   }
}
