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

configparser.c File Reference

configuration parser functions and datatypes More...

#include "config.h"
#include "defines.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/uio.h>
#include <pwd.h>
#include "utils.h"
#include "hashlib.h"
#include "configparser.h"

Go to the source code of this file.

Functions

t_arrayget_conf_file (const u_char **which, size_t llen)
int parse_args (u_char *line, u_char ***args, int lnum)
int read_config (t_configfile *conf, t_take_default deflt)
int handle_command (t_configfile *cfile, t_conf_opt *opt, u_char **args, int argnum)
int add_module (t_configfile *cfile, t_conf_opt *opt, u_char **args, int argnum)
void cfg_cleanup (t_configuration *cfg)
void cfg_destroy_module (void *element)
void cleanup_modules (t_array *modules)
t_name_valuecfg_get_value (t_configuration *cfg, const u_char *name)
void cfg_init_file (t_configfile *conf, u_char *filename)
int cfg_register_options (t_configfile *conf, t_conf_opt *opts)
void cfg_cleanup_file (t_configfile *conf)

Variables

t_configuration fo_default_conf = { NULL, NULL, 0 }
t_configuration fo_server_conf = { NULL, NULL, 0 }
t_configuration fo_view_conf = { NULL, NULL, 0 }
t_configuration fo_arcview_conf = { NULL, NULL, 0 }
t_configuration fo_post_conf = { NULL, NULL, 0 }
t_array Modules [MOD_MAX+1]
t_conf_opt default_options []
t_conf_opt fo_view_options []
t_conf_opt fo_post_options []
t_conf_opt fo_server_options []
t_conf_opt fo_arcview_options []


Detailed Description

configuration parser functions and datatypes

Author:
Christian Kruse, <cjk@wwwtech.de>
This file contains the configuration parser used by this project

Definition in file configparser.c.


Function Documentation

int add_module t_configfile cfile,
t_conf_opt opt,
u_char **  args,
int  argnum
 

This function adds a plugin into the program space

Parameters:
cfile The configuration file structure
opt The configuration option entry
args The argument list
argnum The number of arguments
Returns:
0 on success, any other value on error

Definition at line 501 of file configparser.c.

void cfg_cleanup t_configuration cfg  ) 
 

This function cleans up a configuration file structure

Parameters:
cfg The configuration file structure

Definition at line 565 of file configparser.c.

void cfg_cleanup_file t_configfile conf  ) 
 

This function cleans up a configuration file structure

Parameters:
conf The configuration file structure

Definition at line 681 of file configparser.c.

void cfg_destroy_module void *  element  ) 
 

destructor function for the modules array

Parameters:
element An array element

Definition at line 585 of file configparser.c.

t_name_value* cfg_get_value t_configuration cfg,
const u_char *  name
 

This function returns a configuration entry

Parameters:
cfg The configuration file structure
name The configuration entry name
Returns:
NULL if not found, the t_name_value structure on success

Definition at line 620 of file configparser.c.

void cfg_init_file t_configfile conf,
u_char *  filename
 

This function initializes a configuration file structure

Parameters:
conf The configuration file structure
filename The configuration file filename

Definition at line 642 of file configparser.c.

int cfg_register_options t_configfile conf,
t_conf_opt opts
 

This function registeres configuration options in the configuration file structure

Parameters:
conf The configuration file structure
opts The configuration options

Definition at line 657 of file configparser.c.

void cleanup_modules t_array modules  ) 
 

This function cleans up the modules structure

Parameters:
modules The modules array

Definition at line 603 of file configparser.c.

t_array* get_conf_file const u_char **  which,
size_t  llen
 

This function expects a list of config names (e.g. fo_default, fo_view, fo_post) and its length. It uses the CF_CONF_DIR environment variable to decide where the config files can be found. It returns successfully an array, when all wanted files could be found. It returns NULL if one of them could not be found.

Parameters:
which The list of wanted configuration files
llen The length of the list
Returns:
An array containing the full path to the config files in the order given by the list

Definition at line 226 of file configparser.c.

int handle_command t_configfile cfile,
t_conf_opt opt,
u_char **  args,
int  argnum
 

This function handles a configuration entry.

Parameters:
cfile The configuration file structure
opt The configuration option entry
args The argument list
argnum The length of the argument list
Returns:
0 on success, any other value on error

Definition at line 481 of file configparser.c.

int parse_args u_char *  line,
u_char ***  args,
int  lnum
 

This function parses the arguments of a configuration directive Parameters:

Parameters:
line The line in the configuration file
args A reference to a u_char ** pointer
lnum The line number
Returns:
0 on success, error code on failure

Definition at line 277 of file configparser.c.

int read_config t_configfile conf,
t_take_default  deflt
 

This function parses a configuration file.

Parameters:
conf The configuration file structure
deflt The default callback function
Returns:
0 on success, a value unequal 0 on failure

Definition at line 348 of file configparser.c.


Variable Documentation

t_conf_opt default_options[]
 

The default configuration options

Definition at line 62 of file configparser.c.

