/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
#include <stdio.h>
#include "ptfun5_c.h"

funcHandle def_handle  = NULL;

int ptfun5_setHandle(funcHandle funptr)  {
  def_handle = funptr;
  /* Call Ch function from C space */
  printf("Calling function from C space: return value is %d\n\n", 
          funptr(1.1, 1));
  return 0;
}

funcHandle ptfun5_getHandle(int num)  {
  switch (num) {
    case 1 :
      return def_func1;
    case 2 :
      return def_func2;
    case 3 :
      return def_func3;
    default:
      return NULL;
  }
}

void ptfun5_call_it() {
  if(def_handle != NULL)
    (*def_handle)(1.1, 2);
  else {
    printf("No default C function has been set\n");
  }
}

/* the default callback functions in c space */
int def_func1(float f, int i) {
  printf("in def_func1, f = %f, i = %i\n\n", f, i);
  return 0;
}

int def_func2(float f, int i) {
  printf("in def_func2, f = %f, i = %i\n\n", f, i);
  return 0;
}

int def_func3(float f, int i) {
  printf("in def_func3, f = %f, i = %i\n", f, i);
  return 0;
}

