[Portability] Implemented snprintf() function to support old compilers



git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3290 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/os/print.c b/common/os/print.c
index f24717f..0f26de3 100644
--- a/common/os/print.c
+++ b/common/os/print.c
@@ -89,3 +89,16 @@
 }
 #endif /* HAVE_VSNPRINTF */
 
+#ifndef HAVE_SNPRINTF
+int tight_snprintf(char *str, size_t n, const char *format, ...) {
+	va_list ap;
+	int written;
+
+	va_start(ap, format);
+	written = vsnprintf(str, n, format, ap);
+	va_end(ap);
+
+	return written;
+}
+#endif /* HAVE_SNPRINTF */
+
diff --git a/common/os/print.h b/common/os/print.h
index 47893ad..523f3a1 100644
--- a/common/os/print.h
+++ b/common/os/print.h
@@ -48,6 +48,12 @@
 #define vsnprintf tight_vsnprintf
 #endif
 
+#ifndef HAVE_SNPRINTF
+/* Inherits tight_vsnprintf limitations if vsnprintf is not present */
+int tight_snprintf(char *str, size_t n, const char *format, ...);
+#define snprintf tight_snprintf
+#endif
+
 #ifdef __cplusplus
 };
 #endif