blob: 22b11432ca42e3b11c97cd116d1262016fc87d33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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 */
|