static char global_server[80] = ""; /*!< Server to substitute into templates */
static char global_serverport[6] = ""; /*!< Server port to substitute into templates */
-static char global_default_profile[80] = ""; /*!< Default profile to use if one isn't specified */
+static char global_default_profile[80] = ""; /*!< Default profile to use if one isn't specified */
/*! \brief List of global variables currently available: VOICEMAIL_EXTEN, EXTENSION_LENGTH */
static struct varshead global_variables;
if (!strcasecmp(ftype, mimetypes[x].ext))
return mimetypes[x].mtype;
}
-
+
return NULL;
}
static int profile_hash_fn(const void *obj, const int flags)
{
const struct phone_profile *profile = obj;
-
+
return ast_str_case_hash(profile->name);
}
{
int len = 0;
FILE *f;
-
+
if (!(f = fopen(filename, "r"))) {
*ret = NULL;
return -1;
snprintf(buffer, sizeof(buffer), "%d", tzoffset);
var = ast_var_assign("TZOFFSET", buffer);
if (var)
- AST_LIST_INSERT_TAIL(headp, var, entries);
+ AST_LIST_INSERT_TAIL(headp, var, entries);
if (!dstenable)
return;
if ((var = ast_var_assign("DST_ENABLE", "1")))
AST_LIST_INSERT_TAIL(headp, var, entries);
- when.tv_sec = dststart;
+ when.tv_sec = dststart;
ast_localtime(&when, &tm_info, zone);
snprintf(buffer, sizeof(buffer), "%d", tm_info.tm_mon+1);
"Content-Length: %d\r\n"
"Content-Type: %s\r\n\r\n",
ast_get_version(), buf, len, route->file->mime_type);
-
+
while ((len = read(fd, buf, sizeof(buf))) > 0) {
if (fwrite(buf, 1, len, ser->f) != len) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
/* XXX This is a hack -- maybe sum length of all variables in route->user->headp and add that? */
bufsize = len + VAR_BUF_SIZE;
-
+
/* malloc() instead of alloca() here, just in case the file is bigger than
* we have enough stack space for. */
if (!(tmp = ast_calloc(1, bufsize))) {
}
pbx_substitute_variables_varshead(AST_LIST_FIRST(&route->user->extensions)->headp, file, tmp, bufsize);
-
+
if (file) {
ast_free(file);
}
static void build_route(struct phoneprov_file *pp_file, struct user *user, char *uri)
{
struct http_route *route;
-
+
if (!(route = ao2_alloc(sizeof(*route), route_destructor))) {
return;
}
profile = unref_profile(profile);
return;
}
-
+
if (!(profile->headp = ast_calloc(1, sizeof(*profile->headp)))) {
profile = unref_profile(profile);
return;
AST_APP_ARG(varname);
AST_APP_ARG(varval);
);
-
+
AST_NONSTANDARD_APP_ARGS(args, value_copy, '=');
do {
if (ast_strlen_zero(args.varname) || ast_strlen_zero(args.varval))
} else {
struct phoneprov_file *pp_file;
char *file_extension;
- char *value_copy = ast_strdupa(v->value);
+ char *value_copy = ast_strdupa(v->value);
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filename);
if (!(exten = ast_calloc(1, sizeof(*exten)))) {
return NULL;
}
-
+
if (ast_string_field_init(exten, 32)) {
ast_free(exten);
exten = NULL;
return NULL;
}
-
+
ast_string_field_set(exten, name, name);
-
+
if (!(exten->headp = ast_calloc(1, sizeof(*exten->headp)))) {
ast_free(exten);
exten = NULL;
static int users_hash_fn(const void *obj, const int flags)
{
const struct user *user = obj;
-
+
return ast_str_case_hash(user->macaddress);
}
if (user->profile) {
user->profile = unref_profile(user->profile);
}
-
+
ast_string_field_free_memory(user);
}
profile = unref_profile(profile);
return NULL;
}
-
+
if (ast_string_field_init(user, 32)) {
profile = unref_profile(profile);
user = unref_user(user);
else if (!strcasecmp(v->name, "default_profile"))
ast_copy_string(global_default_profile, v->value, sizeof(global_default_profile));
}
- } else
+ } else
build_profile(cat, ast_variable_browse(phoneprov_cfg, cat));
}
if (!strcasecmp(cat, "general")) {
continue;
}
-
+
if (!strcasecmp(cat, "authentication"))
continue;
- if (!((tmp = ast_variable_retrieve(cfg, cat, "autoprov")) && ast_true(tmp)))
+ if (!((tmp = ast_variable_retrieve(cfg, cat, "autoprov")) && ast_true(tmp)))
continue;
if (!(mac = ast_variable_retrieve(cfg, cat, "macaddress"))) {
{
struct ao2_iterator i;
struct http_route *route;
-
+
i = ao2_iterator_init(http_routes, 0);
while ((route = ao2_iterator_next(&i))) {
ao2_unlink(http_routes, route);
char path[PATH_MAX];
char *file;
int filelen;
- AST_DECLARE_APP_ARGS(args,
+ AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(mac);
AST_APP_ARG(template);
);
-
+
AST_STANDARD_APP_ARGS(args, data);
if (ast_strlen_zero(args.mac) || ast_strlen_zero(args.template)) {
#define FORMAT "%-40.40s %-30.30s\n"
struct ao2_iterator i;
struct http_route *route;
-
+
switch(cmd) {
case CLI_INIT:
e->command = "phoneprov show routes";
AST_LIST_HEAD_INIT_NOLOCK(&global_variables);
ast_mutex_init(&globals_lock);
-
+
ast_custom_function_register(&pp_each_user_function);
ast_custom_function_register(&pp_each_extension_function);
ast_cli_register_multiple(pp_cli, ARRAY_LEN(pp_cli));
set_config();
- ast_http_uri_link(&phoneprovuri);
+ ast_http_uri_link(&phoneprovuri);
return 0;
}
return 0;
}
-static int reload(void)
+static int reload(void)
{
struct ast_var_t *var;