libamxo  4.3.4
Object Definition Language (ODL) parsing
amxo_parser_priv.h File Reference
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <libgen.h>
#include <ctype.h>
#include <dlfcn.h>
#include <unistd.h>
#include <dirent.h>
#include <syslog.h>
#include <amxc/amxc_macros.h>
#include <amxc/amxc.h>
#include <amxp/amxp.h>
#include <amxd/amxd_common.h>
#include <amxd/amxd_dm.h>
#include <amxd/amxd_object.h>
#include <amxd/amxd_object_expression.h>
#include <amxd/amxd_object_event.h>
#include <amxd/amxd_parameter.h>
#include <amxd/amxd_action.h>
#include <amxd/amxd_path.h>
#include <amxo/amxo.h>
#include <amxs/amxs.h>

Go to the source code of this file.

Data Structures

struct  _event
 
struct  _amxo_txt
 
struct  _amxo_txt_regexp
 
struct  _amxo_res_data
 

Typedefs

typedef enum _amxo_parser_attr amxo_parser_attr_t
 
typedef enum _amxo_action amxo_action_t
 
typedef enum _event_id event_id_t
 
typedef struct _event event_t
 
typedef struct _amxo_txt amxo_txt_t
 
typedef struct _amxo_txt_regexp amxo_txt_regexp_t
 
typedef struct _amxo_res_data amxo_res_data_t
 

Enumerations

enum  amxo_parser_tokens_t {
  token_include , token_optional_include , token_conditional_include , token_post_include ,
  token_import , token_config , token_define , token_populate ,
  token_object , token_mib , token_keyword , token_eof ,
  token_requires
}
 
enum  _amxo_parser_attr {
  attr_readonly , attr_persistent , attr_private , attr_template ,
  attr_instance , attr_variable , attr_in , attr_out ,
  attr_mandatory , attr_strict , attr_key , attr_unique ,
  attr_protected , attr_mutable , attr_asynchronous
}
 
enum  _amxo_action {
  amxo_action_invalid = -1 , action_all = 0 , action_read , action_write ,
  action_validate , action_list , action_describe , action_add_inst ,
  action_del_inst , action_destroy , action_translate , action_apply ,
  action_max = action_apply
}
 
enum  _event_id { event_none , event_instance_add , event_object_change }
 

Functions

PRIVATE void amxo_parser_free_event (amxc_llist_it_t *it)
 
PRIVATE void amxo_ftab_fn_free (const char *key, amxc_htable_it_t *it)
 
PRIVATE void amxo_parser_del_mib_info (const char *key, amxc_htable_it_t *it)
 
PRIVATE ssize_t amxo_parser_fd_reader (amxo_parser_t *parser, char *buf, size_t max_size)
 
PRIVATE int amxo_parser_parse_file_impl (amxo_parser_t *parser, const char *file_path, amxd_object_t *object)
 
PRIVATE void amxo_parser_child_init (amxo_parser_t *parser)
 
PRIVATE void amxo_parser_create_lex (amxo_parser_t *parser)
 
PRIVATE void amxo_parser_destroy_lex (amxo_parser_t *parser)
 
