Add runtime version checking functions

This patch adds two new exported functions:

* `jansson_version_str` - Returns a human-readable version number
* `jansson_version_cmp` - Returns an integer less than, equal to, or greater
  than zero if the runtime version of Jansson is found, respectively, to be
  less than, to match, or be greater than the provided major, minor, and micro.
This commit is contained in:
Sean Bright
2019-03-08 12:57:59 -05:00
parent f4498d2856
commit 76300601d9
8 changed files with 122 additions and 2 deletions

View File

@@ -58,6 +58,25 @@ the library:
/* Code specific to version 1.3 and above */
#endif
Additionally, there are functions to determine the version of Jansson at
runtime:
.. function:: const char *jansson_version_str()
Return the version of the Jansson library, in the same format as
the ``JANSSON_VERSION`` preprocessor constant.
.. versionadded:: 2.13
.. function:: int jansson_version_cmp(int major, int minor, int micro)
Returns an integer less than, equal to, or greater than zero if
the runtime version of Jansson is found, respectively, to be less
than, to match, or be greater than the provided *major*, *minor*, and
*micro*.
.. versionadded:: 2.13
``JANSSON_THREAD_SAFE_REFCOUNT``
If this value is defined all read-only operations and reference counting in
Jansson are thread safe. This value is not defined for versions older than