/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#include<dlfcn.h>

return_type3 setFunction6(data_type3 arg3, struct s_t *arg4) {
  void *dlhandle, *fptr;
  return_type3 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, "setFunction6_chdl");
  if(fptr == NULL) {
    printf("Error: %s(): dlsym(): %s\n", __func__, dlerror());
    return FAIL_VALUE;
  }

  /* call the chdl function in dynamically loaded library by address,
     arguments including pointer to the struct are passed */ 
  dlrunfun(fptr, &retval, setFunction6, arg3, arg4);

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