/* 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 <string.h>
#include <descrip.h>
#include <ssdef.h>

long sys$asctoid();
long sys$find_held();
long sys$idtoasc();

main(int argc,char *argv[])
{
   long stat,uic[2],id,cntx;
   short idlen;
   char idnam[32];
   $DESCRIPTOR(undesc,"");
   $DESCRIPTOR(iddesc,idnam);
   undesc.dsc$a_pointer = argv[1];
   undesc.dsc$w_length = strlen(argv[1]);
   stat = sys$asctoid(&undesc,uic,0);
   uic[1] = 0;
   cntx = 0;
   do {
      stat = sys$find_held(uic,&id,0,&cntx);
      if(stat==SS$_NORMAL) {
         stat = sys$idtoasc(id,&idlen,&iddesc,0,0,0);
         idnam[idlen] = '\0';
         printf("%X=%s\n",id,idnam);
      }
   } while(stat==SS$_NORMAL);
}
