2003-08-16 22:39:10 +04:00
|
|
|
/*
|
2004-05-08 22:13:27 +04:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
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/>.
|
2003-08-16 22:39:10 +04:00
|
|
|
*/
|
|
|
|
|
2004-05-08 22:13:27 +04:00
|
|
|
/** \file
|
|
|
|
* Localised message support (interface).
|
|
|
|
*
|
2003-08-16 22:39:10 +04:00
|
|
|
* The messages module loads a file of keys and associated strings, and
|
|
|
|
* provides fast lookup by key. The messages file consists of key:value lines,
|
|
|
|
* comment lines starting with #, and other lines are ignored. Use
|
2004-05-08 22:13:27 +04:00
|
|
|
* messages_load() to read the file into memory. To lookup a key, use
|
|
|
|
* messages_get("key").
|
|
|
|
*
|
2006-08-22 02:07:10 +04:00
|
|
|
* It can also load additional messages files into different contexts and allow
|
|
|
|
* you to look up values in it independantly from the standard shared Messages
|
|
|
|
* file table. Use the _ctx versions of the functions to do this.
|
2003-08-16 22:39:10 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_UTILS_MESSAGES_H_
|
|
|
|
#define _NETSURF_UTILS_MESSAGES_H_
|
|
|
|
|
2015-06-22 01:24:31 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2012-11-26 21:20:15 +04:00
|
|
|
#include "utils/errors.h"
|
2019-08-06 15:15:23 +03:00
|
|
|
#include "netsurf/ssl_certs.h"
|
2006-08-22 02:07:10 +04:00
|
|
|
|
2014-10-25 15:39:21 +04:00
|
|
|
/**
|
|
|
|
* Read keys and values from messages file into the standard Messages hash.
|
|
|
|
*
|
2015-06-19 18:29:42 +03:00
|
|
|
* The messages are merged with any previously loaded messages. Any
|
|
|
|
* keys which are present already are replaced with the new value. The
|
|
|
|
* file may be gzip compressed.
|
2014-10-25 15:39:21 +04:00
|
|
|
*
|
|
|
|
* \param path pathname of messages file.
|
|
|
|
* \return NSERROR_OK on success or error code on faliure.
|
|
|
|
*/
|
2015-06-19 18:29:42 +03:00
|
|
|
nserror messages_add_from_file(const char *path);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read keys and values from inline message data 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. The
|
|
|
|
* data may be gzip compressed.
|
|
|
|
*
|
|
|
|
* \param data The inline message data.
|
2016-09-13 11:16:31 +03:00
|
|
|
* \param data_size The length of the message data.
|
2015-06-19 18:29:42 +03:00
|
|
|
* \return NSERROR_OK on success or error code on faliure.
|
|
|
|
*/
|
2015-06-22 01:24:31 +03:00
|
|
|
nserror messages_add_from_inline(const uint8_t *data, size_t data_size);
|
2014-10-25 15:39:21 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2003-08-16 22:39:10 +04:00
|
|
|
const char *messages_get(const char *key);
|
|
|
|
|
2012-11-26 21:20:15 +04:00
|
|
|
/**
|
|
|
|
* lookup of a message by errorcode from the standard Messages hash.
|
|
|
|
*
|
|
|
|
* \param code errorcode of message
|
|
|
|
* \return message text
|
|
|
|
*/
|
|
|
|
const char *messages_get_errorcode(nserror code);
|
|
|
|
|
2019-08-06 15:15:23 +03:00
|
|
|
/**
|
|
|
|
* lookup of a message by SSL error code from the standard Messages hash.
|
|
|
|
*
|
|
|
|
* \param code ssl error code
|
|
|
|
* \return message text
|
|
|
|
*/
|
|
|
|
const char *messages_get_sslcode(ssl_cert_err code);
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
/**
|
|
|
|
* Formatted message from a key in the global message hash.
|
|
|
|
*
|
|
|
|
* \param key key of message
|
|
|
|
* \param ... message parameters
|
|
|
|
* \return buffer containing formatted message text or NULL if memory
|
|
|
|
* is unavailable. The caller owns the returned buffer and is
|
|
|
|
* responsible for freeing it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *messages_get_buff(const char *key, ...);
|
|
|
|
|
2016-12-11 19:43:48 +03:00
|
|
|
/**
|
|
|
|
* Free memory used by the standard Messages hash
|
|
|
|
*/
|
|
|
|
void messages_destroy(void);
|
|
|
|
|
2003-08-16 22:39:10 +04:00
|
|
|
#endif
|