⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.h

📁 asterisk 是一个很有知名度开源软件
💻 H
📖 第 1 页 / 共 2 页
字号:
 * This function is used to create a parameter in realtime configuration space. * */int ast_store_realtime(const char *family, ...);/*!  * \brief Destroy realtime configuration  * \param family which family/config to be destroyed * \param keyfield which field to use as the key * \param lookup which value to look for in the key field to match the entry. * This function is used to destroy an entry in realtime configuration space. * Additional params are used as keys. * */int ast_destroy_realtime(const char *family, const char *keyfield, const char *lookup, ...);/*!  * \brief Check if realtime engine is configured for family  * \param family which family/config to be checked * \return 1 if family is configured in realtime and engine exists*/int ast_check_realtime(const char *family);/*! \brief Check if there's any realtime engines loaded */int ast_realtime_enabled(void);/*! \brief Free variable list  * \param var the linked list of variables to free * This function frees a list of variables. */void ast_variables_destroy(struct ast_variable *var);/*! \brief Register config engine */int ast_config_engine_register(struct ast_config_engine *newconfig);/*! \brief Deegister config engine */int ast_config_engine_deregister(struct ast_config_engine *del);int register_config_cli(void);int read_config_maps(void);struct ast_config *ast_config_new(void);struct ast_category *ast_config_get_current_category(const struct ast_config *cfg);void ast_config_set_current_category(struct ast_config *cfg, const struct ast_category *cat);const char *ast_config_option(struct ast_config *cfg, const char *cat, const char *var);struct ast_category *ast_category_new(const char *name, const char *in_file, int lineno);void ast_category_append(struct ast_config *config, struct ast_category *cat);/*!  * \brief Inserts new category * \param config which config to use * \param cat newly created category to insert * \param match which category to insert above * This function is used to insert a new category above another category * matching the match parameter. */void ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match);int ast_category_delete(struct ast_config *cfg, const char *category);int ast_category_empty(struct ast_config *cfg, const char *category);void ast_category_destroy(struct ast_category *cat);struct ast_variable *ast_category_detach_variables(struct ast_category *cat);void ast_category_rename(struct ast_category *cat, const char *name);struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename);struct ast_config_include *ast_include_new(struct ast_config *conf, const char *from_file, const char *included_file, int is_exec, const char *exec_file, int from_lineno, char *real_included_file_name, int real_included_file_name_size);struct ast_config_include *ast_include_find(struct ast_config *conf, const char *included_file);void ast_include_rename(struct ast_config *conf, const char *from_file, const char *to_file);void ast_variable_append(struct ast_category *category, struct ast_variable *variable);void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line);int ast_variable_delete(struct ast_category *category, const char *variable, const char *match, const char *line);int ast_variable_update(struct ast_category *category, const char *variable, 						const char *value, const char *match, unsigned int object);int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator);struct ast_config *ast_config_internal_load(const char *configfile, struct ast_config *cfg, struct ast_flags flags, const char *suggested_incl_file, const char *who_asked);/*! \brief Support code to parse config file arguments * * The function ast_parse_arg() provides a generic interface to parse * strings (e.g. numbers, network addresses and so on) in a flexible * way, e.g. by doing proper error and bound checks, provide default * values, and so on. * The function (described later) takes a string as an argument, * a set of flags to specify the result format and checks to perform, * a pointer to the result, and optionally some additional arguments. * It returns 0 on success, != 0 otherwise. * */enum ast_parse_flags {	/* low 4 bits of flags are used for the operand type */	PARSE_TYPE	=	0x000f,	/* numeric types, with optional default value and bound checks.	 * Additional arguments are passed by value.	 */	PARSE_INT32	= 	0x0001,	PARSE_UINT32	= 	0x0002,	PARSE_DOUBLE	= 	0x0003,#if 0	/* not supported yet */	PARSE_INT16	= 	0x0004,	PARSE_UINT16	= 	0x0005,#endif	/* Returns a struct sockaddr_in, with optional default value	 * (passed by reference) and port handling (accept, ignore,	 * require, forbid). The format is 'host.name[:port]'	 */	PARSE_INADDR	= 	0x000f,	/* Other data types can be added as needed */	/* If PARSE_DEFAULT is set, next argument is a default value	 * which is returned in case of error. The argument is passed	 * by value in case of numeric types, by reference in other cases. 	 */	PARSE_DEFAULT	=	0x0010,	/* assign default on error */	/* Request a range check, applicable to numbers. Two additional	 * arguments are passed by value, specifying the low-high end of	 * the range (inclusive). An error is returned if the value	 * is outside or inside the range, respectively.	 */	PARSE_IN_RANGE =	0x0020,	/* accept values inside a range */	PARSE_OUT_RANGE =	0x0040,	/* accept values outside a range */	/* Port handling, for sockaddr_in. accept/ignore/require/forbid	 * port number after the hostname or address.	 */	PARSE_PORT_MASK =	0x0300, /* 0x000: accept port if present */	PARSE_PORT_IGNORE =	0x0100, /* 0x100: ignore port if present */	PARSE_PORT_REQUIRE =	0x0200, /* 0x200: require port number */	PARSE_PORT_FORBID =	0x0300, /* 0x100: forbid port number */};/*! \brief The argument parsing routine. * \param arg the string to parse. It is not modified. * \param flags combination of ast_parse_flags to specify the *	return type and additional checks. * \param result pointer to the result. NULL is valid here, and can *	be used to perform only the validity checks. * \param ... extra arguments are required according to flags. * \retval 0 in case of success, != 0 otherwise. * \retval result returns the parsed value in case of success, *	the default value in case of error, or it is left unchanged *	in case of error and no default specified. Note that in certain *	cases (e.g. sockaddr_in, with multi-field return values) some *	of the fields in result may be changed even if an error occurs. * * Examples of use: *	ast_parse_arg("223", PARSE_INT32|PARSE_IN_RANGE, *		&a, -1000, 1000);  *              returns 0, a = 223 *	ast_parse_arg("22345", PARSE_INT32|PARSE_IN_RANGE|PARSE_DEFAULT, *		&a, 9999, 10, 100); *              returns 1, a = 9999 *      ast_parse_arg("22345ssf", PARSE_UINT32|PARSE_IN_RANGE, &b, 10, 100); *		returns 1, b unchanged *      ast_parse_arg("www.foo.biz:44", PARSE_INADDR, &sa); *		returns 0, sa contains address and port *      ast_parse_arg("www.foo.biz", PARSE_INADDR|PARSE_PORT_REQUIRE, &sa); *		returns 1 because port is missing, sa contains address */int ast_parse_arg(const char *arg, enum ast_parse_flags flags,        void *result, ...);/* * Parsing config file options in C is slightly annoying because we cannot use * string in a switch() statement, yet we need a similar behaviour, with many * branches and a break on a matching one. * The following somehow simplifies the job: we create a block using * the 	CV_START and CV_END macros, and then within the block we can run * actions such as "if (condition) { body; break; }" * Additional macros are present to run simple functions (e.g. ast_copy_string) * or to pass arguments to ast_parse_arg() * * As an example:	CV_START(v->name, v->value);	// start the block	CV_STR("foo", x_foo);		// static string	CV_DSTR("bar", y_bar);		// malloc'ed string	CV_F("bar", ...);		// call a generic function	CV_END;				// end the block *//*! \brief the macro to open a block for variable parsing */#define CV_START(__in_var, __in_val) 		\	do {					\		const char *__var = __in_var;	\		const char *__val = __in_val;/*! \brief close a variable parsing block */#define	CV_END			} while (0)/*! \brief call a generic function if the name matches. */#define	CV_F(__pattern, __body)	if (!strcasecmp((__var), __pattern)) { __body; break; }/*! \brief helper macros to assign the value to a BOOL, UINT, static string and * dynamic string */#define	CV_BOOL(__x, __dst)	CV_F(__x, (__dst) = ast_true(__val) )#define CV_UINT(__x, __dst)	CV_F(__x, (__dst) = strtoul(__val, NULL, 0) )#define CV_STR(__x, __dst)	CV_F(__x, ast_copy_string(__dst, __val, sizeof(__dst)))#define CV_DSTR(__x, __dst)	CV_F(__x, if (__dst) ast_free(__dst); __dst = ast_strdup(__val))#define CV_STRFIELD(__x, __obj, __field) CV_F(__x, ast_string_field_set(__obj, __field, __val))#if defined(__cplusplus) || defined(c_plusplus)}#endif#endif /* _ASTERISK_CONFIG_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -