libamxd  6.4.1
Data Model Manager
amxd_common.h File Reference
#include <amxd/amxd_types.h>

Go to the source code of this file.

Macros

#define SET_BIT(x)   (1 << x)
 
#define IS_BIT_SET(b, f)   ((b & (1 << f)) != 0)
 

Functions

const char * amxd_status_string (const amxd_status_t status)
 
bool amxd_name_is_valid (const char *name)
 
amxd_status_t amxd_action_describe_action (amxd_action_t reason, amxc_var_t *const retval, const char *description, void *priv)
 

Macro Definition Documentation

◆ IS_BIT_SET

#define IS_BIT_SET (   b,
 
)    ((b & (1 << f)) != 0)

Definition at line 66 of file amxd_common.h.

◆ SET_BIT

#define SET_BIT (   x)    (1 << x)

Definition at line 65 of file amxd_common.h.

Function Documentation

◆ amxd_action_describe_action()

amxd_status_t amxd_action_describe_action ( amxd_action_t  reason,
amxc_var_t *const  retval,
const char *  description,
void *  priv 
)

Definition at line 142 of file amxd_common.c.

145  {
147  amxc_var_t* var_description = NULL;
148  amxc_var_t* data = (amxc_var_t*) priv;
149 
150  when_true(reason != action_describe_action, exit);
151  when_false(amxc_var_type_of(retval) == AMXC_VAR_ID_HTABLE, exit);
152 
153  var_description = amxc_var_add_new_key(retval, description);
154  amxc_var_copy(var_description, data);
156 
157 exit:
158  return status;
159 }
@ action_describe_action
Definition: amxd_types.h:127
enum _amxd_status amxd_status_t
@ amxd_status_function_not_implemented
Definition: amxd_types.h:83
@ amxd_status_ok
Definition: amxd_types.h:78
static amxd_status_t status

◆ amxd_name_is_valid()

bool amxd_name_is_valid ( const char *  name)

Definition at line 115 of file amxd_common.c.

115  {
116  bool retval = false;
117  when_str_empty(name, exit);
118  when_true(isalpha(name[0]) == 0 && name[0] != '_', exit);
119 
120  for(int i = 0; name[i] != 0; i++) {
121  if(isalnum(name[i]) == 0) {
122  if((name[i] != '_') && (name[i] != '-')) {
123  goto exit;
124  }
125  }
126  }
127 
128  retval = true;
129 
130 exit:
131  return retval;
132 }

◆ amxd_status_string()

const char* amxd_status_string ( const amxd_status_t  status)

Definition at line 134 of file amxd_common.c.

134  {
135  if((status >= 0) && (status <= amxd_status_last)) {
136  return amxd_error_str[status];
137  }
138 
139  return amxd_error_str[1];
140 }
static const char * amxd_error_str[]
Definition: amxd_common.c:67
@ amxd_status_last
Definition: amxd_types.h:106