/**
 * @file   SCFCULST.c
 * @brief  Sample program in c to run FLUC-UTIL to list files
 * @author limes datentechnik gmbh
 ******************************************************************************/

/* defines code page for literals for IBM mainframes to German */
#ifdef __ZOS__
#  pragma convert(1141)
#endif

#include<stdio.h>
#include<stdlib.h>

#include"FLUCUP.h"

/**
 * This test program takes a file name pattern with wildcards from
 * command line to list the corresponding file. This can for example be
 * used to find all directories or libraries containing a certain member.
 *
 * @param argc must be 2
 * @param argv[1] contains the file name pattern
 * @return flucup error
 */
int main(int argc, char * argv[])
{
   unsigned int         i;
   char                 acCmd[1024];

/* defines environment variable LANG to German EBCDIC for IBM mainframes */
#ifdef __ZOS__
   __setenv("LANG","de_DE.IBM-1141",1);
#endif

   if (argc!=2) {
      fprintf(stderr,"This program list files based on a provided wildcard pattern\n");
      fprintf(stderr,"Parameter count (%d) not correct (2) to run this sample program\n",argc);
      fprintf(stderr,"Given parameter:\n");
      for (i=0;i<argc;i++) fprintf(stderr,"--> P%2.2u(%s)\n",i,argv[i]);
      fprintf(stderr,"Required parameter:\n");
      fprintf(stderr,"   :> %s \"filenamepattern\"\n",argv[0]);
      fprintf(stderr,"\n");
      exit(20);
   }
   snprintf(acCmd,sizeof(acCmd),"run.list='%s'",argv[1]);
   return(flucutil(acCmd,NULL,":STDERR",NULL));
}

/******************************************************************************/

