2 * gw-res.h: Resource management.
4 * Europagate, 1994-1995.
7 * Revision 1.3 1995/02/23 08:32:12 adam
10 * Revision 1.1.1.1 1995/02/09 17:27:12 adam
11 * Initial version of email gateway under CVS control.
13 * Initial: Dec 7, 94 (Adam Dickmeiss)
18 typedef struct Gw_res_info *GwRes; /* Gateway resource handle */
20 GwRes gw_res_init (void);
22 A resource handle is returned by this function describing
26 void gw_res_close (GwRes id);
28 The resources described by 'id' are freed. No further references
32 int gw_res_merge (GwRes id, const char *filename);
34 The resources described by 'id' are merged by the contents of
35 'filename'. If a resource is duplicated (in both resources 'id' and
36 the file) the resource is set to the value specified in 'filename'.
38 This function returns 0 on success; -1 on failure ('filename'
42 const char *gw_res_get (GwRes id, const char *name, const char *def);
44 The resource with name 'name' is checked in the resources represented
45 by 'id'. If the resource is present a pointer to the value (null-
46 terminated string) is returned. If the value is not present the
47 value of 'def' is returned.
50 int gw_res_put (GwRes id, const char *name, const char *value,
53 Change a resource - modify if it exists - add if not already
54 there. The resource will have impact on the file name 'fname'.
55 Use gw_res_commit (see below) to actually write to the
59 int gw_res_commit (GwRes id, const char *fname);
61 Rewrite the resource file 'fname'. If resources are modified/added
62 then these will be written now.
66 int gw_res_trav (GwRes id, const char *fname, void (*tf)(const char *name,
69 Traverse resources associated with file 'fname'. For each resource
70 the handler 'tf' is invoked with name and value.
76 A resource name must begin on column 0 on a line. The name is followed
77 by colon. The value of the resource comes after the colon. A value may
78 span over several lines. Subsequent value lines are preceeded by one or
79 more blanks (tab/space). Empty/blank lines are ignored. Lines beginning
80 with # are treated as comments.
85 # Single line resource
88 FatalMsg: A serious error
90 # Yet another (danish):
91 Warning: Advarsel, taenk
92 dig om - inden du foretager dig noget.
94 The FatalMsg resource has the value "A serious error occured. Aborting.",
95 and the Warning resource has the value
96 "Advarsel, taenk dig om - inden du foretager dig noget." Note
97 that all blanks used to separate subsequent lines are treated as exactly