/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#include <dlfcn.h>
return_type setarrayfunc(int n, return_type2 (*func[])(data_type arg)) {
  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, "setarrayfunc_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __func__, dlerror());
     return FAIL_VALUE;
  }

  dlrunfun(fptr, &retval, setarrayfunc, n, func);

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