/* ** OSSP cfg - Configuration Parsing ** Copyright (c) 1999-2002 Ralf S. Engelschall ** Copyright (c) 1999-2002 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) ** ** This file is part of OSSP cfg, a configuration parsing ** library which can be found at http://www.ossp.org/pkg/lib/cfg/. ** ** Permission to use, copy, modify, and distribute this software for ** any purpose with or without fee is hereby granted, provided that ** the above copyright notice and this permission notice appear in all ** copies. ** ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRCFG, STRICT LIABILITY, ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** cfg.h: master API */ #ifndef __CFG_H__ #define __CFG_H__ #include /* ============================================================ */ /* 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_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); /* ============================================================ */ /* 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_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_t; /* list of node goto */ 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; /* configuration node type */ 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); /* ============================================================ */ #endif /* __CFG_H__ */