5  * conffile.h   Defines for the conffile parsing routines.
 
   7  * Version:     $Id: conffile.h,v 1.1 2010/08/14 04:13:52 faust Exp $
 
  11 //#include <freeradius/ident.h>
 
  12 //RCSIDH(conffile_h, "$Id: conffile.h,v 1.1 2010/08/14 04:13:52 faust Exp $")
 
  15 //#include <freeradius/token.h>
 
  16 #include "libradius.h"
 
  19  * Export the minimum amount of information about these structs
 
  21 typedef struct conf_item CONF_ITEM;
 
  22 typedef struct conf_pair CONF_PAIR;
 
  23 typedef struct conf_part CONF_SECTION;
 
  24 typedef struct conf_data CONF_DATA;
 
  27  *  Instead of putting the information into a configuration structure,
 
  28  *  the configuration file routines MAY just parse it directly into
 
  29  *  user-supplied variables.
 
  31 #define PW_TYPE_STRING_PTR      100
 
  32 #define PW_TYPE_BOOLEAN         101
 
  33 #define PW_TYPE_SUBSECTION      102
 
  34 #define PW_TYPE_FILENAME        103
 
  36 typedef struct CONF_PARSER {
 
  38   int type;                     /* PW_TYPE_STRING, etc. */
 
  39   size_t offset;                /* relative pointer within "base" */
 
  40   void *data;                   /* absolute pointer if base is NULL */
 
  41   const char *dflt;             /* default as it would appear in radiusd.conf */
 
  44 /* This preprocessor trick will be useful in initializing CONF_PARSER struct */
 
  45 #define XStringify(x) #x
 
  46 #define Stringify(x) XStringify(x)
 
  48 void            cf_pair_free(CONF_PAIR **cp);
 
  49 int             cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp,
 
  51 void            cf_section_free(CONF_SECTION **cp);
 
  52 int             cf_item_parse(CONF_SECTION *cs, const char *name,
 
  53                               int type, void *data, const char *dflt);
 
  54 int             cf_section_parse(CONF_SECTION *, void *base,
 
  55                                  const CONF_PARSER *variables);
 
  56 void            cf_section_parse_free(CONF_SECTION *cs, void *base);
 
  57 const CONF_PARSER *cf_section_parse_table(CONF_SECTION *cs);
 
  58 CONF_SECTION    *cf_file_read(const char *file);
 
  59 int             cf_file_include(const char *file, CONF_SECTION *cs);
 
  61 CONF_PAIR       *cf_pair_find(const CONF_SECTION *, const char *name);
 
  62 CONF_PAIR       *cf_pair_find_next(const CONF_SECTION *, CONF_PAIR *, const char *name);
 
  63 CONF_SECTION    *cf_section_find(const char *name);
 
  64 CONF_SECTION    *cf_section_sub_find(const CONF_SECTION *, const char *name);
 
  65 CONF_SECTION    *cf_section_sub_find_name2(const CONF_SECTION *, const char *name1, const char *name2);
 
  66 const char      *cf_section_value_find(const CONF_SECTION *, const char *attr);
 
  67 CONF_SECTION    *cf_top_section(CONF_SECTION *cs);
 
  69 void *cf_data_find(CONF_SECTION *, const char *);
 
  70 int cf_data_add(CONF_SECTION *, const char *, void *, void (*)(void *));
 
  72 const char *cf_pair_attr(CONF_PAIR *pair);
 
  73 const char *cf_pair_value(CONF_PAIR *pair);
 
  74 VALUE_PAIR *cf_pairtovp(CONF_PAIR *pair);
 
  75 const char *cf_section_name1(const CONF_SECTION *);
 
  76 const char *cf_section_name2(const CONF_SECTION *);
 
  77 int dump_config(CONF_SECTION *cs);
 
  78 CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
 
  79                                       CONF_SECTION *subsection,
 
  81 CONF_SECTION *cf_section_find_next(CONF_SECTION *section,
 
  82                                    CONF_SECTION *subsection,
 
  84 int cf_section_lineno(CONF_SECTION *section);
 
  85 int cf_pair_lineno(CONF_PAIR *pair);
 
  86 const char *cf_pair_filename(CONF_PAIR *pair);
 
  87 const char *cf_section_filename(CONF_SECTION *section);
 
  88 CONF_ITEM *cf_item_find_next(CONF_SECTION *section, CONF_ITEM *item);
 
  89 int cf_item_is_section(CONF_ITEM *item);
 
  90 int cf_item_is_pair(CONF_ITEM *item);
 
  91 CONF_PAIR *cf_itemtopair(CONF_ITEM *item);
 
  92 CONF_SECTION *cf_itemtosection(CONF_ITEM *item);
 
  93 CONF_ITEM *cf_pairtoitem(CONF_PAIR *cp);
 
  94 CONF_ITEM *cf_sectiontoitem(CONF_SECTION *cs);
 
  95 int cf_section_template(CONF_SECTION *cs, CONF_SECTION *_template);
 
  96 void cf_log_err(CONF_ITEM *ci, const char *fmt, ...)
 
  98                 __attribute__ ((format (printf, 2, 3)))
 
 101 void cf_log_info(CONF_SECTION *cs, const char *fmt, ...)
 
 103                 __attribute__ ((format (printf, 2, 3)))
 
 106 void cf_log_module(CONF_SECTION *cs, const char *fmt, ...)
 
 108                 __attribute__ ((format (printf, 2, 3)))
 
 111 CONF_ITEM *cf_reference_item(const CONF_SECTION *parentcs,
 
 112                              CONF_SECTION *outercs,
 
 114 extern int cf_log_config;
 
 115 extern int cf_log_modules;
 
 117 extern int cf_pair2xml(FILE *fp, CONF_PAIR *cp);
 
 118 extern int cf_section2xml(FILE *fp, CONF_SECTION *cs);
 
 119 extern int cf_pair2file(FILE *fp, CONF_PAIR *cp);
 
 120 extern int cf_section2file(FILE *fp, CONF_SECTION *cs);
 
 125 int cf_section_migrate(CONF_SECTION *dst, CONF_SECTION *src);
 
 127 #endif /* _CONFFILE_H */