char * plFindCommand(char *fn) { char *fs = NULL, *dn; /* PLPLOT_BIN_ENV = $(PLPLOT_BIN) */ #if defined(PLPLOT_BIN_ENV) if ((dn = getenv(PLPLOT_BIN_ENV)) != NULL) { plGetName(dn, "", fn, &fs); if ( ! plFindName(fs)) return fs; fprintf(stderr, PLPLOT_BIN_ENV"=\"%s\"\n", dn); /* what IS set? */ } #endif /* PLPLOT_BIN_ENV */ /* Current directory */ plGetName(".", "", fn, &fs); if ( ! plFindName(fs)) return fs; /* PLPLOT_HOME_ENV/bin = $(PLPLOT_HOME)/bin */ #if defined(PLPLOT_HOME_ENV) if ((dn = getenv(PLPLOT_HOME_ENV)) != NULL) { plGetName(dn, "bin", fn, &fs); if ( ! plFindName(fs)) return fs; fprintf(stderr, PLPLOT_HOME_ENV"=\"%s\"\n",dn); /* what IS set? */ } #endif /* PLPLOT_HOME_ENV */ /* BIN_DIR */ #if defined (BIN_DIR) plGetName(BIN_DIR, "", fn, &fs); if ( ! plFindName(fs)) return fs; #endif /* Crapped out */ free_mem(fs); fprintf(stderr, "plFindCommand: cannot locate command: %s\n", fn); #if defined (BIN_DIR) fprintf(stderr, "bin dir=\"" BIN_DIR "\"\n" ); /* what WAS set? */ #endif /* BIN_DIR */ return NULL; }
PDFstrm * plLibOpenPdfstrm(const char *fn) /* pmr: const */ { PDFstrm *file; char *fs = NULL, *dn = NULL; #ifndef WIN32 /* EMBOSS additions to avoid need for PLPLOT_LIB */ static const char *prefix = PREFIX; static const char *top = EMBOSS_TOP; if(!strcmp(prefix,"/usr/local")) { plGetName(prefix, "share/EMBOSS", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; plGetName(top, "plplot/lib", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; } else { plGetName(prefix, "share/EMBOSS", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; } /* End of EMBOSS additions */ #endif /**** search build tree ****/ if (plInBuildTree() == 1) { plGetName(BUILD_DIR, "data", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; } /**** search PLPLOT_LIB_ENV = $(EPLPLOT_LIB) ****/ #if defined(PLPLOT_LIB_ENV) if ((dn = getenv(PLPLOT_LIB_ENV)) != NULL) { plGetName(dn, "", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; fprintf(stderr, PLPLOT_LIB_ENV"=\"%s\"\n", dn); /* what IS set? */ } #endif /* PLPLOT_LIB_ENV */ /**** search current directory ****/ if ((file = pdf_fopen(fn, "rb")) != NULL) goto done; /**** search PLPLOT_HOME_ENV/lib = $(EPLPLOT_HOME)/lib ****/ #if defined (PLPLOT_HOME_ENV) if ((dn = getenv(PLPLOT_HOME_ENV)) != NULL) { plGetName(dn, "lib", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; fprintf(stderr, PLPLOT_HOME_ENV"=\"%s\"\n",dn); /* what IS set? */ } #endif /* PLPLOT_HOME_ENV/lib */ /**** search installed location ****/ #if defined (DATA_DIR) plGetName(DATA_DIR, "", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; #endif /* DATA_DIR */ /**** search hardwired location ****/ #ifdef PLLIBDEV plGetName(PLLIBDEV, "", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; #endif /* PLLIBDEV */ #ifdef macintosh file = plMacLibOpen(fn); if (file != NULL) goto done; #endif /* macintosh */ if (plplotLibDir != NULL) { plGetName(plplotLibDir, "", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; } /**** not found, give up ****/ pldebug("plLibOpenPdfstr", "File %s not found.\n", fn); return NULL; done: /* pldebug("plLibOpenPdfstr", "Found file %s\n", fs); */ free_mem(fs); return (file); }
SHPHandle OpenShapeFile( const char *fn ) { SHPHandle file; char *fs = NULL, *dn = NULL; #ifdef HAVE_SAHOOKS SAHooks sHooks; SASetupDefaultHooks( &sHooks ); sHooks.Error = CustomErrors; #else // Using ancient version of shapelib without SAHooks or SHPOpenLL. // For this case live with the misleading "Unable to open" error // messages. // int sHooks; #define SHPOpenLL( a, b, c ) SHPOpen( a, b ) #endif //*** search build tree *** if ( plInBuildTree() == 1 ) { plGetName( SOURCE_DIR, "data", fn, &fs ); if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL ) goto done; } //*** search PLPLOT_LIB_ENV = $(PLPLOT_LIB) *** #if defined ( PLPLOT_LIB_ENV ) if ( ( dn = getenv( PLPLOT_LIB_ENV ) ) != NULL ) { plGetName( dn, "", fn, &fs ); if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL ) goto done; fprintf( stderr, PLPLOT_LIB_ENV "=\"%s\"\n", dn ); // what IS set? } #endif // PLPLOT_LIB_ENV //*** search current directory *** if ( ( file = SHPOpenLL( fn, "rb", &sHooks ) ) != NULL ) { pldebug( "OpenShapeFile", "Found file %s in current directory.\n", fn ); free_mem( fs ); return ( file ); } //*** search PLPLOT_HOME_ENV/lib = $(PLPLOT_HOME)/lib *** #if defined ( PLPLOT_HOME_ENV ) if ( ( dn = getenv( PLPLOT_HOME_ENV ) ) != NULL ) { plGetName( dn, "lib", fn, &fs ); if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL ) goto done; fprintf( stderr, PLPLOT_HOME_ENV "=\"%s\"\n", dn ); // what IS set? } #endif // PLPLOT_HOME_ENV/lib //*** search installed location *** #if defined ( DATA_DIR ) plGetName( DATA_DIR, "", fn, &fs ); if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL ) goto done; #endif // DATA_DIR //*** search hardwired location *** #ifdef PLLIBDEV plGetName( PLLIBDEV, "", fn, &fs ); if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL ) goto done; #endif // PLLIBDEV //*** not found, give up *** pldebug( "OpenShapeFile", "File %s not found.\n", fn ); free_mem( fs ); return NULL; done: pldebug( "OpenShapeFile", "SHPOpen successfully opened two files with basename %s\n", fs ); free_mem( fs ); return ( file ); }
PDFstrm * plLibOpenPdfstrm(char *fn) { PDFstrm *file; char *fs = NULL, *dn = NULL; /**** search PLPLOT_LIB_ENV = $(PLPLOT_LIB) ****/ #if defined(PLPLOT_LIB_ENV) if ((dn = getenv(PLPLOT_LIB_ENV)) != NULL) { plGetName(dn, "", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; fprintf(stderr, PLPLOT_LIB_ENV"=\"%s\"\n", dn); /* what IS set? */ } #endif /* PLPLOT_LIB_ENV */ /**** search current directory ****/ if ((file = pdf_fopen(fn, "rb")) != NULL) goto done; /**** search PLPLOT_HOME_ENV/lib = $(PLPLOT_HOME)/lib ****/ #if defined (PLPLOT_HOME_ENV) if ((dn = getenv(PLPLOT_HOME_ENV)) != NULL) { plGetName(dn, "lib", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; fprintf(stderr, PLPLOT_HOME_ENV"=\"%s\"\n",dn); /* what IS set? */ } #endif /* PLPLOT_HOME_ENV/lib */ /**** search installed location ****/ #if defined (DATA_DIR) plGetName(DATA_DIR, "", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; #endif /* DATA_DIR */ /**** search hardwired location ****/ #ifdef PLLIBDEV plGetName(PLLIBDEV, "", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; #endif /* PLLIBDEV */ #ifdef macintosh file = plMacLibOpen(fn); if (file != NULL) goto done; #endif /* macintosh */ if (plplotLibDir != NULL) { plGetName(plplotLibDir, "", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; } /**** not found, give up ****/ return NULL; done: free_mem(fs); return (file); }