[Asterisk-cvs] asterisk channel.c, 1.219, 1.220 cli.c, 1.90,
1.91 pbx.c, 1.260, 1.261 utils.c, 1.56, 1.57
kpfleming at lists.digium.com
kpfleming at lists.digium.com
Fri Jul 15 17:58:27 CDT 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv12870
Modified Files:
channel.c cli.c pbx.c utils.c
Log Message:
phase two of string portability stuff:
don't need ast_ prefixes on functions
use individual #defines for function presence
add vasprintf to portability library
Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -d -r1.219 -r1.220
--- channel.c 15 Jul 2005 00:39:01 -0000 1.219
+++ channel.c 15 Jul 2005 22:06:15 -0000 1.220
@@ -1753,8 +1753,8 @@
break; /* no frame */
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 = ast_strndup((char *) f->data, f->datalen); /* dup and break */
+ else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
+ buf = strndup((char *) f->data, f->datalen); /* dup and break */
done = 1;
}
ast_frfree(f);
Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- cli.c 10 Jul 2005 22:56:21 -0000 1.90
+++ cli.c 15 Jul 2005 22:06:15 -0000 1.91
@@ -47,15 +47,10 @@
{
char *stuff;
int res = 0;
-
va_list ap;
+
va_start(ap, fmt);
-#ifdef SOLARIS
- stuff = (char *)malloc(10240);
- vsnprintf(stuff, 10240, fmt, ap);
-#else
res = vasprintf(&stuff, fmt, ap);
-#endif
va_end(ap);
if (res == -1) {
ast_log(LOG_ERROR, "Out of memory\n");
Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.260
retrieving revision 1.261
diff -u -d -r1.260 -r1.261
--- pbx.c 15 Jul 2005 16:02:37 -0000 1.260
+++ pbx.c 15 Jul 2005 22:06:15 -0000 1.261
@@ -3104,7 +3104,7 @@
int printapp=0;
total_apps++;
if (like) {
- if (ast_strcasestr(a->name, argv[3])) {
+ if (strcasestr(a->name, argv[3])) {
printapp = 1;
total_match++;
}
@@ -3114,7 +3114,7 @@
int i;
printapp = 1;
for (i=3;i<argc;i++) {
- if (! ast_strcasestr(a->description, argv[i])) {
+ if (!strcasestr(a->description, argv[i])) {
printapp = 0;
} else {
total_match++;
Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- utils.c 15 Jul 2005 15:37:58 -0000 1.56
+++ utils.c 15 Jul 2005 22:06:15 -0000 1.57
@@ -20,6 +20,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <stdarg.h>
#include "asterisk.h"
@@ -492,22 +493,22 @@
return 0;
}
-/* Case-insensitive substring matching */
-#ifndef __linux__
+#ifndef HAVE_STRCASESTR
static char *upper(const char *orig, char *buf, int bufsize)
{
- int i;
- memset(buf, 0, bufsize);
- for (i=0; i<bufsize - 1; i++) {
+ int i = 0;
+
+ while (i < (bufsize - 1) && orig[i]) {
buf[i] = toupper(orig[i]);
- if (orig[i] == '\0') {
- break;
- }
+ i++;
}
+
+ buf[i] = '\0';
+
return buf;
}
-char *ast_strcasestr(const char *haystack, const char *needle)
+char *strcasestr(const char *haystack, const char *needle)
{
char *u1, *u2;
int u1len = strlen(haystack) + 1, u2len = strlen(needle) + 1;
@@ -532,8 +533,10 @@
return NULL;
}
}
+#endif
-size_t ast_strnlen(const char *s, size_t n)
+#ifndef HAVE_STRNLEN
+size_t strnlen(const char *s, size_t n)
{
size_t len;
@@ -543,10 +546,12 @@
return len;
}
+#endif
-char *ast_strndup(const char *s, size_t n)
+#ifndef HAVE_STRNDUP
+char *strndup(const char *s, size_t n)
{
- size_t len = ast_strnlen(s, n);
+ size_t len = strnlen(s, n);
char *new = malloc(len + 1);
if (!new)
@@ -555,5 +560,25 @@
new[len] = '\0';
return memcpy(new, s, len);
}
+#endif
-#endif /* !__linux__ */
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **strp, const char *fmt, va_list ap)
+{
+ int size;
+ va_list ap2;
+
+ *strp = NULL;
+ va_copy(ap2, ap);
+ size = vsnprintf(*strp, 0, fmt, ap2);
+ va_end(ap2);
+ *strp = malloc(size + 1);
+ if (!*strp)
+ return -1;
+ va_start(fmt, ap);
+ vsnprintf(*strp, size + 1, fmt, ap);
+ va_end(ap);
+
+ return size;
+}
+#endif
More information about the svn-commits
mailing list