mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-04-06 18:00:24 +08:00
Merge branch 'issue435.dmh' into multi-pull
This commit is contained in:
commit
9e7a902dcf
@ -1233,6 +1233,7 @@ CHECK_INCLUDE_FILE("stddef.h" HAVE_STDDEF_H)
|
||||
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
|
||||
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
|
||||
CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H)
|
||||
CHECK_INCLUDE_FILE("ftw.h" HAVE_FTW_H)
|
||||
|
||||
CHECK_INCLUDE_FILES("time.h;sys/time.h" TIME_WITH_SYS_TIME)
|
||||
|
||||
|
1
cf
1
cf
@ -111,7 +111,6 @@ FLAGS="$FLAGS --enable-logging"
|
||||
#FLAGS="$FLAGS --enable-jna"
|
||||
#FLAGS="$FLAGS --disable-properties-attribute"
|
||||
#FLAGS="$FLAGS --disable-silent-rules"
|
||||
#FLAGS="$FLAGS --enable-dap4"
|
||||
#FLAGS="$FLAGS --with-testservers=remotestserver.localhost:8083"
|
||||
|
||||
if test "x$PAR4" != x1 ; then
|
||||
|
@ -363,6 +363,9 @@ are set when opening a binary file on Windows. */
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#cmakedefine HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <ftw.h> header file. */
|
||||
#cmakedefine HAVE_FTW_H 1
|
||||
|
||||
/* Define to 1 if you have the `strlcat' function. */
|
||||
#cmakedefine HAVE_STRLCAT 1
|
||||
|
||||
|
@ -790,6 +790,9 @@ AC_CHECK_HEADERS([sys/resource.h])
|
||||
# Check for <stdbool.h> that conforms to C99 requirements
|
||||
AC_HEADER_STDBOOL
|
||||
|
||||
# See if we have ftw.h to walk directory trees
|
||||
AC_CHECK_HEADERS([ftw.h])
|
||||
|
||||
# Check for these functions...
|
||||
AC_CHECK_FUNCS([strlcat strerror snprintf strchr strrchr strcat strcpy \
|
||||
strdup strcasecmp strtod strtoll strtoull strstr \
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "d4read.h"
|
||||
#include "d4curlfunctions.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#ifdef _MSC_VER
|
||||
#include <process.h>
|
||||
#include <direct.h>
|
||||
#endif
|
||||
@ -29,6 +29,7 @@ static void freeInfo(NCD4INFO*);
|
||||
static int paramcheck(NCD4INFO*, const char* key, const char* subkey);
|
||||
static const char* getparam(NCD4INFO* info, const char* key);
|
||||
static int set_curl_properties(NCD4INFO*);
|
||||
static void d4removecookies(const char* path);
|
||||
|
||||
/**************************************************/
|
||||
/* Constants */
|
||||
@ -294,7 +295,6 @@ freeCurl(NCD4curl* curl)
|
||||
nullfree(curl->errdata.code);
|
||||
nullfree(curl->errdata.message);
|
||||
nullfree(curl->curlflags.useragent);
|
||||
nullfree(curl->curlflags.cookiejar);
|
||||
nullfree(curl->curlflags.netrc);
|
||||
nullfree(curl->ssl.certificate);
|
||||
nullfree(curl->ssl.key);
|
||||
@ -304,6 +304,9 @@ freeCurl(NCD4curl* curl)
|
||||
nullfree(curl->proxy.host);
|
||||
nullfree(curl->proxy.userpwd);
|
||||
nullfree(curl->creds.userpwd);
|
||||
if(curl->curlflags.createdflags & COOKIECREATED)
|
||||
d4removecookies(curl->curlflags.cookiejar);
|
||||
nullfree(curl->curlflags.cookiejar);
|
||||
}
|
||||
|
||||
/* Define the set of protocols known to be constrainable */
|
||||
@ -353,32 +356,28 @@ set_curl_properties(NCD4INFO* d4info)
|
||||
|
||||
if(d4info->curl->curlflags.cookiejar == NULL) {
|
||||
/* If no cookie file was defined, define a default */
|
||||
char tmp[4096+1];
|
||||
int ok;
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
int pid = _getpid();
|
||||
#else
|
||||
pid_t pid = getpid();
|
||||
#endif
|
||||
snprintf(tmp,sizeof(tmp)-1,"%s/%s.%ld/",NCD4_globalstate->tempdir,"netcdf",(long)pid);
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
ok = _mkdir(tmp);
|
||||
#else
|
||||
ok = mkdir(tmp,S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
#endif
|
||||
if(ok != 0 && errno != EEXIST) {
|
||||
fprintf(stderr,"Cannot create cookie directory\n");
|
||||
goto fail;
|
||||
}
|
||||
char* path = NULL;
|
||||
char* name = NULL;
|
||||
int len;
|
||||
errno = 0;
|
||||
/* Create the unique cookie file name */
|
||||
ok = NCD4_mktmp(tmp,&d4info->curl->curlflags.cookiejar);
|
||||
d4info->curl->curlflags.createdflags |= COOKIECREATED;
|
||||
len =
|
||||
strlen(NCD4_globalstate->tempdir)
|
||||
+ 1 /* '/' */
|
||||
+ strlen("ncd4cookies");
|
||||
path = (char*)malloc(len+1);
|
||||
if(path == NULL) return NC_ENOMEM;
|
||||
snprintf(path,len,"%s/nc4cookies",NCD4_globalstate->tempdir);
|
||||
/* Create the unique cookie file name */
|
||||
ok = NCD4_mktmp(path,&name);
|
||||
free(path);
|
||||
if(ok != NC_NOERR && errno != EEXIST) {
|
||||
fprintf(stderr,"Cannot create cookie file\n");
|
||||
goto fail;
|
||||
}
|
||||
d4info->curl->curlflags.cookiejar = name;
|
||||
d4info->curl->curlflags.createdflags |= COOKIECREATED;
|
||||
errno = 0;
|
||||
}
|
||||
assert(d4info->curl->curlflags.cookiejar != NULL);
|
||||
@ -489,3 +488,13 @@ getparam(NCD4INFO* info, const char* key)
|
||||
return NULL;
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
d4removecookies(const char* path)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
DeleteFile(path);
|
||||
#else
|
||||
remove(path);
|
||||
#endif
|
||||
}
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
#define NCURIDEBUG
|
||||
|
||||
/* Extra debug info */
|
||||
#undef NCXDEBUG
|
||||
|
||||
#ifdef NCURIDEBUG
|
||||
#define THROW(n) {ret=(n); goto done;}
|
||||
#else
|
||||
@ -314,10 +317,7 @@ ncuriparse(const char* uri0, NCURI** durip)
|
||||
if(strlen(pp)==0)
|
||||
{THROW(NCU_EUSRPWD);} /* we have empty password */
|
||||
tmp.password = pp;
|
||||
/* compress usr+pwd out of tmp.host */
|
||||
rem = strlen(newhost);
|
||||
memmove(tmp.host,newhost,rem);
|
||||
tmp.host[rem] = EOFCHAR;
|
||||
tmp.host = newhost;
|
||||
}
|
||||
/* Breakup host into host + port */
|
||||
pp = tmp.host;
|
||||
|
@ -35,11 +35,13 @@ static Test TESTS[] = {
|
||||
{"[dap4]http://localhost:8081/x#show=fetch&log","http://localhost:8081/x#dap4&show=fetch&log"},
|
||||
/* suffix param tests with constraint*/
|
||||
{"http://localhost:8081/x?dap4.ce=x#dap4&show=fetch&log","http://localhost:8081/x?dap4.ce=x#dap4&show=fetch&log"},
|
||||
/* Test embedded user+pwd */
|
||||
{"http://tiggeUser:tigge@localhost:8081/thredds/dodsC/restrict/testData.nc",
|
||||
"http://tiggeUser:tigge@localhost:8081/thredds/dodsC/restrict/testData.nc"},
|
||||
/* Misc. */
|
||||
{"http://localhost","http://localhost/"},
|
||||
{"http:///x","http:///x"},
|
||||
{"file:///home/osboxes/git/dap4/dap4_test/daptestfiles/test_anon_dim.2.syn#dap4&debug=copy&substratename=./results/test_anon_dim.2.syn.nc","file:///home/osboxes/git/dap4/dap4_test/daptestfiles/test_anon_dim.2.syn#dap4&debug=copy&substratename=./results/test_anon_dim.2.syn.nc"},
|
||||
|
||||
{NULL,NULL}
|
||||
};
|
||||
|
||||
|
@ -92,9 +92,6 @@ t_dap3a.c: t_dap.c
|
||||
echo "#define NETCDF3ONLY" > ./t_dap3a.c
|
||||
cat t_dap.c >> t_dap3a.c
|
||||
|
||||
t_dap4a.c: t_dap.c
|
||||
cat t_dap.c >> ./t_dap4a.c
|
||||
|
||||
# One last thing
|
||||
BUILT_SOURCES = .dodsrc
|
||||
|
||||
|
@ -307,6 +307,7 @@ int main()
|
||||
printf("ncstat=%d %s",ncstat,nc_strerror(ncstat));
|
||||
exit(1);
|
||||
}
|
||||
nc_close(ncid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -308,6 +308,7 @@ int main()
|
||||
printf("ncstat=%d %s",ncstat,nc_strerror(ncstat));
|
||||
exit(1);
|
||||
}
|
||||
nc_close(ncid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -307,6 +307,7 @@ int main()
|
||||
printf("ncstat=%d %s",ncstat,nc_strerror(ncstat));
|
||||
exit(1);
|
||||
}
|
||||
nc_close(ncid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -251,6 +251,7 @@ main()
|
||||
}
|
||||
printf("*** %s: stride case 3\n",(fail?"Fail":"Pass"));
|
||||
|
||||
nc_close(ncid);
|
||||
return fail;
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,9 @@
|
||||
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
||||
. ../test_common.sh
|
||||
|
||||
# Enable if using localhost
|
||||
LOCAL=1
|
||||
|
||||
RCEMBED=1
|
||||
RCLOCAL=1
|
||||
RCHOME=1
|
||||
@ -40,10 +43,13 @@ fi
|
||||
|
||||
BASICCOMBO="tiggeUser:tigge"
|
||||
BADCOMBO="tiggeUser:xxxxx"
|
||||
URLSERVER="remotetest.unidata.ucar.edu"
|
||||
#http://remotetest.unidata.ucar.edu/thredds/dodsC/restrict/testData.nc.html
|
||||
URLPATH="thredds/dodsC/restrict/testData.nc"
|
||||
URLPATH="thredds/dodsC/testRestrictedDataset/testData2.nc"
|
||||
PROTO=http
|
||||
if test "x$LOCAL" = x ; then
|
||||
URLSERVER="remotetest.unidata.ucar.edu"
|
||||
else
|
||||
URLSERVER="localhost:8081"
|
||||
fi
|
||||
|
||||
# See if we need to override
|
||||
if test "x$URS" != "x" ; then
|
||||
|
@ -10,12 +10,16 @@
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#if _MSC_VER
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FTW_H
|
||||
#include <ftw.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "ocinternal.h"
|
||||
@ -29,28 +33,16 @@
|
||||
|
||||
#define DATADDSFILE "datadds"
|
||||
|
||||
#if 0
|
||||
/* Note: TMPPATH must end in '/' */
|
||||
#ifdef __CYGWIN__
|
||||
#define TMPPATH1 "/cygdrive/c/temp/datadds"
|
||||
#define TMPPATH2 "./datadds"
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
#define TMPPATH1 "c:\\temp\\datadds"
|
||||
#define TMPPATH2 ".\\datadds"
|
||||
#else
|
||||
#define TMPPATH1 "/tmp/datadds"
|
||||
#define TMPPATH2 "./datadds"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CLBRACE '{'
|
||||
#define CRBRACE '}'
|
||||
|
||||
/*Forward*/
|
||||
static OCerror ocextractddsinmemory(OCstate*,OCtree*,int);
|
||||
static OCerror ocextractddsinfile(OCstate*,OCtree*,int);
|
||||
static char* constraintescape(const char* url);
|
||||
static OCerror createtempfile(OCstate*,OCtree*);
|
||||
static int dataError(XXDR* xdrs, OCstate*);
|
||||
static void ocremovefile(const char* path);
|
||||
|
||||
static OCerror ocset_curlproperties(OCstate*);
|
||||
|
||||
@ -89,7 +81,7 @@ ocinternalinitialize(void)
|
||||
char* p;
|
||||
char* q;
|
||||
char cwd[4096];
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#ifdef _MSC_VER
|
||||
tempdir = getenv("TEMP");
|
||||
#else
|
||||
tempdir = "/tmp";
|
||||
@ -106,7 +98,7 @@ ocinternalinitialize(void)
|
||||
*q = *p;
|
||||
}
|
||||
*q = '\0';
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#ifdef _MSC_VER
|
||||
#else
|
||||
/* Canonicalize */
|
||||
for(p=ocglobalstate.tempdir;*p;p++) {
|
||||
@ -133,7 +125,7 @@ ocinternalinitialize(void)
|
||||
*q = *p;
|
||||
}
|
||||
*q = '\0';
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#ifdef _MSC_VER
|
||||
#else
|
||||
/* Canonicalize */
|
||||
for(p=home;*p;p++) {
|
||||
@ -390,8 +382,9 @@ createtempfile(OCstate* state, OCtree* tree)
|
||||
name = NULL;
|
||||
tree->data.file = NCfopen(tree->data.filename,"w+");
|
||||
if(tree->data.file == NULL) return OC_EOPEN;
|
||||
/* unlink the temp file so it will automatically be reclaimed */
|
||||
if(ocdebug == 0) unlink(tree->data.filename);
|
||||
/* make the temp file so it will automatically be reclaimed on close */
|
||||
if(ocdebug == 0)
|
||||
ocremovefile(tree->data.filename);
|
||||
return stat;
|
||||
|
||||
fail:
|
||||
@ -423,19 +416,11 @@ occlose(OCstate* state)
|
||||
ocfree(state->error.message);
|
||||
ocfree(state->curlflags.useragent);
|
||||
if(state->curlflags.cookiejar) {
|
||||
#if 0
|
||||
if(state->curlflags.createdflags & COOKIECREATED)
|
||||
unlink(state->curlflags.cookiejar);
|
||||
#endif
|
||||
ocremovefile(state->curlflags.cookiejar);
|
||||
ocfree(state->curlflags.cookiejar);
|
||||
}
|
||||
if(state->curlflags.netrc != NULL) {
|
||||
#if 0
|
||||
if(state->curlflags.createdflags & NETRCCREATED)
|
||||
unlink(state->curlflags.netrc);
|
||||
#endif
|
||||
ocfree(state->curlflags.netrc);
|
||||
}
|
||||
ocfree(state->curlflags.netrc);
|
||||
ocfree(state->ssl.certificate);
|
||||
ocfree(state->ssl.key);
|
||||
ocfree(state->ssl.keypasswd);
|
||||
@ -607,26 +592,23 @@ ocset_curlproperties(OCstate* state)
|
||||
|
||||
if(state->curlflags.cookiejar == NULL) {
|
||||
/* If no cookie file was defined, define a default */
|
||||
char tmp[OCPATHMAX+1];
|
||||
int stat;
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
int pid = _getpid();
|
||||
#else
|
||||
pid_t pid = getpid();
|
||||
#endif
|
||||
snprintf(tmp,sizeof(tmp)-1,"%s/%s.%ld/",ocglobalstate.tempdir,OCDIR,(long)pid);
|
||||
#ifdef _WIN32
|
||||
stat = mkdir(tmp);
|
||||
#else
|
||||
stat = mkdir(tmp,S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
#endif
|
||||
if(stat != 0 && errno != EEXIST) {
|
||||
fprintf(stderr,"Cannot create cookie directory\n");
|
||||
goto fail;
|
||||
}
|
||||
char* path = NULL;
|
||||
char* name = NULL;
|
||||
int len;
|
||||
errno = 0;
|
||||
/* Create the unique cookie file name */
|
||||
stat = ocmktmp(tmp,&state->curlflags.cookiejar);
|
||||
len =
|
||||
strlen(ocglobalstate.tempdir)
|
||||
+ 1 /* '/' */
|
||||
+ strlen("occookies");
|
||||
path = (char*)malloc(len+1);
|
||||
if(path == NULL) return OC_ENOMEM;
|
||||
occopycat(path,len,3,ocglobalstate.tempdir,"/","occookies");
|
||||
stat = ocmktmp(path,&name);
|
||||
fprintf(stderr,"%s => %s\n",state->uri->uri,name); fflush(stderr);
|
||||
free(path);
|
||||
state->curlflags.cookiejar = name;
|
||||
state->curlflags.createdflags |= COOKIECREATED;
|
||||
if(stat != OC_NOERR && errno != EEXIST) {
|
||||
fprintf(stderr,"Cannot create cookie file\n");
|
||||
@ -757,3 +739,13 @@ ocset_netrc(OCstate* state, const char* path)
|
||||
stat = ocset_curlflag(state,CURLOPT_NETRC);
|
||||
return stat;
|
||||
}
|
||||
|
||||
static void
|
||||
ocremovefile(const char* path)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
DeleteFile(path);
|
||||
#else
|
||||
remove(path);
|
||||
#endif
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ typedef struct OCheader {
|
||||
#define nullstring(s) (s==NULL?"(null)":s)
|
||||
#define PATHSEPARATOR "."
|
||||
|
||||
#define OCDIR "oc"
|
||||
#define OCCOOKIEDIR "occookies"
|
||||
|
||||
/* Define infinity for memory size */
|
||||
#if SIZEOF_SIZE_T == 4
|
||||
@ -199,7 +199,6 @@ struct OCstate {
|
||||
char* useragent; /*CURLOPT_USERAGENT*/
|
||||
/* track which of these are created by oc */
|
||||
#define COOKIECREATED 1
|
||||
#define NETRCCREATED 2
|
||||
int createdflags;
|
||||
char* cookiejar; /*CURLOPT_COOKIEJAR,CURLOPT_COOKIEFILE*/
|
||||
char* netrc; /*CURLOPT_NETRC,CURLOPT_NETRC_FILE*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user