[xiph-commits] r7917 - icecast/trunk/net
karl at motherfish-iii.xiph.org
karl at motherfish-iii.xiph.org
Wed Oct 6 07:07:56 PDT 2004
Author: karl
Date: 2004-10-06 07:07:55 -0700 (Wed, 06 Oct 2004)
New Revision: 7917
Modified:
icecast/trunk/net/sock.c
Log:
merged from kh branch, allow for handling the vsnprintf return code better
on older systems.
Modified: icecast/trunk/net/sock.c
===================================================================
--- icecast/trunk/net/sock.c 2004-10-05 22:00:45 UTC (rev 7916)
+++ icecast/trunk/net/sock.c 2004-10-06 14:07:55 UTC (rev 7917)
@@ -362,8 +362,37 @@
return rc;
}
+#ifdef HAVE_OLD_VSNPRINTF
int sock_write_fmt(sock_t sock, const char *fmt, va_list ap)
{
+ va_list ap_local;
+ unsigned int len = 1024;
+ char *buff = NULL;
+ int ret;
+
+ /* don't go infinite, but stop at some huge limit */
+ while (len < 2*1024*1024)
+ {
+ char *tmp = realloc (buff, len);
+ ret = -1;
+ if (tmp == NULL)
+ break;
+ buff = tmp;
+ va_copy (ap_local, ap);
+ ret = vsnprintf (buff, len, fmt, ap_local);
+ if (ret > 0)
+ {
+ ret = sock_write_bytes (sock, buff, ret);
+ break;
+ }
+ len += 8192;
+ }
+ free (buff);
+ return ret;
+}
+#else
+int sock_write_fmt(sock_t sock, const char *fmt, va_list ap)
+{
char buffer [1024], *buff = buffer;
int len;
int rc = SOCK_ERROR;
@@ -394,6 +423,7 @@
return rc;
}
+#endif
int sock_read_bytes(sock_t sock, char *buff, const int len)
More information about the commits
mailing list