// cGetFNamesBckp.c

#include <stdio.h>
#include "GetFNamesBckp_stub.h"

extern void __stginit_GetFNamesBckp(void);

int main( int argc, char** argv)
{
  char* vsBaseDir = NULL;
  char** vsBaseDirs = NULL;
  char** vsNamesToZip = NULL;
  char** it = NULL;
  
  fprintf( stderr, "coucou0\n" );
  startupHaskell(argc, argv, __stginit_GetFNamesBckp);
  
  /* I did ugly explicit mallocs here because I was affraid
     to give memory on the C stack to Haskell. I thought the
     problem was coming from dangling pointers somewhere */
  vsBaseDirs = (char**) malloc(sizeof(char*));
  vsBaseDir = ( char* ) malloc( strlen("/") + 1 );
  strcpy( vsBaseDir, "/" );
  vsBaseDirs[0] = vsBaseDir; 
  
  fprintf( stderr, "coucou1\n" );
  vsNamesToZip = getFNamesToZipC(1, vsBaseDirs);
  fprintf( stderr, "coucou2\n" );
  for( it = vsNamesToZip; strcmp(*it, "//") != 0; it++ )
    printf("%s\n", *it);
  fprintf( stderr, "coucou3\n" );
  shutdownHaskell();
  fprintf( stderr, "coucou4\n" );
  return 0;
}
