From 94ab63319f5ce6eb8fb081d8f38f9fe53808970e Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 25 Oct 2014 12:39:21 +0100 Subject: Improve the message loading API to return error codes. Returning an error instead of simply calling die allows more robust error handling. Secondly initialisation may continue even if the messages have not been loaded which is more friendly than simply dropping dead with no communication to the user. --- utils/messages.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'utils/messages.h') diff --git a/utils/messages.h b/utils/messages.h index 81c380515..795c10009 100644 --- a/utils/messages.h +++ b/utils/messages.h @@ -36,9 +36,23 @@ #include "utils/errors.h" #include "utils/hashtable.h" -void messages_load(const char *path); -struct hash_table *messages_load_ctx(const char *path, struct hash_table *ctx); -const char *messages_get_ctx(const char *key, struct hash_table *ctx); +/** + * Read keys and values from messages file into the standard Messages hash. + * + * The messages are merged with any previously loaded messages. Any keys which + * are present already are replaced with the new value. + * + * \param path pathname of messages file. + * \return NSERROR_OK on success or error code on faliure. + */ +nserror messages_load(const char *path); + +/** + * Fast lookup of a message by key from the standard Messages hash. + * + * \param key key of message + * \return value of message, or key if not found + */ const char *messages_get(const char *key); /** -- cgit v1.2.3