diff options
author | David Timber <mieabby@gmail.com> | 2020-08-29 17:09:10 +0930 |
---|---|---|
committer | David Timber <mieabby@gmail.com> | 2020-08-29 17:20:37 +0930 |
commit | f36333b2c915ac7d9cf82e09ab5cb2a2f8296177 (patch) | |
tree | 48e28c7750c99414bc1430ffefbd9fbaa26788e5 /src/util_rt.c | |
parent | acf0b7a45171555eba2c10a6ef84f915c62f6791 (diff) |
* _POSIX_C_SOURCE=199506L
* Add proone-htbthost
* Add prne_iobuf, use it in resolv, htbt
* memzero() -> prne_memzero() now as a function
* Add prne_mbedtls_pth_handle()
* Protocol changes
* Remove prne_unint_*()
* Add src/proone_conf.skel
Diffstat (limited to 'src/util_rt.c')
-rw-r--r-- | src/util_rt.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/util_rt.c b/src/util_rt.c index 8a1e61b..24e924d 100644 --- a/src/util_rt.c +++ b/src/util_rt.c @@ -29,6 +29,31 @@ void prne_shutdown (const int fd, const int how) { } } +bool prne_sck_fcntl (const int fd) { + fcntl(fd, F_SETFD, FD_CLOEXEC); + return fcntl(fd, F_SETFL, O_NONBLOCK) == 0; +} + +int prne_chfd (const int old, const int ny) { + int ret; + + if (old == ny) { + return old; + } + + ret = dup2(old, ny); + if (ret < 0) { + return ret; + } + close(old); + + return ret; +} + +void prne_memzero(void *addr, const size_t len) { + memset(addr, 0, len); +} + void *prne_malloc (const size_t se, const size_t cnt) { size_t size; @@ -164,6 +189,12 @@ size_t prne_str_shift_spaces (char *str, const size_t len) { return ret; } +void prne_transstr (char *str, int(*trans_f)(int)) { + for (; *str != 0; str += 1) { + *str = (char)trans_f(*str); + } +} + bool prne_hex_fromstr (const char *str, uint_fast8_t *out) { static const uint_fast8_t shift[2] = { 4, 0 }; size_t i; |