[Asterisk-cvs] asterisk utils.c,1.43,1.44
kpfleming at lists.digium.com
kpfleming at lists.digium.com
Sun May 15 18:27:38 CDT 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv18787
Modified Files:
utils.c
Log Message:
add ast_build_string library function (from bug #3644)
Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- utils.c 9 May 2005 13:50:38 -0000 1.43
+++ utils.c 15 May 2005 22:33:01 -0000 1.44
@@ -17,6 +17,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
+#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -433,6 +434,28 @@
*dst = '\0';
}
+int ast_build_string(char **buffer, size_t *space, const char *fmt, ...)
+{
+ va_list ap;
+ int result;
+
+ if (!buffer || !*buffer || !space || !*space)
+ return -1;
+
+ va_start(ap, fmt);
+ result = vsnprintf(*buffer, *space, fmt, ap);
+ va_end(ap);
+
+ if (result < 0)
+ return -1;
+ else if (result > *space)
+ result = *space;
+
+ *buffer += result;
+ *space -= result;
+ return 0;
+}
+
/* Case-insensitive substring matching */
#ifndef LINUX
static char *upper(const char *orig, char *buf, int bufsize)
More information about the svn-commits
mailing list