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

void (*getFunction1(data_type1 arg1))() {
  void *dlhandle, *fptr;
  void (*retval)();

  dlhandle = dlopen("libproject.dl", RTLD_LAZY);
  if(dlhandle == NULL) {
    printf("Error: %s(): dlopen(): %s\n", __func__, dlerror());
    return NULL;
  }
  fptr = dlsym(dlhandle, "getFunction1_chdl");
  if(fptr == NULL) {
    printf("Error: %s(): dlsym(): %s\n", __func__, dlerror());
    return NULL;
  }

  /* call the chdl function in dynamically loaded library by address */
  dlrunfun(fptr, &retval, getFunction1, arg1);

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

  return retval;
}
