Commit Graph

45 Commits

Author SHA1 Message Date
Ward Fisher
f77b96b066 Fixed a potential null/garbage free. 2019-10-24 16:37:52 -06:00
Dennis Heimbigner
f1506d552e Change (again), and hopefully simplify, the file model inference algorithm.
* For URL paths, the new approach essentially centralizes all information
  in the URL into the "#mode=" fragment key and uses that value
  to determine the dispatcher for (most) URLs.

* The new approach has the following steps:

  1. canonicalize the path if it is a URL.
  2. use the mode= fragment key to determine the dispatcher
  3. if dispatcher still not determined, then use the mode flags
     argument to nc_open/nc_create to determine the dispatcher.
  4. if the path points to something readable, attempt to read the
     magic number at the front, and use that to determine the dispatcher.
     this case may override all previous cases.

* Misc changes.

  1. Update documentation
  2. Moved some unit tests from libdispatch to unit_test directory.
  3. Fixed use of wrong #ifdef macro in test_filter_reg.c
     [I think this may fix an previously reported esupport query].
2019-09-29 12:59:28 -06:00
Dennis Heimbigner
000f22b12a Fix encoding of a DAP2 constraint specified outside the URL.
re: github issue #1425

The 'ncdump -v' command causes a constraint to be sent
to the opendap code (in libdap2). This is a separate path
from specifying the constraint via a URL.

This separate path encoded its constraint using code independent
of and duplicative of that provided by ncuri.c and this duplicate
code did not properly encode the constraint, which might include
square brackets.

Solution chosen here was to get rid of the duplicate code and
ensure that all URL escaping is performed in the ncuribuild function
in the ncuri.c file.

Also removed the use of the NEWESCAPE conditional in ncuri.c
because it is no longer needed.
2019-07-14 15:56:29 -06:00
Dennis Heimbigner
6934aa2e8b Thread safety: step 1: cleanup
re: https://github.com/Unidata/netcdf-c/issues/1373 (partial)

* Mark some global constants be const to indicate to make them easier to track.
* Hide direct access to the ncrc_globalstate behind a function call.
* Convert dispatch tables to constants (except the user defined ones)
  This has some consequences in terms of function arguments needing to be marked
  as const also.
* Remove some no longer needed global fields
* Aggregate all the globals in nclog.c
* Uniformly replace nc_sizevector{0,1} with NC_coord_{zero,one}
* Uniformly replace nc_ptrdffvector1 with NC_stride_one
* Remove some obsolete code
2019-03-30 14:06:20 -06:00
Ward Fisher
1fde39c8d7
Merge branch 'master' into byterange.dmh 2019-02-07 14:28:23 -07:00
Ben Boeckel
8c331222ec warnings: store sizes in size_t 2019-01-16 15:55:33 -05:00
Ben Boeckel
eb0b9b8bbd ncuri: check the right preprocessor definition 2019-01-16 15:53:26 -05:00
Dennis Heimbigner
bf2746b8ea 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-01 18:27:36 -07:00
Ward Fisher
25417880f7 Updated libdispatch/ files with copyright notice. 2018-12-06 14:29:57 -07:00
Ed Hartnett
39d45e9941 fixed clang warning in ncuri.c 2018-07-06 06:52:02 -06:00
Ward Fisher
4fba5dfb45 Squaed a potential memory leak. 2018-06-08 12:08:33 -06:00
Ward Fisher
da87652aa7
Merge branch 'master' into dapparams.dmh 2018-03-07 12:50:03 -07:00
Greg Sjaardema
1b68ca28f7
Eliminate warning from clang compilers.
Eliminate this warning from clang:
```
TPL/netcdf/netcdf-c/libdispatch/ncuri.c:914:31: warning: for loop has empty body [-Wempty-body]
        for(p=sp,q=sp+1;(*p++=*q++););
                                     ^
TPL/netcdf/netcdf-c/libdispatch/ncuri.c:914:31: note: put the semicolon on a separate line to silence this warning
1 warning generated.
```
2018-01-11 10:31:13 -07:00
Ed Hartnett
0e0482bc05 fixed warnings 2017-11-09 06:24:18 -07:00
Dennis Heimbigner
3074cc7824 re: esupport AVS-567793
Some parameters like stringlength actually affect a dimension
named maxStrlen.  So, add some aliasing so maxstrlen can be
specified as a parameter and as an alias for stringlength.

