Skip to content

Commit

Permalink
Merge branch 'master' into vars.dmh
Browse files Browse the repository at this point in the history
  • Loading branch information
WardF committed Jun 8, 2018
2 parents 2f1daaa + 601c65e commit 29d5eee
Show file tree
Hide file tree
Showing 39 changed files with 1,135 additions and 771 deletions.
6 changes: 3 additions & 3 deletions cf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#NB=1
DB=1
#DB=1
#X=-x

#FAST=1
Expand Down Expand Up @@ -124,8 +124,8 @@ FLAGS="$FLAGS --disable-parallel4"
fi

if test "x${DB}" = x1 ; then
#FLAGS="$FLAGS --disable-shared --enable-static"
FLAGS="$FLAGS --enable-static"
FLAGS="$FLAGS --disable-shared --enable-static"
#FLAGS="$FLAGS --enable-static"
else
FLAGS="$FLAGS --enable-shared"
fi
Expand Down
7 changes: 3 additions & 4 deletions include/nc4internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ typedef enum {NCNAT, NCVAR, NCDIM, NCATT, NCTYP, NCFLD, NCGRP} NC_SORT;
#define HDF5_DIMSCALE_NAME_ATT_NAME "NAME"

/** This is the number of netCDF atomic types. */
#define NUM_ATOMIC_TYPES (NC_MAX_ATOMIC_TYPE + 1)
#define NUM_ATOMIC_TYPES (NC_MAX_ATOMIC_TYPE + 1)

/* Boolean type, to make the code easier to read */
typedef enum {NC_FALSE = 0, NC_TRUE = 1} nc_bool_t;
Expand Down Expand Up @@ -351,16 +351,15 @@ int nc4_get_typelen_mem(NC_HDF5_FILE_INFO_T *h5, nc_type xtype, size_t *len);
int nc4_convert_type(const void *src, void *dest,
const nc_type src_type, const nc_type dest_type,
const size_t len, int *range_error,
const void *fill_value, int strict_nc3, int src_long,
int dest_long);
const void *fill_value, int strict_nc3);

/* These functions do HDF5 things. */
int rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
int rec_reattach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
int delete_existing_dimscale_dataset(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T *dim);
int nc4_open_var_grp2(NC_GRP_INFO_T *grp, int varid, hid_t *dataset);
int nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
const size_t *countp, nc_type xtype, int is_long, void *op);
const size_t *countp, nc_type xtype, void *op);
int nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
const size_t *countp, nc_type xtype, int is_long, void *op);
int nc4_put_vars(NC *nc, int ncid, int varid, const size_t *startp,
Expand Down
70 changes: 37 additions & 33 deletions libdispatch/dauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ NC_authsetup(NCauth* auth, NCURI* uri)
char* uri_hostport = NULL;

if(uri != NULL)
uri_hostport = NC_combinehostport(uri);

uri_hostport = NC_combinehostport(uri);
else
return NC_EDAP; /* Generic EDAP error. */
setdefaults(auth);

/* Note, we still must do this function even if
Expand Down Expand Up @@ -136,32 +137,34 @@ NC_authsetup(NCauth* auth, NCURI* uri)
NC_rclookup("HTTP.SSL.VERIFYPEER",uri_hostport));
setauthfield(auth,"HTTP.NETRC",
NC_rclookup("HTTP.NETRC",uri_hostport));

{ /* Handle various cases for user + password */
/* First, see if the user+pwd was in the original url */
char* user = NULL;
char* pwd = NULL;
if(uri->user != NULL && uri->password != NULL) {
/* First, see if the user+pwd was in the original url */
char* user = NULL;
char* pwd = NULL;
if(uri->user != NULL && uri->password != NULL) {
user = uri->user;
pwd = uri->password;
} else {
} else {
user = NC_rclookup("HTTP.CREDENTIALS.USER",uri_hostport);
pwd = NC_rclookup("HTTP.CREDENTIALS.PASSWORD",uri_hostport);
}
if(user != NULL && pwd != NULL) {
user = strdup(user); /* so we can consistently reclaim */
pwd = strdup(pwd);
} else {
}
if(user != NULL && pwd != NULL) {
user = strdup(user); /* so we can consistently reclaim */
pwd = strdup(pwd);
} else {
/* Could not get user and pwd, so try USERPASSWORD */
const char* userpwd = NC_rclookup("HTTP.CREDENTIALS.USERPASSWORD",uri_hostport);
if(userpwd != NULL) {
ret = NC_parsecredentials(userpwd,&user,&pwd);
if(ret) return ret;
ret = NC_parsecredentials(userpwd,&user,&pwd);
if(ret) {nullfree(uri_hostport); return ret;}
}
}
setauthfield(auth,"HTTP.USERNAME",user);
setauthfield(auth,"HTTP.PASSWORD",pwd);
nullfree(user);
nullfree(pwd);
}
setauthfield(auth,"HTTP.USERNAME",user);
setauthfield(auth,"HTTP.PASSWORD",pwd);
nullfree(user);
nullfree(pwd);
nullfree(uri_hostport);
}
return (ret);
}
Expand Down Expand Up @@ -347,25 +350,27 @@ and do %xx unescaping
int
NC_parsecredentials(const char* userpwd, char** userp, char** pwdp)
{
char* user = NULL;
char* pwd = NULL;
char* user = NULL;
char* pwd = NULL;

if(userpwd == NULL)
if(userpwd == NULL)
return NC_EINVAL;
user = strdup(userpwd);
if(user == NULL)
user = strdup(userpwd);
if(user == NULL)
return NC_ENOMEM;
pwd = strchr(user,':');
if(pwd == NULL)
pwd = strchr(user,':');
if(pwd == NULL) {
free(user);
return NC_EINVAL;
*pwd = '\0';
pwd++;
if(userp)
}
*pwd = '\0';
pwd++;
if(userp)
*userp = ncuridecode(user);
if(pwdp)
if(pwdp)
*pwdp = ncuridecode(pwd);
free(user);
return NC_NOERR;
free(user);
return NC_NOERR;
}

