From c5e7cd5001e99ccb72204ca415a1eb05ab957cb8 Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Thu, 28 Jan 2010 13:55:34 +0100 Subject: [PATCH] renamed libfn function to gmxlibfn --- include/futil.h | 4 ++-- src/gmxlib/futil.c | 37 +++++++++++++++++++++++-------------- src/gmxlib/gmxcpp.c | 2 +- src/kernel/fflibutil.c | 4 ++-- src/kernel/pdb2top.c | 2 +- src/mdlib/gmx_qhop_xml.c | 2 +- src/mdlib/tables.c | 2 +- src/tools/gmx_genbox.c | 2 +- src/tools/gmx_xpm2ps.c | 2 +- 9 files changed, 33 insertions(+), 24 deletions(-) diff --git a/include/futil.h b/include/futil.h index b33665cc12..70e49e38eb 100644 --- a/include/futil.h +++ b/include/futil.h @@ -113,7 +113,7 @@ extern void frewind(FILE *fp); bool is_pipe(FILE *fp); -extern char *libfn(const char *file); +extern char *gmxlibfn(const char *file); /* allocates and returns a string with the full file name for a library file */ extern FILE *libopen(const char *file); @@ -124,7 +124,7 @@ extern FILE *libopen(const char *file); extern bool get_libdir(char *libdir); -extern char *low_libfn(const char *file,bool bFatal); +extern char *low_gmxlibfn(const char *file,bool bFatal); extern FILE *low_libopen(const char *file,bool bFatal); /* The same as the above, but does not terminate if (!bFatal) */ diff --git a/src/gmxlib/futil.c b/src/gmxlib/futil.c index 29fbebcfeb..b24c1508ca 100644 --- a/src/gmxlib/futil.c +++ b/src/gmxlib/futil.c @@ -1,4 +1,5 @@ -/* +/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- + * * * This source code is part of * @@ -585,48 +586,56 @@ bool get_libdir(char *libdir) } -char *low_libfn(const char *file, bool bFatal) +char *low_gmxlibfn(const char *file, bool bFatal) { - char *ret=NULL; + char *ret; char *lib,*dir; char buf[1024]; char libpath[GMX_PATH_MAX]; bool env_is_set=FALSE; char *s,tmppath[GMX_PATH_MAX]; - bool found; /* GMXLIB can be a path now */ lib=getenv("GMXLIB"); - if (lib != NULL) { + if (lib != NULL) + { env_is_set=TRUE; strncpy(libpath,lib,GMX_PATH_MAX); } else if (!get_libdir(libpath)) + { strncpy(libpath,GMXLIBDIR,GMX_PATH_MAX); + } + ret = NULL; if (gmx_fexist(file)) { - ret=strdup(file); + ret = strdup(file); } else { - found=FALSE; strncpy(tmppath,libpath,GMX_PATH_MAX); s=tmppath; - while(!found && (dir=gmx_strsep(&s, PATH_SEPARATOR)) != NULL ) + while(ret == NULL && (dir=gmx_strsep(&s, PATH_SEPARATOR)) != NULL ) { sprintf(buf,"%s%c%s",dir,DIR_SEPARATOR,file); - found=gmx_fexist(buf); + if (gmx_fexist(buf)) + { + ret = strdup(buf); + } } - if (bFatal && !found) + if (ret == NULL && bFatal) { if (env_is_set) + { gmx_fatal(FARGS,"Library file %s not found in current dir nor in your GMXLIB path.\n",file); + } else + { gmx_fatal(FARGS,"Library file %s not found in current dir nor in default directories.\n" "(You can set the directories to search with the GMXLIB path variable)",file); + } } - ret=strdup(buf); } return ret; @@ -640,7 +649,7 @@ FILE *low_libopen(const char *file,bool bFatal) FILE *ff; char *fn; - fn=low_libfn(file,bFatal); + fn=low_gmxlibfn(file,bFatal); if (fn==NULL) { ff=NULL; @@ -654,9 +663,9 @@ FILE *low_libopen(const char *file,bool bFatal) return ff; } -char *libfn(const char *file) +char *gmxlibfn(const char *file) { - return low_libfn(file,TRUE); + return low_gmxlibfn(file,TRUE); } FILE *libopen(const char *file) diff --git a/src/gmxlib/gmxcpp.c b/src/gmxlib/gmxcpp.c index c45c927602..e5ae3b725d 100644 --- a/src/gmxlib/gmxcpp.c +++ b/src/gmxlib/gmxcpp.c @@ -224,7 +224,7 @@ int cpp_open_file(const char *filenm,gmx_cpp_t *handle, char **cppopts) snew(cpp->cwd,STRLEN); /* Search for the directory in cwd and the GROMACS search path */ - cpp->path = libfn(buf); + cpp->path = gmxlibfn(buf); sfree(buf); #if ((defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64) && !defined __CYGWIN__ && !defined __CYGWIN32__) diff --git a/src/kernel/fflibutil.c b/src/kernel/fflibutil.c index 410e795378..173eb2cdb6 100644 --- a/src/kernel/fflibutil.c +++ b/src/kernel/fflibutil.c @@ -172,7 +172,7 @@ static int low_fflib_search_file_end(const char *ffdir, if (ffdir != NULL) { /* Search in current dir and ffdir */ - libpath = libfn(ffdir); + libpath = gmxlibfn(ffdir); } else { @@ -346,7 +346,7 @@ FILE *fflib_open(const char *file) char *file_fullpath; FILE *fp; - file_fullpath = libfn(file); + file_fullpath = gmxlibfn(file); fprintf(stderr,"Opening force field file %s\n",file_fullpath); fp = ffopen(file_fullpath,"r"); sfree(file_fullpath); diff --git a/src/kernel/pdb2top.c b/src/kernel/pdb2top.c index df16d3f692..d97d210ffa 100644 --- a/src/kernel/pdb2top.c +++ b/src/kernel/pdb2top.c @@ -175,7 +175,7 @@ choose_ff(const char *ffsel, { sprintf(buf,"%s%c%s", ffdirs[i],DIR_SEPARATOR,fflib_forcefield_doc()); - doc_dir = low_libfn(buf,FALSE); + doc_dir = low_gmxlibfn(buf,FALSE); if (doc_dir != NULL) { /* We don't use fflib_open, because we don't want printf's */ diff --git a/src/mdlib/gmx_qhop_xml.c b/src/mdlib/gmx_qhop_xml.c index 8334b6027c..5071f9254a 100644 --- a/src/mdlib/gmx_qhop_xml.c +++ b/src/mdlib/gmx_qhop_xml.c @@ -245,7 +245,7 @@ gmx_qhops_read(char *fn,int *nqhop) xmlDoValidityCheckingDefaultValue = 0; if (NULL == fn) { - fn = (char *)libfn(db); + fn = (char *)gmxlibfn(db); fna=TRUE; } if ((doc = xmlParseFile(fn)) == NULL) { diff --git a/src/mdlib/tables.c b/src/mdlib/tables.c index 669e764dd3..2f32c1a57d 100644 --- a/src/mdlib/tables.c +++ b/src/mdlib/tables.c @@ -356,7 +356,7 @@ static void read_tables(FILE *fp,const char *fn, double tabscale; nny = 2*ntab+1; - libfn = low_libfn(fn,TRUE); + libfn = gmxlibfn(fn); nx = read_xvg(libfn,&yy,&ny); if (ny != nny) gmx_fatal(FARGS,"Trying to read file %s, but nr columns = %d, should be %d", diff --git a/src/tools/gmx_genbox.c b/src/tools/gmx_genbox.c index 1f8006fca8..f0d45be861 100644 --- a/src/tools/gmx_genbox.c +++ b/src/tools/gmx_genbox.c @@ -373,7 +373,7 @@ static void add_solv(const char *fn,t_atoms *atoms,rvec **x,rvec **v,real **r, int onr,onres; char *lfn; - lfn=libfn(fn); + lfn = gmxlibfn(fn); strncpy(filename,lfn,STRLEN); sfree(lfn); snew(atoms_solvt,1); diff --git a/src/tools/gmx_xpm2ps.c b/src/tools/gmx_xpm2ps.c index 4ace297c5b..9f42dcb7d8 100644 --- a/src/tools/gmx_xpm2ps.c +++ b/src/tools/gmx_xpm2ps.c @@ -650,7 +650,7 @@ void ps_mat(const char *outf,int nmat,t_matrix mat[],t_matrix mat2[], bool bMap1,bNextMap1,bDiscrete; /* memory leak: */ - libm2p = m2p ? libfn(m2p) : m2p; + libm2p = m2p ? gmxlibfn(m2p) : m2p; get_params(libm2p,m2pout,&psrec); psr=&psrec; -- 2.11.4.GIT