Debian Codegraph @

include/i18n.h

raw
1 /** BEGIN COPYRIGHT BLOCK
2 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
3 * Copyright (C) 2005 Red Hat, Inc.
4 * All rights reserved.
5 *
6 * License: GPL (version 3 or any later version).
7 * See LICENSE for details.
8 * END COPYRIGHT BLOCK **/
9
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13
14
15 #ifndef I18N_H
16 #define I18N_H
17
18 /* Make NSAPI_PUBLIC available */
19 #include "base/systems.h"
20
21 /* This stuff was copied from libadminutil/resource.h so we could
22 remove the dependency on adminutil which is not being open sourced
23 this first round.
24 */
25 #ifndef COPIED_FROM_LIBADMINUTIL_RESOURCE_H
26 /* Resource contains the name of the
27 property file w/ paht information
28 */
29 typedef struct
30 {
31 char *path;
32 char *package;
33 void *propset;
34 } Resource;
35
36 /*******************************************************************************/
37 /*
38 * this table contains library name
39 * (stored in the first string entry, with id=0),
40 * and the id/string pairs which are used by library
41 */
42
43 typedef struct res_RESOURCE_TABLE
44 {
45 int id;
46 char *str;
47 } res_RESOURCE_TABLE;
48
49 /*******************************************************************************/
50
51 /*
52 * resource global contains resource table list which is used
53 * to generate the database.
54 * Also used for "in memory" version of XP_GetStringFromDatabase()
55 */
56
57 typedef struct res_RESOURCE_GLOBAL
58 {
59 res_RESOURCE_TABLE *restable;
60 } res_RESOURCE_GLOBAL;
61
62 /*******************************************************************************/
63
64 /*
65 * Define the ResDef macro to simplify the maintenance of strings which are to
66 * be added to the library or application header file (dbtxxx.h). This enables
67 * source code to refer to the strings by theit TokenNames, and allows the
68 * strings to be stored in the database.
69 *
70 * Usage: ResDef(TokenName,TokenValue,String)
71 *
72 * Example: ResDef(DBT_HelloWorld_, \
73 * 1,"Hello, World!")
74 * ResDef(DBT_TheCowJumpedOverTheMoon_, \
75 * 2,"The cow jumped over the moon.")
76 * ResDef(DBT_TheValueOfPiIsAbout31415926536_, \
77 * 3,"The value of PI is about 3.1415926536."
78 *
79 * RESOURCE_STR is used by makstrdb.c only. It is not used by getstrdb.c or
80 * in library or application source code.
81 */
82
83 #ifdef RESOURCE_STR
84 #define BEGIN_STR(argLibraryName) \
85 RESOURCE_TABLE argLibraryName[] = {{0, #argLibraryName},
86 #define ResDef(argToken, argID, argString) \
87 {argID, argString},
88 #define END_STR(argLibraryName) \
89 { \
90 0, 0 \
91 } \
92 } \
93 ;
94 #else
95 #define BEGIN_STR(argLibraryName) \
96 enum \
97 {
98 #define ResDef(argToken, argID, argString) \
99 argToken = argID,
100 #define END_STR(argLibraryName) \
101 argLibraryName##top \
102 } \
103 ;
104 #endif
105
106 #endif /* COPIED_FROM_LIBADMINUTIL_RESOURCE_H */
107
108 typedef res_RESOURCE_TABLE RESOURCE_TABLE;
109 typedef res_RESOURCE_GLOBAL RESOURCE_GLOBAL;
110
111
112 /*******************************************************************************/
113
114 /*
115 * In accordance with the recommendations in the
116 * "Netscape Coding Standard for Server Internationalization",
117 * the following aliases are defined for fprintf, et al., and
118 * these aliases should be used to clearly indicate the intended
119 * destination for output.
120 */
121
122 #define AdminFprintf fprintf
123 #define DebugFprintf fprintf
124
125 #define ClientSprintf sprintf
126 #define AdminSprintf sprintf
127 #define DebugSprintf sprintf
128
129 #define ClientFputs fputs
130 #define AdminFputs fputs
131 #define DebugFputs fputs
132
133 /* more #define, as needed */
134
135 /*******************************************************************************/
136
137 /*
138 * Function prototypes for application and libraries
139 */
140
141
142 #ifdef __cplusplus
143 extern "C" {
144 #endif
145
146
147 /******************************/
148 /* XP_GetStringFromDatabase() */
149 /******************************/
150
151 NSAPI_PUBLIC
152 extern const char *
153 XP_GetStringFromDatabase(const char *strLibraryName,
154 const char *strLanguage,
155 int iToken);
156
157 #ifdef __cplusplus
158 }
159 #endif
160
161
162 /*******************************************************************************/
163
164 /*
165 * Function prototypes for building string database
166 */
167
168 extern int XP_MakeStringDatabase(void);
169
170 /* Used to create the string database at build time; not used by the application
171 itself. Returns 0 is successful. */
172
173 extern void XP_PrintStringDatabase(void);
174
175 /* DEBUG: Prints out entire string database to standard output. */
176
177 /*******************************************************************************/
178
179 /*
180 * Macros to simplify calls to XP_GetStringFromDatabase
181 * (need one argument instead of three)
182 */
183
184 #define XP_GetAdminStr(DBTTokenName) \
185 XP_GetStringFromDatabase(LIBRARY_NAME, \
186 "en", \
187 DBTTokenName)
188
189 /*******************************************************************************/
190
191 #endif