PRIVATE void amxo_parser_msg (amxo_parser_t *parser, const char *format,...) __attribute__((format(printf
 
PRIVATE void PRIVATE int amxo_parser_printf (amxo_parser_t *parser, const char *format,...) __attribute__((format(printf
 
PRIVATE void PRIVATE int PRIVATE bool amxo_parser_find (amxo_parser_t *parser, const amxc_llist_t *dirs, const char *file_path, char **full_path)
 
PRIVATE bool amxo_parser_check_attr (amxo_parser_t *pctx, int64_t attributes, int64_t bitmask)
 
PRIVATE bool amxo_parser_set_param_attrs (amxo_parser_t *pctx, uint64_t attr, bool enable)
 
PRIVATE bool amxo_parser_set_param_flags (amxo_parser_t *pctx, amxc_var_t *flags)
 
PRIVATE bool amxo_parser_set_object_attrs (amxo_parser_t *pctx, uint64_t attr, bool enable)
 
PRIVATE int amxo_parser_create_object (amxo_parser_t *pctx, const char *name, int64_t attr_bitmask, amxd_object_type_t type)
 
PRIVATE bool amxo_parser_add_instance (amxo_parser_t *pctx, uint32_t index, const char *name, amxc_var_t *params)
 
PRIVATE bool amxo_parser_push_object (amxo_parser_t *pctx, const char *name)
 
PRIVATE bool amxo_parser_pop_object (amxo_parser_t *pctx)
 
PRIVATE bool amxo_parser_push_param (amxo_parser_t *pctx, const char *name, int64_t attr_bitmask, uint32_t type)
 
PRIVATE int amxo_parser_set_param (amxo_parser_t *pctx, const char *name, amxc_var_t *value)
 
PRIVATE bool amxo_parser_pop_param (amxo_parser_t *pctx)
 
PRIVATE int amxo_parser_push_func (amxo_parser_t *pctx, const char *name, int64_t attr_bitmask, uint32_t type)
 
PRIVATE bool amxo_parser_set_function_flags (amxo_parser_t *pctx, amxc_var_t *flags)
 
PRIVATE void amxo_parser_pop_func (amxo_parser_t *pctx)
 
PRIVATE bool amxo_parser_add_arg (amxo_parser_t *pctx, const char *name, int64_t attr_bitmask, uint32_t type, amxc_var_t *def_value)
 
PRIVATE bool amxo_parser_set_counter (amxo_parser_t *pctx, const char *param_name)
 
PRIVATE int amxo_parser_subscribe_path (amxo_parser_t *pctx, const char *event, bool event_is_regexp, const char *path, bool path_is_regexp)
 
PRIVATE int amxo_parser_subscribe (amxo_parser_t *pctx, const char *event, bool event_is_regexp, const char *full_expr)
 
PRIVATE int amxo_parser_subscribe_object (amxo_parser_t *pctx, const char *event, bool event_is_regexp, const char *full_expr)
 
PRIVATE int amxo_parser_add_post_include (amxo_parser_t *pctx, const char *file_path)
 
PRIVATE int amxo_parser_include (amxo_parser_t *pctx, const char *file_path)
 
PRIVATE amxc_htable_t * amxo_parser_get_resolvers (void)
 
PRIVATE int amxo_parser_resolve_internal (amxo_parser_t *parser, const char *fn_name, amxo_fn_type_t type, const char *data)
 
PRIVATE void amxo_resolver_import_clean (amxo_parser_t *parser, void *priv)
 
PRIVATE int amxo_parser_resolve (amxo_parser_t *parser, const char *resolver_name, const char *func_name, amxo_fn_type_t type, const char *data)
 
PRIVATE void amxo_parser_clean_resolvers (amxo_parser_t *parser)
 
PRIVATE void amxo_parser_init_resolvers (amxo_parser_t *parser)
 
PRIVATE int amxo_parser_call_entry_point (amxo_parser_t *pctx, const char *lib_name, const char *fn_name)
 
PRIVATE int amxo_parser_set_action (amxo_parser_t *pctx, amxo_action_t action, const char *name, amxc_var_t *data)
 
PRIVATE amxo_action_t amxo_parser_get_action_id (amxo_parser_t *pctx, const char *action_name)
 
PRIVATE void amxo_parser_print (amxo_parser_t *pctx, const char *text)
 
PRIVATE bool amxo_parser_add_mib (amxo_parser_t *pctx, const char *mib_name)
 
PRIVATE bool amxo_parser_no_resolve (amxo_parser_t *parser)
 
PRIVATE bool amxo_parser_check_config (amxo_parser_t *pctx, const char *path, const char *check)
 
PRIVATE void amxo_parser_resolve_value (amxo_parser_t *pctx, amxc_string_t *value)
 
PRIVATE void amxo_parser_del_sync_data (amxc_llist_it_t *it)
 
PRIVATE void amxo_parser_pop_sync_item (amxo_parser_t *pctx)
 
PRIVATE int amxo_parser_push_sync_ctx (amxo_parser_t *pctx, const char *path_a, const char *path_b, int direction)
 
PRIVATE int amxo_parser_push_sync_template (amxo_parser_t *pctx, const char *path_a, const char *path_b, int direction, const char *name)
 
PRIVATE int amxo_parser_push_sync_object (amxo_parser_t *pctx, const char *path_a, const char *path_b, int direction)
 
PRIVATE int amxo_parser_push_sync_parameter (amxo_parser_t *pctx, const char *param_a, const char *param_b, int direction)
 
PRIVATE int amxo_parser_start_sync (amxc_llist_it_t *it)
 
PRIVATE void amxo_parser_stop_sync (amxc_llist_it_t *it)
 
PRIVATE amxs_sync_entry_type_t amxo_parser_get_sync_type (amxo_parser_t *pctx)
 
PRIVATE bool amxo_parser_is_sync_item (amxo_parser_t *pctx)
 
PRIVATE amxd_status_t amxo_parser_sync_set_translator (amxo_parser_t *pctx, amxs_translation_cb_t cb)
 
PRIVATE amxd_status_t amxo_parser_sync_set_action (amxo_parser_t *pctx, amxs_action_cb_t cb)
 
PRIVATE bool amxo_parser_sync_item_contains_entries (amxo_parser_t *pctx)
 
PRIVATE void amxo_parser_sync_remove_invalid (amxo_parser_t *pctx)
 
PRIVATE int amxo_parser_sync_update_flags (int direction)
 
PRIVATE amxs_sync_ctx_t * amxo_parser_sync_get (const char *sync_template)
 

Typedef Documentation

◆ amxo_action_t

◆ amxo_parser_attr_t

◆ amxo_res_data_t

◆ amxo_txt_regexp_t

◆ amxo_txt_t

typedef struct _amxo_txt amxo_txt_t

◆ event_id_t

typedef enum _event_id event_id_t

◆ event_t

typedef struct _event event_t

Enumeration Type Documentation

◆ _amxo_action

Enumerator
amxo_action_invalid 
action_all 
action_read 
action_write 
action_validate 
action_list 
action_describe 
action_add_inst 
action_del_inst 
action_destroy 
action_translate 
action_apply 
action_max 

Definition at line 128 of file amxo_parser_priv.h.

128  {
129  amxo_action_invalid = -1,
130  action_all = 0,
131  action_read,
132  action_write,
134  action_list,
140  action_apply,
142 } amxo_action_t;
@ action_read
@ action_translate
@ action_all
@ action_write
@ action_apply
@ action_add_inst
@ action_list
@ action_describe
@ amxo_action_invalid
@ action_max
@ action_destroy
@ action_del_inst
@ action_validate
enum _amxo_action amxo_action_t

◆ _amxo_parser_attr

Enumerator
attr_readonly 
attr_persistent 
attr_private 
attr_template 
attr_instance 
attr_variable 
attr_in 
attr_out 
attr_mandatory 
attr_strict 
attr_key 
attr_unique 
attr_protected 
attr_mutable 
attr_asynchronous 

Definition at line 110 of file amxo_parser_priv.h.

110  {
113  attr_private,
117  attr_in,
118  attr_out,
120  attr_strict,
121  attr_key,
122  attr_unique,
124  attr_mutable,
@ attr_instance
@ attr_variable
@ attr_protected
@ attr_asynchronous
@ attr_template
@ attr_persistent
@ attr_readonly
@ attr_mandatory
@ attr_private
@ attr_strict
@ attr_in
@ attr_key
@ attr_unique
@ attr_out
@ attr_mutable
enum _amxo_parser_attr amxo_parser_attr_t

◆ _event_id

enum _event_id
Enumerator
event_none 
event_instance_add 
event_object_change 

Definition at line 144 of file amxo_parser_priv.h.

144  {
145  event_none,
148 } event_id_t;
enum _event_id event_id_t
@ event_instance_add
@ event_object_change
@ event_none

◆ amxo_parser_tokens_t

Enumerator
token_include 
token_optional_include 
token_conditional_include 
token_post_include 
token_import 
token_config 
token_define 
token_populate 
token_object 
token_mib 
token_keyword 
token_eof 
token_requires 

Definition at line 93 of file amxo_parser_priv.h.

94 {
100  token_config,
101  token_define,
103  token_object,
104  token_mib,
106  token_eof,
108 };
@ token_define
@ token_post_include
@ token_requires
@ token_object
@ token_conditional_include
@ token_mib
@ token_eof
@ token_keyword
@ token_import
@ token_populate
@ token_optional_include
@ token_include
@ token_config

Function Documentation

◆ amxo_ftab_fn_free()

PRIVATE void amxo_ftab_fn_free ( const char *  key,
amxc_htable_it_t *  it 
)

◆ amxo_parser_add_arg()

PRIVATE bool amxo_parser_add_arg ( amxo_parser_t pctx,
const char *  name,
int64_t  attr_bitmask,
uint32_t  type,
amxc_var_t *  def_value 
)

Definition at line 182 of file amxo_parser_dm_func_utils.c.

186  {
187  bool retval = false;
188  int64_t aattrs = amxo_attr_2_arg_attr(attr_bitmask);
189  if(!IS_BIT_SET(aattrs, amxd_aattr_in) &&
190  !IS_BIT_SET(aattrs, amxd_aattr_out)) {
191  aattrs |= 1 << amxd_aattr_in;
192  }
193 
194  amxo_hooks_add_func_arg(pctx, name, aattrs, type, def_value);
195 
196  pctx->status = amxd_function_new_arg(pctx->func, name, type, def_value);
197  if(pctx->status != amxd_status_ok) {
198  amxo_parser_msg(pctx, "Failed to create/add function argument %s", name);
199  goto exit;
200  }
201 
202  amxd_function_arg_set_attrs(pctx->func, name, aattrs, true);
203  retval = true;
204 
205 exit:
206  return retval;
207 }
static int64_t amxo_attr_2_arg_attr(int64_t attributes)
PRIVATE void amxo_hooks_add_func_arg(amxo_parser_t *parser, const char *name, int64_t attr_bitmask, uint32_t type, amxc_var_t *def_value)
PRIVATE void amxo_parser_msg(amxo_parser_t *parser, const char *format,...) __attribute__((format(printf
amxd_status_t status
Definition: amxo_types.h:258
amxd_function_t * func
Definition: amxo_types.h:264

◆ amxo_parser_add_instance()

PRIVATE bool amxo_parser_add_instance ( amxo_parser_t pctx,
uint32_t  index,
const char *  name,
amxc_var_t *  params 
)

Definition at line 563 of file amxo_parser_dm_utils.c.

566  {
567  amxd_object_t* object = NULL;
568  amxd_object_t* parent_obj = pctx->object;
569  bool retval = false;
570  amxc_string_t res_name;
571  amxc_string_init(&res_name, 0);
572 
573  if(amxc_string_set_resolved(&res_name, name, &pctx->config) > 0) {
574  name = amxc_string_get(&res_name, 0);
575  }
576 
577  pctx->status = amxd_object_add_instance(&object,
578  parent_obj,
579  name,
580  index,
581  params);
582  object = amxd_parser_add_instance_msg(pctx, index, name, object, params);
583  when_null(object, exit);
584  when_failed(pctx->status, exit);
585  amxo_hooks_add_instance(pctx, amxd_object_get_index(object),
586  amxd_object_get_name(object, AMXD_OBJECT_NAMED));
587  amxc_astack_push(&pctx->object_stack, pctx->object);
588  pctx->object = object;
590  retval = true;
591 
592 exit:
593  amxc_string_clean(&res_name);
594  amxc_var_delete(&params);
595  return retval;
596 }
static void amxo_parser_push_event(amxo_parser_t *pctx, event_id_t event)
static amxd_object_t * amxd_parser_add_instance_msg(amxo_parser_t *pctx, uint32_t index, const char *name, amxd_object_t *object, amxc_var_t *params)
PRIVATE void amxo_hooks_add_instance(amxo_parser_t *parser, uint32_t index, const char *name)
amxc_astack_t object_stack
Definition: amxo_types.h:261
amxc_var_t config
Definition: amxo_types.h:250
amxd_object_t * object
Definition: amxo_types.h:262

◆ amxo_parser_add_mib()

PRIVATE bool amxo_parser_add_mib ( amxo_parser_t pctx,
const char *  mib_name 
)

Definition at line 843 of file amxo_parser_dm_utils.c.

844  {
845  bool retval = false;
846  amxd_dm_t* dm = amxd_object_get_dm(pctx->object);
847  amxd_object_t* mib = NULL;
848  amxc_string_t res_mib_name;
849  amxc_string_init(&res_mib_name, 0);
850 
851  if(amxc_string_set_resolved(&res_mib_name, mib_name, &pctx->config) > 0) {
852  mib_name = amxc_string_get(&res_mib_name, 0);
853  }
854 
855  when_null(dm, exit);
856 
857  if(amxd_object_has_mib(pctx->object, mib_name)) {
858  retval = true;
859  goto exit;
860  }
861 
862  mib = amxd_dm_get_mib(dm, mib_name);
863  if(mib == NULL) {
864  const char* file = amxo_parser_get_mib_file(pctx, mib_name);
865  if(file != NULL) {
866  amxo_parser_include(pctx, file);
867  mib = amxd_dm_get_mib(dm, mib_name);
868  }
869  if(mib == NULL) {
870  amxo_parser_msg(pctx, "MIB %s is not found", mib_name);
871  pctx->status = amxd_status_object_not_found;
872  goto exit;
873  }
874  }
875 
876  pctx->status = amxd_object_add_mib(pctx->object, mib_name);
877  if(pctx->status != amxd_status_ok) {
878  amxo_parser_msg(pctx,
879  "Failed to add MIB %s on object %s",
880  mib_name,
881  amxd_object_get_name(pctx->object, AMXD_OBJECT_NAMED));
882  goto exit;
883  }
884 
885  retval = true;
886 
887  amxo_hooks_add_mib(pctx, mib_name);
888 
889 exit:
890  amxc_string_clean(&res_mib_name);
891  return retval;
892 }
PRIVATE void amxo_hooks_add_mib(amxo_parser_t *parser, const char *mib)
PRIVATE int amxo_parser_include(amxo_parser_t *pctx, const char *file_path)
const char * amxo_parser_get_mib_file(amxo_parser_t *parser, const char *mib_name)
Get full path and file name of odl file describing a mib.

◆ amxo_parser_add_post_include()

PRIVATE int amxo_parser_add_post_include ( amxo_parser_t pctx,
const char *  file_path 
)

Definition at line 290 of file amxo_parser_include.c.

290  {
291  int retval = -1;
292  char* full_path = NULL;
293  amxc_var_t* incstack = NULL;
294 
295  retval = amxo_parser_check(pctx, file_path, &incstack, &full_path);
296  when_failed(retval, exit);
297 
298  if(pctx->post_includes == NULL) {
299  amxc_var_new(&pctx->post_includes);
300  amxc_var_set_type(pctx->post_includes, AMXC_VAR_ID_LIST);
301  }
302 
303  amxc_var_add(cstring_t, pctx->post_includes, full_path);
304 
305 exit:
306  amxc_var_delete(&incstack);
307  free(full_path);
308  return retval;
309 }
static int amxo_parser_check(amxo_parser_t *pctx, const char *file_path, amxc_var_t **incstack, char **full_path)
amxc_var_t * post_includes
Definition: amxo_types.h:275

◆ amxo_parser_call_entry_point()

PRIVATE int amxo_parser_call_entry_point ( amxo_parser_t pctx,
const char *  lib_name,
const char *  fn_name 
)

Definition at line 172 of file amxo_parser_utils.c.

174  {
175  int retval = -1;
176  amxc_string_t data;
177  amxc_string_init(&data, 0);
178  amxc_string_setf(&data, "%s", lib_name);
179 
180  when_true_status(amxo_parser_no_resolve(pctx), exit, retval = 0);
181 
182  pctx->resolved_fn = NULL;
183  retval = amxo_parser_resolve(pctx, "import", fn_name, amxo_function_ep, amxc_string_get(&data, 0));
184  if(retval == 1) {
185  amxo_parser_msg(pctx,
186  "No entry point \"%s\" found using \"%s\"",
187  fn_name,
188  "import");
189  pctx->status = amxd_status_function_not_found;
190  }
191 
192  if(pctx->resolved_fn != NULL) {
194  retval = amxo_parser_add_entry_point(pctx, fn);
195  amxc_string_delete(&pctx->resolved_fn_name);
196  }
197 
198 exit:
199  amxc_string_clean(&data);
200  return retval;
201 }
PRIVATE int amxo_parser_resolve(amxo_parser_t *parser, const char *resolver_name, const char *func_name, amxo_fn_type_t type, const char *data)
bool amxo_parser_no_resolve(amxo_parser_t *parser)
void amxo_parser_msg(amxo_parser_t *parser, const char *format,...)
@ amxo_function_ep
Definition: amxo_types.h:86
int(* amxo_entry_point_t)(int reason, amxd_dm_t *dm, amxo_parser_t *parser)
Definition: amxo_types.h:218
int amxo_parser_add_entry_point(amxo_parser_t *parser, amxo_entry_point_t fn)
Adds an entry point function.
amxo_fn_ptr_t resolved_fn
Definition: amxo_types.h:266
amxc_string_t * resolved_fn_name
Definition: amxo_types.h:267

◆ amxo_parser_check_attr()

PRIVATE bool amxo_parser_check_attr ( amxo_parser_t pctx,
int64_t  attributes,
int64_t  bitmask 
)

Definition at line 499 of file amxo_parser_dm_utils.c.

501  {
502  bool retval = false;
503  int attr_mask = ~bitmask;
504 
505  int check_attr = attributes | attr_mask;
506  pctx->status = (check_attr != attr_mask) ? amxd_status_ok : amxd_status_invalid_attr;
507  retval = (check_attr != attr_mask);
508  if(!retval) {
509  amxo_parser_msg(pctx, "Invalid attributes given");
510  }
511  return retval;
512 }

◆ amxo_parser_check_config()

PRIVATE bool amxo_parser_check_config ( amxo_parser_t pctx,
const char *  path,
const char *  check 
)

Definition at line 477 of file amxo_parser_dm_utils.c.

479  {
480  amxc_var_t* option = amxc_var_get_path(&pctx->config,
481  path,
482  AMXC_VAR_FLAG_DEFAULT);
483  const char* value = NULL;
484  value = amxc_var_constcast(cstring_t, option);
485 
486  if(value == NULL) {
487  value = "error";
488  }
489 
490  return strcmp(value, check) == 0;
491 }

◆ amxo_parser_child_init()

PRIVATE void amxo_parser_child_init ( amxo_parser_t parser)

Definition at line 181 of file amxo_parser_main.c.

181  {
182  when_null(parser, exit);
183 
184  parser->fd = -1;
185  parser->object = NULL;
186  parser->param = NULL;
187  parser->func = NULL;
188  parser->status = amxd_status_ok;
189  parser->resolved_fn = NULL;
190  parser->resolvers = NULL;
191  parser->include_stack = NULL;
192  parser->hooks = NULL;
193  parser->entry_points = NULL;
194  parser->_unused_1 = NULL;
195  parser->_unused_2 = NULL;
196  parser->post_includes = NULL;
197  parser->parent = NULL;
198  parser->resolved_fn_name = NULL;
199  parser->buffer_len = 0;
200  parser->data = NULL;
201  parser->sync_contexts = NULL;
202 
203  memset(parser->buffer, 0, 128);
204  amxc_rbuffer_init(&parser->rbuffer, 0);
205  amxc_string_init(&parser->msg, 0);
206  amxc_astack_init(&parser->object_stack);
207  amxc_llist_init(&parser->event_list);
208  amxc_var_init(&parser->config);
209  amxc_llist_init(&parser->global_config);
210  amxc_htable_init(&parser->mibs, 5);
211  amxc_llist_init(&parser->function_names);
212 
213  parser->file = "<unknown>";
214 
215 exit:
216  return;
217 }
amxc_htable_t * resolvers
Definition: amxo_types.h:269
amxc_htable_t mibs
Definition: amxo_types.h:282
amxc_llist_t * hooks
Definition: amxo_types.h:274
char buffer[128]
Definition: amxo_types.h:287
amxc_llist_t * _unused_2
Definition: amxo_types.h:272
size_t buffer_len
Definition: amxo_types.h:288
amxc_lstack_t event_list
Definition: amxo_types.h:283
amxc_llist_t function_names
Definition: amxo_types.h:268
amxc_string_t msg
Definition: amxo_types.h:259
amxd_param_t * param
Definition: amxo_types.h:263
amxc_rbuffer_t rbuffer
Definition: amxo_types.h:256
amxc_var_t * include_stack
Definition: amxo_types.h:277
amxc_llist_t * _unused_1
Definition: amxo_types.h:271
const char * file
Definition: amxo_types.h:279
amxc_llist_t * entry_points
Definition: amxo_types.h:273
amxc_var_t * data
Definition: amxo_types.h:265
amxc_llist_t global_config
Definition: amxo_types.h:253
amxo_parser_t * parent
Definition: amxo_types.h:285
amxc_llist_t * sync_contexts
Definition: amxo_types.h:290

◆ amxo_parser_clean_resolvers()

PRIVATE void amxo_parser_clean_resolvers ( amxo_parser_t parser)

Definition at line 103 of file amxo_resolver_mngr.c.

103  {
104  amxc_htable_it_t* hit_data = NULL;
105  amxc_htable_it_t* hit_resolver = NULL;
106 
107  when_null(parser->resolvers, exit);
108 
109  hit_data = amxc_htable_get_first(parser->resolvers);
110  while(hit_data) {
111  const char* key = amxc_htable_it_get_key(hit_data);
112  amxo_resolver_t* resolver = NULL;
113  hit_resolver = amxc_htable_get(&resolvers, key);
114  resolver = amxc_htable_it_get_data(hit_resolver, amxo_resolver_t, hit);
115  if(resolver->clean != NULL) {
116  resolver->clean(parser, resolver->priv);
117  }
118  hit_data = amxc_htable_get_first(parser->resolvers);
119  }
120 
121 exit:
122  return;
123 }
static amxc_htable_t resolvers
amxo_res_clean_fn_t clean
Definition: amxo_types.h:104

◆ amxo_parser_create_lex()

PRIVATE void amxo_parser_create_lex ( amxo_parser_t parser)

◆ amxo_parser_create_object()

PRIVATE int amxo_parser_create_object ( amxo_parser_t pctx,
const char *  name,
int64_t  attr_bitmask,
amxd_object_type_t  type 
)

Definition at line 520 of file amxo_parser_dm_utils.c.

523  {
524  amxd_object_t* object = NULL;
525  amxc_string_t res_name;
526  int64_t oattrs = amxo_attr_2_object_attr(attr_bitmask);
527  int retval = -1;
528  amxd_dm_t* dm = amxd_object_get_dm(pctx->object);
529 
530  amxc_string_init(&res_name, 0);
531 
532  if(amxc_string_set_resolved(&res_name, name, &pctx->config) > 0) {
533  name = amxc_string_get(&res_name, 0);
534  }
535 
536  pctx->status = amxd_status_ok;
537  if(type == amxd_object_mib) {
538  object = amxd_dm_get_mib(dm, name);
539  } else {
540  object = amxd_object_findf(pctx->object, "%s", name);
541  }
542  if(object == NULL) {
543  object = amxo_parser_new_object(pctx, dm, name, oattrs, type);
544  when_null(object, exit);
545  } else {
546  retval = amxo_parser_can_update_object(pctx, name, type);
547  when_true(retval < 0, exit);
548  amxd_object_set_attrs(object, oattrs, true);
549  }
550 
551  amxo_hooks_create_object(pctx, name, oattrs, type);
552 
553  amxc_astack_push(&pctx->object_stack, pctx->object);
554  pctx->object = object;
556  retval = 0;
557 
558 exit:
559  amxc_string_clean(&res_name);
560  return retval;
561 }
static int amxo_parser_can_update_object(amxo_parser_t *pctx, const char *name, amxd_object_type_t type)
static int64_t amxo_attr_2_object_attr(int64_t attributes)
static amxd_object_t * amxo_parser_new_object(amxo_parser_t *pctx, amxd_dm_t *dm, const char *name, int64_t oattrs, amxd_object_type_t type)
PRIVATE void amxo_hooks_create_object(amxo_parser_t *parser, const char *name, int64_t attr_bitmask, amxd_object_type_t type)

◆ amxo_parser_del_mib_info()

PRIVATE void amxo_parser_del_mib_info ( const char *  key,
amxc_htable_it_t *  it 
)

◆ amxo_parser_del_sync_data()

PRIVATE void amxo_parser_del_sync_data ( amxc_llist_it_t *  it)

Definition at line 183 of file amxo_parser_dm_sync_utils.c.

183  {
184  amxo_sync_data_t* data = amxc_container_of(it, amxo_sync_data_t, it);
185  when_null(data, exit);
186 
187  amxc_llist_it_take(it);
188  amxc_htable_it_clean(&data->hit, NULL);
189 
190  when_null(data->entry, exit);
191 
192  switch(data->entry->type) {
193  case amxs_sync_type_ctx:
194  amxs_sync_ctx_delete(&data->entry);
195  break;
196  case amxs_sync_type_object:
197  amxs_sync_object_delete(&data->entry);
198  break;
199  case amxs_sync_type_param:
200  amxs_sync_param_delete(&data->entry);
201  break;
202  default:
203  break;
204  }
205 
206 exit:
207  free(data);
208 }
amxs_sync_entry_t * entry

◆ amxo_parser_destroy_lex()

PRIVATE void amxo_parser_destroy_lex ( amxo_parser_t parser)

◆ amxo_parser_fd_reader()

PRIVATE ssize_t amxo_parser_fd_reader ( amxo_parser_t parser,
char *  buf,
size_t  max_size 
)

Definition at line 104 of file amxo_parser_main.c.

104  {
105  ssize_t result = 0;
106  off_t offset = 0;
107 
108  errno = 0;
109  result = read(parser->fd, buf, max_size - 1);
110  if((result == -1) && (errno != EAGAIN)) {
111  printf("Read failed %d\n", errno);
112  goto exit;
113  }
114  errno = 0;
115 
116  buf[result] = 0;
117  while(result - offset > 0 && buf[result - offset - 1] != '\n') {
118  offset++;
119  }
120  if(result - offset > 0) {
121  lseek(parser->fd, -offset, SEEK_CUR);
122  result -= offset;
123  }
124 
125 exit:
126  return result;
127 }

◆ amxo_parser_find()

PRIVATE void PRIVATE int PRIVATE bool amxo_parser_find ( amxo_parser_t parser,
const amxc_llist_t *  dirs,
const char *  file_path,
char **  full_path 
)

Definition at line 256 of file amxo_parser_include.c.

259  {
260  bool retval = false;
261 
262  if(file_path[0] != '/') {
263  amxc_string_t res_path;
264  amxc_string_init(&res_path, 0);
265  amxc_llist_for_each(it, dirs) {
266  amxc_var_t* var_dir = amxc_var_from_llist_it(it);
267  const char* dir = amxc_var_constcast(cstring_t, var_dir);
268  if(amxc_string_set_resolved(&res_path, dir, &parser->config) > 0) {
269  dir = amxc_string_get(&res_path, 0);
270  }
271 
272  if(amxo_parser_exists(dir, file_path, full_path)) {
273  break;
274  }
275  amxc_string_reset(&res_path);
276  }
277  amxc_string_clean(&res_path);
278  when_null(*full_path, exit);
279  } else {
280  if(!amxo_parser_exists(NULL, file_path, full_path)) {
281  goto exit;
282  }
283  }
284  retval = true;
285 
286 exit:
287  return retval;
288 }
static bool amxo_parser_exists(const char *incdir, const char *file_path, char **full_path)

◆ amxo_parser_free_event()

PRIVATE void amxo_parser_free_event ( amxc_llist_it_t *  it)

Definition at line 493 of file amxo_parser_dm_utils.c.

493  {
494  event_t* e = amxc_container_of(it, event_t, it);
495  amxc_var_clean(&e->data);
496  free(e);
497 }
amxc_var_t data

◆ amxo_parser_get_action_id()

PRIVATE amxo_action_t amxo_parser_get_action_id ( amxo_parser_t pctx,
const char *  action_name 
)

Definition at line 203 of file amxo_parser_utils.c.

204  {
205  static const char* names[] = {
206  "any",
207  "read",
208  "write",
209  "validate",
210  "list",
211  "describe",
212  "add-inst",
213  "del-inst",
214  "destroy",
215  "translate",
216  "apply"
217  };
219  amxc_var_t* ca = GET_ARG(&pctx->config, "_current_action");
220 
221  for(int i = 0; i <= action_max; i++) {
222  if(strcmp(action_name, names[i]) == 0) {
223  action_id = (amxo_action_t) i;
224  break;
225  }
226  }
227 
228  if(action_id < 0) {
229  pctx->status = amxd_status_invalid_action;
230  amxo_parser_msg(pctx,
231  "Invalid action name \"%s\"",
232  action_name);
233  }
234 
235  if(ca == NULL) {
236  amxc_var_add_key(uint32_t, &pctx->config, "_current_action", action_id);
237  } else {
238  amxc_var_set(uint32_t, ca, action_id);
239  }
240 
241  return action_id;
242 }

◆ amxo_parser_get_resolvers()

PRIVATE amxc_htable_t* amxo_parser_get_resolvers ( void  )

Definition at line 99 of file amxo_resolver_mngr.c.

99  {
100  return &resolvers;
101 }

◆ amxo_parser_get_sync_type()

PRIVATE amxs_sync_entry_type_t amxo_parser_get_sync_type ( amxo_parser_t pctx)

Definition at line 158 of file amxo_parser_dm_sync_utils.c.

158  {
159  amxs_sync_entry_type_t type = amxs_sync_type_invalid;
160  amxo_sync_data_t* sync_data = amxo_parser_get_sync_data(pctx);
161  when_null(sync_data, exit);
162  when_null(sync_data->entry, exit);
163 
164  type = sync_data->entry->type;
165 
166 exit:
167  return type;
168 }
static amxo_sync_data_t * amxo_parser_get_sync_data(amxo_parser_t *pctx)

◆ amxo_parser_include()

PRIVATE int amxo_parser_include ( amxo_parser_t pctx,
const char *  file_path 
)

Definition at line 311 of file amxo_parser_include.c.

311  {
312  int retval = -1;
313  char* full_path = NULL;
314  amxc_var_t* incstack = NULL;
315  struct stat statbuf;
316 
317  retval = amxo_parser_check(pctx, file_path, &incstack, &full_path);
318  when_failed(retval, exit);
319 
320  stat(full_path, &statbuf);
321 
322  if(S_ISDIR(statbuf.st_mode)) {
323  retval = amxo_parser_include_dir(pctx, full_path);
324  } else {
325  retval = amxo_parser_include_file(pctx, full_path);
326  }
327 
328 exit:
329  amxc_var_delete(&incstack);
330  free(full_path);
331  return retval;
332 }
static int amxo_parser_include_file(amxo_parser_t *pctx, const char *full_path)
static int amxo_parser_include_dir(amxo_parser_t *pctx, const char *full_path)

◆ amxo_parser_init_resolvers()

PRIVATE void amxo_parser_init_resolvers ( amxo_parser_t parser)

Definition at line 125 of file amxo_resolver_mngr.c.

125  {
126  amxc_htable_for_each(hit, (&resolvers)) {
127  amxo_resolver_t* resolver =
128  amxc_htable_it_get_data(hit, amxo_resolver_t, hit);
129  if(resolver->get != NULL) {
130  resolver->get(parser, resolver->priv);
131  }
132  }
133 
134  return;
135 }
amxo_res_get_default_t get
Definition: amxo_types.h:102

◆ amxo_parser_is_sync_item()

PRIVATE bool amxo_parser_is_sync_item ( amxo_parser_t pctx)

Definition at line 170 of file amxo_parser_dm_sync_utils.c.

170  {
171  amxs_sync_entry_type_t type = amxo_parser_get_sync_type(pctx);
172  return (type == amxs_sync_type_object || type == amxs_sync_type_param);
173 }
amxs_sync_entry_type_t amxo_parser_get_sync_type(amxo_parser_t *pctx)

◆ amxo_parser_msg()

PRIVATE void amxo_parser_msg ( amxo_parser_t parser,
const char *  format,
  ... 
)

◆ amxo_parser_no_resolve()

PRIVATE bool amxo_parser_no_resolve ( amxo_parser_t parser)

Definition at line 87 of file amxo_parser_utils.c.

87  {
88  amxc_var_t* var_resolve = GET_ARG(&parser->config, "odl-resolve");
89  bool resolve = true;
90 
91  if(var_resolve != NULL) {
92  resolve = amxc_var_dyncast(bool, var_resolve);
93  }
94 
95  return !resolve;
96 }

◆ amxo_parser_parse_file_impl()

PRIVATE int amxo_parser_parse_file_impl ( amxo_parser_t parser,
const char *  file_path,
amxd_object_t *  object 
)

Definition at line 156 of file amxo_parser_main.c.

158  {
159  int retval = -1;
160  int fd = -1;
161 
162  fd = open(file_path, O_RDONLY);
163  if(fd == -1) {
164  retval = errno;
165  if(errno == ENOENT) {
166  amxo_parser_msg(parser, "File not found %s", file_path);
167  } else {
168  amxo_parser_msg(parser, "File open error 0x%8.8X", errno);
169  }
170  goto exit;
171  }
172  parser->file = file_path;
173  retval = amxo_parser_parse_fd_internal(parser, fd, object);
174  parser->file = NULL;
175  close(fd);
176 
177 exit:
178  return retval;
179 }
static int amxo_parser_parse_fd_internal(amxo_parser_t *parser, int fd, amxd_object_t *object)

◆ amxo_parser_pop_func()

PRIVATE void amxo_parser_pop_func ( amxo_parser_t pctx)

Definition at line 172 of file amxo_parser_dm_func_utils.c.

172  {
173  amxd_object_fn_t fn = NULL;
174  amxo_hooks_end_func(pctx);
175  fn = (amxd_object_fn_t) pctx->resolved_fn;
176  amxd_function_set_impl(pctx->func, fn);
177  amxc_string_delete(&pctx->resolved_fn_name);
178  pctx->func = NULL;
179  pctx->resolved_fn = NULL;
180 }
PRIVATE void amxo_hooks_end_func(amxo_parser_t *parser)

◆ amxo_parser_pop_object()

PRIVATE bool amxo_parser_pop_object ( amxo_parser_t pctx)

Definition at line 634 of file amxo_parser_dm_utils.c.

634  {
635  bool retval = false;
636  amxd_object_type_t type = amxd_object_get_type(pctx->object);
637  const char* type_name = (type == amxd_object_mib) ? "mib" : "object";
638  amxc_var_t args;
639 
640  pctx->status = amxd_object_validate(pctx->object, 0);
641 
642  amxc_var_init(&args);
643  amxc_var_set_type(&args, AMXC_VAR_ID_HTABLE);
644 
645  if(pctx->status != amxd_status_ok) {
646  amxo_parser_msg(pctx, "%s %s validation failed",
647  type_name,
648  amxd_object_get_name(pctx->object, AMXD_OBJECT_NAMED));
649  goto exit;
650  }
651 
652  amxd_dm_invoke_action(pctx->object, NULL, action_object_write, &args, NULL);
653  amxo_hooks_end_object(pctx);
654 
655  pctx->object = (amxd_object_t*) amxc_astack_pop(&pctx->object_stack);
656 
657  retval = true;
658 
659 exit:
660  amxc_var_clean(&args);
661  return retval;
662 }
PRIVATE void amxo_hooks_end_object(amxo_parser_t *parser)

◆ amxo_parser_pop_param()

PRIVATE bool amxo_parser_pop_param ( amxo_parser_t pctx)

Definition at line 348 of file amxo_parser_dm_param_utils.c.

348  {
349  bool retval = false;
350  amxc_var_t value;
351  amxc_var_init(&value);
352 
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) {
357  amxo_parser_msg(pctx, "Parameter %s validation failed",
358  amxd_param_get_name(pctx->param));
359  goto exit;
360  }
361 
362  amxo_hooks_end_param(pctx);
363  pctx->param = NULL;
364  }
365  retval = true;
366 
367 exit:
368  amxc_var_clean(&value);
369  return retval;
370 }
PRIVATE void amxo_hooks_end_param(amxo_parser_t *parser)

◆ amxo_parser_pop_sync_item()

PRIVATE void amxo_parser_pop_sync_item ( amxo_parser_t pctx)

Definition at line 210 of file amxo_parser_dm_sync_utils.c.

210  {
211  amxo_sync_data_t* data = NULL;
212  when_null(pctx->sync_contexts, exit);
213 
214  data = amxo_parser_get_sync_data(pctx);
215  amxc_llist_it_take(&data->it);
216  free(data);
217 
218 exit:
219  return;
220 }

◆ amxo_parser_print()

PRIVATE void amxo_parser_print ( amxo_parser_t pctx,
const char *  text 
)

Definition at line 244 of file amxo_parser_utils.c.

244  {
245  amxc_string_t print_txt;
246 
247  amxc_string_init(&print_txt, 0);
248 
249  if(amxc_string_set_resolved(&print_txt, text, &pctx->config) > 0) {
250  text = amxc_string_get(&print_txt, 0);
251  }
252 
253  printf("%s (%s@%d)\n", text, pctx->file, pctx->line);
254 
255  amxc_string_clean(&print_txt);
256 }
uint32_t line
Definition: amxo_types.h:280

◆ amxo_parser_printf()

PRIVATE void PRIVATE int amxo_parser_printf ( amxo_parser_t parser,
const char *  format,
  ... 
)

◆ amxo_parser_push_func()

PRIVATE int amxo_parser_push_func ( amxo_parser_t pctx,
const char *  name,
int64_t  attr_bitmask,
uint32_t  type 
)

Definition at line 99 of file amxo_parser_dm_func_utils.c.

102  {
103  amxd_function_t* func = NULL;
104  amxd_function_t* orig_func = NULL;
105  int64_t fattrs = amxo_attr_2_func_attr(attr_bitmask);
106  int retval = -1;
107  amxc_string_t res_name;
108  amxc_string_init(&res_name, 0);
109 
110  if(amxc_string_set_resolved(&res_name, name, &pctx->config) > 0) {
111  name = amxc_string_get(&res_name, 0);
112  }
113 
114  orig_func = amxd_object_get_function(pctx->object, name);
115 
116  pctx->status = amxd_function_new(&func, name, type, NULL);
117  if(pctx->status != amxd_status_ok) {
118  amxo_parser_msg(pctx, "Failed to create function %s", name);
119  goto exit;
120  }
121 
122  if(amxd_object_get_type(pctx->object) == amxd_object_instance) {
123  fattrs |= SET_BIT(amxd_fattr_instance);
124  }
125 
126  amxd_function_set_attrs(func, fattrs, true);
127 
128  if(orig_func != NULL) {
129  if(amxd_function_get_owner(orig_func) == pctx->object) {
130  amxd_function_delete(&orig_func);
131  }
132  amxo_parser_msg(pctx, "Overriding function %s", name);
133  pctx->status = amxd_object_add_function(pctx->object, func);
134  retval = 1;
135  } else {
136  pctx->status = amxd_object_add_function(pctx->object, func);
137  retval = 0;
138  }
139 
140  amxo_hooks_add_func(pctx, name, fattrs, type);
141 
142  pctx->func = func;
143 
144 exit:
145  amxc_string_clean(&res_name);
146  return retval;
147 }
static int64_t amxo_attr_2_func_attr(int64_t attributes)
PRIVATE void amxo_hooks_add_func(amxo_parser_t *parser, const char *name, int64_t attr_bitmask, uint32_t type)

◆ amxo_parser_push_object()

PRIVATE bool amxo_parser_push_object ( amxo_parser_t pctx,
const char *  name 
)

Definition at line 598 of file amxo_parser_dm_utils.c.

599  {
600  amxd_object_t* object = NULL;
601  bool retval = false;
602  amxc_string_t res_path;
603  amxc_string_init(&res_path, 0);
604 
605  if(amxc_string_set_resolved(&res_path, path, &pctx->config) > 0) {
606  path = amxc_string_get(&res_path, 0);
607  }
608 
609  pctx->status = amxd_status_ok;
610  object = amxd_object_findf(pctx->object, "%s", path);
611  if(object == NULL) {
612  char* parent_path = amxd_object_get_path(pctx->object, AMXD_OBJECT_NAMED);
613  amxo_parser_msg(pctx,
614  "Object %s not found (start searching from \"%s\")",
615  path,
616  parent_path == NULL ? "root" : parent_path);
617  free(parent_path);
618  pctx->status = amxd_status_object_not_found;
619  goto exit;
620  }
621 
622  amxo_hooks_select_object(pctx, path);
623 
624  amxc_astack_push(&pctx->object_stack, pctx->object);
625  pctx->object = object;
627  retval = true;
628 
629 exit:
630  amxc_string_clean(&res_path);
631  return retval;
632 }
PRIVATE void amxo_hooks_select_object(amxo_parser_t *parser, const char *path)

◆ amxo_parser_push_param()

PRIVATE 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.

295  {
296  amxd_param_t* param = NULL;
297  int64_t pattrs = amxo_attr_2_param_attr(attr_bitmask);
298  bool retval = false;
299  amxc_string_t res_name;
300  amxc_string_init(&res_name, 0);
301 
303 
304  if(amxc_string_set_resolved(&res_name, name, &pctx->config) > 0) {
305  name = amxc_string_get(&res_name, 0);
306  }
307 
308  pctx->status = amxd_status_ok;
309  param = amxd_object_get_param_def(pctx->object, name);
310  if(param == NULL) {
311  retval = amxo_parser_add_param(pctx, name, pattrs, type);
312  } else {
313  retval = amxo_parser_update_param(pctx, param, name, type);
314  }
315 
316  amxc_string_clean(&res_name);
317  return retval;
318 }
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_push_sync_ctx()

PRIVATE int amxo_parser_push_sync_ctx ( amxo_parser_t pctx,
const char *  path_a,
const char *  path_b,
int  direction 
)

Definition at line 222 of file amxo_parser_dm_sync_utils.c.

225  {
226  amxs_status_t status = amxs_status_unknown_error;
227  amxc_string_t res_path_a;
228  amxc_string_t res_path_b;
229  amxd_dm_t* dm_a = NULL;
230  amxd_dm_t* dm_b = NULL;
231  amxo_sync_data_t* data =
232  (amxo_sync_data_t*) calloc(1, sizeof(amxo_sync_data_t));
233 
234  amxc_string_init(&res_path_a, 0);
235  amxc_string_init(&res_path_b, 0);
236  when_null(data, exit);
237 
238  if(amxc_string_set_resolved(&res_path_a, path_a, &pctx->config) > 0) {
239  path_a = amxc_string_get(&res_path_a, 0);
240  }
241  if(amxc_string_set_resolved(&res_path_b, path_b, &pctx->config) > 0) {
242  path_b = amxc_string_get(&res_path_b, 0);
243  }
244 
245  status = amxs_sync_ctx_new(&data->entry, path_a, path_b, direction);
246  if(status != 0) {
248  path_a, path_b, direction, status);
249  amxo_parser_sync_set_status(pctx, status);
250  data->entry = NULL;
251  goto exit;
252  }
253 
254  if((direction & AMXS_SYNC_ONLY_A_TO_B) == 0) {
255  dm_a = amxo_parser_get_sync_dm(pctx, path_a);
256  }
257  if((direction & AMXS_SYNC_ONLY_B_TO_A) == 0) {
258  dm_b = amxo_parser_get_sync_dm(pctx, path_b);
259  }
260 
261  status = amxs_sync_ctx_set_local_dm(data->entry, dm_a, dm_b);
262  if(status != 0) {
264  path_a, path_b, direction, status);
265  amxo_parser_sync_set_status(pctx, status);
266  goto exit;
267  }
268 
269  if(pctx->sync_contexts == NULL) {
270  amxc_llist_new(&pctx->sync_contexts);
271  }
272  amxc_llist_append(pctx->sync_contexts, &data->it);
273 
274 exit:
275  if(status != 0) {
276  if(data != NULL) {
278  }
279  }
280  amxc_string_clean(&res_path_a);
281  amxc_string_clean(&res_path_b);
282  return status;
283 }
static amxd_dm_t * amxo_parser_get_sync_dm(amxo_parser_t *pctx, const char *path)
static void amxo_parser_sync_set_status(amxo_parser_t *pctx, amxs_status_t status)
#define MSG_SET_DM_FAILED
#define MSG_CREATION_FAILED
void amxo_parser_del_sync_data(amxc_llist_it_t *it)

◆ amxo_parser_push_sync_object()

PRIVATE int amxo_parser_push_sync_object ( amxo_parser_t pctx,
const char *  path_a,
const char *  path_b,
int  direction 
)

Definition at line 320 of file amxo_parser_dm_sync_utils.c.

323  {
324  amxs_status_t status = amxs_status_unknown_error;
325  amxc_string_t res_a;
326  amxc_string_t res_b;
327  amxo_sync_data_t* data = NULL;
328 
329  amxc_string_init(&res_a, 0);
330  amxc_string_init(&res_b, 0);
331 
332  data = (amxo_sync_data_t*) calloc(1, sizeof(amxo_sync_data_t));
333  when_null(data, exit);
334 
335  if(amxc_string_set_resolved(&res_a, path_a, &pctx->config) > 0) {
336  path_a = amxc_string_get(&res_a, 0);
337  }
338  if(amxc_string_set_resolved(&res_b, path_b, &pctx->config) > 0) {
339  path_b = amxc_string_get(&res_b, 0);
340  }
341 
342  status = amxs_sync_object_new_copy(&data->entry, path_a, path_b, direction);
343  when_failed_status(status, exit, data->entry = NULL);
344 
345  status = amxo_parser_sync_add_item(pctx, data,
346  amxs_sync_ctx_add_object,
347  amxs_sync_object_add_object);
348 
349 exit:
350  if(status != 0) {
352  path_a, path_b, direction, status);
353  amxo_parser_sync_set_status(pctx, status);
354  if(data != NULL) {
355  amxs_sync_object_delete(&data->entry);
356  }
357  free(data);
358  }
359  amxc_string_clean(&res_a);
360  amxc_string_clean(&res_b);
361  return status;
362 }
static amxs_status_t amxo_parser_sync_add_item(amxo_parser_t *pctx, amxo_sync_data_t *data, amxo_sync_add_item_fn_t ctx_add, amxo_sync_add_item_fn_t object_add)

◆ amxo_parser_push_sync_parameter()

PRIVATE int amxo_parser_push_sync_parameter ( amxo_parser_t pctx,
const char *  param_a,
const char *  param_b,
int  direction 
)

Definition at line 364 of file amxo_parser_dm_sync_utils.c.

367  {
368  amxs_status_t status = amxs_status_unknown_error;
369  amxc_string_t res_a;
370  amxc_string_t res_b;
371  amxo_sync_data_t* data = NULL;
372 
373  amxc_string_init(&res_a, 0);
374  amxc_string_init(&res_b, 0);
375 
376  data = (amxo_sync_data_t*) calloc(1, sizeof(amxo_sync_data_t));
377  when_null(data, exit);
378 
379  if(amxc_string_set_resolved(&res_a, param_a, &pctx->config) > 0) {
380  param_a = amxc_string_get(&res_a, 0);
381  }
382  if(amxc_string_set_resolved(&res_b, param_b, &pctx->config) > 0) {
383  param_b = amxc_string_get(&res_b, 0);
384  }
385 
386  status = amxs_sync_param_new_copy(&data->entry, param_a, param_b, direction);
387  when_failed_status(status, exit, data->entry = NULL);
388 
389  status = amxo_parser_sync_add_item(pctx,
390  data,
391  amxs_sync_ctx_add_param,
392  amxs_sync_object_add_param);
393 
394 exit:
395  if(status != 0) {
397  param_a, param_b, direction, status);
398  amxo_parser_sync_set_status(pctx, status);
399  if(data != NULL) {
400  amxs_sync_param_delete(&data->entry);
401  }
402  free(data);
403  }
404  amxc_string_clean(&res_a);
405  amxc_string_clean(&res_b);
406  return status;
407 }

◆ amxo_parser_push_sync_template()

PRIVATE int amxo_parser_push_sync_template ( amxo_parser_t pctx,
const char *  path_a,
const char *  path_b,
int  direction,
const char *  name 
)

Definition at line 285 of file amxo_parser_dm_sync_utils.c.

289  {
290  int status = amxs_status_unknown_error;
291  amxd_path_t path;
292  amxo_sync_data_t* data = NULL;
293  amxd_path_init(&path, NULL);
294 
295  status = amxo_parser_push_sync_ctx(pctx, path_a, path_b, direction);
296  when_failed(status, exit);
297 
298  data = amxo_parser_get_sync_data(pctx);
299  status = amxs_status_invalid_type;
300  amxd_path_setf(&path, false, "%s", data->entry->a);
301  when_true(amxd_path_is_instance_path(&path), exit);
302  when_false(amxd_path_is_supported_path(&path) || amxd_path_is_object_path(&path), exit);
303  amxd_path_setf(&path, false, "%s", data->entry->b);
304  when_true(amxd_path_is_instance_path(&path), exit);
305  when_false(amxd_path_is_supported_path(&path) || amxd_path_is_object_path(&path), exit);
306  status = amxs_status_ok;
307 
308  amxc_htable_insert(&sync_templates, name, &data->hit);
309 
310 exit:
311  if(status != 0) {
312  if(data != NULL) {
314  }
315  }
316  amxd_path_clean(&path);
317  return status;
318 }
static amxc_htable_t sync_templates
int amxo_parser_push_sync_ctx(amxo_parser_t *pctx, const char *path_a, const char *path_b, int direction)

◆ amxo_parser_resolve()

PRIVATE int amxo_parser_resolve ( amxo_parser_t parser,
const char *  resolver_name,
const char *  func_name,
amxo_fn_type_t  type,
const char *  data 
)

Definition at line 63 of file amxo_resolver_mngr.c.

67  {
68  int retval = -1;
69  amxo_resolver_t* resolver = NULL;
70  amxc_htable_it_t* hit = NULL;
71  amxc_string_t res_name;
72  amxc_string_init(&res_name, 0);
73 
74  if(amxc_string_set_resolved(&res_name, resolver_name, &parser->config) > 0) {
75  resolver_name = amxc_string_get(&res_name, 0);
76  }
77 
78  hit = amxc_htable_get(&resolvers, resolver_name);
79  when_null(hit, exit);
80 
81  parser->status = amxd_status_ok;
82  resolver = amxc_htable_it_get_data(hit, amxo_resolver_t, hit);
83  parser->resolved_fn = resolver->resolve(parser,
84  func_name,
85  type,
86  data,
87  resolver->priv);
88  if(parser->status == amxd_status_ok) {
89  retval = parser->resolved_fn == NULL ? 1 : 0;
90  } else {
91  retval = -2;
92  }
93 
94 exit:
95  amxc_string_clean(&res_name);
96  return retval;
97 }
amxo_res_resolve_fn_t resolve
Definition: amxo_types.h:103

◆ amxo_parser_resolve_internal()

PRIVATE int amxo_parser_resolve_internal ( amxo_parser_t parser,
const char *  fn_name,
amxo_fn_type_t  type,
const char *  data 
)

Definition at line 124 of file amxo_parser_utils.c.

127  {
128  int retval = -1;
129  char* name = NULL;
130  const char* res_data = NULL;
131 
132  when_true_status(amxo_parser_no_resolve(pctx), exit, retval = 0);
133 
134  if((data == NULL) || (data[0] == '\0')) {
135  amxo_parser_msg(pctx, "Resolver name must be provide (is empty)");
136  pctx->status = amxd_status_invalid_name;
137  goto exit;
138  }
139 
140  name = amxo_parser_get_resolver_name(data);
141  if((name == NULL) || (name[0] == '\0')) {
142  amxo_parser_msg(pctx, "Resolver name must be provide (is empty)");
143  pctx->status = amxd_status_invalid_name;
144  goto exit;
145  }
146  res_data = data + strlen(name);
147  while(isspace(res_data[0]) || res_data[0] == ':') {
148  res_data++;
149  }
150 
151  pctx->resolved_fn = NULL;
152  retval = amxo_parser_resolve(pctx, name, fn_name, type, res_data);
153  if(retval == -1) {
154  pctx->status = amxd_status_invalid_name;
155  amxo_parser_msg(pctx, "No function resolver found with name \"%s\"", name);
156  } else if(retval == 1) {
157  pctx->status = amxd_status_function_not_found;
158  amxo_parser_msg(pctx,
159  "No function implemention found for \"%s\" using \"%s\"",
160  fn_name,
161  name);
162  } else if(retval == 0) {
163  amxc_string_new(&pctx->resolved_fn_name, 0);
164  amxc_string_set(pctx->resolved_fn_name, fn_name);
165  }
166 
167 exit:
168  free(name);
169  return retval;
170 }
static char * amxo_parser_get_resolver_name(const char *data)

◆ amxo_parser_resolve_value()

PRIVATE void amxo_parser_resolve_value ( amxo_parser_t pctx,
amxc_string_t *  value 
)

Definition at line 258 of file amxo_parser_utils.c.

258  {
259  amxc_string_trim(value, NULL);
260  amxc_string_resolve(value, &pctx->config);
261 }

◆ amxo_parser_set_action()

PRIVATE int amxo_parser_set_action ( amxo_parser_t pctx,
amxo_action_t  action,
const char *  name,
amxc_var_t *  data 
)

Definition at line 813 of file amxo_parser_dm_utils.c.

816  {
817 
818  int retval = -1;
819  bool resolve = !amxo_parser_no_resolve(pctx);
820  pctx->status = amxd_status_ok;
821 
822  if((pctx->sync_contexts != NULL) && amxo_parser_is_sync_item(pctx)) {
823  retval = amxo_parser_set_sync_action(pctx, action, name, data);
824  } else if(pctx->param != NULL) {
825  retval = amxo_parser_set_param_action(pctx, action, name, data);
826  } else {
827  retval = amxo_parser_set_object_action(pctx, action, name, data);
828  }
829 
830  if((pctx->resolved_fn == NULL) && resolve) {
831  retval = 1;
832  pctx->status = amxd_status_file_not_found;
833  amxo_parser_msg(pctx, "Action %d not set - no function resolved", action);
834  }
835 
836  amxc_string_delete(&pctx->resolved_fn_name);
837  if((retval != 0) || !resolve) {
838  amxc_var_delete(&data);
839  }
840  return retval;
841 }
static int amxo_parser_set_param_action(amxo_parser_t *pctx, amxo_action_t action, const char *name, amxc_var_t *data)
static int amxo_parser_set_sync_action(amxo_parser_t *pctx, amxo_action_t action, UNUSED const char *name, UNUSED amxc_var_t *data)
static int amxo_parser_set_object_action(amxo_parser_t *pctx, amxo_action_t action, const char *name, amxc_var_t *data)
PRIVATE bool amxo_parser_no_resolve(amxo_parser_t *parser)
PRIVATE bool amxo_parser_is_sync_item(amxo_parser_t *pctx)

◆ amxo_parser_set_counter()

PRIVATE bool amxo_parser_set_counter ( amxo_parser_t pctx,
const char *  param_name 
)

Definition at line 664 of file amxo_parser_dm_utils.c.

665  {
666  bool retval = false;
667  amxc_string_t res_param_name;
668  amxc_string_init(&res_param_name, 0);
669 
670  if(amxc_string_set_resolved(&res_param_name, param_name, &pctx->config) > 0) {
671  param_name = amxc_string_get(&res_param_name, 0);
672  }
673 
674  pctx->status = amxd_object_set_counter(pctx->object, param_name);
675  if(pctx->status != amxd_status_ok) {
676  char* path = amxd_object_get_path(pctx->object, AMXD_OBJECT_NAMED);
677  amxo_parser_msg(pctx,
678  "Failed to to set instance counter %s on %s",
679  param_name,
680  path);
681  pctx->status = amxd_status_duplicate;
682  free(path);
683  goto exit;
684  }
685 
686  amxo_hooks_set_counter(pctx, param_name);
687 
688  retval = true;
689 
690 exit:
691  amxc_string_clean(&res_param_name);
692  return retval;
693 }
PRIVATE void amxo_hooks_set_counter(amxo_parser_t *parser, const char *param_name)

◆ amxo_parser_set_function_flags()

PRIVATE bool amxo_parser_set_function_flags ( amxo_parser_t pctx,
amxc_var_t *  flags 
)

Definition at line 149 of file amxo_parser_dm_func_utils.c.

149  {
150  const amxc_htable_t* ht_flags = NULL;
151 
152  when_null(flags, exit);
153  when_true(amxc_var_type_of(flags) != AMXC_VAR_ID_HTABLE, exit);
154 
155  ht_flags = amxc_var_constcast(amxc_htable_t, flags);
156  amxc_htable_for_each(it, ht_flags) {
157  const char* flag_name = amxc_htable_it_get_key(it);
158  amxc_var_t* flag = amxc_var_from_htable_it(it);
159  if(amxc_var_dyncast(bool, flag)) {
160  amxd_function_set_flag(pctx->func, flag_name);
161  } else {
162  amxd_function_unset_flag(pctx->func, flag_name);
163  }
164  }
165 
166  amxc_var_delete(&flags);
167 
168 exit:
169  return true;
170 }

◆ amxo_parser_set_object_attrs()

PRIVATE bool amxo_parser_set_object_attrs ( amxo_parser_t pctx,
uint64_t  attr,
bool  enable 
)

Definition at line 514 of file amxo_parser_dm_utils.c.

514  {
515  int64_t oattrs = amxo_attr_2_object_attr(attr);
516  amxd_object_set_attrs(pctx->object, oattrs, enable);
517  return true;
518 }

◆ amxo_parser_set_param()

PRIVATE 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.

322  {
323  amxd_param_t* param = NULL;
324  int retval = -1;
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);
328 
329  if(amxc_string_set_resolved(&res_name, name, &pctx->config) > 0) {
330  name = amxc_string_get(&res_name, 0);
331  }
332 
333  pctx->status = amxd_status_ok;
334  param = pctx->param == NULL ? amxd_object_get_param_def(pctx->object, name) : pctx->param;
335  if(param == NULL) {
336  param = amxo_parser_check_param(pctx, name, parent_path, value, &retval);
337  }
338  if(param != NULL) {
339  amxo_parser_data_event(pctx, param);
340  retval = amxo_parser_set_param_value(pctx, parent_path, name, param, value);
341  }
342 
343  amxc_string_clean(&res_name);
344  free(parent_path);
345  return retval;
346 }
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()

PRIVATE bool amxo_parser_set_param_attrs ( amxo_parser_t pctx,
uint64_t  attr,
bool  enable 
)

Definition at line 263 of file amxo_parser_dm_param_utils.c.

263  {
264  int64_t pattrs = amxo_attr_2_param_attr(attr);
265  amxd_param_set_attrs(pctx->param, pattrs, enable);
266  return true;
267 }

◆ amxo_parser_set_param_flags()

PRIVATE 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.

269  {
270  const amxc_htable_t* ht_flags = NULL;
271 
272  when_null(flags, exit);
273  when_true(amxc_var_type_of(flags) != AMXC_VAR_ID_HTABLE, exit);
274 
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);
281  } else {
282  amxd_param_unset_flag(pctx->param, flag_name);
283  }
284  }
285 
286  amxc_var_delete(&flags);
287 
288 exit:
289  return true;
290 }

