Merge pull request #1379 from Unidata/threads_part1.dmh

Thread safety: step 1: cleanup
This commit is contained in:
Ward Fisher 2019-05-02 10:47:46 -06:00 committed by GitHub
commit ae1b30990d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 1795 additions and 1666 deletions

View File

@ -6,6 +6,10 @@ DAP=1
#CDF5=1
#HDF4=1
#TR=--trace
NCC="c:/tools/nccmake"
export SETX=1
for arg in "$@" ; do
@ -13,6 +17,7 @@ case "$arg" in
vs|VS) VS=1 ;;
linux|nix|l|x) unset VS ;;
nobuild|nb) NOBUILD=1 ;;
notest|nt) NOTEST=1 ;;
*) echo "Must specify env: vs|linux"; exit 1; ;;
esac
done
@ -35,8 +40,10 @@ else
CFG="Release"
fi
FLAGS=
if test "x$VS" != x -a "x$INSTALL" != x ; then
FLAGS="-DCMAKE_PREFIX_PATH=c:/tools/nccmake"
FLAGS="$FLAGS -DCMAKE_PREFIX_PATH=${NCC}"
fi
FLAGS="$FLAGS -DCMAKE_INSTALL_PREFIX=/tmp/netcdf"
@ -45,6 +52,8 @@ FLAGS="$FLAGS -DENABLE_DAP=false"
fi
if test "x$NC4" = x ; then
FLAGS="$FLAGS -DENABLE_NETCDF_4=false"
else
FLAGS="-DHDF5_C_LIBRARY=${NCC}/lib/hdf5 -DHDF5_HL_LIBRARY=${NCC}/lib/hdf5_hl -DHDF5_INCLUDE_DIR=${NCC}/include"
fi
if test "x$CDF5" != x ; then
FLAGS="$FLAGS -DENABLE_CDF5=true"
@ -69,6 +78,7 @@ FLAGS="$FLAGS -DENABLE_EXAMPLES=false"
FLAGS="$FLAGS -DENABLE_CONVERSION_WARNINGS=false"
#FLAGS="$FLAGS -DENABLE_TESTS=false"
#FLAGS="$FLAGS -DENABLE_DISKLESS=false"
FLAGS="$FLAGS -DBUILD_UTILITIES=true"
# Withs
FLAGS="$FLAGS -DNCPROPERTIES_EXTRA=\"key1=value1|key2=value2\""
@ -86,10 +96,12 @@ CFG="Release"
NCLIB="${NCLIB}/liblib"
export PATH="${NCLIB}:${PATH}"
#G=
cmake "$G" -DCMAKE_BUILD_TYPE=${CFG} $FLAGS ..
cmake ${TR} "$G" -DCMAKE_BUILD_TYPE=${CFG} $FLAGS ..
if test "x$NOBUILD" = x ; then
cmake --build . --config ${CFG}
cmake --build . --config ${CFG} --target RUN_TESTS
cmake ${TR} --build . --config ${CFG} --target ZERO_CHECK
if test "x$NOTEST" = x ; then
cmake ${TR} --build . --config ${CFG} --target RUN_TESTS
fi
fi
else
# GCC

View File

@ -40,7 +40,7 @@ extern "C" {
extern int
NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
void *parameters, NC_Dispatch *, NC *);
void *parameters, const NC_Dispatch *, NC *);
extern int
NC_HDF4_abort(int ncid);

View File

@ -26,7 +26,7 @@ struct NCmodel;
typedef struct NC {
int ext_ncid;
int int_ncid;
struct NC_Dispatch* dispatch;
const struct NC_Dispatch* dispatch;
void* dispatchdata; /*per-'file' data; points to e.g. NC3_INFO data*/
char* path;
int mode; /* as provided to nc_open/nc_create */
@ -81,9 +81,6 @@ extern int iterate_NCList(int i,NC**); /* Walk from 0 ...; ERANGE return => stop
/* Defined in nc.c */
extern void free_NC(NC*);
extern int new_NC(struct NC_Dispatch*, const char*, int, struct NCmodel*, NC**);
/* Defined in nc.c */
extern int ncdebug;
extern int new_NC(const struct NC_Dispatch*, const char*, int, struct NCmodel*, NC**);
#endif /* _NC_H_ */

View File

@ -53,13 +53,13 @@ extern "C" {
extern int
NC3_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* mpidata, struct NC_Dispatch*, NC* ncp);
void* mpidata, const struct NC_Dispatch*, NC* ncp);
/* WARNING: this signature differs from external nc_open API*/
extern int
NC3_open(const char *path, int mode,
int basepe, size_t *chunksizehintp,
void* mpidata, NC_Dispatch*, NC* ncp);
void* mpidata, const NC_Dispatch*, NC* ncp);
extern int
NC3_new_nc(NC**);

View File

@ -23,12 +23,12 @@ extern "C" {
EXTERNL int
NC4_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* parameters, NC_Dispatch*, NC*);
void* parameters, const NC_Dispatch*, NC*);
EXTERNL int
NC4_open(const char *path, int mode,
int basepe, size_t *chunksizehintp,
void* parameters, NC_Dispatch*, NC*);
void* parameters, const NC_Dispatch*, NC*);
EXTERNL int
NC4_redef(int ncid);

View File

@ -296,7 +296,7 @@ typedef struct {
void *p; /* Pointer to VL data */
} nc_hvl_t;
extern char* nc4_atomic_name[NC_MAX_ATOMIC_TYPE+1];
extern const char* nc4_atomic_name[NC_MAX_ATOMIC_TYPE+1];
/* These functions convert between netcdf and HDF5 types. */
int nc4_get_typelen_mem(NC_FILE_INFO_T *h5, nc_type xtype, size_t *len);

View File

@ -104,23 +104,23 @@ typedef struct NC_MPI_INFO {
extern int NCDISPATCH_initialize(void);
extern int NCDISPATCH_finalize(void);
extern NC_Dispatch* NC3_dispatch_table;
extern const NC_Dispatch* NC3_dispatch_table;
extern int NC3_initialize(void);
extern int NC3_finalize(void);
#ifdef ENABLE_DAP
extern NC_Dispatch* NCD2_dispatch_table;
extern const NC_Dispatch* NCD2_dispatch_table;
extern int NCD2_initialize(void);
extern int NCD2_finalize(void);
#endif
#ifdef ENABLE_DAP4
extern NC_Dispatch* NCD4_dispatch_table;
extern const NC_Dispatch* NCD4_dispatch_table;
extern int NCD4_initialize(void);
extern int NCD4_finalize(void);
#endif
#ifdef USE_PNETCDF
extern NC_Dispatch* NCP_dispatch_table;
extern const NC_Dispatch* NCP_dispatch_table;
extern int NCP_initialize(void);
extern int NCP_finalize(void);
#endif
@ -131,23 +131,18 @@ extern int NC4_finalize(void);
#endif
#ifdef USE_HDF5
extern NC_Dispatch* HDF5_dispatch_table;
extern const NC_Dispatch* HDF5_dispatch_table;
extern int NC_HDF5_initialize(void);
extern int NC_HDF5_finalize(void);
#endif
#ifdef USE_HDF4
extern NC_Dispatch* HDF4_dispatch_table;
extern const NC_Dispatch* HDF4_dispatch_table;
extern int HDF4_initialize(void);
extern int HDF4_finalize(void);
#endif
/* Vectors of ones and zeros */
extern size_t nc_sizevector0[NC_MAX_VAR_DIMS];
extern size_t nc_sizevector1[NC_MAX_VAR_DIMS];
extern ptrdiff_t nc_ptrdiffvector1[NC_MAX_VAR_DIMS];
/* User-defined formats. */
/* User-defined formats.*/
extern NC_Dispatch* UDF0_dispatch_table;
extern char UDF0_magic_number[NC_MAX_MAGIC_NUMBER_LEN + 1];
extern NC_Dispatch* UDF1_dispatch_table;
@ -199,10 +194,10 @@ int model; /* one of the NC_FORMATX #'s */
int (*create)(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* parameters, struct NC_Dispatch* table, NC* ncp);
void* parameters, const struct NC_Dispatch* table, NC* ncp);
int (*open)(const char *path, int mode,
int basepe, size_t *chunksizehintp,
void* parameters, struct NC_Dispatch* table, NC* ncp);
void* parameters, const struct NC_Dispatch* table, NC* ncp);
int (*redef)(int);
int (*_enddef)(int,size_t,size_t,size_t,size_t);
@ -319,7 +314,7 @@ int (*nc_finalize)();
typedef struct NCcommon {
int ext_ncid; /* uid << 16 */
int int_ncid; /* unspecified other id */
struct NC_Dispatch* dispatch;
const struct NC_Dispatch* dispatch;
void* dispatchdata; /* per-protocol instance data */
char* path; /* as specified at open or create */
} NCcommon;
@ -327,17 +322,6 @@ typedef struct NCcommon {
EXTERNL size_t NC_atomictypelen(nc_type xtype);
EXTERNL char* NC_atomictypename(nc_type xtype);
#ifdef OBSOLETE
/* Provide a dispatch table overlay facility */
extern int NC_dispatch_overlay(const NC_Dispatch* overlay,
const NC_Dispatch* base,
NC_Dispatch* merge);
/* Get/set the override dispatch table */
extern NC_Dispatch* NC_get_dispatch_override(void);
extern void NC_set_dispatch_override(NC_Dispatch*);
#endif
/* Misc */
extern int NC_getshape(int ncid, int varid, int ndims, size_t* shape);
@ -354,11 +338,11 @@ extern int NC_inq_recvar(int ncid, int varid, int* nrecdims, int* is_recdim);
#define TRACE(fname)
#endif
extern size_t NC_coord_zero[NC_MAX_VAR_DIMS];
extern size_t NC_coord_one[NC_MAX_VAR_DIMS];
/* Vectors of ones and zeros */
extern const size_t NC_coord_zero[NC_MAX_VAR_DIMS];
extern const size_t NC_coord_one[NC_MAX_VAR_DIMS];
extern const ptrdiff_t NC_stride_one[NC_MAX_VAR_DIMS];
extern int NC_argc;
extern char* NC_argv[];
extern int NC_initialized;
/**
@ -383,7 +367,7 @@ NCDISPATCH_get_att(int ncid, int varid, const char* name, void* value, nc_type t
EXTERNL int NC_RO_create(const char *path, int cmode, size_t initialsz, int basepe,
size_t *chunksizehintp, void* parameters,
NC_Dispatch*, NC*);
const NC_Dispatch*, NC*);
EXTERNL int NC_RO_redef(int ncid);
EXTERNL int NC_RO__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree,
size_t r_align);

View File

@ -33,9 +33,6 @@ EXTERNL void ncvlog(int tag, const char* fmt, va_list ap);
EXTERNL void nclogtext(int tag, const char* text);
EXTERNL void nclogtextn(int tag, const char* text, size_t count);
/* Provide printable names for tags */
EXTERNL void nclogsettags(char** tagset, char* dfalt);
#if defined(_CPLUSPLUS_) || defined(__CPLUSPLUS__)
}
#endif

View File

@ -51,8 +51,7 @@ typedef struct NCtypealignset {
NCalignment ncvlenalign; /* nc_vlen_t*/
} NCtypealignset;
size_t NC_class_alignment(int ncclass);
void NC_compute_alignments(void);
EXTERNL int NC_alignments_computed;
EXTERNL size_t NC_class_alignment(int ncclass);
EXTERNL void NC_compute_alignments(void);
#endif /*NCOFFSETS_H*/

View File

@ -38,9 +38,9 @@ typedef struct NCRCglobalstate {
NCRCinfo rcinfo; /* Currently only one rc file per session */
} NCRCglobalstate;
extern NCRCglobalstate ncrc_globalstate; /* singleton instance */
/* From drc.c */
extern NCRCglobalstate* ncrc_getglobalstate(void);
extern void ncrc_freeglobalstate(void);
/* read and compile the rc file, if any */
extern int NC_rcload(void);
extern char* NC_rclookup(const char* key, const char* hostport);

View File

@ -105,7 +105,7 @@ extern char* ncuridecode(char* s);
/* Partial decode */
extern char* ncuridecodepartial(char* s, const char* decodeset);
/* Encode using specified character set */
extern char* ncuriencodeonly(char* s, char* allowable);
extern char* ncuriencodeonly(char* s, const char* allowable);
/* Encode user or pwd */
extern char* ncuriencodeuserpwd(char* s);

View File

@ -11,8 +11,6 @@
extern char* ocfqn(OCddsnode);
#endif
CDFnode* v4node = NULL;
/* Forward*/
static NCerror sequencecheckr(CDFnode* node, NClist* vars, CDFnode* topseq);
static NCerror restructr(NCDAPCOMMON*, CDFnode*, CDFnode*, NClist*);

View File

@ -7,8 +7,6 @@
#include "dapdump.h"
extern CDFnode* v4node;
static NCerror buildcdftreer(NCDAPCOMMON*,OCddsnode,CDFnode*,CDFtree*,CDFnode**);
static void defdimensions(OCddsnode, CDFnode*, NCDAPCOMMON*, CDFtree*);
static NCerror attachsubsetr(CDFnode*, CDFnode*);

View File

@ -9,8 +9,6 @@
#include "dapincludes.h"
#include "nclog.h"
int ncdap3debug = 0;
#ifdef CATCHERROR
/* Place breakpoint here to catch errors close to where they occur*/
int

View File

@ -25,6 +25,9 @@
# endif
#endif
/* Dump info about constraint processing */
#undef DCEVERBOSE
#undef PARSEDEBUG
/* Warning: setting CATCHERROR has significant performance impact */
#undef CATCHERROR

View File

@ -13,6 +13,8 @@
#define CHECK(n) if((n) != NC_NOERR) {return (n);} else {}
static char* indentstr = " "; /* Used by dumpindent */
static void dumptreer(CDFnode* root, NCbytes* buf, int indent, int visible);
int
@ -31,10 +33,10 @@ dumpmetadata(int ncid, NChdr** hdrp)
&hdr->ngatts,
&hdr->unlimid);
CHECK(stat);
if(ncdap3debug > 0) {
#ifdef DEBUG2
fprintf(stdout,"ncid=%d ngatts=%d ndims=%d nvars=%d unlimid=%d\n",
hdr->ncid,hdr->ngatts,hdr->ndims,hdr->nvars,hdr->unlimid);
}
#endif
hdr->gatts = (NCattribute*)calloc(1,hdr->ngatts*sizeof(NCattribute));
MEMCHECK(hdr->gatts,NC_ENOMEM);
if(hdr->ngatts > 0)
@ -200,10 +202,7 @@ char*
dumpprojections(NClist* projections)
{
char* tmp;
int v = dceverbose;
dceverbose = 1;
tmp = dcelisttostring(projections,",");
dceverbose = v;
return tmp;
}
@ -211,10 +210,7 @@ char*
dumpprojection(DCEprojection* proj)
{
char* tmp;
int v = dceverbose;
dceverbose = 1;
tmp = dcetostring((DCEnode*)proj);
dceverbose = v;
return tmp;
}
@ -234,10 +230,7 @@ char*
dumpconstraint(DCEconstraint* con)
{
char* tmp;
int v = dceverbose;
dceverbose = 1;
tmp = dcetostring((DCEnode*)con);
dceverbose = v;
return tmp;
}
@ -271,7 +264,6 @@ dumppath(CDFnode* leaf)
static void
dumpindent(int indent, NCbytes* buf)
{
static char* indentstr = " ";
int i;
for(i=0;i<indent;i++) ncbytescat(buf,indentstr);
}

View File

