Refactor error reporting

Fixes #123
This commit is contained in:
Bastien Dejean 2014-02-17 11:55:34 +01:00
parent 527766463e
commit 42a0fdd253
16 changed files with 284 additions and 287 deletions

View file

@ -11,7 +11,7 @@ helpers.o: helpers.c bspwm.h types.h helpers.h
history.o: history.c bspwm.h types.h helpers.h query.h
messages.o: messages.c bspwm.h types.h helpers.h desktop.h ewmh.h \
history.h monitor.h pointer.h query.h rule.h restore.h settings.h tree.h \
window.h messages.h
window.h common.h subscribe.h messages.h
monitor.o: monitor.c bspwm.h types.h helpers.h desktop.h ewmh.h history.h \
query.h settings.h tree.h window.h monitor.h
pointer.o: pointer.c bspwm.h types.h helpers.h query.h settings.h stack.h \
@ -29,4 +29,4 @@ subscribe.o: subscribe.c bspwm.h types.h helpers.h tree.h settings.h \
tree.o: tree.c bspwm.h types.h helpers.h desktop.h ewmh.h history.h \
monitor.h query.h settings.h stack.h window.h tree.h
window.o: window.c bspwm.h types.h helpers.h ewmh.h monitor.h query.h \
rule.h settings.h stack.h tree.h window.h
rule.h settings.h stack.h tree.h messages.h window.h

11
bspc.c
View file