◆ amxo_parser_start_sync()

PRIVATE int amxo_parser_start_sync ( amxc_llist_it_t *  it)

Definition at line 464 of file amxo_parser_dm_sync_utils.c.

464  {
465  int status = -1;
466  amxo_sync_data_t* data = amxc_container_of(it, amxo_sync_data_t, it);
467  when_null(data, exit);
468  when_null(data->entry, exit);
469  when_false(data->entry->type == amxs_sync_type_ctx, exit);
470 
471  if(amxc_htable_it_get_key(&data->hit) == NULL) {
472  if(!amxs_sync_ctx_is_started(data->entry)) {
473  status = amxs_sync_ctx_start_sync(data->entry);
474  }
475  } else {
476  status = 0;
477  }
478 
479 exit:
480  return status;
481 }

◆ amxo_parser_stop_sync()

PRIVATE void amxo_parser_stop_sync ( amxc_llist_it_t *  it)

Definition at line 483 of file amxo_parser_dm_sync_utils.c.

483  {
484  amxo_sync_data_t* data = amxc_container_of(it, amxo_sync_data_t, it);
485  when_null(data, exit);
486  when_null(data->entry, exit);
487  when_false(data->entry->type == amxs_sync_type_ctx, exit);
488 
489  if(amxc_htable_it_get_key(&data->hit) == NULL) {
490  amxs_sync_ctx_stop_sync(data->entry);
491  }
492 
493 exit:
494  return;
495 }

◆ amxo_parser_subscribe()

PRIVATE int amxo_parser_subscribe ( amxo_parser_t pctx,
const char *  event,
bool  event_is_regexp,
const char *  full_expr 
)

Definition at line 738 of file amxo_parser_dm_utils.c.

741  {
742  int retval = 1;
743  amxd_dm_t* dm = amxd_object_get_dm(pctx->object);
744  amxp_slot_fn_t fn = (amxp_slot_fn_t) pctx->resolved_fn;
745 
746  when_true_status(amxo_parser_no_resolve(pctx), exit, retval = 0);
747  when_null(dm, exit);
748 
749  if(pctx->resolved_fn == NULL) {
750  amxo_parser_msg(pctx,
751  "No event subscription created - no function was resolved");
752  pctx->status = amxd_status_ok;
753  goto exit;
754  }
755 
756  if(full_expr != NULL) {
757  amxc_string_t res_expr;
758  amxc_string_init(&res_expr, 0);
759  if(amxc_string_set_resolved(&res_expr, full_expr, &pctx->config) > 0) {
760  full_expr = amxc_string_get(&res_expr, 0);
761  }
762  retval = amxo_parser_connect(pctx, &dm->sigmngr, event, event_is_regexp, full_expr, fn);
763  amxc_string_clean(&res_expr);
764  } else {
765  retval = amxo_parser_connect(pctx, &dm->sigmngr, event, event_is_regexp, NULL, fn);
766  }
767 
768 exit:
769  return retval;
770 }
static int amxo_parser_connect(amxo_parser_t *pctx, amxp_signal_mngr_t *const sig_mngr, const char *const signal_name, bool signal_is_regexp, const char *const expression, amxp_slot_fn_t fn)

