extconf.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2007, Digium, Inc.
  5. *
  6. * Steve Murphy <murf@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 External configuration handlers (realtime and static configuration)
  20. * \author Steve Murphy <murf@digium.com>
  21. *
  22. */
  23. #ifndef _ASTERISK_EXTCONF_H
  24. #define _ASTERISK_EXTCONF_H
  25. #if defined(__cplusplus) || defined(c_plusplus)
  26. extern "C" {
  27. #endif
  28. #ifdef NOTYET
  29. /* I'm going to define all the structs mentioned below, to avoid
  30. possible conflicts in declarations that might be introduced,
  31. if we just include the files that define them-- this may be
  32. unnecessary */
  33. struct ast_comment {
  34. struct ast_comment *next;
  35. char cmt[0];
  36. };
  37. struct ast_variable {
  38. char *name;
  39. char *value;
  40. int lineno;
  41. int object; /*!< 0 for variable, 1 for object */
  42. int blanklines; /*!< Number of blanklines following entry */
  43. struct ast_comment *precomments;
  44. struct ast_comment *sameline;
  45. struct ast_variable *next;
  46. char stuff[0];
  47. };
  48. struct ast_category {
  49. char name[80];
  50. int ignored; /*!< do not let user of the config see this category */
  51. int include_level;
  52. struct ast_comment *precomments;
  53. struct ast_comment *sameline;
  54. struct ast_variable *root;
  55. struct ast_variable *last;
  56. struct ast_category *next;
  57. };
  58. struct ast_config {
  59. struct ast_category *root;
  60. struct ast_category *last;
  61. struct ast_category *current;
  62. struct ast_category *last_browse; /*!< used to cache the last category supplied via category_browse */
  63. int include_level;
  64. int max_include_level;
  65. };
  66. /* ================== above: the config world; below, the dialplan world */
  67. /*! \brief A registered application */
  68. struct ast_app {
  69. int (*execute)(struct ast_channel *chan, void *data);
  70. AST_DECLARE_STRING_FIELDS(
  71. AST_STRING_FIELD(synopsis); /*!< Synopsis text for 'show applications' */
  72. AST_STRING_FIELD(description); /*!< Description (help text) for 'show application &lt;name&gt;' */
  73. AST_STRING_FIELD(syntax); /*!< Syntax text for 'core show applications' */
  74. AST_STRING_FIELD(arguments); /*!< Arguments description */
  75. AST_STRING_FIELD(seealso); /*!< See also */
  76. );
  77. enum ast_xmldoc_src docsrc; /*!< Where the documentation come from. */
  78. AST_RWLIST_ENTRY(ast_app) list; /*!< Next app in list */
  79. void *module; /*!< Module this app belongs to */
  80. char name[0]; /*!< Name of the application */
  81. };
  82. /*!
  83. \brief An extension
  84. The dialplan is saved as a linked list with each context
  85. having it's own linked list of extensions - one item per
  86. priority.
  87. */
  88. struct ast_exten {
  89. char *exten; /*!< Extension name */
  90. int matchcid; /*!< Match caller id ? */
  91. const char *cidmatch; /*!< Caller id to match for this extension */
  92. int priority; /*!< Priority */
  93. const char *label; /*!< Label */
  94. struct ast_context *parent; /*!< The context this extension belongs to */
  95. const char *app; /*!< Application to execute */
  96. struct ast_app *cached_app; /*!< Cached location of application */
  97. void *data; /*!< Data to use (arguments) */
  98. void (*datad)(void *); /*!< Data destructor */
  99. struct ast_exten *peer; /*!< Next higher priority with our extension */
  100. const char *registrar; /*!< Registrar */
  101. struct ast_exten *next; /*!< Extension with a greater ID */
  102. char stuff[0];
  103. };
  104. /* from pbx.h */
  105. typedef int (*ast_state_cb_type)(const char *context, const char *exten, enum ast_extension_states state, void *data);
  106. struct ast_timing {
  107. int hastime; /*!< If time construct exists */
  108. unsigned int monthmask; /*!< Mask for month */
  109. unsigned int daymask; /*!< Mask for date */
  110. unsigned int dowmask; /*!< Mask for day of week (mon-sun) */
  111. unsigned int minmask[24]; /*!< Mask for minute */
  112. };
  113. /*! \brief include= support in extensions.conf */
  114. struct ast_include {
  115. const char *name;
  116. const char *rname; /*!< Context to include */
  117. const char *registrar; /*!< Registrar */
  118. int hastime; /*!< If time construct exists */
  119. struct ast_timing timing; /*!< time construct */
  120. struct ast_include *next; /*!< Link them together */
  121. char stuff[0];
  122. };
  123. /*! \brief Switch statement in extensions.conf */
  124. struct ast_sw {
  125. char *name;
  126. const char *registrar; /*!< Registrar */
  127. char *data; /*!< Data load */
  128. int eval;
  129. AST_LIST_ENTRY(ast_sw) list;
  130. char *tmpdata;
  131. char stuff[0];
  132. };
  133. /*! \brief Ignore patterns in dial plan */
  134. struct ast_ignorepat {
  135. const char *registrar;
  136. struct ast_ignorepat *next;
  137. const char pattern[0];
  138. };
  139. /*! \brief An extension context */
  140. struct ast_context {
  141. ast_rwlock_t lock; /*!< A lock to prevent multiple threads from clobbering the context */
  142. struct ast_exten *root; /*!< The root of the list of extensions */
  143. struct ast_context *next; /*!< Link them together */
  144. struct ast_include *includes; /*!< Include other contexts */
  145. struct ast_ignorepat *ignorepats; /*!< Patterns for which to continue playing dialtone */
  146. const char *registrar; /*!< Registrar */
  147. AST_LIST_HEAD_NOLOCK(, ast_sw) alts; /*!< Alternative switches */
  148. ast_mutex_t macrolock; /*!< A lock to implement "exclusive" macros - held whilst a call is executing in the macro */
  149. char name[0]; /*!< Name of the context */
  150. };
  151. #endif
  152. struct ast_config *localized_config_load(const char *filename);
  153. struct ast_config *localized_config_load_with_comments(const char *filename);
  154. struct ast_category *localized_category_get(const struct ast_config *config, const char *category_name);
  155. int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator);
  156. struct ast_context *localized_walk_contexts(struct ast_context *con);
  157. struct ast_exten *localized_walk_context_extensions(struct ast_context *con,
  158. struct ast_exten *exten);
  159. struct ast_exten *localized_walk_extension_priorities(struct ast_exten *exten,
  160. struct ast_exten *priority);
  161. struct ast_include *localized_walk_context_includes(struct ast_context *con,
  162. struct ast_include *inc);
  163. struct ast_sw *localized_walk_context_switches(struct ast_context *con,
  164. struct ast_sw *sw);
  165. void localized_context_destroy(struct ast_context *con, const char *registrar);
  166. int localized_pbx_load_module(void);
  167. /*!
  168. * \version 1.6.1 added tab parameter
  169. * \version 1.6.1 renamed function from localized_context_create to localized_context_find_or_create
  170. */
  171. struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar);
  172. int localized_pbx_builtin_setvar(struct ast_channel *chan, const void *data);
  173. int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar);
  174. int localized_context_add_switch2(struct ast_context *con, const char *value,
  175. const char *data, int eval, const char *registrar);
  176. int localized_context_add_include2(struct ast_context *con, const char *value,
  177. const char *registrar);
  178. int localized_add_extension2(struct ast_context *con,
  179. int replace, const char *extension, int priority, const char *label, const char *callerid,
  180. const char *application, void *data, void (*datad)(void *),
  181. const char *registrar);
  182. /*!
  183. * \version 1.6.1 added tab parameter
  184. */
  185. void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar);
  186. int localized_context_verify_includes(struct ast_context *con);
  187. void localized_use_conf_dir(void);
  188. void localized_use_local_dir(void);
  189. #ifndef _ASTERISK_PBX_H
  190. /*!
  191. * When looking up extensions, we can have different requests
  192. * identified by the 'action' argument, as follows.
  193. * Note that the coding is such that the low 4 bits are the
  194. * third argument to extension_match_core.
  195. */
  196. enum ext_match_t {
  197. E_MATCHMORE = 0x00, /* extension can match but only with more 'digits' */
  198. E_CANMATCH = 0x01, /* extension can match with or without more 'digits' */
  199. E_MATCH = 0x02, /* extension is an exact match */
  200. E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */
  201. E_SPAWN = 0x12, /* want to spawn an extension. Requires exact match */
  202. E_FINDLABEL = 0x22 /* returns the priority for a given label. Requires exact match */
  203. };
  204. #define AST_PBX_MAX_STACK 128
  205. /* request and result for pbx_find_extension */
  206. struct pbx_find_info {
  207. #if 0
  208. const char *context;
  209. const char *exten;
  210. int priority;
  211. #endif
  212. char *incstack[AST_PBX_MAX_STACK]; /* filled during the search */
  213. int stacklen; /* modified during the search */
  214. int status; /* set on return */
  215. struct ast_switch *swo; /* set on return */
  216. const char *data; /* set on return */
  217. const char *foundcontext; /* set on return */
  218. };
  219. #define STATUS_NO_CONTEXT 1
  220. #define STATUS_NO_EXTENSION 2
  221. #define STATUS_NO_PRIORITY 3
  222. #define STATUS_NO_LABEL 4
  223. #define STATUS_SUCCESS 5
  224. #endif
  225. struct ast_exten *localized_find_extension(struct ast_context *bypass,
  226. struct pbx_find_info *q,
  227. const char *context,
  228. const char *exten,
  229. int priority,
  230. const char *label,
  231. const char *callerid,
  232. enum ext_match_t action);
  233. #if defined(__cplusplus) || defined(c_plusplus)
  234. }
  235. #endif
  236. #endif /* _ASTERISK_PBX_H */