/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* file name list_chdl.cpp */

#include <ch.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include "list_cpp.h"


EXPORTCH class List *List_List_chdl(void) {
  ChInterp_t interp;
  class List*c=new List();
  return c;
}

EXPORTCH void List_dList_chdl(void *varg) {
  ChInterp_t interp;
  va_list ap;
  class List *c;

  Ch_VaStart(interp, ap, varg);
  c = Ch_VaArg(interp, ap, class List*);
  delete c;
  Ch_VaEnd(interp, ap);
}

EXPORTCH void List_prepend_chdl(void *varg) {
  ChInterp_t interp;
  va_list ap;
  int ssn;
  //string fname, lname;
  char *fname, *lname;
  class List *c;

  Ch_VaStart(interp, ap, varg);
  c = Ch_VaArg(interp, ap, class List*); 
  ssn = Ch_VaArg(interp, ap, int);         /* get 1st arg  */
  fname = Ch_VaArg(interp, ap, char *);  /* get 2nd arg  */
  lname = Ch_VaArg(interp, ap, char *);
  c->prepend(ssn, fname, lname);

  Ch_VaEnd(interp, ap);
}

EXPORTCH void List_print_chdl(void *varg) {
  ChInterp_t interp;
  va_list ap;
  class List *c;

  Ch_VaStart(interp, ap, varg);
  c = Ch_VaArg(interp, ap, class List*); 
  c->print();
  Ch_VaEnd(interp, ap);

}

EXPORTCH int List_remove_chdl(void *varg) {
  ChInterp_t interp;
  va_list ap;
  int ssn;
  class List *c;
  int retval;
  
  Ch_VaStart(interp, ap, varg);
  c = Ch_VaArg(interp, ap, class List*); 
  ssn = Ch_VaArg(interp, ap, int);
  retval = c->remove(ssn);
  Ch_VaEnd(interp, ap);
  return retval;
}
