/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#include<ch.h>
    ...

EXPORTCH void functionName_chdl(void *varg) {
  ChInterp_t interp;
  ChVaList_t ap;

  int count;
  data_type  param;
  data_type1 arg1;
  data_type2 arg2;
  data_type3 arg3;

  Ch_VaStart(interp, ap, varg);
  /* get the firat argument */
  param = Ch_VaArg(interp, ap, data_type); 

  /* get num of arguments from the Ch function */
  count = Ch_VaCount(interp, ap); 
  
  if(count == 0)
    functionName(param);

  if(count >= 1) {
    arg1 = Ch_VaArg(interp, ap, data_type1);
    if(count == 1) 
      functionName(param, arg1);
  }

  if(count >= 2) {
    arg2 = Ch_VaArg(interp, ap, data_type2);
    if(count == 2) 
      functionName(param, arg1, arg2);
  }
  
  if(count == 3) {
    arg3 = Ch_VaArg(interp, ap, data_type3);
    functionName(param, arg1, arg2, arg3); 
  }

  Ch_VaEnd(interp, ap);
}
