i3 - improved tiling WM


Remove yajl major version conditionals

Patch status: merged

Patch by Tony Crisci

Long description:

Yajl version >= 2 is required for building the i3wm.

fixes #1156

To apply this patch, use:
curl http://cr.i3wm.org/patch/537/raw.patch | git am

b/common.mk

32
@@ -115,9 +115,6 @@ XCURSOR_LIBS   := $(call ldflags_for_lib, xcb-cursor,xcb-cursor)
33
 
34
 # yajl
35
 YAJL_CFLAGS := $(call cflags_for_lib, yajl)
36
-# Fallback for libyajl 1 which did not include yajl_version.h. We need
37
-# YAJL_MAJOR from that file to decide which code path should be used.
38
-YAJL_CFLAGS += -idirafter $(TOPDIR)/yajl-fallback
39
 YAJL_LIBS   := $(call ldflags_for_lib, yajl,yajl)
40
 
41
 #libev

b/i3-msg/main.c

46
@@ -76,11 +76,7 @@ static int reply_boolean_cb(void *params, int val) {
47
     return 1;
48
 }
49
 
50
-#if YAJL_MAJOR >= 2
51
 static int reply_string_cb(void *params, const unsigned char *val, size_t len) {
52
-#else
53
-static int reply_string_cb(void *params, const unsigned char *val, unsigned int len) {
54
-#endif
55
     char *str = scalloc(len + 1);
56
     strncpy(str, (const char*)val, len);
57
     if (strcmp(last_key, "error") == 0)
58
@@ -107,11 +103,7 @@ static int reply_end_map_cb(void *params) {
59
 }
60
 
61
 
62
-#if YAJL_MAJOR >= 2
63
 static int reply_map_key_cb(void *params, const unsigned char *keyVal, size_t keyLen) {
64
-#else
65
-static int reply_map_key_cb(void *params, const unsigned char *keyVal, unsigned keyLen) {
66
-#endif
67
     free(last_key);
68
     last_key = scalloc(keyLen + 1);
69
     strncpy(last_key, (const char*)keyVal, keyLen);
70
@@ -239,21 +231,12 @@ int main(int argc, char *argv[]) {
71
      * If not, nicely format the error message. */
72
     if (reply_type == I3_IPC_MESSAGE_TYPE_COMMAND) {
73
         yajl_handle handle;
74
-#if YAJL_MAJOR < 2
75
-        yajl_parser_config parse_conf = { 0, 0 };
76
-
77
-        handle = yajl_alloc(&reply_callbacks, &parse_conf, NULL, NULL);
78
-#else
79
         handle = yajl_alloc(&reply_callbacks, NULL, NULL);
80
-#endif
81
         yajl_status state = yajl_parse(handle, (const unsigned char*)reply, reply_length);
82
         switch (state) {
83
             case yajl_status_ok:
84
                 break;
85
             case yajl_status_client_canceled:
86
-#if YAJL_MAJOR < 2
87
-            case yajl_status_insufficient_data:
88
-#endif
89
             case yajl_status_error:
90
                 errx(EXIT_FAILURE, "IPC: Could not parse JSON reply.");
91
         }

b/i3bar/src/child.c

96
@@ -161,11 +161,7 @@ static int stdin_start_map(void *context) {
97
     return 1;
98
 }
99
 
100
-#if YAJL_MAJOR >= 2
101
 static int stdin_map_key(void *context, const unsigned char *key, size_t len) {
102
-#else
103
-static int stdin_map_key(void *context, const unsigned char *key, unsigned int len) {
104
-#endif
105
     parser_ctx *ctx = context;
106
     FREE(ctx->last_map_key);
107
     sasprintf(&(ctx->last_map_key), "%.*s", len, key);
108
@@ -183,11 +179,7 @@ static int stdin_boolean(void *context, int val) {
109
     return 1;
110
 }
111
 
112
-#if YAJL_MAJOR >= 2
113
 static int stdin_string(void *context, const unsigned char *val, size_t len) {
114
-#else
115
-static int stdin_string(void *context, const unsigned char *val, unsigned int len) {
116
-#endif
117
     parser_ctx *ctx = context;
118
     if (strcasecmp(ctx->last_map_key, "full_text") == 0) {
119
         ctx->block.full_text = i3string_from_utf8_with_length((const char *)val, len);
120
@@ -223,11 +215,7 @@ static int stdin_string(void *context, const unsigned char *val, unsigned int le
121
     return 1;
122
 }
123
 
124
-#if YAJL_MAJOR >= 2
125
 static int stdin_integer(void *context, long long val) {
126
-#else
127
-static int stdin_integer(void *context, long val) {
128
-#endif
129
     parser_ctx *ctx = context;
130
     if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
131
         ctx->block.min_width = (uint32_t)val;
132
@@ -321,11 +309,7 @@ static void read_flat_input(char *buffer, int length) {
133
 static bool read_json_input(unsigned char *input, int length) {
134
     yajl_status status = yajl_parse(parser, input, length);
135
     bool has_urgent = false;
136
-#if YAJL_MAJOR >= 2
137
     if (status != yajl_status_ok) {
138
-#else
139
-    if (status != yajl_status_ok && status != yajl_status_insufficient_data) {
140
-#endif
141
         char *message = (char *)yajl_get_error(parser, 0, input, length);
142
 
143
         /* strip the newline yajl adds to the error message */
144
@@ -429,11 +413,8 @@ void child_sig_cb(struct ev_loop *loop, ev_child *watcher, int revents) {
145
 void child_write_output(void) {
146
     if (child.click_events) {
147
         const unsigned char *output;
148
-#if YAJL_MAJOR < 2
149
-        unsigned int size;
150
-#else
151
         size_t size;
152
-#endif
153
+
154
         yajl_gen_get_buf(gen, &output, &size);
155
         write(child_stdin, output, size);
156
         write(child_stdin, "\n", 1);
157
@@ -465,17 +446,9 @@ void start_child(char *command) {
158
         .yajl_start_array = stdin_start_array,
159
         .yajl_end_array = stdin_end_array,
160
     };
161
-#if YAJL_MAJOR < 2
162
-    yajl_parser_config parse_conf = { 0, 0 };
163
-
164
-    parser = yajl_alloc(&callbacks, &parse_conf, NULL, (void*)&parser_context);
165
-
166
-    gen = yajl_gen_alloc(NULL, NULL);
167
-#else
168
     parser = yajl_alloc(&callbacks, NULL, &parser_context);
169
 
170
     gen = yajl_gen_alloc(NULL);
171
-#endif
172
 
173
     int pipe_in[2]; /* pipe we read from */
174
     int pipe_out[2]; /* pipe we write to */

b/i3bar/src/config.c

179
@@ -27,11 +27,7 @@ static char *cur_key;
180
  * Essentially we just save it in cur_key.
181
  *
182
  */
183
-#if YAJL_MAJOR >= 2
184
 static int config_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
185
-#else
186
-static int config_map_key_cb(void *params_, const unsigned char *keyVal, unsigned keyLen) {
187
-#endif
188
     FREE(cur_key);
189
 
190
     cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1));
191
@@ -61,11 +57,7 @@ static int config_null_cb(void *params_) {
192
  * Parse a string
193
  *
194
  */
195
-#if YAJL_MAJOR >= 2
196
 static int config_string_cb(void *params_, const unsigned char *val, size_t _len) {
197
-#else
198
-static int config_string_cb(void *params_, const unsigned char *val, unsigned int _len) {
199
-#endif
200
     int len = (int)_len;
201
     /* The id and socket_path are ignored, we already know them. */
202
     if (!strcmp(cur_key, "id") || !strcmp(cur_key, "socket_path"))
203
@@ -225,13 +217,7 @@ static yajl_callbacks outputs_callbacks = {
204
 void parse_config_json(char *json) {
205
     yajl_handle handle;
206
     yajl_status state;
207
-#if YAJL_MAJOR < 2
208
-    yajl_parser_config parse_conf = { 0, 0 };
209
-
210
-    handle = yajl_alloc(&outputs_callbacks, &parse_conf, NULL, NULL);
211
-#else
212
     handle = yajl_alloc(&outputs_callbacks, NULL, NULL);
213
-#endif
214
 
215
     state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
216
 
217
@@ -240,9 +226,6 @@ void parse_config_json(char *json) {
218
         case yajl_status_ok:
219
             break;
220
         case yajl_status_client_canceled:
221
-#if YAJL_MAJOR < 2
222
-        case yajl_status_insufficient_data:
223
-#endif
224
         case yajl_status_error:
225
             ELOG("Could not parse config-reply!\n");
226
             exit(EXIT_FAILURE);

b/i3bar/src/mode.c

231
@@ -27,11 +27,7 @@ struct mode_json_params {
232
  * Parse a string (change)
233
  *
234
  */
235
-#if YAJL_MAJOR >= 2
236
 static int mode_string_cb(void *params_, const unsigned char *val, size_t len) {
237
-#else
238
-static int mode_string_cb(void *params_, const unsigned char *val, unsigned int len) {
239
-#endif
240
         struct mode_json_params *params = (struct mode_json_params*) params_;
241
 
242
         if (!strcmp(params->cur_key, "change")) {
243
@@ -56,11 +52,7 @@ static int mode_string_cb(void *params_, const unsigned char *val, unsigned int
244
  * Essentially we just save it in the parsing-state
245
  *
246
  */
247
-#if YAJL_MAJOR >= 2
248
 static int mode_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
249
-#else
250
-static int mode_map_key_cb(void *params_, const unsigned char *keyVal, unsigned int keyLen) {
251
-#endif
252
     struct mode_json_params *params = (struct mode_json_params*) params_;
253
     FREE(params->cur_key);
254
 
255
@@ -95,13 +87,7 @@ void parse_mode_json(char *json) {
256
     yajl_handle handle;
257
     yajl_status state;
258
 
259
-#if YAJL_MAJOR < 2
260
-    yajl_parser_config parse_conf = { 0, 0 };
261
-
262
-    handle = yajl_alloc(&mode_callbacks, &parse_conf, NULL, (void*) &params);
263
-#else
264
     handle = yajl_alloc(&mode_callbacks, NULL, (void*) &params);
265
-#endif
266
 
267
     state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
268
 
269
@@ -110,9 +96,6 @@ void parse_mode_json(char *json) {
270
         case yajl_status_ok:
271
             break;
272
         case yajl_status_client_canceled:
273
-#if YAJL_MAJOR < 2
274
-        case yajl_status_insufficient_data:
275
-#endif
276
         case yajl_status_error:
277
             ELOG("Could not parse mode-event!\n");
278
             exit(EXIT_FAILURE);

b/i3bar/src/outputs.c

283
@@ -64,11 +64,7 @@ static int outputs_boolean_cb(void *params_, int val) {
284
  * Parse an integer (current_workspace or the rect)
285
  *
286
  */
287
-#if YAJL_MAJOR >= 2
288
 static int outputs_integer_cb(void *params_, long long val) {
289
-#else
290
-static int outputs_integer_cb(void *params_, long val) {
291
-#endif
292
     struct outputs_json_params *params = (struct outputs_json_params*) params_;
293
 
294
     if (!strcmp(params->cur_key, "current_workspace")) {
295
@@ -108,11 +104,7 @@ static int outputs_integer_cb(void *params_, long val) {
296
  * Parse a string (name)
297
  *
298
  */
299
-#if YAJL_MAJOR >= 2
300
 static int outputs_string_cb(void *params_, const unsigned char *val, size_t len) {
301
-#else
302
-static int outputs_string_cb(void *params_, const unsigned char *val, unsigned int len) {
303
-#endif
304
     struct outputs_json_params *params = (struct outputs_json_params*) params_;
305
 
306
     if (!strcmp(params->cur_key, "current_workspace")) {
307
@@ -232,11 +224,7 @@ static int outputs_end_map_cb(void *params_) {
308
  * Essentially we just save it in the parsing-state
309
  *
310
  */
311
-#if YAJL_MAJOR >= 2
312
 static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
313
-#else
314
-static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, unsigned keyLen) {
315
-#endif
316
     struct outputs_json_params *params = (struct outputs_json_params*) params_;
317
     FREE(params->cur_key);
318
 
319
@@ -281,13 +269,7 @@ void parse_outputs_json(char *json) {
320
 
321
     yajl_handle handle;
322
     yajl_status state;
323
-#if YAJL_MAJOR < 2
324
-    yajl_parser_config parse_conf = { 0, 0 };
325
-
326
-    handle = yajl_alloc(&outputs_callbacks, &parse_conf, NULL, (void*) &params);
327
-#else
328
     handle = yajl_alloc(&outputs_callbacks, NULL, (void*) &params);
329
-#endif
330
 
331
     state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
332
 
333
@@ -296,9 +278,6 @@ void parse_outputs_json(char *json) {
334
         case yajl_status_ok:
335
             break;
336
         case yajl_status_client_canceled:
337
-#if YAJL_MAJOR < 2
338
-        case yajl_status_insufficient_data:
339
-#endif
340
         case yajl_status_error:
341
             ELOG("Could not parse outputs-reply!\n");
342
             exit(EXIT_FAILURE);

b/i3bar/src/parse_json_header.c

347
@@ -35,11 +35,7 @@ static enum {
348
     NO_KEY
349
 } current_key;
350
 
351
-#if YAJL_MAJOR >= 2
352
 static int header_integer(void *ctx, long long val) {
353
-#else
354
-static int header_integer(void *ctx, long val) {
355
-#endif
356
     i3bar_child *child = ctx;
357
 
358
     switch (current_key) {
359
@@ -76,11 +72,7 @@ static int header_boolean(void *ctx, int val) {
360
 #define CHECK_KEY(name) (stringlen == strlen(name) && \
361
                          STARTS_WITH((const char*)stringval, stringlen, name))
362
 
363
-#if YAJL_MAJOR >= 2
364
 static int header_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
365
-#else
366
-static int header_map_key(void *ctx, const unsigned char *stringval, unsigned int stringlen) {
367
-#endif
368
     if (CHECK_KEY("version")) {
369
         current_key = KEY_VERSION;
370
     } else if (CHECK_KEY("stop_signal")) {
371
@@ -118,16 +110,10 @@ void parse_json_header(i3bar_child *child, const unsigned char *buffer, int leng
372
 
373
     current_key = NO_KEY;
374
 
375
-#if YAJL_MAJOR >= 2
376
     yajl_handle handle = yajl_alloc(&version_callbacks, NULL, child);
377
     /* Allow trailing garbage. yajl 1 always behaves that way anyways, but for
378
      * yajl 2, we need to be explicit. */
379
     yajl_config(handle, yajl_allow_trailing_garbage, 1);
380
-#else
381
-    yajl_parser_config parse_conf = { 0, 0 };
382
-
383
-    yajl_handle handle = yajl_alloc(&version_callbacks, &parse_conf, NULL, child);
384
-#endif
385
 
386
     yajl_status state = yajl_parse(handle, buffer, length);
387
     if (state != yajl_status_ok) {

b/i3bar/src/workspaces.c

392
@@ -58,11 +58,7 @@ static int workspaces_boolean_cb(void *params_, int val) {
393
  * Parse an integer (num or the rect)
394
  *
395
  */
396
-#if YAJL_MAJOR >= 2
397
 static int workspaces_integer_cb(void *params_, long long val) {
398
-#else
399
-static int workspaces_integer_cb(void *params_, long val) {
400
-#endif
401
     struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
402
 
403
     if (!strcmp(params->cur_key, "num")) {
404
@@ -103,11 +99,7 @@ static int workspaces_integer_cb(void *params_, long val) {
405
  * Parse a string (name, output)
406
  *
407
  */
408
-#if YAJL_MAJOR >= 2
409
 static int workspaces_string_cb(void *params_, const unsigned char *val, size_t len) {
410
-#else
411
-static int workspaces_string_cb(void *params_, const unsigned char *val, unsigned int len) {
412
-#endif
413
         struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
414
 
415
         char *output_name;
416
@@ -182,11 +174,7 @@ static int workspaces_start_map_cb(void *params_) {
417
  * Essentially we just save it in the parsing-state
418
  *
419
  */
420
-#if YAJL_MAJOR >= 2
421
 static int workspaces_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
422
-#else
423
-static int workspaces_map_key_cb(void *params_, const unsigned char *keyVal, unsigned int keyLen) {
424
-#endif
425
     struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
426
     FREE(params->cur_key);
427
 
428
@@ -223,13 +211,7 @@ void parse_workspaces_json(char *json) {
429
 
430
     yajl_handle handle;
431
     yajl_status state;
432
-#if YAJL_MAJOR < 2
433
-    yajl_parser_config parse_conf = { 0, 0 };
434
-
435
-    handle = yajl_alloc(&workspaces_callbacks, &parse_conf, NULL, (void*) &params);
436
-#else
437
     handle = yajl_alloc(&workspaces_callbacks, NULL, (void*) &params);
438
-#endif
439
 
440
     state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
441
 
442
@@ -238,9 +220,6 @@ void parse_workspaces_json(char *json) {
443
         case yajl_status_ok:
444
             break;
445
         case yajl_status_client_canceled:
446
-#if YAJL_MAJOR < 2
447
-        case yajl_status_insufficient_data:
448
-#endif
449
         case yajl_status_error:
450
             ELOG("Could not parse workspaces-reply!\n");
451
             exit(EXIT_FAILURE);

b/include/yajl_utils.h

456
@@ -17,12 +17,6 @@
457
 #define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)
458
 #define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str))
459
 
460
-#if YAJL_MAJOR >= 2
461
 #define ygenalloc() yajl_gen_alloc(NULL)
462
 #define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, client)
463
 typedef size_t ylength;
464
-#else
465
-#define ygenalloc() yajl_gen_alloc(NULL, NULL);
466
-#define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, NULL, client)
467
-typedef unsigned int ylength;
468
-#endif

b/src/commands_parser.c

473
@@ -209,12 +209,8 @@ struct CommandResult *parse_command(const char *input) {
474
     DLOG("COMMAND: *%s*\n", input);
475
     state = INITIAL;
476
 
477
-/* A YAJL JSON generator used for formatting replies. */
478
-#if YAJL_MAJOR >= 2
479
+    /* A YAJL JSON generator used for formatting replies. */
480
     command_output.json_gen = yajl_gen_alloc(NULL);
481
-#else
482
-    command_output.json_gen = yajl_gen_alloc(NULL, NULL);
483
-#endif
484
 
485
     y(array_open);
486
     command_output.needs_tree_render = false;

b/src/config_parser.c

491
@@ -323,12 +323,8 @@ struct ConfigResult *parse_config(const char *input, struct context *context) {
492
     state = INITIAL;
493
     statelist_idx = 1;
494
 
495
-/* A YAJL JSON generator used for formatting replies. */
496
-#if YAJL_MAJOR >= 2
497
+    /* A YAJL JSON generator used for formatting replies. */
498
     command_output.json_gen = yajl_gen_alloc(NULL);
499
-#else
500
-    command_output.json_gen = yajl_gen_alloc(NULL, NULL);
501
-#endif
502
 
503
     y(array_open);
504
 

b/src/display_version.c

509
@@ -21,21 +21,13 @@
510
 static bool human_readable_key;
511
 static char *human_readable_version;
512
 
513
-#if YAJL_MAJOR >= 2
514
 static int version_string(void *ctx, const unsigned char *val, size_t len) {
515
-#else
516
-static int version_string(void *ctx, const unsigned char *val, unsigned int len) {
517
-#endif
518
     if (human_readable_key)
519
         sasprintf(&human_readable_version, "%.*s", (int)len, val);
520
     return 1;
521
 }
522
 
523
-#if YAJL_MAJOR >= 2
524
 static int version_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
525
-#else
526
-static int version_map_key(void *ctx, const unsigned char *stringval, unsigned int stringlen) {
527
-#endif
528
     human_readable_key = (stringlen == strlen("human_readable") &&
529
                    strncmp((const char*)stringval, "human_readable", strlen("human_readable")) == 0);
530
     return 1;
531
@@ -104,13 +96,7 @@ void display_running_version(void) {
532
     if (reply_type != I3_IPC_MESSAGE_TYPE_GET_VERSION)
533
         errx(EXIT_FAILURE, "Got reply type %d, but expected %d (GET_VERSION)", reply_type, I3_IPC_MESSAGE_TYPE_GET_VERSION);
534
 
535
-#if YAJL_MAJOR >= 2
536
     yajl_handle handle = yajl_alloc(&version_callbacks, NULL, NULL);
537
-#else
538
-    yajl_parser_config parse_conf = { 0, 0 };
539
-
540
-    yajl_handle handle = yajl_alloc(&version_callbacks, &parse_conf, NULL, NULL);
541
-#endif
542
 
543
     yajl_status state = yajl_parse(handle, (const unsigned char*)reply, (int)reply_length);
544
     if (state != yajl_status_ok)

b/src/key_press.c

549
@@ -30,11 +30,7 @@ static int json_boolean(void *ctx, int boolval) {
550
     return 1;
551
 }
552
 
553
-#if YAJL_MAJOR >= 2
554
 static int json_map_key(void *ctx, const unsigned char *stringval, size_t stringlen) {
555
-#else
556
-static int json_map_key(void *ctx, const unsigned char *stringval, unsigned int stringlen) {
557
-#endif
558
     parse_error_key = (stringlen >= strlen("parse_error") &&
559
                        strncmp((const char*)stringval, "parse_error", strlen("parse_error")) == 0);
560
     return 1;
561
@@ -86,15 +82,8 @@ void handle_key_press(xcb_key_press_event_t *event) {
562
     /* We parse the JSON reply to figure out whether there was an error
563
      * ("success" being false in on of the returned dictionaries). */
564
     const unsigned char *reply;
565
-#if YAJL_MAJOR >= 2
566
     size_t length;
567
     yajl_handle handle = yajl_alloc(&command_error_callbacks, NULL, NULL);
568
-#else
569
-    unsigned int length;
570
-    yajl_parser_config parse_conf = { 0, 0 };
571
-
572
-    yajl_handle handle = yajl_alloc(&command_error_callbacks, &parse_conf, NULL, NULL);
573
-#endif
574
     yajl_gen_get_buf(command_output->json_gen, &reply, &length);
575
 
576
     current_nesting_level = 0;

b/src/load_layout.c

581
@@ -133,11 +133,7 @@ static int json_end_array(void *ctx) {
582
     return 1;
583
 }
584
 
585
-#if YAJL_MAJOR < 2
586
-static int json_key(void *ctx, const unsigned char *val, unsigned int len) {
587
-#else
588
 static int json_key(void *ctx, const unsigned char *val, size_t len) {
589
-#endif
590
     LOG("key: %.*s\n", (int)len, val);
591
     FREE(last_key);
592
     last_key = scalloc((len+1) * sizeof(char));
593
@@ -160,11 +156,7 @@ static int json_key(void *ctx, const unsigned char *val, size_t len) {
594
     return 1;
595
 }
596
 
597
-#if YAJL_MAJOR >= 2
598
 static int json_string(void *ctx, const unsigned char *val, size_t len) {
599
-#else
600
-static int json_string(void *ctx, const unsigned char *val, unsigned int len) {
601
-#endif
602
     LOG("string: %.*s for key %s\n", (int)len, val, last_key);
603
     if (parsing_swallows) {
604
         char *sval;
605
@@ -307,13 +299,8 @@ static int json_string(void *ctx, const unsigned char *val, unsigned int len) {
606
     return 1;
607
 }
608
 
609
-#if YAJL_MAJOR >= 2
610
 static int json_int(void *ctx, long long val) {
611
     LOG("int %lld for key %s\n", val, last_key);
612
-#else
613
-static int json_int(void *ctx, long val) {
614
-    LOG("int %ld for key %s\n", val, last_key);
615
-#endif
616
     /* For backwards compatibility with i3 < 4.8 */
617
     if (strcasecmp(last_key, "type") == 0)
618
         json_node->type = val;
619
@@ -427,13 +414,8 @@ void tree_append_json(Con *con, const char *filename, char **errormsg) {
620
         .yajl_end_map = json_end_map,
621
         .yajl_end_array = json_end_array,
622
     };
623
-#if YAJL_MAJOR >= 2
624
     g = yajl_gen_alloc(NULL);
625
     hand = yajl_alloc(&callbacks, NULL, (void*)g);
626
-#else
627
-    g = yajl_gen_alloc(NULL, NULL);
628
-    hand = yajl_alloc(&callbacks, NULL, NULL, (void*)g);
629
-#endif
630
     /* Allowing comments allows for more user-friendly layout files. */
631
     yajl_config(hand, yajl_allow_comments, true);
632
     /* Allow multiple values, i.e. multiple nodes to attach */
633
@@ -463,11 +445,7 @@ void tree_append_json(Con *con, const char *filename, char **errormsg) {
634
     con_fix_percent(con);
635
 
636
     setlocale(LC_NUMERIC, "");
637
-#if YAJL_MAJOR >= 2
638
     yajl_complete_parse(hand);
639
-#else
640
-    yajl_parse_complete(hand);
641
-#endif
642
 
643
     fclose(f);
644
     if (to_focus)

b/src/util.c

649
@@ -188,22 +188,14 @@ static char **append_argument(char **original, char *argument) {
650
 
651
 char *store_restart_layout(void) {
652
     setlocale(LC_NUMERIC, "C");
653
-#if YAJL_MAJOR >= 2
654
     yajl_gen gen = yajl_gen_alloc(NULL);
655
-#else
656
-    yajl_gen gen = yajl_gen_alloc(NULL, NULL);
657
-#endif
658
 
659
     dump_node(gen, croot, true);
660
 
661
     setlocale(LC_NUMERIC, "");
662
 
663
     const unsigned char *payload;
664
-#if YAJL_MAJOR >= 2
665
     size_t length;
666
-#else
667
-    unsigned int length;
668
-#endif
669
     y(get_buf, &payload, &length);
670
 
671
     /* create a temporary file if one hasn't been specified, or just
672
@@ -241,11 +233,7 @@ char *store_restart_layout(void) {
673
             return NULL;
674
         }
675
         written += n;
676
-#if YAJL_MAJOR >= 2
677
         DLOG("written: %zd of %zd\n", written, length);
678
-#else
679
-        DLOG("written: %d of %d\n", written, length);
680
-#endif
681
     }
682
     close(fd);
683
 

/dev/null

689
@@ -1,7 +0,0 @@
690
-#ifndef YAJL_VERSION_H_
691
-#define YAJL_VERSION_H_
692
-/* Fallback for libyajl 1 which does not provide yajl_version.h */
693
-#define YAJL_MAJOR 1
694
-#define YAJL_MINOR 0
695
-#define YAJL_MICRO 0
696
-#endif