H5srcdir.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 /*
00017  * Programmer:  Quincey Koziol <koziol@hdfgroup.org>
00018  *              Wednesday, March 17, 2010
00019  *
00020  * Purpose:     srcdir querying support.
00021  */
00022 #ifndef _H5SRCDIR_H
00023 #define _H5SRCDIR_H
00024 
00025 /* Include the header file with the correct relative path for the srcdir string */
00026 #include "H5srcdir_str.h"
00027 
00028 /* Buffer to construct path in and return pointer to */
00029 static char srcdir_path[1024] = "";
00030 
00031 /* Buffer to construct file in and return pointer to */
00032 static char srcdir_testpath[1024] = "";
00033 
00034 /* Append the test file name to the srcdir path and return the whole string */
00035 static const char *H5_get_srcdir_filename(const char *filename)
00036 {
00037     const char *srcdir = HDgetenv("srcdir");
00038 
00039     /* Check for using the srcdir from configure time */
00040     if(NULL == srcdir)
00041         srcdir = config_srcdir;
00042 
00043     /* Build path to test file */
00044     if((HDstrlen(srcdir) + HDstrlen(filename) + 2) < sizeof(srcdir_testpath)) {
00045         HDstrcpy(srcdir_testpath, srcdir);
00046         HDstrcat(srcdir_testpath, "/");
00047         HDstrcat(srcdir_testpath, filename);
00048         return(srcdir_testpath);
00049     } /* end if */
00050     else
00051         return(NULL);
00052 }
00053 
00054 /* Just return the srcdir path */
00055 static const char *H5_get_srcdir(void)
00056 {
00057     const char *srcdir = HDgetenv("srcdir");
00058 
00059     /* Check for using the srcdir from configure time */
00060     if(NULL == srcdir)
00061         srcdir = config_srcdir;
00062 
00063     /* Build path to all test files */
00064     if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) {
00065         HDstrcpy(srcdir_path, srcdir);
00066         HDstrcat(srcdir_path, "/");
00067         return(srcdir_path);
00068     } /* end if */
00069     else
00070         return(NULL);
00071 }
00072 #endif /* _H5SRCDIR_H */
00073 
00074