static void
Expand All @@ -380,4 +385,3 @@ setdefaults(NCauth* auth)
}
}
}

20 changes: 13 additions & 7 deletions libdispatch/dfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2192,13 +2192,19 @@ NC_open(const char *path0, int cmode, int basepe, size_t *chunksizehintp,
#ifdef USE_CDF5
cdf5built = 1;
#endif
if(!hdf5built && model == NC_FORMATX_NC4)
return NC_ENOTBUILT;
if(!hdf4built && model == NC_FORMATX_NC4 && version == 4)
return NC_ENOTBUILT;
if(!cdf5built && model == NC_FORMATX_NC3 && version == 5)
return NC_ENOTBUILT;
}
if(!hdf5built && model == NC_FORMATX_NC4) {
free(path);
return NC_ENOTBUILT;
}
if(!hdf4built && model == NC_FORMATX_NC4 && version == 4) {
free(path);
return NC_ENOTBUILT;
}
if(!cdf5built && model == NC_FORMATX_NC3 && version == 5) {
free(path);
return NC_ENOTBUILT;
}
}

/* Force flag consistentcy */
if(model == NC_FORMATX_NC4 || model == NC_FORMATX_NC_HDF4 || model == NC_FORMATX_DAP4)
Expand Down
50 changes: 25 additions & 25 deletions libdispatch/drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ NC_set_rcfile(const char* rcfile)
nullfree(ncrc_globalstate.rcinfo.rcfile);
ncrc_globalstate.rcinfo.rcfile = strdup(rcfile);
/* Clear ncrc_globalstate.rcinfo */
NC_rcclear(&ncrc_globalstate.rcinfo);
NC_rcclear(&ncrc_globalstate.rcinfo);
/* (re) load the rcfile and esp the triplestore*/
stat = NC_rcload();
done:
Expand Down Expand Up @@ -196,10 +196,9 @@ static void
rctrim(char* text)
{
char* p = text;
size_t len;
size_t len = 0;
int i;

len = strlen(text);
/* locate first non-trimchar */
for(;*p;p++) {
if(strchr(TRIMCHARS,*p) == NULL) break; /* hit non-trim char */
Expand Down Expand Up @@ -264,8 +263,8 @@ rccompile(const char* path)
char* nextline = NULL;

if((ret=NC_readfile(path,tmp))) {
nclog(NCLOGERR, "Could not open configuration file: %s",path);
goto done;
nclog(NCLOGERR, "Could not open configuration file: %s",path);
goto done;
}
contents = ncbytesextract(tmp);
if(contents == NULL) contents = strdup("");
Expand All @@ -292,27 +291,29 @@ rccompile(const char* path)
if((llen=strlen(line)) == 0) continue; /* empty line */
triple = (NCTriple*)calloc(1,sizeof(NCTriple));
if(triple == NULL) {ret = NC_ENOMEM; goto done;}
if(line[0] == LTAG) {
char* url = ++line;
char* rtag = strchr(line,RTAG);
if(rtag == NULL) {
nclog(NCLOGERR, "Malformed [url] in %s entry: %s",path,line);
continue;
}
line = rtag + 1;
*rtag = '\0';
/* compile the url and pull out the host */
if(uri) ncurifree(uri);
if(ncuriparse(url,&uri) != NCU_OK) {
nclog(NCLOGERR, "Malformed [url] in %s entry: %s",path,line);
if(line[0] == LTAG) {
char* url = ++line;
char* rtag = strchr(line,RTAG);
if(rtag == NULL) {
nclog(NCLOGERR, "Malformed [url] in %s entry: %s",path,line);
free(triple);
continue;
}
line = rtag + 1;
*rtag = '\0';
/* compile the url and pull out the host */
if(uri) ncurifree(uri);
if(ncuriparse(url,&uri) != NCU_OK) {
nclog(NCLOGERR, "Malformed [url] in %s entry: %s",path,line);
free(triple);
continue;
}
ncbytesclear(tmp);
ncbytescat(tmp,uri->host);
if(uri->port != NULL) {
}
ncbytesclear(tmp);
ncbytescat(tmp,uri->host);
if(uri->port != NULL) {
ncbytesappend(tmp,':');
ncbytescat(tmp,uri->port);
}
ncbytescat(tmp,uri->port);
}
ncbytesnull(tmp);
triple->host = ncbytesextract(tmp);
if(strlen(triple->host)==0)
Expand Down Expand Up @@ -441,4 +442,3 @@ storedump(char* msg, NClist* triples)
fflush(stderr);
}
#endif

36 changes: 20 additions & 16 deletions libdispatch/dutf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,47 +126,51 @@ int nc_utf8_to_utf16(const unsigned char* s8, unsigned short** utf16p, size_t* l
len8 = strlen((char*)s8);
utf16 = (unsigned short*)malloc(sizeof(unsigned short)*(len8+1));
if(utf16 == NULL) {
ncstat = NC_ENOMEM;
goto done;
ncstat = NC_ENOMEM;
goto done;
}
str = (const nc_utf8proc_uint8_t*)s8;
/* Walk the string and convert each codepoint */
p16 = utf16;
len16 = 0;
while(*str) {
count = nc_utf8proc_iterate(str,nchars,&codepoint);
if(count < 0) {
count = nc_utf8proc_iterate(str,nchars,&codepoint);
if(count < 0) {
switch (count) {
case UTF8PROC_ERROR_NOMEM:
case UTF8PROC_ERROR_OVERFLOW:
ncstat = NC_ENOMEM;
break;
ncstat = NC_ENOMEM;
break;
case UTF8PROC_ERROR_INVALIDOPTS:
ncstat = NC_EINVAL;
break;
ncstat = NC_EINVAL;
break;
case UTF8PROC_ERROR_INVALIDUTF8:
case UTF8PROC_ERROR_NOTASSIGNED:
default:
ncstat = NC_EBADNAME;
break;
ncstat = NC_EBADNAME;
break;
}
goto done;
} else { /* move to next char */
} else { /* move to next char */
/* Complain if top 16 bits not zero */
if((codepoint & 0x0000FFFF) != 0) {
ncstat = NC_EBADNAME;
goto done;
ncstat = NC_EBADNAME;
goto done;
}
/* Truncate codepoint to 16 bits and store */
*p16++ = (unsigned short)(codepoint & 0x0000FFFF);
str += count;
len16++;
}
}
}
*p16++ = (unsigned short)0;
if(utf16p) *utf16p = utf16;
if(utf16p)
*utf16p = utf16;
else
free(utf16);

if(len16p) *len16p = len16;
done:
done:
if(ncstat) free(utf16);
return ncstat;
}
11 changes: 6 additions & 5 deletions libdispatch/dvarinq.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! \file
Functions for inquiring about variables.
Copyright 2010 University Corporation for Atmospheric
Copyright 2018 University Corporation for Atmospheric
Research/Unidata. See COPYRIGHT file for more info.
*/

Expand Down Expand Up @@ -38,6 +38,7 @@ ignored_if_null.
\returns ::NC_NOERR No error.
\returns ::NC_EBADID Bad ncid.
\returns ::NC_ENOTVAR Invalid variable ID.
\section nc_inq_varid_example4 Example
Expand Down Expand Up @@ -181,7 +182,7 @@ nc_inq_vartype(int ncid, int varid, nc_type *typep)
NULL, NULL);
}

/**
/**
Learn how many dimensions are associated with a variable.
\ingroup variables
Expand All @@ -204,7 +205,7 @@ nc_inq_varndims(int ncid, int varid, int *ndimsp)
return nc_inq_var(ncid, varid, NULL, NULL, ndimsp, NULL, NULL);
}

/**
/**
Learn the dimension IDs associated with a variable.
\ingroup variables
Expand All @@ -228,7 +229,7 @@ nc_inq_vardimid(int ncid, int varid, int *dimidsp)
dimidsp, NULL);
}

/**
/**
Learn how many attributes are associated with a variable.
\ingroup variables
Expand Down Expand Up @@ -605,7 +606,7 @@ nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
#endif
}

/**
/**
Find the filter (if any) associated with a variable.
This is a wrapper for nc_inq_var_all().
Expand Down
Loading

0 comments on commit 29d5eee

Please sign in to comment.