Refactored, because muh dryness

This commit is contained in:
buffet 2018-11-06 18:21:55 +01:00
parent 834d842936
commit 648ae00ee4

View file

@ -20,8 +20,6 @@
#include "common.h" #include "common.h"
#define STREQ(a, b) (strcmp((a), (b)) == 0)
int g_sock_fd; int g_sock_fd;
void void
@ -56,16 +54,18 @@ init_socket(void)
} }
} }
#define CMDIS(c) (strcmp(command, (c)) == 0)
void void
handle_ipc_event(char *msg) handle_ipc_event(char *msg)
{ {
char *command = strtok(msg, " "); char *command = strtok(msg, " ");
if (STREQ(command, "quit")) { if (CMDIS("quit")) {
g_is_about_to_quit = true; g_is_about_to_quit = true;
} else if (STREQ(command, "reload")) { } else if (CMDIS("reload")) {
exec_config(); exec_config();
} else if (STREQ(command, "exec")) { } else if (CMDIS("exec")) {
char *command = strtok(NULL, ""); char *command = strtok(NULL, "");
execl("/bin/sh", "/bin/sh", "-c", command, NULL); execl("/bin/sh", "/bin/sh", "-c", command, NULL);
g_is_about_to_quit = true; g_is_about_to_quit = true;