/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#ifndef _EXPVAR_H_
#define _EXPVAR_H_

int i1;

/* load DLL */
#include <dlfcn.h>
void *_ChExpvar_handle = dlopen("libexpvar.dl", RTLD_LAZY);
if(_ChExpvar_handle == NULL) {
     fprintf(_stderr, "Error: %s(): dlopen(): %s\n", __func__, dlerror());
     fprintf(_stderr, "       cannot get _ChExpvar_handle in expvar.h\n");
     exit(-1);
  }

/* release DLL when program exits */
void _dlclose_expvar(void) {
    dlclose(_ChExpvar_handle);
}
atexit(_dlclose_expvar);

/* Get addresses of global variables in C space */
void *fptr_expvar_h = dlsym(_ChExpvar_handle , "expvar_chdl");
if(fptr_expvar_h == NULL) {
     printf("Error: %s(): dlsym(): %s\n", __func__, dlerror());
}
dlrunfun(fptr_expvar_h, NULL, NULL, &i1);

#endif
