diff options
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 4c4484e8..512144a4 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -306,39 +306,16 @@ json_object *ipc_json_describe_input(struct libinput_device *device) { | |||
306 | } | 306 | } |
307 | 307 | ||
308 | json_object *ipc_json_get_version() { | 308 | json_object *ipc_json_get_version() { |
309 | int major = 0, minor = 0, patch = 0; | ||
309 | json_object *version = json_object_new_object(); | 310 | json_object *version = json_object_new_object(); |
310 | 311 | ||
311 | #if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE | 312 | sscanf(SWAY_VERSION, "%u.%u.%u", &major, &minor, &patch); |
312 | char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1); | 313 | |
313 | if (!full_version) { | 314 | json_object_object_add(version, "human_readable", json_object_new_string(SWAY_VERSION)); |
314 | json_object_object_add(version, "human_readable", | ||
315 | json_object_new_string("Allocating version string failed")); | ||
316 | // TODO: it's stupid that we allocate this in the first place | ||
317 | json_object_object_add(version, "major", json_object_new_int(0)); | ||
318 | json_object_object_add(version, "minor", json_object_new_int(0)); | ||
319 | json_object_object_add(version, "patch", json_object_new_int(0)); | ||
320 | return version; | ||
321 | } | ||
322 | strcat(full_version, SWAY_GIT_VERSION); | ||
323 | strcat(full_version, " ("); | ||
324 | strcat(full_version, SWAY_VERSION_DATE); | ||
325 | strcat(full_version, ", branch \""); | ||
326 | strcat(full_version, SWAY_GIT_BRANCH); | ||
327 | strcat(full_version, "\")"); | ||
328 | |||
329 | json_object_object_add(version, "human_readable", json_object_new_string(full_version)); | ||
330 | json_object_object_add(version, "variant", json_object_new_string("sway")); | 315 | json_object_object_add(version, "variant", json_object_new_string("sway")); |
331 | // Todo once we actually release a version | 316 | json_object_object_add(version, "major", json_object_new_int(major)); |
332 | json_object_object_add(version, "major", json_object_new_int(0)); | 317 | json_object_object_add(version, "minor", json_object_new_int(minor)); |
333 | json_object_object_add(version, "minor", json_object_new_int(0)); | 318 | json_object_object_add(version, "patch", json_object_new_int(patch)); |
334 | json_object_object_add(version, "patch", json_object_new_int(1)); | ||
335 | free(full_version); | ||
336 | #else | ||
337 | json_object_object_add(version, "human_readable", json_object_new_string("version not found")); | ||
338 | json_object_object_add(version, "major", json_object_new_int(0)); | ||
339 | json_object_object_add(version, "minor", json_object_new_int(0)); | ||
340 | json_object_object_add(version, "patch", json_object_new_int(0)); | ||
341 | #endif | ||
342 | 319 | ||
343 | return version; | 320 | return version; |
344 | } | 321 | } |