]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/include/parse_json_header.h
Update copyright notices and get rid of ranges
[i3/i3] / i3bar / include / parse_json_header.h
index 52c6f5d257c7afd88c3dce5fa0189944af7b6a75..41e97de2f994ef24a754148e9f676c12446efd60 100644 (file)
@@ -2,28 +2,22 @@
  * vim:ts=4:sw=4:expandtab
  *
  * i3bar - an xcb-based status- and ws-bar for i3
- * © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
+ * © 2010 Axel Wagner and contributors (see also: LICENSE)
  *
- * determine_json_version.c: Determines the JSON protocol version based on the
- *                           first line of input from a child program.
+ * parse_json_header.c: Parse the JSON protocol header to determine
+ *                      protocol version and features.
  *
  */
-#ifndef DETERMINE_JSON_VERSION_H_
-#define DETERMINE_JSON_VERSION_H_
+#pragma once
 
 #include <stdint.h>
 
-/*
- * Determines the JSON i3bar protocol version from the given buffer. In case
- * the buffer does not contain valid JSON, or no version field is found, this
- * function returns -1. The amount of bytes consumed by parsing the header is
- * returned in *consumed (if non-NULL).
- *
- * The return type is an int32_t to avoid machines with different sizes of
- * 'int' to allow different values here. It’s highly unlikely we ever exceed
- * even an int8_t, but still…
+/**
+ * Parse the JSON protocol header to determine protocol version and features.
+ * In case the buffer does not contain a valid header (invalid JSON, or no
+ * version field found), the 'correct' field of the returned header is set to
+ * false. The amount of bytes consumed by parsing the header is returned in
+ * *consumed (if non-NULL).
  *
  */
-int32_t determine_json_version(const unsigned char *buffer, int length, unsigned int *consumed);
-
-#endif
+void parse_json_header(i3bar_child *child, const unsigned char *buffer, int length, unsigned int *consumed);