/***********************************************************************/
/*                                                                     */
/*                                 GALAX                               */
/*                            XML Query Engine                         */
/*                                                                     */
/*  Copyright 2000, Lucent Technologies.                               */
/*  Distributed only by permission.                                    */
/*                                                                     */
/***********************************************************************/

/* $Id: glx_main_cpp.C,v 1.1 2002/10/12 00:33:30 simeon Exp $ */

/* A sample C++ client for the Caml functions */

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

#include "glx_CPP.h"

int main(int argc, char ** argv)
{
  char * result;
  paramlist params = NULL;

  /* Initialize Caml code */
  glx_init(argv);
  /* Do some computation */
  /*  result = fib(10); */

  fprintf(stderr,"Empty test: %i\n\n",is_empty(create_empty()));

#ifdef DEBUG
  fprintf(stderr,"Printing C Parameters\n");
#endif

  /* TEST 1 : succeeds with one answer */

  params = create_cons("\"Data on the Web\"",create_empty());

  params_print(params);
#ifdef DEBUG
  fprintf(stderr,"C Parameters printed\n\n");
#endif

  result = glx_eval_xquery_fun_from_file("glx_test2.xq","selectbook",params);
  printf("result is = %s\n", result);

  /* TEST 2 : succeeds with no answer */

  params = create_cons("\"Data on the We\"",create_empty());

  params_print(params);
#ifdef DEBUG
  fprintf(stderr,"C Parameters printed\n\n");
#endif

  result = glx_eval_xquery_fun_from_file("glx_test2.xq","selectbook",params);
  printf("result is = %s\n", result);

  /* TEST 3 : fails at compile time: wrong number of parameters for the function */

  params = create_cons("toto",create_cons("\"Data on the Web\"",create_empty()));

  params_print(params);
#ifdef DEBUG
  fprintf(stderr,"C Parameters printed\n\n");
#endif
  
  result = glx_eval_xquery_fun_from_file("glx_test2.xq","selectbook",params);
  printf("result is = %s\n", result);

  return 0;
}
