summaryrefslogtreecommitdiffstats
path: root/src/cc4group.h
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2019-08-19 13:42:48 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2019-08-19 18:56:58 +0200
commit177c2d8c1ed33391711524948fef5313c8624c75 (patch)
tree6bf8d0e17b2f6c2d69d77b611213139adbc74b9d /src/cc4group.h
parent228bce0f6612044a18569919798d7e89e18a29c8 (diff)
downloadcc4group-177c2d8c1ed33391711524948fef5313c8624c75.tar.gz
cc4group-177c2d8c1ed33391711524948fef5313c8624c75.zip
Allow the warning handling callback to be set to a custom callback
Diffstat (limited to 'src/cc4group.h')
-rw-r--r--src/cc4group.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/cc4group.h b/src/cc4group.h
index d2d978c..d81e84a 100644
--- a/src/cc4group.h
+++ b/src/cc4group.h
@@ -29,7 +29,7 @@
// the directory separator used for all entry paths in cc4group is "/" _regardless of the platform_. yes, you better watch out Windows users!
// in contrast to paths names are only the the name of the entry itself, not the whole path
// - to free all resources used by the group when it is not needed anymore, call cc4group.delete with the group pointer and discard it afterwards (i.e. don't use it anymore)
-// - all functions, except cc4group.new, cc4group.setLazy, cc4group.openAsChild, cc4group.delete and cc4group.setTmpMemoryStrategy (where the latter two can't fail) follow the same scheme
+// - all functions, except cc4group.new, cc4group.setLazy, cc4group.openAsChild, cc4group.delete, cc4group.setWarningCallback and cc4group.setTmpMemoryStrategy (where the latter three can't fail) follow the same scheme
// all of them can fail, either caused by wrong arguments or by things outside of the applications control
// they all return _true_ if everything went well and _false_ if any error occured
// information about the error (incredibly useful for debugging or asking for help with problems) can be obtained by using one the cc4group.getError* functions
@@ -173,6 +173,13 @@ typedef bool (*CC4Group_ReadSetupCallback)(void* const arg);
typedef bool (*CC4Group_WriteCallback)(const void* const data, size_t const size, void* const arg);
+
+// callback type for receiving warnings
+// whenever a warning is triggered, the callback will be called with the triggering group
+// and a format string and format arguments that are destined for some *printf function
+typedef void (*CC4Group_WarningCallback)(const CC4Group* const group, const char* const format, ...);
+
+
// this is the main API struct of cc4group
// it contains all available methods and constants
typedef struct {
@@ -212,6 +219,12 @@ typedef struct {
// for details, look at the description of CC4Group_TmpMemoryStrategy
void (*setTmpMemoryStrategy)(const CC4Group_TmpMemoryStrategy strategy);
+ // sets the global warning callback
+ // the default callback prints warnings to stderr; it can be restored by calling setWarningCallback with callback as NULL
+ // NOTE: this is a static method (i.e. it is used without any object)
+ // this will affect all groups in any state
+ void (*setWarningCallback)(const CC4Group_WarningCallback callback);
+
// allocates and initializes a new group object, like the operator new
// NULL may be returned if the memory allocation (malloc) fails; in this case errno contains additional error information