Better support for Rhizome logging status enums

Provide functions that return non-NULL even on invalid enum
values
This commit is contained in:
Andrew Bettison 2015-03-30 18:15:41 +10:30
parent dbe0cf862f
commit 86c3c7312c
2 changed files with 14 additions and 0 deletions

View File

@ -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";
}

View File

@ -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);