Yajl version ≥ 2 is required.
fixes #1156
│ xcb-util │ 0.3.3 │ 0.3.8 │ http://xcb.freedesktop.org/dist/ │
│ util-cursor³│ 0.0.99 │ 0.0.99 │ http://xcb.freedesktop.org/dist/ │
│ libev │ 4.0 │ 4.11 │ http://libev.schmorp.de/ │
-│ yajl │ 1.0.8 │ 2.0.1 │ http://lloyd.github.com/yajl/ │
+│ yajl │ 2.0.1 │ 2.0.4 │ http://lloyd.github.com/yajl/ │
│ asciidoc │ 8.3.0 │ 8.6.4 │ http://www.methods.co.nz/asciidoc/ │
│ xmlto │ 0.0.23 │ 0.0.23 │ http://www.methods.co.nz/asciidoc/ │
│ Pod::Simple²│ 3.22 │ 3.22 │ http://search.cpan.org/~dwheeler/Pod-Simple-3.23/
# yajl
YAJL_CFLAGS := $(call cflags_for_lib, yajl)
-# Fallback for libyajl 1 which did not include yajl_version.h. We need
-# YAJL_MAJOR from that file to decide which code path should be used.
-YAJL_CFLAGS += -idirafter $(TOPDIR)/yajl-fallback
YAJL_LIBS := $(call ldflags_for_lib, yajl,yajl)
#libev
return 1;
}
-#if YAJL_MAJOR >= 2
static int reply_string_cb(void *params, const unsigned char *val, size_t len) {
-#else
-static int reply_string_cb(void *params, const unsigned char *val, unsigned int len) {
-#endif
char *str = scalloc(len + 1);
strncpy(str, (const char*)val, len);
if (strcmp(last_key, "error") == 0)
}
-#if YAJL_MAJOR >= 2
static int reply_map_key_cb(void *params, const unsigned char *keyVal, size_t keyLen) {
-#else
-static int reply_map_key_cb(void *params, const unsigned char *keyVal, unsigned keyLen) {
-#endif
free(last_key);
last_key = scalloc(keyLen + 1);
strncpy(last_key, (const char*)keyVal, keyLen);
* If not, nicely format the error message. */
if (reply_type == I3_IPC_MESSAGE_TYPE_COMMAND) {
yajl_handle handle;
-#if YAJL_MAJOR < 2
- yajl_parser_config parse_conf = { 0, 0 };
-
- handle = yajl_alloc(&reply_callbacks, &parse_conf, NULL, NULL);
-#else
handle = yajl_alloc(&reply_callbacks, NULL, NULL);
-#endif
yajl_status state = yajl_parse(handle, (const unsigned char*)reply, reply_length);
switch (state) {
case yajl_status_ok:
break;
case yajl_status_client_canceled:
-#if YAJL_MAJOR < 2
- case yajl_status_insufficient_data:
-#endif
case yajl_status_error:
errx(EXIT_FAILURE, "IPC: Could not parse JSON reply.");
}
return 1;
}
-#if YAJL_MAJOR >= 2
static int stdin_map_key(void *context, const unsigned char *key, size_t len) {
-#else
-static int stdin_map_key(void *context, const unsigned char *key, unsigned int len) {
-#endif
parser_ctx *ctx = context;
FREE(ctx->last_map_key);
sasprintf(&(ctx->last_map_key), "%.*s", len, key);
return 1;
}
-#if YAJL_MAJOR >= 2
static int stdin_string(void *context, const unsigned char *val, size_t len) {
-#else
-static int stdin_string(void *context, const unsigned char *val, unsigned int len) {
-#endif
parser_ctx *ctx = context;
if (strcasecmp(ctx->last_map_key, "full_text") == 0) {
ctx->block.full_text = i3string_from_utf8_with_length((const char *)val, len);
return 1;
}
-#if YAJL_MAJOR >= 2
static int stdin_integer(void *context, long long val) {
-#else
-static int stdin_integer(void *context, long val) {
-#endif
parser_ctx *ctx = context;
if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
ctx->block.min_width = (uint32_t)val;
static bool read_json_input(unsigned char *input, int length) {
yajl_status status = yajl_parse(parser, input, length);
bool has_urgent = false;
-#if YAJL_MAJOR >= 2
if (status != yajl_status_ok) {
-#else
- if (status != yajl_status_ok && status != yajl_status_insufficient_data) {
-#endif
char *message = (char *)yajl_get_error(parser, 0, input, length);
/* strip the newline yajl adds to the error message */
void child_write_output(void) {
if (child.click_events) {
const unsigned char *output;
-#if YAJL_MAJOR < 2
- unsigned int size;
-#else
size_t size;
-#endif
+
yajl_gen_get_buf(gen, &output, &size);
write(child_stdin, output, size);
write(child_stdin, "\n", 1);
.yajl_start_array = stdin_start_array,
.yajl_end_array = stdin_end_array,
};
-#if YAJL_MAJOR < 2
- yajl_parser_config parse_conf = { 0, 0 };
-
- parser = yajl_alloc(&callbacks, &parse_conf, NULL, (void*)&parser_context);
-
- gen = yajl_gen_alloc(NULL, NULL);
-#else
parser = yajl_alloc(&callbacks, NULL, &parser_context);
gen = yajl_gen_alloc(NULL);
-#endif
int pipe_in[2]; /* pipe we read from */
int pipe_out[2]; /* pipe we write to */
* Essentially we just save it in cur_key.
*
*/
-#if YAJL_MAJOR >= 2
static int config_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
-#else
-static int config_map_key_cb(void *params_, const unsigned char *keyVal, unsigned keyLen) {
-#endif
FREE(cur_key);
cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1));
* Parse a string
*
*/
-#if YAJL_MAJOR >= 2
static int config_string_cb(void *params_, const unsigned char *val, size_t _len) {
-#else
-static int config_string_cb(void *params_, const unsigned char *val, unsigned int _len) {
-#endif
int len = (int)_len;
/* The id and socket_path are ignored, we already know them. */
if (!strcmp(cur_key, "id") || !strcmp(cur_key, "socket_path"))
void parse_config_json(char *json) {
yajl_handle handle;
yajl_status state;
-#if YAJL_MAJOR < 2
- yajl_parser_config parse_conf = { 0, 0 };
-
- handle = yajl_alloc(&outputs_callbacks, &parse_conf, NULL, NULL);
-#else
handle = yajl_alloc(&outputs_callbacks, NULL, NULL);
-#endif
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
case yajl_status_ok:
break;
case yajl_status_client_canceled:
-#if YAJL_MAJOR < 2
- case yajl_status_insufficient_data:
-#endif
case yajl_status_error:
ELOG("Could not parse config-reply!\n");
exit(EXIT_FAILURE);
* Parse a string (change)
*
*/
-#if YAJL_MAJOR >= 2
static int mode_string_cb(void *params_, const unsigned char *val, size_t len) {
-#else
-static int mode_string_cb(void *params_, const unsigned char *val, unsigned int len) {
-#endif
struct mode_json_params *params = (struct mode_json_params*) params_;
if (!strcmp(params->cur_key, "change")) {
* Essentially we just save it in the parsing-state
*
*/
-#if YAJL_MAJOR >= 2
static int mode_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
-#else
-static int mode_map_key_cb(void *params_, const unsigned char *keyVal, unsigned int keyLen) {
-#endif
struct mode_json_params *params = (struct mode_json_params*) params_;
FREE(params->cur_key);
yajl_handle handle;
yajl_status state;
-#if YAJL_MAJOR < 2
- yajl_parser_config parse_conf = { 0, 0 };
-
- handle = yajl_alloc(&mode_callbacks, &parse_conf, NULL, (void*) ¶ms);
-#else
handle = yajl_alloc(&mode_callbacks, NULL, (void*) ¶ms);
-#endif
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
case yajl_status_ok:
break;
case yajl_status_client_canceled:
-#if YAJL_MAJOR < 2
- case yajl_status_insufficient_data:
-#endif
case yajl_status_error:
ELOG("Could not parse mode-event!\n");
exit(EXIT_FAILURE);
* Parse an integer (current_workspace or the rect)
*
*/
-#if YAJL_MAJOR >= 2
static int outputs_integer_cb(void *params_, long long val) {
-#else
-static int outputs_integer_cb(void *params_, long val) {
-#endif
struct outputs_json_params *params = (struct outputs_json_params*) params_;
if (!strcmp(params->cur_key, "current_workspace")) {
* Parse a string (name)
*
*/
-#if YAJL_MAJOR >= 2
static int outputs_string_cb(void *params_, const unsigned char *val, size_t len) {
-#else
-static int outputs_string_cb(void *params_, const unsigned char *val, unsigned int len) {
-#endif
struct outputs_json_params *params = (struct outputs_json_params*) params_;
if (!strcmp(params->cur_key, "current_workspace")) {
* Essentially we just save it in the parsing-state
*
*/
-#if YAJL_MAJOR >= 2
static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
-#else
-static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, unsigned keyLen) {
-#endif
struct outputs_json_params *params = (struct outputs_json_params*) params_;
FREE(params->cur_key);
yajl_handle handle;
yajl_status state;
-#if YAJL_MAJOR < 2
- yajl_parser_config parse_conf = { 0, 0 };
-
- handle = yajl_alloc(&outputs_callbacks, &parse_conf, NULL, (void*) ¶ms);
-#else
handle = yajl_alloc(&outputs_callbacks, NULL, (void*) ¶ms);
-#endif
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
case yajl_status_ok:
break;
case yajl_status_client_canceled:
-#if YAJL_MAJOR < 2
- case yajl_status_insufficient_data:
-#endif
case yajl_status_error:
ELOG("Could not parse outputs-reply!\n");
exit(EXIT_FAILURE);
NO_KEY
} current_key;
-#if YAJL_MAJOR >= 2
static int header_integer(void *ctx, long long val) {
-#else
-static int header_integer(void *ctx, long val) {
-#endif
i3bar_child *child = ctx;
switch (current_key) {
#define CHECK_KEY(name) (stringlen == strlen(name) && \
STARTS_WITH((const char*)stringval, stringlen, name))
-#if YAJL_MAJOR >= 2
static int header_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
-#else
-static int header_map_key(void *ctx, const unsigned char *stringval, unsigned int stringlen) {
-#endif
if (CHECK_KEY("version")) {
current_key = KEY_VERSION;
} else if (CHECK_KEY("stop_signal")) {
current_key = NO_KEY;
-#if YAJL_MAJOR >= 2
yajl_handle handle = yajl_alloc(&version_callbacks, NULL, child);
/* Allow trailing garbage. yajl 1 always behaves that way anyways, but for
* yajl 2, we need to be explicit. */
yajl_config(handle, yajl_allow_trailing_garbage, 1);
-#else
- yajl_parser_config parse_conf = { 0, 0 };
-
- yajl_handle handle = yajl_alloc(&version_callbacks, &parse_conf, NULL, child);
-#endif
yajl_status state = yajl_parse(handle, buffer, length);
if (state != yajl_status_ok) {
* Parse an integer (num or the rect)
*
*/
-#if YAJL_MAJOR >= 2
static int workspaces_integer_cb(void *params_, long long val) {
-#else
-static int workspaces_integer_cb(void *params_, long val) {
-#endif
struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
if (!strcmp(params->cur_key, "num")) {
* Parse a string (name, output)
*
*/
-#if YAJL_MAJOR >= 2
static int workspaces_string_cb(void *params_, const unsigned char *val, size_t len) {
-#else
-static int workspaces_string_cb(void *params_, const unsigned char *val, unsigned int len) {
-#endif
struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
char *output_name;
* Essentially we just save it in the parsing-state
*
*/
-#if YAJL_MAJOR >= 2
static int workspaces_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
-#else
-static int workspaces_map_key_cb(void *params_, const unsigned char *keyVal, unsigned int keyLen) {
-#endif
struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
FREE(params->cur_key);
yajl_handle handle;
yajl_status state;
-#if YAJL_MAJOR < 2
- yajl_parser_config parse_conf = { 0, 0 };
-
- handle = yajl_alloc(&workspaces_callbacks, &parse_conf, NULL, (void*) ¶ms);
-#else
handle = yajl_alloc(&workspaces_callbacks, NULL, (void*) ¶ms);
-#endif
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
case yajl_status_ok:
break;
case yajl_status_client_canceled:
-#if YAJL_MAJOR < 2
- case yajl_status_insufficient_data:
-#endif
case yajl_status_error:
ELOG("Could not parse workspaces-reply!\n");
exit(EXIT_FAILURE);
#define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)
#define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str))
-#if YAJL_MAJOR >= 2
#define ygenalloc() yajl_gen_alloc(NULL)
#define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, client)
typedef size_t ylength;
-#else
-#define ygenalloc() yajl_gen_alloc(NULL, NULL);
-#define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, NULL, client)
-typedef unsigned int ylength;
-#endif
DLOG("COMMAND: *%s*\n", input);
state = INITIAL;
-/* A YAJL JSON generator used for formatting replies. */
-#if YAJL_MAJOR >= 2
+ /* A YAJL JSON generator used for formatting replies. */
command_output.json_gen = yajl_gen_alloc(NULL);
-#else
- command_output.json_gen = yajl_gen_alloc(NULL, NULL);
-#endif
y(array_open);
command_output.needs_tree_render = false;
state = INITIAL;
statelist_idx = 1;
-/* A YAJL JSON generator used for formatting replies. */
-#if YAJL_MAJOR >= 2
+ /* A YAJL JSON generator used for formatting replies. */
command_output.json_gen = yajl_gen_alloc(NULL);
-#else
- command_output.json_gen = yajl_gen_alloc(NULL, NULL);
-#endif
y(array_open);
static bool human_readable_key;
static char *human_readable_version;
-#if YAJL_MAJOR >= 2
static int version_string(void *ctx, const unsigned char *val, size_t len) {
-#else
-static int version_string(void *ctx, const unsigned char *val, unsigned int len) {
-#endif
if (human_readable_key)
sasprintf(&human_readable_version, "%.*s", (int)len, val);
return 1;
}
-#if YAJL_MAJOR >= 2
static int version_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
-#else
-static int version_map_key(void *ctx, const unsigned char *stringval, unsigned int stringlen) {
-#endif
human_readable_key = (stringlen == strlen("human_readable") &&
strncmp((const char*)stringval, "human_readable", strlen("human_readable")) == 0);
return 1;
if (reply_type != I3_IPC_MESSAGE_TYPE_GET_VERSION)
errx(EXIT_FAILURE, "Got reply type %d, but expected %d (GET_VERSION)", reply_type, I3_IPC_MESSAGE_TYPE_GET_VERSION);
-#if YAJL_MAJOR >= 2
yajl_handle handle = yajl_alloc(&version_callbacks, NULL, NULL);
-#else
- yajl_parser_config parse_conf = { 0, 0 };
-
- yajl_handle handle = yajl_alloc(&version_callbacks, &parse_conf, NULL, NULL);
-#endif
yajl_status state = yajl_parse(handle, (const unsigned char*)reply, (int)reply_length);
if (state != yajl_status_ok)
return 1;
}
-#if YAJL_MAJOR >= 2
static int json_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
-#else
-static int json_map_key(void *ctx, const unsigned char *stringval, unsigned int stringlen) {
-#endif
parse_error_key = (stringlen >= strlen("parse_error") &&
strncmp((const char*)stringval, "parse_error", strlen("parse_error")) == 0);
return 1;
/* We parse the JSON reply to figure out whether there was an error
* ("success" being false in on of the returned dictionaries). */
const unsigned char *reply;
-#if YAJL_MAJOR >= 2
size_t length;
yajl_handle handle = yajl_alloc(&command_error_callbacks, NULL, NULL);
-#else
- unsigned int length;
- yajl_parser_config parse_conf = { 0, 0 };
-
- yajl_handle handle = yajl_alloc(&command_error_callbacks, &parse_conf, NULL, NULL);
-#endif
yajl_gen_get_buf(command_output->json_gen, &reply, &length);
current_nesting_level = 0;
return 1;
}
-#if YAJL_MAJOR < 2
-static int json_key(void *ctx, const unsigned char *val, unsigned int len) {
-#else
static int json_key(void *ctx, const unsigned char *val, size_t len) {
-#endif
LOG("key: %.*s\n", (int)len, val);
FREE(last_key);
last_key = scalloc((len+1) * sizeof(char));
return 1;
}
-#if YAJL_MAJOR >= 2
static int json_string(void *ctx, const unsigned char *val, size_t len) {
-#else
-static int json_string(void *ctx, const unsigned char *val, unsigned int len) {
-#endif
LOG("string: %.*s for key %s\n", (int)len, val, last_key);
if (parsing_swallows) {
char *sval;
return 1;
}
-#if YAJL_MAJOR >= 2
static int json_int(void *ctx, long long val) {
LOG("int %lld for key %s\n", val, last_key);
-#else
-static int json_int(void *ctx, long val) {
- LOG("int %ld for key %s\n", val, last_key);
-#endif
/* For backwards compatibility with i3 < 4.8 */
if (strcasecmp(last_key, "type") == 0)
json_node->type = val;
.yajl_end_map = json_end_map,
.yajl_end_array = json_end_array,
};
-#if YAJL_MAJOR >= 2
g = yajl_gen_alloc(NULL);
hand = yajl_alloc(&callbacks, NULL, (void*)g);
-#else
- g = yajl_gen_alloc(NULL, NULL);
- hand = yajl_alloc(&callbacks, NULL, NULL, (void*)g);
-#endif
/* Allowing comments allows for more user-friendly layout files. */
yajl_config(hand, yajl_allow_comments, true);
/* Allow multiple values, i.e. multiple nodes to attach */
con_fix_percent(con);
setlocale(LC_NUMERIC, "");
-#if YAJL_MAJOR >= 2
yajl_complete_parse(hand);
-#else
- yajl_parse_complete(hand);
-#endif
fclose(f);
if (to_focus)
char *store_restart_layout(void) {
setlocale(LC_NUMERIC, "C");
-#if YAJL_MAJOR >= 2
yajl_gen gen = yajl_gen_alloc(NULL);
-#else
- yajl_gen gen = yajl_gen_alloc(NULL, NULL);
-#endif
dump_node(gen, croot, true);
setlocale(LC_NUMERIC, "");
const unsigned char *payload;
-#if YAJL_MAJOR >= 2
size_t length;
-#else
- unsigned int length;
-#endif
y(get_buf, &payload, &length);
/* create a temporary file if one hasn't been specified, or just
return NULL;
}
written += n;
-#if YAJL_MAJOR >= 2
DLOG("written: %zd of %zd\n", written, length);
-#else
- DLOG("written: %d of %d\n", written, length);
-#endif
}
close(fd);
+++ /dev/null
-#ifndef YAJL_VERSION_H_
-#define YAJL_VERSION_H_
-/* Fallback for libyajl 1 which does not provide yajl_version.h */
-#define YAJL_MAJOR 1
-#define YAJL_MINOR 0
-#define YAJL_MICRO 0
-#endif