#include "amxo_parser_priv.h"
#include "amxo_parser_hooks_priv.h"
#include "amxo_parser.tab.h"
Go to the source code of this file.
|
static char * | amxo_parser_get_resolver_name (const char *data) |
|
bool | amxo_parser_no_resolve (amxo_parser_t *parser) |
|
void | amxo_parser_msg (amxo_parser_t *parser, const char *format,...) |
|
int | amxo_parser_printf (amxo_parser_t *parser, const char *format,...) |
|
int | amxo_parser_resolve_internal (amxo_parser_t *pctx, const char *fn_name, amxo_fn_type_t type, const char *data) |
|
int | amxo_parser_call_entry_point (amxo_parser_t *pctx, const char *lib_name, const char *fn_name) |
|
amxo_action_t | amxo_parser_get_action_id (amxo_parser_t *pctx, const char *action_name) |
|
void | amxo_parser_print (amxo_parser_t *pctx, const char *text) |
|
void | amxo_parser_resolve_value (amxo_parser_t *pctx, amxc_string_t *value) |
|
◆ _GNU_SOURCE
◆ amxo_parser_call_entry_point()
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.
177 amxc_string_init(&data, 0);
178 amxc_string_setf(&data,
"%s", lib_name);
186 "No entry point \"%s\" found using \"%s\"",
189 pctx->
status = amxd_status_function_not_found;
199 amxc_string_clean(&data);
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,...)
int(* amxo_entry_point_t)(int reason, amxd_dm_t *dm, amxo_parser_t *parser)
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
amxc_string_t * resolved_fn_name
◆ amxo_parser_get_action_id()
Definition at line 203 of file amxo_parser_utils.c.
205 static const char* names[] = {
219 amxc_var_t* ca = GET_ARG(&pctx->
config,
"_current_action");
222 if(strcmp(action_name, names[i]) == 0) {
229 pctx->
status = amxd_status_invalid_action;
231 "Invalid action name \"%s\"",
236 amxc_var_add_key(uint32_t, &pctx->
config,
"_current_action", action_id);
238 amxc_var_set(uint32_t, ca, action_id);
enum _amxo_action amxo_action_t
◆ amxo_parser_get_resolver_name()
static char* amxo_parser_get_resolver_name |
( |
const char * |
data | ) |
|
|
static |
Definition at line 62 of file amxo_parser_utils.c.
63 amxc_string_t full_data;
64 size_t length = strlen(data);
66 amxc_llist_it_t* it = NULL;
69 amxc_llist_init(&parts);
70 amxc_string_init(&full_data, length + 1);
71 amxc_string_set_at(&full_data, 0, data, length, amxc_string_overwrite);
72 amxc_string_split_to_llist(&full_data, &parts,
':');
73 it = amxc_llist_take_first(&parts);
74 amxc_llist_clean(&parts, amxc_string_list_it_free);
75 amxc_string_clean(&full_data);
79 amxc_string_trim(amxc_string_from_llist_it(it), NULL);
80 name = amxc_string_take_buffer(amxc_string_from_llist_it(it));
81 amxc_llist_it_clean(it, amxc_string_list_it_free);
◆ amxo_parser_msg()
void amxo_parser_msg |
( |
amxo_parser_t * |
parser, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
Definition at line 98 of file amxo_parser_utils.c.
101 amxc_string_reset(&parser->
msg);
102 va_start(args, format);
103 amxc_string_vsetf(&parser->
msg, format, args);
105 va_start(args, format);
106 vsyslog(LOG_PID | LOG_USER, format, args);
◆ amxo_parser_no_resolve()
Definition at line 87 of file amxo_parser_utils.c.
88 amxc_var_t* var_resolve = GET_ARG(&parser->
config,
"odl-resolve");
91 if(var_resolve != NULL) {
92 resolve = amxc_var_dyncast(
bool, var_resolve);
◆ amxo_parser_print()
void amxo_parser_print |
( |
amxo_parser_t * |
pctx, |
|
|
const char * |
text |
|
) |
| |
Definition at line 244 of file amxo_parser_utils.c.
245 amxc_string_t print_txt;
247 amxc_string_init(&print_txt, 0);
249 if(amxc_string_set_resolved(&print_txt, text, &pctx->
config) > 0) {
250 text = amxc_string_get(&print_txt, 0);
253 printf(
"%s (%s@%d)\n", text, pctx->
file, pctx->
line);
255 amxc_string_clean(&print_txt);
◆ amxo_parser_printf()
int amxo_parser_printf |
( |
amxo_parser_t * |
parser, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
Definition at line 110 of file amxo_parser_utils.c.
111 bool silent = GET_BOOL(&parser->
config,
"silent");
113 va_start(args, format);
115 vfprintf(stderr, format, args);
118 va_start(args, format);
119 vsyslog(LOG_PID | LOG_USER, format, args);
◆ amxo_parser_resolve_internal()
Definition at line 124 of file amxo_parser_utils.c.
130 const char* res_data = NULL;
134 if((data == NULL) || (data[0] ==
'\0')) {
136 pctx->
status = amxd_status_invalid_name;
141 if((name == NULL) || (name[0] ==
'\0')) {
143 pctx->
status = amxd_status_invalid_name;
146 res_data = data + strlen(name);
147 while(isspace(res_data[0]) || res_data[0] ==
':') {
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;
159 "No function implemention found for \"%s\" using \"%s\"",
162 }
else if(retval == 0) {
static char * amxo_parser_get_resolver_name(const char *data)
◆ amxo_parser_resolve_value()
void amxo_parser_resolve_value |
( |
amxo_parser_t * |
pctx, |
|
|
amxc_string_t * |
value |
|
) |
| |