summaryrefslogtreecommitdiff
path: root/include/hybbx/commands_registry.h
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-08 03:54:55 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-08 03:54:55 +0000
commit20cb29c2f8c5c87bc590896854a20b1473ceb358 (patch)
tree2857f41513a56ad41af97b57362639298aa7f033 /include/hybbx/commands_registry.h
#2
Diffstat (limited to 'include/hybbx/commands_registry.h')
-rw-r--r--include/hybbx/commands_registry.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/include/hybbx/commands_registry.h b/include/hybbx/commands_registry.h
new file mode 100644
index 0000000..22b1143
--- /dev/null
+++ b/include/hybbx/commands_registry.h
@@ -0,0 +1,73 @@
+#ifndef HYBBX_COMMANDS_REGISTRY_H
+#define HYBBX_COMMANDS_REGISTRY_H
+
+#include "hybbx/auth.h"
+#include "hybbx/limits.h"
+#include "hybbx/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct hybbx_session;
+
+typedef struct hybbx_command_def {
+ char verb[HYBBX_CMD_VERB_MAX];
+ char group[16];
+ hybbx_user_level_t min_level;
+ hybbx_user_level_t max_level; /* 0 = no upper cap */
+ int only_level; /* HYBBX_LEVEL_* when set; else 0 */
+ char line1[HYBBX_COMMANDS_HELP_LINE_MAX];
+ char line2[HYBBX_COMMANDS_HELP_LINE_MAX];
+} hybbx_command_def_t;
+
+/** Load areas.yaml then commands.yaml from install root. Call once at service startup. */
+hybbx_result_t hybbx_commands_registry_init(void);
+
+void hybbx_commands_registry_shutdown(void);
+
+const hybbx_command_def_t *hybbx_commands_registry_find(const char *verb);
+
+/** Map alias or topic name to canonical verb; returns @p topic if unknown. */
+const char *hybbx_commands_registry_canonical(const char *topic);
+
+int hybbx_commands_registry_verb_allowed(hybbx_user_level_t level,
+ const char *verb);
+
+int hybbx_commands_registry_help_allowed(hybbx_user_level_t level,
+ const char *verb);
+
+int hybbx_commands_registry_may_userchange(hybbx_user_level_t actor,
+ hybbx_user_level_t target);
+
+int hybbx_commands_registry_may_userdelete(hybbx_user_level_t actor,
+ hybbx_user_level_t target);
+
+int hybbx_commands_registry_may_promote(hybbx_user_level_t actor,
+ hybbx_user_level_t target,
+ int target_active,
+ hybbx_user_level_t new_level);
+
+int hybbx_commands_registry_may_demote(hybbx_user_level_t actor,
+ hybbx_user_level_t target);
+
+int hybbx_commands_registry_may_delete(hybbx_user_level_t actor,
+ hybbx_user_level_t target);
+
+void hybbx_commands_registry_show_menu(struct hybbx_session *session);
+void hybbx_commands_registry_show_index(struct hybbx_session *session);
+void hybbx_commands_registry_show_aliases(struct hybbx_session *session);
+void hybbx_commands_registry_show_help(struct hybbx_session *session,
+ const char *canonical);
+
+/**
+ * List line1 for every registry command with min Admin or Sysop
+ * (the admin set a Sysop may run while staying invisible via /monitor).
+ */
+void hybbx_commands_registry_show_sysop_cmds(struct hybbx_session *session);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HYBBX_COMMANDS_REGISTRY_H */
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com