2 gw-res.h: Resource management.
7 Revision 1.1 1995/02/09 17:27:11 adam
11 Initial: Dec 7, 94 (Adam Dickmeiss)
12 Last update: Dec 13, 94 (Adam Dickmeiss)
17 typedef struct Gw_res_info *GwRes; /* Gateway resource handle */
19 GwRes gw_res_init (void);
21 A resource handle is returned by this function describing
25 void gw_res_close (GwRes id);
27 The resources described by 'id' are freed. No further references
31 int gw_res_merge (GwRes id, const char *filename);
33 The resources described by 'id' are merged by the contents of
34 'filename'. If a resource is duplicated (in both resources 'id' and
35 the file) the resource is set to the value specified in 'filename'.
37 This function returns 0 on success; -1 on failure ('filename'
41 const char *gw_res_get (GwRes id, const char *name, const char *def);
43 The resource with name 'name' is checked in the resources represented
44 by 'id'. If the resource is present a pointer to the value (null-
45 terminated string) is returned. If the value is not present the
46 value of 'def' is returned.
49 int gw_res_put (GwRes id, const char *name, const char *value,
52 Change a resource - modify if it exists - add if not already
53 there. The resource will have impact on the file name 'fname'.
54 Use gw_res_commit (see below) to actually write to the
58 int gw_res_commit (GwRes id, const char *fname);
60 Rewrite the resource file 'fname'. If resources are modified/added
61 then these will be written now.
65 int gw_res_trav (GwRes id, const char *fname, void (*tf)(const char *name,
68 Traverse resources associated with file 'fname'. For each resource
69 the handler 'tf' is invoked with name and value.
75 A resource name must begin on column 0 on a line. The name is followed
76 by colon. The value of the resource comes after the colon. A value may
77 span over several lines. Subsequent value lines are preceeded by one or
78 more blanks (tab/space). Empty/blank lines are ignored. Lines beginning
79 with # are treated as comments.
84 # Single line resource
87 FatalMsg: A serious error
89 # Yet another (danish):
90 Warning: Advarsel, taenk
91 dig om - inden du foretager dig noget.
93 The FatalMsg resource has the value "A serious error occured. Aborting.",
94 and the Warning resource has the value
95 "Advarsel, taenk dig om - inden du foretager dig noget." Note
96 that all blanks used to separate subsequent lines are treated as exactly