void (*command_output_func)(FILE *, ucl_object_t *obj);
};
-std::vector<rspamc_command> rspamc_commands = {
- {
+static const constexpr auto rspamc_commands = rspamd::array_of<rspamc_command>(
+ rspamc_command{
.cmd = RSPAMC_COMMAND_SYMBOLS,
.name = "symbols",
.path = "checkv2",
.need_input = TRUE,
.command_output_func = rspamc_symbols_output
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_LEARN_SPAM,
.name = "learn_spam",
.path = "learnspam",
.need_input = TRUE,
.command_output_func = nullptr
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_LEARN_HAM,
.name = "learn_ham",
.path = "learnham",
.need_input = TRUE,
.command_output_func = nullptr
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_FUZZY_ADD,
.name = "fuzzy_add",
.path = "fuzzyadd",
.need_input = TRUE,
.command_output_func = nullptr
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_FUZZY_DEL,
.name = "fuzzy_del",
.path = "fuzzydel",
.need_input = TRUE,
.command_output_func = nullptr
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_FUZZY_DELHASH,
.name = "fuzzy_delhash",
.path = "fuzzydelhash",
.need_input = FALSE,
.command_output_func = nullptr
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_STAT,
.name = "stat",
.path = "stat",
.need_input = FALSE,
.command_output_func = rspamc_stat_output,
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_STAT_RESET,
.name = "stat_reset",
.path = "statreset",
.need_input = FALSE,
.command_output_func = rspamc_stat_output
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_COUNTERS,
.name = "counters",
.path = "counters",
.need_input = FALSE,
.command_output_func = rspamc_counters_output
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_UPTIME,
.name = "uptime",
.path = "auth",
.need_input = FALSE,
.command_output_func = rspamc_uptime_output
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_ADD_SYMBOL,
.name = "add_symbol",
.path = "addsymbol",
.need_input = FALSE,
.command_output_func = nullptr
},
- {
+ rspamc_command{
.cmd = RSPAMC_COMMAND_ADD_ACTION,
.name = "add_action",
.path = "addaction",
.need_input = FALSE,
.command_output_func = nullptr
}
-};
+);
struct rspamc_callback_data {
struct rspamc_command cmd;
}
template<typename T>
-auto sort_containert_with_default(T &cont, const char *default_sort,
- typename std::enable_if<std::is_same_v<typename T::value_type, const ucl_object_t *>>::type* = 0) -> void
+auto sort_ucl_container_with_default(T &cont, const char *default_sort,
+ typename std::enable_if<std::is_same_v<typename T::value_type, const ucl_object_t *>>::type* = 0) -> void
{
auto real_sort = sort ? sort : default_sort;
if (real_sort) {
symbols.push_back(cur);
}
- sort_containert_with_default(symbols, "name");
+ sort_ucl_container_with_default(symbols, "name");
for (const auto *sym_obj : symbols) {
rspamc_symbol_output(out, sym_obj);
counters_vec.push_back(cur);
}
- sort_containert_with_default(counters_vec, "name");
+ sort_ucl_container_with_default(counters_vec, "name");
char fmt_buf[64], dash_buf[82], sym_buf[82];
const int dashes = 44;