JIRA: NCF-311

Initial attempt to make libnsetcdf.settings
accessible programatically.
Added libdispatch/ncsettings.hdr
used to construct ncsettings.c
See end of libdispatch/Makefile.am to
see how ncsettings.c is constructed.
This commit is contained in:
dmh 2014-08-26 12:28:38 -06:00
parent b43813d821
commit 9e43180470
2 changed files with 88 additions and 44 deletions

View File

@ -21,7 +21,8 @@ dvarinq.c ddispatch.c \
nclog.c dstring.c dutf8proc.c utf8proc_data.h \
ncuri.c nclist.c ncbytes.c nchashmap.c nctime.c \
dsubstrate.c \
nc.c nclistmgr.c
nc.c nclistmgr.c \
ncsettings.c
# Add functions only found in netCDF-4.
if USE_NETCDF4
@ -41,4 +42,11 @@ libnetcdf2_la_SOURCES = dv2i.c
libnetcdf2_la_CPPFLAGS = ${AM_CPPFLAGS} -DDLL_EXPORT
endif # BUILD_V2
EXTRA_DIST=CMakeLists.txt
EXTRA_DIST=CMakeLists.txt ncsettings.hdr
ncsettings.c: $(top_srcdir)/libnetcdf.settings ncsettings.hdr
rm -f ncsettings.c
cat ncsettings.hdr > ncsettings.c
sed -e 's/"/\\"/g' <$(top_srcdir)/libnetcdf.settings | sed -e 's/\(.*\)/"\1\\n"/' >> ncsettings.c
echo ';' >> ncsettings.c

View File

@ -0,0 +1,36 @@
/*********************************************************************
* Copyright 2014, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
#include "config.h"
#include <stdlib.h>
static const char* ncsettings;
static char** map = NULL;
static void parse();
const char*
nc_settings(const char* key)
{
char** mapp;
int keylen = strlen(key);
if(map == NULL)
parse();
for(mapp=map;*mapp != NULL;mapp+=2) {
/* Note this assumes that no key is a prefix of another */
if(strncmp(*mapp,key,keylen)==0) {
return mapp[1];
}
}
return NULL;
}
static void parse()
{
}
static const char* ncsettings =