◆ amxo_parser_subscribe_object()

PRIVATE int amxo_parser_subscribe_object ( amxo_parser_t pctx,
const char *  event,
bool  event_is_regexp,
const char *  full_expr 
)

Definition at line 772 of file amxo_parser_dm_utils.c.

775  {
776  int retval = 1;
777  amxd_dm_t* dm = amxd_object_get_dm(pctx->object);
778  amxp_slot_fn_t fn = (amxp_slot_fn_t) pctx->resolved_fn;
779  amxc_string_t path_expr;
780 
781  amxc_string_init(&path_expr, 0);
782 
783  when_true_status(amxo_parser_no_resolve(pctx), exit, retval = 0);
784  when_null(dm, exit);
785 
786  if(pctx->resolved_fn == NULL) {
787  amxo_parser_msg(pctx,
788  "No event subscription created - no function was resolved");
789  pctx->status = amxd_status_ok;
790  goto exit;
791  }
792 
793  amxo_parser_build_path_expr(pctx->object, &path_expr);
794  if((full_expr != NULL) && (*full_expr != 0)) {
795  if(amxc_string_is_empty(&path_expr)) {
796  amxc_string_set(&path_expr, full_expr);
797  } else {
798  amxc_string_appendf(&path_expr, " && (%s)", full_expr);
799  }
800  }
801  retval = amxo_parser_connect(pctx,
802  &dm->sigmngr,
803  event,
804  event_is_regexp,
805  amxc_string_get(&path_expr, 0),
806  fn);
807 
808 exit:
809  amxc_string_clean(&path_expr);
810  return retval;
811 }
static void amxo_parser_build_path_expr(amxd_object_t *object, amxc_string_t *expr)

