conf2ael.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  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. /*
  19. *
  20. * Reverse compile extensions.conf code into prototype AEL code
  21. *
  22. */
  23. /*** MODULEINFO
  24. <depend>res_ael_share</depend>
  25. <support_level>extended</support_level>
  26. ***/
  27. #include "asterisk.h"
  28. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  29. #include "asterisk/paths.h" /* CONFIG_DIR */
  30. #include <locale.h>
  31. #include <ctype.h>
  32. #if !defined(SOLARIS) && !defined(__CYGWIN__)
  33. #include <err.h>
  34. #endif
  35. #include <regex.h>
  36. #include "asterisk.h"
  37. #include "asterisk/pbx.h"
  38. #include "asterisk/ast_expr.h"
  39. #include "asterisk/channel.h"
  40. #include "asterisk/chanvars.h"
  41. #include "asterisk/module.h"
  42. #include "asterisk/app.h"
  43. #include "asterisk/config.h"
  44. #include "asterisk/options.h"
  45. #include "asterisk/callerid.h"
  46. #include "asterisk/lock.h"
  47. #include "asterisk/hashtab.h"
  48. #include "asterisk/ael_structs.h"
  49. #include "asterisk/devicestate.h"
  50. #include "asterisk/stringfields.h"
  51. #include "asterisk/pval.h"
  52. #include "asterisk/extconf.h"
  53. struct ast_flags ast_compat = { 7 };
  54. const char *ast_config_AST_CONFIG_DIR = "/etc/asterisk"; /* placeholder */
  55. void get_start_stop(unsigned int *word, int bitsperword, int totalbits, int *start, int *end);
  56. int all_bits_set(unsigned int *word, int bitsperword, int totalbits);
  57. extern char *days[];
  58. extern char *months[];
  59. char *config = "extensions.conf";
  60. /*
  61. static char *registrar = "conf2ael";
  62. static char userscontext[AST_MAX_EXTENSION] = "default";
  63. static int static_config = 0;
  64. static int write_protect_config = 1;
  65. static int autofallthrough_config = 0;
  66. static int clearglobalvars_config = 0;
  67. char ast_config_AST_SYSTEM_NAME[20] = ""; */
  68. /*! Go no deeper than this through includes (not counting loops) */
  69. #define AST_PBX_MAX_STACK 128
  70. /* static AST_RWLIST_HEAD_STATIC(acf_root, ast_custom_function); */
  71. //extern char ast_config_AST_CONFIG_DIR[PATH_MAX];
  72. int option_debug = 0;
  73. int option_verbose = 0;
  74. void ast_register_file_version(const char *file, const char *version);
  75. void ast_register_file_version(const char *file, const char *version)
  76. {
  77. }
  78. void ast_unregister_file_version(const char *file);
  79. void ast_unregister_file_version(const char *file)
  80. {
  81. }
  82. #if !defined(LOW_MEMORY)
  83. int ast_add_profile(const char *x, uint64_t scale) { return 0;}
  84. #endif
  85. /* Our own version of ast_log, since the expr parser uses it. -- stolen from utils/check_expr.c */
  86. void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf,5,6)));
  87. void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
  88. {
  89. va_list vars;
  90. va_start(vars,fmt);
  91. printf("LOG: lev:%d file:%s line:%d func: %s ",
  92. level, file, line, function);
  93. vprintf(fmt, vars);
  94. fflush(stdout);
  95. va_end(vars);
  96. }
  97. /* stolen from pbx.c */
  98. struct ast_context;
  99. struct ast_app;
  100. #ifdef LOW_MEMORY
  101. #define EXT_DATA_SIZE 256
  102. #else
  103. #define EXT_DATA_SIZE 8192
  104. #endif
  105. #define SWITCH_DATA_LENGTH 256
  106. #define VAR_BUF_SIZE 4096
  107. #define VAR_NORMAL 1
  108. #define VAR_SOFTTRAN 2
  109. #define VAR_HARDTRAN 3
  110. #define BACKGROUND_SKIP (1 << 0)
  111. #define BACKGROUND_NOANSWER (1 << 1)
  112. #define BACKGROUND_MATCHEXTEN (1 << 2)
  113. #define BACKGROUND_PLAYBACK (1 << 3)
  114. /*!
  115. \brief ast_exten: An extension
  116. The dialplan is saved as a linked list with each context
  117. having it's own linked list of extensions - one item per
  118. priority.
  119. */
  120. struct ast_exten {
  121. char *exten; /*!< Extension name */
  122. int matchcid; /*!< Match caller id ? */
  123. const char *cidmatch; /*!< Caller id to match for this extension */
  124. int priority; /*!< Priority */
  125. const char *label; /*!< Label */
  126. struct ast_context *parent; /*!< The context this extension belongs to */
  127. const char *app; /*!< Application to execute */
  128. struct ast_app *cached_app; /*!< Cached location of application */
  129. void *data; /*!< Data to use (arguments) */
  130. void (*datad)(void *); /*!< Data destructor */
  131. struct ast_exten *peer; /*!< Next higher priority with our extension */
  132. const char *registrar; /*!< Registrar */
  133. struct ast_exten *next; /*!< Extension with a greater ID */
  134. char stuff[0];
  135. };
  136. /*! \brief ast_include: include= support in extensions.conf */
  137. struct ast_include {
  138. const char *name;
  139. const char *rname; /*!< Context to include */
  140. const char *registrar; /*!< Registrar */
  141. int hastime; /*!< If time construct exists */
  142. struct ast_timing timing; /*!< time construct */
  143. struct ast_include *next; /*!< Link them together */
  144. char stuff[0];
  145. };
  146. /*! \brief ast_sw: Switch statement in extensions.conf */
  147. struct ast_sw {
  148. char *name;
  149. const char *registrar; /*!< Registrar */
  150. char *data; /*!< Data load */
  151. int eval;
  152. AST_LIST_ENTRY(ast_sw) list;
  153. char *tmpdata;
  154. char stuff[0];
  155. };
  156. /*! \brief ast_ignorepat: Ignore patterns in dial plan */
  157. struct ast_ignorepat {
  158. const char *registrar;
  159. struct ast_ignorepat *next;
  160. const char pattern[0];
  161. };
  162. /*! \brief ast_context: An extension context */
  163. struct ast_context {
  164. ast_rwlock_t lock; /*!< A lock to prevent multiple threads from clobbering the context */
  165. struct ast_exten *root; /*!< The root of the list of extensions */
  166. struct ast_context *next; /*!< Link them together */
  167. struct ast_include *includes; /*!< Include other contexts */
  168. struct ast_ignorepat *ignorepats; /*!< Patterns for which to continue playing dialtone */
  169. const char *registrar; /*!< Registrar */
  170. AST_LIST_HEAD_NOLOCK(, ast_sw) alts; /*!< Alternative switches */
  171. ast_mutex_t macrolock; /*!< A lock to implement "exclusive" macros - held whilst a call is executing in the macro */
  172. char name[0]; /*!< Name of the context */
  173. };
  174. /*! \brief ast_app: A registered application */
  175. struct ast_app {
  176. int (*execute)(struct ast_channel *chan, void *data);
  177. const char *synopsis; /*!< Synopsis text for 'show applications' */
  178. const char *description; /*!< Description (help text) for 'show application &lt;name&gt;' */
  179. AST_RWLIST_ENTRY(ast_app) list; /*!< Next app in list */
  180. struct module *module; /*!< Module this app belongs to */
  181. char name[0]; /*!< Name of the application */
  182. };
  183. /*! \brief ast_state_cb: An extension state notify register item */
  184. struct ast_state_cb {
  185. int id;
  186. void *data;
  187. ast_state_cb_type callback;
  188. struct ast_state_cb *next;
  189. };
  190. /*! \brief Structure for dial plan hints
  191. \note Hints are pointers from an extension in the dialplan to one or
  192. more devices (tech/name)
  193. - See \ref AstExtState
  194. */
  195. struct ast_hint {
  196. struct ast_exten *exten; /*!< Extension */
  197. int laststate; /*!< Last known state */
  198. struct ast_state_cb *callbacks; /*!< Callback list for this extension */
  199. AST_RWLIST_ENTRY(ast_hint) list;/*!< Pointer to next hint in list */
  200. };
  201. struct store_hint {
  202. char *context;
  203. char *exten;
  204. struct ast_state_cb *callbacks;
  205. int laststate;
  206. AST_LIST_ENTRY(store_hint) list;
  207. char data[1];
  208. };
  209. AST_LIST_HEAD(store_hints, store_hint);
  210. static const struct cfextension_states {
  211. int extension_state;
  212. const char * const text;
  213. } extension_states[] = {
  214. { AST_EXTENSION_NOT_INUSE, "Idle" },
  215. { AST_EXTENSION_INUSE, "InUse" },
  216. { AST_EXTENSION_BUSY, "Busy" },
  217. { AST_EXTENSION_UNAVAILABLE, "Unavailable" },
  218. { AST_EXTENSION_RINGING, "Ringing" },
  219. { AST_EXTENSION_INUSE | AST_EXTENSION_RINGING, "InUse&Ringing" },
  220. { AST_EXTENSION_ONHOLD, "Hold" },
  221. { AST_EXTENSION_INUSE | AST_EXTENSION_ONHOLD, "InUse&Hold" }
  222. };
  223. #define STATUS_NO_CONTEXT 1
  224. #define STATUS_NO_EXTENSION 2
  225. #define STATUS_NO_PRIORITY 3
  226. #define STATUS_NO_LABEL 4
  227. #define STATUS_SUCCESS 5
  228. extern struct ast_context *local_contexts;
  229. extern struct ast_context *contexts;
  230. struct ast_custom_function *ast_custom_function_find(const char *name);
  231. struct ast_custom_function *ast_custom_function_find(const char *name)
  232. {
  233. return 0; /* in "standalone" mode, functions are just not avail */
  234. }
  235. struct profile_entry {
  236. const char *name;
  237. uint64_t scale; /* if non-zero, values are scaled by this */
  238. int64_t mark;
  239. int64_t value;
  240. int64_t events;
  241. };
  242. struct profile_data {
  243. int entries;
  244. int max_size;
  245. struct profile_entry e[0];
  246. };
  247. static int bit_at(unsigned int *word, int bitsperword, int bitnum)
  248. {
  249. return word[bitnum/bitsperword] & (1 << (bitnum % bitsperword));
  250. }
  251. void get_start_stop(unsigned int *word, int bitsperword, int totalbits, int *start, int *end)
  252. {
  253. int i;
  254. int thisbit, thatbit = bit_at(word, bitsperword, totalbits-1);
  255. for (i=0; i<totalbits; i++) {
  256. thisbit = bit_at(word, bitsperword, i);
  257. if (thisbit != thatbit ) {
  258. if (thisbit) {
  259. *start = i;
  260. } else {
  261. *end = i;
  262. }
  263. }
  264. thatbit = thisbit;
  265. }
  266. }
  267. int all_bits_set(unsigned int *word, int bitsperword, int totalbits )
  268. {
  269. int i, total=totalbits/bitsperword,bitmask = 0;
  270. for (i=0; i<bitsperword; i++)
  271. {
  272. bitmask |= (1 << i);
  273. }
  274. for (i=0; i<total; i++)
  275. {
  276. if (word[i] != bitmask)
  277. return 0;
  278. }
  279. return 1;
  280. }
  281. int main(int argc, char **argv)
  282. {
  283. struct ast_context *tmp;
  284. struct ast_exten *e, *eroot;
  285. pval *tree, *tmptree, *sws;
  286. struct ast_include *tmpi;
  287. struct ast_sw *sw = 0;
  288. struct ast_ignorepat *ipi;
  289. pval *incl=0;
  290. int localdir = 0, i;
  291. tree = 0;
  292. tmptree = 0;
  293. /* process the command line args */
  294. for (i=1; i<argc; i++)
  295. {
  296. if (strcmp(argv[i],"-d")==0)
  297. localdir =1;
  298. }
  299. /* 3 simple steps: */
  300. /* 1. read in the extensions.conf config file
  301. * 2. traverse, and build an AEL tree
  302. * 3. Output the AEL tree into a file
  303. */
  304. printf("WARNING: This is an EXTREMELY preliminary version of a program\n");
  305. printf(" that will someday hopefully do a thoughful and intelligent\n");
  306. printf(" job of transforming your extensions.conf file into an\n");
  307. printf(" extensions.ael file.\n");
  308. printf(" This version has absolutely no intelligence, and pretty\n");
  309. printf(" much just does a direct conversion\n");
  310. printf(" The result will most likely need careful attention to\n");
  311. printf(" finish the job!!!!!\n");
  312. if (!localdir)
  313. printf(" (You could use -d the use the extensions.conf in the current directory!)\n");
  314. printf("Loading %s/%s...\n", ast_config_AST_CONFIG_DIR, config);
  315. if (!localdir)
  316. localized_use_conf_dir();
  317. localized_pbx_load_module();
  318. printf("... Done!\n");
  319. tmp = 0;
  320. while ((tmp = localized_walk_contexts(tmp)) ) {
  321. printf("Context: %s\n", tmp->name);
  322. }
  323. printf("=========\n");
  324. tmp = 0;
  325. while ((tmp = localized_walk_contexts(tmp)) ) {
  326. /* printf("Context: %s\n", tmp->name); */
  327. tmptree = pvalCreateNode(PV_CONTEXT);
  328. if (!tree)
  329. tree = tmptree;
  330. else
  331. pvalTopLevAddObject(tree, tmptree);
  332. pvalContextSetName(tmptree, ast_strdup(tmp->name));
  333. if (tmp->includes) {
  334. incl = pvalCreateNode(PV_INCLUDES);
  335. pvalContextAddStatement(tmptree, incl);
  336. for (tmpi = tmp->includes; tmpi; ) { /* includes */
  337. if (strchr(tmpi->name,'|')==0) {
  338. if (tmpi->hastime)
  339. {
  340. char timerange[15];
  341. char dowrange[10];
  342. char domrange[10];
  343. char monrange[10];
  344. int startbit=0, endbit=0;
  345. if (all_bits_set(tmpi->timing.minmask, 30, 720))
  346. strcpy(timerange, "*");
  347. else {
  348. int hr, min;
  349. char tbuf[20];
  350. get_start_stop(tmpi->timing.minmask, 30, 720, &startbit, &endbit);
  351. hr = startbit/30;
  352. min = (startbit % 30) * 2;
  353. sprintf(tbuf,"%02d:%02d", hr, min);
  354. strcpy(timerange, tbuf);
  355. hr = endbit/30;
  356. min = (endbit % 30) * 2;
  357. sprintf(tbuf,"%02d:%02d", hr, min);
  358. strcat(timerange,"-");
  359. strcat(timerange,tbuf);
  360. }
  361. if (all_bits_set(&tmpi->timing.dowmask, 7, 7))
  362. strcpy(dowrange, "*");
  363. else {
  364. get_start_stop(&tmpi->timing.dowmask, 7, 7, &startbit, &endbit);
  365. strcpy(dowrange, days[startbit]);
  366. strcat(dowrange,"-");
  367. strcat(dowrange, days[endbit]);
  368. }
  369. if (all_bits_set(&tmpi->timing.monthmask, 12, 12))
  370. strcpy(monrange, "*");
  371. else {
  372. get_start_stop(&tmpi->timing.monthmask, 12, 12, &startbit, &endbit);
  373. strcpy(monrange, months[startbit]);
  374. strcat(monrange,"-");
  375. strcat(monrange, months[endbit]);
  376. }
  377. if (all_bits_set(&tmpi->timing.daymask, 31, 31))
  378. strcpy(domrange, "*");
  379. else {
  380. char tbuf[20];
  381. get_start_stop(&tmpi->timing.daymask, 31, 31, &startbit, &endbit);
  382. sprintf(tbuf,"%d", startbit);
  383. strcpy(domrange, tbuf);
  384. strcat(domrange,"-");
  385. sprintf(tbuf,"%d", endbit);
  386. strcat(domrange, tbuf);
  387. }
  388. /* now all 4 fields are set; what do we do? */
  389. pvalIncludesAddIncludeWithTimeConstraints(incl, strdup(tmpi->name), strdup(timerange), strdup(domrange), strdup(dowrange), strdup(monrange));
  390. } else {
  391. pvalIncludesAddInclude(incl, strdup(tmpi->name));
  392. }
  393. } else { /* it appears the timing constraint info is tacked onto the name, carve it up and divvy it out */
  394. char *dow,*dom,*mon;
  395. char *all = strdup(tmpi->name);
  396. char *hr = strchr(all,'|');
  397. if (hr) {
  398. *hr++ = 0;
  399. dow = strchr(hr,'|');
  400. if (dow) {
  401. *dow++ = 0;
  402. dom = strchr(dow,'|');
  403. if (dom) {
  404. *dom++ = 0;
  405. mon = strchr(dom,'|');
  406. if (mon) {
  407. *mon++ = 0;
  408. /* now all 4 fields are set; what do we do? */
  409. pvalIncludesAddIncludeWithTimeConstraints(incl, strdup(all), strdup(hr), strdup(dow), strdup(dom), strdup(mon));
  410. /* the original data is always best to keep (no 2-min rounding) */
  411. } else {
  412. ast_log(LOG_ERROR,"No month spec attached to include!\n");
  413. }
  414. } else {
  415. ast_log(LOG_ERROR,"No day of month spec attached to include!\n");
  416. }
  417. } else {
  418. ast_log(LOG_ERROR,"No day of week spec attached to include!\n");
  419. }
  420. }
  421. free(all);
  422. }
  423. tmpi = tmpi->next;
  424. }
  425. }
  426. for (ipi = tmp->ignorepats; ipi; ) { /* ignorepats */
  427. incl = pvalCreateNode(PV_IGNOREPAT);
  428. pvalIgnorePatSetPattern(incl,(char *)ipi->pattern);
  429. pvalContextAddStatement(tmptree, incl);
  430. ipi = ipi->next;
  431. }
  432. eroot=0;
  433. while ( (eroot = localized_walk_context_extensions(tmp, eroot)) ) {
  434. pval *exten = pvalCreateNode(PV_EXTENSION);
  435. pvalContextAddStatement(tmptree, exten);
  436. pvalExtenSetName(exten, ast_strdup(eroot->exten));
  437. if (eroot->peer) {
  438. pval *block = pvalCreateNode(PV_STATEMENTBLOCK);
  439. pvalExtenSetStatement(exten, block);
  440. e = 0;
  441. while ( (e = localized_walk_extension_priorities(eroot, e)) ) {
  442. pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
  443. pval *args = pvalCreateNode(PV_WORD);
  444. /* printf(" %s(%s)\n", e->app, (char*)e->data); */
  445. pvalAppCallSetAppName(statemnt, ast_strdup(e->app));
  446. pvalWordSetString(args, ast_strdup(e->data));
  447. pvalAppCallAddArg(statemnt, args);
  448. pvalStatementBlockAddStatement(block, statemnt);
  449. }
  450. } else if (eroot->priority == -1) {
  451. pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
  452. pval *args = pvalCreateNode(PV_WORD);
  453. /* printf("Mike, we have a hint on exten %s with data %s\n", eroot->exten, eroot->app); */
  454. pvalAppCallSetAppName(statemnt, "NoOp");
  455. pvalWordSetString(args, ast_strdup(eroot->app));
  456. pvalExtenSetStatement(exten, statemnt);
  457. pvalExtenSetHints(exten, ast_strdup(eroot->app));
  458. } else {
  459. pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
  460. pval *args = pvalCreateNode(PV_WORD);
  461. /* printf(" %s (%s)\n", eroot->app, (char *)eroot->data); */
  462. pvalAppCallSetAppName(statemnt, ast_strdup(eroot->app));
  463. pvalWordSetString(args, ast_strdup(eroot->data));
  464. pvalAppCallAddArg(statemnt, args);
  465. pvalExtenSetStatement(exten, statemnt);
  466. }
  467. /* printf(" extension: %s\n", eroot->exten); */
  468. }
  469. if (AST_LIST_FIRST(&tmp->alts)) {
  470. sws = pvalCreateNode(PV_SWITCHES);
  471. pvalContextAddStatement(tmptree,sws);
  472. sw = 0;
  473. while ((sw = localized_walk_context_switches(tmp,sw)) ) {
  474. pvalSwitchesAddSwitch(sws, ast_strdup(sw->name));
  475. }
  476. }
  477. }
  478. printf("Generating aelout.ael file...\n");
  479. ael2_print("aelout.ael", tree);
  480. printf("...Done!\n");
  481. return 0;
  482. }
  483. /* ==================================== for linking internal stuff to external stuff */
  484. int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
  485. {
  486. return localized_pbx_builtin_setvar(chan, data);
  487. }
  488. void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
  489. void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count)
  490. {
  491. if (cp1 && *cp1)
  492. strncpy(cp2,cp1,AST_MAX_EXTENSION); /* Right now, this routine is ONLY being called for
  493. a possible var substitution on extension names,
  494. so....! */
  495. else
  496. *cp2 = 0;
  497. }
  498. int ast_add_extension2(struct ast_context *con,
  499. int replace, const char *extension, int priority, const char *label, const char *callerid,
  500. const char *application, void *data, void (*datad)(void *),
  501. const char *registrar)
  502. {
  503. return localized_add_extension2(con, replace, extension, priority, label, callerid, application, data, datad, registrar);
  504. }
  505. int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
  506. {
  507. return localized_context_add_ignorepat2(con, value, registrar);
  508. }
  509. int ast_context_add_switch2(struct ast_context *con, const char *value,
  510. const char *data, int eval, const char *registrar)
  511. {
  512. return localized_context_add_switch2(con, value, data, eval, registrar);
  513. }
  514. int ast_context_add_include2(struct ast_context *con, const char *value,
  515. const char *registrar)
  516. {
  517. return localized_context_add_include2(con, value,registrar);
  518. }
  519. struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
  520. {
  521. printf("find/Creating context %s, registrar=%s\n", name, registrar);
  522. return localized_context_find_or_create(extcontexts, exttable, name, registrar);
  523. }
  524. void ast_cli_register_multiple(void);
  525. void ast_cli_register_multiple(void)
  526. {
  527. }
  528. void ast_module_register(const struct ast_module_info *x)
  529. {
  530. }
  531. void ast_module_unregister(const struct ast_module_info *x)
  532. {
  533. }
  534. void ast_cli_unregister_multiple(void);
  535. void ast_cli_unregister_multiple(void)
  536. {
  537. }
  538. struct ast_context *ast_walk_contexts(struct ast_context *con);
  539. struct ast_context *ast_walk_contexts(struct ast_context *con)
  540. {
  541. return localized_walk_contexts(con);
  542. }
  543. void ast_context_destroy(struct ast_context *con, const char *registrar);
  544. void ast_context_destroy(struct ast_context *con, const char *registrar)
  545. {
  546. return localized_context_destroy(con, registrar);
  547. }
  548. int ast_context_verify_includes(struct ast_context *con);
  549. int ast_context_verify_includes(struct ast_context *con)
  550. {
  551. return localized_context_verify_includes(con);
  552. }
  553. void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar);
  554. void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
  555. {
  556. localized_merge_contexts_and_delete(extcontexts, exttable, registrar);
  557. }
  558. const char *ast_get_context_name(struct ast_context *con);
  559. const char *ast_get_context_name(struct ast_context *con)
  560. {
  561. return con ? con->name : NULL;
  562. }
  563. struct ast_exten *ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten);
  564. struct ast_exten *ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
  565. {
  566. return NULL;
  567. }
  568. struct ast_include *ast_walk_context_includes(struct ast_context *con, struct ast_include *inc);
  569. struct ast_include *ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
  570. {
  571. return NULL;
  572. }
  573. struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip);
  574. struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip)
  575. {
  576. return NULL;
  577. }
  578. struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw);
  579. struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
  580. {
  581. return NULL;
  582. }
  583. struct ast_exten *pbx_find_extension(struct ast_channel *chan,
  584. struct ast_context *bypass,
  585. struct pbx_find_info *q,
  586. const char *context,
  587. const char *exten,
  588. int priority,
  589. const char *label,
  590. const char *callerid,
  591. enum ext_match_t action);
  592. struct ast_exten *pbx_find_extension(struct ast_channel *chan,
  593. struct ast_context *bypass,
  594. struct pbx_find_info *q,
  595. const char *context,
  596. const char *exten,
  597. int priority,
  598. const char *label,
  599. const char *callerid,
  600. enum ext_match_t action)
  601. {
  602. return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
  603. }
  604. int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
  605. int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
  606. {
  607. return 0;
  608. }
  609. unsigned int ast_hashtab_hash_contexts(const void *obj);
  610. unsigned int ast_hashtab_hash_contexts(const void *obj)
  611. {
  612. return 0;
  613. }
  614. #ifdef DEBUG_THREADS
  615. #if !defined(LOW_MEMORY)
  616. void ast_mark_lock_acquired(void *lock_addr)
  617. {
  618. }
  619. #ifdef HAVE_BKTR
  620. void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
  621. {
  622. }
  623. void ast_store_lock_info(enum ast_lock_type type, const char *filename,
  624. int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
  625. {
  626. }
  627. int ast_bt_get_addresses(struct ast_bt *bt)
  628. {
  629. return 0;
  630. }
  631. char **ast_bt_get_symbols(void **addresses, size_t num_frames)
  632. {
  633. char **foo = calloc(num_frames, sizeof(char *) + 1);
  634. if (foo) {
  635. int i;
  636. for (i = 0; i < num_frames; i++) {
  637. foo[i] = (char *) foo + sizeof(char *) * num_frames;
  638. }
  639. }
  640. return foo;
  641. }
  642. #else
  643. void ast_remove_lock_info(void *lock_addr)
  644. {
  645. }
  646. void ast_store_lock_info(enum ast_lock_type type, const char *filename,
  647. int line_num, const char *func, const char *lock_name, void *lock_addr)
  648. {
  649. }
  650. #endif /* HAVE_BKTR */
  651. #endif /* !defined(LOW_MEMORY) */
  652. #endif /* DEBUG_THREADS */