Revert "use designated initializers for yajl_callbacks struct"
This reverts commit 705b43294a
.
This commit broke i3bar for some users.
This commit is contained in:
parent
f6ee035c61
commit
2fea5ef82b
|
@ -119,11 +119,17 @@ static int reply_map_key_cb(void *params, const unsigned char *keyVal, unsigned
|
||||||
}
|
}
|
||||||
|
|
||||||
yajl_callbacks reply_callbacks = {
|
yajl_callbacks reply_callbacks = {
|
||||||
.yajl_boolean = reply_boolean_cb,
|
NULL,
|
||||||
.yajl_string = reply_string_cb,
|
&reply_boolean_cb,
|
||||||
.yajl_start_map = reply_start_map_cb,
|
NULL,
|
||||||
.yajl_map_key = reply_map_key_cb,
|
NULL,
|
||||||
.yajl_end_map = reply_end_map_cb,
|
NULL,
|
||||||
|
&reply_string_cb,
|
||||||
|
&reply_start_map_cb,
|
||||||
|
&reply_map_key_cb,
|
||||||
|
&reply_end_map_cb,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ ev_io *stdin_io;
|
||||||
ev_child *child_sig;
|
ev_child *child_sig;
|
||||||
|
|
||||||
/* JSON parser for stdin */
|
/* JSON parser for stdin */
|
||||||
|
yajl_callbacks callbacks;
|
||||||
yajl_handle parser;
|
yajl_handle parser;
|
||||||
|
|
||||||
/* JSON generator for stdout */
|
/* JSON generator for stdout */
|
||||||
|
@ -457,16 +458,15 @@ void start_child(char *command) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Allocate a yajl parser which will be used to parse stdin. */
|
/* Allocate a yajl parser which will be used to parse stdin. */
|
||||||
yajl_callbacks callbacks = {
|
memset(&callbacks, '\0', sizeof(yajl_callbacks));
|
||||||
.yajl_boolean = stdin_boolean,
|
callbacks.yajl_map_key = stdin_map_key;
|
||||||
.yajl_integer = stdin_integer,
|
callbacks.yajl_boolean = stdin_boolean;
|
||||||
.yajl_string = stdin_string,
|
callbacks.yajl_string = stdin_string;
|
||||||
.yajl_start_map = stdin_start_map,
|
callbacks.yajl_integer = stdin_integer;
|
||||||
.yajl_map_key = stdin_map_key,
|
callbacks.yajl_start_array = stdin_start_array;
|
||||||
.yajl_end_map = stdin_end_map,
|
callbacks.yajl_end_array = stdin_end_array;
|
||||||
.yajl_start_array = stdin_start_array,
|
callbacks.yajl_start_map = stdin_start_map;
|
||||||
.yajl_end_array = stdin_end_array,
|
callbacks.yajl_end_map = stdin_end_map;
|
||||||
};
|
|
||||||
#if YAJL_MAJOR < 2
|
#if YAJL_MAJOR < 2
|
||||||
yajl_parser_config parse_conf = { 0, 0 };
|
yajl_parser_config parse_conf = { 0, 0 };
|
||||||
|
|
||||||
|
|
|
@ -212,10 +212,17 @@ static int config_boolean_cb(void *params_, int val) {
|
||||||
|
|
||||||
/* A datastructure to pass all these callbacks to yajl */
|
/* A datastructure to pass all these callbacks to yajl */
|
||||||
static yajl_callbacks outputs_callbacks = {
|
static yajl_callbacks outputs_callbacks = {
|
||||||
.yajl_null = config_null_cb,
|
&config_null_cb,
|
||||||
.yajl_boolean = config_boolean_cb,
|
&config_boolean_cb,
|
||||||
.yajl_string = config_string_cb,
|
NULL,
|
||||||
.yajl_map_key = config_map_key_cb,
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&config_string_cb,
|
||||||
|
NULL,
|
||||||
|
&config_map_key_cb,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -73,8 +73,17 @@ static int mode_map_key_cb(void *params_, const unsigned char *keyVal, unsigned
|
||||||
|
|
||||||
/* A datastructure to pass all these callbacks to yajl */
|
/* A datastructure to pass all these callbacks to yajl */
|
||||||
yajl_callbacks mode_callbacks = {
|
yajl_callbacks mode_callbacks = {
|
||||||
.yajl_string = mode_string_cb,
|
NULL,
|
||||||
.yajl_map_key = mode_map_key_cb,
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&mode_string_cb,
|
||||||
|
NULL,
|
||||||
|
&mode_map_key_cb,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -249,13 +249,17 @@ static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, unsign
|
||||||
|
|
||||||
/* A datastructure to pass all these callbacks to yajl */
|
/* A datastructure to pass all these callbacks to yajl */
|
||||||
yajl_callbacks outputs_callbacks = {
|
yajl_callbacks outputs_callbacks = {
|
||||||
.yajl_null = outputs_null_cb,
|
&outputs_null_cb,
|
||||||
.yajl_boolean = outputs_boolean_cb,
|
&outputs_boolean_cb,
|
||||||
.yajl_integer = outputs_integer_cb,
|
&outputs_integer_cb,
|
||||||
.yajl_string = outputs_string_cb,
|
NULL,
|
||||||
.yajl_start_map = outputs_start_map_cb,
|
NULL,
|
||||||
.yajl_map_key = outputs_map_key_cb,
|
&outputs_string_cb,
|
||||||
.yajl_end_map = outputs_end_map_cb,
|
&outputs_start_map_cb,
|
||||||
|
&outputs_map_key_cb,
|
||||||
|
&outputs_end_map_cb,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -93,6 +93,20 @@ static int header_map_key(void *ctx, const unsigned char *stringval, unsigned in
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static yajl_callbacks version_callbacks = {
|
||||||
|
NULL, /* null */
|
||||||
|
&header_boolean, /* boolean */
|
||||||
|
&header_integer,
|
||||||
|
NULL, /* double */
|
||||||
|
NULL, /* number */
|
||||||
|
NULL, /* string */
|
||||||
|
NULL, /* start_map */
|
||||||
|
&header_map_key,
|
||||||
|
NULL, /* end_map */
|
||||||
|
NULL, /* start_array */
|
||||||
|
NULL /* end_array */
|
||||||
|
};
|
||||||
|
|
||||||
static void child_init(i3bar_child *child) {
|
static void child_init(i3bar_child *child) {
|
||||||
child->version = 0;
|
child->version = 0;
|
||||||
child->stop_signal = SIGSTOP;
|
child->stop_signal = SIGSTOP;
|
||||||
|
@ -108,12 +122,6 @@ static void child_init(i3bar_child *child) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void parse_json_header(i3bar_child *child, const unsigned char *buffer, int length, unsigned int *consumed) {
|
void parse_json_header(i3bar_child *child, const unsigned char *buffer, int length, unsigned int *consumed) {
|
||||||
static yajl_callbacks version_callbacks = {
|
|
||||||
.yajl_boolean = header_boolean,
|
|
||||||
.yajl_integer = header_integer,
|
|
||||||
.yajl_map_key = &header_map_key,
|
|
||||||
};
|
|
||||||
|
|
||||||
child_init(child);
|
child_init(child);
|
||||||
|
|
||||||
current_key = NO_KEY;
|
current_key = NO_KEY;
|
||||||
|
|
|
@ -199,11 +199,17 @@ static int workspaces_map_key_cb(void *params_, const unsigned char *keyVal, uns
|
||||||
|
|
||||||
/* A datastructure to pass all these callbacks to yajl */
|
/* A datastructure to pass all these callbacks to yajl */
|
||||||
yajl_callbacks workspaces_callbacks = {
|
yajl_callbacks workspaces_callbacks = {
|
||||||
.yajl_boolean = workspaces_boolean_cb,
|
NULL,
|
||||||
.yajl_integer = workspaces_integer_cb,
|
&workspaces_boolean_cb,
|
||||||
.yajl_string = workspaces_string_cb,
|
&workspaces_integer_cb,
|
||||||
.yajl_start_map = workspaces_start_map_cb,
|
NULL,
|
||||||
.yajl_map_key = workspaces_map_key_cb,
|
NULL,
|
||||||
|
&workspaces_string_cb,
|
||||||
|
&workspaces_start_map_cb,
|
||||||
|
&workspaces_map_key_cb,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -42,8 +42,17 @@ static int version_map_key(void *ctx, const unsigned char *stringval, unsigned i
|
||||||
}
|
}
|
||||||
|
|
||||||
static yajl_callbacks version_callbacks = {
|
static yajl_callbacks version_callbacks = {
|
||||||
.yajl_string = version_string,
|
NULL, /* null */
|
||||||
.yajl_map_key = version_map_key,
|
NULL, /* boolean */
|
||||||
|
NULL, /* integer */
|
||||||
|
NULL, /* double */
|
||||||
|
NULL, /* number */
|
||||||
|
&version_string,
|
||||||
|
NULL, /* start_map */
|
||||||
|
&version_map_key,
|
||||||
|
NULL, /* end_map */
|
||||||
|
NULL, /* start_array */
|
||||||
|
NULL /* end_array */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -815,6 +815,7 @@ static int add_subscription(void *extra, const unsigned char *s,
|
||||||
*/
|
*/
|
||||||
IPC_HANDLER(subscribe) {
|
IPC_HANDLER(subscribe) {
|
||||||
yajl_handle p;
|
yajl_handle p;
|
||||||
|
yajl_callbacks callbacks;
|
||||||
yajl_status stat;
|
yajl_status stat;
|
||||||
ipc_client *current, *client = NULL;
|
ipc_client *current, *client = NULL;
|
||||||
|
|
||||||
|
@ -833,9 +834,8 @@ IPC_HANDLER(subscribe) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the JSON parser */
|
/* Setup the JSON parser */
|
||||||
yajl_callbacks callbacks = {
|
memset(&callbacks, 0, sizeof(yajl_callbacks));
|
||||||
.yajl_string = add_subscription,
|
callbacks.yajl_string = add_subscription;
|
||||||
};
|
|
||||||
|
|
||||||
p = yalloc(&callbacks, (void*)client);
|
p = yalloc(&callbacks, (void*)client);
|
||||||
stat = yajl_parse(p, (const unsigned char*)message, message_size);
|
stat = yajl_parse(p, (const unsigned char*)message, message_size);
|
||||||
|
|
|
@ -51,10 +51,17 @@ static int json_end_map(void *ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static yajl_callbacks command_error_callbacks = {
|
static yajl_callbacks command_error_callbacks = {
|
||||||
.yajl_boolean = json_boolean,
|
NULL,
|
||||||
.yajl_start_map = json_start_map,
|
&json_boolean,
|
||||||
.yajl_map_key = json_map_key,
|
NULL,
|
||||||
.yajl_end_map = json_end_map,
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&json_start_map,
|
||||||
|
&json_map_key,
|
||||||
|
&json_end_map,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -406,16 +406,16 @@ void tree_append_json(const char *filename, char **errormsg) {
|
||||||
LOG("read %d bytes\n", n);
|
LOG("read %d bytes\n", n);
|
||||||
yajl_gen g;
|
yajl_gen g;
|
||||||
yajl_handle hand;
|
yajl_handle hand;
|
||||||
yajl_callbacks callbacks = {
|
yajl_callbacks callbacks;
|
||||||
.yajl_boolean = json_bool,
|
memset(&callbacks, '\0', sizeof(yajl_callbacks));
|
||||||
.yajl_integer = json_int,
|
callbacks.yajl_start_map = json_start_map;
|
||||||
.yajl_double = json_double,
|
callbacks.yajl_end_map = json_end_map;
|
||||||
.yajl_string = json_string,
|
callbacks.yajl_end_array = json_end_array;
|
||||||
.yajl_start_map = json_start_map,
|
callbacks.yajl_string = json_string;
|
||||||
.yajl_map_key = json_key,
|
callbacks.yajl_map_key = json_key;
|
||||||
.yajl_end_map = json_end_map,
|
callbacks.yajl_integer = json_int;
|
||||||
.yajl_end_array = json_end_array,
|
callbacks.yajl_double = json_double;
|
||||||
};
|
callbacks.yajl_boolean = json_bool;
|
||||||
#if YAJL_MAJOR >= 2
|
#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);
|
||||||
|
|
Loading…
Reference in New Issue