◆ amxo_parser_subscribe_path()

PRIVATE int amxo_parser_subscribe_path ( amxo_parser_t pctx,
const char *  event,
bool  event_is_regexp,
const char *  path,
bool  path_is_regexp 
)

Definition at line 695 of file amxo_parser_dm_utils.c.

699  {
700  int retval = 1;
701  amxc_string_t res_path;
702  amxc_string_t expression;
703  const char* expr = NULL;
704  amxd_dm_t* dm = amxd_object_get_dm(pctx->object);
705  amxp_slot_fn_t fn = (amxp_slot_fn_t) pctx->resolved_fn;
706 
707  amxc_string_init(&expression, 0);
708  amxc_string_init(&res_path, 0);
709 
710  when_true_status(amxo_parser_no_resolve(pctx), exit, retval = 0);
711  when_null(dm, exit);
712 
713  if(pctx->resolved_fn == NULL) {
714  amxo_parser_msg(pctx,
715  "No event subscription created - no function was resolved");
716  pctx->status = amxd_status_ok;
717  goto exit;
718  }
719 
720  if(amxc_string_set_resolved(&res_path, path, &pctx->config) > 0) {
721  path = amxc_string_get(&res_path, 0);
722  }
723  if(path_is_regexp) {
724  amxc_string_appendf(&expression, "object matches \"%s\" || path matches \"%s\"", path, path);
725  } else {
726  amxc_string_appendf(&expression, "object starts with \"%s\" || path starts with \"%s\"", path, path);
727  }
728  expr = amxc_string_get(&expression, 0);
729  retval = amxo_parser_connect(pctx, &dm->sigmngr, event, event_is_regexp, expr, fn);
730 
731 exit:
732  amxc_string_clean(&expression);
733  amxc_string_clean(&res_path);
734 
735  return retval;
736 }

