| 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_sw { |
| 38 |
const char *name; |
| 39 |
|
| 40 |
const char *registrar; |
| 41 |
|
| 42 |
const char *data; |
| 43 |
int eval; |
| 44 |
AST_LIST_ENTRY(ast_sw) list; |
| 45 |
char stuff[0]; |
| 46 |
}; |
| 47 |
|
| 48 |
const char *ast_get_switch_name(const struct ast_sw *sw) |
| 49 |
{ |
| 50 |
return sw ? sw->name : NULL; |
| 51 |
} |
| 52 |
|
| 53 |
const char *ast_get_switch_data(const struct ast_sw *sw) |
| 54 |
{ |
| 55 |
return sw ? sw->data : NULL; |
| 56 |
} |
| 57 |
|
| 58 |
int ast_get_switch_eval(const struct ast_sw *sw) |
| 59 |
{ |
| 60 |
return sw->eval; |
| 61 |
} |
| 62 |
|
| 63 |
const char *ast_get_switch_registrar(const struct ast_sw *sw) |
| 64 |
{ |
| 65 |
return sw ? sw->registrar : NULL; |
| 66 |
} |
| 67 |
|
| 68 |
struct ast_sw *sw_alloc(const char *value, const char *data, int eval, const char *registrar) |
| 69 |
{ |
| 70 |
struct ast_sw *new_sw; |
| 71 |
int length; |
| 72 |
char *p; |
| 73 |
|
| 74 |
if (!data) { |
| 75 |
data = ""; |
| 76 |
} |
| 77 |
length = sizeof(struct ast_sw); |
| 78 |
length += strlen(value) + 1; |
| 79 |
length += strlen(data) + 1; |
| 80 |
|
| 81 |
|
| 82 |
if (!(new_sw = ast_calloc(1, length))) { |
| 83 |
return NULL; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
p = new_sw->stuff; |
| 88 |
new_sw->name = p; |
| 89 |
strcpy(p, value); |
| 90 |
|
| 91 |
p += strlen(value) + 1; |
| 92 |
new_sw->data = p; |
| 93 |
strcpy(p, data); |
| 94 |
|
| 95 |
new_sw->eval = eval; |
| 96 |
new_sw->registrar = registrar; |
| 97 |
|
| 98 |
return new_sw; |
| 99 |
} |
| 100 |
|
| 101 |
void sw_free(struct ast_sw *sw) |
| 102 |
{ |
| 103 |
ast_free(sw); |
| 104 |
} |