y(bool, success); \
y(map_close); \
} while (0)
+#define yerror(message) do { \
+ y(map_open); \
+ ystr("success"); \
+ y(bool, false); \
+ ystr("error"); \
+ ystr(message); \
+ y(map_close); \
+} while (0)
/** When the command did not include match criteria (!), we use the currently
* focused container. Do not confuse this case with a command which included
ws = workspace_back_and_forth_get();
if (ws == NULL) {
- y(map_open);
- ystr("success");
- y(bool, false);
- ystr("error");
- ystr("No workspace was previously active.");
- y(map_close);
+ yerror("No workspace was previously active.");
return;
}
parsed_num < 0 ||
endptr == which) {
LOG("Could not parse initial part of \"%s\" as a number.\n", which);
- y(map_open);
- ystr("success");
- y(bool, false);
- ystr("error");
// TODO: better error message
- ystr("Could not parse number");
- y(map_close);
+ yerror("Could not parse number");
return;
}
parsed_num < 0 ||
endptr == which) {
LOG("Could not parse initial part of \"%s\" as a number.\n", which);
- y(map_open);
- ystr("success");
- y(bool, false);
- ystr("error");
// TODO: better error message
- ystr("Could not parse number");
- y(map_close);
+ yerror("Could not parse number");
return;
}
ELOG("You have to specify which window/container should be focused.\n");
ELOG("Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
- y(map_open);
- ystr("success");
- y(bool, false);
- ystr("error");
- ystr("You have to specify which window/container should be focused");
- y(map_close);
+ yerror("You have to specify which window/container should be focused");
return;
}
if (!con_is_floating(focused)) {
ELOG("Cannot change position. The window/container is not floating\n");
- y(map_open);
- ystr("success");
- y(bool, false);
- ystr("error");
- ystr("Cannot change position. The window/container is not floating.");
- y(map_close);
+ yerror("Cannot change position. The window/container is not floating.");
return;
}
if (!con_is_floating(focused)) {
ELOG("Cannot change position. The window/container is not floating\n");
- y(map_open);
- ystr("success");
- y(bool, false);
- ystr("error");
- ystr("Cannot change position. The window/container is not floating.");
- y(map_close);
+ yerror("Cannot change position. The window/container is not floating.");
return;
}
if (!workspace) {
// TODO: we should include the old workspace name here and use yajl for
// generating the reply.
- y(map_open);
- ystr("success");
- y(bool, false);
- ystr("error");
// TODO: better error message
- ystr("Old workspace not found");
- y(map_close);
+ yerror("Old workspace not found");
return;
}
if (check_dest != NULL) {
// TODO: we should include the new workspace name here and use yajl for
// generating the reply.
- y(map_open);
- ystr("success");
- y(bool, false);
- ystr("error");
// TODO: better error message
- ystr("New workspace already exists");
- y(map_close);
+ yerror("New workspace already exists");
return;
}
#include "all.h"
-// Macros to make the YAJL API a bit easier to use.
-#define y(x, ...) yajl_gen_ ## x (cmd_output->json_gen, ##__VA_ARGS__)
-#define ystr(str) yajl_gen_string(cmd_output->json_gen, (unsigned char*)str, strlen(str))
-#define ysuccess(success) do { \
- y(map_open); \
- ystr("success"); \
- y(bool, success); \
- y(map_close); \
-} while (0)
-
/*******************************************************************************
* Criteria functions.
******************************************************************************/