The affected parameters (case insensitive):
stringlength has alias maxstrlen
stringlength_<varname> has alias maxstrlen_<varname>

Also:
1. added a test case in ncdap_test/testurl.sh
2. added note to documentation
2017-11-08 19:02:13 -07:00
Dennis Heimbigner
61d2b38c8e Final fixes 2017-08-30 19:13:52 -06:00
Dennis Heimbigner
80dbc7fb6c Undo DECODE_IDENTIFIER change 2017-08-29 18:01:26 -06:00
Dennis Heimbigner
bc9e41ae2b 1. Fix bug in ocrc.c#combinecredentials where a null user+pwd
generates garbage. This in turn interferes with using .netrc
because the garbage user+pwd can will override the
.netrc. Note that this may work ok sometimes
if the garbage happens to start with a nul character.

2. It turns out that the user:pwd combination needs to support
character escaping. One reason is the user may contain an '@' character.
The other is that modern password rules make it not unlikely that
the password will contain characters that interfere with url parsing.
So, the rule I have implemented is that all occurrences of the user:pwd
format must escape any dodgy characters. The escape format is URL escaping
of the form %XX. This applies both to user:pwd
embedded in a URL as well as the use of HTTP.CREDENTIALS.USERPASSWORD
in a .dodsrc/.daprc file. The user and password in .netrc must not
be escaped. This is now documented in docs/auth.md

The fix for #2 actually obviated #1. Now, internally, the user and pwd
are stored separately and not in the user:pwd format. They are combined
(and escaped) only when needed.
2017-08-29 14:11:15 -06:00
Dennis Heimbigner
d1544b8ad9 Error in ncuri in handling user:pwd@ in url 2017-07-05 14:39:23 -06:00
Dennis Heimbigner
32fe709615 ckp 2017-04-14 11:05:30 -06:00
Dennis Heimbigner
d98769a98f ckp 2017-04-11 17:09:58 -06:00
Dennis Heimbigner
83a4c42bc0 ckp 2017-04-11 16:16:29 -06:00
Dennis Heimbigner
3db4f013bf Primary change: add dap4 support
Specific changes:
1. Add dap4 code: libdap4 and dap4_test.
   Note that until the d4ts server problem is solved, dap4 is turned off.
2. Modify various files to support dap4 flags:
	configure.ac, Makefile.am, CMakeLists.txt, etc.
3. Add nc_test/test_common.sh. This centralizes
   the handling of the locations of various
   things in the build tree: e.g. where is
   ncgen.exe located. See nc_test/test_common.sh
   for details.
4. Modify .sh files to use test_common.sh
5. Obsolete separate oc2 by moving it to be part of
   netcdf-c. This means replacing code with netcdf-c
   equivalents.
5. Add --with-testserver to configure.ac to allow
   override of the servers to be used for --enable-dap-remote-tests.
6. There were multiple versions of nctypealignment code. Try to
   centralize in libdispatch/doffset.c and include/ncoffsets.h
7. Add a unit test for the ncuri code because of its complexity.
8. Move the findserver code out of libdispatch and into
   a separate, self contained program in ncdap_test and dap4_test.
9. Move the dispatch header files (nc{3,4}dispatch.h) to
   .../include because they are now shared by modules.
10. Revamp the handling of TOPSRCDIR and TOPBUILDDIR for shell scripts.
11. Make use of MREMAP if available
12. Misc. minor changes e.g.
	- #include <config.h> -> #include "config.h"
	- Add some no-install headers to /include
	- extern -> EXTERNL and vice versa as needed
	- misc header cleanup
	- clean up checking for misc. unix vs microsoft functions
