69
69
#include "asterisk/threadstorage.h"
70
70
#include "asterisk/linkedlists.h"
71
71
#include "asterisk/term.h"
72
#include "asterisk/astobj2.h"
73
74
struct fast_originate_helper {
74
75
char tech[AST_MAX_EXTENSION];
278
struct variable_count {
283
static int compress_char(char c)
288
else if (c >= 'a' && c <= 'z')
296
static int variable_count_hash_fn(const void *vvc, const int flags)
298
const struct variable_count *vc = vvc;
300
for (i = 0; i < 5; i++) {
301
if (vc->varname[i] == '\0')
303
res += compress_char(vc->varname[i]) << (i * 6);
308
static int variable_count_cmp_fn(void *obj, void *vstr, int flags)
310
/* Due to the simplicity of struct variable_count, it makes no difference
311
* if you pass in objects or strings, the same operation applies. This is
312
* due to the fact that the hash occurs on the first element, which means
313
* the address of both the struct and the string are exactly the same. */
314
struct variable_count *vc = obj;
316
return !strcmp(vc->varname, str) ? CMP_MATCH : 0;
277
319
static char *xml_translate(char *in, struct ast_variable *vars)
279
321
struct ast_variable *v;
332
struct variable_count *vc = NULL;
333
struct ao2_container *vco = NULL;
291
335
for (v = vars; v; v = v->next) {
292
336
if (!dest && !strcasecmp(v->name, "ajaxdest"))
304
348
else if (in[x] == '\n')
306
else if (strchr("&\"<>", in[x]))
350
else if (strchr("&\"<>\'", in[x]))
309
353
len = (size_t) (strlen(in) + colons * 5 + breaks * (40 + strlen(dest) + strlen(objtype)) + escaped * 10); /* foo="bar", "<response type=\"object\" id=\"dest\"", "&" */
319
363
if ((count > 3) && inobj) {
320
364
ast_build_string(&tmp, &len, " /></response>\n");
367
/* Entity is closed, so close out the name cache */
324
372
while (*in && (*in < 32)) {
384
vco = ao2_container_alloc(37, variable_count_hash_fn, variable_count_cmp_fn);
336
385
ast_build_string(&tmp, &len, "<response type='object' id='%s'><%s", dest, objtype);
339
ast_build_string(&tmp, &len, " ");
389
/* Check if the var has been used already */
390
if ((vc = ao2_find(vco, var, 0)))
393
/* Create a new entry for this one */
394
vc = ao2_alloc(sizeof(*vc), NULL);
397
/* Increment refcount, because we're going to deref once later */
402
ast_build_string(&tmp, &len, " ");
340
403
xml_copy_escape(&tmp, &len, var, 1);
405
ast_build_string(&tmp, &len, "-%d", vc->count);
341
406
ast_build_string(&tmp, &len, "='");
342
407
xml_copy_escape(&tmp, &len, val, 0);
343
408
ast_build_string(&tmp, &len, "'");
348
414
ast_build_string(&tmp, &len, " /></response>\n");
986
1054
struct ast_variable *v;
987
1055
const char *password = NULL;
988
1056
int hasmanager = 0;
1057
const char *readperms = NULL;
1058
const char *writeperms = NULL;
989
1060
if (strcasecmp(cat, user) || !strcasecmp(cat, "general")) {
990
1061
cat = ast_category_browse(cfg, cat);
995
1066
password = v->value;
996
1067
else if (!strcasecmp(v->name, "hasmanager"))
997
1068
hasmanager = ast_true(v->value);
1069
else if (!strcasecmp(v->name, "managerread"))
1070
readperms = v->value;
1071
else if (!strcasecmp(v->name, "managerwrite"))
1072
writeperms = v->value;
999
1074
if (!hasmanager)
1006
1081
ast_copy_string(s->username, cat, sizeof(s->username));
1082
s->readperm = readperms ? get_perm(readperms) : -1;
1083
s->writeperm = writeperms ? get_perm(writeperms) : -1;
1009
1084
ast_config_destroy(cfg);
1011
1086
set_eventmask(s, events);
1648
1723
term_strip(final_buf, buf, l);
1649
1724
final_buf[l] = '\0';
1651
astman_append(s, S_OR(final_buf, buf));
1726
astman_append(s, "%s", S_OR(final_buf, buf));