Subversion Repositories Kolibri OS

Rev

Rev 3584 | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
  3.  *
  4.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  5.  *
  6.  * NetSurf is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; version 2 of the License.
  9.  *
  10.  * NetSurf is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. /** \file
  20.  * Localised message support (interface).
  21.  *
  22.  * The messages module loads a file of keys and associated strings, and
  23.  * provides fast lookup by key. The messages file consists of key:value lines,
  24.  * comment lines starting with #, and other lines are ignored. Use
  25.  * messages_load() to read the file into memory. To lookup a key, use
  26.  * messages_get("key").
  27.  *
  28.  * It can also load additional messages files into different contexts and allow
  29.  * you to look up values in it independantly from the standard shared Messages
  30.  * file table.  Use the _ctx versions of the functions to do this.
  31.  */
  32.  
  33. #ifndef _NETSURF_UTILS_MESSAGES_H_
  34. #define _NETSURF_UTILS_MESSAGES_H_
  35.  
  36. #include "utils/errors.h"
  37. #include "utils/hashtable.h"
  38.  
  39. void messages_load(const char *path);
  40. struct hash_table *messages_load_ctx(const char *path, struct hash_table *ctx);
  41. const char *messages_get_ctx(const char *key, struct hash_table *ctx);
  42. const char *messages_get(const char *key);
  43.  
  44. /**
  45.  * lookup of a message by errorcode from the standard Messages hash.
  46.  *
  47.  * \param code errorcode of message
  48.  * \return message text
  49.  */
  50. const char *messages_get_errorcode(nserror code);
  51.  
  52. /**
  53.  * Formatted message from a key in the global message hash.
  54.  *
  55.  * \param  key  key of message
  56.  * \param ... message parameters
  57.  * \return buffer containing formatted message text or NULL if memory
  58.  *         is unavailable. The caller owns the returned buffer and is
  59.  *         responsible for freeing it.
  60.  */
  61.  
  62. char *messages_get_buff(const char *key, ...);
  63.  
  64. #endif
  65.