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

typedef void(*funcHandle)();
int ptfun1_2_setHandle(int num, funcHandle funptr);
funcHandle ptfun1_2_getHandle(int num);

/* below is added only 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, "ptfun1_2_setgetHandles_init");
if(_fptr == NULL)  {
   printf("Error: %s(): dlsym(): %s\n", __func__, dlerror());
   exit(-1);
}
dlrunfun(_fptr, NULL, NULL);

/* usr-defined function which is called to close DLL 
   when the program exits */
void _dlclose_ptfun1_2(void) {
   dlclose(_Chptfun_handle);
}
atexit(_dlclose_ptfun1_2);

#pragma importf <ptfun1_2.chf>
#endif /* _PTFUN1_2_H_ */
