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

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

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

#include <stdio.h>

#include "glx.h"

int main(int argc, char ** argv)
{

  char *fake_argv[2];

  char * result;
  paramlist params = NULL;

  fake_argv[0] = "caml";
  fake_argv[1] = 0;

  /* Initialize Caml code */
  glx_init(fake_argv);

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

  result = glx_eval_xquery_from_file("glx_test1.xq");

  printf("result is = %s\n", result);

  /* 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 3 : fails at compile time: wrong number of parameters for the function */

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

  /* TEST 4 : Boolean value */

  params = 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","test",params);
  printf("result is = %s######", result);  

  return 0;
}
