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); }
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); }