Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make public a limited API for programmatic access to internal .rc tables #2408

Merged
merged 3 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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