diff options
author | Vincent Sanders <vince@kyllikki.org> | 2014-10-25 12:39:21 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2014-10-25 12:45:32 +0100 |
commit | 94ab63319f5ce6eb8fb081d8f38f9fe53808970e (patch) | |
tree | 1543f9bf4117cb58af3a7ce87516dfcd34cb79aa /utils/messages.h | |
parent | 808783c2ebb692ba84d21b9b5f8670b1ae61f03e (diff) | |
download | netsurf-94ab63319f5ce6eb8fb081d8f38f9fe53808970e.tar.gz netsurf-94ab63319f5ce6eb8fb081d8f38f9fe53808970e.tar.bz2 |
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.
Diffstat (limited to 'utils/messages.h')
-rw-r--r-- | utils/messages.h | 20 |
1 files changed, 17 insertions, 3 deletions
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); /** |