summaryrefslogtreecommitdiffstats
path: root/common/os
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2008-12-03 14:18:19 +0000
committerAdam Tkac <atkac@redhat.com>2008-12-03 14:18:19 +0000
commit3422fbd158632894ae203f6d7fc2cddfbcbf7a73 (patch)
tree8f5f9ea0aeee2bd88bfbc74a1b592785cefa95d1 /common/os
parent241e9009710f205fb95273a9bed9684285a2ef0d (diff)
downloadtigervnc-3422fbd158632894ae203f6d7fc2cddfbcbf7a73.tar.gz
tigervnc-3422fbd158632894ae203f6d7fc2cddfbcbf7a73.zip
[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
Diffstat (limited to 'common/os')
-rw-r--r--common/os/print.c13
-rw-r--r--common/os/print.h6
2 files changed, 19 insertions, 0 deletions
diff --git a/common/os/print.c b/common/os/print.c
index f24717fb..0f26de36 100644
--- a/common/os/print.c
+++ b/common/os/print.c
@@ -89,3 +89,16 @@ int tight_vsnprintf(char *str, size_t n, const char *format, va_list ap) {
}
#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 47893adf..523f3a1f 100644
--- a/common/os/print.h
+++ b/common/os/print.h
@@ -48,6 +48,12 @@ int tight_vsnprintf(char *str, size_t n, const char *format, va_list ap);
#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