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