Initial revision
[egate.git] / include / gw-res.h
diff --git a/include/gw-res.h b/include/gw-res.h
new file mode 100644 (file)
index 0000000..35f654d
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+   gw-res.h: Resource management.
+
+   Europagate, 1994-1995.
+
+   $Log: gw-res.h,v $
+   Revision 1.1  1995/02/09 17:27:11  adam
+   Initial revision
+
+
+   Initial:       Dec  7, 94 (Adam Dickmeiss)
+   Last update:   Dec 13, 94 (Adam Dickmeiss)
+ */
+#ifndef GW_RES_H
+#define GW_RES_H
+
+typedef struct Gw_res_info *GwRes;   /* Gateway resource handle */
+
+GwRes gw_res_init (void);
+/*
+    A resource handle is returned by this function describing
+    the empty resource.
+ */
+
+void gw_res_close (GwRes id);
+/*
+    The resources described by 'id' are freed. No further references
+    to 'id' are allowed.
+ */
+
+int gw_res_merge (GwRes id, const char *filename);
+/*
+    The resources described by 'id' are merged by the contents of 
+    'filename'. If a resource is duplicated (in both resources 'id' and
+    the file) the resource is set to the value specified in 'filename'.
+
+    This function returns 0 on success; -1 on failure ('filename'
+    could not be read)
+ */
+
+const char *gw_res_get (GwRes id, const char *name, const char *def);
+/*
+    The resource with name 'name' is checked in the resources represented
+    by 'id'. If the resource is present a pointer to the value (null-
+    terminated string) is returned. If the value is not present the 
+    value of 'def' is returned.
+ */
+
+int gw_res_put (GwRes id, const char *name, const char *value, 
+                const char *fname);
+/*
+    Change a resource - modify if it exists - add if not already
+    there. The resource will have impact on the file name 'fname'.
+    Use gw_res_commit (see below) to actually write to the
+    resource file.
+ */
+
+int gw_res_commit (GwRes id, const char *fname);
+/*
+    Rewrite the resource file 'fname'. If resources are modified/added
+    then these will be written now.
+ */
+
+
+int gw_res_trav (GwRes id, const char *fname, void (*tf)(const char *name,
+                                                        const char *value));
+/*
+    Traverse resources associated with file 'fname'. For each resource
+    the handler 'tf' is invoked with name and value.
+ */
+
+/*
+   GwRes file format.
+
+   A resource name must begin on column 0 on a  line. The name is followed 
+   by colon. The value of the resource comes after the colon. A value may 
+   span over several lines. Subsequent value lines are preceeded by one or 
+   more blanks (tab/space). Empty/blank lines are ignored. Lines beginning 
+   with # are treated as comments. 
+
+   Example
+    # Comment. Ignored
+   
+    # Single line resource
+    MaxSize: 1000
+    # Multi line resource
+    FatalMsg: A serious error
+     occured. Aborting.
+    # Yet another (danish):
+    Warning: Advarsel, taenk
+         dig om - inden du foretager dig noget.
+
+   The FatalMsg resource has the value "A serious error occured. Aborting.", 
+   and the Warning resource has the value 
+   "Advarsel, taenk dig om - inden du foretager dig noget." Note
+   that all blanks used to separate subsequent lines are treated as exactly 
+   one blank.
+*/
+#endif