Commit 5daea376 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

autodetection of includes in make_cdilib [patch 13/14 from Nathanael]

parent f2f5c168
......@@ -4,7 +4,7 @@
#if defined (HAVE_LIBNETCDF)
#include <stdlib.h>
#include "netcdf.h"
#include <netcdf.h>
void cdf_create (const char *path, int cmode, int *idp);
int cdf_open (const char *path, int omode, int *idp);
......
#ifndef _DMEMORY_H
#define _DMEMORY_H
//Ensure that all standard headers that may declare malloc() and friends are already included so that our macros won't clobber their definitions.
#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
/*
* if DEBUG_MEMORY is defined setenv MEMORY_DEBUG to debug memory
......
#ifndef INCLUDE_GUARD_CDI_GRIBAPI_UTILITIES_H
#define INCLUDE_GUARD_CDI_GRIBAPI_UTILITIES_H
#include "grib_api.h"
#include "grid.h"
#include <grib_api.h>
#include <stdbool.h>
char* gribCopyString(grib_handle* gribHandle, const char* key);
......
......@@ -15,7 +15,7 @@ static void cdiInputFile_destruct(CdiInputFile* me);
//For an explanation of the condestruct() pattern, see the comment in iterator_grib.c
//path != NULL -> construction
//path = NULL -> destruction
static CdiInputFile* condestruct(CdiInputFile* me, const char* path)
static CdiInputFile* cdiInputFile_condestruct(CdiInputFile* me, const char* path)
{
#define super() (&me->super)
if(!path) goto destruct;
......@@ -74,7 +74,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
else
{
result = xmalloc(sizeof(*result));
if(!condestruct(result, path))
if(!cdiInputFile_condestruct(result, path))
{
//An error occured during construction, avoid a memory leak.
free(result);
......@@ -137,5 +137,5 @@ void cdiInputFile_destruct(CdiInputFile* me)
}
error = pthread_mutex_unlock(&openFileListLock);
xassert(!error);
condestruct(me, NULL);
cdiInputFile_condestruct(me, NULL);
}
......@@ -10,7 +10,7 @@
#include <stdlib.h>
//For more information on the condestruct() pattern, see comment in src/iterator_grib.c
static CdiFallbackIterator* condestruct(CdiFallbackIterator* me, const char* path, int filetype)
static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator* me, const char* path, int filetype)
{
if(me) goto destruct;
......@@ -51,7 +51,7 @@ destructSuper:
CdiIterator* cdiFallbackIterator_new(const char* path, int filetype)
{
return &condestruct(NULL, path, filetype)->super;
return &cdiFallbackIterator_condestruct(NULL, path, filetype)->super;
}
//Fetches the info that is published by the variables in the base class from the current field.
......@@ -69,7 +69,7 @@ CdiFallbackIterator* cdiFallbackIterator_clone(CdiIterator* super)
CdiFallbackIterator* me = (CdiFallbackIterator*)super;
//Make another stream for this file. This yields an unadvanced iterator.
CdiFallbackIterator* clone = condestruct(NULL, me->path, me->super.filetype);
CdiFallbackIterator* clone = cdiFallbackIterator_condestruct(NULL, me->path, me->super.filetype);
if(!clone) return NULL;
//Point the clone to the same position in the file.
......@@ -281,5 +281,5 @@ void cdiFallbackIterator_readFieldF(CdiIterator* super, float* buffer, size_t* n
void cdiFallbackIterator_delete(CdiIterator* super)
{
CdiFallbackIterator* me = (CdiFallbackIterator*)super;
condestruct(me, NULL, 0);
cdiFallbackIterator_condestruct(me, NULL, 0);
}
......@@ -20,7 +20,7 @@
//The mode of operation depends on whether me is a NULL pointer on entry:
//If it is NULL, a new object is allocated and constructed, which is returned if construction is successful.
//If a non-NULL pointer is passed in, the object is destructed and NULL is returned. In this case, the other arguments are ignored.
static CdiGribIterator* condestruct(CdiGribIterator* me, const char* path, int filetype)
static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const char* path, int filetype)
{
#define super() (&me->super)
if(me) goto destruct;
......@@ -58,7 +58,7 @@ success:
CdiIterator* cdiGribIterator_new(const char* path, int filetype)
{
return &condestruct(NULL, path, filetype)->super;
return &cdiGribIterator_condestruct(NULL, path, filetype)->super;
}
CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super)
......@@ -545,7 +545,7 @@ void cdiGribIterator_readFieldF(CdiIterator* super, float* buffer, size_t* nmiss
*/
void cdiGribIterator_delete(CdiGribIterator* me)
{
if(me) condestruct(me, NULL, 0);
if(me) cdiGribIterator_condestruct(me, NULL, 0);
}
......
......@@ -6,7 +6,7 @@
# pretty generic script -- just echos, cats and greps.
#
#
srcdir=./
srcdir=.
if [ ! -z $1 ] ; then
srcdir=$1
fi
......@@ -89,73 +89,98 @@ cat > ${PROG} << EOR
EOR
c="dmemory.c \
dmemory.h \
cksum.c \
cdi_cksum.c \
taxis.c \
timebase.c \
calendar.c \
model.c \
institution.c \
table.c \
util.c \
gaussgrid.c \
varscan.c \
vlist.c \
vlist_att.c \
vlist_var.c \
basetime.c \
servicelib.c \
extralib.c \
ieglib.c \
grid.c \
zaxis.c \
cdf_int.c \
cdi_error.c \
cdi_util.c \
cdi_int.c \
stream.c \
stream_history.c \
stream_cgribex.c \
stream_gribapi.c \
stream_fcommon.c \
stream_grb.c \
stream_srv.c \
stream_ext.c \
stream_ieg.c \
stream_cdf.c \
stream_var.c \
stream_record.c \
tsteps.c \
file.c \
cgribexlib.c \
gribapi.c \
swap.c \
binary.c \
cdf.c \
namespace.c \
serialize.c \
resource_handle.c"
h="cdi_limits.h resource_handle.h taxis.h dtypes.h file.h service.h extra.h \
ieg.h cdi.h timebase.h calendar.h basetime.h datetime.h namespace.h \
cksum.h cdi_cksum.h error.c error.h cdi_int.h cgribex.h gribapi.h \
stream_cgribex.h stream_gribapi.h stream_grb.h stream_cdf.h \
tablepar.h table.h gaussgrid.h grid.h zaxis.h varscan.h binary.h swap.h \
service.h stream_srv.h stream_ext.h stream_ieg.h cdf_int.h \
cdf.h vlist.h vlist_var.h vlist_att.h model.h institution.h \
resource_unpack.h serialize.h stream_fcommon.h"
#cat $h >> ${PROG}
#cat $c | grep -v '#include' | grep -v '# include' >> ${PROG}
for hfile in $h ; do
cat $srcdir/$hfile >> ${PROG}
files="basetime.c \
binary.c \
calendar.c \
cdf.c \
cdf_int.c \
cdi_cksum.c \
cdi_error.c \
cdi_int.c \
cdi_util.c \
cgribexlib.c \
cksum.c \
dmemory.c \
error.c \
extralib.c \
file.c \
gaussgrid.c \
gribapi.c \
gribapi_utilities.c \
grid.c \
ieglib.c \
input_file.c \
institution.c \
iterator.c \
iterator_fallback.c \
iterator_grib.c \
model.c \
namespace.c \
proprietarySystemWorkarounds.c \
referenceCounting.c \
resource_handle.c \
serialize.c \
servicelib.c \
stream.c \
stream_cdf.c \
stream_cgribex.c \
stream_ext.c \
stream_fcommon.c \
stream_grb.c \
stream_gribapi.c \
stream_history.c \
stream_ieg.c \
stream_record.c \
stream_srv.c \
stream_var.c \
swap.c \
table.c \
taxis.c \
timebase.c \
tsteps.c \
util.c \
varscan.c \
vlist.c \
vlist_att.c \
vlist_var.c \
zaxis.c"
car () {
echo "$1"
}
cdr () {
shift
echo "$@"
}
listIncludes () {
grep '^ *# *include *"' "$1" | sed 's/^ *# *include *"\(.*\)".*$/\1/'
}
scanlist="$files"
fileList=
until test "foo$scanlist" = "foo" ; do
curFile="$(car $scanlist)"
scanlist="$(cdr $scanlist)"
case $curFile in
(\<*\>)
fileList="$fileList $(echo "$curFile" | sed 's/<\(.*\)>/\1/')"
;;
(*)
if echo "$fileList" | grep -q '\<'"$curFile"'\>' ; then
true #Nothing to do, we have already scanned this header.
else
#Prepend the includes of the current header to the scanlist so that we will scan them in the order that the preprocessor would.
scanlist="$(listIncludes "$curFile") <$curFile> $scanlist"
fi
;;
esac
done
for cfile in $c ; do
cat $srcdir/$cfile | grep -v '#include "' | grep -v '# include "' >> ${PROG}
echo file list:
echo $fileList
for file in $fileList ; do
cat $srcdir/$file | grep -v '^ *# *include *"' >> ${PROG}
done
......
......@@ -20,7 +20,8 @@
#if defined (HAVE_LIBGRIB_API)
# include "cgribex.h" /* gribGetSize, gribRead, gribGetZip, GRIB1_LTYPE_99 */
# include "gribapi.h"
# include "grib_api.h"
# include <grib_api.h>
#endif
extern int cdiInventoryMode;
......
......@@ -2,7 +2,8 @@
#define _STREAM_GRIBAPI_H
#include "cdi_int.h"
#include "grib_api.h"
#include <grib_api.h>
int gribapiScanTimestep1(stream_t * streamptr);
int gribapiScanTimestep2(stream_t * streamptr);
......
......@@ -16,6 +16,13 @@
#include "error.h"
#include "proprietarySystemWorkarounds.h"
#if defined (HAVE_LIBGRIB_API)
# include "file.h"
# include <grib_api.h>
#endif
static
void vlistvarInitEntry(int vlistID, int varID)
{
......@@ -1816,11 +1823,6 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
#endif
}
#if defined (HAVE_LIBGRIB_API)
# include "file.h"
# include "grib_api.h"
#endif
/* cdiClearAdditionalKeys: Clears the list of additional GRIB keys. */
void cdiClearAdditionalKeys()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment