Index: /trunk/FACT++/src/EventBuilder.h
===================================================================
--- /trunk/FACT++/src/EventBuilder.h	(revision 10783)
+++ /trunk/FACT++/src/EventBuilder.h	(revision 10784)
@@ -35,4 +35,7 @@
 extern uint gp_EvtTot   ;
 
+//#define error Error
+//extern void Error(int severity, int errnum, const char *fmt, ...);
+
 #ifdef __cplusplus
 }
Index: /trunk/FACT++/src/fadctrl.cc
===================================================================
--- /trunk/FACT++/src/fadctrl.cc	(revision 10783)
+++ /trunk/FACT++/src/fadctrl.cc	(revision 10784)
@@ -103,5 +103,5 @@
                 err!=ba::error::basic_errors::operation_aborted)  // Connection closed by us
             {
-                stringstream str;
+                ostringstream str;
                 str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
                 Error(str);
@@ -117,5 +117,5 @@
             if (fEventHeader.fStartDelimiter!=FAD::kDelimiterStart)
             {
-                stringstream str;
+                ostringstream str;
                 str << "Invalid header received: start delimiter wrong, received ";
                 str << hex << fEventHeader.fStartDelimiter << ", expected " << FAD::kDelimiterStart << ".";
@@ -140,5 +140,5 @@
         if (ntohs(fBuffer.back())!=FAD::kDelimiterEnd)
         {
-            stringstream str;
+            ostringstream str;
             str << "Invalid data received: end delimiter wrong, received ";
             str << hex << ntohs(fBuffer.back()) << ", expected " << FAD::kDelimiterEnd << ".";
@@ -231,5 +231,5 @@
         if (error && error!=ba::error::basic_errors::operation_aborted)
         {
-            stringstream str;
+            ostringstream str;
             str << "Read timeout of " << URL() << ": " << error.message() << " (" << error << ")";// << endl;
             Error(str);
@@ -261,5 +261,5 @@
     void PostCmd(std::vector<uint16_t> cmd)
     {
-        stringstream msg;
+        ostringstream msg;
         msg << "Sending command:" << hex;
         msg << " 0x" << setw(4) << setfill('0') << cmd[0];
@@ -273,5 +273,5 @@
     void PostCmd(uint16_t cmd)
     {
-        stringstream msg;
+        ostringstream msg;
         msg << "Sending command:" << hex;
         msg << " 0x" << setw(4) << setfill('0') << cmd;
@@ -284,5 +284,5 @@
     void PostCmd(uint16_t cmd, uint16_t data)
     {
-        stringstream msg;
+        ostringstream msg;
         msg << "Sending command:" << hex;
         msg << " 0x" << setw(4) << setfill('0') << cmd;
@@ -589,4 +589,9 @@
 class EventBuilderWrapper
 {
+public:
+    // FIXME
+    static EventBuilderWrapper *This;
+
+private:
     boost::thread fThread;
 
@@ -609,5 +614,14 @@
     EventBuilderWrapper(MessageImp &msg) : fMsg(msg)
     {
+        if (This)
+            throw runtime_error("EventBuilderWrapper cannot be instantiated twice.");
+
+        This = this;
         Start();
+    }
+
+    void Update(ostringstream &out, int severity)
+    {
+        fMsg.Update(out, severity);
     }
 
@@ -672,6 +686,42 @@
         Abort();
     }
-
 };
+/*
+extern "C" {
+
+void Error(int severity, int errnum, const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+
+    int n=256;
+
+    char *ret=0;
+    while (1)
+    {
+        ret = new char[n+1];
+
+        const int sz = vsnprintf(ret, n, fmt, ap);
+        if (sz<=n)
+            break;
+
+        n *= 2;
+        delete [] ret;
+    };
+
+    va_end(ap);
+
+    ostringstream str;
+    str << ret << " (" << errnum << ":" << strerror(errnum) << ")";
+
+    delete [] ret;
+
+    EventBuilderWrapper::This->Update(str, severity);
+}
+
+}
+*/
+
+EventBuilderWrapper *EventBuilderWrapper::This = 0;
 
 // ------------------------------------------------------------------------
@@ -696,5 +746,5 @@
             return true;
 
-        stringstream msg;
+        ostringstream msg;
         msg << name << " - Received event has " << has << " bytes, but expected " << size << ".";
         T::Fatal(msg);
@@ -725,5 +775,5 @@
         if (dat[0]>FAD::kMaxRegAddr)
         {
-            stringstream msg;
+            ostringstream msg;
             msg << hex << "Address " << dat[0] << " out of range, max=" << maxaddr << ".";
             T::Error(msg);
@@ -733,5 +783,5 @@
         if (dat[1]>FAD::kMaxRegValue)
         {
-            stringstream msg;
+            ostringstream msg;
             msg << hex << "Value " << dat[1] << " out of range, max=" << maxval << ".";
             T::Error(msg);
@@ -840,5 +890,5 @@
         if (evt.GetUShort()>0xff)
         {
-            stringstream msg;
+            ostringstream msg;
             msg << hex << "Value " << evt.GetUShort() << " out of range, max=" << 0xff << "(?)";
             T::Error(msg);
