i18n.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. #ifndef I18N_H
  42. #define I18N_H
  43. /* Make NSAPI_PUBLIC available */
  44. #include "base/systems.h"
  45. /* This stuff was copied from libadminutil/resource.h so we could
  46. remove the dependency on adminutil which is not being open sourced
  47. this first round.
  48. */
  49. #ifndef COPIED_FROM_LIBADMINUTIL_RESOURCE_H
  50. /* Resource contains the name of the
  51. property file w/ paht information
  52. */
  53. typedef struct
  54. {
  55. char *path;
  56. char *package;
  57. void *propset;
  58. } Resource;
  59. /*******************************************************************************/
  60. /*
  61. * this table contains library name
  62. * (stored in the first string entry, with id=0),
  63. * and the id/string pairs which are used by library
  64. */
  65. typedef struct res_RESOURCE_TABLE
  66. {
  67. int id;
  68. char *str;
  69. } res_RESOURCE_TABLE;
  70. /*******************************************************************************/
  71. /*
  72. * resource global contains resource table list which is used
  73. * to generate the database.
  74. * Also used for "in memory" version of XP_GetStringFromDatabase()
  75. */
  76. typedef struct res_RESOURCE_GLOBAL
  77. {
  78. res_RESOURCE_TABLE *restable;
  79. } res_RESOURCE_GLOBAL;
  80. /*******************************************************************************/
  81. /*
  82. * Define the ResDef macro to simplify the maintenance of strings which are to
  83. * be added to the library or application header file (dbtxxx.h). This enables
  84. * source code to refer to the strings by theit TokenNames, and allows the
  85. * strings to be stored in the database.
  86. *
  87. * Usage: ResDef(TokenName,TokenValue,String)
  88. *
  89. * Example: ResDef(DBT_HelloWorld_, \
  90. * 1,"Hello, World!")
  91. * ResDef(DBT_TheCowJumpedOverTheMoon_, \
  92. * 2,"The cow jumped over the moon.")
  93. * ResDef(DBT_TheValueOfPiIsAbout31415926536_, \
  94. * 3,"The value of PI is about 3.1415926536."
  95. *
  96. * RESOURCE_STR is used by makstrdb.c only. It is not used by getstrdb.c or
  97. * in library or application source code.
  98. */
  99. #ifdef RESOURCE_STR
  100. #define BEGIN_STR(argLibraryName) \
  101. RESOURCE_TABLE argLibraryName[] = { {0, #argLibraryName},
  102. #define ResDef(argToken,argID,argString) \
  103. {argID, argString},
  104. #define END_STR(argLibraryName) \
  105. {0, 0} };
  106. #else
  107. #define BEGIN_STR(argLibraryName) \
  108. enum {
  109. #define ResDef(argToken,argID,argString) \
  110. argToken = argID,
  111. #define END_STR(argLibraryName) \
  112. argLibraryName ## top };
  113. #endif
  114. #endif /* COPIED_FROM_LIBADMINUTIL_RESOURCE_H */
  115. typedef res_RESOURCE_TABLE RESOURCE_TABLE;
  116. typedef res_RESOURCE_GLOBAL RESOURCE_GLOBAL;
  117. /*******************************************************************************/
  118. /*
  119. * In accordance with the recommendations in the
  120. * "Netscape Coding Standard for Server Internationalization",
  121. * the following aliases are defined for fprintf, et al., and
  122. * these aliases should be used to clearly indicate the intended
  123. * destination for output.
  124. */
  125. #define AdminFprintf fprintf
  126. #define DebugFprintf fprintf
  127. #define ClientSprintf sprintf
  128. #define AdminSprintf sprintf
  129. #define DebugSprintf sprintf
  130. #define ClientFputs fputs
  131. #define AdminFputs fputs
  132. #define DebugFputs fputs
  133. /* more #define, as needed */
  134. /*******************************************************************************/
  135. /*
  136. * Function prototypes for application and libraries
  137. */
  138. #ifdef __cplusplus
  139. extern "C"
  140. {
  141. #endif
  142. /******************************/
  143. /* XP_GetStringFromDatabase() */
  144. /******************************/
  145. NSAPI_PUBLIC
  146. extern char*
  147. XP_GetStringFromDatabase(char* strLibraryName,
  148. char* strLanguage,
  149. int iToken);
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. /*******************************************************************************/
  154. /*
  155. * Function prototypes for building string database
  156. */
  157. extern int XP_MakeStringDatabase(void);
  158. /* Used to create the string database at build time; not used by the application
  159. itself. Returns 0 is successful. */
  160. extern void XP_PrintStringDatabase(void);
  161. /* DEBUG: Prints out entire string database to standard output. */
  162. /*******************************************************************************/
  163. /*
  164. * Macros to simplify calls to XP_GetStringFromDatabase
  165. * (need one argument instead of three)
  166. */
  167. #define XP_GetAdminStr(DBTTokenName) \
  168. XP_GetStringFromDatabase(LIBRARY_NAME, \
  169. "en", \
  170. DBTTokenName)
  171. /*******************************************************************************/
  172. #endif