#ifndef ZABBIX_ZBXSERVER_H
#define ZABBIX_ZBXSERVER_H
#include "dbcache.h"
#include "zbxvariant.h"
#include "zbxeval.h"
#include "zbxdb.h"
#define MACRO_TYPE_MESSAGE_NORMAL 0x00000001
#define MACRO_TYPE_MESSAGE_RECOVERY 0x00000002
#define MACRO_TYPE_TRIGGER_URL 0x00000004
#define MACRO_TYPE_TRIGGER_EXPRESSION 0x00000008
#define MACRO_TYPE_TRIGGER_DESCRIPTION 0x00000010
#define MACRO_TYPE_TRIGGER_COMMENTS 0x00000020
#define MACRO_TYPE_ITEM_KEY 0x00000040
#define MACRO_TYPE_ALERT_EMAIL 0x00000080
#define MACRO_TYPE_INTERFACE_ADDR 0x00000100
#define MACRO_TYPE_COMMON 0x00000400
#define MACRO_TYPE_PARAMS_FIELD 0x00000800
#define MACRO_TYPE_SCRIPT 0x00001000
#define MACRO_TYPE_SNMP_OID 0x00002000
#define MACRO_TYPE_HTTPTEST_FIELD 0x00004000
#define MACRO_TYPE_LLD_FILTER 0x00008000
#define MACRO_TYPE_ALERT 0x00010000
#define MACRO_TYPE_TRIGGER_TAG 0x00020000
#define MACRO_TYPE_JMX_ENDPOINT 0x00040000
#define MACRO_TYPE_MESSAGE_UPDATE 0x00080000
#define MACRO_TYPE_HTTP_RAW 0x00100000
#define MACRO_TYPE_HTTP_JSON 0x00200000
#define MACRO_TYPE_HTTP_XML 0x00400000
#define MACRO_TYPE_ALLOWED_HOSTS 0x00800000
#define MACRO_TYPE_ITEM_TAG 0x01000000
#define MACRO_TYPE_EVENT_NAME 0x02000000
#define MACRO_TYPE_SCRIPT_PARAMS_FIELD 0x04000000
#define MACRO_TYPE_SCRIPT_NORMAL 0x08000000
#define MACRO_TYPE_SCRIPT_RECOVERY 0x10000000
#define MACRO_TYPE_REPORT 0x20000000
#define MACRO_TYPE_QUERY_FILTER 0x40000000
#define MACRO_EXPAND_NO 0
#define MACRO_EXPAND_YES 1
#define STR_CONTAINS_MACROS(str) (NULL != strchr(str, '{'))
int evaluate_function2(zbx_variant_t *value, DC_EVALUATE_ITEM *item, const char *function, const char *parameter,
const zbx_timespec_t *ts, char **error);
int zbx_is_trigger_function(const char *name, size_t len);
int substitute_simple_macros(const zbx_uint64_t *actionid, const DB_EVENT *event, const DB_EVENT *r_event,
const zbx_uint64_t *userid, const zbx_uint64_t *hostid, const DC_HOST *dc_host, const DC_ITEM *dc_item,
const DB_ALERT *alert, const DB_ACKNOWLEDGE *ack, const zbx_service_alarm_t *service_alarm,
const DB_SERVICE *service, const char *tz, char **data, int macro_type, char *error, int maxerrlen);
int substitute_simple_macros_unmasked(const zbx_uint64_t *actionid, const DB_EVENT *event, const DB_EVENT *r_event,
const zbx_uint64_t *userid, const zbx_uint64_t *hostid, const DC_HOST *dc_host, const DC_ITEM *dc_item,
const DB_ALERT *alert, const DB_ACKNOWLEDGE *ack, const zbx_service_alarm_t *service_alarm,
const DB_SERVICE *service, const char *tz, char **data, int macro_type, char *error, int maxerrlen);
void zbx_substitute_simple_macros_allowed_hosts(zbx_history_recv_item_t *item, char **allowed_peers);
void evaluate_expressions(zbx_vector_ptr_t *triggers, const zbx_vector_uint64_t *history_itemids,
const zbx_history_sync_item_t *history_items, const int *history_errcodes);
void prepare_triggers(DC_TRIGGER **triggers, int triggers_num);
void zbx_format_value(char *value, size_t max_len, zbx_uint64_t valuemapid,
const char *units, unsigned char value_type);
void zbx_determine_items_in_expressions(zbx_vector_ptr_t *trigger_order, const zbx_uint64_t *itemids, int item_num);
#define ZBX_EXPRESSION_NORMAL 0
#define ZBX_EXPRESSION_AGGREGATE 1