Remove yajl major version conditionals
Yajl version ≥ 2 is required. fixes #1156
This commit is contained in:
parent
22b4215d92
commit
13db562551
2
DEPENDS
2
DEPENDS
|
@ -12,7 +12,7 @@
|
||||||
│ xcb-util │ 0.3.3 │ 0.3.8 │ http://xcb.freedesktop.org/dist/ │
|
│ 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/ │
|
│ util-cursor³│ 0.0.99 │ 0.0.99 │ http://xcb.freedesktop.org/dist/ │
|
||||||
│ libev │ 4.0 │ 4.11 │ http://libev.schmorp.de/ │
|
│ 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/ │
|
│ 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/ │
|
│ 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/
|
│ Pod::Simple²│ 3.22 │ 3.22 │ http://search.cpan.org/~dwheeler/Pod-Simple-3.23/
|
||||||
|
|
|
@ -115,9 +115,6 @@ XCURSOR_LIBS := $(call ldflags_for_lib, xcb-cursor,xcb-cursor)
|
||||||
|
|
||||||
# yajl
|
# yajl
|
||||||
YAJL_CFLAGS := $(call cflags_for_lib, 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)
|
YAJL_LIBS := $(call ldflags_for_lib, yajl,yajl)
|
||||||
|
|
||||||
#libev
|
#libev
|
||||||
|
|
|
@ -76,11 +76,7 @@ static int reply_boolean_cb(void *params, int val) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int reply_string_cb(void *params, const unsigned char *val, size_t len) {
|
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);
|
char *str = scalloc(len + 1);
|
||||||
strncpy(str, (const char*)val, len);
|
strncpy(str, (const char*)val, len);
|
||||||
if (strcmp(last_key, "error") == 0)
|
if (strcmp(last_key, "error") == 0)
|
||||||
|
@ -107,11 +103,7 @@ static int reply_end_map_cb(void *params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int reply_map_key_cb(void *params, const unsigned char *keyVal, size_t keyLen) {
|
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);
|
free(last_key);
|
||||||
last_key = scalloc(keyLen + 1);
|
last_key = scalloc(keyLen + 1);
|
||||||
strncpy(last_key, (const char*)keyVal, keyLen);
|
strncpy(last_key, (const char*)keyVal, keyLen);
|
||||||
|
@ -239,21 +231,12 @@ int main(int argc, char *argv[]) {
|
||||||
* If not, nicely format the error message. */
|
* If not, nicely format the error message. */
|
||||||
if (reply_type == I3_IPC_MESSAGE_TYPE_COMMAND) {
|
if (reply_type == I3_IPC_MESSAGE_TYPE_COMMAND) {
|
||||||
yajl_handle handle;
|
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);
|
handle = yajl_alloc(&reply_callbacks, NULL, NULL);
|
||||||
#endif
|
|
||||||
yajl_status state = yajl_parse(handle, (const unsigned char*)reply, reply_length);
|
yajl_status state = yajl_parse(handle, (const unsigned char*)reply, reply_length);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case yajl_status_ok:
|
case yajl_status_ok:
|
||||||
break;
|
break;
|
||||||
case yajl_status_client_canceled:
|
case yajl_status_client_canceled:
|
||||||
#if YAJL_MAJOR < 2
|
|
||||||
case yajl_status_insufficient_data:
|
|
||||||
#endif
|
|
||||||
case yajl_status_error:
|
case yajl_status_error:
|
||||||
errx(EXIT_FAILURE, "IPC: Could not parse JSON reply.");
|
errx(EXIT_FAILURE, "IPC: Could not parse JSON reply.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,11 +161,7 @@ static int stdin_start_map(void *context) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int stdin_map_key(void *context, const unsigned char *key, size_t len) {
|
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;
|
parser_ctx *ctx = context;
|
||||||
FREE(ctx->last_map_key);
|
FREE(ctx->last_map_key);
|
||||||
sasprintf(&(ctx->last_map_key), "%.*s", len, key);
|
sasprintf(&(ctx->last_map_key), "%.*s", len, key);
|
||||||
|
@ -183,11 +179,7 @@ static int stdin_boolean(void *context, int val) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int stdin_string(void *context, const unsigned char *val, size_t len) {
|
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;
|
parser_ctx *ctx = context;
|
||||||
if (strcasecmp(ctx->last_map_key, "full_text") == 0) {
|
if (strcasecmp(ctx->last_map_key, "full_text") == 0) {
|
||||||
ctx->block.full_text = i3string_from_utf8_with_length((const char *)val, len);
|
ctx->block.full_text = i3string_from_utf8_with_length((const char *)val, len);
|
||||||
|
@ -223,11 +215,7 @@ static int stdin_string(void *context, const unsigned char *val, unsigned int le
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int stdin_integer(void *context, long long val) {
|
static int stdin_integer(void *context, long long val) {
|
||||||
#else
|
|
||||||
static int stdin_integer(void *context, long val) {
|
|
||||||
#endif
|
|
||||||
parser_ctx *ctx = context;
|
parser_ctx *ctx = context;
|
||||||
if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
|
if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
|
||||||
ctx->block.min_width = (uint32_t)val;
|
ctx->block.min_width = (uint32_t)val;
|
||||||
|
@ -321,11 +309,7 @@ static void read_flat_input(char *buffer, int length) {
|
||||||
static bool read_json_input(unsigned char *input, int length) {
|
static bool read_json_input(unsigned char *input, int length) {
|
||||||
yajl_status status = yajl_parse(parser, input, length);
|
yajl_status status = yajl_parse(parser, input, length);
|
||||||
bool has_urgent = false;
|
bool has_urgent = false;
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
if (status != yajl_status_ok) {
|
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);
|
char *message = (char *)yajl_get_error(parser, 0, input, length);
|
||||||
|
|
||||||
/* strip the newline yajl adds to the error message */
|
/* strip the newline yajl adds to the error message */
|
||||||
|
@ -429,11 +413,8 @@ void child_sig_cb(struct ev_loop *loop, ev_child *watcher, int revents) {
|
||||||
void child_write_output(void) {
|
void child_write_output(void) {
|
||||||
if (child.click_events) {
|
if (child.click_events) {
|
||||||
const unsigned char *output;
|
const unsigned char *output;
|
||||||
#if YAJL_MAJOR < 2
|
|
||||||
unsigned int size;
|
|
||||||
#else
|
|
||||||
size_t size;
|
size_t size;
|
||||||
#endif
|
|
||||||
yajl_gen_get_buf(gen, &output, &size);
|
yajl_gen_get_buf(gen, &output, &size);
|
||||||
write(child_stdin, output, size);
|
write(child_stdin, output, size);
|
||||||
write(child_stdin, "\n", 1);
|
write(child_stdin, "\n", 1);
|
||||||
|
@ -465,17 +446,9 @@ void start_child(char *command) {
|
||||||
.yajl_start_array = stdin_start_array,
|
.yajl_start_array = stdin_start_array,
|
||||||
.yajl_end_array = stdin_end_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);
|
parser = yajl_alloc(&callbacks, NULL, &parser_context);
|
||||||
|
|
||||||
gen = yajl_gen_alloc(NULL);
|
gen = yajl_gen_alloc(NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
int pipe_in[2]; /* pipe we read from */
|
int pipe_in[2]; /* pipe we read from */
|
||||||
int pipe_out[2]; /* pipe we write to */
|
int pipe_out[2]; /* pipe we write to */
|
||||||
|
|
|
@ -27,11 +27,7 @@ static char *cur_key;
|
||||||
* Essentially we just save it in cur_key.
|
* 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) {
|
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);
|
FREE(cur_key);
|
||||||
|
|
||||||
cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1));
|
cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1));
|
||||||
|
@ -61,11 +57,7 @@ static int config_null_cb(void *params_) {
|
||||||
* Parse a string
|
* Parse a string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int config_string_cb(void *params_, const unsigned char *val, size_t _len) {
|
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;
|
int len = (int)_len;
|
||||||
/* The id and socket_path are ignored, we already know them. */
|
/* The id and socket_path are ignored, we already know them. */
|
||||||
if (!strcmp(cur_key, "id") || !strcmp(cur_key, "socket_path"))
|
if (!strcmp(cur_key, "id") || !strcmp(cur_key, "socket_path"))
|
||||||
|
@ -225,13 +217,7 @@ static yajl_callbacks outputs_callbacks = {
|
||||||
void parse_config_json(char *json) {
|
void parse_config_json(char *json) {
|
||||||
yajl_handle handle;
|
yajl_handle handle;
|
||||||
yajl_status state;
|
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);
|
handle = yajl_alloc(&outputs_callbacks, NULL, NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
||||||
|
|
||||||
|
@ -240,9 +226,6 @@ void parse_config_json(char *json) {
|
||||||
case yajl_status_ok:
|
case yajl_status_ok:
|
||||||
break;
|
break;
|
||||||
case yajl_status_client_canceled:
|
case yajl_status_client_canceled:
|
||||||
#if YAJL_MAJOR < 2
|
|
||||||
case yajl_status_insufficient_data:
|
|
||||||
#endif
|
|
||||||
case yajl_status_error:
|
case yajl_status_error:
|
||||||
ELOG("Could not parse config-reply!\n");
|
ELOG("Could not parse config-reply!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -27,11 +27,7 @@ struct mode_json_params {
|
||||||
* Parse a string (change)
|
* Parse a string (change)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int mode_string_cb(void *params_, const unsigned char *val, size_t len) {
|
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_;
|
struct mode_json_params *params = (struct mode_json_params*) params_;
|
||||||
|
|
||||||
if (!strcmp(params->cur_key, "change")) {
|
if (!strcmp(params->cur_key, "change")) {
|
||||||
|
@ -56,11 +52,7 @@ static int mode_string_cb(void *params_, const unsigned char *val, unsigned int
|
||||||
* Essentially we just save it in the parsing-state
|
* 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) {
|
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_;
|
struct mode_json_params *params = (struct mode_json_params*) params_;
|
||||||
FREE(params->cur_key);
|
FREE(params->cur_key);
|
||||||
|
|
||||||
|
@ -95,13 +87,7 @@ void parse_mode_json(char *json) {
|
||||||
yajl_handle handle;
|
yajl_handle handle;
|
||||||
yajl_status state;
|
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);
|
handle = yajl_alloc(&mode_callbacks, NULL, (void*) ¶ms);
|
||||||
#endif
|
|
||||||
|
|
||||||
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
||||||
|
|
||||||
|
@ -110,9 +96,6 @@ void parse_mode_json(char *json) {
|
||||||
case yajl_status_ok:
|
case yajl_status_ok:
|
||||||
break;
|
break;
|
||||||
case yajl_status_client_canceled:
|
case yajl_status_client_canceled:
|
||||||
#if YAJL_MAJOR < 2
|
|
||||||
case yajl_status_insufficient_data:
|
|
||||||
#endif
|
|
||||||
case yajl_status_error:
|
case yajl_status_error:
|
||||||
ELOG("Could not parse mode-event!\n");
|
ELOG("Could not parse mode-event!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -64,11 +64,7 @@ static int outputs_boolean_cb(void *params_, int val) {
|
||||||
* Parse an integer (current_workspace or the rect)
|
* Parse an integer (current_workspace or the rect)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int outputs_integer_cb(void *params_, long long val) {
|
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_;
|
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||||
|
|
||||||
if (!strcmp(params->cur_key, "current_workspace")) {
|
if (!strcmp(params->cur_key, "current_workspace")) {
|
||||||
|
@ -108,11 +104,7 @@ static int outputs_integer_cb(void *params_, long val) {
|
||||||
* Parse a string (name)
|
* Parse a string (name)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int outputs_string_cb(void *params_, const unsigned char *val, size_t len) {
|
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_;
|
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||||
|
|
||||||
if (!strcmp(params->cur_key, "current_workspace")) {
|
if (!strcmp(params->cur_key, "current_workspace")) {
|
||||||
|
@ -232,11 +224,7 @@ static int outputs_end_map_cb(void *params_) {
|
||||||
* Essentially we just save it in the parsing-state
|
* 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) {
|
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_;
|
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||||
FREE(params->cur_key);
|
FREE(params->cur_key);
|
||||||
|
|
||||||
|
@ -281,13 +269,7 @@ void parse_outputs_json(char *json) {
|
||||||
|
|
||||||
yajl_handle handle;
|
yajl_handle handle;
|
||||||
yajl_status state;
|
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);
|
handle = yajl_alloc(&outputs_callbacks, NULL, (void*) ¶ms);
|
||||||
#endif
|
|
||||||
|
|
||||||
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
||||||
|
|
||||||
|
@ -296,9 +278,6 @@ void parse_outputs_json(char *json) {
|
||||||
case yajl_status_ok:
|
case yajl_status_ok:
|
||||||
break;
|
break;
|
||||||
case yajl_status_client_canceled:
|
case yajl_status_client_canceled:
|
||||||
#if YAJL_MAJOR < 2
|
|
||||||
case yajl_status_insufficient_data:
|
|
||||||
#endif
|
|
||||||
case yajl_status_error:
|
case yajl_status_error:
|
||||||
ELOG("Could not parse outputs-reply!\n");
|
ELOG("Could not parse outputs-reply!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -35,11 +35,7 @@ static enum {
|
||||||
NO_KEY
|
NO_KEY
|
||||||
} current_key;
|
} current_key;
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int header_integer(void *ctx, long long val) {
|
static int header_integer(void *ctx, long long val) {
|
||||||
#else
|
|
||||||
static int header_integer(void *ctx, long val) {
|
|
||||||
#endif
|
|
||||||
i3bar_child *child = ctx;
|
i3bar_child *child = ctx;
|
||||||
|
|
||||||
switch (current_key) {
|
switch (current_key) {
|
||||||
|
@ -76,11 +72,7 @@ static int header_boolean(void *ctx, int val) {
|
||||||
#define CHECK_KEY(name) (stringlen == strlen(name) && \
|
#define CHECK_KEY(name) (stringlen == strlen(name) && \
|
||||||
STARTS_WITH((const char*)stringval, stringlen, 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) {
|
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")) {
|
if (CHECK_KEY("version")) {
|
||||||
current_key = KEY_VERSION;
|
current_key = KEY_VERSION;
|
||||||
} else if (CHECK_KEY("stop_signal")) {
|
} else if (CHECK_KEY("stop_signal")) {
|
||||||
|
@ -118,16 +110,10 @@ void parse_json_header(i3bar_child *child, const unsigned char *buffer, int leng
|
||||||
|
|
||||||
current_key = NO_KEY;
|
current_key = NO_KEY;
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
yajl_handle handle = yajl_alloc(&version_callbacks, NULL, child);
|
yajl_handle handle = yajl_alloc(&version_callbacks, NULL, child);
|
||||||
/* Allow trailing garbage. yajl 1 always behaves that way anyways, but for
|
/* Allow trailing garbage. yajl 1 always behaves that way anyways, but for
|
||||||
* yajl 2, we need to be explicit. */
|
* yajl 2, we need to be explicit. */
|
||||||
yajl_config(handle, yajl_allow_trailing_garbage, 1);
|
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);
|
yajl_status state = yajl_parse(handle, buffer, length);
|
||||||
if (state != yajl_status_ok) {
|
if (state != yajl_status_ok) {
|
||||||
|
|
|
@ -58,11 +58,7 @@ static int workspaces_boolean_cb(void *params_, int val) {
|
||||||
* Parse an integer (num or the rect)
|
* Parse an integer (num or the rect)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int workspaces_integer_cb(void *params_, long long val) {
|
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_;
|
struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
|
||||||
|
|
||||||
if (!strcmp(params->cur_key, "num")) {
|
if (!strcmp(params->cur_key, "num")) {
|
||||||
|
@ -103,11 +99,7 @@ static int workspaces_integer_cb(void *params_, long val) {
|
||||||
* Parse a string (name, output)
|
* Parse a string (name, output)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int workspaces_string_cb(void *params_, const unsigned char *val, size_t len) {
|
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_;
|
struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
|
||||||
|
|
||||||
char *output_name;
|
char *output_name;
|
||||||
|
@ -182,11 +174,7 @@ static int workspaces_start_map_cb(void *params_) {
|
||||||
* Essentially we just save it in the parsing-state
|
* 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) {
|
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_;
|
struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
|
||||||
FREE(params->cur_key);
|
FREE(params->cur_key);
|
||||||
|
|
||||||
|
@ -223,13 +211,7 @@ void parse_workspaces_json(char *json) {
|
||||||
|
|
||||||
yajl_handle handle;
|
yajl_handle handle;
|
||||||
yajl_status state;
|
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);
|
handle = yajl_alloc(&workspaces_callbacks, NULL, (void*) ¶ms);
|
||||||
#endif
|
|
||||||
|
|
||||||
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
||||||
|
|
||||||
|
@ -238,9 +220,6 @@ void parse_workspaces_json(char *json) {
|
||||||
case yajl_status_ok:
|
case yajl_status_ok:
|
||||||
break;
|
break;
|
||||||
case yajl_status_client_canceled:
|
case yajl_status_client_canceled:
|
||||||
#if YAJL_MAJOR < 2
|
|
||||||
case yajl_status_insufficient_data:
|
|
||||||
#endif
|
|
||||||
case yajl_status_error:
|
case yajl_status_error:
|
||||||
ELOG("Could not parse workspaces-reply!\n");
|
ELOG("Could not parse workspaces-reply!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -17,12 +17,6 @@
|
||||||
#define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)
|
#define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)
|
||||||
#define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str))
|
#define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str))
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
#define ygenalloc() yajl_gen_alloc(NULL)
|
#define ygenalloc() yajl_gen_alloc(NULL)
|
||||||
#define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, client)
|
#define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, client)
|
||||||
typedef size_t ylength;
|
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
|
|
||||||
|
|
|
@ -210,11 +210,7 @@ struct CommandResult *parse_command(const char *input) {
|
||||||
state = INITIAL;
|
state = INITIAL;
|
||||||
|
|
||||||
/* A YAJL JSON generator used for formatting replies. */
|
/* A YAJL JSON generator used for formatting replies. */
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
command_output.json_gen = yajl_gen_alloc(NULL);
|
command_output.json_gen = yajl_gen_alloc(NULL);
|
||||||
#else
|
|
||||||
command_output.json_gen = yajl_gen_alloc(NULL, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
y(array_open);
|
y(array_open);
|
||||||
command_output.needs_tree_render = false;
|
command_output.needs_tree_render = false;
|
||||||
|
|
|
@ -324,11 +324,7 @@ struct ConfigResult *parse_config(const char *input, struct context *context) {
|
||||||
statelist_idx = 1;
|
statelist_idx = 1;
|
||||||
|
|
||||||
/* A YAJL JSON generator used for formatting replies. */
|
/* A YAJL JSON generator used for formatting replies. */
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
command_output.json_gen = yajl_gen_alloc(NULL);
|
command_output.json_gen = yajl_gen_alloc(NULL);
|
||||||
#else
|
|
||||||
command_output.json_gen = yajl_gen_alloc(NULL, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
y(array_open);
|
y(array_open);
|
||||||
|
|
||||||
|
|
|
@ -21,21 +21,13 @@
|
||||||
static bool human_readable_key;
|
static bool human_readable_key;
|
||||||
static char *human_readable_version;
|
static char *human_readable_version;
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int version_string(void *ctx, const unsigned char *val, size_t len) {
|
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)
|
if (human_readable_key)
|
||||||
sasprintf(&human_readable_version, "%.*s", (int)len, val);
|
sasprintf(&human_readable_version, "%.*s", (int)len, val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int version_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
|
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") &&
|
human_readable_key = (stringlen == strlen("human_readable") &&
|
||||||
strncmp((const char*)stringval, "human_readable", strlen("human_readable")) == 0);
|
strncmp((const char*)stringval, "human_readable", strlen("human_readable")) == 0);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -104,13 +96,7 @@ void display_running_version(void) {
|
||||||
if (reply_type != I3_IPC_MESSAGE_TYPE_GET_VERSION)
|
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);
|
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);
|
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);
|
yajl_status state = yajl_parse(handle, (const unsigned char*)reply, (int)reply_length);
|
||||||
if (state != yajl_status_ok)
|
if (state != yajl_status_ok)
|
||||||
|
|
|
@ -30,11 +30,7 @@ static int json_boolean(void *ctx, int boolval) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int json_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
|
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") &&
|
parse_error_key = (stringlen >= strlen("parse_error") &&
|
||||||
strncmp((const char*)stringval, "parse_error", strlen("parse_error")) == 0);
|
strncmp((const char*)stringval, "parse_error", strlen("parse_error")) == 0);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -86,15 +82,8 @@ void handle_key_press(xcb_key_press_event_t *event) {
|
||||||
/* We parse the JSON reply to figure out whether there was an error
|
/* We parse the JSON reply to figure out whether there was an error
|
||||||
* ("success" being false in on of the returned dictionaries). */
|
* ("success" being false in on of the returned dictionaries). */
|
||||||
const unsigned char *reply;
|
const unsigned char *reply;
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
size_t length;
|
size_t length;
|
||||||
yajl_handle handle = yajl_alloc(&command_error_callbacks, NULL, NULL);
|
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);
|
yajl_gen_get_buf(command_output->json_gen, &reply, &length);
|
||||||
|
|
||||||
current_nesting_level = 0;
|
current_nesting_level = 0;
|
||||||
|
|
|
@ -133,11 +133,7 @@ static int json_end_array(void *ctx) {
|
||||||
return 1;
|
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) {
|
static int json_key(void *ctx, const unsigned char *val, size_t len) {
|
||||||
#endif
|
|
||||||
LOG("key: %.*s\n", (int)len, val);
|
LOG("key: %.*s\n", (int)len, val);
|
||||||
FREE(last_key);
|
FREE(last_key);
|
||||||
last_key = scalloc((len+1) * sizeof(char));
|
last_key = scalloc((len+1) * sizeof(char));
|
||||||
|
@ -160,11 +156,7 @@ static int json_key(void *ctx, const unsigned char *val, size_t len) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int json_string(void *ctx, const unsigned char *val, size_t len) {
|
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);
|
LOG("string: %.*s for key %s\n", (int)len, val, last_key);
|
||||||
if (parsing_swallows) {
|
if (parsing_swallows) {
|
||||||
char *sval;
|
char *sval;
|
||||||
|
@ -307,13 +299,8 @@ static int json_string(void *ctx, const unsigned char *val, unsigned int len) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
static int json_int(void *ctx, long long val) {
|
static int json_int(void *ctx, long long val) {
|
||||||
LOG("int %lld for key %s\n", val, last_key);
|
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 */
|
/* For backwards compatibility with i3 < 4.8 */
|
||||||
if (strcasecmp(last_key, "type") == 0)
|
if (strcasecmp(last_key, "type") == 0)
|
||||||
json_node->type = val;
|
json_node->type = val;
|
||||||
|
@ -427,13 +414,8 @@ void tree_append_json(Con *con, const char *filename, char **errormsg) {
|
||||||
.yajl_end_map = json_end_map,
|
.yajl_end_map = json_end_map,
|
||||||
.yajl_end_array = json_end_array,
|
.yajl_end_array = json_end_array,
|
||||||
};
|
};
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
g = yajl_gen_alloc(NULL);
|
g = yajl_gen_alloc(NULL);
|
||||||
hand = yajl_alloc(&callbacks, NULL, (void*)g);
|
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. */
|
/* Allowing comments allows for more user-friendly layout files. */
|
||||||
yajl_config(hand, yajl_allow_comments, true);
|
yajl_config(hand, yajl_allow_comments, true);
|
||||||
/* Allow multiple values, i.e. multiple nodes to attach */
|
/* Allow multiple values, i.e. multiple nodes to attach */
|
||||||
|
@ -463,11 +445,7 @@ void tree_append_json(Con *con, const char *filename, char **errormsg) {
|
||||||
con_fix_percent(con);
|
con_fix_percent(con);
|
||||||
|
|
||||||
setlocale(LC_NUMERIC, "");
|
setlocale(LC_NUMERIC, "");
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
yajl_complete_parse(hand);
|
yajl_complete_parse(hand);
|
||||||
#else
|
|
||||||
yajl_parse_complete(hand);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if (to_focus)
|
if (to_focus)
|
||||||
|
|
12
src/util.c
12
src/util.c
|
@ -188,22 +188,14 @@ static char **append_argument(char **original, char *argument) {
|
||||||
|
|
||||||
char *store_restart_layout(void) {
|
char *store_restart_layout(void) {
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
yajl_gen gen = yajl_gen_alloc(NULL);
|
yajl_gen gen = yajl_gen_alloc(NULL);
|
||||||
#else
|
|
||||||
yajl_gen gen = yajl_gen_alloc(NULL, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dump_node(gen, croot, true);
|
dump_node(gen, croot, true);
|
||||||
|
|
||||||
setlocale(LC_NUMERIC, "");
|
setlocale(LC_NUMERIC, "");
|
||||||
|
|
||||||
const unsigned char *payload;
|
const unsigned char *payload;
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
size_t length;
|
size_t length;
|
||||||
#else
|
|
||||||
unsigned int length;
|
|
||||||
#endif
|
|
||||||
y(get_buf, &payload, &length);
|
y(get_buf, &payload, &length);
|
||||||
|
|
||||||
/* create a temporary file if one hasn't been specified, or just
|
/* create a temporary file if one hasn't been specified, or just
|
||||||
|
@ -241,11 +233,7 @@ char *store_restart_layout(void) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
written += n;
|
written += n;
|
||||||
#if YAJL_MAJOR >= 2
|
|
||||||
DLOG("written: %zd of %zd\n", written, length);
|
DLOG("written: %zd of %zd\n", written, length);
|
||||||
#else
|
|
||||||
DLOG("written: %d of %d\n", written, length);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
#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
|
|
Loading…
Reference in New Issue