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

#define $VDESCRIPTOR(name,string) struct dsc$descriptor_vs name = \
                                  { sizeof(string.BODY)-1, DSC$K_DTYPE_VT, \
                                    DSC$K_CLASS_VS, (char *)&string }

int lib$find_file();
int lib$find_file_end();

main()
{
   int context = 0;
   int status;
   char *s;
   char find[]="*.c";
   $DESCRIPTOR(finddesc,find);
   struct {
          short LENGTH;
          char BODY[256];
          } result;
   $VDESCRIPTOR(resultdesc,result);
   do {
      status = lib$find_file(&finddesc,&resultdesc,&context,0,0,0,0);
      if (status == RMS$_NORMAL) {
         result.BODY[result.LENGTH] = '\0';
         printf("%s\n",result.BODY);
      };
   } while (status == RMS$_NORMAL);
   lib$find_file_end(&context);
   return SS$_NORMAL;
}
