Index: Evidence/Evidence.cc
===================================================================
--- Evidence/Evidence.cc	(revision 212)
+++ Evidence/Evidence.cc	(revision 216)
@@ -5,8 +5,8 @@
   - The server is started with the given name.
   - DIM exit and error handlers are implemented.
-  - The Status service is published (special format, see below).
-    It can be updated with the State() method. The text will also be logged.
-  - If the severity of a State() call is FATAL, exit() will be called (with
-    this severity, the call to State() is guranteed not to return).
+  - The Message service is published (special format, see below).
+    It can be updated with the Message() method. The text will also be logged.
+  - If the severity of a Message() call is FATAL, exit() will be called (with
+    this severity, the call to Message() is guranteed not to return).
   - Configuration data can be requested by GetConfig(). 
   - Signal handlers to ignore common signals are installed.
@@ -60,5 +60,5 @@
   snprintf(InitMsg, sizeof(InitMsg), "Server started (%s, compiled %s %s)", Rev.c_str(),__DATE__, __TIME__);
   
-  Status = new DimService((ServerName+"/Status").c_str(), (char *) "C", InitMsg, strlen(InitMsg)+1);
+  Status = new DimService((ServerName+"/Message").c_str(), (char *) "C", InitMsg, strlen(InitMsg)+1);
   StdOut = new DimService((ServerName+"/Textout").c_str(), (char *) "");
 
@@ -70,5 +70,5 @@
 EvidenceServer::~EvidenceServer() {
 
-  State(INFO, "Server stopped");
+  Message(INFO, "Server stopped");
   
   for (unsigned int i=0; i<ConfigList.size(); i++) {
@@ -84,11 +84,11 @@
 void EvidenceServer::exitHandler(int Code) {
 
-  State(INFO, "Exit handler called (DIM exit code %d)", Code);
+  Message(INFO, "Exit handler called (DIM exit code %d)", Code);
   exit(EXIT_SUCCESS);
 }
 
 // DIM error handler
-void EvidenceServer::errorHandler(int Severity, int Code, char *Message) {   
-  State(ERROR, "%s (DIM error code %d, severity %d)\n", Message, Code, Severity);
+void EvidenceServer::errorHandler(int Severity, int Code, char *Text) {   
+  Message(ERROR, "%s (DIM error code %d, severity %d)\n", Text, Code, Severity);
 }
 
@@ -98,8 +98,8 @@
 // is given, terminated by another '\0'  The buffer for the DIM service must have
 // the same lifetime as the DIM service. If Severity is FATAL, exit() will be invoked.
-void EvidenceServer::State(StateType Severity, const char *Format, ...) {
+void EvidenceServer::Message(MessageType Severity, const char *Format, ...) {
 
   static const char* StateString[] = {"Info", "Warn", "Error", "Fatal"};
-  static char ErrorString[] = "vasprintf() failed in State()";
+  static char ErrorString[] = "vasprintf() failed in Message()";
   static char SBuf[STATUS_SIZE];
   char TBuf[STATUS_SIZE];
@@ -116,7 +116,7 @@
 
   // Create string with severity encoding
-  snprintf(SBuf, sizeof(SBuf), "%s**", Tmp);
-  SBuf[strlen(SBuf)-2] = '\0';
-  SBuf[strlen(SBuf)+1] = Severity;
+  snprintf(SBuf, sizeof(SBuf), "%s*", Tmp);
+  SBuf[strlen(SBuf)-1] = '\0'; 		// new string terminiation replaces '*'
+  SBuf[strlen(SBuf)+1] = Severity;	// Severity after new string termination
 
   if (Tmp != ErrorString) free(Tmp);
@@ -174,9 +174,9 @@
   // Terminate if not successful
   if (!EvidenceServer::ServiceOK(&Config)) {
-    State(FATAL, "Configuration server unreachable, can't get '%s'", Item.c_str());
+    Message(FATAL, "Configuration server unreachable, can't get '%s'", Item.c_str());
   }
 
   if (strlen(Result) == 0) {
-    if (Default == NULL) State(FATAL, "Missing configuration data '%s'", Item.c_str());
+    if (Default == NULL) Message(FATAL, "Missing configuration data '%s'", Item.c_str());
 	Result = (char *) Default;
   }
@@ -214,5 +214,5 @@
 
   // If invoked twice, call exit()
-  ThisServer->State(ThisServer->WARN, "Signal handler called again, invoking exit() (signal %d)", Signal);
+  ThisServer->Message(ThisServer->WARN, "Signal handler called again, invoking exit() (signal %d)", Signal);
   exit(EXIT_FAILURE);
 }
@@ -253,9 +253,10 @@
   else snprintf(Msg, sizeof(Msg), "Terminate() called without an active exception");
 
-  ThisServer->State(FATAL, Msg);
+  ThisServer->Message(FATAL, Msg);
 }
 
 
 // Translates DIMInfo to string (memory has to be freed by caller)
+// Static method: it cannot report memory allocation errors via Message()
 char *EvidenceServer::ToString(DimInfo *Item) {
 
@@ -355,6 +356,6 @@
 
 // Marker for history buffer
-const int EvidenceHistory::WrapMark[] = {0, -1};
-const int EvidenceHistory::EndMark[] = {0, 0};
+const struct EvidenceHistory::Item EvidenceHistory::WrapMark = {0, -1, {}};
+const struct EvidenceHistory::Item EvidenceHistory::EndMark = {0, 0, {}};
 
 // Constructor
@@ -392,21 +393,18 @@
 
 // Returns next item in history buffer
-bool EvidenceHistory::Next(int &Time, int &Size, void *&Data) {
-
-  if (Buffer == NULL) return false;
+const struct EvidenceHistory::Item *EvidenceHistory::Next() {
+
+  if (Buffer == NULL) return NULL;
 
   // Check for wrap around
-  if (memcmp(Buffer+Offset, WrapMark, sizeof(WrapMark)) == 0) Offset = 4;
+  if (memcmp(Pointer, &WrapMark, sizeof(WrapMark)) == 0) Pointer = (struct Item *) (Buffer + 4);
   
   // Check if at end of ring buffer
-  if (memcmp(Buffer+Offset, EndMark, sizeof(EndMark)) == 0) return false;
-
-  Time = *(int *) (Buffer + Offset);
-  Size = *(int *) (Buffer + Offset + sizeof(int));
-  Data = Buffer + Offset + 2*sizeof(int);
-
-  Offset += *((int *) (Buffer + Offset) + 1) + 2*sizeof(int);
-
-  return true;
+  if (memcmp(Pointer, &EndMark, sizeof(EndMark)) == 0) return NULL;
+
+  const struct Item *Ret = Pointer;
+  Pointer = (struct Item *) ((char *) (Pointer + 1) + Pointer->Size);
+
+  return Ret;
 }
 
@@ -414,4 +412,4 @@
 void EvidenceHistory::Rewind() {
 
-  if (Buffer != NULL) Offset = *(int *) Buffer;
-}
+  if (Buffer != NULL) Pointer = (struct Item *) (Buffer + (*(int *) Buffer));
+}