t_configuration fo_arcview_conf = { NULL, NULL, 0 }
 

The configuration data of the archive viewer

Definition at line 54 of file configparser.c.

t_conf_opt fo_arcview_options[]
 

Initial value:

 {
  { "<Filters>",            NULL,             NULL },
  { "AddFilter",            add_module,       &Modules        },
  { "</Filters>",           NULL,             NULL },

  { "<General>",            NULL,             NULL },
  { "SortYearList",         handle_command,   &fo_arcview_conf },
  { "SortMonthList",        handle_command,   &fo_arcview_conf },
  { "DateFormatList",       handle_command,   &fo_arcview_conf },
  { "</General>",           NULL,             NULL },

  { "<Templates>",             NULL,             NULL },
  { "FatalTemplate",           handle_command,   &fo_arcview_conf },
  { "YearsTemplate",           handle_command,   &fo_arcview_conf },
  { "YearListTemplate",        handle_command,   &fo_arcview_conf },
  { "MonthsTemplate",          handle_command,   &fo_arcview_conf },
  { "MonthsListTemplate",      handle_command,   &fo_arcview_conf },
  { "ThreadListMonthTemplate", handle_command,   &fo_arcview_conf },
  { "ThreadTemplate",          handle_command,   &fo_arcview_conf },
  { "ThreadListTemplate",      handle_command,   &fo_arcview_conf },
  { "PerThreadTemplate",       handle_command,   &fo_arcview_conf },
  { "UpDownTemplate",          handle_command,   &fo_arcview_conf },
  { "</Templates>",            NULL,             NULL },

  { NULL,                      NULL,             NULL            }
}
The archiv viewer configuration options

Definition at line 186 of file configparser.c.

t_configuration fo_default_conf = { NULL, NULL, 0 }
 

The configuration data of the default configuration

Definition at line 51 of file configparser.c.

t_configuration fo_post_conf = { NULL, NULL, 0 }
 

The configuration data of the archive viewer

Definition at line 55 of file configparser.c.

t_conf_opt fo_post_options[]
 

Initial value:

 {
  {  "<General>",                 NULL,             NULL          },
  {  "AddFilter",                 add_module,       &Modules      },
  {  "PostingUrl",                handle_command,   &fo_post_conf },
  {  "FieldConfig",               handle_command,   &fo_post_conf },
  {  "FieldNeeded",               handle_command,   &fo_post_conf },
  {  "RedirectOnPost",            handle_command,   &Modules      },
  {  "</General>",                NULL,             NULL          },
  {  "<Images>",                  NULL,             NULL          },
  {  "Image",                     handle_command,   &fo_post_conf },
  {  "</Images>",                 NULL,             NULL          },
  {  "<Templates>",               NULL,             NULL          },
  {  "ThreadTemplate",            handle_command,   &fo_post_conf },
  {  "FatalTemplate",             handle_command,   &fo_post_conf },
  {  "OkTemplate",                handle_command,   &fo_post_conf },
  {  "</Templates>",              handle_command,   &fo_post_conf },
  {  NULL,                        NULL,             NULL          }
}
The posting configuration options

Definition at line 140 of file configparser.c.

t_configuration fo_server_conf = { NULL, NULL, 0 }
 

The configuration data of the server

Definition at line 52 of file configparser.c.

t_conf_opt fo_server_options[]
 

Initial value:

 {
  { "<General>",            NULL,             NULL },
  { "SortThreads",          handle_command,   &fo_server_conf },
  { "SortMessages",         handle_command,   &fo_server_conf },
  { "RunArchiver",          handle_command,   &fo_server_conf },
  { "ErrorLog",             handle_command,   &fo_server_conf },
  { "StdLog",               handle_command,   &fo_server_conf },
  { "PIDFile",              handle_command,   &fo_server_conf },
  { "</General>",           NULL,             NULL },

  { "<Archiving>",          NULL,             NULL },
  { "ArchiveOnVote",        handle_command,   &fo_server_conf },
  { "MainFileMaxBytes",     handle_command,   &fo_server_conf },
  { "MainFileMaxPostings",  handle_command,   &fo_server_conf },
  { "MainFileMaxThreads",   handle_command,   &fo_server_conf },
  { "</Archiving>",         NULL,             NULL },

  { "<Filters>",            handle_command,   &fo_server_conf },
  { "AddFilter",            add_module,       &Modules        },
  { "</Filters>",           NULL,             NULL },

  { NULL,                   NULL,             NULL            }
}
The server configuration options

Definition at line 162 of file configparser.c.

t_configuration fo_view_conf = { NULL, NULL, 0 }
 

The configuration data of the forum viewer

Definition at line 53 of file configparser.c.

t_conf_opt fo_view_options[]
 

The client configuration options

Definition at line 104 of file configparser.c.

t_array Modules[MOD_MAX+1]
 

The modules array

Definition at line 57 of file configparser.c.


Generated on Sun Apr 25 16:37:39 2004 for Classic Forum by doxygen 1.3.5