OSSP CVS Repository

ossp - Difference in ossp-pkg/cfg/cfg.h versions 1.4 and 1.5
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/cfg/cfg.h 1.4 -> 1.5

--- cfg.h        2002/07/05 15:32:42     1.4
+++ cfg.h        2002/07/10 12:00:23     1.5
@@ -31,84 +31,125 @@
 #ifndef __CFG_H__
 #define __CFG_H__
 
-#ifdef DMALLOC
-#include <dmalloc.h>
-#endif
+#include <stdlib.h>
 #include <stdarg.h>
-
-/* ============================================================ */
+#include <string.h>
 
 /* general return codes */
 typedef enum {
-    CFG_OK = 0,
-    CFG_ERR_ARG,
-    CFG_ERR_USE,
-    CFG_ERR_INT,
-    CFG_ERR_SYS,
-    CFG_ERR_SYN,
-    CFG_ERR_FMT,
-    CFG_ERR_GOT
+    CFG_OK = 0,               /* everything ok */
+    CFG_ERR_ARG,              /* invalid argument */
+    CFG_ERR_USE,              /* invalid use */
+    CFG_ERR_SYS,              /* operating system error (see errno) */
+    CFG_ERR_SYN,              /* syntax parsing error */
+    CFG_ERR_FMT,              /* formatting error */
+    CFG_ERR_GOT,              /* goto error */
+    CFG_ERR_INT               /* internal error */
 } cfg_rc_t;
 
-/* ============================================================ */
-
-/* configuration handle */
-struct cfg_st;
-typedef struct cfg_st cfg_t;
-
-/* configuration API */
-cfg_rc_t   cfg_create      (cfg_t **cfg);
-cfg_rc_t   cfg_destroy     (cfg_t  *cfg);
-
-/* ============================================================ */
+/* configuration format */
+typedef enum {
+    CFG_FMT_CFG,
+    CFG_FMT_XML
+} cfg_fmt_t;
 
 /* list of node types */
 typedef enum {
     CFG_NODE_TYPE_SEQ,        /* node represents a sequence */
     CFG_NODE_TYPE_DIR,        /* node represents a directive */
-    CFG_NODE_TYPE_TOK         /* node represents a token */
+    CFG_NODE_TYPE_OPT,        /* node represents a option */
+    CFG_NODE_TYPE_ARG         /* node represents a argument */
 } cfg_node_type_t;
 
 /* list of node attributes */
 typedef enum {
-    CFG_NODE_ATTR_TYPE,       /* type of node */
-    CFG_NODE_ATTR_PARENT,     /* pointer to parent node */
-    CFG_NODE_ATTR_RBROTH,     /* pointer to right brother node */
-    CFG_NODE_ATTR_CHILD1,     /* pointer to first child node */
-    CFG_NODE_ATTR_TOKEN,      /* pointer to the node token string */
-    CFG_NODE_ATTR_DATA        /* pointer to the node annotation data */
+    CFG_NODE_ATTR_PARENT,     /* RW: pointer to parent node */
+    CFG_NODE_ATTR_LBROTH,     /* RW: pointer to right brother node */
+    CFG_NODE_ATTR_RBROTH,     /* RW: pointer to right brother node */
+    CFG_NODE_ATTR_CHILD1,     /* RW: pointer to first child node */
+    CFG_NODE_ATTR_CHILDL,     /* RO: pointer to last child */
+    CFG_NODE_ATTR_CHILDS,     /* RO: number of child nodes */
+    CFG_NODE_ATTR_NODES,      /* RO: number of total nodes (recursive) */
+    CFG_NODE_ATTR_DEPTH,      /* RO: number of nodes back to root node */
+    CFG_NODE_ATTR_TYPE,       /* RW: type of node */
+    CFG_NODE_ATTR_TOKEN,      /* RW: pointer to the node token string */
+    CFG_NODE_ATTR_DATA,       /* RW: pointer to the node annotation data */
+    CFG_NODE_ATTR_SRCNAME,    /* RW: pointer to the source name */
+    CFG_NODE_ATTR_SRCPOS      /* RW: position offset into source */
 } cfg_node_attr_t;
 
-/* list of node goto */
+/* list of data types */
+typedef enum {
+    CFG_DATA_TYPE_PTR,        /* "void *" */
+    CFG_DATA_TYPE_STR,        /* "char *" */
+    CFG_DATA_TYPE_INT,        /* "int"    */
+    CFG_DATA_TYPE_FLT         /* "double" */
+} cfg_data_type_t;
+
+/* list of data control operations */
+typedef enum {
+    CFG_DATA_CTRL_CLONE,      /* clone data */
+    CFG_DATA_CTRL_DESTROY     /* destroy data */
+} cfg_data_ctrl_t;
+
+/* list of data attributes */
 typedef enum {
-    CFG_NODE_GOTO_PARENT,
-    CFG_NODE_GOTO_LBROTH,
-    CFG_NODE_GOTO_RBROTH,
-    CFG_NODE_GOTO_CHILD1,
-    CFG_NODE_GOTO_CHILDL
-} cfg_node_goto_t;
-
-/* list of node linking variants */
-typedef enum {
-    CFG_NODE_LINK_PARENT,
-    CFG_NODE_LINK_RBROTH,
-    CFG_NODE_LINK_CHILD1
-} cfg_node_link_t;
+    CFG_DATA_ATTR_TYPE,       /* RW: type of data value */
+    CFG_DATA_ATTR_VALUE,      /* RW: pointer to data value */
+    CFG_DATA_ATTR_CTRL        /* RW: pointer to data control callback */
+} cfg_data_attr_t;
+
+/* configuration handle type (opaque) */
+struct cfg_st;
+typedef struct cfg_st cfg_t;
 
