2003-08-16 22:39:10 +04:00
|
|
|
/*
|
2004-05-08 22:13:27 +04:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2006-08-22 02:07:10 +04:00
|
|
|
* Copyright 2006 Rob Kendrick <rjek@rjek.com>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-05-08 22:13:27 +04:00
|
|
|
*/
|
|
|
|
|
2014-10-25 15:39:21 +04:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Localised message support implementation.
|
2004-05-08 22:13:27 +04:00
|
|
|
*
|
|
|
|
* Native language messages are loaded from a file and stored hashed by key for
|
|
|
|
* fast access.
|
2003-08-16 22:39:10 +04:00
|
|
|
*/
|
|
|
|
|
2016-04-22 00:36:21 +03:00
|
|
|
#include <stdlib.h>
|
2003-08-16 22:39:10 +04:00
|
|
|
#include <assert.h>
|
2004-05-08 22:13:27 +04:00
|
|
|
#include <errno.h>
|
2003-08-16 22:39:10 +04:00
|
|
|
#include <stdio.h>
|
2006-08-22 02:07:10 +04:00
|
|
|
#include <stdbool.h>
|
2003-08-16 22:39:10 +04:00
|
|
|
#include <string.h>
|
2008-07-26 19:18:21 +04:00
|
|
|
#include <zlib.h>
|
2010-10-05 23:14:46 +04:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "utils/hashtable.h"
|
2003-08-16 22:39:10 +04:00
|
|
|
|
2014-10-25 15:39:21 +04:00
|
|
|
/** Messages are stored in a fixed-size hash table. */
|
2006-08-20 03:37:58 +04:00
|
|
|
#define HASH_SIZE 101
|
2003-08-16 22:39:10 +04:00
|
|
|
|
2006-08-22 02:07:10 +04:00
|
|
|
/** The hash table used to store the standard Messages file for the old API */
|
|
|
|
static struct hash_table *messages_hash = NULL;
|
2003-08-16 22:39:10 +04:00
|
|
|
|
2015-06-22 01:24:31 +03:00
|
|
|
|
2003-08-16 22:39:10 +04:00
|
|
|
/**
|
2004-05-08 22:13:27 +04:00
|
|
|
* Read keys and values from messages file.
|
|
|
|
*
|
|
|
|
* \param path pathname of messages file
|
2018-04-22 14:03:49 +03:00
|
|
|
* \param ctx reference of hash table to merge with or NULL to create one.
|
2014-10-25 15:39:21 +04:00
|
|
|
* \return NSERROR_OK on sucess and ctx updated or error code on faliure.
|
2003-08-16 22:39:10 +04:00
|
|
|
*/
|
2014-10-25 15:39:21 +04:00
|
|
|
static nserror messages_load_ctx(const char *path, struct hash_table **ctx)
|
2003-08-16 22:39:10 +04:00
|
|
|
{
|
2014-10-25 15:39:21 +04:00
|
|
|
struct hash_table *nctx; /* new context */
|
2018-04-22 14:03:49 +03:00
|
|
|
nserror res;
|
2018-05-18 11:56:16 +03:00
|
|
|
|
|
|
|
if (*ctx != NULL) {
|
2014-10-25 15:39:21 +04:00
|
|
|
/**
|
|
|
|
* \note The passed hash is not copied here so this
|
|
|
|
* updates in place.
|
|
|
|
*/
|
2018-05-18 11:56:16 +03:00
|
|
|
return hash_add_file(*ctx, path);
|
2014-10-25 15:39:21 +04:00
|
|
|
}
|
2018-05-18 11:56:16 +03:00
|
|
|
|
|
|
|
nctx = hash_create(HASH_SIZE);
|
2014-10-25 15:39:21 +04:00
|
|
|
if (nctx == NULL) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"Unable to create hash table for messages file %s",
|
|
|
|
path);
|
2014-10-25 15:39:21 +04:00
|
|
|
return NSERROR_NOMEM;
|
2003-08-16 22:39:10 +04:00
|
|
|
}
|
|
|
|
|
2018-04-22 14:03:49 +03:00
|
|
|
res = hash_add_file(nctx, path);
|
|
|
|
if (res == NSERROR_OK) {
|
|
|
|
*ctx = nctx;
|
2018-05-18 11:56:16 +03:00
|
|
|
} else {
|
|
|
|
hash_destroy(nctx);
|
2018-04-22 14:03:49 +03:00
|
|
|
}
|
2003-08-16 22:39:10 +04:00
|
|
|
|
2018-04-22 14:03:49 +03:00
|
|
|
return res;
|
2003-08-16 22:39:10 +04:00
|
|
|
}
|
|
|
|
|
2014-10-25 15:39:21 +04:00
|
|
|
|
2003-08-16 22:39:10 +04:00
|
|
|
/**
|
2006-08-22 02:07:10 +04:00
|
|
|
* Fast lookup of a message by key.
|
|
|
|
*
|
|
|
|
* \param key key of message
|
|
|
|
* \param ctx context of messages file to look up in
|
|
|
|
* \return value of message, or key if not found
|
2003-08-16 22:39:10 +04:00
|
|
|
*/
|
2014-10-25 15:39:21 +04:00
|
|
|
static const char *
|
|
|
|
messages_get_ctx(const char *key, struct hash_table *ctx)
|
2003-08-16 22:39:10 +04:00
|
|
|
{
|
2014-10-25 15:39:21 +04:00
|
|
|
const char *r = NULL;
|
2006-10-12 18:00:40 +04:00
|
|
|
|
|
|
|
assert(key != NULL);
|
|
|
|
|
2014-10-25 15:39:21 +04:00
|
|
|
/* allow attempts to retrieve messages before context is set up. */
|
|
|
|
if (ctx != NULL) {
|
|
|
|
r = hash_get(ctx, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If called with no context or unable to retrive a value
|
|
|
|
* return the key.
|
|
|
|
*/
|
|
|
|
if (r == NULL) {
|
|
|
|
r = key;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2016-12-11 19:43:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free memory used by a messages hash.
|
|
|
|
* The context will not be valid after this function returns.
|
|
|
|
*
|
|
|
|
* \param ctx context of messages file to free
|
|
|
|
*/
|
|
|
|
static void messages_destroy_ctx(struct hash_table *ctx)
|
|
|
|
{
|
|
|
|
if (ctx == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hash_destroy(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-25 15:39:21 +04:00
|
|
|
/* exported interface documented in messages.h */
|
2015-06-19 18:29:42 +03:00
|
|
|
nserror messages_add_from_file(const char *path)
|
2014-10-25 15:39:21 +04:00
|
|
|
{
|
|
|
|
if (path == NULL) {
|
2015-06-22 01:24:31 +03:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
2014-10-25 15:39:21 +04:00
|
|
|
}
|
2006-10-12 18:00:40 +04:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Loading Messages from '%s'", path);
|
2015-06-22 01:24:31 +03:00
|
|
|
|
2018-04-22 14:03:49 +03:00
|
|
|
return messages_load_ctx(path, &messages_hash);
|
2003-08-16 22:39:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-22 01:24:31 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
/* exported interface documented in messages.h */
|
2018-04-22 14:03:49 +03:00
|
|
|
nserror messages_add_from_inline(const uint8_t *data, size_t size)
|
2015-06-19 18:29:42 +03:00
|
|
|
{
|
2015-06-22 01:24:31 +03:00
|
|
|
/* ensure the hash table is initialised */
|
|
|
|
if (messages_hash == NULL) {
|
|
|
|
messages_hash = hash_create(HASH_SIZE);
|
|
|
|
}
|
|
|
|
if (messages_hash == NULL) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Unable to create hash table");
|
2015-06-22 01:24:31 +03:00
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
2018-04-22 14:03:49 +03:00
|
|
|
return hash_add_inline(messages_hash, data, size);
|
2015-06-19 18:29:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* exported interface documented in messages.h */
|
2010-10-05 23:14:46 +04:00
|
|
|
char *messages_get_buff(const char *key, ...)
|
|
|
|
{
|
|
|
|
const char *msg_fmt;
|
|
|
|
char *buff = NULL; /* formatted buffer to return */
|
|
|
|
int buff_len = 0;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
msg_fmt = messages_get_ctx(key, messages_hash);
|
|
|
|
|
|
|
|
va_start(ap, key);
|
|
|
|
buff_len = vsnprintf(buff, buff_len, msg_fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
buff = malloc(buff_len + 1);
|
|
|
|
|
2016-04-29 11:41:10 +03:00
|
|
|
if (buff != NULL) {
|
2010-10-05 23:14:46 +04:00
|
|
|
va_start(ap, key);
|
|
|
|
vsnprintf(buff, buff_len + 1, msg_fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-25 15:39:21 +04:00
|
|
|
/* exported function documented in utils/messages.h */
|
2006-08-22 02:07:10 +04:00
|
|
|
const char *messages_get(const char *key)
|
2003-08-16 22:39:10 +04:00
|
|
|
{
|
2006-08-22 02:07:10 +04:00
|
|
|
return messages_get_ctx(key, messages_hash);
|
2003-08-16 22:39:10 +04:00
|
|
|
}
|
2012-11-26 21:20:15 +04:00
|
|
|
|
|
|
|
|
2014-10-25 15:39:21 +04:00
|
|
|
/* exported function documented in utils/messages.h */
|
2012-11-26 21:20:15 +04:00
|
|
|
const char *messages_get_errorcode(nserror code)
|
|
|
|
{
|
|
|
|
switch (code) {
|
|
|
|
case NSERROR_OK:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* No error */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("OK", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_NOMEM:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Memory exhaustion */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("NoMemory", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_NO_FETCH_HANDLER:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* No fetch handler for URL scheme */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("NoHandler", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_NOT_FOUND:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Requested item not found */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("NotFound", messages_hash);
|
|
|
|
|
2017-08-28 13:39:21 +03:00
|
|
|
case NSERROR_NOT_DIRECTORY:
|
|
|
|
/* Missing directory */
|
|
|
|
return messages_get_ctx("NotDirectory", messages_hash);
|
|
|
|
|
2012-11-26 21:20:15 +04:00
|
|
|
case NSERROR_SAVE_FAILED:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Failed to save data */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("SaveFailed", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_CLONE_FAILED:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Failed to clone handle */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("CloneFailed", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_INIT_FAILED:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Initialisation failed */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("InitFailed", messages_hash);
|
|
|
|
|
2017-08-28 13:39:21 +03:00
|
|
|
case NSERROR_BMP_ERROR:
|
|
|
|
/* A BMP error occurred */
|
|
|
|
return messages_get_ctx("BMPError", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_GIF_ERROR:
|
|
|
|
/* A GIF error occurred */
|
|
|
|
return messages_get_ctx("GIFError", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_ICO_ERROR:
|
|
|
|
/* A ICO error occurred */
|
|
|
|
return messages_get_ctx("ICOError", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_PNG_ERROR:
|
|
|
|
/* A PNG error occurred */
|
|
|
|
return messages_get_ctx("PNGError", messages_hash);
|
|
|
|
|
2017-08-30 11:43:13 +03:00
|
|
|
case NSERROR_SPRITE_ERROR:
|
2017-08-30 11:47:49 +03:00
|
|
|
/* A RISC OS Sprite error occurred */
|
2017-08-30 11:43:13 +03:00
|
|
|
return messages_get_ctx("SpriteError", messages_hash);
|
|
|
|
|
2017-08-28 13:39:21 +03:00
|
|
|
case NSERROR_SVG_ERROR:
|
|
|
|
/* A SVG error occurred */
|
|
|
|
return messages_get_ctx("SVGError", messages_hash);
|
|
|
|
|
2012-11-26 21:20:15 +04:00
|
|
|
case NSERROR_BAD_ENCODING:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* The character set is unknown */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("BadEncoding", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_NEED_DATA:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* More data needed */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("NeedData", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_ENCODING_CHANGE:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* The character set encoding change was unhandled */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("EncodingChanged", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_BAD_PARAMETER:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Bad Parameter */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("BadParameter", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_INVALID:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Invalid data */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("Invalid", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_BOX_CONVERT:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Box conversion failed */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("BoxConvert", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_STOPPED:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Content conversion stopped */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("Stopped", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_DOM:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* DOM call returned error */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("ParsingFail", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_CSS:
|
2015-06-22 01:24:31 +03:00
|
|
|
/* CSS call returned error */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("CSSGeneric", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_CSS_BASE:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* CSS base sheet failed */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("CSSBase", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_BAD_URL:
|
2014-10-25 16:28:41 +04:00
|
|
|
/* Bad URL */
|
2012-11-26 21:20:15 +04:00
|
|
|
return messages_get_ctx("BadURL", messages_hash);
|
|
|
|
|
2017-08-28 13:39:21 +03:00
|
|
|
case NSERROR_BAD_CONTENT:
|
|
|
|
/* Bad Content */
|
|
|
|
return messages_get_ctx("BadContent", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_FRAME_DEPTH:
|
|
|
|
/* Exceeded frame depth */
|
|
|
|
return messages_get_ctx("FrameDepth", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_PERMISSION:
|
|
|
|
/* Permission error */
|
|
|
|
return messages_get_ctx("PermissionError", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_BAD_SIZE:
|
|
|
|
/* Bad size */
|
|
|
|
return messages_get_ctx("BadSize", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_NOSPACE:
|
|
|
|
/* Insufficient space */
|
|
|
|
return messages_get_ctx("NoSpace", messages_hash);
|
|
|
|
|
|
|
|
case NSERROR_NOT_IMPLEMENTED:
|
|
|
|
/* Functionality is not implemented */
|
|
|
|
return messages_get_ctx("NotImplemented", messages_hash);
|
|
|
|
|
2012-11-26 21:20:15 +04:00
|
|
|
case NSERROR_UNKNOWN:
|
2017-08-28 13:39:21 +03:00
|
|
|
/* Unknown error */
|
|
|
|
return messages_get_ctx("Unknown", messages_hash);
|
2012-11-26 21:20:15 +04:00
|
|
|
}
|
|
|
|
|
2017-08-28 13:39:21 +03:00
|
|
|
/* The switch has no default, so the compiler should tell us when we
|
|
|
|
* forget to add messages for new error codes. As such, we should
|
|
|
|
* never get here.
|
|
|
|
*/
|
|
|
|
assert(0);
|
2017-08-28 14:21:03 +03:00
|
|
|
return messages_get_ctx("Unknown", messages_hash);
|
2012-11-26 21:20:15 +04:00
|
|
|
}
|
2016-12-11 19:43:48 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* exported function documented in utils/messages.h */
|
|
|
|
void messages_destroy(void)
|
|
|
|
{
|
|
|
|
messages_destroy_ctx(messages_hash);
|
|
|
|
messages_hash = NULL;
|
|
|
|
}
|