X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libbb%2Fxfuncs.c;h=a86efc2981d49cd80c5fa5016bbd63b4b033f38c;hb=781b672b372ade5c1903adbdc4de8dcb16a29a37;hp=e2aee136c8631d731fdd298297e973e23ff076db;hpb=202ac504e1addf0aa2debd53e7cd2411cc73ac8c;p=oweals%2Fbusybox.git diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index e2aee136c..a86efc298 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -40,6 +40,14 @@ int FAST_FUNC close_on_exec_on(int fd) return fcntl(fd, F_SETFD, FD_CLOEXEC); } +char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) +{ +#ifndef IFNAMSIZ + enum { IFNAMSIZ = 16 }; +#endif + return strncpy(dst, src, IFNAMSIZ); +} + /* Convert unsigned long long value into compact 4-char * representation. Examples: "1234", "1.2k", " 27M", "123T" * String is not terminated (buf[4] is untouched) */ @@ -260,6 +268,17 @@ off_t FAST_FUNC fdlength(int fd) } #endif +char* FAST_FUNC xmalloc_ttyname(int fd) +{ + char *buf = xzalloc(128); + int r = ttyname_r(fd, buf, 127); + if (r) { + free(buf); + buf = NULL; + } + return buf; +} + /* It is perfectly ok to pass in a NULL for either width or for * height, in which case that value will not be set. */ int FAST_FUNC get_terminal_width_height(int fd, unsigned *width, unsigned *height)