-/* configuration node type */
+/* configuration node type (opaque) */
 struct cfg_node_st;
 typedef struct cfg_node_st cfg_node_t;
 
-cfg_rc_t   cfg_node_create  (cfg_node_t **node);
-cfg_rc_t   cfg_node_set     (cfg_node_t  *node, cfg_node_attr_t attr, ...);
-cfg_rc_t   cfg_node_get     (cfg_node_t  *node, cfg_node_attr_t attr, ...);
-cfg_rc_t   cfg_node_goto    (cfg_node_t  *node, cfg_node_goto_t id, cfg_node_t **node2);
-cfg_rc_t   cfg_node_link    (cfg_node_t  *node, cfg_node_link_t id, cfg_node_t *node2);
-cfg_rc_t   cfg_node_unlink  (cfg_node_t  *node);
-cfg_rc_t   cfg_node_apply   (cfg_node_t  *node, void (*cb_fct)(void *, cfg_node_t *), void *cb_ctx);
-cfg_rc_t   cfg_node_destroy (cfg_node_t  *node);
+/* configuration data type */
+struct cfg_data_st;
+typedef struct cfg_data_st cfg_data_t;
+
+/* configuration data control callback type */
+typedef cfg_rc_t (*cfg_data_cb_t)(cfg_data_t *, cfg_data_ctrl_t, ...);
+
+/* configuration handling */
+cfg_rc_t   cfg_create      (cfg_t **cfg);
+cfg_rc_t   cfg_destroy     (cfg_t  *cfg);
+cfg_rc_t   cfg_error       (cfg_t  *cfg, cfg_rc_t rc, char *err_ptr, size_t err_len);
 
-/* ============================================================ */
+/* configuration import/export */
+cfg_rc_t   cfg_import      (cfg_t  *cfg, cfg_node_t  *node, cfg_fmt_t fmt, const char *in_ptr, size_t in_len);
+cfg_rc_t   cfg_export      (cfg_t  *cfg, cfg_node_t  *node, cfg_fmt_t fmt,       char *ex_ptr, size_t ex_len);
+
+/* node handling */
+cfg_rc_t   cfg_node_create (cfg_t  *cfg, cfg_node_t **node);
+cfg_rc_t   cfg_node_destroy(cfg_t  *cfg, cfg_node_t  *node);
+cfg_rc_t   cfg_node_clone  (cfg_t  *cfg, cfg_node_t  *node, cfg_node_t **node2);
+
+/* node attribution */
+cfg_rc_t   cfg_node_set    (cfg_t  *cfg, cfg_node_t  *node, cfg_node_attr_t attr, ...);
+cfg_rc_t   cfg_node_get    (cfg_t  *cfg, cfg_node_t  *node, cfg_node_attr_t attr, ...);
+
+/* node traversing */
+cfg_rc_t   cfg_node_root   (cfg_t  *cfg, cfg_node_t **node);
+cfg_rc_t   cfg_node_goto   (cfg_t  *cfg, cfg_node_t **node, const char *spec);
+
+/* node locating */
+cfg_rc_t   cfg_node_select (cfg_t  *cfg, cfg_node_t  *node, const char *dotpath, cfg_node_t **node2);
+cfg_rc_t   cfg_node_find   (cfg_t  *cfg, cfg_node_t  *node, cfg_rc_t (*cb_fct_cmp)(cfg_t *, cfg_node_t *, void *), void *cb_ctx_cmp, cfg_node_t **cont);
+cfg_rc_t   cfg_node_apply  (cfg_t  *cfg, cfg_node_t  *node, cfg_rc_t (*cb_fct_cmp)(cfg_t *, cfg_node_t *, void *), void *cb_ctx_cmp, cfg_rc_t (*cb_fct_cb)(cfg_t *, cfg_node_t *, void *), void *cb_ctx_cb);
+cfg_rc_t   cfg_node_cmp    (cfg_t  *cfg, cfg_node_t  *node, void *token);
+
+/* node linking */
+cfg_rc_t   cfg_node_link   (cfg_t  *cfg, cfg_node_t  *node, cfg_node_attr_t id, cfg_node_t *node2);
+cfg_rc_t   cfg_node_unlink (cfg_t  *cfg, cfg_node_t  *node);
+
+/* data attribution */
+cfg_rc_t   cfg_data_set    (cfg_data_t *data, cfg_data_attr_t attr, ...);
+cfg_rc_t   cfg_data_get    (cfg_data_t *data, cfg_data_attr_t attr, ...);
+cfg_rc_t   cfg_data_ctrl   (cfg_data_t *data, cfg_data_ctrl_t ctrl, ...);
 
 #endif /* __CFG_H__ */
 

CVSTrac 2.0.1