]> git.sur5r.net Git - i3/i3/blobdiff - src/display_version.c
Merge pull request #1657 from Georgiy-Tugai/fix-flickering-shortened
[i3/i3] / src / display_version.c
index da667ffa30d5a1ebf60e1caf942e28c85d0cce4e..6ece3f742dde32f9916b66a061661fee0e86b6d5 100644 (file)
@@ -4,7 +4,7 @@
  * vim:ts=4:sw=4:expandtab
  *
  * i3 - an improved dynamic tiling window manager
- * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  * display_version.c: displays the running i3 version, runs as part of
  *                    i3 --moreversion.
 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);
+                          strncmp((const char *)stringval, "human_readable", strlen("human_readable")) == 0);
     return 1;
 }
 
@@ -84,11 +76,11 @@ void display_running_version(void) {
     memset(&addr, 0, sizeof(struct sockaddr_un));
     addr.sun_family = AF_LOCAL;
     strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
-    if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0)
+    if (connect(sockfd, (const struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0)
         err(EXIT_FAILURE, "Could not connect to i3");
 
     if (ipc_send_message(sockfd, 0, I3_IPC_MESSAGE_TYPE_GET_VERSION,
-                         (uint8_t*)"") == -1)
+                         (uint8_t *)"") == -1)
         err(EXIT_FAILURE, "IPC: write()");
 
     uint32_t reply_length;
@@ -104,15 +96,9 @@ void display_running_version(void) {
     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);
+    yajl_status state = yajl_parse(handle, (const unsigned char *)reply, (int)reply_length);
     if (state != yajl_status_ok)
         errx(EXIT_FAILURE, "Could not parse my own reply. That's weird. reply is %.*s", (int)reply_length, reply);
 
@@ -127,8 +113,8 @@ void display_running_version(void) {
     sasprintf(&exepath, "/proc/%d/exe", getpid());
 
     while ((linksize = readlink(exepath, destpath, destpath_size)) == (ssize_t)destpath_size) {
-            destpath_size = destpath_size * 2;
-            destpath = srealloc(destpath, destpath_size);
+        destpath_size = destpath_size * 2;
+        destpath = srealloc(destpath, destpath_size);
     }
     if (linksize == -1)
         err(EXIT_FAILURE, "readlink(%s)", exepath);