Changed header.
[egate.git] / include / gw-res.h
1 /*
2  * gw-res.h: Resource management.
3  *
4  * Europagate, 1994-1995.
5  *
6  * $Log: gw-res.h,v $
7  * Revision 1.3  1995/02/23 08:32:12  adam
8  * Changed header.
9  *
10  * Revision 1.1.1.1  1995/02/09  17:27:12  adam
11  * Initial version of email gateway under CVS control.
12  *
13  * Initial:       Dec  7, 94 (Adam Dickmeiss)
14  */
15 #ifndef GW_RES_H
16 #define GW_RES_H
17
18 typedef struct Gw_res_info *GwRes;   /* Gateway resource handle */
19
20 GwRes gw_res_init (void);
21 /*
22     A resource handle is returned by this function describing
23     the empty resource.
24  */
25
26 void gw_res_close (GwRes id);
27 /*
28     The resources described by 'id' are freed. No further references
29     to 'id' are allowed.
30  */
31
32 int gw_res_merge (GwRes id, const char *filename);
33 /*
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'.
37
38     This function returns 0 on success; -1 on failure ('filename'
39     could not be read)
40  */
41
42 const char *gw_res_get (GwRes id, const char *name, const char *def);
43 /*
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.
48  */
49
50 int gw_res_put (GwRes id, const char *name, const char *value, 
51                 const char *fname);
52 /*
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
56     resource file.
57  */
58
59 int gw_res_commit (GwRes id, const char *fname);
60 /*
61     Rewrite the resource file 'fname'. If resources are modified/added
62     then these will be written now.
63  */
64
65
66 int gw_res_trav (GwRes id, const char *fname, void (*tf)(const char *name,
67                                                         const char *value));
68 /*
69     Traverse resources associated with file 'fname'. For each resource
70     the handler 'tf' is invoked with name and value.
71  */
72
73 /*
74    GwRes file format.
75
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. 
81
82    Example
83     # Comment. Ignored
84    
85     # Single line resource
86     MaxSize: 1000
87     # Multi line resource
88     FatalMsg: A serious error
89      occured. Aborting.
90     # Yet another (danish):
91     Warning: Advarsel, taenk
92          dig om - inden du foretager dig noget.
93
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 
98    one blank.
99 */
100 #endif