2 * gw-res.h: Resource management.
4 * Europagate, 1994-1995.
7 * Revision 1.4 1995/04/19 12:12:02 adam
8 * Resource system uses only one log debug level.
10 * Revision 1.3 1995/02/23 08:32:12 adam
13 * Revision 1.1.1.1 1995/02/09 17:27:12 adam
14 * Initial version of email gateway under CVS control.
16 * Initial: Dec 7, 94 (Adam Dickmeiss)
21 #define RES_DEBUG GW_LOG_DEBUGN(8)
23 typedef struct Gw_res_info *GwRes; /* Gateway resource handle */
25 GwRes gw_res_init (void);
27 A resource handle is returned by this function describing
31 void gw_res_close (GwRes id);
33 The resources described by 'id' are freed. No further references
37 int gw_res_merge (GwRes id, const char *filename);
39 The resources described by 'id' are merged by the contents of
40 'filename'. If a resource is duplicated (in both resources 'id' and
41 the file) the resource is set to the value specified in 'filename'.
43 This function returns 0 on success; -1 on failure ('filename'
47 const char *gw_res_get (GwRes id, const char *name, const char *def);
49 The resource with name 'name' is checked in the resources represented
50 by 'id'. If the resource is present a pointer to the value (null-
51 terminated string) is returned. If the value is not present the
52 value of 'def' is returned.
55 int gw_res_put (GwRes id, const char *name, const char *value,
58 Change a resource - modify if it exists - add if not already
59 there. The resource will have impact on the file name 'fname'.
60 Use gw_res_commit (see below) to actually write to the
64 int gw_res_commit (GwRes id, const char *fname);
66 Rewrite the resource file 'fname'. If resources are modified/added
67 then these will be written now.
71 int gw_res_trav (GwRes id, const char *fname, void (*tf)(const char *name,
74 Traverse resources associated with file 'fname'. For each resource
75 the handler 'tf' is invoked with name and value.
81 A resource name must begin on column 0 on a line. The name is followed
82 by colon. The value of the resource comes after the colon. A value may
83 span over several lines. Subsequent value lines are preceeded by one or
84 more blanks (tab/space). Empty/blank lines are ignored. Lines beginning
85 with # are treated as comments.
90 # Single line resource
93 FatalMsg: A serious error
95 # Yet another (danish):
96 Warning: Advarsel, taenk
97 dig om - inden du foretager dig noget.
99 The FatalMsg resource has the value "A serious error occured. Aborting.",
100 and the Warning resource has the value
101 "Advarsel, taenk dig om - inden du foretager dig noget." Note
102 that all blanks used to separate subsequent lines are treated as exactly