[Refactoring] Improved rdr::Exception constructor. It now accepts variable
number of arguments.

[Bugfix] Minor compilation fixes (missing #includes)


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3168 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/os/print.h b/common/os/print.h
index 471002c..a16e6a9 100644
--- a/common/os/print.h
+++ b/common/os/print.h
@@ -28,10 +28,19 @@
 #endif
 
 #include <stdarg.h>
+#include <stdio.h>
 #include <sys/types.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef HAVE_VSNPRINTF
 int vsnprintf(char *str, size_t n, const char *format, va_list ap);
 #endif
 
+#ifdef __cplusplus
+};
+#endif
+
 #endif /* OS_PRINT_H */
diff --git a/common/rdr/Exception.cxx b/common/rdr/Exception.cxx
index 7d38711..a0a08f0 100644
--- a/common/rdr/Exception.cxx
+++ b/common/rdr/Exception.cxx
@@ -22,8 +22,21 @@
 #include <windows.h>
 #endif
 
+#include <string.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <os/print.h>
+
 using namespace rdr;
 
+Exception::Exception(const char *format, ...) {
+	va_list ap;
+
+	va_start(ap, format);
+	(void) vsnprintf(str_, len, format, ap);
+	va_end(ap);
+}
+
 SystemException::SystemException(const char* s, int err_)
   : Exception(s), err(err_)
 {
diff --git a/common/rdr/Exception.h b/common/rdr/Exception.h
index 2fdc0a2..ef6b368 100644
--- a/common/rdr/Exception.h
+++ b/common/rdr/Exception.h
@@ -19,21 +19,12 @@
 #ifndef __RDR_EXCEPTION_H__
 #define __RDR_EXCEPTION_H__
 
-#include <stdio.h>
-#include <string.h>
-
 namespace rdr {
 
   struct Exception {
     enum { len = 256 };
     char str_[len];
-    Exception(const char* s=0) {
-      str_[0] = 0;
-      if (s)
-        strncat(str_, s, len-1);
-      else
-        strcat(str_, "Exception");
-    }
+    Exception(const char *format = 0, ...);
     virtual ~Exception() {}
     virtual const char* str() const { return str_; }
   };
diff --git a/common/rdr/ZlibOutStream.cxx b/common/rdr/ZlibOutStream.cxx
index df1dbee..f60a620 100644
--- a/common/rdr/ZlibOutStream.cxx
+++ b/common/rdr/ZlibOutStream.cxx
@@ -18,6 +18,8 @@
 
 #include <rdr/ZlibOutStream.h>
 #include <rdr/Exception.h>
+#include <os/print.h>
+
 #include <zlib.h>
 
 using namespace rdr;
diff --git a/common/rfb/CMsgReaderV3.cxx b/common/rfb/CMsgReaderV3.cxx
index d0cfc89..ae5f455 100644
--- a/common/rfb/CMsgReaderV3.cxx
+++ b/common/rfb/CMsgReaderV3.cxx
@@ -22,6 +22,7 @@
 #include <rfb/CMsgReaderV3.h>
 #include <rfb/CMsgHandler.h>
 #include <rfb/util.h>
+#include <stdio.h>
 
 using namespace rfb;
 
diff --git a/common/rfb/ComparingUpdateTracker.cxx b/common/rfb/ComparingUpdateTracker.cxx
index ec32302..671e6ee 100644
--- a/common/rfb/ComparingUpdateTracker.cxx
+++ b/common/rfb/ComparingUpdateTracker.cxx
@@ -16,6 +16,7 @@
  * USA.
  */
 #include <stdio.h>
+#include <string.h>
 #include <vector>
 #include <rdr/types.h>
 #include <rfb/Exception.h>
diff --git a/common/rfb/ConnParams.cxx b/common/rfb/ConnParams.cxx
index 42134c3..446c3ad 100644
--- a/common/rfb/ConnParams.cxx
+++ b/common/rfb/ConnParams.cxx
@@ -15,6 +15,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  */
+#include <stdio.h>
 #include <rdr/InStream.h>
 #include <rdr/OutStream.h>
 #include <rfb/Exception.h>
diff --git a/common/rfb/SMsgReaderV3.cxx b/common/rfb/SMsgReaderV3.cxx
index 37070a8..da012c6 100644
--- a/common/rfb/SMsgReaderV3.cxx
+++ b/common/rfb/SMsgReaderV3.cxx
@@ -15,6 +15,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  */
+
+#include <stdio.h>
 #include <rfb/PixelFormat.h>
 #include <rfb/msgTypes.h>
 #include <rfb/Exception.h>
diff --git a/common/rfb/TransImageGetter.cxx b/common/rfb/TransImageGetter.cxx
index 82c291b..c7d730f 100644
--- a/common/rfb/TransImageGetter.cxx
+++ b/common/rfb/TransImageGetter.cxx
@@ -17,6 +17,7 @@
  */
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <rfb/PixelFormat.h>
 #include <rfb/Exception.h>
 #include <rfb/ConnParams.h>
diff --git a/unix/vncpasswd/Makefile.am b/unix/vncpasswd/Makefile.am
index dfbec97..c6b9e97 100644
--- a/unix/vncpasswd/Makefile.am
+++ b/unix/vncpasswd/Makefile.am
@@ -6,6 +6,6 @@
 
 vncpasswd_CPPFLAGS = -I$(COMMON_DIR)
 
-vncpasswd_LDADD = $(COMMON_DIR)/rfb/librfb.la
+vncpasswd_LDADD = $(COMMON_DIR)/rfb/librfb.la $(COMMON_DIR)/rdr/librdr.la
 
 EXTRA_DIST = vncpasswd.man