Copyright (C) 2000-2012 |
Manpages READ_CONFIGSection: C Library Functions (3)Updated: 02 Mar 1999 Index Return to Main Contents NAMEregister_config_handler, register_premib_handler unregister_config_handler, register_mib_handlers, read_configs, read_premib_configs, config_perror, config_pwarn - read_config functionsSYNOPSIS#include <read_config.h>
struct config_line *
struct config_line *
struct config_line *
void unregister_config_handler(char *filePrefix,
void read_config_print_usage(char *lead) void read_configs(void) void read_premib_configs(void) DESCRIPTIONThe functions are a fairly extensible system of parsing various configuration files at the run time of an application. The configuration file flow is broken into the following phases:
The idea is that the calling application is able to register handlers for certain tokens specified in certain types of files. The read_configs() function can then be called to look for all the files that it has registrations for, find the first word on each line, and pass the remainder to the appropriately registered handler. Token HandlersHandler functions should be of the following type:
The function will be called with two arguments, the first being the token that triggered the call to this function (which would be one of the tokens that the function had been registered for), and the second being the remainder of the configuration file line beyond the white space following the token. Resource Freeing HandlersIf the read_config configuration system is called a second time to re-read the configuration files, the optional second handler freefunc will be called, if registered as non-NULL, to free any resources and reset its notions to defaults before the config handlers are called again. It is not called with any arguments. Registering A Handler
Help StringsThe usageLine token passed to the register_config_handler(), and similar calls, is used to display help information when the read_config_print_usage() function is called. This function is used by all of the applications when the -H flag is passed to the command line. It prints a summary of all of the configuration file lines, and the associated files, that the configuration system understands. The usageLine parameter should be a list of arguments expected after the token, and not a lengthy description (which should go into a manual page instead). The lead prefix will be prepended to each line that the function prints to stderr, where it displays its output. The init_snmp() function should be called before the read_config_print_usage() function is called, so that the library can register its configuration file directives as well for the read_config_print_usage() function to display. Reading Configuration Files
If the init_snmp() function is used, none of the following functions need to be called by the application:
Configuration Files ReadThe configuration files read are found by using the colon separated SNMPCONFPATH environment variable (or its default value, which will be /etc/snmp, followed by /usr/lib/snmp, followed by $HOME/.snmp) and reading in the files found that match both the prefix registered and the two suffixes .conf and .local.conf. The idea behind the two different suffixes is that the first file can be rdisted across a large number of machines and the second file can be used to configure local settings for one particular machine. They do not need to be present, and will only be read if found. Error Handling FunctionsThe two functions config_pwarn() and config_perror() both take an error string as an argument and print it to stderr along with the file and line number that caused the error. A call to the second function will also force read_configs() to eventually return with an error code indicating to it's calling function that it should abort the operation of the application. ENVIRONMENT VARIABLES
SEE ALSOmib_api(3), snmp_api(3)
Index
This document was created by man2html, using the manual pages. Time: 10:02:02 GMT, April 18, 2024 |