/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* File name vararg.chf 
   function file for sample function vararg()
*/
#include<dlfcn.h>
#include<stdarg.h>
#include<stdio.h>

void vfunc(int ii, va_list ap) {
    void *fptr, *handle;

    handle = dlopen("libvararg.dl", RTLD_LAZY);
    if(handle == NULL) {
      printf("Error: %s(): dlopen(): %s\n", __func__, dlerror());
      return;
    } 

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

    dlrunfun(fptr, NULL, NULL, ii, ap);

    if(dlclose(handle)!=0) {
       fprintf(stderr, "Error: %s(): dlclose(): %s\n", __func__, dlerror());
       return;
    }
    return;
}
