Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

config.h

Go to the documentation of this file.
00001 /* 00002 * Asterisk -- A telephony toolkit for Linux. 00003 * 00004 * Configuration File Parser 00005 * 00006 * Copyright (C) 1999, Mark Spencer 00007 * 00008 * Mark Spencer <markster@linux-support.net> 00009 * 00010 * This program is free software, distributed under the terms of 00011 * the GNU General Public License 00012 */ 00013 00014 #ifndef _ASTERISK_CONFIG_H 00015 #define _ASTERISK_CONFIG_H 00016 00017 #if defined(__cplusplus) || defined(c_plusplus) 00018 extern "C" { 00019 #endif 00020 00021 struct ast_config; 00022 00023 struct ast_comment { 00024 struct ast_comment *next; 00025 char cmt[0]; 00026 }; 00027 00028 struct ast_variable { 00029 char *name; 00030 char *value; 00031 int lineno; 00032 int object; /* 0 for variable, 1 for object */ 00033 int blanklines; /* Number of blanklines following entry */ 00034 struct ast_comment *precomments; 00035 struct ast_comment *sameline; 00036 struct ast_variable *next; 00037 }; 00038 00039 //! Load a config file 00040 /*! 00041 * \param configfile path of file to open. If no preceding '/' character, path is considered relative to AST_CONFIG_DIR 00042 * Create a config structure from a given configuration file. 00043 * Returns NULL on error, or an ast_config data structure on success 00044 */ 00045 struct ast_config *ast_load(char *configfile); 00046 00047 //! Removes a config 00048 /*! 00049 * \param config config data structure associated with the config. 00050 * Free memory associated with a given config 00051 * Returns nothing 00052 */ 00053 void ast_destroy(struct ast_config *config); 00054 00055 //! Goes through categories 00056 /*! 00057 * \param config Which config file you wish to "browse" 00058 * \param prev A pointer to a previous category. 00059 * This funtion is kind of non-intuitive in it's use. To begin, one passes NULL as the second arguement. It will return a pointer to the string of the first category in the file. From here on after, one must then pass the previous usage's return value as the second pointer, and it will return a pointer to the category name afterwards. Note: If you manually strcpy a string into a character array and pass it thinking it will return your category, it will not; the comparisons are not done doing strcmp, they are done by checking whether the value of the string POINTER is the same. 00060 * Returns a category on success, or NULL on failure/no-more-categories 00061 */ 00062 char *ast_category_browse(struct ast_config *config, char *prev); 00063 00064 //! Goes through variables 00065 /*! 00066 * Somewhat similar in intent as the ast_category_browse. The category MUST be an actual pointer to an actual category (such as one obtained by using ast_category_browse()). 00067 * List variables of config file 00068 * Returns ast_variable list on success, or NULL on failure 00069 */ 00070 struct ast_variable *ast_variable_browse(struct ast_config *config, char *category); 00071 00072 //! Gets a variable 00073 /*! 00074 * \param config which (opened) config to use 00075 * \param category category under which the variable lies (must be a pointer to the category, such as one given by ast_category_browse) 00076 * \param value which variable you wish to get the data for 00077 * Goes through a given config file in the given category and searches for the given variable 00078 * Returns the variable value on success, or NULL if unable to find it. 00079 * Retrieve a specific variable */ 00080 char *ast_variable_retrieve(struct ast_config *config, char *category, char *value); 00081 00082 //! Make sure something is true 00083 /*! 00084 * Determine affermativeness of a boolean value. 00085 * This function checks to see whether a string passed to it is an indication of an affirmitave value. It checks to see if the string is "yes", "true", "y", "t", and "1". 00086 * Returns 0 if the value of s is a NULL pointer, 0 on "truth", and -1 on falsehood. 00087 */ 00088 int ast_true(char *val); 00089 00090 //! Make sure something is false 00091 /*! 00092 * Determine falseness of a boolean value. 00093 * This function checks to see whether a string passed to it is an indication of a negatirve value. It checks to see if the string is "no", "false", "n", "f", and "0". 00094 * Returns 0 if the value of s is a NULL pointer, 0 on "truth", and -1 on falsehood. 00095 */ 00096 int ast_false(char *val); 00097 00098 //! Check for category duplicates 00099 /*! 00100 * \param config which config to use 00101 * \param category_name name of the category you're looking for 00102 * This will search through the categories within a given config file and search for a match. The passed category_name can be a regular string (as opposed to a pointer of an existent string, lol) 00103 * Browse config structure and check for category duplicity Return non-zero if found */ 00104 int ast_category_exist(struct ast_config *config, char *category_name); 00105 00106 /* These are only in the config engine at this point */ 00107 struct ast_variable *ast_variable_append_modify(struct ast_config *cfg, char *category, char *variable, char *newvalue, int newcat, int newvar, int move); 00108 00109 int ast_category_delete(struct ast_config *cfg, char *category); 00110 int ast_variable_delete(struct ast_config *cfg, char *category, char *variable, char *value); 00111 int ast_save(char *filename, struct ast_config *cfg, char *generator); 00112 00113 #if defined(__cplusplus) || defined(c_plusplus) 00114 } 00115 #endif 00116 00117 00118 00119 #endif

Generated on Sat Jun 12 16:40:57 2004 for Asterisk by doxygen 1.3.7