/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#ifndef _PTFUN5_H_
#define _PTFUN5_H_

typedef int(*funcHandle)(float, int);

int def_func1(float f, int i);
int def_func2(float f, int i);
int def_func3(float f, int i);

int ptfun5_setHandle(funcHandle);
funcHandle ptfun5_getHandle(int i);
void ptfun5_call_it();


/* added for Ch */

#include <dlfcn.h>
void *_Chptfun_handle = dlopen("libptfun.dl", RTLD_LAZY);
if(_Chptfun_handle== NULL) {
   printf("Error: %s(): dlopen(): %s\n", __func__, dlerror());
   exit(-1);
} 

/* initialize and set static function pointer array */
void *_fptr = dlsym(_Chptfun_handle, "ptfun5_setgetHandles_init");
if(_fptr == NULL)  {
   printf("Error: %s(): dlsym(): %s\n", __func__, dlerror());
   exit(-1);
}
dlrunfun(_fptr, NULL, NULL);

/* to close dl */
void _dlclose_ptfun5(void) {
   dlclose(_Chptfun_handle);
}
atexit(_dlclose_ptfun5);

#pragma importf "ChProcDefault.chf"
#pragma importf "ptfun5.chf" 

#endif /* _PTFUN5_H_ */
