/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/****** member functions of Class1 ******/
Class1::Class1(){
  void *fptr;

  fptr = dlsym(g_sample_dlhandle, "Class1_Class1_chdl");
  if(fptr == NULL)  {
    printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
    return;
  }
  dlrunfun(fptr, NULL, NULL);
}

Class1::~Class1() {
  void *fptr;
  fptr = dlsym(g_sample_dlhandle, "Class1_dClass1_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return;
  }

  dlrunfun(fptr, NULL, NULL, this);
}

int Class1::memfun1(int i) {
  void *fptr;
  int retval;

  fptr = dlsym(g_sample_dlhandle, "Class1_memfun1_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return -1;
  }

  dlrunfun(fptr, &retval, memfun1, this, i);
  return retval;
}

/****** member functions of Class2 ******/

Class2::Class2(){
  void *fptr;
 
  fptr = dlsym(g_sample_dlhandle, "Class2_Class2_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return;
  }
  dlrunfun(fptr, NULL, NULL);
}

Class2::~Class2() {
  void *fptr;
  fptr = dlsym(g_sample_dlhandle, "Class2_dClass2_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return;
  }
  dlrunfun(fptr, NULL, NULL, this);
}

void Class2::memfun1(Class1 *pc) {
  void *fptr;

  fptr = dlsym(g_sample_dlhandle, "Class2_memfun1_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return;
  }

  dlrunfun(fptr, NULL, memfun1, this, pc);
  return;
}

Class1 *Class2::memfun2(int i) {
  void *fptr;
  Class1 *retval;

  fptr = dlsym(g_sample_dlhandle, "Class2_memfun2_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return NULL;
  }

  dlrunfun(fptr, &retval, memfun2, this, i);
  return retval;
}

Class1 *Class2::memfun3(int i, Class1 **ppc) {
  void *fptr;
  Class1 *retval;

  fptr = dlsym(g_sample_dlhandle, "Class2_memfun3_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return NULL;
  }

  dlrunfun(fptr, &retval, memfun3, this, i, ppc);
  return retval;
}

int Class2::memfun4(Class1 *apc[NUM]) {
  void *fptr;
  int retval;

  fptr = dlsym(g_sample_dlhandle, "Class2_memfun4_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return NULL;
  }

  dlrunfun(fptr, &retval, NULL, this, apc);
  return retval;
}

int Class2::memfun5(int num, Class1 c[NUM]) {
  void *fptr;
  int retval;

  fptr = dlsym(g_sample_dlhandle, "Class2_memfun5_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return NULL;
  }

  dlrunfun(fptr, &retval, NULL, this, num, c);
  return retval;
}

