#include <stdio.h>
#include <descrip.h>
#include <lbrdef.h>
#include <ssdef.h>
#include <string.h>

long lbr$ini_control();
long lbr$open();
long lbr$get_index();
long lbr$close();

int doit(struct dsc$descriptor_s *key,long rfa[2])
{
   char tmp[80];
   memcpy(&tmp,key->dsc$a_pointer,key->dsc$w_length);
   tmp[key->dsc$w_length] = '\0';
   printf("%s\n",tmp);
   return SS$_NORMAL;
}

void text_lookup(struct dsc$descriptor_s *tlbdesc)
{
   long c1 = LBR$C_READ, c2 = LBR$C_TYP_TXT, c3 = 1;
   long stat,libix;
   stat = lbr$ini_control(&libix,&c1,&c2);
   stat = lbr$open(&libix,tlbdesc,0,0,0,0,0);
   stat = lbr$get_index(&libix,&c3,doit,0);
   stat = lbr$close(&libix);
   return;
}

main()
{
   $DESCRIPTOR(tlbdesc,"SYS$LIBRARY:FORSYSDEF.TLB");
   text_lookup(&tlbdesc);
}