13. Change copyright decls in some files to point to LICENSE file.
14. Add notes to RELEASENOTES.md
2017-03-08 17:01:10 -07:00
Ward Fisher
b248523a49 Corrected a potential null pointer dereference. 2016-04-12 11:18:34 -06:00
tbeu
e2820e4d8a Fix common typos
Detected by https://github.com/vlajos/misspell_fixer
2015-08-20 11:42:05 +02:00
Martin Steghöfer
a9012c7bfe Fix segmentation fault when parsing malformed URLs (e.g. "http:/"). 2014-10-05 19:28:03 +02:00
Ward Fisher
88d01e4c08 Coverity: 715198. Removed redundant goto fail() stanzas. 2014-08-26 10:36:06 -06:00
dmh
18eb1c1126 Coverity fixing 2014-08-17 12:03:23 -06:00
Ward Fisher
6c071be031 Corrected issues where functions were not available in Windows. Specifically strndup. Also accomodated an included needed for getcwd. 2014-08-07 17:03:27 -06:00
Ward Fisher
b92c26943d Coverity: 1229473 2014-08-01 10:47:20 -06:00
Ward Fisher
ab7883897b Coverity: 1198195 2014-07-31 16:39:12 -06:00
dmh
fb00c88763 fix bugs introduced by previous coverity fixes 2014-04-07 14:01:40 -06:00
dmh
389d2ea394 fix some coverity complaints 2014-04-07 13:00:47 -06:00
dmh
19d377e87a conflict resolution 2014-03-10 12:13:16 -06:00
dmh
9d5c8ba308 1. Previous ci of conversion fixes in libdispatch
was incomplete; complete the fix.
2. There is an inconsistency in the netcdfh interface
   about whether rank (# dimensions) is an int or
   size_t. I inadvertently assumed the latter and that
   breaks some API calls; so revert back.
2014-03-10 12:09:36 -06:00
Ward Fisher
513cb29ea4 The replacement of 'int' with 'size_t' caused a number of errors across multiple platforms in our CI system. The culprit is not obvious, so I am reverting the commit until we can take a closer look at the underlying issue.
Revert "1. Attempted to reduce the number of conversion errors"

This reverts commit 1b941d342d.
2014-03-10 10:04:37 -06:00
dmh
1b941d342d 1. Attempted to reduce the number of conversion errors
when -Wconversion is set. Fixed libdispatch, but
   rest of netcdf remains to be done.
2014-03-09 15:51:45 -06:00
Ward Fisher
f43bf8f1da Addressed a handful of issues identified by
Coverity static analysis.
2013-08-05 20:36:33 +00:00
Dennis Heimbigner
228e8439d2 1. The code to parse a constraint
was losing the initial double quote
for a quoted string.
2. The code in ncuri.c was not properly
   handling occurrences of e.g. %xx
2013-05-16 21:37:58 +00:00
Dennis Heimbigner
253a26cb82 change format of url parameters in fragment part 2013-05-13 19:12:37 +00:00
Ward Fisher
7b91248723 Merged changes from netcdf-branch.
o Changed variable names 'typeid' to 'typeid1' to avoid a namespace conflict
in visual studio.
o Cleaned up a handful of warnings in Visual Studio.
o Addressed a few Coverity-discovered issuesl
o Made changes to CMake-based builds.
2012-12-13 22:09:41 +00:00
Ward Fisher
7a226dd3f1 Merging the win_netcdf branch into the trunk. 2012-09-27 22:50:41 +00:00
Ward Fisher
2fdea864a2 Changes to includes to supress a few specific MSVC warnings. 2012-09-04 22:39:10 +00:00
Dennis Heimbigner
5380aa5b67 update utilities: list,byte,hash,uri,log 2012-08-19 21:54:30 +00:00
Dennis Heimbigner
499f8d3a1c complete update of utilities: ncbyte, nclist, ncuri, nclog 2012-08-08 23:15:18 +00:00