diff options
| author | Drew DeVault <sir@cmpwn.com> | 2019-01-13 21:15:32 -0500 |
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2019-01-13 21:16:47 -0500 |
| commit | b90637e2a6e854d586b977ed9b80b806edeb12dd (patch) | |
| tree | fa4d90324daf36d01850d7e8e90dce4b45602c40 /main.c | |
| parent | 43435cd7317e24bd57a9d154f18c7fd9f334418e (diff) | |
Convert swaylock into standalone project
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 44 |
1 files changed, 39 insertions, 5 deletions
@@ -16,15 +16,12 @@ #include <wayland-client.h> #include <wordexp.h> #include <wlr/util/log.h> -#include "swaylock/seat.h" -#include "swaylock/swaylock.h" #include "background-image.h" +#include "seat.h" +#include "swaylock.h" #include "pool-buffer.h" #include "cairo.h" -#include "log.h" #include "loop.h" -#include "stringop.h" -#include "util.h" #include "wlr-input-inhibitor-unstable-v1-client-protocol.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" #include "xdg-output-unstable-v1-client-protocol.h" @@ -33,6 +30,43 @@ void sway_terminate(int exit_code) { exit(exit_code); } +void sway_abort(const char *format, ...) { + va_list args; + va_start(args, format); + _wlr_vlog(WLR_ERROR, format, args); + va_end(args); + sway_terminate(EXIT_FAILURE); +} + +static uint32_t parse_color(const char *color) { + if (color[0] == '#') { + ++color; + } + + int len = strlen(color); + if (len != 6 && len != 8) { + wlr_log(WLR_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); + return 0xFFFFFFFF; + } + uint32_t res = (uint32_t)strtoul(color, NULL, 16); + if (strlen(color) == 6) { + res = (res << 8) | 0xFF; + } + return res; +} + +int lenient_strcmp(char *a, char *b) { + if (a == b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } else { + return strcmp(a, b); + } +} + static void daemonize(void) { int fds[2]; if (pipe(fds) != 0) { |
