#include "amxo_parser_priv.h"
#include "amxo_parser.tab.h"
#include "amxo_parser_hooks_priv.h"
Go to the source code of this file.
|
static int64_t | amxo_attr_2_param_attr (int64_t attributes) |
|
static void | amxo_parser_set_event (amxo_parser_t *pctx, event_id_t event) |
|
static void | amxo_parser_data_event (amxo_parser_t *pctx, amxd_param_t *param) |
|
static amxd_param_t * | amxo_parser_new_param (amxo_parser_t *pctx, const char *name, int64_t pattrs, uint32_t type) |
|
static int | amxo_parser_set_param_value (amxo_parser_t *pctx, const char *parent_path, const char *name, amxd_param_t *param, amxc_var_t *value) |
|
static bool | amxo_parser_add_param (amxo_parser_t *pctx, const char *name, int64_t pattrs, uint32_t type) |
|
static bool | amxo_parser_update_param (amxo_parser_t *pctx, amxd_param_t *param, const char *name, uint32_t type) |
|
static amxd_param_t * | amxo_parser_check_param (amxo_parser_t *pctx, const char *name, const char *parent_path, amxc_var_t *value, int *retval) |
|
bool | amxo_parser_set_param_attrs (amxo_parser_t *pctx, uint64_t attr, bool enable) |
|
bool | amxo_parser_set_param_flags (amxo_parser_t *pctx, amxc_var_t *flags) |
|
bool | amxo_parser_push_param (amxo_parser_t *pctx, const char *name, int64_t attr_bitmask, uint32_t type) |
|
int | amxo_parser_set_param (amxo_parser_t *pctx, const char *name, amxc_var_t *value) |
|
bool | amxo_parser_pop_param (amxo_parser_t *pctx) |
|
◆ _GNU_SOURCE
◆ amxo_attr_2_param_attr()
static int64_t amxo_attr_2_param_attr |
( |
int64_t |
attributes | ) |
|
|
static |
Definition at line 62 of file amxo_parser_dm_param_utils.c.
63 int64_t param_attrs = 0;
65 param_attrs |= SET_BIT(amxd_pattr_read_only);
68 param_attrs |= SET_BIT(amxd_pattr_persistent);
71 param_attrs |= SET_BIT(amxd_pattr_private);
74 param_attrs |= SET_BIT(amxd_pattr_protected);
77 param_attrs |= SET_BIT(amxd_pattr_template);
80 param_attrs |= SET_BIT(amxd_pattr_instance);
83 param_attrs |= SET_BIT(amxd_pattr_variable);
86 param_attrs |= SET_BIT(amxd_pattr_key);
89 param_attrs |= SET_BIT(amxd_pattr_unique);
92 param_attrs |= SET_BIT(amxd_pattr_mutable);
◆ amxo_parser_add_param()
static bool amxo_parser_add_param |
( |
amxo_parser_t * |
pctx, |
|
|
const char * |
name, |
|
|
int64_t |
pattrs, |
|
|
uint32_t |
type |
|
) |
| |
|
static |
Definition at line 175 of file amxo_parser_dm_param_utils.c.
180 amxd_param_t* param = NULL;
182 if(amxd_object_get_type(pctx->
object) == amxd_object_instance) {
183 pattrs |= SET_BIT(amxd_pattr_instance);
186 when_null(param, exit);
static amxd_param_t * amxo_parser_new_param(amxo_parser_t *pctx, const char *name, int64_t pattrs, uint32_t type)
PRIVATE void amxo_hooks_add_param(amxo_parser_t *parser, const char *name, int64_t attr_bitmask, uint32_t type)
◆ amxo_parser_check_param()
static amxd_param_t* amxo_parser_check_param |
( |
amxo_parser_t * |
pctx, |
|
|
const char * |
name, |
|
|
const char * |
parent_path, |
|
|
amxc_var_t * |
value, |
|
|
int * |
retval |
|
) |
| |
|
static |
Definition at line 226 of file amxo_parser_dm_param_utils.c.
231 amxd_param_t* param = NULL;
233 uint32_t type = amxc_var_is_null(value) ? AMXC_VAR_ID_CSTRING : amxc_var_type_of(value);
234 int64_t pattrs = SET_BIT(amxd_pattr_persistent);
235 if(amxd_object_get_type(pctx->
object) == amxd_object_instance) {
236 pattrs |= SET_BIT(amxd_pattr_instance);
238 if(amxd_object_get_type(pctx->
object) == amxd_object_template) {
239 pattrs |= SET_BIT(amxd_pattr_instance);
240 pattrs |= SET_BIT(amxd_pattr_template);
244 "populate-behavior.unknown-parameter",
247 "Parameter %s not found in object \"%s\"",
250 pctx->
status = amxd_status_parameter_not_found;
254 "Parameter %s not found in object \"%s\"",
257 pctx->
status = amxd_status_parameter_not_found;
PRIVATE bool amxo_parser_check_config(amxo_parser_t *pctx, const char *path, const char *check)
PRIVATE void amxo_parser_msg(amxo_parser_t *parser, const char *format,...) __attribute__((format(printf
◆ amxo_parser_data_event()
static void amxo_parser_data_event |
( |
amxo_parser_t * |
pctx, |
|
|
amxd_param_t * |
param |
|
) |
| |
|
static |
Definition at line 104 of file amxo_parser_dm_param_utils.c.
106 amxc_lstack_it_t* it = amxc_llist_get_last(&pctx->
event_list);
108 amxc_var_t* value = NULL;
111 if(amxc_var_type_of(&e->
data) != AMXC_VAR_ID_HTABLE) {
112 amxc_var_set_type(&e->
data, AMXC_VAR_ID_HTABLE);
114 value = GET_ARG(&e->
data, amxd_param_get_name(param));
115 when_not_null(value, exit);
117 amxc_var_set_key(&e->
data, amxd_param_get_name(param), ¶m->value, AMXC_VAR_FLAG_COPY);
◆ amxo_parser_new_param()
static amxd_param_t* amxo_parser_new_param |
( |
amxo_parser_t * |
pctx, |
|
|
const char * |
name, |
|
|
int64_t |
pattrs, |
|
|
uint32_t |
type |
|
) |
| |
|
static |
Definition at line 123 of file amxo_parser_dm_param_utils.c.
127 amxd_param_t* param = NULL;
129 pctx->
status = amxd_param_new(¶m, name, type);
130 if(pctx->
status != amxd_status_ok) {
134 amxd_param_set_attrs(param, pattrs,
true);
135 pctx->
status = amxd_object_add_param(pctx->
object, param);
◆ amxo_parser_pop_param()
Definition at line 348 of file amxo_parser_dm_param_utils.c.
351 amxc_var_init(&value);
353 if(pctx->
param != NULL) {
354 amxc_var_copy(&value, &pctx->
param->value);
355 pctx->
status = amxd_param_validate(pctx->
param, &value);
356 if(pctx->
status != amxd_status_ok) {
358 amxd_param_get_name(pctx->
param));
368 amxc_var_clean(&value);
PRIVATE void amxo_hooks_end_param(amxo_parser_t *parser)
◆ amxo_parser_push_param()
bool amxo_parser_push_param |
( |
amxo_parser_t * |
pctx, |
|
|
const char * |
name, |
|
|
int64_t |
attr_bitmask, |
|
|
uint32_t |
type |
|
) |
| |
Definition at line 292 of file amxo_parser_dm_param_utils.c.
296 amxd_param_t* param = NULL;
299 amxc_string_t res_name;
300 amxc_string_init(&res_name, 0);
304 if(amxc_string_set_resolved(&res_name, name, &pctx->
config) > 0) {
305 name = amxc_string_get(&res_name, 0);
308 pctx->
status = amxd_status_ok;
309 param = amxd_object_get_param_def(pctx->
object, name);
316 amxc_string_clean(&res_name);
static bool amxo_parser_add_param(amxo_parser_t *pctx, const char *name, int64_t pattrs, uint32_t type)
static void amxo_parser_set_event(amxo_parser_t *pctx, event_id_t event)
static bool amxo_parser_update_param(amxo_parser_t *pctx, amxd_param_t *param, const char *name, uint32_t type)
static int64_t amxo_attr_2_param_attr(int64_t attributes)
◆ amxo_parser_set_event()
◆ amxo_parser_set_param()
int amxo_parser_set_param |
( |
amxo_parser_t * |
pctx, |
|
|
const char * |
name, |
|
|
amxc_var_t * |
value |
|
) |
| |
Definition at line 320 of file amxo_parser_dm_param_utils.c.
323 amxd_param_t* param = NULL;
325 char* parent_path = amxd_object_get_path(pctx->
object, AMXD_OBJECT_NAMED);
326 amxc_string_t res_name;
327 amxc_string_init(&res_name, 0);
329 if(amxc_string_set_resolved(&res_name, name, &pctx->
config) > 0) {
330 name = amxc_string_get(&res_name, 0);
333 pctx->
status = amxd_status_ok;
334 param = pctx->
param == NULL ? amxd_object_get_param_def(pctx->
object, name) : pctx->param;
343 amxc_string_clean(&res_name);
static void amxo_parser_data_event(amxo_parser_t *pctx, amxd_param_t *param)
static amxd_param_t * amxo_parser_check_param(amxo_parser_t *pctx, const char *name, const char *parent_path, amxc_var_t *value, int *retval)
static int amxo_parser_set_param_value(amxo_parser_t *pctx, const char *parent_path, const char *name, amxd_param_t *param, amxc_var_t *value)
◆ amxo_parser_set_param_attrs()
bool amxo_parser_set_param_attrs |
( |
amxo_parser_t * |
pctx, |
|
|
uint64_t |
attr, |
|
|
bool |
enable |
|
) |
| |
◆ amxo_parser_set_param_flags()
bool amxo_parser_set_param_flags |
( |
amxo_parser_t * |
pctx, |
|
|
amxc_var_t * |
flags |
|
) |
| |
Definition at line 269 of file amxo_parser_dm_param_utils.c.
270 const amxc_htable_t* ht_flags = NULL;
272 when_null(flags, exit);
273 when_true(amxc_var_type_of(flags) != AMXC_VAR_ID_HTABLE, exit);
275 ht_flags = amxc_var_constcast(amxc_htable_t, flags);
276 amxc_htable_for_each(it, ht_flags) {
277 const char* flag_name = amxc_htable_it_get_key(it);
278 amxc_var_t* flag = amxc_var_from_htable_it(it);
279 if(amxc_var_dyncast(
bool, flag)) {
280 amxd_param_set_flag(pctx->
param, flag_name);
282 amxd_param_unset_flag(pctx->
param, flag_name);
286 amxc_var_delete(&flags);
◆ amxo_parser_set_param_value()
static int amxo_parser_set_param_value |
( |
amxo_parser_t * |
pctx, |
|
|
const char * |
parent_path, |
|
|
const char * |
name, |
|
|
amxd_param_t * |
param, |
|
|
amxc_var_t * |
value |
|
) |
| |
|
static |
Definition at line 141 of file amxo_parser_dm_param_utils.c.
147 if((value != NULL) && (param != NULL)) {
148 if((amxc_var_type_of(value) == AMXC_VAR_ID_HTABLE) ||
149 (amxc_var_type_of(value) == AMXC_VAR_ID_LIST)) {
150 pctx->
status = amxd_status_invalid_value;
152 pctx->
status = amxd_param_set_value(param, value);
154 if(pctx->
status == amxd_status_invalid_value) {
156 "Invalid parameter value for parameter %s in object \"%s\"",
159 }
else if(pctx->
status == amxd_status_ok) {
PRIVATE void amxo_hooks_set_param(amxo_parser_t *parser, amxc_var_t *value)
◆ amxo_parser_update_param()
static bool amxo_parser_update_param |
( |
amxo_parser_t * |
pctx, |
|
|
amxd_param_t * |
param, |
|
|
const char * |
name, |
|
|
uint32_t |
type |
|
) |
| |
|
static |
Definition at line 196 of file amxo_parser_dm_param_utils.c.
203 "define-behavior.existing-parameter",
206 pctx->
status = amxd_status_duplicate;
209 if((type != AMXC_VAR_ID_LIST) &&
210 ( type != AMXC_VAR_ID_HTABLE) &&
211 ( type != AMXC_VAR_ID_FD)) {
212 amxc_var_set_type(¶m->value, type);
214 amxo_parser_msg(pctx,
"Invalid parameter type for parameter %s", name);
215 pctx->
status = amxd_status_invalid_type;