~ubuntu-branches/ubuntu/karmic/asterisk/karmic-proposed

« back to all changes in this revision

Viewing changes to utils/ael_main.c

  • Committer: Bazaar Package Importer
  • Author(s): Faidon Liambotis, Faidon Liambotis, Tzafrir Cohen
  • Date: 2009-07-28 03:42:54 UTC
  • mfrom: (8.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090728034254-ip2jeh7h3s45fqre
Tags: 1:1.6.2.0~dfsg~beta3-1
[ Faidon Liambotis ]
* New upstream release.
  - Drop patches astvarrundir, pubkey_jnctn; merged upstream (finally!).
  - Adapt patch safe_asterisk-nobg.
* Switch to downloads.asterisk.org instead of downloads.digium.com.
* Add depends on libxml2-dev for the new XML documentation.
* Remove Conflicts/Replaces with asterisk-classic, asterisk-bristuff,
  asterisk-chan-capi (<< 1.1.1-1~), since those are pre-lenny.
* Revert upstream's r190830 that ported app_osplookup to OSP Toolkit 3.5;
  the API is not backwards compatible and Debian still has 3.4.2.
* Accommodate for the rename of libcap2-dev to libcap-dev (Closes: #532971).
* Add dependency to libspandsp to build the fax applications.
* Update Standards-Version to 3.8.2, no changes needed.
* Remove init script's "zaptel-fix" action; there's no zaptel anymore and
  was also lintian-buggy in its current form.
* Don't include /var/run/asterisk in the package, it is created at boot-time
  by the init script (thanks lintian).
* Remove asterisk-progdocs: it is of very limited use but a) is enormous in
  size and b) takes too long to build.
* Re-enable and port to 1.6 the h323 segfault patch, apparently it's still
  needed.
* Fix asterisk's Makefiles so that the openh323/libpt dependencies are added
  to chan_h323.so instead of the main asterisk binary.
* Fix astgenkey to respect system's umask. Thanks Jonas Smedegaard.
  (Closes: #531730) 
* Create /var/log/asterisk/* directories if non-existent, for /var/log on
  tmpfs scenarios. Thanks martin f krafft! (Closes: #524015)
* Use the lsb-base standard way of gathering and reporting status in the
  init script. Thanks Dustin Kirkland and Ubuntu! (Closes: #506453)
* Fix debian/rules so that configure isn't called twice during a build.
* Install Zaptel-to-DAHDI.txt, explains the migration procedure from Zaptel
  to DAHDI and is therefore useful when upgrading from lenny.

[ Tzafrir Cohen ]
* New upstream release.
  - Fixes that bashism in safe_asterisk (Closes: #530047) (not dashism).
  - Dropped patch astcanary_startup: merged upstream.
* Patch makefile_appdocs_dtd: fix location of DTD installation.
* Register the HTML docs with doc-base as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <sys/types.h>
2
 
#include <stdio.h>
3
 
#include <stdlib.h>
4
 
#include <stdarg.h>
5
 
#include <string.h>
 
1
/*
 
2
 * XXX this file probably need a fair amount of cleanup, at the very least:
 
3
 *
 
4
 * - documenting its purpose;
 
5
 * - removing all unnecessary headers and other stuff from the sources
 
6
 *   it was copied from;
 
7
 * - fixing the formatting
 
8
 */
 
9
#include "asterisk.h"
 
10
 
6
11
#include <locale.h>
7
12
#include <ctype.h>
8
 
#include <errno.h>
9
13
#include <regex.h>
10
14
#include <limits.h>
11
15
 
 
16
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 165071 $")
 
17
 
 
18
#include "asterisk/channel.h"
12
19
#include "asterisk/ast_expr.h"
13
 
#include "asterisk/channel.h"
14
20
#include "asterisk/module.h"
15
21
#include "asterisk/app.h"
 
22
#include "asterisk/lock.h"
 
23
#include "asterisk/hashtab.h"
16
24
#include "asterisk/ael_structs.h"
 
25
#include "asterisk/extconf.h"
 
26
 
 
27
int option_debug = 0;
 
28
int option_verbose = 0;
 
29
void ast_register_file_version(const char *file, const char *version) { }
 
30
void ast_unregister_file_version(const char *file) { }
 
31
 
 
32
struct ast_flags ast_compat = { 7 };
17
33
 
18
34
/*** MODULEINFO
19
 
        <depend>pbx_ael</depend>
 
35
        <depend>res_ael_share</depend>
20
36
 ***/
21
37
 
22
38
struct namelist
75
91
 
76
92
int conts=0, extens=0, priors=0;
77
93
char last_exten[18000];
78
 
char ast_config_AST_CONFIG_DIR[PATH_MAX];
79
 
char ast_config_AST_VAR_DIR[PATH_MAX];
80
 
 
81
 
void ast_add_profile(void);
 
94
 
 
95
static char config_dir[PATH_MAX];
 
96
static char var_dir[PATH_MAX];
 
97
const char *ast_config_AST_CONFIG_DIR = config_dir;
 
98
const char *ast_config_AST_VAR_DIR = var_dir;
 
99
 
82
100
void ast_cli_register_multiple(void);
83
 
void ast_register_file_version(void);
84
 
void ast_unregister_file_version(void);
85
101
int ast_add_extension2(struct ast_context *con,
86
102
                                           int replace, const char *extension, int priority, const char *label, const char *callerid,
87
103
                                                const char *application, void *data, void (*datad)(void *),
88
104
                                           const char *registrar);
89
105
void pbx_builtin_setvar(void *chan, void *data);
90
106
struct ast_context * ast_context_create(void **extcontexts, const char *name, const char *registrar);
91
 
struct ast_context * ast_context_find_or_create(void **extcontexts, const char *name, const char *registrar);
 
107
struct ast_context * ast_context_find_or_create(void **extcontexts, void *tab, const char *name, const char *registrar);
92
108
void ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar);
93
109
void ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar);
94
110
void ast_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar);
99
115
void ast_context_destroy(void);
100
116
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...);
101
117
char *ast_process_quotes_and_slashes(char *start, char find, char replace_with);
102
 
