Add strlcat and strlcpy functions if build env is glibc or eglibc because they do not have those functions. Patch originates from: https://dev.openwrt.org/ticket/9012
Tested-by: Mika Laitio <lam...@pilppa.org> --- package/hotplug2/src/udevtrigger.c | 45 ++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) diff --git a/package/hotplug2/src/udevtrigger.c b/package/hotplug2/src/udevtrigger.c index 297e64c..1f9ea69 100644 --- a/package/hotplug2/src/udevtrigger.c +++ b/package/hotplug2/src/udevtrigger.c @@ -36,6 +36,51 @@ static int verbose; static int dry_run; +#ifdef __GLIBC__ +size_t strlcpy(char *dst, const char *src, size_t size) +{ + size_t bytes = 0; + char *q = dst; + const char *p = src; + char ch; + + while ((ch = *p++)) { + if (bytes+1 < size) + *q++ = ch; + bytes++; + } + + /* If size == 0 there is no space for a final null... */ + if (size) + *q = '\0'; + return bytes; +} + +size_t strlcat(char *dst, const char *src, size_t size) +{ + size_t bytes = 0; + char *q = dst; + const char *p = src; + char ch; + + while (bytes < size && *q) { + q++; + bytes++; + } + if (bytes == size) + return (bytes + strlen(src)); + + while ((ch = *p++)) { + if (bytes+1 < size) + *q++ = ch; + bytes++; + } + + *q = '\0'; + return bytes; +} +#endif /* __GLIBC__ */ + void log_message(int priority, const char *format, ...) { va_list args; -- 1.7.1 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel