chanvars.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2005, Digium, Inc.
  5. *
  6. * Mark Spencer <markster@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*! \file
  19. * \brief Channel Variables
  20. */
  21. #ifndef _ASTERISK_CHANVARS_H
  22. #define _ASTERISK_CHANVARS_H
  23. #include "asterisk/linkedlists.h"
  24. struct ast_var_t {
  25. AST_LIST_ENTRY(ast_var_t) entries;
  26. char *value;
  27. char name[0];
  28. };
  29. AST_LIST_HEAD_NOLOCK(varshead, ast_var_t);
  30. struct varshead *ast_var_list_create(void);
  31. void ast_var_list_destroy(struct varshead *head);
  32. #ifdef __AST_DEBUG_MALLOC
  33. struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function);
  34. #define ast_var_assign(a,b) _ast_var_assign(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
  35. #else
  36. struct ast_var_t *ast_var_assign(const char *name, const char *value);
  37. #endif
  38. void ast_var_delete(struct ast_var_t *var);
  39. const char *ast_var_name(const struct ast_var_t *var);
  40. const char *ast_var_full_name(const struct ast_var_t *var);
  41. const char *ast_var_value(const struct ast_var_t *var);
  42. char *ast_var_find(const struct varshead *head, const char *name);
  43. struct varshead *ast_var_list_clone(struct varshead *head);
  44. #define AST_VAR_LIST_TRAVERSE(head, var) AST_LIST_TRAVERSE(head, var, entries)
  45. static inline void AST_VAR_LIST_INSERT_TAIL(struct varshead *head, struct ast_var_t *var) {
  46. if (var) {
  47. AST_LIST_INSERT_TAIL(head, var, entries);
  48. }
  49. }
  50. static inline void AST_VAR_LIST_INSERT_HEAD(struct varshead *head, struct ast_var_t *var) {
  51. if (var) {
  52. AST_LIST_INSERT_HEAD(head, var, entries);
  53. }
  54. }
  55. #endif /* _ASTERISK_CHANVARS_H */