X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Futil.c;h=85f359c0fa801b45e20a9ee9515253cd0316d934;hb=1847938d4eeba98260cc79ca45a11a134274c2ea;hp=ba0969c729674aabe3dd04a0ce9614803514f4f7;hpb=b5583d6cf4e0426d9aedd589f18e03407793199b;p=i3%2Fi3 diff --git a/src/util.c b/src/util.c index ba0969c7..85f359c0 100644 --- a/src/util.c +++ b/src/util.c @@ -217,7 +217,7 @@ static char **add_argument(char **original, char *opt_char, char *opt_arg, char #define y(x, ...) yajl_gen_##x(gen, ##__VA_ARGS__) #define ystr(str) yajl_gen_string(gen, (unsigned char *)str, strlen(str)) -char *store_restart_layout(void) { +static char *store_restart_layout(void) { setlocale(LC_NUMERIC, "C"); yajl_gen gen = yajl_gen_alloc(NULL); @@ -500,10 +500,17 @@ ssize_t slurp(const char *path, char **buf) { size_t n = fread(*buf, 1, stbuf.st_size, f); fclose(f); if ((ssize_t)n != stbuf.st_size) { - ELOG("File \"%s\" could not be read entirely: got %zd, want %zd\n", path, n, stbuf.st_size); - free(*buf); - *buf = NULL; + ELOG("File \"%s\" could not be read entirely: got %zd, want %" PRIi64 "\n", path, n, (int64_t)stbuf.st_size); + FREE(*buf); return -1; } return (ssize_t)n; } + +/* + * Convert a direction to its corresponding orientation. + * + */ +orientation_t orientation_from_direction(direction_t direction) { + return (direction == D_LEFT || direction == D_RIGHT) ? HORIZ : VERT; +}