-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcommands.c
More file actions
67 lines (58 loc) · 1.52 KB
/
Copy pathcommands.c
File metadata and controls
67 lines (58 loc) · 1.52 KB
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
#include <string.h>
#include <nagios/downtime.h>
#include <nagios/nagios.h>
#include "helper.h"
#include "commands.h"
#include "commands/acknowledgment.h"
#include "commands/check.h"
#include "commands/downtime.h"
#include "commands/help.h"
#include "commands/notifications.h"
#include "commands/problems.h"
#include "commands/stats.h"
#include "commands/status.h"
// COMMANDS
static int
nez_cmd_frenchman(int sd, char* object, char* rest)
{
(void)object;
(void)rest;
nsock_printf_nul(sd, "http://yolochocin.co/\n");
return 420; // easter egg
}
static int
unknown_command(int sd, char* object, char* rest)
{
(void)object;
(void)rest;
nsock_printf_nul(sd, "UNKNOWN COMMAND\n");
return 404;
}
static nez_command_t
commands[] = {
{ "help", nez_cmd_help },
{ "yolo", nez_cmd_frenchman },
{ "stats", nez_cmd_stats },
{ "status", nez_cmd_status },
{ "check", nez_cmd_check },
{ "enable_notifications", nez_cmd_enable_notifications },
{ "disable_notifications", nez_cmd_disable_notifications },
{ "downtime", nez_cmd_schedule_fixed_downtime },
{ "flexdowntime", nez_cmd_schedule_flex_downtime },
{ "acknowledge", nez_cmd_acknowledge },
{ "unacknowledge", nez_cmd_unacknowledge },
{ "problems", nez_cmd_problems },
{ "muted", nez_cmd_show_muted },
};
nez_handler_t
nez_lookup_command(const char* cmd)
{
if (cmd) {
for (size_t i = 0; i < countof(commands); i++) {
if (nez_string_equals(commands[i].name, cmd)) {
return commands[i].handler;
}
}
}
return unknown_command;
}