Skip to content

Commit

Permalink
Merge pull request #2408 from DennisHeimbigner/rcapi.dmh
Browse files Browse the repository at this point in the history
Make public a limited API for programmatic access to internal .rc tables
  • Loading branch information
WardF authored Jun 21, 2022
2 parents 7375f4b + abba5c3 commit a3998aa
Show file tree
Hide file tree
Showing 17 changed files with 411 additions and 124 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ endif()
if(MSVC)
SET(ISMSVC yes)
endif()
if(osname MATCHES "MINGW.*")
if(osname MATCHES "MINGW.*" OR osname MATCHES "MSYS.*")
SET(ISMINGW yes)
SET(MINGW yes)
endif()
Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This file contains a high-level description of this package's evolution. Release

## 4.9.1 - T.B.D.


* [Enhancement] Provide a simple API to allow user access to the internal .rc file table: supports get/set/overwrite of entries of the form "key=value". See [Github #2408](https://github.com/Unidata/netcdf-c/pull/2408).
* [Bug Fix] Use env variable USERPROFILE instead of HOME for windows and mingw. See [Github #2405](https://github.com/Unidata/netcdf-c/pull/2405).
* [Bug Fix] Fix the nc_def_var_fletcher32 code in hdf5 to properly test value of the fletcher32 argument. See [Github #2403](https://github.com/Unidata/netcdf-c/pull/2403).

Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ case "`uname`" in
Darwin*) ISOSX=yes;;
WIN*) ISMSVC=yes;;
MINGW*) ISMINGW=yes;;
MSYS*) ISMINGW=yes;;
esac

if test "x$MSYSTEM" != x ; then
Expand Down
4 changes: 2 additions & 2 deletions include/ncrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ and accessing rc files (e.g. .daprc).

typedef struct NCRCentry {
char* host; /* combined host:port */
char* path; /* prefix to match or NULL */
char* urlpath; /* prefix to match or NULL */
char* key;
char* value;
} NCRCentry;
Expand Down Expand Up @@ -67,7 +67,7 @@ extern "C" {

/* From drc.c */
EXTERNL void ncrc_initialize(void);
EXTERNL int NC_rcfile_insert(const char* key, const char* value, const char* hostport, const char* path);
EXTERNL int NC_rcfile_insert(const char* key, const char* hostport, const char* path, const char* value);
EXTERNL char* NC_rclookup(const char* key, const char* hostport, const char* path);
EXTERNL char* NC_rclookupx(NCURI* uri, const char* key);

Expand Down
8 changes: 8 additions & 0 deletions include/netcdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,14 @@ EXTERNL int nc_initialize(void);
*/
EXTERNL int nc_finalize(void);

/* Programmatic access to the internal .rc table */

/* Get the value corresponding to key | return NULL; caller frees result */
EXTERNL char* nc_rc_get(const char* key);

/* Set/overwrite the value corresponding to key */
EXTERNL int nc_rc_set(const char* key, const char* value);

#if defined(__cplusplus)
}
#endif
Expand Down
1 change: 0 additions & 1 deletion libdispatch/ddispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ NCDISPATCH_initialize(void)
NCpathcanonical(home,&globalstate->home);
nullfree(home);
}
fprintf(stderr,">>> HOME=|%s|\n",globalstate->home); fflush(stderr);

/* Capture $CWD */
{
Expand Down
19 changes: 19 additions & 0 deletions libdispatch/dhttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include "nclog.h"
#include "ncbytes.h"
#include "nclist.h"
#include "ncuri.h"
#include "nchttp.h"
#include "ncauth.h"

#undef TRACE

Expand Down Expand Up @@ -482,6 +484,23 @@ setupconn(NC_HTTP_STATE* state, const char* objecturl)
cstat = curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
if (cstat != CURLE_OK) goto fail;

/* Pull some values from .rc tables */
{
NCURI* uri = NULL;
char* hostport = NULL;
char* value = NULL;
ncuriparse(objecturl,&uri);
if(uri == NULL) goto fail;
hostport = NC_combinehostport(uri);
value = NC_rclookup("HTTP.SSL.CAINFO",hostport,NULL);
if(value == NULL)
value = NC_rclookup("HTTP.SSL.CAINFO",NULL,NULL);
if(value != NULL) {
cstat = CURLERR(curl_easy_setopt(state->curl, CURLOPT_CAINFO, value));
if (cstat != CURLE_OK) goto fail;
}
}

/* Set the method */
if((stat = nc_http_set_method(state,state->request.method))) goto done;

Expand Down
Loading

0 comments on commit a3998aa

Please sign in to comment.