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

  program: dirf.c
  author:  Lars Ottemoeller
  purpose: write list of files from list
           of arguments to file 'filenr.lis'
  date:    24 March 2000

  changes:
           
*******************************************/

#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>

main (int argc,char *argv[]) {
  int counter;                  /* counter */
  FILE *fil;

/* open file */
  fil = fopen("filenr.lis","w");
  if (fil==NULL) {
    printf("Fail to open filenr.lis \n");
    return(0);    
  }

/* write all arguments to filenr.lis */
  for (counter = 1;counter<argc;++counter) {
/* maximum of 9999 files */
    if (counter > 9999) 
    {
      printf(" Maximum is 9999 files \n");
      fclose(fil);
      return(0);
    }
    if (counter <= 999) {
      printf(" #%3d  %-70s\n",counter,argv[counter]);
      fprintf(fil," #%3d  %-70s\n",counter,argv[counter]);
    } else {
      printf("#%4d  %-70s\n",counter,argv[counter]);
      fprintf(fil,"#%4d  %-70s\n",counter,argv[counter]);
    }
  }
/* print blank line */
  fprintf(fil,"\n");

/* close file */
  fclose(fil);
  return(0);
}