@ -632,12 +632,10 @@ normal: *s++ = *t++;
return;
}
#ifdef HAVE_GETTIMEOFDAY
static struct timeval time0;
static struct timeval time1;
#ifdef HAVE_GETTIMEOFDAY
static double
deltatime()
deltatime(struct timeval time0, struct timeval time1)
{
double t0, t1;
t0 = ((double)time0.tv_sec);
@ -658,6 +656,10 @@ dap_fetch(NCDAPCOMMON* nccomm, OClink conn, const char* ce,
char* ext = NULL;
OCflags flags = 0;
int httpcode = 0;
#ifdef HAVE_GETTIMEOFDAY
struct timeval time0;
struct timeval time1;
#endif
if(dxd == OCDDS) ext = ".dds";
else if(dxd == OCDAS) ext = ".das";
@ -691,7 +693,7 @@ dap_fetch(NCDAPCOMMON* nccomm, OClink conn, const char* ce,
#ifdef HAVE_GETTIMEOFDAY
double secs;
gettimeofday(&time1,NULL);
secs = deltatime();
secs = deltatime(time0,time1);
nclog(NCLOGNOTE,"fetch complete: %0.3f secs",secs);
#else
nclog(NCLOGNOTE,"fetch complete.");

View File

@ -18,9 +18,7 @@
#define LBRACE "{"
#define RBRACE "}"
int dceverbose = 0;
static char* opstrings[] = OPSTRINGS ;
static const char* opstrings[] = OPSTRINGS ;
static void ceallnodesr(DCEnode* node, NClist* allnodes, CEsort which);
static void dcedump(DCEnode* node, NCbytes* buf);
@ -60,11 +58,8 @@ fprintf(stderr,"constraint: %s",dcetostring((DCEnode*)dapconstraint));
static void
slicedump(const char* prefix, DCEslice* s)
{
#if 1
int v = dceverbose;
dceverbose = 1;
#ifdef DCEVERBOSE
fprintf(stderr,"%s: %s\n",prefix,dcetostring((DCEnode*)s));
dceverbose = v;
#else
size_t last = (s->first+s->length)-1;
fprintf(stderr,"%s: [%lu:%lu:%lu p=%lu l=%lu c=%lu]\n",
@ -567,25 +562,6 @@ dcerawlisttostring(NClist* list)
return s;
}
/* For debugging */
#ifdef DEBUG
static char*
dimdecl(size_t declsize)
{
static char tag[16];
tag[0] = '\0';
if(dceverbose)
snprintf(tag,sizeof(tag),"/%lu",(unsigned long)declsize);
return tag;
}
#else
static char*
dimdecl(size_t declsize)
{
return "";
}
#endif
void
dcetobuffer(DCEnode* node, NCbytes* buf)
{
@ -595,7 +571,6 @@ dcetobuffer(DCEnode* node, NCbytes* buf)
static void
dcedump(DCEnode* node, NCbytes* buf)
{
int i;
char tmp[1024];
if(buf == NULL) return;
@ -607,33 +582,30 @@ dcedump(DCEnode* node, NCbytes* buf)
DCEslice* slice = (DCEslice*)node;
size_t last = (slice->first+slice->length)-1;
if(slice->count == 1) {
snprintf(tmp,sizeof(tmp),"[%lu%s]",
(unsigned long)slice->first,dimdecl(slice->declsize));
snprintf(tmp,sizeof(tmp),"[%lu]",
(unsigned long)slice->first);
} else if(slice->stride == 1) {
snprintf(tmp,sizeof(tmp),"[%lu:%lu%s]",
snprintf(tmp,sizeof(tmp),"[%lu:%lu]",
(unsigned long)slice->first,
(unsigned long)last,
dimdecl(slice->declsize));
(unsigned long)last);
} else {
snprintf(tmp,sizeof(tmp),"[%lu:%lu:%lu%s]",
snprintf(tmp,sizeof(tmp),"[%lu:%lu:%lu]",
(unsigned long)slice->first,
(unsigned long)slice->stride,
(unsigned long)last,
dimdecl(slice->declsize));
(unsigned long)last);
}
ncbytescat(buf,tmp);
} break;
case CES_SEGMENT: {
DCEsegment* segment = (DCEsegment*)node;
int rank = segment->rank;
char* name = (segment->name?segment->name:"<unknown>");
int rank = segment->rank;
int i;
name = nulldup(name);
ncbytescat(buf,name);
nullfree(name);
if(dceverbose && dceiswholesegment(segment))
ncbytescat(buf,"*");
if(dceverbose || !dceiswholesegment(segment)) {
if(!dceiswholesegment(segment)) {
for(i=0;i<rank;i++) {
DCEslice* slice = segment->slices+i;
dcetobuffer((DCEnode*)slice,buf);

View File

@ -24,14 +24,14 @@ static void ceaddyytext(DCElexstate* lex, int c);
/****************************************************/
/* Define 1 and > 1st legal characters */
static char* wordchars1 =
static const char* wordchars1 =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\";
static char* wordcharsn =
static const char* wordcharsn =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\";
/* Number characters */
static char* numchars1="+-0123456789";
static char* numcharsn="Ee.+-0123456789";
static const char* numchars1="+-0123456789";
static const char* numcharsn="Ee.+-0123456789";
/**************************************************/

View File

@ -12,8 +12,6 @@
#define NEWVARM
static DCEnode* save = NULL;
/* Define a tracker for memory to support*/
/* the concatenation*/
struct NCMEMORY {
@ -173,7 +171,7 @@ fprintf(stderr,"\n");
/* Fill in missing arguments */
if(startp == NULL)
startp = nc_sizevector0;
startp = NC_coord_zero;
if(countp == NULL) {
/* Accumulate the dimension sizes */
@ -185,7 +183,7 @@ fprintf(stderr,"\n");
}
if(stridep == NULL)
stridep = nc_ptrdiffvector1;
stridep = NC_stride_one;
/* Validate the dimension sizes */
for(i=0;i<ncrank;i++) {
@ -412,7 +410,6 @@ fprintf(stderr,"cache.datadds=%s\n",dumptree(cachenode->datadds));
/* Switch to datadds tree space*/
varainfo->target = xtarget;
save = (DCEnode*)varaprojection;
ncstat = moveto(dapcomm,varainfo,varainfo->cache->datadds,data);
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}

View File

@ -25,7 +25,7 @@
#endif
/* Define the set of protocols known to be constrainable */
static char* constrainableprotocols[] = {"http", "https",NULL};
static const char* constrainableprotocols[] = {"http", "https",NULL};
static int ncd2initialized = 0;
@ -63,7 +63,7 @@ static NCerror applyclientparams(NCDAPCOMMON*);
static int
NCD2_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* mpidata, NC_Dispatch*,NC* ncp);
void* mpidata, const struct NC_Dispatch*,NC* ncp);
static int NCD2_redef(int ncid);
static int NCD2__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align);
@ -88,7 +88,7 @@ static int NCD2_get_vars(int ncid, int varid,
const size_t *start, const size_t *edges, const ptrdiff_t* stride,
void *value, nc_type memtype);
static NC_Dispatch NCD2_dispatch_base = {
static const NC_Dispatch NCD2_dispatch_base = {
NC_FORMATX_DAP2,
@ -181,7 +181,7 @@ NCD2_get_var_chunk_cache,
};
NC_Dispatch* NCD2_dispatch_table = NULL; /* moved here from ddispatch.c */
const NC_Dispatch* NCD2_dispatch_table = NULL; /* moved here from ddispatch.c */
int
NCD2_initialize(void)
@ -231,7 +231,7 @@ NCD2_abort(int ncid)
static int
NCD2_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* mpidata, NC_Dispatch* dispatch, NC* ncp)
void* mpidata, const NC_Dispatch* dispatch, NC* ncp)
{
return NC_EPERM;
}
@ -251,7 +251,7 @@ NCD2_get_vara(int ncid, int varid,
void *value,
nc_type memtype)
{
int stat = nc3d_getvarx(ncid, varid, start, edges, nc_ptrdiffvector1, value,memtype);
int stat = nc3d_getvarx(ncid, varid, start, edges, NC_stride_one, value,memtype);
return stat;
}
@ -275,7 +275,7 @@ NCD2_get_vars(int ncid, int varid,
/* See ncd2dispatch.c for other version */
int
NCD2_open(const char* path, int mode, int basepe, size_t *chunksizehintp,
void* mpidata, NC_Dispatch* dispatch, NC* drno)
void* mpidata, const NC_Dispatch* dispatch, NC* drno)
{
NCerror ncstat = NC_NOERR;
OCerror ocstat = OC_NOERR;
@ -1211,7 +1211,7 @@ fprintf(stderr,"basedim: %s=%ld\n",dim->ncfullname,(long)dim->dim.declsize);
int
constrainable(NCURI* durl)
{
char** protocol = constrainableprotocols;
const char** protocol = constrainableprotocols;
for(;*protocol;protocol++) {
if(strcmp(durl->protocol,*protocol)==0)
return 1;

View File

@ -46,7 +46,7 @@ extern "C" {
extern int
NCD2_open(const char *path, int mode,
int basepe, size_t *chunksizehintp,
void* mpidata, struct NC_Dispatch* dispatch, NC* ncp);
void* mpidata, const struct NC_Dispatch* dispatch, NC* ncp);
extern int
NCD2_close(int ncid,void*);

View File

@ -93,7 +93,7 @@ fprintf(stderr,"\n");
/* Fill in missing arguments */
if(startp == NULL)
startp = nc_sizevector0;
startp = NC_coord_zero;
if(countp == NULL) {
/* Accumulate the dimension sizes */
@ -105,7 +105,7 @@ fprintf(stderr,"\n");
}
if(stridep == NULL)
stridep = nc_ptrdiffvector1;
stridep = NC_stride_one;
/* Validate the dimension sizes */
for(i=0;i<ncrank;i++) {

View File

@ -230,7 +230,7 @@ set_curl_options(NCD4INFO* state)
hostport = NC_combinehostport(state->uri);
store = ncrc_globalstate.rcinfo.triples;
store = ncrc_getglobalstate()->rcinfo.triples;
for(i=0;i<nclistlength(store);i++) {
struct CURLFLAG* flag;

View File

@ -10,8 +10,6 @@
#include "ncdispatch.h"
#include "netcdf_aux.h"
int ncdap4debug = 0;
#ifdef D4CATCH
/* Place breakpoint here to catch errors close to where they occur*/
int
@ -138,7 +136,7 @@ NCD4_debugcopy(NCD4INFO* info)
NCD4node* dim = (NCD4node*)nclistget(var->dims,d);
edges[d] = (size_t)dim->dim.size;
}
if((ret=nc_put_vara(grpid,varid,nc_sizevector0,edges,memory)))
if((ret=nc_put_vara(grpid,varid,NC_coord_zero,edges,memory)))
goto done;
}
if((ret=ncaux_reclaim_data(ncid,type->meta.id,memory,dimprod)))

View File

@ -38,7 +38,7 @@ static const char* checkseps = "+,:;";
int
NCD4_open(const char * path, int mode,
int basepe, size_t *chunksizehintp,
void *mpidata, NC_Dispatch *dispatch, NC *nc)
void *mpidata, const NC_Dispatch *dispatch, NC *nc)
{
int ret = NC_NOERR;
NCD4INFO* d4info = NULL;
@ -376,14 +376,16 @@ set_curl_properties(NCD4INFO* d4info)
char* newpath = NULL;
int len;
errno = 0;
NCRCglobalstate* globalstate = ncrc_getglobalstate();
/* Create the unique cookie file name */
len =
strlen(ncrc_globalstate.tempdir)
strlen(globalstate->tempdir)
+ 1 /* '/' */
+ strlen("ncd4cookies");
path = (char*)malloc(len+1);
if(path == NULL) return NC_ENOMEM;
snprintf(path,len,"%s/nc4cookies",ncrc_globalstate.tempdir);
snprintf(path,len,"%s/nc4cookies",globalstate->tempdir);
/* Create the unique cookie file name */
newpath = NC_mktmp(path);
free(path);

View File

@ -24,11 +24,8 @@ static int readfile(NCD4INFO* state, const NCURI*, const char* suffix, NCbytes*
static int readfiletofile(NCD4INFO* state, const NCURI*, const char* suffix, FILE* stream, d4size_t*);
#ifdef HAVE_GETTIMEOFDAY
static struct timeval time0;
static struct timeval time1;
static double
deltatime()
deltatime(struct timeval time0,struct timeval time1)
{
double t0, t1;
t0 = ((double)time0.tv_sec);
@ -106,6 +103,10 @@ readpacket(NCD4INFO* state, NCURI* url, NCbytes* packet, NCD4mode dxx, long* las
int fileprotocol = 0;
const char* suffix = dxxextension(dxx);
CURL* curl = state->curl->curl;
#ifdef HAVE_GETTIMEOFDAY
struct timeval time0;
struct timeval time1;
#endif
fileprotocol = (strcmp(url->protocol,"file")==0);
@ -133,7 +134,7 @@ readpacket(NCD4INFO* state, NCURI* url, NCbytes* packet, NCD4mode dxx, long* las
double secs = 0;
#ifdef HAVE_GETTIMEOFDAY
gettimeofday(&time1,NULL);
secs = deltatime();
secs = deltatime(time0,time1);
#endif
nclog(NCLOGDBG,"fetch complete: %0.3f",secs);
}
@ -191,6 +192,10 @@ readfile(NCD4INFO* state, const NCURI* uri, const char* suffix, NCbytes* packet)
ncbytesnull(tmp);
filename = ncbytesextract(tmp);
ncbytesfree(tmp);
#ifdef HAVE_GETTIMEOFDAY
struct timeval time0;
struct timeval time1;
#endif
state->fileproto.filename = filename; /* filename is alloc'd here anyway */
@ -207,7 +212,7 @@ readfile(NCD4INFO* state, const NCURI* uri, const char* suffix, NCbytes* packet)
double secs;
#ifdef HAVE_GETTIMEOFDAY
gettimeofday(&time1,NULL);
secs = deltatime();
secs = deltatime(time0,time1);
#endif
nclog(NCLOGDBG,"fetch complete: %0.3f",secs);
}

View File

@ -21,7 +21,7 @@ NCD4_get_vara(int ncid, int varid,
{
int ret;
/* TODO: optimize since we know stride is 1 */
ret = NCD4_get_vars(ncid,varid,start,edges,nc_ptrdiffvector1,value,memtype);
ret = NCD4_get_vars(ncid,varid,start,edges,NC_stride_one,value,memtype);
return ret;
}

View File

@ -56,7 +56,7 @@ struct ezxml_root { /* additional data for the root tag*/
char err[EZXML_ERRL]; /* error string*/
};
char *EZXML_NIL[] = { NULL }; /* empty, null terminated array of strings*/
static const char *EZXML_NIL[] = { NULL }; /* empty, null terminated array of strings*/
/* returns the first child tag with the given name or NULL if not found*/
ezxml_t ezxml_child(ezxml_t xml, const char *name)
@ -131,7 +131,7 @@ const char **ezxml_pi(ezxml_t xml, const char *target)
if (! root) return (const char **)EZXML_NIL;
while (root->xml.parent) root = (ezxml_root_t)root->xml.parent; /* root tag*/
while (root->pi[i] && strcmp(target, root->pi[i][0])) i++; /* find target*/
return (const char **)((root->pi[i]) ? root->pi[i] + 1 : EZXML_NIL);
return ((root->pi[i]) ? (const char**)(root->pi[i] + 1) : EZXML_NIL);
}
/* set an error string and return root*/
@ -459,7 +459,7 @@ void ezxml_free_attr(char **attr) {
int i = 0;
char *m;
if (! attr || attr == EZXML_NIL) return; /* nothing to free*/
if (! attr || ((const char**)attr) == EZXML_NIL) return; /* nothing to free*/
while (attr[i]) i += 2; /* find end of attribute list*/
m = attr[i + 1]; /* list of which names and values are malloced*/
for (i = 0; m[i]; i++) {
@ -795,15 +795,15 @@ const char *ezxml_error(ezxml_t xml)
/* returns a new empty ezxml structure with the given root tag name*/
ezxml_t ezxml_new(const char *name)
{
static char *ent[] = { "lt;", "&#60;", "gt;", "&#62;", "quot;", "&#34;",
static const char *entities[] = { "lt;", "&#60;", "gt;", "&#62;", "quot;", "&#34;",
"apos;", "&#39;", "amp;", "&#38;", NULL };
ezxml_root_t root = (ezxml_root_t)memset(malloc(sizeof(struct ezxml_root)),
'\0', sizeof(struct ezxml_root));
root->xml.name = (char *)name;
root->cur = &root->xml;
strcpy(root->err, root->xml.txt = "");
root->ent = memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
root->attr = root->pi = (char ***)(root->xml.attr = EZXML_NIL);
root->ent = memcpy(malloc(sizeof(entities)), entities, sizeof(entities));
root->attr = root->pi = (char ***)(root->xml.attr = (char**)EZXML_NIL);
return &root->xml;
}
@ -859,7 +859,7 @@ ezxml_t ezxml_add_child(ezxml_t xml, const char *name, size_t off)
child = (ezxml_t)memset(malloc(sizeof(struct ezxml)), '\0',
sizeof(struct ezxml));
child->name = (char *)name;
child->attr = EZXML_NIL;
child->attr = (char**)EZXML_NIL;
child->txt = "";
return ezxml_insert(child, xml, off);
@ -885,7 +885,7 @@ ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value)
while (xml->attr[l] && strcmp(xml->attr[l], name)) l += 2;
if (! xml->attr[l]) { /* not found, add as new attribute*/
if (! value) return xml; /* nothing to do*/
if (xml->attr == EZXML_NIL) { /* first attribute*/
if (xml->attr == (char**)EZXML_NIL) { /* first attribute*/
xml->attr = malloc(4 * sizeof(char *));
xml->attr[1] = strdup(""); /* empty list of malloced names/vals*/
}

View File

@ -30,9 +30,9 @@ static char* constrainableprotocols[] = {"http", "https",NULL};
static int ncd4initialized = 0;
static NC_Dispatch NCD4_dispatch_base;
static const NC_Dispatch NCD4_dispatch_base;
NC_Dispatch* NCD4_dispatch_table = NULL; /* moved here from ddispatch.c */
const NC_Dispatch* NCD4_dispatch_table = NULL; /* moved here from ddispatch.c */
/* Forward */
static int globalinit(void);
@ -86,7 +86,7 @@ NCD4_sync(int ncid)
static int
NCD4_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* mpidata, NC_Dispatch *dispatch, NC *ncp)
void* mpidata, const NC_Dispatch *dispatch, NC *ncp)
{
return THROW(NC_EPERM);
}
@ -805,7 +805,7 @@ globalinit(void)
/**************************************************/
static NC_Dispatch NCD4_dispatch_base = {
static const NC_Dispatch NCD4_dispatch_base = {
NC_FORMATX_DAP4,

View File

@ -17,7 +17,7 @@ extern "C" {
extern int
NCD4_open(const char *path, int mode,
int basepe, size_t *chunksizehintp,
void *mpidata, struct NC_Dispatch *dispatch, NC *ncp);
void *mpidata, const struct NC_Dispatch *dispatch, NC *ncp);
extern int
NCD4_close(int ncid,void*);

View File

@ -97,7 +97,7 @@ NC_authsetup(NCauth* auth, NCURI* uri)
setdefaults(auth);
/* Note, we still must do this function even if
ncrc_globalstate.rc.ignore is set in order
ncrc_getglobalstate()->rc.ignore is set in order
to getinfo e.g. host+port from url
*/

View File

@ -423,7 +423,7 @@ ncaux_class_alignment(int ncclass)
EXTERNL size_t
ncaux_type_alignment(int xtype, int ncid)
{
if(!NC_alignments_computed) {
if(!ncaux_initialized) {
NC_compute_alignments();
ncaux_initialized = 1;
}

View File

@ -9,6 +9,7 @@ See LICENSE.txt for license information.
#include "nclog.h"
#include "ncbytes.h"
#include "ncrc.h"
#include "ncoffsets.h"
/* Required for getcwd, other functions. */
#ifdef HAVE_UNISTD_H
@ -23,11 +24,9 @@ See LICENSE.txt for license information.
/* Define vectors of zeros and ones for use with various nc_get_varX function*/
size_t nc_sizevector0[NC_MAX_VAR_DIMS];
size_t nc_sizevector1[NC_MAX_VAR_DIMS];
ptrdiff_t nc_ptrdiffvector1[NC_MAX_VAR_DIMS];
size_t NC_coord_zero[NC_MAX_VAR_DIMS];
size_t NC_coord_one[NC_MAX_VAR_DIMS];
const size_t NC_coord_zero[NC_MAX_VAR_DIMS];
const size_t NC_coord_one[NC_MAX_VAR_DIMS];
const ptrdiff_t NC_stride_one[NC_MAX_VAR_DIMS];
NCRCglobalstate ncrc_globalstate;
@ -42,18 +41,20 @@ NCDISPATCH_initialize(void)
{
int status = NC_NOERR;
int i;
NCRCglobalstate* globalstate = NULL;
memset(&ncrc_globalstate,0,sizeof(NCRCglobalstate));
{
size_t* c0 = (size_t*)NC_coord_zero;
size_t* c1 = (size_t*)NC_coord_one;
ptrdiff_t* s1 = (ptrdiff_t*)NC_stride_one;
for(i=0;i<NC_MAX_VAR_DIMS;i++) {
c0[0] = 0;
c1[i] = 1;
s1[i] = 1;
}
}
for(i=0;i<NC_MAX_VAR_DIMS;i++) {
nc_sizevector0[i] = 0;
nc_sizevector1[i] = 1;
nc_ptrdiffvector1[i] = 1;
}
for(i=0;i<NC_MAX_VAR_DIMS;i++) {
NC_coord_one[i] = 1;
NC_coord_zero[i] = 0;
}
globalstate = ncrc_getglobalstate(); /* will allocate and clear */
/* Capture temp dir*/
{
@ -71,8 +72,8 @@ NCDISPATCH_initialize(void)
tempdir = getcwd(cwd,sizeof(cwd));
if(tempdir == NULL || *tempdir == '\0') tempdir = ".";
}
ncrc_globalstate.tempdir= (char*)malloc(strlen(tempdir) + 1);
for(p=tempdir,q=ncrc_globalstate.tempdir;*p;p++,q++) {
globalstate->tempdir= (char*)malloc(strlen(tempdir) + 1);
for(p=tempdir,q=globalstate->tempdir;*p;p++,q++) {
if((*p == '/' && *(p+1) == '/')
|| (*p == '\\' && *(p+1) == '\\')) {p++;}
*q = *p;
@ -81,7 +82,7 @@ NCDISPATCH_initialize(void)
#ifdef _MSC_VER
#else
/* Canonicalize */
for(p=ncrc_globalstate.tempdir;*p;p++) {
for(p=globalstate->tempdir;*p;p++) {
if(*p == '\\') {*p = '/'; };
}
*q = '\0';
@ -96,10 +97,10 @@ NCDISPATCH_initialize(void)
if(home == NULL) {
/* use tempdir */
home = ncrc_globalstate.tempdir;
home = globalstate->tempdir;
}
ncrc_globalstate.home = (char*)malloc(strlen(home) + 1);
for(p=home,q=ncrc_globalstate.home;*p;p++,q++) {
globalstate->home = (char*)malloc(strlen(home) + 1);
for(p=home,q=globalstate->home;*p;p++,q++) {
if((*p == '/' && *(p+1) == '/')
|| (*p == '\\' && *(p+1) == '\\')) {p++;}
*q = *p;
@ -118,6 +119,9 @@ NCDISPATCH_initialize(void)
status = NC_rcload();
ncloginit();
/* Compute type alignments */
NC_compute_alignments();
return status;
}
@ -125,10 +129,7 @@ int
NCDISPATCH_finalize(void)
{
int status = NC_NOERR;
nullfree(ncrc_globalstate.tempdir);
nullfree(ncrc_globalstate.home);
NC_rcclear(&ncrc_globalstate.rcinfo);
memset(&ncrc_globalstate,0,sizeof(NCRCglobalstate));
ncrc_freeglobalstate();
return status;
}

View File

@ -1827,7 +1827,7 @@ NC_create(const char *path0, int cmode, size_t initialsz,
{
int stat = NC_NOERR;
NC* ncp = NULL;
NC_Dispatch* dispatcher = NULL;
const NC_Dispatch* dispatcher = NULL;
char* path = NULL;
NCmodel model;
char* newpath = NULL;
@ -1967,7 +1967,7 @@ NC_open(const char *path0, int omode, int basepe, size_t *chunksizehintp,
{
int stat = NC_NOERR;
NC* ncp = NULL;
NC_Dispatch* dispatcher = NULL;
const NC_Dispatch* dispatcher = NULL;
int inmemory = 0;
int diskless = 0;
int mmap = 0;

View File

@ -105,7 +105,7 @@ char* ctypenames[NCTYPES] = {
static NCtypealignvec vec[NC_NCTYPES];
static NCtypealignset set;
int NC_alignments_computed = 0;
static int NC_alignments_computed = 0;
/* Argument is a netcdf type class, except compound|ENUM */
size_t
@ -113,10 +113,8 @@ NC_class_alignment(int ncclass)
{
NCalignment* align = NULL;
int index = 0;
if(!NC_alignments_computed) {
if(!NC_alignments_computed)
NC_compute_alignments();
NC_alignments_computed = 1;
}
switch (ncclass) {
case NC_BYTE: index = NC_UCHARINDEX; break;
case NC_CHAR: index = NC_CHARINDEX; break;
@ -143,7 +141,6 @@ NC_class_alignment(int ncclass)
return align->alignment;
}
void
NC_compute_alignments(void)
{

View File

@ -43,11 +43,56 @@ static void storedump(char* msg, NClist* triples);
#endif
/* Define default rc files and aliases, also defines search order*/
static char* rcfilenames[] = {".daprc",".dodsrc",NULL};
static const char* rcfilenames[] = {".daprc",".dodsrc",".ncrc",NULL};
/**************************************************/
/* External Entry Points */
static NCRCglobalstate* ncrc_globalstate = NULL;
/* Get global state */
NCRCglobalstate*
ncrc_getglobalstate(void)
{
if(ncrc_globalstate == NULL) {
ncrc_globalstate = calloc(1,sizeof(NCRCglobalstate));
}
return ncrc_globalstate;
}
void
ncrc_freeglobalstate(void)
{
if(ncrc_globalstate != NULL) {
nullfree(ncrc_globalstate->tempdir);
nullfree(ncrc_globalstate->home);
NC_rcclear(&ncrc_globalstate->rcinfo);
free(ncrc_globalstate);
ncrc_globalstate = NULL;
}
}
void
NC_rcclear(NCRCinfo* info)
{
if(info == NULL) return;
nullfree(info->rcfile);
rcfreetriples(info->triples);
}
void
rcfreetriples(NClist* rc)
{
int i;
for(i=0;i<nclistlength(rc);i++) {
NCTriple* t = (NCTriple*)nclistget(rc,i);
nullfree(t->host);
nullfree(t->key);
nullfree(t->value);
free(t);
}
nclistfree(rc);
}
/* locate, read and compile the rc file, if any */
int
@ -55,12 +100,13 @@ NC_rcload(void)
{
int ret = NC_NOERR;
char* path = NULL;
NCRCglobalstate* globalstate = ncrc_getglobalstate();
if(ncrc_globalstate.rcinfo.ignore) {
if(globalstate->rcinfo.ignore) {
nclog(NCLOGDBG,"No runtime configuration file specified; continuing");
return (NC_NOERR);
}
if(ncrc_globalstate.rcinfo.loaded) return (NC_NOERR);
if(globalstate->rcinfo.loaded) return (NC_NOERR);
/* locate the configuration files in the following order:
1. specified by NC_set_rcfile
@ -68,17 +114,17 @@ NC_rcload(void)
3. ./<rcfile> (current directory)
4. $HOME/<rcfile>
*/
if(ncrc_globalstate.rcinfo.rcfile != NULL) { /* always use this */
path = strdup(ncrc_globalstate.rcinfo.rcfile);
if(globalstate->rcinfo.rcfile != NULL) { /* always use this */
path = strdup(globalstate->rcinfo.rcfile);
} else if(getenv(RCFILEENV) != NULL && strlen(getenv(RCFILEENV)) > 0) {
path = strdup(getenv(RCFILEENV));
} else {
char** rcname;
const char** rcname;
int found = 0;
for(rcname=rcfilenames;!found && *rcname;rcname++) {
ret = rcsearch(".",*rcname,&path);
if(ret == NC_NOERR && path == NULL) /* try $HOME */
ret = rcsearch(ncrc_globalstate.home,*rcname,&path);
ret = rcsearch(globalstate->home,*rcname,&path);
if(ret != NC_NOERR)
goto done;
if(path != NULL)
@ -97,7 +143,7 @@ NC_rcload(void)
}
}
done:
ncrc_globalstate.rcinfo.loaded = 1; /* even if not exists */
globalstate->rcinfo.loaded = 1; /* even if not exists */
nullfree(path);
return (ret);
}
@ -130,6 +176,7 @@ NC_set_rcfile(const char* rcfile)
{
int stat = NC_NOERR;
FILE* f = NULL;
NCRCglobalstate* globalstate = ncrc_getglobalstate();
if(rcfile != NULL && strlen(rcfile) == 0)
rcfile = NULL;
@ -139,38 +186,16 @@ NC_set_rcfile(const char* rcfile)
goto done;
}
fclose(f);
nullfree(ncrc_globalstate.rcinfo.rcfile);
ncrc_globalstate.rcinfo.rcfile = strdup(rcfile);
/* Clear ncrc_globalstate.rcinfo */
NC_rcclear(&ncrc_globalstate.rcinfo);
nullfree(globalstate->rcinfo.rcfile);
globalstate->rcinfo.rcfile = strdup(rcfile);
/* Clear globalstate->rcinfo */
NC_rcclear(&globalstate->rcinfo);
/* (re) load the rcfile and esp the triplestore*/
stat = NC_rcload();
done:
return stat;
}
void
NC_rcclear(NCRCinfo* info)
{
if(info == NULL) return;
nullfree(info->rcfile);
rcfreetriples(info->triples);
}
void
rcfreetriples(NClist* rc)
{
int i;
for(i=0;i<nclistlength(rc);i++) {
NCTriple* t = (NCTriple*)nclistget(rc,i);
nullfree(t->host);
nullfree(t->key);
nullfree(t->value);
free(t);
}
nclistfree(rc);
}
/**************************************************/
/* RC processing functions */
@ -261,6 +286,7 @@ rccompile(const char* path)
NCbytes* tmp = ncbytesnew();
NCURI* uri = NULL;
char* nextline = NULL;
NCRCglobalstate* globalstate = ncrc_getglobalstate();
if((ret=NC_readfile(path,tmp))) {
nclog(NCLOGERR, "Could not open configuration file: %s",path);
@ -269,12 +295,12 @@ rccompile(const char* path)
contents = ncbytesextract(tmp);
if(contents == NULL) contents = strdup("");
/* Either reuse or create new */
rc = ncrc_globalstate.rcinfo.triples;
rc = globalstate->rcinfo.triples;
if(rc != NULL)
rcfreetriples(rc); /* clear out any old data */
else {
rc = nclistnew();
ncrc_globalstate.rcinfo.triples = rc;
globalstate->rcinfo.triples = rc;
}
nextline = contents;
for(;;) {
@ -357,10 +383,11 @@ static struct NCTriple*
rclocate(const char* key, const char* hostport)
{
int i,found;
NClist* rc = ncrc_globalstate.rcinfo.triples;
NCRCglobalstate* globalstate = ncrc_getglobalstate();
NClist* rc = globalstate->rcinfo.triples;
NCTriple* triple = NULL;
if(ncrc_globalstate.rcinfo.ignore)
if(globalstate->rcinfo.ignore)
return NULL;
if(key == NULL || rc == NULL) return NULL;
@ -432,7 +459,8 @@ NC_rcfile_insert(const char* key, const char* value, const char* hostport)
int ret = NC_NOERR;
/* See if this key already defined */
struct NCTriple* triple = NULL;
NClist* rc = ncrc_globalstate.rcinfo.triples;
NCRCglobalstate* globalstate = ncrc_getglobalstate();
NClist* rc = globalstate->rcinfo.triples;
if(rc == NULL) {
rc = nclistnew();

View File

@ -253,7 +253,7 @@ NC_RO_sync(int ncid)
int
NC_RO_create(const char* path, int cmode, size_t initialsz, int basepe,
size_t *chunksizehintp, void *parameters,
NC_Dispatch *dispatch, NC *nc_file)
const NC_Dispatch *dispatch, NC *nc_file)
{
return NC_EPERM;
}

View File

@ -268,7 +268,7 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
while(odom_more(&odom)) {
int localstatus = NC_NOERR;
/* Read a single value */
localstatus = NC_get_vara(ncid,varid,odom.index,nc_sizevector1,memptr,memtype);
localstatus = NC_get_vara(ncid,varid,odom.index,NC_coord_one,memptr,memtype);
/* So it turns out that when get_varm is used, all errors are
delayed and ERANGE will be overwritten by more serious errors.
*/

View File

@ -283,7 +283,7 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
while(odom_more(&odom)) {
int localstatus = NC_NOERR;
/* Write a single value */
localstatus = NC_put_vara(ncid,varid,odom.index,nc_sizevector1,memptr,memtype);
localstatus = NC_put_vara(ncid,varid,odom.index,NC_coord_one,memptr,memtype);
/* So it turns out that when get_varm is used, all errors are
delayed and ERANGE will be overwritten by more serious errors.
*/

View File

@ -17,8 +17,6 @@
#include "ncdispatch.h"
int ncdebug = 0;
/* This is the default create format for nc_create and nc__create. */
static int default_create_format = NC_FORMAT_CLASSIC;
@ -55,7 +53,7 @@ free_NC(NC *ncp)
}
int
new_NC(NC_Dispatch* dispatcher, const char* path, int mode, NCmodel* model, NC** ncpp)
new_NC(const NC_Dispatch* dispatcher, const char* path, int mode, NCmodel* model, NC** ncpp)
{
NC *ncp = (NC*)calloc(1,sizeof(NC));
if(ncp == NULL) return NC_ENOMEM;

View File

@ -17,7 +17,7 @@
#define DEFAULTALLOC 1024
#define ALLOCINCR 1024
static int ncbytesdebug = 1;
#define NCBYTESDEBUG 1
static int
ncbytesfail(void)
@ -25,7 +25,9 @@ ncbytesfail(void)
fflush(stdout);
fprintf(stderr,"bytebuffer failure\n");
fflush(stderr);
if(ncbytesdebug) abort();
#ifdef NCBYTESDEBUG
abort();
#endif
return FALSE;
}

View File

@ -72,8 +72,8 @@ extern unsigned int hash_fast(const char*, size_t length);
#define MAX(a,b) ((a) > (b) ? (a) : (b))
/* Forward */
static unsigned int NC_nprimes;
static unsigned int NC_primes[16386];
static const unsigned int NC_nprimes;
static const unsigned int NC_primes[16386];
static unsigned int findPrimeGreaterThan(size_t val);
extern void printhashmapstats(NC_hashmap* hm);
@ -397,7 +397,7 @@ Table of the the first 2^14 primes.
Add leading and trailing values to simplify
search binary algorithm.
*/
static unsigned int NC_primes[16386] = {
static const unsigned int NC_primes[16386] = {
0U,
2U, 3U, 5U, 7U, 11U, 13U, 17U, 19U, 23U, 29U,
31U, 37U, 41U, 43U, 47U, 53U, 59U, 61U, 67U, 71U,
@ -2041,7 +2041,7 @@ static unsigned int NC_primes[16386] = {
0xFFFFFFFF
};
static unsigned int NC_nprimes = (sizeof(NC_primes) / sizeof(unsigned int));
static const unsigned int NC_nprimes = (sizeof(NC_primes) / sizeof(unsigned int));
/**************************************************/
/* Debug support */

View File

@ -18,25 +18,29 @@
#endif
extern FILE* fdopen(int fd, const char *mode);
#include "nclog.h"
#define PREFIXLEN 8
#define MAXTAGS 256
#define NCTAGDFALT "Log";
static int nclogginginitialized = 0;
static int nclogging = 0;
static int ncsystemfile = 0; /* 1 => we are logging to file we did not open */
static char* nclogfile = NULL;
static FILE* nclogstream = NULL;
static int nctagsize = 0;
static char** nctagset = NULL;
static char* nctagdfalt = NULL;
static char* nctagsetdfalt[] = {"Warning","Error","Note","Debug"};
static char* nctagname(int tag);
static struct NCLOGGLOBAL {
int nclogging;
int ncsystemfile; /* 1 => we are logging to file we did not open */
char* nclogfile;
FILE* nclogstream;
} nclog_global = {0,0,NULL,NULL};
static const char* nctagset[] = {"Warning","Error","Note","Debug"};
static const int nctagsize = sizeof(nctagset)/sizeof(char*);
/* Forward */
static const char* nctagname(int tag);
/*!\defgroup NClog NClog Management
@{*/
@ -50,9 +54,10 @@ ncloginit(void)
if(nclogginginitialized)
return;
nclogginginitialized = 1;
memset(&nclog_global,0,sizeof(nclog_global));
ncsetlogging(0);
nclogfile = NULL;
nclogstream = NULL;
nclog_global.nclogfile = NULL;
nclog_global.nclogstream = NULL;
/* Use environment variables to preset nclogging state*/
/* I hope this is portable*/
file = getenv(NCENVFLAG);
@ -61,8 +66,6 @@ ncloginit(void)
ncsetlogging(1);
}
}
nctagdfalt = NCTAGDFALT;
nctagset = nctagsetdfalt;
}
/*!
@ -78,8 +81,8 @@ ncsetlogging(int tf)
{
int was;
if(!nclogginginitialized) ncloginit();
was = nclogging;
nclogging = tf;
was = nclog_global.nclogging;
nclog_global.nclogging = tf;
return was;
}
@ -100,36 +103,36 @@ nclogopen(const char* file)
nclogclose();
if(file == NULL || strlen(file) == 0) {
/* use stderr*/
nclogstream = stderr;
nclogfile = NULL;
ncsystemfile = 1;
nclog_global.nclogstream = stderr;
nclog_global.nclogfile = NULL;
nclog_global.ncsystemfile = 1;
} else if(strcmp(file,"stdout") == 0) {
/* use stdout*/
nclogstream = stdout;
nclogfile = NULL;
ncsystemfile = 1;
nclog_global.nclogstream = stdout;
nclog_global.nclogfile = NULL;
nclog_global.ncsystemfile = 1;
} else if(strcmp(file,"stderr") == 0) {
/* use stderr*/
nclogstream = stderr;
nclogfile = NULL;
ncsystemfile = 1;
nclog_global.nclogstream = stderr;
nclog_global.nclogfile = NULL;
nclog_global.ncsystemfile = 1;
} else {
int fd;
nclogfile = strdup(file);
nclogstream = NULL;
nclog_global.nclogfile = strdup(file);
nclog_global.nclogstream = NULL;
/* We need to deal with this file carefully
to avoid unauthorized access*/
fd = open(nclogfile,O_WRONLY|O_APPEND|O_CREAT,0600);
fd = open(nclog_global.nclogfile,O_WRONLY|O_APPEND|O_CREAT,0600);
if(fd >= 0) {
nclogstream = fdopen(fd,"a");
nclog_global.nclogstream = fdopen(fd,"a");
} else {
free(nclogfile);
nclogfile = NULL;
nclogstream = NULL;
free(nclog_global.nclogfile);
nclog_global.nclogfile = NULL;
nclog_global.nclogstream = NULL;
ncsetlogging(0);
return 0;
}
ncsystemfile = 0;
nclog_global.ncsystemfile = 0;
}
return 1;
}
@ -138,13 +141,13 @@ void
nclogclose(void)
{
if(!nclogginginitialized) ncloginit();
if(nclogstream != NULL && !ncsystemfile) {
fclose(nclogstream);
if(nclog_global.nclogstream != NULL && !nclog_global.ncsystemfile) {
fclose(nclog_global.nclogstream);
}
if(nclogfile != NULL) free(nclogfile);
nclogstream = NULL;
nclogfile = NULL;
ncsystemfile = 0;
if(nclog_global.nclogfile != NULL) free(nclog_global.nclogfile);
nclog_global.nclogstream = NULL;
nclog_global.nclogfile = NULL;
nclog_global.ncsystemfile = 0;
}
/*!
@ -160,41 +163,41 @@ void
nclog(int tag, const char* fmt, ...)
{
va_list args;
char* prefix;
const char* prefix;
if(!nclogginginitialized) ncloginit();
if(!nclogging || nclogstream == NULL) return;
if(!nclog_global.nclogging || nclog_global.nclogstream == NULL) return;
prefix = nctagname(tag);
fprintf(nclogstream,"%s:",prefix);
fprintf(nclog_global.nclogstream,"%s:",prefix);
if(fmt != NULL) {
va_start(args, fmt);
vfprintf(nclogstream, fmt, args);
vfprintf(nclog_global.nclogstream, fmt, args);
va_end( args );
}
fprintf(nclogstream, "\n" );
fflush(nclogstream);
fprintf(nclog_global.nclogstream, "\n" );
fflush(nclog_global.nclogstream);
}
void
ncvlog(int tag, const char* fmt, va_list ap)
{
char* prefix;
const char* prefix;
if(!nclogginginitialized) ncloginit();
if(!nclogging || nclogstream == NULL) return;
if(!nclog_global.nclogging || nclog_global.nclogstream == NULL) return;
prefix = nctagname(tag);
fprintf(nclogstream,"%s:",prefix);
fprintf(nclog_global.nclogstream,"%s:",prefix);
if(fmt != NULL) {
vfprintf(nclogstream, fmt, ap);
vfprintf(nclog_global.nclogstream, fmt, ap);
}
fprintf(nclogstream, "\n" );
fflush(nclogstream);
fprintf(nclog_global.nclogstream, "\n" );
fflush(nclog_global.nclogstream);
}
void
@ -214,35 +217,17 @@ void
nclogtextn(int tag, const char* text, size_t count)
{
NC_UNUSED(tag);
if(!nclogging || nclogstream == NULL) return;
fwrite(text,1,count,nclogstream);
fflush(nclogstream);
if(!nclog_global.nclogging || nclog_global.nclogstream == NULL) return;
fwrite(text,1,count,nclog_global.nclogstream);
fflush(nclog_global.nclogstream);
}
/* The tagset is null terminated */
void
nclogsettags(char** tagset, char* dfalt)
{
nctagdfalt = dfalt;
if(tagset == NULL) {
nctagsize = 0;
} else {
int i;
/* Find end of the tagset */
for(i=0;i<MAXTAGS;i++) {if(tagset[i]==NULL) break;}
nctagsize = i;
}
nctagset = tagset;
}
static char*
static const char*
nctagname(int tag)
{
if(tag < 0 || tag >= nctagsize) {
return nctagdfalt;
} else {
return nctagset[tag];
}
if(tag < 0 || tag >= nctagsize)
return "unknown";
return nctagset[tag];
}
/**@}*/

View File

@ -26,6 +26,9 @@
#include "ncconfigure.h"
#include "nctime.h"
static const cdCompTime ZA = {1582, 10, 5, 0.0};
static const cdCompTime ZB = {1582, 10, 15, 0.0};
static int cuErrOpts; /* Error options */
static int cuErrorOccurred = 0; /* True iff cdError was called */
@ -75,8 +78,11 @@ cdError(char *fmt, ...)
#define ISLEAP(year,timeType) ((timeType & Cd366) || (((timeType) & CdHasLeap) && (!((year) % 4) && (((timeType) & CdJulianType) || (((year) % 100) || !((year) % 400))))))
static int mon_day_cnt[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
static int days_sum[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
static const int mon_day_cnt_normal[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
static const int mon_day_cnt_leap[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
static const int days_sum[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
static const int* mon_day_cnt;
/* Compute month and day from year and day-of-year.
*
@ -114,9 +120,9 @@ CdMonthDay(int *doy, CdTime *date)
year = date->year;
if (ISLEAP(year,date->timeType)) {
mon_day_cnt[1] = 29;
mon_day_cnt = mon_day_cnt_leap;
} else {
mon_day_cnt[1] = 28;
mon_day_cnt = mon_day_cnt_normal;
}
date->month = 0;
for (i = 0; i < 12; i++) {
@ -434,10 +440,8 @@ cdDiffJulian(cdCompTime ca, cdCompTime cb){
/* ca - cb in mixed Julian/Gregorian calendar. */
/* Result is in hours. */
static double
cdDiffMixed(cdCompTime ca, cdCompTime cb){
static cdCompTime ZA = {1582, 10, 5, 0.0};
static cdCompTime ZB = {1582, 10, 15, 0.0};
cdDiffMixed(cdCompTime ca, cdCompTime cb)
{
double result;
if (cdCompCompare(cb, ZB) == -1){
@ -905,8 +909,6 @@ cdCompAdd(cdCompTime comptime, double value, cdCalenType calendar, cdCompTime *r
static void
cdCompAddMixed(cdCompTime ct, double value, cdCompTime *result){
static cdCompTime ZA = {1582, 10, 5, 0.0};
static cdCompTime ZB = {1582, 10, 15, 0.0};
double xj, xg;
if (cdCompCompare(ct, ZB) == -1){

View File

@ -57,14 +57,14 @@
#define rshift(buf,buflen) {memmove(buf+1,buf,buflen+1);}
/* Allowable character sets for encode */
static char* pathallow =
static const char* pathallow =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$&'()*+,-./:;=?@_~";
static char* queryallow =
static const char* queryallow =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$&'()*+,-./:;=?@_~";
/* user+pwd allow = path allow - "@:" */
static char* userpwdallow =
static const char* userpwdallow =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!$&'()*+,-.;=_~?#/";
#ifndef HAVE_STRNDUP
@ -748,7 +748,7 @@ ncrshift1(char* p)
/* Provide % encoders and decoders */
static char* hexchars = "0123456789abcdefABCDEF";
static const char* hexchars = "0123456789abcdefABCDEF";
static void
toHex(unsigned int b, char hex[2])
@ -782,7 +782,7 @@ ncuriencodeuserpwd(char* s)
*/
char*
ncuriencodeonly(char* s, char* allowable)
ncuriencodeonly(char* s, const char* allowable)
{
size_t slen;
char* encoded;

View File

@ -14,7 +14,7 @@
/* This is the dispatch object that holds pointers to all the
* functions that make up the HDF4 dispatch interface. */
static NC_Dispatch HDF4_dispatcher = {
static const NC_Dispatch HDF4_dispatcher = {
NC_FORMATX_NC_HDF4,
@ -104,7 +104,7 @@ static NC_Dispatch HDF4_dispatcher = {
NC_NOTNC4_get_var_chunk_cache
};
NC_Dispatch* HDF4_dispatch_table = NULL;
const NC_Dispatch* HDF4_dispatch_table = NULL;
/**
* @internal Initialize HDF4 dispatch layer.

View File

@ -594,7 +594,7 @@ hdf4_read_var(NC_FILE_INFO_T *h5, int v)
*/
int
NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
void *parameters, NC_Dispatch *dispatch, NC *nc_file)
void *parameters, const NC_Dispatch *dispatch, NC *nc_file)
{
NC_FILE_INFO_T *h5;
NC_HDF4_FILE_INFO_T *hdf4_file;

View File

@ -271,7 +271,7 @@ exit: /*failure exit*/
int
NC4_create(const char* path, int cmode, size_t initialsz, int basepe,
size_t *chunksizehintp, void *parameters,
NC_Dispatch *dispatch, NC *nc_file)
const NC_Dispatch *dispatch, NC *nc_file)
{
int res;

View File

@ -15,7 +15,7 @@
#include "H5FDhttp.h"
#endif
static NC_Dispatch NC4_dispatcher = {
static const NC_Dispatch HDF5_dispatcher = {
NC_FORMATX_NC4,
@ -108,7 +108,7 @@ static NC_Dispatch NC4_dispatcher = {
};
NC_Dispatch* HDF5_dispatch_table = NULL; /* moved here from ddispatch.c */
const NC_Dispatch* HDF5_dispatch_table = NULL; /* moved here from ddispatch.c */
/**
* @internal Initialize the HDF5 dispatch layer.
@ -119,8 +119,7 @@ NC_Dispatch* HDF5_dispatch_table = NULL; /* moved here from ddispatch.c */
int
NC_HDF5_initialize(void)
{
HDF5_dispatch_table = &NC4_dispatcher;
HDF5_dispatch_table = &HDF5_dispatcher;
if (!nc4_hdf5_initialized)
nc4_hdf5_initialize();

View File

@ -862,7 +862,7 @@ exit:
*/
int
NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
void *parameters, NC_Dispatch *dispatch, NC *nc_file)
void *parameters, const NC_Dispatch *dispatch, NC *nc_file)
{
assert(nc_file && path && dispatch && nc_file &&
nc_file->model->impl == NC_FORMATX_NC4);

View File

@ -208,6 +208,9 @@ typedef struct {
NC_FILE_INFO_T* h5;
} H5LT_file_image_ud_t;
/* Unique id for file name */
static long file_name_counter;
/* callbacks prototypes for file image ops */
static void *local_image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata);
static void *local_image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *udata);
@ -729,8 +732,6 @@ NC4_image_init(NC_FILE_INFO_T* h5)
&local_image_realloc, &local_image_free,
&local_udata_copy, &local_udata_free,
(void *)NULL};
static long file_name_counter;
imageflags = h5->mem.imageflags;
create = h5->mem.created;

View File

@ -11,7 +11,6 @@
#include "ncdispatch.h"
extern int NC3_initialize(void);
extern int NC3_finalize(void);
@ -52,9 +51,6 @@ extern int NC_HDF4_finalize(void);
#include <fcntl.h>
#endif
int NC_argc = 1;
char* NC_argv[] = {"nc_initialize",NULL};
int NC_initialized = 0;
int NC_finalized = 1;

View File

@ -80,7 +80,7 @@ static int NC3_set_var_chunk_cache(int,int,size_t,size_t,float);
static int NC3_get_var_chunk_cache(int,int,size_t*,size_t*,float*);
#endif /*USE_NETCDF4*/
static NC_Dispatch NC3_dispatcher = {
static const NC_Dispatch NC3_dispatcher = {
NC_FORMATX_NC3,
@ -173,7 +173,7 @@ NC3_get_var_chunk_cache,
};
NC_Dispatch* NC3_dispatch_table = NULL; /*!< NC3 Dispatch table, moved here from ddispatch.c */
const NC_Dispatch* NC3_dispatch_table = NULL; /*!< NC3 Dispatch table, moved here from ddispatch.c */
int
NC3_initialize(void)

View File

@ -1039,7 +1039,7 @@ int NC3_new_nc(NC3_INFO** ncpp)
int
NC3_create(const char *path, int ioflags, size_t initialsz, int basepe,
size_t *chunksizehintp, void *parameters,
NC_Dispatch *dispatch, NC *nc)
const NC_Dispatch *dispatch, NC *nc)
{
int status = NC_NOERR;
void *xp = NULL;
@ -1171,7 +1171,7 @@ nc_set_default_format(int format, int *old_formatp)
int
NC3_open(const char *path, int ioflags, int basepe, size_t *chunksizehintp,
void *parameters, NC_Dispatch *dispatch, NC *nc)
void *parameters, const NC_Dispatch *dispatch, NC *nc)
{
int status;
NC3_INFO* nc3 = NULL;

View File

@ -499,7 +499,7 @@ printValue(NC4printer* out, NCID* basetype, void* value, int depth)
/* Make public to allow use elsewhere */
static char hexchars[16] = "0123456789abcdef";
static const char hexchars[16] = "0123456789abcdef";
static int
getPrintValue(NCbytes* out, NCID* basetype, void* value)

View File

@ -15,7 +15,7 @@
#include "nc4dispatch.h"
/** @internal Names of atomic types. */
char* nc4_atomic_name[NUM_ATOMIC_TYPES] = {"none", "byte", "char",
const char* nc4_atomic_name[NUM_ATOMIC_TYPES] = {"none", "byte", "char",
"short", "int", "float",
"double", "ubyte",
"ushort", "uint",

View File

@ -44,7 +44,7 @@ NCP_create(const char *path,
int basepe,
size_t *chunksizehintp,
void *mpidata,
struct NC_Dispatch *table,
const struct NC_Dispatch *table,
NC *nc)
{
int status;
@ -81,7 +81,7 @@ NCP_open(const char *path,
int basepe,
size_t *chunksizehintp,
void *mpidata,
struct NC_Dispatch *table,
const struct NC_Dispatch *table,
NC *nc)
{
int status;
@ -1380,7 +1380,7 @@ NCP_inq_user_type(int ncid, nc_type typeid, char *name, size_t *size,
/**************************************************/
/* Pnetcdf Dispatch table */
NC_Dispatch NCP_dispatcher = {
static const NC_Dispatch NCP_dispatcher = {
NC_FORMATX_PNETCDF,
@ -1473,7 +1473,7 @@ NC_NOTNC4_get_var_chunk_cache,
};
NC_Dispatch *NCP_dispatch_table = NULL; /* moved here from ddispatch.c */
const NC_Dispatch *NCP_dispatch_table = NULL; /* moved here from ddispatch.c */
int
NCP_initialize(void)

View File

@ -125,6 +125,7 @@ main()
printf("********************\n");
printf("open URL %s\n",url);
printf(" \n");
fflush(stdout);
ncstatus = nc_open(url, NC_NOWRITE, &ncid);
@ -174,10 +175,10 @@ main()
printf("%s[%d] = %f\n",VAR1,i,dat[i]);
printf(" \n");
for (i=(nelems-11); i<(nelems-1); i++)
printf("%s[%d] = %f\n",VAR1,i,dat[i]);
printf(" \n");
fflush(stdout);
#endif
memset((void*)dat,0,sizeof(dat));
@ -193,6 +194,7 @@ main()
printf("********************\n");
printf("Read %s data w/o strides\n",VAR2);
printf(" \n");
fflush(stdout);
#endif
start[0] = 0;
@ -210,6 +212,7 @@ main()
for (idim=0; idim<ndim; idim++)
printf("start[%d]=%3lu count[%d]=%3lu stride[%d]=%3lu\n",
idim, (unsigned long)start[idim], idim, (unsigned long)count[idim], idim, (unsigned long)stride[idim]);
fflush(stdout);
#endif
ncstatus = nc_get_vars_float (ncid, varid, start, count, stride, (float*) dat);
@ -227,6 +230,7 @@ main()
for (i=(nelems-11); i<(nelems-1); i++)
printf("%s[%d] = %f\n",VAR2,i,dat[i]);
printf(" \n");
fflush(stdout);
#endif
memset((void*)dat,0,sizeof(dat));
@ -237,6 +241,7 @@ main()
printf(" \n");
printf("********************\n");
printf("Close and reopen the dataset\n");
fflush(stdout);
#endif
ncstatus = nc_close (ncid);
@ -252,6 +257,7 @@ main()
printf("********************\n");
printf("Read a subset of %s data with strides\n",VAR1);
printf(" \n");
fflush(stdout);
#endif
start[0] = 250;
@ -265,8 +271,9 @@ main()
#ifdef VERBOSE
for (idim=0; idim<ndim; idim++)
printf("start[%1d]=%3lu count[%1d]=%3lu stride[%1d]=%3lu\n",
printf("start[%d]=%lu count[%d]=%lu stride[%d]=%lu\n",
idim,(unsigned long)start[idim],idim,(unsigned long)count[idim],idim,(unsigned long)stride[idim]);
fflush(stdout);
#endif
memset((void*)sdat,0,sizeof(sdat));
@ -290,6 +297,7 @@ main()
for (i=0; i<10; i++)
printf("%s[%d] = %f\n",VAR1,i,sdat[i]);
fflush(stdout);
#endif
ncstatus = nc_close (ncid);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -30,13 +30,13 @@ static int tohex(int c);
#ifdef INFORMATIONAL
/* Set of all ascii printable characters */
static char ascii[] = " !\"#$%&'()*+,-./:;<=>?@[]\\^_`|{}~";
static const char ascii[] = " !\"#$%&'()*+,-./:;<=>?@[]\\^_`|{}~";
/* Define the set of legal nonalphanum characters as specified in the DAP2 spec. */
static char* daplegal ="_!~*'-\"";
static const char* daplegal ="_!~*'-\"";
#endif
static char* ddsworddelims =
static const char* ddsworddelims =
"{}[]:;=,";
/* Define 1 and > 1st legal characters */
@ -51,7 +51,7 @@ static const char* ddswordcharsn =
"-+_/%\\.*!~'\"";
/* This includes sharp and colon for historical reasons */
static char* daswordcharsn =
static const char* daswordcharsn =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
"-+_/%\\.*#:!~'\"";

View File

@ -1452,7 +1452,7 @@ and the read request cannot be completed.
OCerror
oc_data_readn(OCobject link, OCobject datanode,
size_t* start, size_t N,
const size_t* start, size_t N,
size_t memsize, void* memory)
{
OCerror ocerr = OC_NOERR;

View File

@ -436,7 +436,7 @@ EXTERNL OCerror oc_data_readscalar(OClink, OCdatanode, size_t, void*);
and free'ing it.
See also oc_dds_readn().
*/
EXTERNL OCerror oc_data_readn(OClink, OCdatanode, size_t*, size_t, size_t, void*);
EXTERNL OCerror oc_data_readn(OClink, OCdatanode, const size_t*, size_t, size_t, void*);
/* Return the indices for this datas; Assumes the data
was obtained using oc_data_ithelement or oc_data_ithrecord;

View File

@ -22,23 +22,18 @@ static void dumpocnode1(OCnode* node, int depth);
static void dumpdimensions(OCnode* node);
static void dumpattvalue(OCtype nctype, char** aset, int index);
static char* sindent = NULL;
static const char* sindent =
" ";
static char*
static const char*
dent(int n)
{
if(sindent == NULL) {
sindent = (char*)ocmalloc(102);
MEMCHECK(sindent,NULL);
memset((void*)sindent,(int)' ',(size_t)101);
sindent[101] = '\0';
}
if(n > 100) n = 100;
return sindent+(100-n);
}
/* support [dd] leader*/
static char*
static const char*
dent2(int n) {return dent(n+4);}
static void
@ -500,6 +495,8 @@ ocdumpdata(OCstate* state, OCdata* data, NCbytes* buffer, int frominstance)
{
char tmp[1024];
OCnode* pattern = data->pattern;
char* smode = NULL;
snprintf(tmp,sizeof(tmp),"%lx:",(unsigned long)data);
ncbytescat(buffer,tmp);
if(!frominstance) {
@ -523,7 +520,8 @@ ocdumpdata(OCstate* state, OCdata* data, NCbytes* buffer, int frominstance)
snprintf(tmp,sizeof(tmp),"%lx",(unsigned long)data->container);
ncbytescat(buffer,tmp);
ncbytescat(buffer," mode=");
ncbytescat(buffer,ocdtmodestring(data->datamode,0));
ncbytescat(buffer,(smode=ocdtmodestring(data->datamode,0)));
nullfree(smode);
}
/*
@ -545,6 +543,7 @@ ocdumpdatatree(OCstate* state, OCdata* data, NCbytes* buffer, int depth)
size_t crossproduct;
int tabstop = 0;
const char* typename;
char* smode = NULL;
/* If this is the first call, then dump a header line */
if(depth == 0) {
@ -581,7 +580,8 @@ ocdumpdatatree(OCstate* state, OCdata* data, NCbytes* buffer, int depth)
tabto(tabstops[++tabstop],buffer);
/* Dump the mode flags in compact form */
ncbytescat(buffer,ocdtmodestring(data->datamode,1));
ncbytescat(buffer,(smode=ocdtmodestring(data->datamode,1)));
nullfree(smode);
tabto(tabstops[++tabstop],buffer);

View File

@ -327,14 +327,15 @@ createtempfile(OCstate* state, OCtree* tree)
char* path = NULL;
char* tmppath = NULL;
int len;
NCRCglobalstate* globalstate = ncrc_getglobalstate();
len =
strlen(ncrc_globalstate.tempdir)
strlen(globalstate->tempdir)
+ 1 /* '/' */
+ strlen(DATADDSFILE);
path = (char*)malloc(len+1);
if(path == NULL) return OC_ENOMEM;
occopycat(path,len,3,ncrc_globalstate.tempdir,"/",DATADDSFILE);
occopycat(path,len,3,globalstate->tempdir,"/",DATADDSFILE);
tmppath = NC_mktmp(path);
free(path);
if(stat != OC_NOERR) goto fail;
@ -462,8 +463,8 @@ fprintf(stderr,"missing bod: ddslen=%lu bod=%lu\n",
}
/* Allow these (non-alpha-numerics) to pass thru */
static char okchars[] = "&/:;,.=?@'\"<>{}!|\\^[]`~";
static char hexdigits[] = "0123456789abcdef";
static const char okchars[] = "&/:;,.=?@'\"<>{}!|\\^[]`~";
static const char hexdigits[] = "0123456789abcdef";
/* Modify constraint to use %XX escapes */
static char*
@ -559,6 +560,8 @@ static OCerror
ocset_curlproperties(OCstate* state)
{
OCerror stat = OC_NOERR;
NCRCglobalstate* globalstate = ncrc_getglobalstate();
if(state->auth.curlflags.useragent == NULL) {
size_t len = strlen(DFALTUSERAGENT) + strlen(VERSION) + 1;
char* agent = (char*)malloc(len+1);
@ -586,12 +589,12 @@ ocset_curlproperties(OCstate* state)
errno = 0;
/* Create the unique cookie file name */
len =
strlen(ncrc_globalstate.tempdir)
strlen(globalstate->tempdir)
+ 1 /* '/' */
+ strlen("occookies");
path = (char*)calloc(1,len+1);
if(path == NULL) return OC_ENOMEM;
occopycat(path,len,3,ncrc_globalstate.tempdir,"/","occookies");
occopycat(path,len,3,globalstate->tempdir,"/","occookies");
tmppath = NC_mktmp(path);
free(path);
state->auth.curlflags.cookiejar = tmppath;
@ -647,7 +650,7 @@ fail:
return OCTHROW(stat);
}
static char* ERROR_TAG = "Error ";
static const char* ERROR_TAG = "Error ";
static int
dataError(XXDR* xdrs, OCstate* state)

View File

@ -22,7 +22,7 @@
#include "ocdebug.h"
/* Order is important: longest first */
static char* DDSdatamarks[3] = {"Data:\r\n","Data:\n",(char*)NULL};
static const char* DDSdatamarks[3] = {"Data:\r\n","Data:\n",(char*)NULL};
/* Not all systems have strndup, so provide one*/
char*
@ -136,12 +136,12 @@ ocfindbod(NCbytes* buffer, size_t* bodp, size_t* ddslenp)
unsigned int i;
char* content;
size_t len = ncbyteslength(buffer);
char** marks;
const char** marks;
content = ncbytescontents(buffer);
for(marks = DDSdatamarks;*marks;marks++) {
char* mark = *marks;
const char* mark = *marks;
size_t tlen = strlen(mark);
for(i=0;i<len;i++) {
if((i+tlen) <= len
@ -471,7 +471,7 @@ done:
for set of dimension indices.
*/
size_t
ocarrayoffset(size_t rank, size_t* sizes, size_t* indices)
ocarrayoffset(size_t rank, size_t* sizes, const size_t* indices)
{
unsigned int i;
size_t count = 0;
@ -538,7 +538,7 @@ oc_ispacked(OCnode* node)
/* Must be consistent with ocx.h.OCDT */
#define NMODES 6
#define MAXMODENAME 8 /*max (strlen(modestrings[i])) */
static char* modestrings[NMODES+1] = {
static const char* modestrings[NMODES+1] = {
"FIELD", /* ((OCDT)(1<<0)) field of a container */
"ELEMENT", /* ((OCDT)(1<<1)) element of a structure array */
"RECORD", /* ((OCDT)(1<<2)) record of a sequence */
@ -548,19 +548,23 @@ static char* modestrings[NMODES+1] = {
NULL,
};
const char*
char*
ocdtmodestring(OCDT mode,int compact)
{
static char result[1+(NMODES*(MAXMODENAME+1))]; /* hack to avoid malloc */
char* result = NULL;
int i;
char* p = result;
char* p = NULL;
result = malloc(1+(NMODES*(MAXMODENAME+1)));
if(result == NULL) return NULL;
p = result;
result[0] = '\0';
if(mode == 0) {
if(compact) *p++ = '-';
else if(!occoncat(result,sizeof(result),1,"NONE"))
return NULL;
} else for(i=0;;i++) {
char* ms = modestrings[i];
const char* ms = modestrings[i];
if(ms == NULL) break;
if(!compact && i > 0)
if(!occoncat(result,sizeof(result),1,","))

View File

@ -27,7 +27,7 @@ extern int oc_ispacked(OCnode* node);
extern size_t octotaldimsize(size_t,size_t*);
extern size_t ocarrayoffset(size_t rank, size_t*, size_t*);
extern size_t ocarrayoffset(size_t rank, size_t*, const size_t*);
extern void ocarrayindices(size_t index, size_t rank, size_t*, size_t*);
extern size_t ocedgeoffset(size_t rank, size_t*, size_t*);
@ -49,7 +49,7 @@ extern int ocmktmp(const char* base, char** tmpnamep);
extern void ocdataddsmsg(struct OCstate*, struct OCtree*);
extern const char* ocdtmodestring(OCDT mode,int compact);
extern char* ocdtmodestring(OCDT mode,int compact);
/* Define some classifiers */
#define ociscontainer(t) ((t) == OC_Dataset || (t) == OC_Structure || (t) == OC_Sequence || (t) == OC_Grid || (t) == OC_Attributeset)