netcdf-c/docs
Dennis Heimbigner efdec07f3d Extend the netcdf API to support programmatic changes to the plugin search path
Replaces PR https://github.com/Unidata/netcdf-c/pull/3024
         and PR https://github.com/Unidata/netcdf-c/pull/3033

re: https://github.com/Unidata/netcdf-c/issues/2753

As suggested by Ed Hartnett, This PR extends the netcdf.h API to support programmatic control over the search path used to locate plugins.

I created several different APIs, but finally settled on the following API as being the simplest possible. It does have the disadvantage that it requires use of a global lock (not implemented) if used in a threaded environment.

Specifically, note that modifying the plugin path must be done "atomically". That is, in a multi-threaded environment, it is important that the sequence of actions involved in setting up the plugin path must be done by a single processor or in some other way as to guarantee that two or more processors are not simultaneously accessing the plugin path get/set operations.

As an example, assume there exists a mutex lock called PLUGINLOCK. Then any processor accessing the plugin paths should operate as follows:
````
lock(PLUGINLOCK);
nc_plugin_path_get(...);
<rebuild plugin path>
nc_plugin_path_set(...);
unlock(PLUGINLOCK);
````
## Internal Architecture

It is assumed here that there only needs to be a single set of plugin path directories that is shared by all filter code and is independent of any file descriptor; it is global in other words. This means, for example, that the path list for NCZarr and for HDF5 will always be the same.

However internally, processing the set of plugin paths depends on the particular NC_FORMATX value (NC_FORMATX_NC_HDF5 and NC_FORMATX_NCZARR, currently). So the *nc_plugin_path_set* function, will take the paths it is given and propagate them to each of the NC_FORMATX dispatchers to store in a way that is appropriate to the given dispatcher.

There is a complication with respect to the *nc_plugin_path_get* function. It is possible for users to bypass the netcdf API and modify the HDF5 plugin paths directly. This can result in an inconsistent plugin path between the value used by HDF5 and the global value used by netcdf-c. Since there is no obvious fix for this, we warn the user of this possibility and otherwise ignore it.

## Test Changes
* New tests<br>
    a. unit_test/run_pluginpaths.sh -- was created to test this new capability.<br>
    b. A new test utility has been added as *unit_test/run_dfaltpluginpath.sh* to test the default plugin path list.
* New test support utilities<br>
    a. unit_test/ncpluginpath.c -- report current state of the plugin path<br>
    b. unit_test/tst_pluginpaths.c -- test program to support run_pluginpaths.sh

## Documentation
* A new file -- docs/pluginpath.md -- provides documentation of the new API. It includes some
  material taken fro filters.md.

## Other Major Changes
1. Cleanup the whole plugin path decision tree. This is described in the *docs/pluginpath.md* document and summarized in Addendum 2 below.
2. I noticed that the ncdump/testpathcvt.sh had been disabled, so fixed and re-enabled it. This necessitated some significant changes to dpathmgr.c.

## Misc. Changes
1. Add some path manipulation utilities to netcf_aux.h
2. Fix some minor bugs in netcdf_json.h
3. Convert netcdf_json.h and netcdf_proplist.h to BUILT_SOURCE.
4. Add NETCDF_ENABLE_HDF5 as synonym for USE_HDF5
5. Fix some size_t <-> int conversion warnings.
6. Encountered and fixed the Windows \r\n problem in tst_pluginpaths.c.
7. Cleanup some minor CMakeLists.txt problems.
8. Provide an implementation of echo -n since it appears to not be
   available on all platforms.
9. Add a property list mechanism to pass environmental information to filters.
10. Cleanup Doxyfile.in
11. Fixed a memory leak in libdap2; surprised that I did not find this earlier.

## Addendum 1: Proposed API

The API makes use of a counted vector of strings representing the sequence of directories in the path. The relevant type definition is as follows.
````
typedef struct NCPluginList {size_t ndirs; char** dirs;} NCPluginList;
````

The API proposed in this PR looks like this (from netcdf-c/include/netcdf_filter.h).

* ````int nc_plugin_path_ndirs(size_t* ndirsp);````
    Arguments: *ndirsp* -- store the number of directories in this memory.

    This function returns the number of directories in the sequence if internal directories of the internal plugin path list.

