]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/workspaces.c
i3bar: add modelines to all files
[i3/i3] / i3bar / src / workspaces.c
index 89f7757da1ae990a4b863ba1b3e4a9588d6928fb..8099cd7843f430b430bbd2d59723ead6cc32e00f 100644 (file)
@@ -1,7 +1,9 @@
 /*
+ * vim:ts=4:sw=4:expandtab
+ *
  * i3bar - an xcb-based status- and ws-bar for i3
  *
- * © 2010 Axel Wagner and contributors
+ * © 2010-2011 Axel Wagner and contributors
  *
  * See file LICNSE for license information
  *
@@ -13,6 +15,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <yajl/yajl_parse.h>
+#include <yajl/yajl_version.h>
 
 #include "common.h"
 
@@ -25,10 +28,10 @@ struct workspaces_json_params {
 };
 
 /*
- * Parse a booleant-value (visible, focused, urgent)
+ * Parse a boolean value (visible, focused, urgent)
  *
  */
-static int workspaces_boolean_cb(void *params_, bool val) {
+static int workspaces_boolean_cb(void *params_, int val) {
     struct workspaces_json_params *params = (struct workspaces_json_params*) params_;
 
     if (!strcmp(params->cur_key, "visible")) {
@@ -58,7 +61,11 @@ static int workspaces_boolean_cb(void *params_, bool val) {
  * 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")) {
@@ -99,8 +106,11 @@ static int workspaces_integer_cb(void *params_, long val) {
  * 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;
@@ -111,7 +121,7 @@ static int workspaces_string_cb(void *params_, const unsigned char *val, unsigne
             strncpy(params->workspaces_walk->name, (const char*) val, len);
             params->workspaces_walk->name[len] = '\0';
 
-            /* Convert the name to ucs2, save it's length in glyphs and calculate it'srendered width */
+            /* Convert the name to ucs2, save its length in glyphs and calculate its rendered width */
             int ucs2_len;
             xcb_char2b_t *ucs2_name = (xcb_char2b_t*) convert_utf8_to_ucs2(params->workspaces_walk->name, &ucs2_len);
             params->workspaces_walk->ucs2_name = ucs2_name;
@@ -179,7 +189,11 @@ static int workspaces_start_map_cb(void *params_) {
  * 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);
 
@@ -225,10 +239,14 @@ void parse_workspaces_json(char *json) {
     params.json = json;
 
     yajl_handle handle;
-    yajl_parser_config parse_conf = { 0, 0 };
     yajl_status state;
+#if YAJL_MAJOR < 2
+    yajl_parser_config parse_conf = { 0, 0 };
 
     handle = yajl_alloc(&workspaces_callbacks, &parse_conf, NULL, (void*) &params);
+#else
+    handle = yajl_alloc(&workspaces_callbacks, NULL, (void*) &params);
+#endif
 
     state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
 
@@ -237,7 +255,9 @@ void parse_workspaces_json(char *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);