/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/***********************************
* Filename - callch_chdl.c
* Call Ch function chfun() through three methods
************************************/

#include<ch.h>
#include<stdio.h>

EXPORTCH void callch_chdl(void *varg) {
  ChInterp_t interp;
  ChVaList_t ap;
  void *chfunhandle;
  int funret;
 
  Ch_VaStart(interp, ap, varg); 
  /* Method 1: get address of ch function and call it */
  chfunhandle = Ch_GlobalSymbolAddrByName(interp, "chfun");
  Ch_CallFuncByAddr(interp, chfunhandle, &funret, 10);
  printf("after Method 1, return value is %d\n\n", funret); 

  /* Method 2: call ch function by its name */
  Ch_CallFuncByName(interp, "chfun", &funret, 20);
  printf("after Method 2, return value is %d\n\n", funret); 

  Ch_VaEnd(interp, ap);
  return;
}