* ````int nc_plugin_path_get(NCPluginList* dirs);````
    Arguments:  *dirs* -- counted vector for storing the sequence of directies in the internal path list.

    This function returns the current sequence of directories from the internal plugin path list. Since this function does not modify the plugin path, it does not need to be locked; it is only when used to get the path to be modified that locking is required.  If the value of *dirs.dirs* is NULL (the normal case), then memory is allocated to hold the vector of directories. Otherwise, use the memory of *dirs.dirs* to hold the vector of directories.

* ````int nc_plugin_path_set(const NCPluginList* dirs);````
    Arguments: *dirs* -- counted vector for providing the new sequence of directories in the internal path list.

    This function empties the current internal path sequence and replaces it with the sequence of directories argument. Using an *ndirs* argument of 0 will clear the set of plugin paths.

## Addendum 2: Build-Time and Run-Time Constants.

### Build-Time Constants
<table style="border:2px solid black;border-collapse:collapse">
<tr style="outline: thin solid;" align="center"><td colspan="4">Table showing the build-time computation of NETCDF_PLUGIN_INSTALL_DIR and NETCDF_PLUGIN_SEARCH_PATH.</td>
<tr style="outline: thin solid" ><th>--with-plugin-dir<th>--prefix<th>NETCDF_PLUGIN_INSTALL_DIR<th>NETCDF_PLUGIN_SEARCH_PATH
<tr style="outline: thin solid" ><td>undefined<td>undefined<td>undefined<td>PLATFORMDEFALT
<tr style="outline: thin solid" ><td>undefined<td>&lt;abspath-prefix&gt;<td>&lt;abspath-prefix&gt;/hdf5/lib/plugin<td>&lt;abspath-prefix&gt;/hdf5/lib/plugin&lt;SEP&gt;PLATFORMDEFALT
<tr style="outline: thin solid" ><td>&lt;abspath-plugins&gt;<td>N.A.<td>&lt;abspath-plugins&gt;<td>&lt;abspath-plugins&gt;&lt;SEP&gt;PLATFORMDEFALT
</table>

