sway/include/util.h
Markus Ongyerth acae6ad40f move wlr dependent input handler to sway
Moves input handling code that uses headers from wlroots from the common
code to sway proper, to allow for removing the wlroots dependency from
clients
2018-05-24 21:52:35 +02:00

44 lines
1.1 KiB
C

#ifndef _SWAY_UTIL_H
#define _SWAY_UTIL_H
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <xkbcommon/xkbcommon.h>
/**
* Wrap i into the range [0, max[
*/
int wrap(int i, int max);
/**
* Count number of digits in int
*/
int numlen(int n);
/**
* Get the pid of a parent process given the pid of a child process.
*
* Returns the parent pid or NULL if the parent pid cannot be determined.
*/
pid_t get_parent_pid(pid_t pid);
/**
* Given a string that represents an RGB(A) color, return a uint32_t
* version of the color.
*/
uint32_t parse_color(const char *color);
/**
* Given a path string, recurseively resolves any symlinks to their targets
* (which may be a file, directory) and returns the result.
* argument is returned. Caller must free the returned buffer.
* If an error occures, if the path does not exist or if the path corresponds
* to a dangling symlink, NULL is returned.
*/
char* resolve_path(const char* path);
char *b64_encode(const char* binaryData, size_t len, size_t *flen);
unsigned char *b64_decode(const char *ascii, size_t len, size_t *flen);
#endif