From 86c3c7312c2e8de67b0a3294bad65ca33b39a999 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Mon, 30 Mar 2015 18:15:41 +1030 Subject: [PATCH] Better support for Rhizome logging status enums Provide functions that return non-NULL even on invalid enum values --- rhizome.c | 12 ++++++++++++ rhizome.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/rhizome.c b/rhizome.c index 6e48224e..1238c806 100644 --- a/rhizome.c +++ b/rhizome.c @@ -616,6 +616,12 @@ const char *rhizome_bundle_status_message(enum rhizome_bundle_status status) return NULL; } +const char *rhizome_bundle_status_message_nonnull(enum rhizome_bundle_status status) +{ + const char *message = rhizome_bundle_status_message(status); + return message ? message : "Invalid"; +} + const char *rhizome_payload_status_message(enum rhizome_payload_status status) { switch (status) { @@ -631,3 +637,9 @@ const char *rhizome_payload_status_message(enum rhizome_payload_status status) } return NULL; } + +const char *rhizome_payload_status_message_nonnull(enum rhizome_payload_status status) +{ + const char *message = rhizome_payload_status_message(status); + return message ? message : "Invalid"; +} diff --git a/rhizome.h b/rhizome.h index 00a8b799..37c2053e 100644 --- a/rhizome.h +++ b/rhizome.h @@ -416,6 +416,7 @@ enum rhizome_bundle_status { #define INVALID_RHIZOME_BUNDLE_STATUS ((enum rhizome_bundle_status)-2) const char *rhizome_bundle_status_message(enum rhizome_bundle_status); +const char *rhizome_bundle_status_message_nonnull(enum rhizome_bundle_status); enum rhizome_payload_status { RHIZOME_PAYLOAD_STATUS_ERROR = -1, @@ -432,6 +433,7 @@ enum rhizome_payload_status { #define INVALID_RHIZOME_PAYLOAD_STATUS ((enum rhizome_payload_status)-2) const char *rhizome_payload_status_message(enum rhizome_payload_status); +const char *rhizome_payload_status_message_nonnull(enum rhizome_payload_status); int rhizome_write_manifest_file(rhizome_manifest *m, const char *filename, char append); int rhizome_manifest_selfsign(rhizome_manifest *m);