/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#include <dlfcn.h>
return_type setFuncVNA(return_type2 (*pf)(int num, ...)) {
  void *dlhandle, *fptr;
  return_type retval;

  dlhandle = dlopen("libproject.dl", RTLD_LAZY);
  if(dlhandle == NULL) {
    printf("Error: %s(): dlopen(): %s\n", __func__, dlerror());
    return FAIL_VALUE; /* FAIL_VALUE is typically NULL for point
                          and negative value for integral type */
  }

  fptr = dlsym(dlhandle, "setFuncVNA_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __func__, dlerror());
     return FAIL_VALUE;
  }

  dlrunfun(fptr, &retval, setFuncVNA, pf);

  if(dlclose(dlhandle)!=0) {
    printf("Error: %s(): dlclose(): %s\n", __func__, dlerror());
    return FAIL_VALUE;
  }
  return retval;
}