<table style="border:2px solid black;border-collapse:collapse">
<tr style="outline: thin solid" align="center"><td colspan="2">Table showing the computation of the initial global plugin path</td>
<tr style="outline: thin solid"><th>HDF5_PLUGIN_PATH<th>Initial global plugin path
<tr style="outline: thin solid"><td>undefined<td>NETCDF_PLUGIN_SEARCH_PATH
<tr style="outline: thin solid"><td>&lt;path1;...pathn&gt;<td>&lt;path1;...pathn&gt;
</table>
2024-10-18 19:23:59 -06:00
..
doxygen-awesome-css Trying out a new style sheet for modern doxygen, see https://jothepro.github.io/doxygen-awesome-css/ for more information. Starting by updating the developer documentation system, invoked from the top-level netcdf-c directory via 'doxygen docs/Doxyfile.developer' 2024-02-01 13:58:27 -08:00
images Correct error in make dist 2022-06-10 14:08:57 -06:00
obsolete Docs migration 2021-11-11 10:47:49 -07:00
old docs cleanup 2021-11-11 11:40:45 -07:00
static-pages Re-added NCSTAT to the list of software using netCDF. 2024-07-17 16:34:43 -06:00
.gitignore Restore header and footer files. 2024-07-26 15:55:12 -05:00
all-error-codes.md Working towards writing the quick start for plugins and integrating it into doxygen. 2022-10-05 13:31:49 -06:00
architecture.dox Use PnetCDF instead of parallel-netcdf to avoid confusion with 2018-09-17 17:18:48 -05:00
attribute_conventions.md ftp --> resources 2024-05-13 16:50:50 -06:00
auth.md Merge branch 'main' into rcdoc.dmh 2024-08-05 10:46:55 -06:00
building-with-autotools.md adding info about plugins 2024-08-13 08:09:36 -06:00
building-with-cmake.md adding info about plugins 2024-08-13 08:09:36 -06:00
byterange.md Replace ENABLE_BYTERANGE with NETCDF_ENABLE_BYTERANGE 2024-03-18 15:50:57 -05:00
cloud.md Replace ENABLE_S3 with NETCDF_ENABLE_S3 2024-03-18 15:54:15 -05:00
CMakeLists.txt Merge branch 'main' into rcdoc.dmh 2024-08-05 10:46:55 -06:00
COPYRIGHT.md Updating files to refer to the top-level COPYRIGHT file. 2018-12-04 15:52:43 -07:00
credits.md Added individual authors, also updated docs/credits.md with nczarr attribution. 2024-01-31 15:27:18 -08:00
developer_header.html Trying out a new style sheet for modern doxygen, see https://jothepro.github.io/doxygen-awesome-css/ for more information. Starting by updating the developer documentation system, invoked from the top-level netcdf-c directory via 'doxygen docs/Doxyfile.developer' 2024-02-01 13:58:27 -08:00
dispatch.md Clean up doxygen warnings that were being treated as failures. 2023-12-21 09:39:44 -07:00
docmap.pdf The 'Credits' page is now a generated document distributed with netcdf, even though the contents are static. It is currently included as a subpage underneath the NetCDF Overview page. Also, renamed 'Credits' on the Overview page to 'About NetCDF'. 2014-12-10 11:14:43 -07:00
Doxyfile.developer Bumped to next version. 2024-06-18 14:15:47 -06:00
Doxyfile.in ckp 2024-09-30 14:39:48 -06:00
Doxyfile.user Update issue with make distcheck 2023-04-12 14:14:38 -06:00
DoxygenLayout.xml Further reorganization. Figured out how subpage works with different files. Renamed some of the header cells. 2014-12-09 16:36:15 -07:00
esg.md More doxygen tweaks. 2016-01-15 12:23:56 -07:00
FAQ.md fixed some broken links 2024-08-17 06:33:59 -06:00
file_format_specifications.md This PR adds EXPERIMENTAL support for accessing data in the 2020-06-28 18:02:47 -06:00
filters.md ckp 2024-09-30 14:39:48 -06:00
footer.html ckp 2024-09-30 14:39:48 -06:00
groups.dox Renamed man4 directory to docs. 2014-05-21 14:40:39 -06:00
header.html ckp 2024-09-30 14:39:48 -06:00
indexing.dox ckp 2024-09-30 14:39:48 -06:00
inmeminternal.dox Spelling fixes 2019-09-18 08:03:01 -06:00
inmemory.md Spelling fixes 2019-09-18 08:03:01 -06:00
install-fortran.md fixed some broken links 2024-08-17 06:33:59 -06:00
internal.md Replace ENABLE_S3 with NETCDF_ENABLE_S3 2024-03-18 15:54:15 -05:00
known_problems.md removal of ftp and netcdf contrib site 2024-05-01 12:22:03 -06:00
logging.md Replace ENABLE_LOGGING with NETCDF_ENABLE_LOGGING 2024-03-18 15:52:11 -05:00
mainpage.dox Remove stale section from documentation. 2024-02-06 10:46:22 -07:00
Makefile.am ckp 2024-09-30 14:39:48 -06:00
nczarr.md Added missing quote 2024-07-25 15:38:02 -06:00
netcdf-50x50.png Renamed man4 directory to docs. 2014-05-21 14:40:39 -06:00
netcdf.m4 Docs migration 2021-11-11 10:47:49 -07:00
notes.md fixed some doxygen warnings 2022-05-28 18:54:08 +03:00
pluginpath.md Extend the netcdf API to support programmatic changes to the plugin search path 2024-10-18 19:23:59 -06:00
quantize.md moved quantize error documentation 2022-06-23 09:51:09 +02:00
quickstart_env.md ckp 2024-09-30 14:39:48 -06:00
quickstart_filters.md re-added quickstart filters document. 2023-02-01 11:20:40 -07:00
quickstart_paths.md ckp 2024-09-30 14:39:48 -06:00
release_header.html Update release_header.html 2022-01-19 11:50:59 -07:00
release.css Tweaks to css 2016-01-21 11:19:23 -07:00
tests.md Added a document to catalog what the various tests are. 2016-06-06 14:51:57 -06:00
testserver.dox chore: unset executable flag 2023-08-23 13:31:42 +09:00
tutorial.dox Clean up doxygen syntax in release notes, fix incorrect version in CMakeLists.txt, and resolve duplicated doxygen tags in tutorial.dox 2024-08-23 11:13:01 -06:00
unidata_logo_cmyk.png Renamed man4 directory to docs. 2014-05-21 14:40:39 -06:00
windows-binaries.md Incorporated GitHub-generated release notes into the manually managed release notes, and updated the list of included dependencies for Windows installer downloads. 2022-06-10 14:43:50 -06:00