Index: Makefile =================================================================== RCS file: /usr/cvsroot/asterisk/Makefile,v retrieving revision 1.178 diff -u -r1.178 Makefile --- Makefile 12 Jul 2005 03:23:30 -0000 1.178 +++ Makefile 14 Jul 2005 15:38:56 -0000 @@ -240,7 +240,7 @@ CFLAGS+=-D__Darwin__ endif ifeq (${OSARCH},FreeBSD) -LIBS+=-lcrypto -lstrfunc +LIBS+=-lcrypto endif ifeq (${OSARCH},NetBSD) LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/local/lib -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib -lncurses Index: channel.c =================================================================== RCS file: /usr/cvsroot/asterisk/channel.c,v retrieving revision 1.218 diff -u -r1.218 channel.c --- channel.c 12 Jul 2005 16:00:23 -0000 1.218 +++ channel.c 14 Jul 2005 15:38:56 -0000 @@ -31,12 +31,6 @@ #error "You need newer zaptel! Please cvs update zaptel" #endif #endif -#ifdef __FreeBSD__ -#include -#if (!defined(__STRFUNC_H__) && (!defined(STRFUNC_H))) -#error "Please install the strfunc library located in the ports collection at /usr/ports/devel/libstrfunc" -#endif -#endif #include "asterisk.h" @@ -59,6 +53,7 @@ #include "asterisk/indications.h" #include "asterisk/monitor.h" #include "asterisk/causes.h" +#include "asterisk/strings.h" #include "asterisk/utils.h" #include "asterisk/lock.h" #include "asterisk/app.h" @@ -1760,7 +1755,7 @@ if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) done = 1; /* force a break */ else if (f->frametype == AST_FRAME_TEXT) { /* what we want */ - buf = strndup((char *)f->data, f->datalen); /* dup and break */ + buf = ast_strndup((char *)f->data, f->datalen); /* dup and break */ done = 1; } ast_frfree(f); Index: utils.c =================================================================== RCS file: /usr/cvsroot/asterisk/utils.c,v retrieving revision 1.53 diff -u -r1.53 utils.c --- utils.c 24 Jun 2005 22:45:15 -0000 1.53 +++ utils.c 14 Jul 2005 15:38:56 -0000 @@ -535,4 +535,26 @@ return NULL; } } + +size_t ast_strnlen(const char *s, size_t n) +{ + size_t len; + for (len=0;len < n;len++) + if (s[len] == '\0') + break; + return len; +} + +char *ast_strndup(const char *s, size_t n) +{ + size_t len = ast_strnlen(s, n); + char *new = (char *) malloc(len + 1); + + if (new == NULL) + return NULL; + + new[len] = '\0'; + return (char *) memcpy(new, s, len); +} + #endif /* LINUX */ Index: include/asterisk/strings.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/strings.h,v retrieving revision 1.3 diff -u -r1.3 strings.h --- include/asterisk/strings.h 12 Jul 2005 15:26:24 -0000 1.3 +++ include/asterisk/strings.h 14 Jul 2005 15:38:57 -0000 @@ -199,8 +199,12 @@ #ifdef __linux__ #define ast_strcasestr strcasestr +#define ast_strndup strndup +#define ast_strnlen strnlen #else extern char *ast_strcasestr(const char *, const char *); +extern char *ast_strndup(const char *, size_t); +extern size_t ast_strnlen(const char *, size_t); #endif /* __linux__ */ #endif /* _ASTERISK_STRINGS_H */