2017-08-31 02:05:04 +08:00
|
|
|
/*
|
2018-12-07 05:29:57 +08:00
|
|
|
Copyright (c) 1998-2018 University Corporation for Atmospheric Research/Unidata
|
|
|
|
See COPYRIGHT for license information.
|
2017-08-31 02:05:04 +08:00
|
|
|
*/
|
2017-03-09 08:01:10 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STDARG_H
|
|
|
|
#include <stdarg.h>
|
|
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2017-08-31 07:44:57 +08:00
|
|
|
#include "netcdf.h"
|
2017-03-09 08:01:10 +08:00
|
|
|
#include "ncbytes.h"
|
2017-08-31 07:44:57 +08:00
|
|
|
#include "ncuri.h"
|
2017-03-09 08:01:10 +08:00
|
|
|
#include "ncrc.h"
|
2017-08-31 07:44:57 +08:00
|
|
|
#include "nclog.h"
|
2020-10-14 09:12:15 +08:00
|
|
|
#include "ncpathmgr.h"
|
2017-08-31 07:44:57 +08:00
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
#define RTAG ']'
|
|
|
|
#define LTAG '['
|
|
|
|
|
|
|
|
#define TRIMCHARS " \t\r\n"
|
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
#undef MEMCHECK
|
|
|
|
#define MEMCHECK(x) if((x)==NULL) {goto nomem;} else {}
|
|
|
|
|
|
|
|
/* Forward */
|
|
|
|
static char* rcreadline(char** nextlinep);
|
|
|
|
static void rctrim(char* text);
|
2018-02-09 10:53:40 +08:00
|
|
|
static void rcorder(NClist* rc);
|
2017-08-31 07:44:57 +08:00
|
|
|
static int rccompile(const char* path);
|
|
|
|
static struct NCTriple* rclocate(const char* key, const char* hostport);
|
|
|
|
static int rcsearch(const char* prefix, const char* rcname, char** pathp);
|
2017-09-01 04:19:56 +08:00
|
|
|
static void rcfreetriples(NClist* rc);
|
2017-08-31 07:44:57 +08:00
|
|
|
#ifdef D4DEBUG
|
|
|
|
static void storedump(char* msg, NClist* triples);
|
|
|
|
#endif
|
2017-03-09 08:01:10 +08:00
|
|
|
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
/* Define default rc files and aliases, also defines load order*/
|
|
|
|
static const char* rcfilenames[] = {".ncrc", ".daprc", ".dodsrc",NULL};
|
2017-03-09 08:01:10 +08:00
|
|
|
|
|
|
|
/**************************************************/
|
2017-08-31 07:44:57 +08:00
|
|
|
/* External Entry Points */
|
2017-03-09 08:01:10 +08:00
|
|
|
|
2019-03-31 04:06:20 +08:00
|
|
|
static NCRCglobalstate* ncrc_globalstate = NULL;
|
|
|
|
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
static int NCRCinitialized = 0;
|
|
|
|
|
|
|
|
/* Initialize defaults */
|
|
|
|
void
|
|
|
|
ncrc_initialize(void)
|
2019-03-31 04:06:20 +08:00
|
|
|
{
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
const char* tmp = NULL;
|
|
|
|
|
|
|
|
if(NCRCinitialized) return;
|
2019-03-31 04:06:20 +08:00
|
|
|
if(ncrc_globalstate == NULL) {
|
|
|
|
ncrc_globalstate = calloc(1,sizeof(NCRCglobalstate));
|
|
|
|
}
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
/* Get environment variables */
|
|
|
|
if(getenv(NCRCENVIGNORE) != NULL)
|
|
|
|
ncrc_globalstate->rcinfo.ignore = 1;
|
|
|
|
tmp = getenv(NCRCENVRC);
|
|
|
|
if(tmp != NULL && strlen(tmp) > 0)
|
|
|
|
ncrc_globalstate->rcinfo.rcfile = strdup(tmp);
|
|
|
|
NCRCinitialized = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get global state */
|
|
|
|
NCRCglobalstate*
|
|
|
|
ncrc_getglobalstate(void)
|
|
|
|
{
|
|
|
|
if(!NCRCinitialized)
|
|
|
|
ncrc_initialize();
|
2019-03-31 04:06:20 +08:00
|
|
|
return ncrc_globalstate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ncrc_freeglobalstate(void)
|
|
|
|
{
|
|
|
|
if(ncrc_globalstate != NULL) {
|
|
|
|
nullfree(ncrc_globalstate->tempdir);
|
|
|
|
nullfree(ncrc_globalstate->home);
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
nullfree(ncrc_globalstate->cwd);
|
2019-03-31 04:06:20 +08:00
|
|
|
NC_rcclear(&ncrc_globalstate->rcinfo);
|
|
|
|
free(ncrc_globalstate);
|
|
|
|
ncrc_globalstate = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NC_rcclear(NCRCinfo* info)
|
|
|
|
{
|
|
|
|
if(info == NULL) return;
|
|
|
|
nullfree(info->rcfile);
|
|
|
|
rcfreetriples(info->triples);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rcfreetriples(NClist* rc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0;i<nclistlength(rc);i++) {
|
|
|
|
NCTriple* t = (NCTriple*)nclistget(rc,i);
|
|
|
|
nullfree(t->host);
|
|
|
|
nullfree(t->key);
|
|
|
|
nullfree(t->value);
|
|
|
|
free(t);
|
|
|
|
}
|
|
|
|
nclistfree(rc);
|
|
|
|
}
|
2017-03-09 08:01:10 +08:00
|
|
|
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
/* locate, read and compile the rc files, if any */
|
2017-03-09 08:01:10 +08:00
|
|
|
int
|
2017-08-31 07:44:57 +08:00
|
|
|
NC_rcload(void)
|
2017-03-09 08:01:10 +08:00
|
|
|
{
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
int i,ret = NC_NOERR;
|
2017-03-09 08:01:10 +08:00
|
|
|
char* path = NULL;
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
NCRCglobalstate* globalstate = NULL;
|
|
|
|
NClist* rcfileorder = nclistnew();
|
2017-03-09 08:01:10 +08:00
|
|
|
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
if(!NCRCinitialized) ncrc_initialize();
|
|
|
|
globalstate = ncrc_getglobalstate();
|
|
|
|
|
2019-03-31 04:06:20 +08:00
|
|
|
if(globalstate->rcinfo.ignore) {
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
nclog(NCLOGDBG,".rc file loading suppressed");
|
|
|
|
goto done;
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
if(globalstate->rcinfo.loaded) goto done;
|
|
|
|
|
|
|
|
/* locate the configuration files in order of use:
|
|
|
|
1. Specified by NCRCENV_RC environment variable.
|
|
|
|
2. If NCRCENV_RC is not set then merge the set of rc files in this order:
|
|
|
|
1. $HOME/.ncrc
|
|
|
|
2. $HOME/.daprc
|
|
|
|
3. $HOME/.docsrc
|
|
|
|
4. $CWD/.ncrc
|
|
|
|
5. $CWD/.daprc
|
|
|
|
6. $CWD/.docsrc
|
|
|
|
Entries in later files override any of the earlier files
|
2017-03-09 08:01:10 +08:00
|
|
|
*/
|
2019-03-31 04:06:20 +08:00
|
|
|
if(globalstate->rcinfo.rcfile != NULL) { /* always use this */
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
nclistpush(rcfileorder,strdup(globalstate->rcinfo.rcfile));
|
2017-08-31 07:44:57 +08:00
|
|
|
} else {
|
2019-03-31 04:06:20 +08:00
|
|
|
const char** rcname;
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
const char* dirnames[3];
|
|
|
|
const char** dir;
|
|
|
|
|
|
|
|
dirnames[0] = globalstate->home;
|
|
|
|
dirnames[1] = globalstate->cwd;
|
|
|
|
dirnames[2] = NULL;
|
|
|
|
|
|
|
|
for(dir=dirnames;*dir;dir++) {
|
|
|
|
for(rcname=rcfilenames;*rcname;rcname++) {
|
|
|
|
ret = rcsearch(*dir,*rcname,&path);
|
|
|
|
if(ret == NC_NOERR && path != NULL)
|
|
|
|
nclistpush(rcfileorder,path);
|
|
|
|
path = NULL;
|
|
|
|
}
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
}
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
for(i=0;i<nclistlength(rcfileorder);i++) {
|
|
|
|
path = (char*)nclistget(rcfileorder,i);
|
|
|
|
if((ret=rccompile(path))) {
|
|
|
|
nclog(NCLOGWARN, "Error parsing %s\n",path);
|
|
|
|
ret = NC_NOERR; /* ignore it */
|
2017-08-31 07:44:57 +08:00
|
|
|
goto done;
|
|
|
|
}
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
done:
|
2019-03-31 04:06:20 +08:00
|
|
|
globalstate->rcinfo.loaded = 1; /* even if not exists */
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
nclistfreeall(rcfileorder);
|
2017-08-31 07:44:57 +08:00
|
|
|
return (ret);
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
/**
|
|
|
|
* Locate a triple by property key and host+port (may be null|"")
|
|
|
|
* If duplicate keys, first takes precedence.
|
|
|
|
*/
|
|
|
|
char*
|
|
|
|
NC_rclookup(const char* key, const char* hostport)
|
|
|
|
{
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
struct NCTriple* triple = NULL;
|
|
|
|
if(!NCRCinitialized) ncrc_initialize();
|
|
|
|
triple = rclocate(key,hostport);
|
2017-03-09 08:01:10 +08:00
|
|
|
return (triple == NULL ? NULL : triple->value);
|
|
|
|
}
|
|
|
|
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
#if 0
|
2017-08-31 07:44:57 +08:00
|
|
|
/*!
|
|
|
|
Set the absolute path to use for the rc file.
|
|
|
|
WARNING: this MUST be called before any other
|
|
|
|
call in order for this to take effect.
|
2017-03-09 08:01:10 +08:00
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
\param[in] rcfile The path to use. If NULL, or "",
|
|
|
|
then do not use any rcfile.
|
|
|
|
|
|
|
|
\retval OC_NOERR if the request succeeded.
|
|
|
|
\retval OC_ERCFILE if the file failed to load
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
NC_set_rcfile(const char* rcfile)
|
|
|
|
{
|
|
|
|
int stat = NC_NOERR;
|
|
|
|
FILE* f = NULL;
|
2019-03-31 04:06:20 +08:00
|
|
|
NCRCglobalstate* globalstate = ncrc_getglobalstate();
|
2017-08-31 07:44:57 +08:00
|
|
|
|
|
|
|
if(rcfile != NULL && strlen(rcfile) == 0)
|
|
|
|
rcfile = NULL;
|
|
|
|
f = NCfopen(rcfile,"r");
|
|
|
|
if(f == NULL) {
|
|
|
|
stat = NC_ERCFILE;
|
|
|
|
goto done;
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
2017-08-31 07:44:57 +08:00
|
|
|
fclose(f);
|
2019-03-31 04:06:20 +08:00
|
|
|
nullfree(globalstate->rcinfo.rcfile);
|
|
|
|
globalstate->rcinfo.rcfile = strdup(rcfile);
|
|
|
|
/* Clear globalstate->rcinfo */
|
|
|
|
NC_rcclear(&globalstate->rcinfo);
|
2017-08-31 07:44:57 +08:00
|
|
|
/* (re) load the rcfile and esp the triplestore*/
|
|
|
|
stat = NC_rcload();
|
|
|
|
done:
|
|
|
|
return stat;
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
#endif
|
2017-03-09 08:01:10 +08:00
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
/**************************************************/
|
|
|
|
/* RC processing functions */
|
|
|
|
|
|
|
|
static char*
|
|
|
|
rcreadline(char** nextlinep)
|
2017-03-09 08:01:10 +08:00
|
|
|
{
|
2017-08-31 07:44:57 +08:00
|
|
|
char* line;
|
|
|
|
char* p;
|
|
|
|
|
|
|
|
line = (p = *nextlinep);
|
|
|
|
if(*p == '\0') return NULL; /*signal done*/
|
|
|
|
for(;*p;p++) {
|
|
|
|
if(*p == '\r' && p[1] == '\n') *p = '\0';
|
|
|
|
else if(*p == '\n') break;
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
2017-08-31 07:44:57 +08:00
|
|
|
*p++ = '\0'; /* null terminate line; overwrite newline */
|
|
|
|
*nextlinep = p;
|
|
|
|
return line;
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
/* Trim TRIMCHARS from both ends of text; */
|
2017-03-09 08:01:10 +08:00
|
|
|
static void
|
2017-08-31 07:44:57 +08:00
|
|
|
rctrim(char* text)
|
2017-03-09 08:01:10 +08:00
|
|
|
{
|
2017-08-31 07:44:57 +08:00
|
|
|
char* p = text;
|
2018-06-08 06:17:32 +08:00
|
|
|
size_t len = 0;
|
2017-08-31 07:44:57 +08:00
|
|
|
int i;
|
|
|
|
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
if(text == NULL) return;
|
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
/* locate first non-trimchar */
|
|
|
|
for(;*p;p++) {
|
|
|
|
if(strchr(TRIMCHARS,*p) == NULL) break; /* hit non-trim char */
|
|
|
|
}
|
|
|
|
memmove(text,p,strlen(p)+1);
|
|
|
|
len = strlen(text);
|
|
|
|
/* locate last non-trimchar */
|
|
|
|
if(len > 0) {
|
|
|
|
for(i=(len-1);i>=0;i--) {
|
|
|
|
if(strchr(TRIMCHARS,text[i]) == NULL) {
|
|
|
|
text[i+1] = '\0'; /* elide trailing trimchars */
|
|
|
|
break;
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
}
|
2017-08-31 07:44:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Order the triples: those with urls must be first,
|
|
|
|
but otherwise relative order does not matter.
|
|
|
|
*/
|
2018-02-09 10:53:40 +08:00
|
|
|
static void
|
2017-08-31 07:44:57 +08:00
|
|
|
rcorder(NClist* rc)
|
|
|
|
{
|
2017-11-09 21:24:18 +08:00
|
|
|
int i;
|
2017-08-31 07:44:57 +08:00
|
|
|
int len = nclistlength(rc);
|
2018-05-19 10:28:51 +08:00
|
|
|
NClist* tmprc = NULL;
|
2018-02-09 10:53:40 +08:00
|
|
|
if(rc == NULL || len == 0) return;
|
2018-05-19 10:28:51 +08:00
|
|
|
tmprc = nclistnew();
|
2018-02-09 10:53:40 +08:00
|
|
|
/* Copy rc into tmprc and clear rc */
|
2017-08-31 07:44:57 +08:00
|
|
|
for(i=0;i<len;i++) {
|
|
|
|
NCTriple* ti = nclistget(rc,i);
|
2018-02-09 10:53:40 +08:00
|
|
|
nclistpush(tmprc,ti);
|
|
|
|
}
|
|
|
|
nclistclear(rc);
|
|
|
|
/* Two passes: 1) pull triples with host */
|
|
|
|
for(i=0;i<len;i++) {
|
|
|
|
NCTriple* ti = nclistget(tmprc,i);
|
2017-08-31 07:44:57 +08:00
|
|
|
if(ti->host == NULL) continue;
|
2018-02-09 10:53:40 +08:00
|
|
|
nclistpush(rc,ti);
|
2017-08-31 07:44:57 +08:00
|
|
|
}
|
|
|
|
/* pass 2 pull triples without host*/
|
|
|
|
for(i=0;i<len;i++) {
|
2018-02-09 10:53:40 +08:00
|
|
|
NCTriple* ti = nclistget(tmprc,i);
|
2017-08-31 07:44:57 +08:00
|
|
|
if(ti->host != NULL) continue;
|
2018-02-09 10:53:40 +08:00
|
|
|
nclistpush(rc,ti);
|
2017-08-31 07:44:57 +08:00
|
|
|
}
|
|
|
|
#ifdef D4DEBUG
|
2018-02-09 10:53:40 +08:00
|
|
|
storedump("reorder:",rc);
|
2017-08-31 07:44:57 +08:00
|
|
|
#endif
|
2018-02-09 10:53:40 +08:00
|
|
|
nclistfree(tmprc);
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
/* Merge a triple store from a file*/
|
2017-03-09 08:01:10 +08:00
|
|
|
static int
|
2017-08-31 07:44:57 +08:00
|
|
|
rccompile(const char* path)
|
2017-03-09 08:01:10 +08:00
|
|
|
{
|
2017-08-31 07:44:57 +08:00
|
|
|
int ret = NC_NOERR;
|
2018-02-09 10:53:40 +08:00
|
|
|
NClist* rc = NULL;
|
2017-08-31 07:44:57 +08:00
|
|
|
char* contents = NULL;
|
|
|
|
NCbytes* tmp = ncbytesnew();
|
|
|
|
NCURI* uri = NULL;
|
|
|
|
char* nextline = NULL;
|
2019-03-31 04:06:20 +08:00
|
|
|
NCRCglobalstate* globalstate = ncrc_getglobalstate();
|
2017-08-31 07:44:57 +08:00
|
|
|
|
|
|
|
if((ret=NC_readfile(path,tmp))) {
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
nclog(NCLOGWARN, "Could not open configuration file: %s",path);
|
2018-06-08 06:17:32 +08:00
|
|
|
goto done;
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
2017-08-31 07:44:57 +08:00
|
|
|
contents = ncbytesextract(tmp);
|
|
|
|
if(contents == NULL) contents = strdup("");
|
2018-02-09 10:53:40 +08:00
|
|
|
/* Either reuse or create new */
|
2019-03-31 04:06:20 +08:00
|
|
|
rc = globalstate->rcinfo.triples;
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
if(rc == NULL) {
|
2018-02-09 10:53:40 +08:00
|
|
|
rc = nclistnew();
|
2019-03-31 04:06:20 +08:00
|
|
|
globalstate->rcinfo.triples = rc;
|
2018-02-09 10:53:40 +08:00
|
|
|
}
|
2017-08-31 07:44:57 +08:00
|
|
|
nextline = contents;
|
2017-03-09 08:01:10 +08:00
|
|
|
for(;;) {
|
|
|
|
char* line;
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
char* key = NULL;
|
|
|
|
char* value = NULL;
|
|
|
|
char* host = NULL;
|
2017-08-31 07:44:57 +08:00
|
|
|
size_t llen;
|
|
|
|
NCTriple* triple;
|
|
|
|
|
|
|
|
line = rcreadline(&nextline);
|
|
|
|
if(line == NULL) break; /* done */
|
|
|
|
rctrim(line); /* trim leading and trailing blanks */
|
|
|
|
if(line[0] == '#') continue; /* comment */
|
|
|
|
if((llen=strlen(line)) == 0) continue; /* empty line */
|
2018-10-02 05:51:43 +08:00
|
|
|
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);
|
2017-08-31 07:44:57 +08:00
|
|
|
continue;
|
2018-10-02 05:51:43 +08:00
|
|
|
}
|
|
|
|
line = rtag + 1;
|
|
|
|
*rtag = '\0';
|
|
|
|
/* compile the url and pull out the host */
|
|
|
|
if(uri) ncurifree(uri);
|
2019-09-30 02:59:28 +08:00
|
|
|
if(ncuriparse(url,&uri)) {
|
2018-10-02 05:51:43 +08:00
|
|
|
nclog(NCLOGERR, "Malformed [url] in %s entry: %s",path,line);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ncbytesclear(tmp);
|
|
|
|
ncbytescat(tmp,uri->host);
|
|
|
|
if(uri->port != NULL) {
|
2017-08-31 07:44:57 +08:00
|
|
|
ncbytesappend(tmp,':');
|
2018-10-02 05:51:43 +08:00
|
|
|
ncbytescat(tmp,uri->port);
|
|
|
|
}
|
|
|
|
ncbytesnull(tmp);
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
host = ncbytesextract(tmp);
|
|
|
|
if(strlen(host)==0)
|
|
|
|
{free(host); host = NULL;}
|
2018-10-02 05:51:43 +08:00
|
|
|
}
|
2017-03-09 08:01:10 +08:00
|
|
|
/* split off key and value */
|
2017-08-31 07:44:57 +08:00
|
|
|
key=line;
|
2017-03-09 08:01:10 +08:00
|
|
|
value = strchr(line, '=');
|
|
|
|
if(value == NULL)
|
|
|
|
value = line + strlen(line);
|
|
|
|
else {
|
|
|
|
*value = '\0';
|
|
|
|
value++;
|
|
|
|
}
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
/* See if key already exists */
|
|
|
|
triple = rclocate(key,host);
|
|
|
|
if(triple != NULL) {
|
|
|
|
nullfree(triple->host);
|
|
|
|
nullfree(triple->key);
|
|
|
|
nullfree(triple->value);
|
|
|
|
} else {
|
|
|
|
triple = (NCTriple*)calloc(1,sizeof(NCTriple));
|
|
|
|
if(triple == NULL) {ret = NC_ENOMEM; goto done;}
|
|
|
|
nclistpush(rc,triple);
|
|
|
|
}
|
|
|
|
triple->host = host; host = NULL;
|
|
|
|
triple->key = nulldup(key);
|
|
|
|
triple->value = nulldup(value);
|
|
|
|
rctrim(triple->host);
|
2017-08-31 07:44:57 +08:00
|
|
|
rctrim(triple->key);
|
|
|
|
rctrim(triple->value);
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
#ifdef D4DEBUG
|
|
|
|
fprintf(stderr,"rc: host=%s key=%s value=%s\n",
|
2018-02-28 05:22:04 +08:00
|
|
|
(triple->host != NULL ? triple->host : "<null>"),
|
|
|
|
triple->key,triple->valu);
|
2017-08-31 07:44:57 +08:00
|
|
|
#endif
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
triple = NULL;
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
2017-08-31 07:44:57 +08:00
|
|
|
rcorder(rc);
|
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
done:
|
2018-02-09 10:53:40 +08:00
|
|
|
if(contents) free(contents);
|
2017-08-31 07:44:57 +08:00
|
|
|
ncurifree(uri);
|
|
|
|
ncbytesfree(tmp);
|
|
|
|
return (ret);
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
/**
|
|
|
|
* (Internal) Locate a triple by property key and host+port (may be null or "").
|
|
|
|
* If duplicate keys, first takes precedence.
|
|
|
|
*/
|
|
|
|
static struct NCTriple*
|
|
|
|
rclocate(const char* key, const char* hostport)
|
|
|
|
{
|
2018-02-09 10:53:40 +08:00
|
|
|
int i,found;
|
2019-03-31 04:06:20 +08:00
|
|
|
NCRCglobalstate* globalstate = ncrc_getglobalstate();
|
|
|
|
NClist* rc = globalstate->rcinfo.triples;
|
2017-08-31 07:44:57 +08:00
|
|
|
NCTriple* triple = NULL;
|
|
|
|
|
2019-03-31 04:06:20 +08:00
|
|
|
if(globalstate->rcinfo.ignore)
|
2017-08-31 07:44:57 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(key == NULL || rc == NULL) return NULL;
|
|
|
|
if(hostport == NULL) hostport = "";
|
|
|
|
|
|
|
|
for(found=0,i=0;i<nclistlength(rc);i++) {
|
2018-11-09 03:37:03 +08:00
|
|
|
int t;
|
|
|
|
size_t hplen;
|
|
|
|
triple = (NCTriple*)nclistget(rc,i);
|
|
|
|
|
|
|
|
hplen = (triple->host == NULL ? 0 : strlen(triple->host));
|
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
if(strcmp(key,triple->key) != 0) continue; /* keys do not match */
|
|
|
|
/* If the triple entry has no url, then use it
|
|
|
|
(because we have checked all other cases)*/
|
|
|
|
if(hplen == 0) {found=1;break;}
|
|
|
|
/* do hostport match */
|
2018-02-28 05:22:04 +08:00
|
|
|
t = 0;
|
|
|
|
if(triple->host != NULL)
|
|
|
|
t = strcmp(hostport,triple->host);
|
2017-08-31 07:44:57 +08:00
|
|
|
if(t == 0) {found=1; break;}
|
|
|
|
}
|
|
|
|
return (found?triple:NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate rc file by searching in directory prefix.
|
|
|
|
*/
|
|
|
|
static
|
|
|
|
int
|
|
|
|
rcsearch(const char* prefix, const char* rcname, char** pathp)
|
2017-03-09 08:01:10 +08:00
|
|
|
{
|
|
|
|
char* path = NULL;
|
|
|
|
FILE* f = NULL;
|
2019-10-25 04:28:39 +08:00
|
|
|
size_t plen = (prefix?strlen(prefix):0);
|
2019-01-12 02:41:09 +08:00
|
|
|
size_t rclen = strlen(rcname);
|
2017-08-31 07:44:57 +08:00
|
|
|
int ret = NC_NOERR;
|
|
|
|
|
|
|
|
size_t pathlen = plen+rclen+1; /*+1 for '/' */
|
|
|
|
path = (char*)malloc(pathlen+1); /* +1 for nul*/
|
|
|
|
if(path == NULL) {ret = NC_ENOMEM; goto done;}
|
|
|
|
strncpy(path,prefix,pathlen);
|
|
|
|
strncat(path,"/",pathlen);
|
|
|
|
strncat(path,rcname,pathlen);
|
2017-03-09 08:01:10 +08:00
|
|
|
/* see if file is readable */
|
Codify cross-platform file paths
The netcdf-c code has to deal with a variety of platforms:
Windows, OSX, Linux, Cygwin, MSYS, etc. These platforms differ
significantly in the kind of file paths that they accept. So in
order to handle this, I have created a set of replacements for
the most common file system operations such as _open_ or _fopen_
or _access_ to manage the file path differences correctly.
A more limited version of this idea was already implemented via
the ncwinpath.h and dwinpath.c code. So this can be viewed as a
replacement for that code. And in path in many cases, the only
change that was required was to replace '#include <ncwinpath.h>'
with '#include <ncpathmgt.h>' and then replace file operation
calls with the NCxxx equivalent from ncpathmgr.h Note that
recently, the ncwinpath.h was renamed ncpathmgmt.h, so this pull
request should not require dealing with winpath.
The heart of the change is include/ncpathmgmt.h, which provides
alternate operations such as NCfopen or NCaccess and which properly
parse and rebuild path arguments to work for the platform on which
the code is executing. This mostly matters for Windows because of the
way that it uses backslash and drive letters, as compared to *nix*.
One important feature is that the user can do string manipulations
on a file path without having to worry too much about the platform
because the path management code will properly handle most mixed cases.
So one can for example concatenate a path suffix that uses forward
slashes to a Windows path and have it work correctly.
The conversion code is in libdispatch/dpathmgr.c, and the
important function there is NCpathcvt which does the proper
conversions to the local path format.
As a rule, most code should just replace their file operations with
the corresponding NCxxx ones defined in include/ncpathmgmt.h. These
NCxxx functions all call NCpathcvt on their path arguments before
executing the actual file operation.
In some rare cases, the client may need to directly use NCpathcvt,
but this should be avoided as much as possible. If there is a need
for supporting a new file operation not already in ncpathmgmt.h, then
use the code in dpathmgr.c as a template. Also please notify Unidata
so we can include it as a formal part or our supported operations.
Also, if you see an operation in the library that is not using the
NCxxx form, then please submit an issue so we can fix it.
Misc. Changes:
* Clean up the utf8 testing code; it is impossible to get some
tests to work under windows using shell scripts; the args do
not pass as utf8 but as some other encoding.
* Added an extra utf8 test case: test_unicode_path.sh
* Add a true test for HDF5 1.10.6 or later because as noted in
PR https://github.com/Unidata/netcdf-c/pull/1794,
HDF5 changed its Windows file path handling.
2021-03-05 04:41:31 +08:00
|
|
|
f = NCfopen(path,"r");
|
2017-03-09 08:01:10 +08:00
|
|
|
if(f != NULL)
|
|
|
|
nclog(NCLOGDBG, "Found rc file=%s",path);
|
|
|
|
done:
|
2017-08-31 07:44:57 +08:00
|
|
|
if(f == NULL || ret != NC_NOERR) {
|
|
|
|
nullfree(path);
|
2017-03-09 08:01:10 +08:00
|
|
|
path = NULL;
|
|
|
|
}
|
|
|
|
if(f != NULL)
|
2017-08-31 07:44:57 +08:00
|
|
|
fclose(f);
|
2017-03-09 08:01:10 +08:00
|
|
|
if(pathp != NULL)
|
2017-08-31 07:44:57 +08:00
|
|
|
*pathp = path;
|
|
|
|
else {
|
|
|
|
nullfree(path);
|
|
|
|
path = NULL;
|
|
|
|
}
|
|
|
|
return (ret);
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
|
|
|
|
2018-08-27 07:04:46 +08:00
|
|
|
int
|
|
|
|
NC_rcfile_insert(const char* key, const char* value, const char* hostport)
|
|
|
|
{
|
|
|
|
int ret = NC_NOERR;
|
|
|
|
/* See if this key already defined */
|
|
|
|
struct NCTriple* triple = NULL;
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
NCRCglobalstate* globalstate = NULL;
|
|
|
|
NClist* rc = NULL;
|
2018-08-27 07:04:46 +08:00
|
|
|
|
Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716
The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}. So now it
is possible to use a key like "0/1/2/0" for chunk names.
This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.
Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.
In addition the following unrelated changes were made.
1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
is not found then the other options that depend upon it properly
are disabled.
1. I decided that xarray support should be enabled by default for pure
zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
to work when testing in parallel, some inter-test dependencies needed to
be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-25 09:48:15 +08:00
|
|
|
if(!NCRCinitialized) ncrc_initialize();
|
|
|
|
globalstate = ncrc_getglobalstate();
|
|
|
|
rc = globalstate->rcinfo.triples;
|
|
|
|
|
2018-08-27 07:04:46 +08:00
|
|
|
if(rc == NULL) {
|
|
|
|
rc = nclistnew();
|
|
|
|
if(rc == NULL) {ret = NC_ENOMEM; goto done;}
|
|
|
|
}
|
|
|
|
triple = rclocate(key,hostport);
|
|
|
|
if(triple == NULL) {
|
|
|
|
triple = (NCTriple*)calloc(1,sizeof(NCTriple));
|
|
|
|
if(triple == NULL) {ret = NC_ENOMEM; goto done;}
|
|
|
|
triple->key = strdup(key);
|
|
|
|
triple->value = NULL;
|
|
|
|
rctrim(triple->key);
|
|
|
|
triple->host = (hostport == NULL ? NULL : strdup(hostport));
|
|
|
|
nclistpush(rc,triple);
|
|
|
|
}
|
|
|
|
if(triple->value != NULL) free(triple->value);
|
|
|
|
triple->value = strdup(value);
|
|
|
|
rctrim(triple->value);
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Provide byte-range reading of remote datasets
re: issue https://github.com/Unidata/netcdf-c/issues/1251
Assume that you have the URL to a remote dataset
which is a normal netcdf-3 or netcdf-4 file.
This PR allows the netcdf-c to read that dataset's
contents as a netcdf file using HTTP byte ranges
if the remote server supports byte-range access.
Originally, this PR was set up to access Amazon S3 objects,
but it can also access other remote datasets such as those
provided by a Thredds server via the HTTPServer access protocol.
It may also work for other kinds of servers.
Note that this is not intended as a true production
capability because, as is known, this kind of access to
can be quite slow. In addition, the byte-range IO drivers
do not currently do any sort of optimization or caching.
An additional goal here is to gain some experience with
the Amazon S3 REST protocol.
This architecture and its use documented in
the file docs/byterange.dox.
There are currently two test cases:
1. nc_test/tst_s3raw.c - this does a simple open, check format, close cycle
for a remote netcdf-3 file and a remote netcdf-4 file.
2. nc_test/test_s3raw.sh - this uses ncdump to investigate some remote
datasets.
This PR also incorporates significantly changed model inference code
(see the superceded PR https://github.com/Unidata/netcdf-c/pull/1259).
1. It centralizes the code that infers the dispatcher.
2. It adds support for byte-range URLs
Other changes:
1. NC_HDF5_finalize was not being properly called by nc_finalize().
2. Fix minor bug in ncgen3.l
3. fix memory leak in nc4info.c
4. add code to walk the .daprc triples and to replace protocol=
fragment tag with a more general mode= tag.
Final Note:
Th inference code is still way too complicated. We need to move
to the validfile() model used by netcdf Java, where each
dispatcher is asked if it can process the file. This decentralizes
the inference code. This will be done after all the major new
dispatchers (PIO, Zarr, etc) have been implemented.
2019-01-02 09:27:36 +08:00
|
|
|
/* Obtain the count of number of triples */
|
|
|
|
size_t
|
|
|
|
NC_rcfile_length(NCRCinfo* info)
|
|
|
|
{
|
|
|
|
return nclistlength(info->triples);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Obtain the ith triple; return NULL if out of range */
|
|
|
|
NCTriple*
|
|
|
|
NC_rcfile_ith(NCRCinfo* info, size_t i)
|
|
|
|
{
|
|
|
|
if(i >= nclistlength(info->triples))
|
|
|
|
return NULL;
|
|
|
|
return (NCTriple*)nclistget(info->triples,i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-31 07:44:57 +08:00
|
|
|
#ifdef D4DEBUG
|
|
|
|
static void
|
|
|
|
storedump(char* msg, NClist* triples)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(msg != NULL) fprintf(stderr,"%s\n",msg);
|
|
|
|
if(triples == NULL || nclistlength(triples)==0) {
|
|
|
|
fprintf(stderr,"<EMPTY>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for(i=0;i<nclistlength(triples);i++) {
|
|
|
|
NCTriple* t = (NCTriple*)nclistget(triples,i);
|
|
|
|
fprintf(stderr,"\t%s\t%s\t%s\n",
|
|
|
|
((t->host == NULL || strlen(t->host)==0)?"--":t->host),t->key,t->value);
|
|
|
|
}
|
|
|
|
fflush(stderr);
|
2017-03-09 08:01:10 +08:00
|
|
|
}
|
2017-08-31 07:44:57 +08:00
|
|
|
#endif
|