From d0bbed1af9ac0e6fd713181d1bf739524a05735a Mon Sep 17 00:00:00 2001 From: Attila Kovacs Date: Thu, 29 Aug 2024 18:46:44 +0200 Subject: [PATCH] Header version, link against math libs, doxygen edits --- Makefile | 3 +++ include/xchange.h | 38 +++++++++++++++++++++++++++++++++++--- src/xchange.c | 2 +- src/xjson.c | 4 +++- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 73c7ae1..b9a86a2 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ include config.mk # The version of the shared .so libraries SO_VERSION := 1 +# Link against math libs (for e.g. isnan()) +LDFLAGS += -lm + # Check if there is a doxygen we can run ifndef DOXYGEN DOXYGEN := $(shell which doxygen) diff --git a/include/xchange.h b/include/xchange.h index 1b82890..e164f8a 100644 --- a/include/xchange.h +++ b/include/xchange.h @@ -6,12 +6,46 @@ * * A Basic set of utilities to allow platform-independent structured data exchange from C/C++. * It also includes a JSON parser and emitter implementation. + * + * @version 0.9.0 */ #ifndef XCHANGE_H_ #define XCHANGE_H_ -#include + +/// API major version +#define XCHANGE_MAJOR_VERSION 0 + +/// API minor version +#define XCHANGE_MINOR_VERSION 9 + +/// Integer sub version of the release +#define XCHANGE_PATCHLEVEL 0 + +/// Additional release information in version, e.g. "-1", or "-rc1". +#define XCHANGE_RELEASE_STRING "-devel" + + +#ifdef str_2 +# undef str_2 +#endif + +/// Stringify level 2 macro +#define str_2(s) str_1(s) + +#ifdef str_1 +# undef str_1 +#endif + +/// Stringify level 1 macro +#define str_1(s) #s + + +/// The version string for this library +#define XCHANGE_VERSION_STRING str_2(XCHANGE_MAJOR_VERSION) "." str_2(XCHANGE_MINOR_VERSION) \ + "." str_2(XCHANGE_PATCHLEVEL) XCHANGE_RELEASE_STRING + #ifndef TRUE #define TRUE 1 ///< Boolean 'true' value, if not already defined. @@ -135,8 +169,6 @@ extern boolean xDebug; ///< Switch to enable debugging (very verbose) o #define xdprintf if(xDebug) printf ///< Use for generating debug output // In xutil.c ------------------------------------------------> -boolean xIsVerbose(); -void xSetVerbose(boolean value); int xError(const char *func, int errorCode); // TODO... const char *xErrorDescription(int code); diff --git a/src/xchange.c b/src/xchange.c index 065d68e..e1da96b 100644 --- a/src/xchange.c +++ b/src/xchange.c @@ -5,7 +5,7 @@ * @author Attila Kovacs * * \brief - * A collection of commonly used functions for data exchange for scalars and arrays, and + * A collection of commonly used functions for standard data exchange for scalars and arrays, and * ASCII representations. * */ diff --git a/src/xjson.c b/src/xjson.c index f43bd05..3556958 100644 --- a/src/xjson.c +++ b/src/xjson.c @@ -63,7 +63,7 @@ static int PrintArray(const char *prefix, char *ptr, XType type, int ndim, const static int PrintPrimitive(const void *ptr, XType type, char *str); static int PrintString(const char *src, int maxLength, char *json); -static FILE *xerr; ///< File which errors are printed to. +static FILE *xerr = stderr; ///< File / stream, which errors are printed to. static char *indent = XJSON_INDENT; static int ilen = sizeof(XJSON_INDENT) - 1; @@ -210,6 +210,8 @@ XStructure *xjsonParseFilename(const char *fileName, int *lineNumber) { return NULL; } + if(xIsVerbose()) fprintf(stderr, "XJSON: Parsing %s.\n", fileName); + fp = fopen(fileName, "r"); if(!fp) { Error("Cannot open file (%s).\n", strerror(errno));