diff options
| author | Mistivia <i@mistivia.com> | 2025-11-02 15:29:28 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-11-02 15:29:28 +0800 |
| commit | 9f42c2d5f911cb4e215d7873221e642ce7df4d61 (patch) | |
| tree | 6dac90a889a7402a9556d3d1bcc5cb53cdb9f123 /deprecated-ngircd/src/portab/strndup.c | |
| parent | fb2d9de539b660a261af19b1cbcceb7ee7980cb1 (diff) | |
deprecate webircdateway and ngircd
Diffstat (limited to 'deprecated-ngircd/src/portab/strndup.c')
| -rw-r--r-- | deprecated-ngircd/src/portab/strndup.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/deprecated-ngircd/src/portab/strndup.c b/deprecated-ngircd/src/portab/strndup.c new file mode 100644 index 0000000..d63b972 --- /dev/null +++ b/deprecated-ngircd/src/portab/strndup.c @@ -0,0 +1,34 @@ +/* + * ngIRCd -- The Next Generation IRC Daemon + */ + +#include "portab.h" + +/** + * @file + * strndup() implementation. Public domain. + */ + +#ifndef HAVE_STRNDUP + +#include <string.h> +#include <stdlib.h> +#include <sys/types.h> + +GLOBAL char * +strndup(const char *s, size_t maxlen) +{ + char *dup; + size_t len = strlen(s); + + if (len > maxlen) + len = maxlen; + len++; + dup = malloc(len); + if (dup) + strlcpy(dup, s, len); + + return dup; +} + +#endif |
