From 3a559d3f1d6aaee3a365778278f75be7813cfe0d Mon Sep 17 00:00:00 2001 From: dmh Date: Sun, 28 Dec 2014 15:54:02 -0700 Subject: [PATCH] Fix occurlflags bug --- ncgen/CMakeLists.txt | 6 +++++- ncgen/Makefile.am | 2 +- oc2/occurlflags.c | 24 ++++++++++++------------ oc2/ocinternal.c | 15 +++++++++++++-- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ncgen/CMakeLists.txt b/ncgen/CMakeLists.txt index 369344d51..71af0eed3 100644 --- a/ncgen/CMakeLists.txt +++ b/ncgen/CMakeLists.txt @@ -31,6 +31,11 @@ ENDIF() SET(CLEANFILES c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}") +# These rules are used if someone wants to rebuild ncgenyy.c or ncgentab.c +# Otherwise never invoked, but records how to do it. +# BTW: note that renaming is essential because otherwise +# autoconf will forcibly delete files of the name *.tab.* + ADD_CUSTOM_COMMAND( OUTPUT ncgentab.h COMMAND flex -Pncg -B ncgen.l @@ -45,7 +50,6 @@ ADD_CUSTOM_COMMAND( COMMAND mv ncgenyy.c ${CMAKE_CURRENT_SOURCE_DIR} ) - ADD_CUSTOM_TARGET(makeparser DEPENDS ncgentab.h) ## Specify files to be distributed by 'make dist' diff --git a/ncgen/Makefile.am b/ncgen/Makefile.am index 636e364c7..e88dc0556 100644 --- a/ncgen/Makefile.am +++ b/ncgen/Makefile.am @@ -36,7 +36,7 @@ endif # USE_NETCDF4 CLEANFILES = c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c \ ncf199.nc -# These rule are used if someone wants to rebuild ncgenyy.c or ncgentab.c +# These rules are used if someone wants to rebuild ncgenyy.c or ncgentab.c # Otherwise never invoked, but records how to do it. # BTW: note that renaming is essential because otherwise # autoconf will forcibly delete files of the name *.tab.* diff --git a/oc2/occurlflags.c b/oc2/occurlflags.c index 7197e038e..429a1c2bc 100644 --- a/oc2/occurlflags.c +++ b/oc2/occurlflags.c @@ -43,6 +43,7 @@ static struct OCCURLFLAG oc_curlflags[] = { {NULL,0} }; +#if 0 static struct OCCURLFLAG oc_allcurlflags[] = { {"CURLOPT_ADDRESS_SCOPE",CURLOPT_ADDRESS_SCOPE,171,CF_UNKNOWN}, {"CURLOPT_APPEND",CURLOPT_APPEND,50,CF_UNKNOWN}, @@ -51,9 +52,7 @@ static struct OCCURLFLAG oc_allcurlflags[] = { {"CURLOPT_CAINFO",CURLOPT_CAINFO,10065,CF_UNKNOWN}, {"CURLOPT_CAPATH",CURLOPT_CAPATH,10097,CF_UNKNOWN}, {"CURLOPT_CERTINFO",CURLOPT_CERTINFO,172,CF_UNKNOWN}, -#ifdef HAVE_CURLOPT_CHUNK_BGN_FUNCTION {"CURLOPT_CHUNK_BGN_FUNCTION",CURLOPT_CHUNK_BGN_FUNCTION,20198,CF_UNKNOWN}, -#endif {"CURLOPT_CHUNK_DATA",CURLOPT_CHUNK_DATA,10201,CF_UNKNOWN}, {"CURLOPT_CHUNK_END_FUNCTION",CURLOPT_CHUNK_END_FUNCTION,20199,CF_UNKNOWN}, {"CURLOPT_CLOSEPOLICY",CURLOPT_CLOSEPOLICY,72,CF_UNKNOWN}, @@ -234,6 +233,15 @@ static struct OCCURLFLAG oc_allcurlflags[] = { {NULL,0} }; +struct OCCURLFLAG* +occurlflagsall(void) +{ + if(nflags == 0) initialize(); + return oc_allcurlflags; +} + +#endif + static int touppercase(int c) { if(c >= 'a' && c <= 'z') @@ -270,14 +278,6 @@ occurlflags(void) return oc_curlflags; } -struct OCCURLFLAG* -occurlflagsall(void) -{ - if(nflags == 0) initialize(); - return oc_allcurlflags; -} - - struct OCCURLFLAG* occurlflagbyname(const char* name) { @@ -287,7 +287,7 @@ occurlflagbyname(const char* name) const char* p; char* q; - if(nflags == 0) initialize(); + if(nflags == 0) initialize(); /* Force upper case */ for(p=name,q=flagname;*p;p++) { int cc = touppercase(*p); @@ -309,7 +309,7 @@ occurlflagbyname(const char* name) struct OCCURLFLAG* occurlflagbyflag(int flag) { - if(nflags == 0) initialize(); + if(nflags == 0) initialize(); if(flag >= 0 || flag <= maxflag) return flagindices[flag]; return NULL; diff --git a/oc2/ocinternal.c b/oc2/ocinternal.c index 5f053c47b..519c8bb33 100644 --- a/oc2/ocinternal.c +++ b/oc2/ocinternal.c @@ -594,6 +594,12 @@ ocset_curlproperties(OCstate* state) /* Some servers (e.g. thredds and columbia) appear to require a place to put cookies in order for some security functions to work */ + if(state->curlflags.cookiejar != NULL + && strlen(state->curlflags.cookiejar) == 0) { + free(state->curlflags.cookiejar); + state->curlflags.cookiejar = NULL; + } + if(state->curlflags.cookiejar == NULL) { /* If no cookie file was defined, define a default */ char tmp[OCPATHMAX+1]; @@ -607,9 +613,14 @@ ocset_curlproperties(OCstate* state) errno = 0; /* Create the unique cookie file name */ stat = ocmktmp(tmp,&state->curlflags.cookiejar); - state->curlflags.createdflags |= COOKIECREATED; + state->curlflags.createdflags |= COOKIECREATED; + if(stat != OC_NOERR && errno != EEXIST) { + fprintf(stderr,"Cannot create cookie file\n"); + goto fail; + } + errno = 0; } - OCASSERT(state->curlflags.cookiejar != NULL && *state->curlflags.cookiejar != '\0'); + OCASSERT(state->curlflags.cookiejar != NULL); /* Make sure the cookie jar exists and can be read and written */ {