xp_comm_proj/build3d_2/build3d_2.c
/*----------------------------------------------------------------------
 * given an access variable loads the appropriate shared library if
 * necessary and then sets the function pointers.
 * "NO_DL_LOAD" means we don't do the dynamic library/dll open and
 * lookup but just set the function pointers from an assumed-to-be
 * filled-in table
 */
given an access variable loads the appropriate shared library if
necessary and then sets the function pointers.
"NO_DL_LOAD" means we don't do the dynamic library/dll open and
lookup but just set the function pointers from an assumed-to-be
filled-in table
given an access variable loads the appropriate shared library if necessary and then sets the function pointers . " NO_DL_LOAD " means we don ' t do the dynamic library / dll open and lookup but just set the function pointers from an assumed - to - be filled - in table
static int FUNCget_image_funcs(void *access)
{
#ifndef NO_DL_LOAD
  char **info = (char **) access;
#else
  funcs_t *funcs = (funcs_t *) access;
#endif
#ifndef NO_DL_LOAD
#ifdef sol1
  {
    char pathbuf[AVS_PATH_MAX], *pathdir, *libname;
    pathdir = FILEmap_variables("$XP_PATH<0>/lib/$MACHINE", pathbuf);
    if ((strlen(pathdir) + strlen(info[LIBNAME]) + 2) >= AVS_PATH_MAX)
      libname = malloc(strlen(pathdir) + strlen(info[LIBNAME]) + 2);
    else
      libname = pathbuf;
    sprintf(libname, "%s/%s", pathdir, info[LIBNAME]);
    DL_OPEN(libname, DL_BIND, handle);
    if (libname != pathbuf)
      free(libname);
  }
#else
  if (info[LIBNAME] != NULL)
    DL_OPEN(info[LIBNAME], DL_BIND, handle);
  else
    return(FUNCread_wrapup("No library name to load?", NULL));
#endif
  if (handle == NULL)
  {
    char err[512];
#if defined(hpux) || defined(__hpux)
    const char *libpath = "SHLIB_PATH";
#else
#ifdef MSDOS
    const char *libpath = "PATH";
    DWORD last_err = GetLastError();
#else
    const char *libpath = "LD_LIBRARY_PATH";
#endif
#endif
    sprintf(err, "Cannot open library '%s'.  Most likely cause is an unset or incorrectly set '%s' environment variable: please see the System Prerequisites Document.  The system error message is:\n'%s'\n", info[LIBNAME], libpath, DL_ERROR());
#ifdef MSDOS
    sprintf(err, "%s and GetLastError number is %d", err, last_err);
#endif
    return(FUNCread_wrapup(err, NULL));
  }
#endif
#ifndef NO_DL_LOAD
  DL_LOOKUP(handle, info[OPEN_FUNC], void *(*)(), funcOpen);
  if (funcOpen == NULL)
    return(FUNCread_wrapup("Cannot find Open function in library", NULL));
  DL_LOOKUP(handle, info[CLOSE_FUNC], void *(*)(), funcClose);
  if (funcClose == NULL)
    return(FUNCread_wrapup("Cannot find Close function in library", NULL));
  DL_LOOKUP(handle, info[GETWIDTH_FUNC], void *(*)(), funcGetWidth);
  if (funcGetWidth == NULL)
    return(FUNCread_wrapup("Cannot find GetWidth function in library", NULL));
  DL_LOOKUP(handle, info[GETHEIGHT_FUNC], void *(*)(), funcGetHeight);
  if (funcGetHeight == NULL)
    return(FUNCread_wrapup("Cannot find GetHeight function in library", NULL));
  DL_LOOKUP(handle, info[GETARGB_FUNC], void *(*)(), funcGetARGBImage);
  if (funcGetARGBImage == NULL)
    return(FUNCread_wrapup("Cannot find GetARGBImage function in library", NULL));
#else
  funcOpen = (void *(*)()) funcs->Open;
  funcClose = (void *(*)()) funcs->Close;
  funcGetWidth = (void *(*)()) funcs->GetWidth;
  funcGetHeight = (void *(*)()) funcs->GetHeight;
  funcGetARGBImage = (void *(*)()) funcs->GetARGBImage;
#endif
  return(1);
}
static int FUNCget_image_funcs ( void * access ) { #ifndef NO_DL_LOAD char * * info = ( char * * ) access ; #else funcs_t * funcs = ( funcs_t * ) access ; #endif #ifndef NO_DL_LOAD #ifdef sol1 { char pathbuf [ AVS_PATH_MAX ] , * pathdir , * libname ; pathdir = FILEmap_variables ( " " , pathbuf ) ; if ( ( strlen ( pathdir ) + strlen ( info [ LIBNAME ] ) + 2 ) >= AVS_PATH_MAX ) libname = malloc ( strlen ( pathdir ) + strlen ( info [ LIBNAME ] ) + 2 ) ; else libname = pathbuf ; sprintf ( libname , " " , pathdir , info [ LIBNAME ] ) ; DL_OPEN ( libname , DL_BIND , handle ) ; if ( libname != pathbuf ) free ( libname ) ; } #else if ( info [ LIBNAME ] != NULL ) DL_OPEN ( info [ LIBNAME ] , DL_BIND , handle ) ; else return ( FUNCread_wrapup ( " " , NULL ) ) ; #endif if ( handle == NULL ) { char err [ 512 ] ; #if defined ( hpux ) || defined ( __hpux ) const char * libpath = " " ; #else #ifdef MSDOS const char * libpath = " " ; DWORD last_err = GetLastError ( ) ; #else const char * libpath = " " ; #endif #endif sprintf ( err , " \n \n " , info [ LIBNAME ] , libpath , DL_ERROR ( ) ) ; #ifdef MSDOS sprintf ( err , " " , err , last_err ) ; #endif return ( FUNCread_wrapup ( err , NULL ) ) ; } #endif #ifndef NO_DL_LOAD DL_LOOKUP ( handle , info [ OPEN_FUNC ] , void * ( * ) ( ) , funcOpen ) ; if ( funcOpen == NULL ) return ( FUNCread_wrapup ( " " , NULL ) ) ; DL_LOOKUP ( handle , info [ CLOSE_FUNC ] , void * ( * ) ( ) , funcClose ) ; if ( funcClose == NULL ) return ( FUNCread_wrapup ( " " , NULL ) ) ; DL_LOOKUP ( handle , info [ GETWIDTH_FUNC ] , void * ( * ) ( ) , funcGetWidth ) ; if ( funcGetWidth == NULL ) return ( FUNCread_wrapup ( " " , NULL ) ) ; DL_LOOKUP ( handle , info [ GETHEIGHT_FUNC ] , void * ( * ) ( ) , funcGetHeight ) ; if ( funcGetHeight == NULL ) return ( FUNCread_wrapup ( " " , NULL ) ) ; DL_LOOKUP ( handle , info [ GETARGB_FUNC ] , void * ( * ) ( ) , funcGetARGBImage ) ; if ( funcGetARGBImage == NULL ) return ( FUNCread_wrapup ( " " , NULL ) ) ; #else funcOpen = ( void * ( * ) ( ) ) funcs -> Open ; funcClose = ( void * ( * ) ( ) ) funcs -> Close ; funcGetWidth = ( void * ( * ) ( ) ) funcs -> GetWidth ; funcGetHeight = ( void * ( * ) ( ) ) funcs -> GetHeight ; funcGetARGBImage = ( void * ( * ) ( ) ) funcs -> GetARGBImage ; #endif return ( 1 ) ; }
given an access variable loads the appropriate shared library if
 necessary and then sets the function pointers.
given an access variable loads the appropriate shared library if necessary and then sets the function pointers .
/* open the lib */ /* SunOS4 wants an absolute path and doesn't pay attention to LD_LIBRARY_PATH
   * it seems... get a path to the lib directory and glue it to front of
   * library name
   */ /* lookup the Image access functions */