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