/* * This file is part of fwm-sysdaemon * util.h * * Copyright (c) 2019, 2022 firk (firk@cantconnect.ru) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The origin of this software must not be misrepresented; you must * not claim that you wrote the original software. * 4. Altered versions in any form must be plainly marked as such, and * must not be misinterpreted as being the original software. * * This software is provided by the author and contributors `as is' * without any express or implied warranty. */ #ifndef INCLUDED_UTIL_H #define INCLUDED_UTIL_H typedef unsigned int uint; typedef unsigned long long ull; extern char const * parse_uint(char const *st, uint * res); extern char const * parse_ull(char const *st, ull * res); extern int txtfile_read(int dirfd, char const * name, char * dest, size_t max, size_t * n); extern char const * make_timestr(void); extern unsigned long get_ms(void); extern int write_all(int fd, unsigned char const * buf, size_t n); extern int fd_set_str(int fd, char const *st); extern int fd_set_vstr(int fd, char const *fmt, ...); /* _S for sysfs, _U for userspace files */ extern int fd_get_int_S(int fd); extern int fd_set_int_S(int fd, int v); extern int fd_get_int_U(int fd); extern int fd_set_int_U(int fd, int v); #endif