◆ amxo_parser_sync_get()

PRIVATE amxs_sync_ctx_t* amxo_parser_sync_get ( const char *  sync_template)

Definition at line 526 of file amxo_parser_dm_sync_utils.c.

526  {
527  amxs_sync_ctx_t* ctx = NULL;
528  amxo_sync_data_t* sync_data = NULL;
529  amxc_htable_it_t* hit = amxc_htable_get(&sync_templates, sync_template);
530 
531  when_null(hit, exit);
532  sync_data = amxc_container_of(hit, amxo_sync_data_t, hit);
533 
534  ctx = sync_data->entry;
535 
536 exit:
537  return ctx;
538 }

◆ amxo_parser_sync_item_contains_entries()

PRIVATE bool amxo_parser_sync_item_contains_entries ( amxo_parser_t pctx)

Definition at line 447 of file amxo_parser_dm_sync_utils.c.

447  {
448  bool retval = false;
449  amxo_sync_data_t* sync_data = amxo_parser_get_sync_data(pctx);
450  when_null(sync_data, exit);
451  when_null(sync_data->entry, exit);
452 
453  retval = true;
454  if(amxc_llist_is_empty(&sync_data->entry->entries)) {
456  pctx->status = amxd_status_invalid_action;
457  retval = false;
458  }
459 
460 exit:
461  return retval;
462 }
#define MSG_MUST_CONTAIN_SYNC_ENTRIES

