From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM"  7-AUG-1993 13:32:37.66
To:	EVERHART
CC:	
Subj:	Re: VAXC and sys$getquiw or lib$getqui

Date: Sat, 07 Aug 1993 16:02:16 +0100
From: Arne Vajhøj <ARNE@kopc.hhs.dk>
Subject: Re: VAXC and sys$getquiw or lib$getqui
To: bamon@OCVAXC.CC.OBERLIN.EDU, INFO-VAX@SRI.COM
Message-id: <01H1GX2YU23S9LVCX6@kopc.hhs.dk>
X-VMS-To: KOPC::IN%"bamon@OCVAXC.CC.OBERLIN.EDU"
X-VMS-Cc: IN::"INFO-VAX@SRI.COM"
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=ISO-8859-1
Content-transfer-encoding: 8BIT

> I hate reinventing the wheel. I need to be able to loop through the
> jobs in a given queue. To make sure that everything that's supposed
> to be in the queue is indeed in the queue. I'm using C.
> 
> Does anybody have an example of using SYS$GETQUIW or LIB$GETQUI from
> VAXC?

Small example program:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <prvdef.h>
#include <quidef.h>

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

long sys$setprv();
long sys$getquiw();

main(int argc,char *argv[])
{
   long stat,iosb[2],ne,ent[1000],i;
   short jnl,unl;
   char qname[33],jn[33],un[13];
   long flag1 = QUI$M_SEARCH_WILDCARD;
   long flag2 = QUI$M_SEARCH_ALL_JOBS;
   long priv[2] = { PRV$M_OPER,0 };
   struct itemlist quilist1[3] = { {sizeof(qname)-1,QUI$_SEARCH_NAME,&qname,0} ,
                                   {sizeof(flag1),QUI$_SEARCH_FLAGS,&flag1,0} ,
                                   {0,0,0,0} };
   struct itemlist quilist2[3] = { {sizeof(long),QUI$_ENTRY_NUMBER,0,0} ,
                                   {sizeof(flag2),QUI$_SEARCH_FLAGS,&flag2,0} ,
                                   {0,0,0,0} };
   struct itemlist quilist3[4] = { {sizeof(jn)-1,QUI$_JOB_NAME,&jn,&jnl} ,
                                   {sizeof(un)-1,QUI$_USERNAME,&un,&unl} ,
                                   {sizeof(ent[0]),QUI$_SEARCH_NUMBER,
                                    &ent[0],0} ,
                                   {0,0,0,0} };
   stat = sys$setprv(1,priv,0,0);
   stat = sys$getquiw(0,QUI$_CANCEL_OPERATION,0,0,iosb,0,0);
   strcpy(qname,argv[1]);
   quilist1[0].buflen = strlen(qname);
   stat = sys$getquiw(0,QUI$_DISPLAY_QUEUE,0,quilist1,iosb,0,0);
   ne = 0;
   while (1) {
      quilist2[0].bufadr = &ent[ne];
      stat = sys$getquiw(0,QUI$_DISPLAY_JOB,0,quilist2,iosb,0,0);
      if ((stat&1)!=1) break;
      if ((iosb[0]&1)!=1) break;
      ne++;
   };
   for (i=0;i<ne;i++) {
      quilist3[2].bufadr = &ent[i];
      stat = sys$getquiw(0,QUI$_DISPLAY_ENTRY,0,quilist3,iosb,0,0);
      jn[jnl] = '\0';
      un[unl] = '\0';
      printf("%d %s %s\n",ent[i],jn,un);
   };
};

Hope it helps !

                                                          Arne

Arne Vajhøj                             local DECNET:  KO::ARNE
Computer Department                     PSI:           PSI%238310013040::ARNE
Business School of Southern Denmark     Internet:      ARNE@KO.HHS.DK


