Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

treeconf_int.h

Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2004, 2005 by Kevin L. Mitchell <klmitch@mit.edu>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 **
00018 ** @(#)$Id: treeconf_int.h,v 1.7 2005/06/08 04:38:39 klmitch Exp $
00019 */
00020 #ifndef __include_treeconf_int_h__
00021 #define __include_treeconf_int_h__
00022 
00038 #define __TREECONF_LIBRARY__
00039 
00040 #include <stdlib.h> /* need free for _tc_release_node() below */
00041 
00042 #include "tc_config.h"
00043 #include "treeconf_err.h"
00044 #include "treeconf_version.h"
00045 #include "treeconf.h"
00046 
00058 #ifdef __GNUC__
00059 # if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
00060 #  define __attribute__(A)
00061 # endif
00062 #else
00063 # define __attribute__(A)
00064 #endif
00065 
00073 #define RCSTAG(tag) static char rcsid[] __attribute__((unused)) = tag
00074 
00081 #define TC_BUFSIZE      1024  /* buffer size for tc_load() */
00082 
00088 #define TC_NAMSIZE      128   /* buffer size for variable name */
00089 
00108 #define _tn_call_nodown(parent, name, elements)                         \
00109   (!((parent) && (parent)->tn_nodown) ? 0 :                             \
00110    ((parent)->tn_nodown)((parent)->tn_context, (parent), (name), (elements)))
00111 
00121 #define _tn_call_change(node) do {                                \
00122   if ((node)->tn_change)                                          \
00123     ((node)->tn_change)((node)->tn_context, (node));                    \
00124 } while (0)
00125 
00136 #define _tc_doerror(e) do {                                       \
00137   err = (e);                                                      \
00138   goto error;                                                     \
00139 } while (0)
00140 
00150 #define _tc_release_node(node) do {                               \
00151   treeconf_node_t *_node = (node);                                \
00152   _node->tn_magic = 0; /* clear the magic number */                     \
00153   if (_node->tn_value && !tn_isdef(_node))                              \
00154     free((void *)_node->tn_value); /* release current value... */       \
00155   if (_node->tn_default)                                          \
00156     free((void *)_node->tn_default); /* and default value... */               \
00157   if (_node->tn_down)                                             \
00158     _tc_release_children(_node); /* recurse to children of this node */       \
00159   _node->tn_context->tx_count--; /* update configuration count */       \
00160   free(_node); /* finally, release the node */                          \
00161 } while (0)
00162 
00170 struct result {
00171   treeconf_str_t       *r_comps;    
00172   int             r_count;    
00173   int             r_startnew; 
00174   treeconf_node_t      *r_node;           
00175 };
00176 
00177 /* The following functions are documented in their respective source files. */
00178 
00179 extern unsigned int _tc_lookup_node(treeconf_ctx_t *ctx, const char *name,
00180                             treeconf_node_t *node, struct result *res);
00181 extern treeconf_node_t *_tc_create_node(treeconf_ctx_t *ctx,
00182                               treeconf_node_t *parent,
00183                               treeconf_type_t type,
00184                               const char *name, int len,
00185                               const char *def,
00186                               treeconf_nodown_t nodown,
00187                               treeconf_change_t change, void *assoc);
00188 extern void _tc_release_children(treeconf_node_t *node);
00189 
00190 #endif /* __include_treeconf_int_h__ */

Generated on Wed Jun 8 09:18:27 2005 for treeconf by  doxygen 1.3.9.1