◆ amxo_parser_sync_remove_invalid()

PRIVATE void amxo_parser_sync_remove_invalid ( amxo_parser_t pctx)

Definition at line 497 of file amxo_parser_dm_sync_utils.c.

497  {
498  when_null(pctx, exit);
499  when_null(pctx->sync_contexts, exit);
500 
501  amxc_llist_for_each_reverse(it, pctx->sync_contexts) {
502  amxo_sync_data_t* data = amxc_container_of(it, amxo_sync_data_t, it);
503  switch(data->entry->type) {
504  case amxs_sync_type_param:
505  case amxs_sync_type_object:
507  break;
508  case amxs_sync_type_ctx:
509  if(amxc_llist_is_empty(&data->entry->entries)) {
511  }
512  break;
513  default:
514  break;
515  }
516  }
517 
518  if(amxc_llist_is_empty(pctx->sync_contexts)) {
519  amxc_llist_delete(&pctx->sync_contexts, NULL);
520  }
521 
522 exit:
523  return;
524 }

◆ amxo_parser_sync_set_action()

PRIVATE amxd_status_t amxo_parser_sync_set_action ( amxo_parser_t pctx,
amxs_action_cb_t  cb 
)

Definition at line 428 of file amxo_parser_dm_sync_utils.c.

429  {
430  amxd_status_t status = amxd_status_unknown_error;
431  amxo_sync_data_t* sync_data = amxo_parser_get_sync_data(pctx);
432  when_null(sync_data, exit);
433  when_null(sync_data->entry, exit);
434 
435  if(amxs_sync_entry_is_batch_param(sync_data->entry)) {
437  pctx->status = amxd_status_invalid_action;
438  } else {
439  sync_data->entry->action_cb = cb;
440  status = amxd_status_ok;
441  }
442 
443 exit:
444  return status;
445 }
#define MSG_BATCH_PARAM_WITH_CB

◆ amxo_parser_sync_set_translator()

PRIVATE amxd_status_t amxo_parser_sync_set_translator ( amxo_parser_t pctx,
amxs_translation_cb_t  cb 
)

Definition at line 409 of file amxo_parser_dm_sync_utils.c.

410  {
411  amxd_status_t status = amxd_status_unknown_error;
412  amxo_sync_data_t* sync_data = amxo_parser_get_sync_data(pctx);
413  when_null(sync_data, exit);
414  when_null(sync_data->entry, exit);
415 
416  if(amxs_sync_entry_is_batch_param(sync_data->entry)) {
418  pctx->status = amxd_status_invalid_action;
419  } else {
420  sync_data->entry->translation_cb = cb;
421  status = amxd_status_ok;
422  }
423 
424 exit:
425  return status;
426 }

◆ amxo_parser_sync_update_flags()

PRIVATE int amxo_parser_sync_update_flags ( int  direction)

Definition at line 175 of file amxo_parser_dm_sync_utils.c.

175  {
176  if((direction & AMXS_SYNC_ONLY_B_TO_A) == AMXS_SYNC_ONLY_B_TO_A) {
177  direction |= AMXS_SYNC_INIT_B;
178  }
179 
180  return direction;
181 }

◆ amxo_resolver_import_clean()

PRIVATE void amxo_resolver_import_clean ( amxo_parser_t parser,
void *  priv 
)