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

typedef int (*funcHandle)(); /* return a int */
int ptfun2_setHandle(int num, funcHandle funptr);
funcHandle ptfun2_getHandle(int num);

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

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

#pragma importf <ptfun2.chf>
#endif /* _PTFUN2_H_ */
