diff options
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c new file mode 100644 index 00000000..6fcb91fa --- /dev/null +++ b/sway/ipc-json.c | |||
@@ -0,0 +1,18 @@ | |||
1 | #include <json-c/json.h> | ||
2 | #include <stdio.h> | ||
3 | #include "sway/ipc-json.h" | ||
4 | |||
5 | json_object *ipc_json_get_version() { | ||
6 | int major = 0, minor = 0, patch = 0; | ||
7 | json_object *version = json_object_new_object(); | ||
8 | |||
9 | sscanf(SWAY_VERSION, "%u.%u.%u", &major, &minor, &patch); | ||
10 | |||
11 | json_object_object_add(version, "human_readable", json_object_new_string(SWAY_VERSION)); | ||
12 | json_object_object_add(version, "variant", json_object_new_string("sway")); | ||
13 | json_object_object_add(version, "major", json_object_new_int(major)); | ||
14 | json_object_object_add(version, "minor", json_object_new_int(minor)); | ||
15 | json_object_object_add(version, "patch", json_object_new_int(patch)); | ||
16 | |||
17 | return version; | ||
18 | } | ||