void ast_verbose(const char *fmt, ...);
 
118
void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...);
103
119
struct ast_app *pbx_findapp(const char *app);
104
120
void filter_leading_space_from_exprs(char *str);
105
121
void filter_newlines(char *str);
110
126
static int FIRST_TIME = 0;
111
127
static FILE *dumpfile;
112
128
 
 
129
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
 
130
{
 
131
                va_list vars;
 
132
                        va_start(vars,fmt);
 
133
                        
 
134
                                printf("LOG: lev:%d file:%s  line:%d func: %s  ",
 
135
                                                                   level, file, line, function);
 
136
                                        vprintf(fmt, vars);
 
137
                                                fflush(stdout);
 
138
                                                        va_end(vars);
 
139
}
 
140
 
 
141
struct ast_exten *pbx_find_extension(struct ast_channel *chan,
 
142
                                                                         struct ast_context *bypass,
 
143
                                                                         struct pbx_find_info *q,
 
144
                                                                         const char *context, 
 
145
                                                                         const char *exten, 
 
146
                                                                         int priority,
 
147
                                                                         const char *label, 
 
148
                                                                         const char *callerid, 
 
149
                                                                         enum ext_match_t action);
 
150
 
 
151
struct ast_exten *pbx_find_extension(struct ast_channel *chan,
 
152
                                                                         struct ast_context *bypass,
 
153
                                                                         struct pbx_find_info *q,
 
154
                                                                         const char *context, 
 
155
                                                                         const char *exten, 
 
156
                                                                         int priority,
 
157
                                                                         const char *label, 
 
158
                                                                         const char *callerid, 
 
159
                                                                         enum ext_match_t action)
 
160
{
 
161
        return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
 
162
}
 
163
 
113
164
struct ast_app *pbx_findapp(const char *app)
114
165
{
115
166
        return (struct ast_app*)1; /* so as not to trigger an error */
116
167
}
117
168
 
118
 
void ast_add_profile(void)
 
169
struct ast_custom_function *ast_custom_function_find(const char *name);
 
170
 
 
171
 
 
172
struct ast_custom_function *ast_custom_function_find(const char *name)
 
173
{
 
174
        return 0; /* in "standalone" mode, functions are just not avail */
 
175
}
 
176
 
 
177
#if !defined(LOW_MEMORY)
 
