2 * Copyright (c) 1995, the EUROPAGATE consortium (see below).
4 * The EUROPAGATE consortium members are:
6 * University College Dublin
7 * Danmarks Teknologiske Videnscenter
8 * An Chomhairle Leabharlanna
9 * Consejo Superior de Investigaciones Cientificas
11 * Permission to use, copy, modify, distribute, and sell this software and
12 * its documentation, in whole or in part, for any purpose, is hereby granted,
15 * 1. This copyright and permission notice appear in all copies of the
16 * software and its documentation. Notices of copyright or attribution
17 * which appear at the beginning of any file must remain unchanged.
19 * 2. The names of EUROPAGATE or the project partners may not be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
23 * 3. Users of this software (implementors and gateway operators) agree to
24 * inform the EUROPAGATE consortium of their use of the software. This
25 * information will be used to evaluate the EUROPAGATE project and the
26 * software, and to plan further developments. The consortium may use
27 * the information in later publications.
29 * 4. Users of this software agree to make their best efforts, when
30 * documenting their use of the software, to acknowledge the EUROPAGATE
31 * consortium, and the role played by the software in their work.
33 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
34 * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
35 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
36 * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE
37 * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF
38 * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
39 * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND
40 * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
41 * USE OR PERFORMANCE OF THIS SOFTWARE.
46 * Resource management.
48 * Europagate, 1994-1995.
51 * Revision 1.6 1995/05/16 09:39:39 adam
54 * Revision 1.5 1995/05/03 07:36:29 adam
55 * New functions: gw_res_bool and gw_res_int.
57 * Revision 1.4 1995/04/19 12:12:02 adam
58 * Resource system uses only one log debug level.
60 * Revision 1.3 1995/02/23 08:32:12 adam
63 * Revision 1.1.1.1 1995/02/09 17:27:12 adam
64 * Initial version of email gateway under CVS control.
66 * Initial: Dec 7, 94 (Adam Dickmeiss)
71 #define RES_DEBUG GW_LOG_DEBUGN(8)
73 typedef struct Gw_res_info *GwRes; /* Gateway resource handle */
75 GwRes gw_res_init (void);
77 A resource handle is returned by this function describing
81 void gw_res_close (GwRes id);
83 The resources described by 'id' are freed. No further references
87 int gw_res_merge (GwRes id, const char *filename);
89 The resources described by 'id' are merged by the contents of
90 'filename'. If a resource is duplicated (in both resources 'id' and
91 the file) the resource is set to the value specified in 'filename'.
93 This function returns 0 on success; -1 on failure ('filename'
97 const char *gw_res_get (GwRes id, const char *name, const char *def);
99 The resource with name 'name' is checked in the resources represented
100 by 'id'. If the resource is present a pointer to the value (null-
101 terminated string) is returned. If the value is not present the
102 value of 'def' is returned.
105 int gw_res_put (GwRes id, const char *name, const char *value,
108 Change a resource - modify if it exists - add if not already
109 there. The resource will have impact on the file name 'fname'.
110 Use gw_res_commit (see below) to actually write to the
114 int gw_res_commit (GwRes id, const char *fname);
116 Rewrite the resource file 'fname'. If resources are modified/added
117 then these will be written now.
121 int gw_res_trav (GwRes id, const char *fname, void (*tf)(const char *name,
124 Traverse resources associated with file 'fname'. For each resource
125 the handler 'tf' is invoked with name and value.
128 int gw_res_bool (GwRes res, const char *name, int def_val);
130 Return true(1) or false(0) depending on setting for name. If
131 name doesn't exist, def_val is returned
134 int gw_res_int (GwRes res, const char *name, int def_val);
136 Treat value of name as integer. Issue warning (GW_LOG_WARN) if the value
137 cannot be read as integer. If name doesn't exist, def_val is returned
142 A resource name must begin on column 0 on a line. The name is followed
143 by colon. The value of the resource comes after the colon. A value may
144 span over several lines. Subsequent value lines are preceeded by one or
145 more blanks (tab/space). Empty/blank lines are ignored. Lines beginning
146 with # are treated as comments.
151 # Single line resource
153 # Multi line resource
154 FatalMsg: A serious error
156 # Yet another (danish):
157 Warning: Advarsel, taenk
158 dig om - inden du foretager dig noget.
160 The FatalMsg resource has the value "A serious error occured. Aborting.",
161 and the Warning resource has the value
162 "Advarsel, taenk dig om - inden du foretager dig noget." Note
163 that all blanks used to separate subsequent lines are treated as exactly