| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#include "asterisk.h" |
| 31 |
|
| 32 |
#include "asterisk/_private.h" |
| 33 |
#include "asterisk/pbx.h" |
| 34 |
#include "pbx_private.h" |
| 35 |
|
| 36 |
|
| 37 |
struct ast_include { |
| 38 |
const char *name; |
| 39 |
|
| 40 |
const char *rname; |
| 41 |
|
| 42 |
const char *registrar; |
| 43 |
|
| 44 |
int hastime; |
| 45 |
|
| 46 |
struct ast_timing timing; |
| 47 |
char stuff[0]; |
| 48 |
}; |
| 49 |
|
| 50 |
const char *ast_get_include_name(const struct ast_include *inc) |
| 51 |
{ |
| 52 |
return inc ? inc->name : NULL; |
| 53 |
} |
| 54 |
|
| 55 |
const char *include_rname(const struct ast_include *inc) |
| 56 |
{ |
| 57 |
return inc ? inc->rname : NULL; |
| 58 |
} |
| 59 |
|
| 60 |
const char *ast_get_include_registrar(const struct ast_include *inc) |
| 61 |
{ |
| 62 |
return inc ? inc->registrar : NULL; |
| 63 |
} |
| 64 |
|
| 65 |
int include_valid(const struct ast_include *inc) |
| 66 |
{ |
| 67 |
if (!inc->hastime) { |
| 68 |
return 1; |
| 69 |
} |
| 70 |
|
| 71 |
return ast_check_timing(&(inc->timing)); |
| 72 |
} |
| 73 |
|
| 74 |
struct ast_include *include_alloc(const char *value, const char *registrar) |
| 75 |
{ |
| 76 |
struct ast_include *new_include; |
| 77 |
char *c; |
| 78 |
int valuebufsz = strlen(value) + 1; |
| 79 |
char *p; |
| 80 |
|
| 81 |
|
| 82 |
new_include = ast_calloc(1, sizeof(*new_include) + (valuebufsz * 2)); |
| 83 |
if (!new_include) { |
| 84 |
return NULL; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
p = new_include->stuff; |
| 91 |
new_include->name = p; |
| 92 |
strcpy(p, value); |
| 93 |
p += valuebufsz; |
| 94 |
new_include->rname = p; |
| 95 |
strcpy(p, value); |
| 96 |
|
| 97 |
if ( (c = strchr(p, '|')) || (c = strchr(p, ',')) ) { |
| 98 |
*c++ = '\0'; |
| 99 |
new_include->hastime = ast_build_timing(&(new_include->timing), c); |
| 100 |
} |
| 101 |
new_include->registrar = registrar; |
| 102 |
|
| 103 |
return new_include; |
| 104 |
} |
| 105 |
|
| 106 |
void include_free(struct ast_include *inc) |
| 107 |
{ |
| 108 |
ast_destroy_timing(&(inc->timing)); |
| 109 |
ast_free(inc); |
| 110 |
} |