@ -70,10 +70,15 @@ int main(int argc, char *argv[])
if (send(fd, msg, msg_len, 0) == -1)
err("Failed to send the data.\n");
int ret = EXIT_SUCCESS, nb;
int ret = 0, nb;
while ((nb = recv(fd, rsp, sizeof(rsp), 0)) > 0) {
if (nb == 1 && rsp[0] == MESSAGE_FAILURE) {
ret = EXIT_FAILURE;
if (nb == 1 && rsp[0] < MSG_LENGTH) {
ret = rsp[0];
if (ret == MSG_UNKNOWN) {
warn("Unknown command.\n");
} else if (ret == MSG_SYNTAX) {
warn("Invalid syntax.\n");
}
} else {
int end = MIN(nb, (int) sizeof(rsp) - 1);
rsp[end--] = '\0';

32
bspwm.c
View file

@ -61,9 +61,7 @@ int main(int argc, char *argv[])
config_path[0] = '\0';
int sock_fd, cli_fd, dpy_fd, max_fd, n;
struct sockaddr_un sock_address;
size_t rsp_len = 0;
char msg[BUFSIZ] = {0};
char rsp[BUFSIZ] = {0};
xcb_generic_event_t *event;
char opt;
@ -159,29 +157,21 @@ int main(int argc, char *argv[])
cli_fd = accept(sock_fd, NULL, 0);
if (cli_fd > 0 && (n = recv(cli_fd, msg, sizeof(msg), 0)) > 0) {
msg[n] = '\0';
if (handle_message(msg, n, rsp)) {
rsp_len = strlen(rsp);
} else {
rsp[0] = MESSAGE_FAILURE;
rsp_len = 1;
}
if (rsp_len == 1 && rsp[0] != MESSAGE_FAILURE && rsp[0] < NON_CONTROL_START) {
if (rsp[0] == MESSAGE_SUBSCRIBE) {
add_subscriber(cli_fd);
} else if (rsp[0] == MESSAGE_GET_STATUS) {
FILE *stream = fdopen(cli_fd, "w");
if (stream != NULL) {
print_status(stream);
fclose(stream);
} else {
close(cli_fd);
}
FILE *rsp = fdopen(cli_fd, "w");
if (rsp != NULL) {
int ret = handle_message(msg, n, rsp);
if (ret == MSG_SUBSCRIBE) {
add_subscriber(rsp);
} else {
if (ret != MSG_SUCCESS)
fprintf(rsp, "%c", ret);
fflush(rsp);
fclose(rsp);
}
} else {
send(cli_fd, rsp, rsp_len, 0);
warn("Can't open the client socket as file.\n");
close(cli_fd);
}
rsp[0] = '\0';
}
}

View file

@ -31,6 +31,14 @@
#define SOCKET_PATH_TPL "/tmp/bspwm%s-socket"
#define SOCKET_ENV_VAR "BSPWM_SOCKET"
#define MESSAGE_FAILURE '\x18'
enum {
MSG_SUCCESS,
MSG_FAILURE,
MSG_SYNTAX,
MSG_UNKNOWN,
MSG_SUBSCRIBE,
MSG_LENGTH
};
#endif

View file

@ -2,5 +2,4 @@
- Internal nodes selectors/actions: labels?
- Invisible state.
- Restore built-in pointer grabbing?
- `FILE *` instead of `char *` for writing the server response?
- Use BSD `sys/{queue/tree}.h` for {list,tree} structures?

View file

@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 02/11/2014
.\" Date: 02/17/2014
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.8.8
.\" Language: English
.\"
.TH "BSPWM" "1" "02/11/2014" "Bspwm 0\&.8\&.8" "Bspwm Manual"
.TH "BSPWM" "1" "02/17/2014" "Bspwm 0\&.8\&.8" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -940,6 +940,24 @@ quit [<status>]
Quit with an optional exit status\&.
.RE
.RE
.SH "EXIT CODES"
.sp
If the server can\(cqt handle a message, \fBbspc\fR will return with one of the following exit codes:
.PP
1
.RS 4
Failure\&.
.RE
.PP
2
.RS 4
Syntax error\&.
.RE
.PP
3
.RS 4
Unknown command\&.
.RE
.SH "SETTINGS"
.sp
Colors are either X color names or \fI#RRGGBB\fR, booleans are \fItrue\fR or \fIfalse\fR\&.

View file

@ -576,6 +576,19 @@ General Syntax
quit [<status>]::
Quit with an optional exit status.
Exit Codes
----------
If the server can't handle a message, *bspc* will return with one of the following exit codes:
1::
Failure.
2::
Syntax error.
3::
Unknown command.
Settings
--------
Colors are either http://en.wikipedia.org/wiki/X11_color_names[X color names] or '#RRGGBB', booleans are 'true' or 'false'.

View file

@ -48,7 +48,6 @@
#define SMALEN 32
#define INIT_CAP 8
#define REMLEN(x) (BUFSIZ - strlen(x) - 1)
#define streq(s1, s2) (strcmp((s1), (s2)) == 0)
#ifdef DEBUG

View file

@ -42,15 +42,17 @@
#include "settings.h"
#include "tree.h"
#include "window.h"
#include "common.h"
#include "subscribe.h"
#include "messages.h"
bool handle_message(char *msg, int msg_len, char *rsp)
int handle_message(char *msg, int msg_len, FILE *rsp)
{
int cap = INIT_CAP;
int num = 0;
char **args = malloc(cap * sizeof(char *));
if (args == NULL)
return false;
return MSG_FAILURE;
for (int i = 0, j = 0; i < msg_len; i++) {
if (msg[i] == 0) {
@ -62,7 +64,7 @@ bool handle_message(char *msg, int msg_len, char *rsp)
char **new = realloc(args, cap * sizeof(char *));
if (new == NULL) {
free(args);
return false;
return MSG_FAILURE;
} else {
args = new;
}
@ -71,16 +73,16 @@ bool handle_message(char *msg, int msg_len, char *rsp)
if (num < 1) {
free(args);
return false;
return MSG_SYNTAX;
}
char **args_orig = args;
bool ret = process_message(args, num, rsp);
int ret = process_message(args, num, rsp);
free(args_orig);
return ret;
}
bool process_message(char **args, int num, char *rsp)
int process_message(char **args, int num, FILE *rsp)
{
if (streq("window", *args)) {
return cmd_window(++args, --num);
@ -104,13 +106,13 @@ bool process_message(char **args, int num, char *rsp)
return cmd_quit(++args, --num);
}
return false;
return MSG_UNKNOWN;
}
bool cmd_window(char **args, int num)
int cmd_window(char **args, int num)
{
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t ref = {mon, mon->desk, mon->desk->focus};
coordinates_t trg = ref;
@ -119,11 +121,11 @@ bool cmd_window(char **args, int num)
if (node_from_desc(*args, &ref, &trg))
num--, args++;
else
return false;
return MSG_FAILURE;
}
if (trg.node == NULL)
return false;
return MSG_FAILURE;
bool dirty = false;
@ -133,7 +135,7 @@ bool cmd_window(char **args, int num)
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
if (!node_from_desc(*args, &trg, &dst))
return false;
return MSG_FAILURE;
}
focus_node(dst.monitor, dst.desktop, dst.node);
} else if (streq("-d", *args) || streq("--to-desktop", *args)) {
@ -145,12 +147,12 @@ bool cmd_window(char **args, int num)
trg.desktop = dst.desktop;
}
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-m", *args) || streq("--to-monitor", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t dst;
if (monitor_from_desc(*args, &trg, &dst)) {
if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.monitor->desk, dst.monitor->desk->focus)) {
@ -158,12 +160,12 @@ bool cmd_window(char **args, int num)
trg.desktop = dst.monitor->desk;
}
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-w", *args) || streq("--to-window", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t dst;
if (node_from_desc(*args, &trg, &dst)) {
if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.node)) {
@ -171,12 +173,12 @@ bool cmd_window(char **args, int num)
trg.desktop = dst.desktop;
}
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-s", *args) || streq("--swap", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t dst;
if (node_from_desc(*args, &trg, &dst)) {
if (swap_nodes(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.node)) {
@ -187,12 +189,12 @@ bool cmd_window(char **args, int num)
dirty = true;
}
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-t", *args) || streq("--toggle", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
char *key = strtok(*args, EQL_TOK);
char *val = strtok(NULL, EQL_TOK);
alter_state_t a;
@ -203,7 +205,7 @@ bool cmd_window(char **args, int num)
if (parse_bool(val, &b))
a = ALTER_SET;
else
return false;
return MSG_FAILURE;
}
if (streq("fullscreen", key)) {
set_fullscreen(trg.node, (a == ALTER_SET ? b : !trg.node->client->fullscreen));
@ -221,13 +223,15 @@ bool cmd_window(char **args, int num)
} else if (streq("private", key)) {
set_private(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->client->private));
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-p", *args) || streq("--presel", *args)) {
num--, args++;
if (num < 1 || !is_tiled(trg.node->client)
|| trg.desktop->layout != LAYOUT_TILED)
return false;
if (num < 1)
return MSG_SYNTAX;
if (!is_tiled(trg.node->client) ||
trg.desktop->layout != LAYOUT_TILED)
return MSG_FAILURE;
if (streq("cancel", *args)) {
reset_mode(&trg);
} else {
@ -237,7 +241,7 @@ bool cmd_window(char **args, int num)
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
if (sscanf(*args, "%lf", &rat) != 1 || rat <= 0 || rat >= 1)
return false;
return MSG_FAILURE;
}
if (auto_cancel && trg.node->split_mode == MODE_MANUAL &&
dir == trg.node->split_dir &&
@ -250,19 +254,19 @@ bool cmd_window(char **args, int num)
}
window_draw_border(trg.node, trg.desktop->focus == trg.node, mon == trg.monitor);
} else {
return false;
return MSG_FAILURE;
}
}
} else if (streq("-e", *args) || streq("--edge", *args)) {
num--, args++;
if (num < 2)
return false;
return MSG_SYNTAX;
direction_t dir;
if (!parse_direction(*args, &dir))
return false;
return MSG_FAILURE;
node_t *n = find_fence(trg.node, dir);
if (n == NULL)
return false;
return MSG_FAILURE;
num--, args++;
if ((*args)[0] == '+' || (*args)[0] == '-') {
int pix;
@ -272,58 +276,58 @@ bool cmd_window(char **args, int num)
if (rat > 0 && rat < 1)
n->split_ratio = rat;
else
return false;
return MSG_FAILURE;
} else {
return false;
return MSG_FAILURE;
}
} else {
double rat;
if (sscanf(*args, "%lf", &rat) == 1 && rat > 0 && rat < 1)
n->split_ratio = rat;
else
return false;
return MSG_FAILURE;
}
dirty = true;
} else if (streq("-r", *args) || streq("--ratio", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
double rat;
if (sscanf(*args, "%lf", &rat) == 1 && rat > 0 && rat < 1) {
trg.node->split_ratio = rat;
window_draw_border(trg.node, trg.desktop->focus == trg.node, mon == trg.monitor);
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-R", *args) || streq("--rotate", *args)) {
num--, args++;
if (num < 2)
return false;
return MSG_SYNTAX;
direction_t dir;
if (!parse_direction(*args, &dir))
return false;
return MSG_FAILURE;
node_t *n = find_fence(trg.node, dir);
if (n == NULL)
return false;
return MSG_FAILURE;
num--, args++;
int deg;
if (parse_degree(*args, &deg)) {
rotate_tree(n, deg);
dirty = true;
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-c", *args) || streq("--close", *args)) {
if (num > 1)
return false;
return MSG_SYNTAX;
window_close(trg.node);
} else if (streq("-k", *args) || streq("--kill", *args)) {
if (num > 1)
return false;
return MSG_SYNTAX;
window_kill(trg.monitor, trg.desktop, trg.node);
dirty = true;
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
@ -332,13 +336,13 @@ bool cmd_window(char **args, int num)
if (dirty)
arrange(trg.monitor, trg.desktop);
return true;
return MSG_SUCCESS;
}
bool cmd_desktop(char **args, int num)
int cmd_desktop(char **args, int num)
{
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t ref = {mon, mon->desk, NULL};
coordinates_t trg = ref;
@ -347,7 +351,7 @@ bool cmd_desktop(char **args, int num)
if (desktop_from_desc(*args, &ref, &trg))
num--, args++;
else
return false;
return MSG_FAILURE;
}
bool dirty = false;
@ -358,7 +362,7 @@ bool cmd_desktop(char **args, int num)
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
if (!desktop_from_desc(*args, &trg, &dst))
return false;
return MSG_FAILURE;
}
if (auto_alternate && dst.desktop == mon->desk) {
desktop_select_t sel = {DESKTOP_STATUS_ALL, false, false};
@ -367,29 +371,31 @@ bool cmd_desktop(char **args, int num)
focus_node(dst.monitor, dst.desktop, dst.desktop->focus);
} else if (streq("-m", *args) || streq("--to-monitor", *args)) {
num--, args++;
if (num < 1 || trg.monitor->desk_head == trg.monitor->desk_tail)
return false;
if (num < 1)
return MSG_SYNTAX;
if (trg.monitor->desk_head == trg.monitor->desk_tail)
return MSG_FAILURE;
coordinates_t dst;
if (monitor_from_desc(*args, &trg, &dst)) {
transfer_desktop(trg.monitor, dst.monitor, trg.desktop);
trg.monitor = dst.monitor;
update_current();
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-s", *args) || streq("--swap", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t dst;
if (desktop_from_desc(*args, &trg, &dst))
swap_desktops(trg.monitor, trg.desktop, dst.monitor, dst.desktop);
else
return false;
return MSG_FAILURE;
} else if (streq("-l", *args) || streq("--layout", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
layout_t lyt;
cycle_dir_t cyc;
if (parse_cycle_direction(*args, &cyc))
@ -397,11 +403,11 @@ bool cmd_desktop(char **args, int num)
else if (parse_layout(*args, &lyt))
change_layout(trg.monitor, trg.desktop, lyt);
else
return false;
return MSG_FAILURE;
} else if (streq("-n", *args) || streq("--rename", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
snprintf(trg.desktop->name, sizeof(trg.desktop->name), "%s", *args);
ewmh_update_desktop_names();
put_status();
@ -411,33 +417,33 @@ bool cmd_desktop(char **args, int num)
remove_desktop(trg.monitor, trg.desktop);
show_desktop(trg.monitor->desk);
update_current();
return true;
return MSG_SUCCESS;
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-c", *args) || streq("--cancel-presel", *args)) {
reset_mode(&trg);
} else if (streq("-F", *args) || streq("--flip", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
flip_t flp;
if (parse_flip(*args, &flp)) {
flip_tree(trg.desktop->root, flp);
dirty = true;
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-R", *args) || streq("--rotate", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
int deg;
if (parse_degree(*args, &deg)) {
rotate_tree(trg.desktop->root, deg);
dirty = true;
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-E", *args) || streq("--equalize", *args)) {
equalize_tree(trg.desktop->root);
@ -448,18 +454,18 @@ bool cmd_desktop(char **args, int num)
} else if (streq("-C", *args) || streq("--circulate", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
circulate_dir_t cir;
if (parse_circulate_direction(*args, &cir)) {
circulate_leaves(trg.monitor, trg.desktop, cir);
dirty = true;
} else {
return false;
return MSG_FAILURE;
}
} else if (streq("-t", *args) || streq("--toggle", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
char *key = strtok(*args, EQL_TOK);
char *val = strtok(NULL, EQL_TOK);
alter_state_t a;
@ -470,14 +476,14 @@ bool cmd_desktop(char **args, int num)
if (parse_bool(val, &b))
a = ALTER_SET;
else
return false;
return MSG_FAILURE;
}
if (streq("floating", key))
trg.desktop->floating = (a == ALTER_SET ? b : !trg.desktop->floating);
else
return false;
return MSG_FAILURE;
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
}
@ -485,13 +491,13 @@ bool cmd_desktop(char **args, int num)
if (dirty)
arrange(trg.monitor, trg.desktop);
return true;
return MSG_SUCCESS;
}
bool cmd_monitor(char **args, int num)
int cmd_monitor(char **args, int num)
{
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t ref = {mon, NULL, NULL};
coordinates_t trg = ref;
@ -500,7 +506,7 @@ bool cmd_monitor(char **args, int num)
if (monitor_from_desc(*args, &ref, &trg))
num--, args++;
else
return false;
return MSG_FAILURE;
}
while (num > 0) {
@ -509,7 +515,7 @@ bool cmd_monitor(char **args, int num)
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
if (!monitor_from_desc(*args, &trg, &dst))
return false;
return MSG_FAILURE;
}
if (auto_alternate && dst.monitor == mon) {
desktop_select_t sel = {DESKTOP_STATUS_ALL, false, false};
@ -519,7 +525,7 @@ bool cmd_monitor(char **args, int num)
} else if (streq("-d", *args) || streq("--reset-desktops", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
desktop_t *d = trg.monitor->desk_head;
while (num > 0 && d != NULL) {
snprintf(d->name, sizeof(d->name), "%s", *args);
@ -542,7 +548,7 @@ bool cmd_monitor(char **args, int num)
} else if (streq("-a", *args) || streq("--add-desktops", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
while (num > 0) {
add_desktop(trg.monitor, make_desktop(*args));
num--, args++;
@ -550,7 +556,7 @@ bool cmd_monitor(char **args, int num)
} else if (streq("-r", *args) || streq("--remove-desktops", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
while (num > 0) {
coordinates_t dst;
if (locate_desktop(*args, &dst) && dst.monitor->desk_head != dst.monitor->desk_tail && dst.desktop->root == NULL) {
@ -562,7 +568,7 @@ bool cmd_monitor(char **args, int num)
} else if (streq("-o", *args) || streq("--order-desktops", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
desktop_t *d = trg.monitor->desk_head;
while (d != NULL && num > 0) {
desktop_t *next = d->next;
@ -578,28 +584,28 @@ bool cmd_monitor(char **args, int num)
} else if (streq("-n", *args) || streq("--rename", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
snprintf(trg.monitor->name, sizeof(trg.monitor->name), "%s", *args);
put_status();
} else if (streq("-s", *args) || streq("--swap", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t dst;
if (monitor_from_desc(*args, &trg, &dst))
swap_monitors(trg.monitor, dst.monitor);
else
return false;
return MSG_FAILURE;
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
}
return true;
return MSG_SUCCESS;
}
bool cmd_query(char **args, int num, char *rsp)
int cmd_query(char **args, int num, FILE *rsp)
{
coordinates_t ref = {mon, mon->desk, mon->desk->focus};
coordinates_t trg = {NULL, NULL, NULL};
@ -624,7 +630,7 @@ bool cmd_query(char **args, int num, char *rsp)
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
if (!monitor_from_desc(*args, &ref, &trg))
return false;
return MSG_FAILURE;
}
t++;
} else if (streq("-d", *args) || streq("--desktop", *args)) {
@ -633,7 +639,7 @@ bool cmd_query(char **args, int num, char *rsp)
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
if (!desktop_from_desc(*args, &ref, &trg))
return false;
return MSG_FAILURE;
}
t++;
} else if (streq("-w", *args) || streq("--window", *args)) {
@ -641,17 +647,17 @@ bool cmd_query(char **args, int num, char *rsp)
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
if (!node_from_desc(*args, &ref, &trg))
return false;
return MSG_FAILURE;
}
t++;
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
}
if (d != 1 || t > 1)
return false;
return MSG_SYNTAX;
if (dom == DOMAIN_HISTORY)
query_history(trg, rsp);
@ -662,18 +668,18 @@ bool cmd_query(char **args, int num, char *rsp)
else
query_monitors(trg, dom, rsp);
return true;
return MSG_SUCCESS;
}
bool cmd_rule(char **args, int num, char *rsp)
int cmd_rule(char **args, int num, FILE *rsp)
{
if (num < 1)
return false;
return MSG_SYNTAX;
while (num > 0) {
if (streq("-a", *args) || streq("--add", *args)) {
num--, args++;
if (num < 2)
return false;
return MSG_SYNTAX;
rule_t *rule = make_rule();
snprintf(rule->cause, sizeof(rule->cause), "%s", *args);
num--, args++;
@ -694,7 +700,7 @@ bool cmd_rule(char **args, int num, char *rsp)
} else if (streq("-r", *args) || streq("--remove", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
int idx;
while (num > 0) {
if (parse_index(*args, &idx))
@ -711,135 +717,135 @@ bool cmd_rule(char **args, int num, char *rsp)
num--, args++;
list_rules(num > 0 ? *args : NULL, rsp);
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
}
return true;
return MSG_SUCCESS;
}
bool cmd_pointer(char **args, int num)
int cmd_pointer(char **args, int num)
{
if (num < 1)
return false;
return MSG_SYNTAX;
while (num > 0) {
if (streq("-t", *args) || streq("--track", *args)) {
num--, args++;
if (num < 2)
return false;
return MSG_SYNTAX;
int x, y;
if (sscanf(*args, "%i", &x) == 1 && sscanf(*(args + 1), "%i", &y) == 1)
track_pointer(x, y);
else
return false;
return MSG_FAILURE;
} else if (streq("-g", *args) || streq("--grab", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
pointer_action_t pac;
if (parse_pointer_action(*args, &pac))
grab_pointer(pac);
else
return false;
return MSG_FAILURE;
} else if (streq("-u", *args) || streq("--ungrab", *args)) {
ungrab_pointer();
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
}
return true;
return MSG_SUCCESS;
}
bool cmd_restore(char **args, int num)
int cmd_restore(char **args, int num)
{
if (num < 1)
return false;
return MSG_SYNTAX;
while (num > 0) {
if (streq("-T", *args) || streq("--tree", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
restore_tree(*args);
} else if (streq("-H", *args) || streq("--history", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
restore_history(*args);
} else if (streq("-S", *args) || streq("--stack", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
restore_stack(*args);
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
}
return true;
return MSG_SUCCESS;
}
bool cmd_control(char **args, int num, char *rsp)
int cmd_control(char **args, int num, FILE *rsp)
{
if (num < 1)
return false;
return MSG_SYNTAX;
while (num > 0) {
if (streq("--adopt-orphans", *args)) {
adopt_orphans();
} else if (streq("--toggle-visibility", *args)) {
toggle_visibility();
} else if (streq("--subscribe", *args)) {
snprintf(rsp, BUFSIZ, "%c", MESSAGE_SUBSCRIBE);
return MSG_SUBSCRIBE;
} else if (streq("--get-status", *args)) {
snprintf(rsp, BUFSIZ, "%c", MESSAGE_GET_STATUS);
print_status(rsp);
} else if (streq("--record-history", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
bool b;
if (parse_bool(*args, &b))
record_history = b;
else
return false;
return MSG_SYNTAX;
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
}
return true;
return MSG_SUCCESS;
}
bool cmd_config(char **args, int num, char *rsp)
int cmd_config(char **args, int num, FILE *rsp)
{
if (num < 1)
return false;
return MSG_SYNTAX;
coordinates_t ref = {mon, mon->desk, mon->desk->focus};
coordinates_t trg = {NULL, NULL, NULL};
if ((*args)[0] == OPT_CHR) {
if (streq("-m", *args) || streq("--monitor", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
if (!monitor_from_desc(*args, &ref, &trg))
return false;
return MSG_FAILURE;
} else if (streq("-d", *args) || streq("--desktop", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
if (!desktop_from_desc(*args, &ref, &trg))
return false;
return MSG_FAILURE;
} else if (streq("-w", *args) || streq("--window", *args)) {
num--, args++;
if (num < 1)
return false;
return MSG_SYNTAX;
if (!node_from_desc(*args, &ref, &trg))
return false;
return MSG_FAILURE;
} else {
return false;
return MSG_SYNTAX;
}
num--, args++;
}
@ -848,18 +854,18 @@ bool cmd_config(char **args, int num, char *rsp)
else if (num == 1)
return get_setting(trg, *args, rsp);
else
return false;
return MSG_SYNTAX;
}
bool cmd_quit(char **args, int num)
int cmd_quit(char **args, int num)
{
if (num > 0 && sscanf(*args, "%i", &exit_status) != 1)
return false;
return MSG_FAILURE;
running = false;
return true;
return MSG_SUCCESS;
}
bool set_setting(coordinates_t loc, char *name, char *value)
int set_setting(coordinates_t loc, char *name, char *value)
{
#define DESKWINSET(k, v) \
if (loc.node != NULL) \
@ -876,7 +882,7 @@ bool set_setting(coordinates_t loc, char *name, char *value)
if (streq("border_width", name)) {
unsigned int bw;
if (sscanf(value, "%u", &bw) != 1)
return false;
return MSG_FAILURE;
DESKWINSET(border_width, bw)
#undef DESKWINSET
#define DESKSET(k, v) \
@ -892,7 +898,7 @@ bool set_setting(coordinates_t loc, char *name, char *value)
} else if (streq("window_gap", name)) {
int wg;
if (sscanf(value, "%i", &wg) != 1)
return false;
return MSG_FAILURE;
DESKSET(window_gap, wg)
#undef DESKSET
#define MONDESKSET(k, v) \
@ -906,22 +912,22 @@ bool set_setting(coordinates_t loc, char *name, char *value)
} else if (streq("top_padding", name)) {
int tp;
if (sscanf(value, "%i", &tp) != 1)
return false;
return MSG_FAILURE;
MONDESKSET(top_padding, tp)
} else if (streq("right_padding", name)) {
int rp;
if (sscanf(value, "%i", &rp) != 1)
return false;
return MSG_FAILURE;
MONDESKSET(right_padding, rp)
} else if (streq("bottom_padding", name)) {
int bp;
if (sscanf(value, "%i", &bp) != 1)
return false;
return MSG_FAILURE;
MONDESKSET(bottom_padding, bp)
} else if (streq("left_padding", name)) {
int lp;
if (sscanf(value, "%i", &lp) != 1)
return false;
return MSG_FAILURE;
MONDESKSET(left_padding, lp)
#undef MONDESKSET
#define SETSTR(s) \
@ -935,8 +941,8 @@ bool set_setting(coordinates_t loc, char *name, char *value)
if (sscanf(value, "%lf", &r) == 1 && r > 0 && r < 1)
split_ratio = r;
else
return false;
return true;
return MSG_FAILURE;
return MSG_SUCCESS;
#define SETCOLOR(s) \
} else if (streq(#s, name)) { \
snprintf(s, sizeof(s), "%s", value);
@ -974,14 +980,14 @@ bool set_setting(coordinates_t loc, char *name, char *value)
window_hide(m->root);
disable_motion_recorder();
}
return true;
return MSG_SUCCESS;
} else {
return false;
return MSG_FAILURE;
}
#define SETBOOL(s) \
} else if (streq(#s, name)) { \
if (!parse_bool(value, &s)) \
return false;
return MSG_FAILURE;
SETBOOL(borderless_monocle)
SETBOOL(gapless_monocle)
SETBOOL(pointer_follows_monitor)
@ -993,44 +999,44 @@ bool set_setting(coordinates_t loc, char *name, char *value)
SETBOOL(remove_disabled_monitor)
#undef SETBOOL
} else {
return false;
return MSG_FAILURE;
}
for (monitor_t *m = mon_head; m != NULL; m = m->next)
for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
arrange(m, d);
return true;
return MSG_SUCCESS;
}
bool get_setting(coordinates_t loc, char *name, char* rsp)
int get_setting(coordinates_t loc, char *name, FILE* rsp)
{
if (streq("split_ratio", name))
snprintf(rsp, BUFSIZ, "%lf", split_ratio);
fprintf(rsp, "%lf", split_ratio);
else if (streq("window_gap", name))
if (loc.desktop == NULL)
return false;
return MSG_FAILURE;
else
snprintf(rsp, BUFSIZ, "%i", loc.desktop->window_gap);
fprintf(rsp, "%i", loc.desktop->window_gap);
else if (streq("border_width", name))
if (loc.node != NULL)
snprintf(rsp, BUFSIZ, "%u", loc.node->client->border_width);
fprintf(rsp, "%u", loc.node->client->border_width);
else if (loc.desktop != NULL)
snprintf(rsp, BUFSIZ, "%u", loc.desktop->border_width);
fprintf(rsp, "%u", loc.desktop->border_width);
else
return false;
return MSG_FAILURE;
else if (streq("external_rules_command", name))
snprintf(rsp, BUFSIZ, "%s", external_rules_command);
fprintf(rsp, "%s", external_rules_command);
else if (streq("status_prefix", name))
snprintf(rsp, BUFSIZ, "%s", status_prefix);
fprintf(rsp, "%s", status_prefix);
#define MONDESKGET(k) \
else if (streq(#k, name)) \
if (loc.desktop != NULL) \
snprintf(rsp, BUFSIZ, "%i", loc.desktop->k); \
fprintf(rsp, "%i", loc.desktop->k); \
else if (loc.monitor != NULL) \
snprintf(rsp, BUFSIZ, "%i", loc.monitor->k); \
fprintf(rsp, "%i", loc.monitor->k); \
else \
return false;
return MSG_FAILURE;
MONDESKGET(top_padding)
MONDESKGET(right_padding)
MONDESKGET(bottom_padding)
@ -1038,7 +1044,7 @@ bool get_setting(coordinates_t loc, char *name, char* rsp)
#undef DESKGET
#define GETCOLOR(s) \
else if (streq(#s, name)) \
snprintf(rsp, BUFSIZ, "%s", s);
fprintf(rsp, "%s", s);
GETCOLOR(focused_border_color)
GETCOLOR(active_border_color)
GETCOLOR(normal_border_color)
@ -1053,7 +1059,7 @@ bool get_setting(coordinates_t loc, char *name, char* rsp)
#undef GETCOLOR
#define GETBOOL(s) \
else if (streq(#s, name)) \
snprintf(rsp, BUFSIZ, "%s", BOOLSTR(s));
fprintf(rsp, "%s", BOOLSTR(s));
GETBOOL(borderless_monocle)
GETBOOL(gapless_monocle)
GETBOOL(focus_follows_pointer)
@ -1066,8 +1072,8 @@ bool get_setting(coordinates_t loc, char *name, char* rsp)
GETBOOL(remove_disabled_monitor)
#undef GETBOOL
else
return false;
return true;
return MSG_FAILURE;
return MSG_SUCCESS;
}
bool parse_bool(char *value, bool *b)

View file

@ -35,24 +35,20 @@
#define CAT_CHR '.'
#define EQL_TOK "="
#define MESSAGE_SUBSCRIBE '\x01'
#define MESSAGE_GET_STATUS '\x02'
#define NON_CONTROL_START '\x20'
bool handle_message(char *msg, int msg_len, char *rsp);
bool process_message(char **args, int num, char *rsp);
bool cmd_window(char **args, int num);
bool cmd_desktop(char **args, int num);
bool cmd_monitor(char **args, int num);
bool cmd_query(char **args, int num, char *rsp);
bool cmd_rule(char **args, int num, char *rsp);
bool cmd_pointer(char **args, int num);
bool cmd_restore(char **args, int num);
bool cmd_control(char **args, int num, char *rsp);
bool cmd_config(char **args, int num, char *rsp);
bool cmd_quit(char **args, int num);
bool set_setting(coordinates_t loc, char *name, char *value);
bool get_setting(coordinates_t loc, char *name, char* rsp);
int handle_message(char *msg, int msg_len, FILE *rsp);
int process_message(char **args, int num, FILE *rsp);
int cmd_window(char **args, int num);
int cmd_desktop(char **args, int num);
int cmd_monitor(char **args, int num);
int cmd_query(char **args, int num, FILE *rsp);
int cmd_rule(char **args, int num, FILE *rsp);
int cmd_pointer(char **args, int num);
int cmd_restore(char **args, int num);
int cmd_control(char **args, int num, FILE *rsp);
int cmd_config(char **args, int num, FILE *rsp);
int cmd_quit(char **args, int num);
int set_setting(coordinates_t loc, char *name, char *value);
int get_setting(coordinates_t loc, char *name, FILE* rsp);
bool parse_bool(char *value, bool *b);
bool parse_layout(char *s, layout_t *l);
bool parse_direction(char *s, direction_t *d);

78
query.c
View file

@ -37,69 +37,58 @@
#include "tree.h"
#include "query.h"
void query_monitors(coordinates_t loc, domain_t dom, char *rsp)
void query_monitors(coordinates_t loc, domain_t dom, FILE *rsp)
{
char line[MAXLEN];
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
if (loc.monitor != NULL && m != loc.monitor)
continue;
if (dom != DOMAIN_DESKTOP) {
if (dom == DOMAIN_MONITOR) {
snprintf(line, sizeof(line), "%s\n", m->name);
strncat(rsp, line, REMLEN(rsp));
fprintf(rsp, "%s\n", m->name);
continue;
} else {
snprintf(line, sizeof(line), "%s %ux%u%+i%+i %i,%i,%i,%i", m->name,
fprintf(rsp, "%s %ux%u%+i%+i %i,%i,%i,%i%s\n", m->name,
m->rectangle.width,m->rectangle.height, m->rectangle.x, m->rectangle.y,
m->top_padding, m->right_padding, m->bottom_padding, m->left_padding);
strncat(rsp, line, REMLEN(rsp));
if (m == mon)
strncat(rsp, " *", REMLEN(rsp));
strncat(rsp, "\n", REMLEN(rsp));
m->top_padding, m->right_padding, m->bottom_padding, m->left_padding,
(m == mon ? " *" : ""));
}
}
query_desktops(m, dom, loc, (dom == DOMAIN_DESKTOP ? 0 : 1), rsp);
}
}
void query_desktops(monitor_t *m, domain_t dom, coordinates_t loc, unsigned int depth, char *rsp)
void query_desktops(monitor_t *m, domain_t dom, coordinates_t loc, unsigned int depth, FILE *rsp)
{
char line[MAXLEN];
for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
if (loc.desktop != NULL && d != loc.desktop)
continue;
for (unsigned int i = 0; i < depth; i++)
strncat(rsp, "\t", REMLEN(rsp));
fprintf(rsp, "\t");
if (dom == DOMAIN_DESKTOP) {
snprintf(line, sizeof(line), "%s\n", d->name);
strncat(rsp, line, REMLEN(rsp));
fprintf(rsp, "%s\n", d->name);
continue;
} else {
snprintf(line, sizeof(line), "%s %u %i %i,%i,%i,%i %c %c", d->name, d->border_width, d->window_gap,
d->top_padding, d->right_padding, d->bottom_padding, d->left_padding,
(d->layout == LAYOUT_TILED ? 'T' : 'M'), (d->floating ? 'f' : '-'));
strncat(rsp, line, REMLEN(rsp));
if (d == m->desk)
strncat(rsp, " *", REMLEN(rsp));
strncat(rsp, "\n", REMLEN(rsp));
fprintf(rsp, "%s %u %i %i,%i,%i,%i %c %c%s\n", d->name, d->border_width,
d->window_gap,
d->top_padding, d->right_padding, d->bottom_padding, d->left_padding,
(d->layout == LAYOUT_TILED ? 'T' : 'M'), (d->floating ? 'f' : '-'),
(d == m->desk ? " *" : ""));
}
query_tree(d, d->root, rsp, depth + 1);
}
}
void query_tree(desktop_t *d, node_t *n, char *rsp, unsigned int depth)
void query_tree(desktop_t *d, node_t *n, FILE *rsp, unsigned int depth)
{
if (n == NULL)
return;
char line[MAXLEN];
for (unsigned int i = 0; i < depth; i++)
strncat(rsp, "\t", REMLEN(rsp));
fprintf(rsp, "\t");
if (is_leaf(n)) {
client_t *c = n->client;
snprintf(line, sizeof(line), "%c %s %s 0x%X %u %ux%u%+i%+i %c %c%c%c%c%c%c%c%c",
fprintf(rsp, "%c %s %s 0x%X %u %ux%u%+i%+i %c %c%c%c%c%c%c%c%c%s\n",
(n->birth_rotation == 90 ? 'a' : (n->birth_rotation == 270 ? 'c' : 'm')),
c->class_name, c->instance_name, c->window, c->border_width,
c->floating_rectangle.width, c->floating_rectangle.height,
@ -107,25 +96,19 @@ void query_tree(desktop_t *d, node_t *n, char *rsp, unsigned int depth)
(n->split_dir == DIR_UP ? 'U' : (n->split_dir == DIR_RIGHT ? 'R' : (n->split_dir == DIR_DOWN ? 'D' : 'L'))),
(c->floating ? 'f' : '-'), (c->pseudo_tiled ? 'd' : '-'), (c->fullscreen ? 'F' : '-'),
(c->urgent ? 'u' : '-'), (c->locked ? 'l' : '-'), (c->sticky ? 's' : '-'),
(c->private ? 'i' : '-'), (n->split_mode ? 'p' : '-'));
(c->private ? 'i' : '-'), (n->split_mode ? 'p' : '-'),
(n == d->focus ? " *" : ""));
} else {
snprintf(line, sizeof(line), "%c %c %lf", (n->split_type == TYPE_HORIZONTAL ? 'H' : 'V'),
fprintf(rsp, "%c %c %lf\n", (n->split_type == TYPE_HORIZONTAL ? 'H' : 'V'),
(n->birth_rotation == 90 ? 'a' : (n->birth_rotation == 270 ? 'c' : 'm')), n->split_ratio);
}
strncat(rsp, line, REMLEN(rsp));
if (n == d->focus)
strncat(rsp, " *", REMLEN(rsp));
strncat(rsp, "\n", REMLEN(rsp));
query_tree(d, n->first_child, rsp, depth + 1);
query_tree(d, n->second_child, rsp, depth + 1);
}
void query_history(coordinates_t loc, char *rsp)
void query_history(coordinates_t loc, FILE *rsp)
{
char line[MAXLEN];
for (history_t *h = history_head; h != NULL; h = h->next) {
if ((loc.monitor != NULL && h->loc.monitor != loc.monitor)
|| (loc.desktop != NULL && h->loc.desktop != loc.desktop))
@ -133,26 +116,18 @@ void query_history(coordinates_t loc, char *rsp)
xcb_window_t win = XCB_NONE;
if (h->loc.node != NULL)
win = h->loc.node->client->window;
snprintf(line, sizeof(line), "%s %s 0x%X", h->loc.monitor->name, h->loc.desktop->name, win);
strncat(rsp, line, REMLEN(rsp));
strncat(rsp, "\n", REMLEN(rsp));
fprintf(rsp, "%s %s 0x%X\n", h->loc.monitor->name, h->loc.desktop->name, win);
}
}
void query_stack(char *rsp)
void query_stack(FILE *rsp)
{
char line[MAXLEN];
for (stacking_list_t *s = stack_head; s != NULL; s = s->next) {
snprintf(line, sizeof(line), "0x%X", s->node->client->window);
strncat(rsp, line, REMLEN(rsp));
strncat(rsp, "\n", REMLEN(rsp));
}
for (stacking_list_t *s = stack_head; s != NULL; s = s->next)
fprintf(rsp, "0x%X\n", s->node->client->window);
}
void query_windows(coordinates_t loc, char *rsp)
void query_windows(coordinates_t loc, FILE *rsp)
{
char line[MAXLEN];
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
if (loc.monitor != NULL && m != loc.monitor)
continue;
@ -162,8 +137,7 @@ void query_windows(coordinates_t loc, char *rsp)
for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) {
if (loc.node != NULL && n != loc.node)
continue;
snprintf(line, sizeof(line), "0x%X\n", n->client->window);
strncat(rsp, line, REMLEN(rsp));
fprintf(rsp, "0x%X\n", n->client->window);
}
}
}

12
query.h
View file

@ -38,12 +38,12 @@ typedef enum {
DOMAIN_STACK
} domain_t;
void query_monitors(coordinates_t loc, domain_t dom, char *rsp);
void query_desktops(monitor_t *m, domain_t dom, coordinates_t loc, unsigned int depth, char *rsp);
void query_tree(desktop_t *d, node_t *n, char *rsp, unsigned int depth);
void query_history(coordinates_t loc, char *rsp);
void query_stack(char *rsp);
void query_windows(coordinates_t loc, char *rsp);
void query_monitors(coordinates_t loc, domain_t dom, FILE *rsp);
void query_desktops(monitor_t *m, domain_t dom, coordinates_t loc, unsigned int depth, FILE *rsp);
void query_tree(desktop_t *d, node_t *n, FILE *rsp, unsigned int depth);
void query_history(coordinates_t loc, FILE *rsp);
void query_stack(FILE *rsp);
void query_windows(coordinates_t loc, FILE *rsp);
bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst);
bool desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst);
bool monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst);

6
rule.c
View file

@ -303,13 +303,11 @@ void parse_key_value(char *key, char *value, rule_consequence_t *csq)
}
}
void list_rules(char *pattern, char *rsp)
void list_rules(char *pattern, FILE *rsp)
{
char line[MAXLEN];
for (rule_t *r = rule_head; r != NULL; r = r->next) {
if (pattern != NULL && !streq(pattern, r->cause))
continue;
snprintf(line, sizeof(line), "%s => %s\n", r->cause, r->effect);
strncat(rsp, line, REMLEN(rsp));
fprintf(rsp, "%s => %s\n", r->cause, r->effect);
}
}

2
rule.h
View file

@ -45,6 +45,6 @@ void apply_rules(xcb_window_t win, rule_consequence_t *csq);
bool schedule_rules(xcb_window_t win, rule_consequence_t *csq);
void parse_rule_consequence(int fd, rule_consequence_t *csq);
void parse_key_value(char *key, char *value, rule_consequence_t *csq);
void list_rules(char *pattern, char *rsp);
void list_rules(char *pattern, FILE *rsp);
#endif

View file

@ -34,18 +34,11 @@
#include "settings.h"
#include "subscribe.h"
subscriber_list_t *make_subscriber_list(int fd)
subscriber_list_t *make_subscriber_list(FILE *stream)
{
subscriber_list_t *sb = malloc(sizeof(subscriber_list_t));
sb->prev = sb->next = NULL;
sb->fd = fd;
sb->stream = fdopen(fd, "w");
if (sb->stream == NULL) {
warn("Can't open subscriber %i\n", fd);
close(fd);
free(sb);
return NULL;
}
sb->stream = stream;
return sb;
}
@ -67,11 +60,9 @@ void remove_subscriber(subscriber_list_t *sb)
free(sb);
}
void add_subscriber(int fd)
void add_subscriber(FILE *stream)
{
subscriber_list_t *sb = make_subscriber_list(fd);
if (sb == NULL)
return;
subscriber_list_t *sb = make_subscriber_list(stream);
if (subscribe_head == NULL) {
subscribe_head = subscribe_tail = sb;
} else {

View file

@ -29,9 +29,9 @@
#ifndef BSPWM_SUBSCRIBE_H
#define BSPWM_SUBSCRIBE_H
subscriber_list_t *make_subscriber_list(int fd);
subscriber_list_t *make_subscriber_list(FILE *stream);
void remove_subscriber(subscriber_list_t *sb);
void add_subscriber(int fd);
void add_subscriber(FILE *stream);
int print_status(FILE *stream);
#endif