Fix compile errors caused by r4500 / r4501.
[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 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_version(const char *file, const char *version);
83 void ast_register_file_version(const char *file, const char *version)
84 {
85 }
86
87 void ast_unregister_file_version(const char *file);
88 void ast_unregister_file_version(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 static const struct cfextension_states {
241         int extension_state;
242         const char * const text;
243 } extension_states[] = {
244         { AST_EXTENSION_NOT_INUSE,                     "Idle" },
245         { AST_EXTENSION_INUSE,                         "InUse" },
246         { AST_EXTENSION_BUSY,                          "Busy" },
247         { AST_EXTENSION_UNAVAILABLE,                   "Unavailable" },
248         { AST_EXTENSION_RINGING,                       "Ringing" },
249         { AST_EXTENSION_INUSE | AST_EXTENSION_RINGING, "InUse&Ringing" },
250         { AST_EXTENSION_ONHOLD,                        "Hold" },
251         { AST_EXTENSION_INUSE | AST_EXTENSION_ONHOLD,  "InUse&Hold" }
252 };
253 #define STATUS_NO_CONTEXT       1
254 #define STATUS_NO_EXTENSION     2
255 #define STATUS_NO_PRIORITY      3
256 #define STATUS_NO_LABEL         4
257 #define STATUS_SUCCESS          5
258
259 extern struct ast_context *local_contexts;
260 extern struct ast_context *contexts;
261
262
263 struct ast_custom_function *ast_custom_function_find(const char *name);
264
265
266 struct ast_custom_function *ast_custom_function_find(const char *name)
267 {
268         return 0; /* in "standalone" mode, functions are just not avail */
269 }
270
271
272 struct profile_entry {
273         const char *name;
274         uint64_t        scale;  /* if non-zero, values are scaled by this */
275         int64_t mark;
276         int64_t value;
277         int64_t events;
278 };
279
280 struct profile_data {
281         int entries;
282         int max_size;
283         struct profile_entry e[0];
284 };
285
286 static int bit_at(unsigned int *word, int bitsperword, int bitnum)
287 {
288         return word[bitnum/bitsperword] & (1 << (bitnum % bitsperword));
289 }
290
291 void get_start_stop(unsigned int *word, int bitsperword, int totalbits, int *start, int *end)
292 {
293         int i;
294         int thisbit, thatbit = bit_at(word, bitsperword, totalbits-1);
295         
296         for (i=0; i<totalbits; i++) {
297                 thisbit = bit_at(word, bitsperword, i);
298                 
299                 if (thisbit != thatbit ) {
300                         if (thisbit) {
301                                 *start = i;
302                         } else {
303                                 *end = i;
304                         }
305                 }
306                 thatbit = thisbit;
307         }
308 }
309
310 int all_bits_set(unsigned int *word, int bitsperword, int totalbits )
311 {
312         
313         int i, total=totalbits/bitsperword,bitmask = 0;
314         
315         for (i=0; i<bitsperword; i++)
316         {
317                 bitmask |= (1 << i);
318         }
319         
320         for (i=0; i<total; i++)
321         {
322                 if (word[i] != bitmask)
323                         return 0;
324         }
325         return 1;
326 }
327
328
329 int main(int argc, char **argv)
330 {
331         struct ast_context *tmp;
332         struct ast_exten *e, *eroot;
333         pval *tree, *tmptree, *sws;
334         struct ast_include *tmpi;
335         struct ast_sw *sw = 0;
336         struct ast_ignorepat *ipi;
337         pval *incl=0;
338         int localdir = 0, i;
339
340         tree = 0;
341         tmptree = 0;
342
343         /* process the command line args */
344         for (i=1; i<argc; i++)
345         {
346                 if (strcmp(argv[i],"-d")==0)
347                         localdir =1;
348         }
349         
350         /* 3 simple steps: */
351         /*   1. read in the extensions.conf config file 
352          *   2. traverse, and build an AEL tree
353          *   3. Output the AEL tree into a file
354          */
355         printf("WARNING: This is an EXTREMELY preliminary version of a program\n");
356         printf("         that will someday hopefully do a thoughful and intelligent\n");
357         printf("         job of transforming your extensions.conf file into an\n");
358         printf("         extensions.ael file.\n");
359         printf("         This version has absolutely no intelligence, and pretty\n");
360         printf("         much just does a direct conversion\n");
361         printf("         The result will most likely need careful attention to\n");
362         printf("         finish the job!!!!!\n");
363
364         if (!localdir)
365                 printf(" (You could use -d the use the extensions.conf in the current directory!)\n");
366
367         printf("Loading %s/%s...\n", ast_config_AST_CONFIG_DIR, config);
368
369         if (!localdir)
370                 localized_use_conf_dir();
371         localized_pbx_load_module();
372         
373         printf("... Done!\n");
374         
375         tmp = 0;
376         while ((tmp = localized_walk_contexts(tmp)) ) {
377                 printf("Context: %s\n", tmp->name);
378         }
379         printf("=========\n");
380         tmp = 0;
381         while ((tmp = localized_walk_contexts(tmp)) ) {
382                 /* printf("Context: %s\n", tmp->name); */
383                 tmptree = pvalCreateNode(PV_CONTEXT);
384                 if (!tree)
385                         tree = tmptree;
386                 else
387                         pvalTopLevAddObject(tree, tmptree);
388                 
389                 pvalContextSetName(tmptree, ast_strdup(tmp->name));
390                 
391                 if (tmp->includes) {
392                         incl = pvalCreateNode(PV_INCLUDES);
393                         pvalContextAddStatement(tmptree, incl);
394                         for (tmpi = tmp->includes; tmpi; ) { /* includes */
395                                 if (strchr(tmpi->name,'|')==0) {
396                                         if (tmpi->hastime)
397                                         {
398                                                 char timerange[15];
399                                                 char dowrange[10];
400                                                 char domrange[10];
401                                                 char monrange[10];
402                                                 int startbit=0, endbit=0;
403                                                 
404                                                 if (all_bits_set(tmpi->timing.minmask, 30, 720))
405                                                         strcpy(timerange, "*");
406                                                 else {
407                                                         int hr, min;
408                                                         char tbuf[20];
409                                                         get_start_stop(tmpi->timing.minmask, 30, 720, &startbit, &endbit);
410                                                         hr = startbit/30;
411                                                         min = (startbit % 30) * 2;
412                                                         sprintf(tbuf,"%02d:%02d", hr, min);
413                                                         strcpy(timerange, tbuf);
414                                                         hr = endbit/30;
415                                                         min = (endbit % 30) * 2;
416                                                         sprintf(tbuf,"%02d:%02d", hr, min);
417                                                         strcat(timerange,"-");
418                                                         strcat(timerange,tbuf);
419                                                 }
420                                                 
421                                                 if (all_bits_set(&tmpi->timing.dowmask, 7, 7))
422                                                         strcpy(dowrange, "*");
423                                                 else {
424                                                         get_start_stop(&tmpi->timing.dowmask, 7, 7, &startbit, &endbit);
425                                                         strcpy(dowrange, days[startbit]);
426                                                         strcat(dowrange,"-");
427                                                         strcat(dowrange, days[endbit]);
428                                                 }
429                                                 
430                                                 if (all_bits_set(&tmpi->timing.monthmask, 12, 12))
431                                                         strcpy(monrange, "*");
432                                                 else {
433                                                         get_start_stop(&tmpi->timing.monthmask, 12, 12, &startbit, &endbit);
434                                                         strcpy(monrange, months[startbit]);
435                                                         strcat(monrange,"-");
436                                                         strcat(monrange, months[endbit]);
437                                                 }
438                                                 
439                                                 if (all_bits_set(&tmpi->timing.daymask, 31, 31))
440                                                         strcpy(domrange, "*");
441                                                 else {
442                                                         char tbuf[20];
443                                                         get_start_stop(&tmpi->timing.daymask, 31, 31, &startbit, &endbit);
444                                                         sprintf(tbuf,"%d", startbit);
445                                                         strcpy(domrange, tbuf);
446                                                         strcat(domrange,"-");
447                                                         sprintf(tbuf,"%d", endbit);
448                                                         strcat(domrange, tbuf);
449                                                 }
450                                                 /* now all 4 fields are set; what do we do? */
451                                                 pvalIncludesAddIncludeWithTimeConstraints(incl, strdup(tmpi->name), strdup(timerange), strdup(domrange), strdup(dowrange), strdup(monrange));
452                                                 
453                                         } else {
454                                                 pvalIncludesAddInclude(incl, strdup(tmpi->name));
455                                         }
456                                 } else { /* it appears the timing constraint info is tacked onto the name, carve it up and divvy it out */
457                                         char *dow,*dom,*mon;
458                                         char *all = strdup(tmpi->name);
459                                         char *hr = strchr(all,'|');
460                                         if (hr) {
461                                                 *hr++ = 0;
462                                                 dow = strchr(hr,'|');
463                                                 if (dow) {
464                                                         *dow++ = 0;
465                                                         dom = strchr(dow,'|');
466                                                         if (dom) {
467                                                                 *dom++ = 0;
468                                                                 mon = strchr(dom,'|');
469                                                                 if (mon) {
470                                                                         *mon++ = 0;
471                                                                         /* now all 4 fields are set; what do we do? */
472                                                                         pvalIncludesAddIncludeWithTimeConstraints(incl, strdup(all), strdup(hr), strdup(dow), strdup(dom), strdup(mon));
473                                                                         /* the original data is always best to keep (no 2-min rounding) */
474                                                                 } else {
475                                                                         ast_log(LOG_ERROR,"No month spec attached to include!\n");
476                                                                 }
477                                                         } else {
478                                                                 ast_log(LOG_ERROR,"No day of month spec attached to include!\n");
479                                                         }
480                                                 } else {
481                                                         ast_log(LOG_ERROR,"No day of week spec attached to include!\n");
482                                                 }
483                                         }
484                                         free(all);
485                                 }
486                                 tmpi = tmpi->next;
487                         }
488                 }
489                 for (ipi = tmp->ignorepats; ipi; ) { /* ignorepats */
490                         incl = pvalCreateNode(PV_IGNOREPAT);
491                         pvalIgnorePatSetPattern(incl,(char *)ipi->pattern);
492                         pvalContextAddStatement(tmptree, incl);
493                         ipi = ipi->next;
494                 }
495                 eroot=0;
496                 while ( (eroot = localized_walk_context_extensions(tmp, eroot)) ) {
497                         pval *exten = pvalCreateNode(PV_EXTENSION);
498                         pvalContextAddStatement(tmptree, exten);
499                         pvalExtenSetName(exten, ast_strdup(eroot->exten));
500                 
501                         if (eroot->peer) {
502                                 pval *block = pvalCreateNode(PV_STATEMENTBLOCK);
503                                 pvalExtenSetStatement(exten, block);
504                                 
505                                 e = 0;
506                                 while ( (e = localized_walk_extension_priorities(eroot, e)) ) {
507                                         
508                                         pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
509                                         pval *args = pvalCreateNode(PV_WORD);
510                                         
511                                         /* printf("           %s(%s)\n", e->app, (char*)e->data); */
512
513                                         pvalAppCallSetAppName(statemnt, ast_strdup(e->app));
514                                         pvalWordSetString(args, ast_strdup(e->data));
515                                         pvalAppCallAddArg(statemnt, args);
516                                         
517                                         pvalStatementBlockAddStatement(block, statemnt);
518                                 }
519                         } else if (eroot->priority == -1) {
520
521                                 pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
522                                 pval *args = pvalCreateNode(PV_WORD);
523
524                                 /* printf("Mike, we have a hint on exten %s with data %s\n", eroot->exten, eroot->app); */
525
526                                 pvalAppCallSetAppName(statemnt, "NoOp");
527                                 pvalWordSetString(args, ast_strdup(eroot->app));
528
529
530                                 pvalExtenSetStatement(exten, statemnt);
531                                 pvalExtenSetHints(exten, ast_strdup(eroot->app));
532                         } else {
533
534                                 pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
535                                 pval *args = pvalCreateNode(PV_WORD);
536         
537                                 /* printf("           %s (%s)\n", eroot->app, (char *)eroot->data); */
538                                 
539                                 pvalAppCallSetAppName(statemnt, ast_strdup(eroot->app));
540                                 pvalWordSetString(args, ast_strdup(eroot->data));
541
542                                 
543                                 pvalAppCallAddArg(statemnt, args);
544                                 pvalExtenSetStatement(exten, statemnt);
545                         }
546
547                         /* printf("   extension: %s\n", eroot->exten); */
548                 }
549                 if (AST_LIST_FIRST(&tmp->alts)) {
550                         sws = pvalCreateNode(PV_SWITCHES);
551                         pvalContextAddStatement(tmptree,sws);
552                         
553                         sw = 0;
554                         while ((sw = localized_walk_context_switches(tmp,sw)) ) {
555                                 pvalSwitchesAddSwitch(sws, ast_strdup(sw->name));
556                         }
557                 }
558         }
559         printf("Generating aelout.ael file...\n");
560         
561         ael2_print("aelout.ael", tree);
562         
563         printf("...Done!\n");
564         return 0;
565 }
566
567
568 /* ==================================== for linking internal stuff to external stuff */
569
570 int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
571 {
572         return localized_pbx_builtin_setvar(chan, data);
573 }
574
575 void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
576 void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count)
577 {
578         if (cp1 && *cp1)
579                 strncpy(cp2,cp1,AST_MAX_EXTENSION); /* Right now, this routine is ONLY being called for 
580                                                                                            a possible var substitution on extension names,
581                                                                                            so....! */
582         else
583                 *cp2 = 0;
584 }
585
586 int ast_add_extension2(struct ast_context *con,
587                                            int replace, const char *extension, int priority, const char *label, const char *callerid,
588                                            const char *application, void *data, void (*datad)(void *),
589                                            const char *registrar)
590 {
591         return localized_add_extension2(con, replace, extension, priority, label, callerid, application, data, datad, registrar);
592 }
593
594 int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
595 {
596         
597         return localized_context_add_ignorepat2(con, value, registrar);
598 }
599
600 int ast_context_add_switch2(struct ast_context *con, const char *value,
601                                                                  const char *data, int eval, const char *registrar)
602 {
603         
604         return localized_context_add_switch2(con, value, data, eval, registrar);
605 }
606
607 int ast_context_add_include2(struct ast_context *con, const char *value,
608                                                                   const char *registrar)
609 {
610         
611         return localized_context_add_include2(con, value,registrar);
612 }
613
614 struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
615 {
616         printf("find/Creating context %s, registrar=%s\n", name, registrar);
617         
618         return localized_context_find_or_create(extcontexts, exttable, name, registrar);
619 }
620
621 void ast_cli_register_multiple(void);
622
623 void ast_cli_register_multiple(void)
624 {
625 }
626
627 void ast_module_register(const struct ast_module_info *x)
628 {
629 }
630
631 void ast_module_unregister(const struct ast_module_info *x)
632 {
633 }
634
635 void ast_cli_unregister_multiple(void);
636
637 void ast_cli_unregister_multiple(void)
638 {
639 }
640
641 struct ast_context *ast_walk_contexts(struct ast_context *con);
642 struct ast_context *ast_walk_contexts(struct ast_context *con)
643 {
644         return localized_walk_contexts(con);
645 }
646
647 void ast_context_destroy(struct ast_context *con, const char *registrar);
648
649 void ast_context_destroy(struct ast_context *con, const char *registrar)
650 {
651         return localized_context_destroy(con, registrar);
652 }
653
654 int ast_context_verify_includes(struct ast_context *con);
655
656 int ast_context_verify_includes(struct ast_context *con)
657 {
658         return  localized_context_verify_includes(con);
659 }
660
661 void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar);
662
663 void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
664 {
665         localized_merge_contexts_and_delete(extcontexts, exttable, registrar);
666 }
667
668 const char *ast_get_context_name(struct ast_context *con);
669 const char *ast_get_context_name(struct ast_context *con)
670 {
671         return con ? con->name : NULL;
672 }
673
674 struct ast_exten *ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten);
675 struct ast_exten *ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
676 {
677         return NULL;
678 }
679
680 struct ast_include *ast_walk_context_includes(struct ast_context *con, struct ast_include *inc);
681 struct ast_include *ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
682 {
683         return NULL;
684 }
685
686 struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip);
687 struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip)
688 {
689         return NULL;
690 }
691
692 struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw);
693 struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
694 {
695         return NULL;
696 }
697
698 struct ast_exten *pbx_find_extension(struct ast_channel *chan,
699                                                                          struct ast_context *bypass,
700                                                                          struct pbx_find_info *q,
701                                                                          const char *context, 
702                                                                          const char *exten, 
703                                                                          int priority,
704                                                                          const char *label, 
705                                                                          const char *callerid, 
706                                                                          enum ext_match_t action);
707
708 struct ast_exten *pbx_find_extension(struct ast_channel *chan,
709                                                                          struct ast_context *bypass,
710                                                                          struct pbx_find_info *q,
711                                                                          const char *context, 
712                                                                          const char *exten, 
713                                                                          int priority,
714                                                                          const char *label, 
715                                                                          const char *callerid, 
716                                                                          enum ext_match_t action)
717 {
718         return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
719 }
720
721 int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
722
723 int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
724 {
725         return 0;
726 }
727
728 unsigned int ast_hashtab_hash_contexts(const void *obj);
729
730 unsigned int ast_hashtab_hash_contexts(const void *obj)
731 {
732         return 0;
733 }
734
735 #ifdef DEBUG_THREADS
736 #if !defined(LOW_MEMORY)
737 void ast_mark_lock_acquired(void *lock_addr)
738 {
739 }
740 #ifdef HAVE_BKTR
741 void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
742 {
743 }
744
745 void ast_store_lock_info(enum ast_lock_type type, const char *filename,
746         int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
747 {
748 }
749
750 int __ast_bt_get_addresses(struct ast_bt *bt)
751 {
752         return 0;
753 }
754
755 char **__ast_bt_get_symbols(void **addresses, size_t num_frames)
756 {
757         char **foo = calloc(num_frames, sizeof(char *) + 1);
758         if (foo) {
759                 int i;
760                 for (i = 0; i < num_frames; i++) {
761                         foo[i] = (char *) foo + sizeof(char *) * num_frames;
762                 }
763         }
764         return foo;
765 }
766
767 #else
768 void ast_remove_lock_info(void *lock_addr)
769 {
770 }
771
772 void ast_store_lock_info(enum ast_lock_type type, const char *filename,
773         int line_num, const char *func, const char *lock_name, void *lock_addr)
774 {
775 }
776 #endif /* HAVE_BKTR */
777 void ast_suspend_lock_info(void *lock_addr)
778 {
779 }
780 void ast_restore_lock_info(void *lock_addr)
781 {
782 }
783 #endif /* !defined(LOW_MEMORY) */
784 #endif /* DEBUG_THREADS */