178
int ast_add_profile(const char *x, uint64_t scale)
119
179
{
120
180
        if (!no_comp)
121
181
                printf("Executed ast_add_profile();\n");
 
182
 
 
183
        return 0;
122
184
}
 
185
#endif
123
186
 
124
187
int ast_loader_register(int (*updater)(void))
125
188
{
145
208
                printf("Executed ast_cli_register_multiple();\n");
146
209
}
147
210
 
148
 
void ast_register_file_version(void)
149
 
{
150
 
        /* if(!no_comp)
151
 
                printf("Executed ast_register_file_version();\n"); */
152
 
        /* I'm erasing this, because I don't think anyone really ever needs to see it anyway */
153
 
}
154
 
 
155
 
void ast_unregister_file_version(void)
156
 
{
157
 
        /* if(!no_comp)
158
 
                printf("Executed ast_unregister_file_version();\n"); */
159
 
        /* I'm erasing this, because I don't think anyone really ever needs to see it anyway */
160
 
 
161
 
}
162
211
void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
163
212
void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count)
164
213
{
197
246
 
198
247
        if( dump_extensions && dumpfile ) {
199
248
                struct namelist *n;
200
 
                char *data2,*data3=0;
201
 
                int commacount = 0;
202
249
 
203
250
                if( FIRST_TIME ) {
204
251
                        FIRST_TIME = 0;
232
279
                if( data ) {
233
280
                        filter_newlines((char*)data);
234
281
                        filter_leading_space_from_exprs((char*)data);
 
282
                        /* in previous versions, commas were converted to '|' to separate
 
283
                           args in app calls, but now, commas are used. There used to be
 
284
                           code here to insert backslashes (escapes) before any commas
 
285
                           that may have been embedded in the app args. This code is no more. */
235
286
 
236
 
                        /* compiling turns commas into vertical bars in the app data, and also removes the backslash from before escaped commas;
237
 
                           we have to restore the escaping backslash in front of any commas; the vertical bars are OK to leave as-is */
238
 
                        for (data2 = data; *data2; data2++) {
239
 
                                if (*data2 == ',')
240
 
                                        commacount++;  /* we need to know how much bigger the string will grow-- one backslash for each comma  */
241
 
                        }
242
 
                        if (commacount) 
243
 
                        {
244
 
                                char *d3,*d4;
245
 
                                
246
 
                                data2 = (char*)malloc(strlen(data)+commacount+1);
247
 
                                data3 = data;
248
 
                                d3 = data;
249
 
                                d4 = data2;
250
 
                                while (*d3) {
251
 
                                        if (*d3 == ',') {
252
 
                                                *d4++ = '\\'; /* put a backslash in front of each comma */
253
 
                                                *d4++ = *d3++;
254
 
                                        } else
255
 
                                                *d4++ = *d3++;  /* or just copy the char */
256
 
                                }
257
 
                                *d4++ = 0;  /* cap off the new string */
258
 
                                data = data2;
259
 
                        } else
260
 
                                data2 = 0;
261
 
                        
262
287
                        if( strcmp(label,"(null)") != 0  )
263
288
                                fprintf(dumpfile,"exten => %s,%d(%s),%s(%s)\n", extension, priority, label, application, (char*)data);
264
289
                        else
265
290
                                fprintf(dumpfile,"exten => %s,%d,%s(%s)\n", extension, priority, application, (char*)data);
266
291
 
267
 
                        if (data2) {
268
 
                                free(data2);
269
 
                                data2 = 0;
270
 
                                data = data3; /* restore data to pre-messedup state */
271
 
                        }
272
 
 
273
292
                } else {
274
293
 
275
294
                        if( strcmp(label,"(null)") != 0  )
313
332
        return x;
314
333
}
315
334
 
316
 
struct ast_context * ast_context_find_or_create(void **extcontexts, const char *name, const char *registrar)
 
335
struct ast_context * ast_context_find_or_create(void **extcontexts, void *tab, const char *name, const char *registrar)
317
336
{
318
337
        struct ast_context *x = calloc(1, sizeof(*x));
319
338
        if (!x)
400
419
                printf("Executed ast_context_destroy();\n");
401
420
}
402
421
 
403
 
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
404
 
{
405
 
        va_list vars;
406
 
        va_start(vars,fmt);
407
 
        if( !quiet || level > 2 ) {
408
 
            printf("LOG: lev:%d file:%s  line:%d func: %s  ",
409
 
                   level, file, line, function);
410
 
            vprintf(fmt, vars);
411
 
            fflush(stdout);
412
 
            va_end(vars);
413
 
        }
414
 
}
415
 
 
416
 
void ast_verbose(const char *fmt, ...)
417
 
{
418
 
        va_list vars;
419
 
        va_start(vars,fmt);
420
 
 
421
 
        printf("VERBOSE: ");
422
 
        vprintf(fmt, vars);
423
 
        fflush(stdout);
424
 
        va_end(vars);
425
 
}
426
 
 
427
 
char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
428
 
{
429
 
        char *dataPut = start;
430
 
        int inEscape = 0;
431
 
        int inQuotes = 0;
432
 
 
433
 
        for (; *start; start++) {
434
 
                if (inEscape) {
435
 
                        *dataPut++ = *start;       /* Always goes verbatim */
436
 
                        inEscape = 0;
437
 
                } else {
438
 
                        if (*start == '\\') {
439
 
                                inEscape = 1;      /* Do not copy \ into the data */
440
 
                        } else if (*start == '\'') {
441
 
                                inQuotes = 1-inQuotes;   /* Do not copy ' into the data */
442
 
                        } else {
443
 
                                /* Replace , with |, unless in quotes */
444
 
                                *dataPut++ = inQuotes ? *start : ((*start==find) ? replace_with : *start);
445
 
                        }
446
 
                }
447
 
        }
448
 
        if (start != dataPut)
449
 
                *dataPut = 0;
450
 
        return dataPut;
451
 
}
452
 
 
453
422
void filter_leading_space_from_exprs(char *str)
454
423
{
455
424
        /*  Mainly for aesthetics */
488
457
 
489
458
 
490
459
extern struct module_symbols mod_data;
491
 
extern int ael_external_load_module(void);
 
460
int ael_external_load_module(void);
 
461
 
492
462
 
493
463
int main(int argc, char **argv)
494
464
{
520
490
        }
521
491
 
522
492
        if( use_curr_dir ) {
523
 
                strcpy(ast_config_AST_CONFIG_DIR, ".");
 
493
                strcpy(config_dir, ".");
 
494
                localized_use_local_dir();
524
495
        }
525
496
        else {
526
 
                strcpy(ast_config_AST_CONFIG_DIR, "/etc/asterisk");
 
497
                strcpy(config_dir, "/etc/asterisk");
 
498
                localized_use_conf_dir();
527
499
        }
528
 
        strcpy(ast_config_AST_VAR_DIR, "/var/lib/asterisk");
 
500
        strcpy(var_dir, "/var/lib/asterisk");
529
501
        
530
502
        if( dump_extensions ) {
531
503
                dumpfile = fopen("extensions.conf.aeldump","w");
583
555
        
584
556
    return 0;
585
557
}
 
558
 
 
559
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
 
560
 
 
561
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
 
562
{
 
563
        return 0;
 
564
}
 
565
 
 
566
unsigned int ast_hashtab_hash_contexts(const void *obj);
 
567
 
 
568
unsigned int ast_hashtab_hash_contexts(const void *obj)
 
569
{
 
570
        return 0;
 
571
}
 
572
 
 
573
#ifdef DEBUG_THREADS
 
574
#if !defined(LOW_MEMORY)
 
575
void ast_mark_lock_acquired(void *lock_addr)
 
576
{
 
577
}
 
578
#ifdef HAVE_BKTR
 
579
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
 
580
{
 
581
}
 
582
 
 
583
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
 
584
        int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
 
585
{
 
586
}
 
587
 
 
588
int ast_bt_get_addresses(struct ast_bt *bt)
 
589
{
 
590
        return 0;
 
591
}
 
592
 
 
593
#else
 
594
void ast_remove_lock_info(void *lock_addr)
 
595
{
 
596
}
 
597
 
 
598
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
 
599
        int line_num, const char *func, const char *lock_name, void *lock_addr)
 
600
{
 
601
}
 
602
#endif /* HAVE_BKTR */
 
603
#endif /* !defined(LOW_MEMORY) */
 
604
#endif /* DEBUG_THREADS */