Index: /Evidence/Alarm/Alarm.cc
===================================================================
--- /Evidence/Alarm/Alarm.cc	(revision 127)
+++ /Evidence/Alarm/Alarm.cc	(revision 127)
@@ -0,0 +1,137 @@
+/********************************************************************\
+
+  Alarm handler of the Evidence Control System
+
+  - Checks periodically if all required servers are up
+    (later it should try to start them if not)
+  - Listens to the 'Status' service of each server. The server state 
+    is published as a DIM service.
+    
+  Oliver Grimm, September 2009
+
+\********************************************************************/
+
+#define SERVER_NAME "Alarm"
+#include "../Evidence.h"
+
+//
+// Data handling class
+//
+class AlarmHandler : public DimClient, public EvidenceServer {
+    
+    DimStampedInfo **StatusService;
+    void infoHandler();
+
+  public:
+    AlarmHandler();
+    ~AlarmHandler();
+    
+    char **Server;
+    unsigned int NumServers;
+    char *StateString;
+    char *ServerList;  
+}; 
+
+// Constructor
+AlarmHandler::AlarmHandler(): EvidenceServer(SERVER_NAME) {
+
+  char *ServerNames = GetConfig(SERVER_NAME " servers");
+
+  // Copy original list of servers to observe
+  ServerList = new char [strlen(ServerNames)+1];
+  strcpy(ServerList, ServerNames);
+  
+  // Extract DIM servers to observe
+  Server = new char* [strlen(ServerNames)];
+  NumServers = 0;
+  char *NextToken = strtok(ServerNames, " \t");
+  while (NextToken != NULL) {
+    Server[NumServers++] = NextToken; // Subscribe with handler
+    NextToken = strtok(NULL, " \t");     
+  }
+
+  // Subscribe with handler to 'Status' service of all servers
+  StatusService = new DimStampedInfo* [NumServers];
+  
+  for (int i=0; i<NumServers; i++) {
+    char *Buffer = new char [strlen(Server[i])+10];
+    strcpy(Buffer, Server[i]);
+    strcat(Buffer, "/Status");
+    StatusService[i] = new DimStampedInfo(Buffer, 0, this);
+    printf("Subscribed to %s\n", Buffer);
+    delete[] Buffer; 
+  }
+  
+  StateString = new char [NumServers+1];
+  for (int i=0; i<NumServers; i++) StateString[i] = '1';
+  StateString[NumServers] = '\0';
+}
+
+// Destructor
+AlarmHandler::~AlarmHandler() {
+
+  for (int i=0; i<NumServers; i++) delete StatusService[i];
+  delete[] StatusService;
+  delete[] Server;
+  delete[] ServerList;
+}
+
+// Print messages of status changes to screen
+void AlarmHandler::infoHandler() {
+
+  // Ignore empty messages
+  if (strlen(getInfo()->getString()) == 0) return;
+  
+  // Print message
+  time_t RawTime = getInfo()->getTimestamp();
+  struct tm *TM = localtime(&RawTime);
+  printf("%s (%02d:%02d:%02d): %s\n", getInfo()->getName(), TM->tm_hour,
+	TM->tm_min, TM->tm_sec, getInfo()->getString());
+
+  // Update status string
+  for (int i=0; i<NumServers; i++) {
+    if (strcmp(getInfo()->getName(),Server[i]) == 0) {
+      StateString[i] = '2';
+    }
+  }  
+}
+
+
+//	    
+// Main program
+//
+int main() {
+    
+  DimBrowser Browser;
+  char *ServerName, *Node;
+  bool Exists;
+  
+  // Static declaration ensures calling of destructor by exit()
+  static AlarmHandler Alarm; 
+  
+  // Request configuration data
+  unsigned int Period = atoi(Alarm.GetConfig(SERVER_NAME " period"));
+
+  // Create DIM services
+  static DimService ServerState(SERVER_NAME"/State", Alarm.StateString);
+  static DimService ServerList(SERVER_NAME"/Servers", Alarm.ServerList);
+
+  // Check periodically if servers are up
+  while(!EvidenceServer::ExitRequest) {
+    for (int i=0; i<Alarm.NumServers; i++) {
+      Exists = false;
+      Browser.getServers();
+      while (Browser.getNextServer(ServerName, Node) == 1) {
+        if (strcmp(ServerName, Alarm.Server[i]) == 0) Exists = true;
+      }
+      if (!Exists) {
+        Alarm.Msg(Alarm.WARN, "Server %s unavailable", Alarm.Server[i]);
+	Alarm.StateString[i] = '0';
+      }
+      else if (Alarm.StateString[i] == '0') Alarm.StateString[i] = '1';
+    }
+    
+    ServerState.updateService(Alarm.StateString);
+    sleep(Period);
+  }
+}
Index: /Evidence/Alarm/Makefile
===================================================================
--- /Evidence/Alarm/Makefile	(revision 127)
+++ /Evidence/Alarm/Makefile	(revision 127)
@@ -0,0 +1,10 @@
+CC=g++
+
+PROG=Alarm
+CPPFLAGS += -I../DIM	
+LDLIBS += -lpthread
+
+$(PROG): $(PROG).o ../Evidence.o ../DIM/libdim.a
+
+clean:
+	@rm -f $(PROG) $(PROG).o *.d *~
Index: /Evidence/Config/Config.cc
===================================================================
--- /Evidence/Config/Config.cc	(revision 127)
+++ /Evidence/Config/Config.cc	(revision 127)
@@ -0,0 +1,154 @@
+/********************************************************************\
+
+  Configuration server for the Evidence Control System
+
+  - The configuration file is opened without buffering to catch changes
+    without closing/opening.
+  - If a configuration file change is detected through inotify, the service "Config/Modified"
+    is updated (it contains no data) to inform applications. 
+  - The employed line buffer has conservatively at least the size of the configuration file. If
+    needed, it will be enlarged.
+         
+  Oliver Grimm, November 2009
+
+\********************************************************************/
+
+#define CONFIG_FILE "configuration.txt"
+#define SERVER_NAME "Config"
+
+#include "../Evidence.h"
+#include <sys/stat.h>
+#include <sys/inotify.h>
+
+//
+// Class derived from DimRpc
+//
+class EvidenceConfig: public DimRpc, public EvidenceServer {
+
+  private:
+    FILE *File;	
+    char *Buffer;
+    unsigned int BufferLength;
+    DimService *ConfigModified;
+
+    void rpcHandler();
+  
+  public:
+    EvidenceConfig(const char *);
+    ~EvidenceConfig();
+	
+	void ConfigChanged(); 
+};
+
+// Constructor
+EvidenceConfig::EvidenceConfig(const char *Filename):
+	DimRpc("ConfigRequest", "C", "C"), EvidenceServer(SERVER_NAME) {
+
+  // Create DIM service to indicate changes of configuration file
+  ConfigModified = new DimService (SERVER_NAME"/Modified", (char *) "");
+
+  // Open configuration file
+  if ((File = fopen(Filename, "r")) == NULL) {
+    Msg(FATAL, "Could not open configuration file '%s' (%s)\n", Filename, strerror(errno));
+  }
+
+  // Disable buffering, so file modifications are immediately seen
+  if(setvbuf(File, NULL, _IONBF, 0) != 0) {
+    Msg(WARN, "Error setting configuration file '%s' to unbuffered mode.\n", Filename);
+  }
+    
+  Buffer = NULL;    // Will be allocated in rpcHandler()
+  BufferLength = 0;
+}
+
+// Destructor
+EvidenceConfig::~EvidenceConfig() {
+
+  if (File != NULL) fclose(File);  
+  delete[] Buffer;
+}
+
+// Implementation of response to configuration request
+void EvidenceConfig::rpcHandler() {
+
+  char *Token1,*Token2,*Token3, *Request = getString();
+  struct stat FileStatus;
+  
+  // Check if Buffer[] is large enough to hold full file, enlarge if necessary
+  if (fstat(fileno(File), &FileStatus) == -1) {
+     Msg(ERROR, "Could not determine size of configuration file to allocate buffer (%s)\n", strerror(errno));
+  }
+  else if(BufferLength < FileStatus.st_size) {
+    delete[] Buffer;
+    Buffer = new char [FileStatus.st_size];
+    BufferLength = FileStatus.st_size;   
+  }
+  
+  // Search for configuration item
+  rewind(File);
+  while (fgets(Buffer, BufferLength, File) != NULL) {
+    
+    // Combine lines that end with '+'
+    while (Buffer[strlen(Buffer)-2] == '+') {
+      if (fgets(Buffer+strlen(Buffer)-2, BufferLength-(strlen(Buffer)-2), File) == NULL) break;
+    }
+    
+    // Ignore comments
+    for (int i=0; i<strlen(Buffer); i++) if (Buffer[i] == '#') Buffer[i] = '\0';
+    
+    // Extract tokens
+    Token1 = strtok(Buffer, " \t:");
+    Token2 = strtok(NULL, " \t:");
+    Token3 = strtok(NULL, "\n");
+    
+    // Check if all tokens existing
+    if(Token1==NULL || Token2==NULL || Token3==NULL) continue;
+
+    // Check for match and then send data
+    if (strstr(Request, Token1)!=NULL && strstr(Request, Token2)!=NULL) {
+      setData(Token3);
+      break;
+    }
+  }
+  Msg(INFO, "Client '%s' (ID %d) requested '%s'. Send '%s'.",
+		DimServer::getClientName(),
+		DimServer::getClientId(), 
+		Request, feof(File)!=0 ? "n/a" : Token3);
+}
+
+// Signalisation of configuration change
+void EvidenceConfig::ConfigChanged() {
+
+  ConfigModified->updateService();
+}
+
+//	    
+// Declaring class static ensures destructor is called when exit() is invoked 
+//
+int main() {
+        
+  static EvidenceConfig Config(CONFIG_FILE);
+
+  int Notify;
+  struct inotify_event Event;
+  
+  if ((Notify = inotify_init()) == -1) {
+    Config.Msg(EvidenceConfig::WARN, "inotify_init() failed, cannot monitor changes of configuration file (%s)\n", strerror(errno));
+  }
+  else if (inotify_add_watch(Notify, CONFIG_FILE, IN_MODIFY) == -1) { 
+      Config.Msg(EvidenceConfig::WARN, "Could not set inotify watch on configuration file (%s)\n", strerror(errno));
+	  close(Notify);
+	  Notify = -1;
+  }
+
+  // Sleep until file changes or signal caught 
+  while (!EvidenceServer::ExitRequest) {
+    if (Notify != -1) {
+	  read(Notify, &Event, sizeof(Event));
+	  Config.ConfigChanged();
+	}
+    else pause();	  
+  }
+  
+  if (Notify != -1) close(Notify);
+}
Index: /Evidence/Config/Makefile
===================================================================
--- /Evidence/Config/Makefile	(revision 127)
+++ /Evidence/Config/Makefile	(revision 127)
@@ -0,0 +1,11 @@
+CC=g++
+
+PROG=Config
+CPPFLAGS += -I../DIM/ 
+LDLIBS += -lpthread
+
+$(PROG): $(PROG).o ../Evidence.o ../DIM/libdim.a
+
+clean:
+	@rm -f $(PROG) $(PROG).o
+	
Index: /Evidence/Config/configuration.txt
===================================================================
--- /Evidence/Config/configuration.txt	(revision 127)
+++ /Evidence/Config/configuration.txt	(revision 127)
@@ -0,0 +1,29 @@
+# Configuration data for the Evidence Control System
+#
+# The first entry of each line gives the requester for the parameter in
+# the second entry. The remaining text of the line is send in reponse
+# to the configuration request.
+# A plus sign before the line break signals continuation of the line.
+
+
+# Sky Quality Monitor
+
+SQM address	sqm.ethz.ch
+SQM port	10001
+SQM period	10
+
+
+# Central Data Collector
+
+DColl items	SQM/NSB Alarm/Servers Alarm/State +
+		Config/Status DColl/Status Alarm/Status SMQ/Status +
+		BIAS/VOLT/ID00/*-*
+DColl datadir	../../../no_back/EvidenceData
+DColl logfile	../../../no_back/EvidenceData/Evidence.log
+DColl histsize	1000 # Number of items in history buffer
+
+
+# Alarm Handler
+
+Alarm servers	DIS_DNS DColl SQM Config
+Alarm period	10 # Check interval in seconds
Index: /Evidence/DColl/DColl.cc
===================================================================
--- /Evidence/DColl/DColl.cc	(revision 127)
+++ /Evidence/DColl/DColl.cc	(revision 127)
@@ -0,0 +1,270 @@
+/********************************************************************\
+
+  Central data collector of the Evidence Control System
+  
+  - DColl subscribes to all services given by the configuration
+    server and writes these to the data file at every update.
+  - For each service, it creates a new service with '.hist' appended that
+    contains a history of events kept within a ring buffer. Each entry will
+	be the result of a conversion to double of the text written to the data file.
+  - The command 'DColl/Log' writes the associated string to the log 
+    file specified in the configuration.
+  
+  Oliver Grimm, December 2009
+
+\********************************************************************/
+
+#define SERVER_NAME "DColl"
+
+#include "../Evidence.h"
+
+#define NO_LINK "__&DIM&NOLINK&__" // for checking if DIMserver is alive
+
+//
+// Class declaration
+//
+class DataHandler:	public DimClient, public DimCommand,
+					public DimBrowser, public EvidenceServer {
+  private:
+    pthread_mutex_t DataMutex;
+    pthread_mutex_t LogMutex;
+
+    unsigned int NumItems;
+    FILE *DataFile;
+    FILE *LogFile;
+    char *Filename;
+
+    DimStampedInfo **DataItem;
+    DimService **HistService;	    
+    int HistSize;
+    struct EvidenceHistoryItem **HistBuffer;
+	int *HistPointer;
+    	
+    void infoHandler();
+    void commandHandler();
+    bool ReallocMem(void *&, int);
+	    
+  public:
+    DataHandler();
+    ~DataHandler();
+}; 
+
+//
+// Constructor
+//
+DataHandler::DataHandler(): DimCommand((char *) "DColl/Log", (char *) "C"), EvidenceServer(SERVER_NAME) {
+
+  // Initialization to prevent freeing unallocated memory 
+  DataFile = NULL;
+  Filename = NULL;
+
+  DataItem = NULL;
+  HistService = NULL;
+  HistBuffer = NULL;
+  HistPointer = NULL;
+  
+  // Request configuration data
+  char *Items = GetConfig(SERVER_NAME " items");
+  char *DataDir = GetConfig(SERVER_NAME " datadir");
+  char *Logname = GetConfig(SERVER_NAME " logfile");
+  HistSize = atoi(GetConfig(SERVER_NAME " histsize"));
+  if (HistSize < 1) HistSize = 1; // Minimum one items
+   
+  // Create mutex for thread synchronization 
+  if ((errno=pthread_mutex_init(&DataMutex, NULL)) != 0) {
+    Msg(FATAL, "pthread_mutex_init() failed for data file (%s)", strerror(errno));
+  }
+  if ((errno=pthread_mutex_init(&LogMutex, NULL)) != 0) {
+    Msg(FATAL, "pthread_mutex_init() failed for log file (%s)", strerror(errno));
+  }
+
+  // Interpret DIM services to observe and prepare history buffer
+  char *Buf, *ServiceName, *Format;
+  int NumServices;
+  NumItems = 0;
+  char *NextToken = strtok(Items, " \t");
+  while (NextToken != NULL) {
+    NumServices = getServices(NextToken);
+    for (int j=0; j<NumServices; j++)  {
+	  if (getNextService(ServiceName, Format) == DimSERVICE) {
+
+	    // Check if already subsubed to this service
+		for (int i=0; i<NumItems; i++) {
+		  if(strcmp(ServiceName, DataItem[i]->getName()) == 0) continue;
+		}
+		
+	    // Increase capacity of arrays
+	    if (!ReallocMem((void *&) DataItem, NumItems+1)) continue;
+	    if (!ReallocMem((void *&) HistService, NumItems+1)) continue;
+	    if (!ReallocMem((void *&) HistBuffer, NumItems+1)) continue;
+	    if (!ReallocMem((void *&) HistPointer, NumItems+1)) continue;
+
+  		// Subscribe to service
+    	DataItem[NumItems] = new DimStampedInfo(ServiceName, (char *) NO_LINK, this);
+
+    	// Create history service
+    	HistBuffer[NumItems] = new struct EvidenceHistoryItem [HistSize];
+		memset(HistBuffer[NumItems], 0, HistSize*sizeof(EvidenceHistoryItem));
+		HistPointer[NumItems] = 0;
+
+    	if (asprintf(&Buf, "%s.hist", ServiceName) == -1) {
+    	  Msg(ERROR, "Could not create Hist service for %s because asprintf() failed", ServiceName);
+    	}
+    	else {
+		  HistService[NumItems] = new DimService (Buf, (char *) "C",
+	  							HistBuffer[NumItems], HistSize*sizeof(EvidenceHistoryItem));
+    	  free(Buf);
+		}
+		NumItems++;
+	  }
+	}
+    NextToken = strtok(NULL, " \t");
+  }
+
+  // Open data file
+  time_t rawtime = time(NULL);
+  struct tm * timeinfo = gmtime(&rawtime);
+  if(timeinfo->tm_hour >= 13) rawtime += 12*60*60;
+  timeinfo = gmtime(&rawtime);
+
+  if (asprintf(&Filename, "%s/%d%02d%02d.slow", DataDir, timeinfo->tm_year+1900, timeinfo->tm_mon+1, timeinfo->tm_mday) == -1) {
+    Filename = NULL;
+    Msg(FATAL, "Could not create filename with asprintf()(%s)", strerror(errno));
+  }
+  if ((DataFile = fopen(Filename, "a")) == NULL) {
+    Msg(FATAL, "Could not open data file '%s' (%s)", Filename, strerror(errno));
+  }
+  
+  // Open log file
+  if ((LogFile = fopen(Logname, "a")) == NULL) {
+    Msg(FATAL, "Could not open log file '%s' (%s)", Logname, strerror(errno));
+  }
+
+}
+
+//
+// Destructor: Close files and free memory
+//
+DataHandler::~DataHandler() {
+
+  // Close files
+  if (LogFile != NULL && fclose(LogFile) != 0) {
+	Msg(ERROR, "Could not close log file (%s)", strerror(errno));
+  }
+  if (DataFile != NULL && fclose(DataFile) != 0) {
+	Msg(ERROR, "Error: Could not close data file (%s)", strerror(errno));
+  }	
+
+  // Free all memory
+  for (int i=0; i<NumItems; i++) {
+    delete[] HistBuffer[i];
+    delete DataItem[i];
+  }
+
+  free(Filename);
+  free(HistService);
+  free(HistPointer);
+  free(HistBuffer);
+  free(DataItem);
+  
+  // Destroy mutex
+  pthread_mutex_destroy (&LogMutex);
+  pthread_mutex_destroy (&DataMutex);
+}
+
+//
+// Implementation of data handling
+//
+// More than one infoHandler() might run in parallel, therefore
+// the mutex mechanism is used to serialize writing to the file
+void DataHandler::infoHandler() {
+  
+  DimInfo *Info = getInfo();
+
+  // Check if service actually available, if it contains data and if data file is open
+  if (Info->getSize()==strlen(NO_LINK)+1 && strcmp(Info->getString(), NO_LINK)==0) return;
+  if (Info->getSize() == 0 || DataFile == NULL) return;
+
+  // Identify index of service
+  int Service;  
+  for (Service=0; Service<NumItems; Service++) if (Info == DataItem[Service]) break;
+  if (Service == NumItems) return;  // Not found: should never happen
+
+  pthread_mutex_lock(&DataMutex);
+  
+  // Write data header
+  time_t RawTime = Info->getTimestamp();
+  struct tm *TM = localtime(&RawTime);
+
+  fprintf(DataFile, "%s %d %d %d %d %d %d %d %lu ", Info->getName(), TM->tm_year+1900, TM->tm_mon+1, TM->tm_mday, TM->tm_hour, TM->tm_min, TM->tm_sec, Info->getTimestampMillisecs(), Info->getTimestamp());
+
+  // Translate info data into ASCII and write to file and to history buffer
+  char *Text = EvidenceServer::ToString(Info);
+  if (Text != NULL) {
+    fprintf(DataFile, "%s\n", Text);
+	
+	HistBuffer[Service][HistPointer[Service]].Seconds = Info->getTimestamp();
+    HistBuffer[Service][HistPointer[Service]].Value = atof(Text);
+    HistService[Service]->updateService();
+	HistPointer[Service]++;
+	if (HistPointer[Service] >= HistSize) HistPointer[Service] = 0;
+
+	free(Text);
+  }
+  else fprintf(DataFile, "Cannot interpret format identifier\n");
+ 
+  fflush(DataFile);
+  if(ferror(DataFile)) Msg(ERROR, "Error writing to data file (%s)", strerror(errno));
+
+  pthread_mutex_unlock(&DataMutex);
+}
+
+//
+// Implementation of log writing (the only command is 'DColl/Log')
+//
+void DataHandler::commandHandler() {
+
+  if (LogFile == NULL) return;  // Handler might be called before file is opened
+ 
+  pthread_mutex_lock(&LogMutex);
+
+  time_t RawTime = time(NULL);
+  struct tm *TM = localtime(&RawTime);
+
+  fprintf(LogFile, "%d/%d/%d %d:%d:%d: %s\n",
+  		TM->tm_mday, TM->tm_mon+1, TM->tm_year+1900,
+		TM->tm_hour, TM->tm_min, TM->tm_sec, getString());
+
+  fflush(LogFile);
+  if(ferror(LogFile)) Msg(ERROR, "Error writing to log file (%s)", strerror(errno));
+  pthread_mutex_unlock(&LogMutex);
+}
+
+
+//
+// Implementation of memory re-allocation for pointer arrays
+//
+bool DataHandler::ReallocMem(void *&Memory, int Size) {
+
+  void *NewMem = realloc(Memory, Size*sizeof(void *));
+
+  if (NewMem != NULL) {
+    Memory = NewMem;
+	return true;
+  }
+  else {
+	Msg(ERROR, "Could not allocate memory ()", strerror(errno));
+	return false;
+  }
+}
+
+//	    
+// Main program
+//
+int main() {
+        
+  // Static ensures calling of destructor by exit()
+  static DataHandler Data;
+  
+  pause();	  // Sleep until signal caught
+}
Index: /Evidence/DColl/Makefile
===================================================================
--- /Evidence/DColl/Makefile	(revision 127)
+++ /Evidence/DColl/Makefile	(revision 127)
@@ -0,0 +1,11 @@
+CC=g++
+
+PROG=DColl
+CPPFLAGS += -I../DIM
+LDLIBS += -lpthread
+
+$(PROG): $(PROG).o ../Evidence.o ../DIM/libdim.a
+
+clean:
+	@rm -f $(PROG) $(PROG).o
+	
Index: /Evidence/DIM/.setup
===================================================================
--- /Evidence/DIM/.setup	(revision 127)
+++ /Evidence/DIM/.setup	(revision 127)
@@ -0,0 +1,92 @@
+
+set POSSOSVALUES = HP-UX,AIX,OSF1,SunOS,Solaris,LynxOS,Linux,Darwin,
+if ($?OS) then
+    echo OS is set to $OS
+    set TEMP = $OS,
+    echo $POSSOSVALUES | grep $TEMP>/dev/null
+    if ( ! $status == 0) then
+        echo Unknown OS... setup failed
+        echo Possible values are: $POSSOSVALUES
+        exit 1
+    endif
+else
+   echo Variable OS must be defined... setup failed
+   echo Possible values are: $POSSOSVALUES
+   exit 1
+endif
+
+if ( ${OS} == Solaris ) then
+    set path = (/usr/ccs/bin $path)
+endif
+
+if ($?DIMDIR) then
+	echo DIMDIR is set to $DIMDIR
+else
+	setenv DIMDIR `pwd`
+	echo DIMDIR is set to $DIMDIR
+endif
+
+if ($?ODIR) then
+    echo ODIR is set to $ODIR
+    goto finish
+endif
+
+switch ($OS)
+	case HP-UX:
+		setenv ODIR hp
+		breaksw
+	case AIX:
+		setenv ODIR aix
+		breaksw
+	case OSF1:
+		setenv ODIR osf
+		breaksw
+	case SunOS:
+		setenv ODIR sunos
+		breaksw
+	case Solaris
+		setenv ODIR solaris
+		breaksw
+	case LynxOS:
+		setenv ODIR lynxos
+		breaksw
+	case Linux:
+		setenv ODIR linux
+		breaksw
+	case Darwin:
+		setenv ODIR darwin
+		breaksw
+	default:
+        	echo Unknown OS... setup failed
+                exit 1
+endsw
+
+echo ODIR is set to $ODIR
+
+finish:
+if ( ${OS} == Linux ) then
+if (! $?LD_LIBRARY_PATH) then
+    setenv LD_LIBRARY_PATH $DIMDIR/$ODIR
+else
+    setenv LD_LIBRARY_PATH $DIMDIR/$ODIR\:$LD_LIBRARY_PATH
+endif
+endif
+
+alias TestServer $DIMDIR/$ODIR/testServer
+alias TestClient $DIMDIR/$ODIR/testClient
+alias Test_server $DIMDIR/$ODIR/test_server
+alias Test_client $DIMDIR/$ODIR/test_client
+alias Dns    $DIMDIR/$ODIR/dns
+alias Dim_get_service $DIMDIR/$ODIR/dim_get_service
+alias Dim_send_command $DIMDIR/$ODIR/dim_send_command
+alias DimBridge    $DIMDIR/$ODIR/DimBridge
+alias Did    $DIMDIR/$ODIR/did
+
+if (! -d $DIMDIR/$ODIR) then
+   mkdir $DIMDIR/$ODIR
+   echo Created Directory: $DIMDIR/$ODIR 
+endif
+exit
+
+
+
Index: /Evidence/DIM/dic.h
===================================================================
--- /Evidence/DIM/dic.h	(revision 127)
+++ /Evidence/DIM/dic.h	(revision 127)
@@ -0,0 +1,64 @@
+#ifndef __DICDEFS
+#define __DICDEFS
+
+#include "dim_common.h"
+
+/* part for CFORTRAN */
+
+#define dic_info_service dic_info_service_
+#define dic_info_service_stamped dic_info_service_stamped_
+#define dic_cmnd_service dic_cmnd_service_
+#define dic_cmnd_callback dic_cmnd_callback_
+#define dic_cmnd_service_stamped dic_cmnd_service_stamped_
+#define dic_cmnd_callback_stamped dic_cmnd_callback_stamped_
+#define dic_change_address dic_change_address_
+#define dic_release_service dic_release_service_
+#define dic_find_service dic_find_service_
+#define dic_get_id dic_get_id_
+#define dic_get_quality dic_get_quality_
+#define dic_get_timestamp dic_get_timestamp_
+#define dic_get_format dic_get_format_
+
+/* Routine definition */
+
+_DIM_PROTOE( unsigned dic_info_service, (char *service_name, int req_type,
+				    int req_timeout, void *service_address,
+				    int service_size, void (*usr_routine)(void*, void*, int*),
+				    long tag, void *fill_addr, int fill_size) );
+_DIM_PROTOE( unsigned dic_info_service_stamped, (char *service_name, int req_type,
+				    int req_timeout, void *service_address,
+				    int service_size, void (*usr_routine)(void*, void*, int*),
+				    long tag, void *fill_addr, int fill_size) );
+_DIM_PROTOE( int dic_cmnd_callback,      (char *service_name, void *service_address,
+				    int service_size, void (*usr_routine)(void*, int*),
+				    long tag) );
+_DIM_PROTOE( int dic_cmnd_service,      (char *service_name, void *service_address,
+				    int service_size) );
+_DIM_PROTOE( void dic_change_address,  (unsigned service_id, void *service_address,
+				    int service_size) );
+_DIM_PROTOE( void dic_release_service,  (unsigned service_id) );
+_DIM_PROTOE( int dic_find_service,      (char *service_name) );
+_DIM_PROTOE( int dic_get_id,      		(char *name) );
+_DIM_PROTOE( int dic_get_quality,  		(unsigned service_id) );
+_DIM_PROTOE( int dic_get_timestamp,  (unsigned service_id, int *secs, int *milisecs) );
+_DIM_PROTOE( char *dic_get_format,      		(unsigned service_id) );
+_DIM_PROTOE( void dic_disable_padding,      		() );
+_DIM_PROTOE( void dic_close_dns,      		() );
+_DIM_PROTOE( void dic_add_error_handler,(void (*usr_routine)(int, int, char*)) );
+_DIM_PROTOE( char *dic_get_error_services,	() );
+_DIM_PROTOE( char *dic_get_server_services,	(int conn_id) );
+_DIM_PROTOE( int dic_get_server,       (char *name ) );
+_DIM_PROTOE( int dic_get_conn_id,      () );
+_DIM_PROTOE( void dic_stop,      () );
+_DIM_PROTOE( int dic_get_server_pid,       (int *pid ) );
+
+#endif
+
+
+
+
+
+
+
+
+
Index: /Evidence/DIM/dic.hxx
===================================================================
--- /Evidence/DIM/dic.hxx	(revision 127)
+++ /Evidence/DIM/dic.hxx	(revision 127)
@@ -0,0 +1,493 @@
+#ifndef __DICHHDEFS
+#define __DICHHDEFS
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef WIN32
+#include <unistd.h>
+#endif
+#ifdef __VMS
+#include <starlet.h>
+#endif
+#include "dim_core.hxx"
+#include "dim.hxx"
+#include "tokenstring.hxx"
+
+enum DimServiceType {DimSERVICE=1, DimCOMMAND, DimRPC};
+
+class DimClient;
+class DimInfo;
+class DimCurrentInfo;
+class DimRpcInfo;
+
+class DllExp DimInfoHandler{
+public:
+	DimInfo *itsService;
+    DimInfo *getInfo() { return itsService; }; 
+	virtual void infoHandler() = 0;
+	virtual ~DimInfoHandler() {};
+};
+
+class DllExp DimInfo : public DimInfoHandler, public DimTimer{
+
+public :
+	DimInfoHandler *itsHandler;
+
+	DimInfo(){};
+	DimInfo(const char *name, int nolink) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(int), 0); };
+	DimInfo(const char *name, int time, int nolink) 
+		{ subscribe((char *)name, time, &nolink, sizeof(int), 0); };
+	DimInfo(const char *name, float nolink) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(float), 0); };
+	DimInfo(const char *name, int time, float nolink) 
+		{ subscribe((char *)name, time, &nolink, sizeof(float), 0); };
+	DimInfo(const char *name, double nolink) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(double), 0); };
+	DimInfo(const char *name, int time, double nolink) 
+		{ subscribe((char *)name, time, &nolink, sizeof(double), 0); };
+	DimInfo(const char *name, longlong nolink) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(longlong), 0); };
+	DimInfo(const char *name, int time, longlong nolink) 
+		{ subscribe((char *)name, time, &nolink, sizeof(longlong), 0); };
+	DimInfo(const char *name, short nolink) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(short), 0); };
+	DimInfo(const char *name, int time, short nolink) 
+		{ subscribe((char *)name, time, &nolink, sizeof(short), 0); };
+	DimInfo(const char *name, char *nolink) 
+		{ subscribe((char *)name, 0, nolink, strlen(nolink)+1, 0); };
+	DimInfo(const char *name, int time, char *nolink) 
+		{ subscribe((char *)name, time, nolink, strlen(nolink)+1, 0); };
+	DimInfo(const char *name, void *nolink, int nolinksize) 
+		{ subscribe((char *)name, 0, nolink, nolinksize, 0); };
+	DimInfo(const char *name, int time, void *nolink, int nolinksize) 
+		{ subscribe((char *)name, time, nolink, nolinksize, 0); };
+
+	DimInfo(const char *name, int nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(int), handler); };
+	DimInfo(const char *name, int time, int nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, time, &nolink, sizeof(int), handler); };
+	DimInfo(const char *name, float nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(float), handler); };
+	DimInfo(const char *name, int time, float nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, time, &nolink, sizeof(float), handler); };
+	DimInfo(const char *name, double nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(double), handler); };
+	DimInfo(const char *name, int time, double nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, time, &nolink, sizeof(double), handler); };
+	DimInfo(const char *name, longlong nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(longlong), handler); };
+	DimInfo(const char *name, int time, longlong nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, time, &nolink, sizeof(longlong), handler); };
+	DimInfo(const char *name, short nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, 0, &nolink, sizeof(short), handler); };
+	DimInfo(const char *name, int time, short nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, time, &nolink, sizeof(short), handler); };
+	DimInfo(const char *name, char *nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, 0, nolink, strlen(nolink)+1, handler); };
+	DimInfo(const char *name, int time, char *nolink, DimInfoHandler *handler) 
+		{ subscribe((char *)name, time, nolink, strlen(nolink)+1, handler); };
+	DimInfo(const char *name, void *nolink, int nolinksize, DimInfoHandler *handler) 
+		{ subscribe((char *)name, 0, nolink, nolinksize, handler); };
+	DimInfo(const char *name, int time, void *nolink, int nolinksize, DimInfoHandler *handler) 
+		{ subscribe((char *)name, time, nolink, nolinksize, handler); };
+
+	virtual ~DimInfo();
+	void *itsData;
+	int itsDataSize;
+	int itsSize;
+	int getSize() {return itsSize; };
+	char *getName()  { return itsName; } ;
+	void *getData();
+	int getInt() { return *(int *)getData(); } ;
+	float getFloat() { return *(float *)getData(); } ;
+	double getDouble() { return *(double *)getData(); } ;
+	longlong getLonglong() { return *(longlong *)getData(); } ;
+	short getShort() { return *(short *)getData(); } ;
+	char *getString()  { return (char *)getData(); } ;
+
+	virtual void infoHandler();
+	void timerHandler();
+	virtual void subscribe(char *name, int time, void *nolink, int nolinksize,
+		DimInfoHandler *handler);
+	virtual void doIt();
+	int getQuality();
+	int getTimestamp();
+	int getTimestampMillisecs();
+	char *getFormat();
+
+protected :
+	char *itsName;
+	int itsId;
+	int itsTime;
+	int itsType;
+	int itsTagId;
+	char *itsFormat;
+	void *itsNolinkBuf;
+	int itsNolinkSize;
+	int secs, milisecs;
+};
+
+class DllExp DimStampedInfo : public DimInfo{
+
+public :
+	DimStampedInfo(){};
+	DimStampedInfo(const char *name, int nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(int), 0); };
+	DimStampedInfo(const char *name, int time, int nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(int), 0); };
+	DimStampedInfo(const char *name, float nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(float), 0); };
+	DimStampedInfo(const char *name, int time, float nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(float), 0); };
+	DimStampedInfo(const char *name, double nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(double), 0); };
+	DimStampedInfo(const char *name, int time, double nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(double), 0); };
+	DimStampedInfo(const char *name, longlong nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(longlong), 0); };
+	DimStampedInfo(const char *name, int time, longlong nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(longlong), 0); };
+	DimStampedInfo(const char *name, short nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(short), 0); };
+	DimStampedInfo(const char *name, int time, short nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(short), 0); };
+	DimStampedInfo(const char *name, char *nolink) 
+	{ subscribe((char *)name, 0, nolink, strlen(nolink)+1, 0); };
+	DimStampedInfo(const char *name, int time, char *nolink) 
+	{ subscribe((char *)name, time, nolink, strlen(nolink)+1, 0); };
+	DimStampedInfo(const char *name, void *nolink, int nolinksize) 
+	{ subscribe((char *)name, 0, nolink, nolinksize, 0); };
+	DimStampedInfo(const char *name, int time, void *nolink, int nolinksize) 
+	{ subscribe((char *)name, time, nolink, nolinksize, 0); };
+
+	DimStampedInfo(const char *name, int nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(int), handler); };
+	DimStampedInfo(const char *name, int time, int nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(int), handler); };
+	DimStampedInfo(const char *name, float nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(float), handler); };
+	DimStampedInfo(const char *name, int time, float nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(float), handler); };
+	DimStampedInfo(const char *name, double nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(double), handler); };
+	DimStampedInfo(const char *name, int time, double nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(double), handler); };
+	DimStampedInfo(const char *name, longlong nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(longlong), handler); };
+	DimStampedInfo(const char *name, int time, longlong nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(longlong), handler); };
+	DimStampedInfo(const char *name, short nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(short), handler); };
+	DimStampedInfo(const char *name, int time, short nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(short), handler); };
+		DimStampedInfo(const char *name, char *nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, nolink, strlen(nolink)+1, handler); };
+	DimStampedInfo(const char *name, int time, char *nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, nolink, strlen(nolink)+1, handler); };
+	DimStampedInfo(const char *name, void *nolink, int nolinksize, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, nolink, nolinksize, handler); };
+	DimStampedInfo(const char *name, int time, void *nolink, int nolinksize, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, nolink, nolinksize, handler); };
+
+	virtual ~DimStampedInfo();
+private :
+	void doIt();
+	void subscribe(char *name, int time, void *nolink, int nolinksize,
+		DimInfoHandler *handler);
+};
+
+class DllExp DimUpdatedInfo : public DimInfo{
+
+public :
+	DimUpdatedInfo(){};
+	DimUpdatedInfo(const char *name, int nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(int), 0); };
+	DimUpdatedInfo(const char *name, int time, int nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(int), 0); };
+	DimUpdatedInfo(const char *name, float nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(float), 0); };
+	DimUpdatedInfo(const char *name, int time, float nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(float), 0); };
+	DimUpdatedInfo(const char *name, double nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(double), 0); };
+	DimUpdatedInfo(const char *name, int time, double nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(double), 0); };
+	DimUpdatedInfo(const char *name, longlong nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(longlong), 0); };
+	DimUpdatedInfo(const char *name, int time, longlong nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(longlong), 0); };
+	DimUpdatedInfo(const char *name, short nolink) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(short), 0); };
+	DimUpdatedInfo(const char *name, int time, short nolink) 
+	{ subscribe((char *)name, time, &nolink, sizeof(short), 0); };
+	DimUpdatedInfo(const char *name, char *nolink) 
+	{ subscribe((char *)name, 0, nolink, strlen(nolink)+1, 0); };
+	DimUpdatedInfo(const char *name, int time, char *nolink) 
+	{ subscribe((char *)name, time, nolink, strlen(nolink)+1, 0); };
+	DimUpdatedInfo(const char *name, void *nolink, int nolinksize) 
+	{ subscribe((char *)name, 0, nolink, nolinksize, 0); };
+	DimUpdatedInfo(const char *name, int time, void *nolink, int nolinksize) 
+	{ subscribe((char *)name, time, nolink, nolinksize, 0); };
+
+	DimUpdatedInfo(const char *name, int nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(int), handler); };
+	DimUpdatedInfo(const char *name, int time, int nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(int), handler); };
+	DimUpdatedInfo(const char *name, float nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(float), handler); };
+	DimUpdatedInfo(const char *name, int time, float nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(float), handler); };
+	DimUpdatedInfo(const char *name, double nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(double), handler); };
+	DimUpdatedInfo(const char *name, int time, double nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(double), handler); };
+	DimUpdatedInfo(const char *name, longlong nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(longlong), handler); };
+	DimUpdatedInfo(const char *name, int time, longlong nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(longlong), handler); };
+	DimUpdatedInfo(const char *name, short nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, &nolink, sizeof(short), handler); };
+	DimUpdatedInfo(const char *name, int time, short nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, &nolink, sizeof(short), handler); };
+	DimUpdatedInfo(const char *name, char *nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, nolink, strlen(nolink)+1, handler); };
+	DimUpdatedInfo(const char *name, int time, char *nolink, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, nolink, strlen(nolink)+1, handler); };
+	DimUpdatedInfo(const char *name, void *nolink, int nolinksize, DimInfoHandler *handler) 
+	{ subscribe((char *)name, 0, nolink, nolinksize, handler); };
+	DimUpdatedInfo(const char *name, int time, void *nolink, int nolinksize, DimInfoHandler *handler) 
+	{ subscribe((char *)name, time, nolink, nolinksize, handler); };
+
+	virtual ~DimUpdatedInfo();
+private :
+	void doIt();
+	void subscribe(char *name, int time, void *nolink, int nolinksize,
+		DimInfoHandler *handler);
+};
+
+class DllExp DimCmnd {
+public :
+
+	int wakeUp;
+	int result;
+	int send(char *name, void *data, int datasize);
+	void sendNB(char *name, void *data, int datasize);
+  DimCmnd(){};
+};
+
+class DllExp DimCurrentInfo {
+
+public :
+	void *itsData;
+	int itsDataSize;
+	int itsSize;
+	int itsTagId;
+	int wakeUp;
+
+	DimCurrentInfo(const char *name, int nolink) { 
+		subscribe((char *)name, 0, &nolink, sizeof(int)); };
+	DimCurrentInfo(const char *name, float nolink) { 
+		subscribe((char *)name, 0, &nolink, sizeof(float)); };
+	DimCurrentInfo(const char *name, double nolink) { 
+		subscribe((char *)name, 0, &nolink, sizeof(double)); };
+	DimCurrentInfo(const char *name, longlong nolink) { 
+		subscribe((char *)name, 0, &nolink, sizeof(longlong)); };
+	DimCurrentInfo(const char *name, short nolink) { 
+		subscribe((char *)name, 0, &nolink, sizeof(short)); };
+	DimCurrentInfo(const char *name, char *nolink) { 
+		subscribe((char *)name, 0, nolink, strlen(nolink)+1); };
+	DimCurrentInfo(const char *name, void *nolink, int nolinksize) { 
+		subscribe((char *)name, 0, nolink, nolinksize); };
+	DimCurrentInfo(const char *name, int time, int nolink) { 
+		subscribe((char *)name, time, &nolink, sizeof(int)); };
+	DimCurrentInfo(const char *name, int time, float nolink) { 
+		subscribe((char *)name, time, &nolink, sizeof(float)); };
+	DimCurrentInfo(const char *name, int time, double nolink) { 
+		subscribe((char *)name, time, &nolink, sizeof(double)); };
+	DimCurrentInfo(const char *name, int time, longlong nolink) { 
+		subscribe((char *)name, time, &nolink, sizeof(longlong)); };
+	DimCurrentInfo(const char *name, int time, short nolink) { 
+		subscribe((char *)name, time, &nolink, sizeof(short)); };
+	DimCurrentInfo(const char *name, int time, char *nolink) { 
+		subscribe((char *)name, time, nolink, strlen(nolink)+1); };
+	DimCurrentInfo(const char *name, int time, void *nolink, int nolinksize) { 
+		subscribe((char *)name, time, nolink, nolinksize); };
+
+
+	virtual ~DimCurrentInfo();
+	char *getName()  { return itsName; } ;
+	void *getData();
+	int getInt() { return *(int *)getData(); } ;
+	float getFloat() { return *(float *)getData(); } ;
+	double getDouble() { return *(double *)getData(); } ;
+	longlong getLonglong() { return *(longlong *)getData(); } ;
+	short getShort() { return *(short *)getData(); } ;
+	char *getString()  { return (char *)getData(); } ;
+	int getSize()  { getData(); return itsSize; } ;
+
+private :
+	char *itsName;
+	void *itsNolinkBuf;
+	int itsNolinkSize;
+	void subscribe(char *name, int time, void *nolink, int nolinksize);
+};
+
+class DllExp DimRpcInfo : public DimTimer {
+public :
+	int itsId;
+	int itsTagId;
+	int itsInit;
+	void *itsData;
+	int itsDataSize;
+	void *itsDataOut;
+	int itsDataOutSize;
+	int itsSize;
+	int wakeUp;
+	int itsWaiting;
+	int itsConnected;
+	void *itsNolinkBuf;
+	int itsNolinkSize;
+	DimRpcInfo *itsHandler;
+
+	DimRpcInfo(const char *name, int nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(int), 0); };
+	DimRpcInfo(const char *name, float nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(float), 0); };
+	DimRpcInfo(const char *name, double nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(double), 0); };
+	DimRpcInfo(const char *name, longlong nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(longlong), 0); };
+	DimRpcInfo(const char *name, short nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(short), 0); };
+	DimRpcInfo(const char *name, char *nolink) { 
+		subscribe((char *)name, 0, 0, nolink, strlen(nolink)+1, 0); };
+	DimRpcInfo(const char *name, void *nolink, int nolinksize) { 
+		subscribe((char *)name, 0, 0, nolink, nolinksize, 0); };
+
+	DimRpcInfo(const char *name, int time, int nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(int), time); };
+	DimRpcInfo(const char *name, int time, float nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(float), time); };
+	DimRpcInfo(const char *name, int time, double nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(double), time); };
+	DimRpcInfo(const char *name, int time, longlong nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(longlong), time); };
+	DimRpcInfo(const char *name, int time, short nolink) { 
+		subscribe((char *)name, 0, 0, &nolink, sizeof(short), time); };
+	DimRpcInfo(const char *name, int time, char *nolink) { 
+		subscribe((char *)name, 0, 0, nolink, strlen(nolink)+1, time); };
+	DimRpcInfo(const char *name, int time, void *nolink, int nolinksize) { 
+		subscribe((char *)name, 0, 0, nolink, nolinksize, time); };
+	
+	virtual void rpcInfoHandler();
+
+	virtual ~DimRpcInfo();
+	int getId() {return itsId;};
+	void keepWaiting() {itsWaiting = 2;};
+	char *getName()  { return itsName; } ;
+	void *getData();
+	int getInt() { return *(int *)getData(); } ;
+	float getFloat() { return *(float *)getData(); } ;
+	double getDouble() { return *(double *)getData(); } ;
+	longlong getLonglong() { return *(longlong *)getData(); } ;
+	short getShort() { return *(short *)getData(); } ;
+	char *getString()  { return (char *)getData(); } ;
+	int getSize()  { getData(); return itsSize; } ;
+
+	void setData(void *data, int size) { doIt(data, size); };
+	void setData(int &data) { doIt(&data, sizeof(int)); } ;
+	void setData(float &data) { doIt(&data, sizeof(float)); } ;
+	void setData(double &data) { doIt(&data, sizeof(double)); } ;
+	void setData(longlong &data) { doIt(&data, sizeof(longlong)); } ;
+	void setData(short &data) { doIt(&data, sizeof(short)); } ;
+	void setData(char *data)  { doIt(data, strlen(data)+1); } ;
+
+private :
+	char *itsName;
+	char *itsNameIn;
+	char *itsNameOut;
+	int itsTimeout;
+	void subscribe(char *name, void *data, int size, 
+		void *nolink, int nolinksize, int timeout);
+	void doIt(void *data, int size);
+	void timerHandler();
+};
+
+class DllExp DimClient : public DimInfoHandler, public DimErrorHandler
+{
+public:
+
+	static char *dimDnsNode;
+	static DimErrorHandler *itsCltError;
+
+	DimClient();
+	virtual ~DimClient();
+	static int sendCommand(const char *name, int data);
+	static int sendCommand(const char *name, float data);
+	static int sendCommand(const char *name, double data);
+	static int sendCommand(const char *name, longlong data);
+	static int sendCommand(const char *name, short data);
+	static int sendCommand(const char *name, const char *data);
+	static int sendCommand(const char *name, void *data, int datasize);
+	static void sendCommandNB(const char *name, int data);
+	static void sendCommandNB(const char *name, float data);
+	static void sendCommandNB(const char *name, double data);
+	static void sendCommandNB(const char *name, longlong data);
+	static void sendCommandNB(const char *name, short data);
+	static void sendCommandNB(const char *name, char *data);
+	static void sendCommandNB(const char *name, void *data, int datasize);
+	static int setExitHandler(const char *serverName);
+	static int killServer(const char *serverName);
+	static int setDnsNode(const char *node);
+	static int setDnsNode(const char *node, int port);
+	static char *getDnsNode();
+	static int getDnsPort();
+	static void addErrorHandler(DimErrorHandler *handler);
+	void addErrorHandler();
+	virtual void errorHandler(int /* severity */, int /* code */, char* /* msg */) {};
+	static char *serverName;
+	// Get Current Server Identifier	
+	static int getServerId();
+	// Get Current Server Process Identifier	
+	static int getServerPid();
+	// Get Current Server Name	
+	static char *getServerName();
+	static char **getServerServices();
+//	static char *getServerServices(int serverId);
+
+	virtual void infoHandler() {};
+
+	static int dicNoCopy;
+	static void setNoDataCopy();
+	static int getNoDataCopy();
+};
+
+class DllExp DimBrowser
+{
+public :
+
+	DimBrowser();
+
+	~DimBrowser();
+
+	int getServices(const char *serviceName);
+	int getServers();
+	int getServerServices(const char *serverName);
+	int getServerClients(const char *serverName);
+	int getNextService(char *&service, char *&format);
+	int getNextServer(char *&server, char *&node);
+	int getNextServer(char *&server, char *&node, int &pid);
+	int getNextServerService(char *&service, char *&format);
+	int getNextServerClient(char *&client, char *&node);
+
+private:
+
+	TokenString *itsData[5];
+	int currIndex; 
+	char *currToken;
+	char none;
+	DimRpcInfo *browserRpc;
+};
+
+#endif
Index: /Evidence/DIM/dim.h
===================================================================
--- /Evidence/DIM/dim.h	(revision 127)
+++ /Evidence/DIM/dim.h	(revision 127)
@@ -0,0 +1,591 @@
+#ifndef __DIMDEFS
+#define __DIMDEFS
+/*
+ * DNA (Delphi Network Access) implements the network layer for the DIM
+ * (Delphi Information Managment) System.
+ *
+ * Started           : 10-11-91
+ * Last modification : 03-08-94
+ * Written by        : C. Gaspar
+ * Adjusted by       : G.C. Ballintijn
+ *
+ */
+
+#include "dim_common.h"
+
+#define DIM_VERSION_NUMBER 1907
+
+#define MY_LITTLE_ENDIAN	0x1
+#define MY_BIG_ENDIAN 		0x2
+
+#define VAX_FLOAT		0x10
+#define IEEE_FLOAT 		0x20
+#define AXP_FLOAT		0x30
+
+#define MY_OS9			0x100
+#define IT_IS_FLOAT		0x1000
+
+#ifdef VMS
+#include <ssdef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <starlet.h>
+#include <time.h>
+#define DIM_NOSHARE noshare
+#define RE_ENABLE_AST   long int ast_enable = sys$setast(1);
+#define RE_DISABLE_AST  if (ast_enable != SS$_WASSET) sys$setast(0);
+#define	vtohl(l)	(l)
+#define	htovl(l)	(l)
+#ifdef __alpha
+#define MY_FORMAT MY_LITTLE_ENDIAN+AXP_FLOAT
+#else
+#define MY_FORMAT MY_LITTLE_ENDIAN+VAX_FLOAT
+#endif
+#endif
+
+#ifdef __unix__
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#ifdef VxWorks
+#include <sigLib.h>
+#endif
+#define DIM_NOSHARE 
+#define RE_ENABLE_AST   sigset_t set, oset;sigemptyset(&set);sigaddset(&set,SIGIO);sigaddset(&set,SIGALRM);sigprocmask(SIG_UNBLOCK,&set,&oset);
+#define RE_DISABLE_AST  sigprocmask(SIG_SETMASK,&oset,0);
+#ifdef MIPSEL
+#define	vtohl(l)	(l)
+#define	htovl(l)	(l)
+#define MY_FORMAT MY_LITTLE_ENDIAN+IEEE_FLOAT
+#endif
+#ifdef MIPSEB
+#define	vtohl(l)	_swapl(l)
+#define	htovl(l)	_swapl(l)
+#define	vtohs(s)	_swaps(s)
+#define	htovs(s)	_swaps(s)
+#define MY_FORMAT MY_BIG_ENDIAN+IEEE_FLOAT
+#endif
+_DIM_PROTO( int _swapl,  (int l) );
+_DIM_PROTO( short _swaps,   (short s) );
+
+#endif
+
+#ifdef WIN32
+#include <windows.h>
+#include <process.h>
+#include <io.h>
+#include <fcntl.h>
+#include <Winsock.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#define DIM_NOSHARE 
+#define RE_ENABLE_AST     
+#define RE_DISABLE_AST    
+#ifdef MIPSEL
+#define	vtohl(l)	(l)
+#define	htovl(l)	(l)
+#define MY_FORMAT MY_LITTLE_ENDIAN+IEEE_FLOAT
+#endif
+#ifdef MIPSEB
+#define	vtohl(l)	_swapl(l)
+#define	htovl(l)	_swapl(l)
+#define	vtohs(s)	_swaps(s)
+#define	htovs(s)	_swaps(s)
+#define MY_FORMAT MY_BIG_ENDIAN+IEEE_FLOAT
+#endif
+_DIM_PROTO( int _swapl,  (int l) );
+_DIM_PROTO( short _swaps,   (short s) );
+#endif
+
+#ifdef OSK
+#include <types.h>
+#ifndef _UCC
+#include <machine/types.h>
+#else
+#define register
+#endif
+#include <inet/in.h>
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+#define DIM_NOSHARE 
+#define RE_ENABLE_AST      sigmask(DEC_LEVEL);
+#define RE_DISABLE_AST     sigmask(INC_LEVEL);
+#define	vtohl(l)	_swapl(l)
+#define	htovl(l)	_swapl(l)
+#define	vtohs(s)	_swaps(s)
+#define	htovs(s)	_swaps(s)
+#define MY_FORMAT MY_BIG_ENDIAN+IEEE_FLOAT+MY_OS9
+typedef unsigned short	ushort;
+_DIM_PROTO( char *getenv,  (char *name) );
+_DIM_PROTO( void *malloc,  (unsigned size) );
+_DIM_PROTO( void *realloc, (void *ptr, unsigned size) );
+_DIM_PROTO( int _swapl,   (int l) );
+_DIM_PROTO( short _swaps,   (short s) );
+#endif
+
+#define	TRUE	1
+#define	FALSE	0
+
+#define DNS_TASK	"DIM_DNS"
+#define DNS_PORT	2505			/* Name server port          */
+#define SEEK_PORT	0			/* server should seek a port */
+
+#define MIN_BIOCNT	 	50
+#ifdef OSK
+#define DIS_DNS_TMOUT_MIN	5
+#define DIS_DNS_TMOUT_MAX	10
+#define DIC_DNS_TMOUT_MIN	5
+#define DIC_DNS_TMOUT_MAX	10
+#define MAX_SERVICE_UNIT 	32
+#define MAX_REGISTRATION_UNIT 100
+#define CONN_BLOCK		32
+#define MAX_CONNS		32
+#define ID_BLOCK		64
+#define TCP_RCV_BUF_SIZE	4096
+#define TCP_SND_BUF_SIZE	4096
+#else
+#define DIS_DNS_TMOUT_MIN	5
+#define DIS_DNS_TMOUT_MAX	10
+#define DIC_DNS_TMOUT_MIN	5
+#define DIC_DNS_TMOUT_MAX	10
+#define MAX_SERVICE_UNIT 	100
+#define MAX_REGISTRATION_UNIT 100
+#define CONN_BLOCK		256
+#define MAX_CONNS		1024
+#define ID_BLOCK		512
+#define TCP_RCV_BUF_SIZE	16384/*32768*//*65536*/
+#define TCP_SND_BUF_SIZE	16384/*32768*//*65536*/
+#endif
+#define DID_DNS_TMOUT_MIN	5
+#define DID_DNS_TMOUT_MAX	10
+/*
+#define WATCHDOG_TMOUT_MIN	120
+#define WATCHDOG_TMOUT_MAX	180
+*/
+#define WATCHDOG_TMOUT_MIN	60
+#define WATCHDOG_TMOUT_MAX	90
+/*
+#define WATCHDOG_TMOUT_MIN	15
+#define WATCHDOG_TMOUT_MAX	25
+*/
+#define MAX_NODE_NAME		40
+#define MAX_TASK_NAME		40
+#define MAX_NAME 		132
+/*
+#define MAX_CMND 		16384
+#define MAX_IO_DATA 	65535
+#define MAX_IO_DATA		(TCP_SND_BUF_SIZE - 16)
+*/
+typedef enum { DNS_DIS_REGISTER, DNS_DIS_KILL, DNS_DIS_STOP, 
+			   DNS_DIS_EXIT } DNS_DIS_TYPES;
+typedef enum { RD_HDR, RD_DATA, RD_DUMMY } CONN_STATE;
+typedef enum { NOSWAP, SWAPS, SWAPL, SWAPD} SWAP_TYPE;
+
+#define DECNET			0		/* Decnet as transport layer */
+#define TCPIP			1		/* Tcpip as transport layer  */
+#define BOTH			2		/* Both protocols allowed    */
+
+#define	STA_DISC		(-1)		/* Connection lost           */
+#define	STA_DATA		0		/* Data received             */
+#define	STA_CONN		1		/* Connection made           */
+
+#define	START_PORT_RANGE	5100		/* Lowest port to use        */
+#define	STOP_PORT_RANGE		10000		/* Highest port to use       */
+#define	TEST_TIME_OSK		15		/* Interval to test conn.    */
+#define	TEST_TIME_VMS		30		/* Interval to test conn.    */
+#define	TEST_WRITE_TAG		25		/* DTQ tag for test writes   */
+
+#define	OPN_MAGIC		0xc0dec0de	/* Magic value 1st packet    */
+#define	HDR_MAGIC		0xfeadfead	/* Magic value in header     */
+#define	LONG_HDR_MAGIC	0xfeadc0de	/* Magic value in long header*/
+#define	TST_MAGIC		0x11131517	/* Magic value, test write   */
+#define	TRP_MAGIC		0x71513111	/* Magic value, test reply   */
+
+/* String Format */
+
+typedef struct{
+	int par_num;
+	short par_bytes;
+	short flags;     /* bits 0-1 is type of swap, bit 4 id float conversion */
+}FORMAT_STR;
+
+/* Packet sent by the client to the server inside DNA */
+typedef struct{
+	int code;
+	char node[MAX_NODE_NAME];
+	char task[MAX_TASK_NAME];
+} DNA_NET;
+
+/* Packet sent by the client to the server */
+typedef struct{
+	int size;
+	char service_name[MAX_NAME];
+	int service_id;
+	int type;
+	int timeout;
+	int format;
+	int buffer[1];
+} DIC_PACKET;
+
+#define DIC_HEADER		(MAX_NAME + 20)
+
+/* Packets sent by the server to the client */
+typedef struct{
+	int size;
+	int service_id;
+	int buffer[1];
+} DIS_PACKET;
+
+#define DIS_HEADER		8
+
+typedef struct{
+	int size;
+	int service_id;
+	int time_stamp[2];
+	int quality;
+	int reserved[3];
+	int buffer[1];
+} DIS_STAMPED_PACKET;
+
+#define DIS_STAMPED_HEADER		32
+
+/* Packet sent by the server to the name_server */
+typedef struct{
+	char service_name[MAX_NAME];
+	int service_id;
+	char service_def[MAX_NAME];
+} SERVICE_REG;
+	
+typedef struct{
+	int size;
+	SRC_TYPES src_type;
+	char node_name[MAX_NODE_NAME];
+	char task_name[MAX_TASK_NAME-4];
+	char node_addr[4];
+	int pid;
+	int port;
+	int protocol;
+	int format;
+	int n_services;
+	SERVICE_REG services[MAX_SERVICE_UNIT];
+} DIS_DNS_PACKET;
+
+#define DIS_DNS_HEADER		(MAX_NODE_NAME + MAX_TASK_NAME + 28) 
+
+/* Packet sent by the name_server to the server */
+typedef struct {
+	int size;
+	int type;
+} DNS_DIS_PACKET;
+
+#define DNS_DIS_HEADER		8
+
+/* Packet sent by the client to the name_server */
+typedef struct{
+	char service_name[MAX_NAME];
+	int service_id;
+} SERVICE_REQ;
+	
+typedef struct{
+	int size;
+	SRC_TYPES src_type;
+	SERVICE_REQ service;
+} DIC_DNS_PACKET;
+
+/* Packet sent by the name_server to the client */
+typedef struct {
+	int size;
+	int service_id;
+	char service_def[MAX_NAME];
+	char node_name[MAX_NODE_NAME];
+	char task_name[MAX_TASK_NAME-4];
+	char node_addr[4];
+	int pid;
+	int port;
+	int protocol;
+	int format;
+} DNS_DIC_PACKET;
+
+#define DNS_DIC_HEADER		(MAX_NODE_NAME + MAX_TASK_NAME + MAX_NAME + 24) 
+
+typedef struct {
+	char name[MAX_NAME];
+	char node[MAX_NODE_NAME];
+	char task[MAX_TASK_NAME];
+	int type;
+	int status;
+	int n_clients;
+} DNS_SERV_INFO;
+
+typedef struct {
+	char name[MAX_NAME];
+	int type;
+	int status;
+	int n_clients;
+} DNS_SERVICE_INFO;
+
+typedef struct {
+	char node[MAX_NODE_NAME];
+	char task[MAX_TASK_NAME];
+	int pid;
+	int n_services;
+} DNS_SERVER_INFO;
+
+typedef struct {
+	DNS_SERVER_INFO server;
+	DNS_SERVICE_INFO services[1];
+} DNS_DID;
+
+typedef struct {
+	char node[MAX_NODE_NAME];
+	char task[MAX_TASK_NAME];
+} DNS_CLIENT_INFO;
+
+typedef struct {
+	int header_size;
+	int data_size;
+	int header_magic;
+} DNA_HEADER;
+
+typedef struct {
+	int header_size;
+	int data_size;
+	int header_magic;
+	int time_stamp[2];
+	int quality;
+} DNA_LONG_HEADER;
+
+/* Connection handling */
+
+typedef struct timer_entry{
+	struct timer_entry *next;
+	struct timer_entry *prev;
+	struct timer_entry *next_done;
+	int time;
+	int time_left;
+	void (*user_routine)();
+	long tag;
+} TIMR_ENT;
+
+typedef struct {
+	int busy;
+	void (*read_ast)();
+	void (*error_ast)();
+	int *buffer;
+	int buffer_size;
+	char *curr_buffer;
+	int curr_size;
+	int full_size;
+	int protocol;
+	CONN_STATE state;
+	int writing;
+	int saw_init;
+} DNA_CONNECTION;
+
+extern DllExp DIM_NOSHARE DNA_CONNECTION *Dna_conns;
+
+typedef struct {
+	int channel;
+	int mbx_channel;
+	void (*read_rout)();
+	char *buffer;
+	int size;
+	unsigned short *iosb_r;
+	unsigned short *iosb_w;
+	char node[MAX_NODE_NAME];
+	char task[MAX_TASK_NAME];
+	int port;
+	int reading;
+	int timeout;
+	TIMR_ENT *timr_ent;
+	time_t last_used;
+} NET_CONNECTION;
+ 
+extern DllExp DIM_NOSHARE NET_CONNECTION *Net_conns;
+
+typedef struct {
+	char node_name[MAX_NODE_NAME];
+	char task_name[MAX_TASK_NAME];
+	int port;
+	int pid;
+	char *service_head;
+} DIC_CONNECTION;
+
+extern DIM_NOSHARE DIC_CONNECTION *Dic_conns;
+
+typedef struct {
+	SRC_TYPES src_type;
+	char node_name[MAX_NODE_NAME];
+	char task_name[MAX_TASK_NAME-4];
+	char node_addr[4];
+	int pid;
+	int port;
+	char *service_head;
+	char *node_head;
+	int protocol;
+	int validity;
+	int n_services;
+	int old_n_services;
+	TIMR_ENT *timr_ent;
+	int already;
+	char long_task_name[MAX_TASK_NAME*2];
+} DNS_CONNECTION;
+
+extern DllExp DIM_NOSHARE DNS_CONNECTION *Dns_conns;
+
+extern DllExp DIM_NOSHARE int Curr_N_Conns;
+
+/* Client definitions needed by dim_jni.c (from H.Essel GSI) */
+typedef enum {
+	NOT_PENDING, WAITING_DNS_UP, WAITING_DNS_ANSWER, WAITING_SERVER_UP,
+	WAITING_CMND_ANSWER, DELETED
+} PENDING_STATES;
+
+typedef struct dic_serv {
+	struct dic_serv *next;
+	struct dic_serv *prev;
+	char serv_name[MAX_NAME];
+	int serv_id;
+	FORMAT_STR format_data[MAX_NAME/4];
+	char def[MAX_NAME];
+	int format;
+	int type;
+	int timeout;
+	int curr_timeout;
+	int *serv_address;
+	int serv_size;
+	int *fill_address;
+	int fill_size;
+	void (*user_routine)();
+	long tag;
+	TIMR_ENT *timer_ent;
+	int conn_id;
+	PENDING_STATES pending;
+	int tmout_done;
+	int stamped;
+	int time_stamp[2];
+	int quality;
+    int tid;
+} DIC_SERVICE;
+
+/* PROTOTYPES */
+
+/* DNA */
+_DIM_PROTOE( int dna_start_read,    (int conn_id, int size) );
+_DIM_PROTOE( void dna_test_write,   (int conn_id) );
+_DIM_PROTOE( int dna_write,         (int conn_id, void *buffer, int size) );
+_DIM_PROTOE( int dna_write_nowait,  (int conn_id, void *buffer, int size) );
+_DIM_PROTOE( int dna_open_server,   (char *task, void (*read_ast)(), int *protocol,
+				int *port, void (*error_ast)()) );
+_DIM_PROTOE( int dna_get_node_task, (int conn_id, char *node, char *task) );
+_DIM_PROTOE( int dna_open_client,   (char *server_node, char *server_task, int port,
+                                int server_protocol, void (*read_ast)(), void (*error_ast)(), SRC_TYPES src_type ));
+_DIM_PROTOE( int dna_close,         (int conn_id) );
+_DIM_PROTOE( void dna_report_error, (int conn_id, int code, char *routine_name) );
+
+
+/* TCPIP */
+_DIM_PROTOE( int tcpip_open_client,     (int conn_id, char *node, char *task,
+                                    int port) );
+_DIM_PROTOE( int tcpip_open_server,     (int conn_id, char *task, int *port) );
+_DIM_PROTOE( int tcpip_open_connection, (int conn_id, int channel) );
+_DIM_PROTOE( int tcpip_start_read,      (int conn_id, char *buffer, int size,
+                                    void (*ast_routine)()) );
+_DIM_PROTOE( int tcpip_start_listen,    (int conn_id, void (*ast_routine)()) );
+_DIM_PROTOE( int tcpip_write,           (int conn_id, char *buffer, int size) );
+_DIM_PROTOE( void tcpip_get_node_task,  (int conn_id, char *node, char *task) );
+_DIM_PROTOE( int tcpip_close,           (int conn_id) );
+_DIM_PROTOE( int tcpip_failure,         (int code) );
+_DIM_PROTOE( void tcpip_report_error,   (int code) );
+
+
+/* DTQ */
+_DIM_PROTOE( int dtq_create,          (void) );
+_DIM_PROTOE( int dtq_delete,          (int queue_id) );
+_DIM_PROTOE( TIMR_ENT *dtq_add_entry, (int queue_id, int time,
+                                  void (*user_routine)(), long tag) );
+_DIM_PROTOE( int dtq_clear_entry,     (TIMR_ENT *entry) );
+_DIM_PROTOE( int dtq_rem_entry,       (int queue_id, TIMR_ENT *entry) );
+
+/* UTIL */
+typedef struct dll {
+	struct dll *next;
+	struct dll *prev;
+	char user_info[1];
+} DLL;
+
+typedef struct sll {
+	struct sll *next;
+	char user_info[1];
+} SLL;
+
+_DIM_PROTO( void DimDummy,        () );     
+_DIM_PROTOE( void conn_arr_create, (SRC_TYPES type) );
+_DIM_PROTOE( int conn_get,         (void) );
+_DIM_PROTOE( void conn_free,       (int conn_id) );
+_DIM_PROTOE( void *arr_increase,   (void *conn_ptr, int conn_size, int n_conns) );
+_DIM_PROTOE( void id_arr_create,   () );
+_DIM_PROTOE( void *id_arr_increase,(void *id_ptr, int id_size, int n_ids) );
+
+_DIM_PROTOE( void dll_init,         ( DLL *head ) );
+_DIM_PROTOE( void dll_insert_queue, ( DLL *head, DLL *item ) );
+_DIM_PROTOE( void dll_insert_after, ( DLL *after, DLL *item ) );
+_DIM_PROTOE( DLL *dll_search,       ( DLL *head, char *data, int size ) );
+_DIM_PROTOE( DLL *dll_get_next,     ( DLL *head, DLL *item ) );
+_DIM_PROTOE( DLL *dll_get_prev,     ( DLL *head, DLL *item ) );
+_DIM_PROTOE( int dll_empty,         ( DLL *head ) );
+_DIM_PROTOE( void dll_remove,       ( DLL *item ) );
+
+_DIM_PROTOE( void sll_init,               ( SLL *head ) );
+_DIM_PROTOE( int sll_insert_queue,        ( SLL *head, SLL *item ) );
+_DIM_PROTOE( SLL *sll_search,             ( SLL *head, char *data, int size ) );
+_DIM_PROTOE( SLL *sll_get_next,           ( SLL *item ) );
+_DIM_PROTOE( int sll_empty,               ( SLL *head ) );
+_DIM_PROTOE( int sll_remove,              ( SLL *head, SLL *item ) );
+_DIM_PROTOE( SLL *sll_remove_head,        ( SLL *head ) );
+_DIM_PROTOE( SLL *sll_search_next_remove, ( SLL *item, int offset, char *data, int size ) );
+_DIM_PROTOE( SLL *sll_get_head, 		  ( SLL *head ) );
+
+_DIM_PROTOE( int HashFunction,         ( char *name, int max ) );
+
+_DIM_PROTOE( int copy_swap_buffer_out, (int format, FORMAT_STR *format_data, 
+					void *buff_out, void *buff_in, int size) );
+_DIM_PROTOE( int copy_swap_buffer_in, (FORMAT_STR *format_data, void *buff_out, 
+					void *buff_in, int size) );
+_DIM_PROTOE( int get_node_name, (char *node_name) );
+
+_DIM_PROTOE( int get_dns_port_number, () );
+
+_DIM_PROTOE( int get_dns_node_name, ( char *node_name ) );
+
+_DIM_PROTOE( int get_dns_accepted_domains, ( char *domains ) );
+_DIM_PROTOE( int get_dns_accepted_nodes, ( char *nodes ) );
+
+_DIM_PROTO( double _swapd_by_addr, (double *d) );
+_DIM_PROTO( int _swapl_by_addr, (int *l) );
+_DIM_PROTO( short _swaps_by_addr, (short *s) );
+_DIM_PROTO( void _swapd_buffer, (double *dout, double *din, int n) );
+_DIM_PROTO( void _swapl_buffer, (int *lout, int *lin, int n) );
+_DIM_PROTO( void _swaps_buffer, (short *sout, short *sin, int n) );
+
+#define SIZEOF_CHAR 1
+#define SIZEOF_SHORT 2
+#define SIZEOF_LONG 4
+#define SIZEOF_FLOAT 4
+#define SIZEOF_DOUBLE 8
+
+#if defined(OSK) && !defined(_UCC)
+#	define inc_pter(p,i) (char *)p += (i)
+#else
+#	define inc_pter(p,i) p = (void *)((char *)p + (i))
+#endif
+
+#endif
Index: /Evidence/DIM/dim.hxx
===================================================================
--- /Evidence/DIM/dim.hxx	(revision 127)
+++ /Evidence/DIM/dim.hxx	(revision 127)
@@ -0,0 +1,60 @@
+#ifndef DIM_HH
+#define DIM_HH
+
+#include "dim_common.h"
+#include "sllist.hxx"
+#include "dllist.hxx"
+
+class DimCore
+{
+public:
+	static int inCallback;
+};
+
+class DllExp DimErrorHandler{
+public:
+	virtual void errorHandler(int severity, int code, char *msg) = 0;
+	virtual ~DimErrorHandler() {};
+};
+
+class DllExp DimTimer
+{
+public:
+	int firedFlag;
+	int runningFlag;
+	DimTimer();
+	DimTimer(int time);
+	virtual ~DimTimer();
+	int start(int time);
+	int stop();
+	int fired() { return firedFlag;}; 
+	void clear() { firedFlag = 0;};
+	virtual void timerHandler() { };
+};
+
+class DllExp DimThread
+{
+public:
+	long itsId;
+	DimThread();
+	virtual ~DimThread();
+	int start();
+//	int stop();
+//	void start(int time);
+//	int stop();
+//	int fired() { return firedFlag;}; 
+//	void clear() { firedFlag = 0;};
+	virtual void threadHandler() { };
+};
+
+class DllExp DimUtil
+{
+public:
+	static char *getEnvVar(char *varName);
+	DimUtil();
+	~DimUtil();
+	static char *itsBuffer;
+	static int itsBufferSize;
+};
+
+#endif
Index: /Evidence/DIM/dim_common.h
===================================================================
--- /Evidence/DIM/dim_common.h	(revision 127)
+++ /Evidence/DIM/dim_common.h	(revision 127)
@@ -0,0 +1,264 @@
+#ifndef __COMMONDEFS
+#define __COMMONDEFS
+
+/* Service type definition */
+
+#ifndef ONCE_ONLY
+#define ONCE_ONLY	0x01
+#define TIMED		0x02
+#define MONITORED	0x04
+#define COMMAND		0x08
+#define DIM_DELETE	0x10
+#define MONIT_ONLY	0x20
+#define UPDATE 		0x40
+#define TIMED_ONLY	0x80
+#define MONIT_FIRST 0x100
+#define MAX_TYPE_DEF    0x100
+#define STAMPED       0x1000
+
+typedef enum { SRC_NONE, SRC_DIS, SRC_DIC, SRC_DNS, SRC_DNA, SRC_USR }SRC_TYPES;
+
+#ifdef __APPLE__
+#ifndef unix
+#define unix
+#endif
+#endif
+
+#ifdef __Lynx__
+#ifndef unix
+#define unix
+#endif
+#endif
+
+#ifdef unix
+#ifndef __unix__
+#define __unix__
+#endif
+#endif
+
+#ifdef linux
+#ifndef __linux__
+#define __linux__
+#endif
+#endif
+
+#ifdef WIN32
+typedef __int64		longlong;
+#elif defined(__linux__)
+typedef long long int longlong;
+#else
+#include <sys/types.h> 
+typedef int64_t	longlong;
+#endif
+
+#endif
+
+#ifndef OSK
+#	ifdef _OSK
+#		define OSK
+#	endif
+#endif
+
+
+#ifdef __VMS
+#define VMS
+#endif
+
+#ifndef _DIM_PROTO
+#ifndef OSK		/* Temorary hack */
+#	if defined(__cplusplus) /* || (__STDC__ == 1) || defined(_ANSI_EXT) || defined(ultrix) */
+#		define	_DIM_PROTO(func,param)	func param
+#	else
+#		define _DIM_PROTO(func,param)	func ()
+#	endif
+#else
+#	define _DIM_PROTO(func,param)	func ()
+#endif
+#ifdef WIN32
+#ifdef DIMLIB
+#	define _DIM_PROTOE(func,param) __declspec(dllexport) _DIM_PROTO(func,param)
+#	define DllExp __declspec(dllexport)
+#else
+#	define _DIM_PROTOE(func,param) __declspec(dllimport) _DIM_PROTO(func,param)
+#	define DllExp __declspec(dllimport)
+#endif
+#else
+#	define _DIM_PROTOE(func,param) _DIM_PROTO(func,param)
+#	define DllExp
+#endif
+#endif
+
+#if defined (hpux) || defined (__osf__) || defined(_AIX)  || defined(WIN32)
+#ifndef NOTHREADS
+#define NOTHREADS
+#endif
+#endif
+
+#ifndef VMS
+#ifndef WIN32
+#ifdef NOTHREADS
+#ifndef DIMLIB
+#ifndef sleep
+#define sleep(t) dtq_sleep(t)
+#endif
+#endif
+#endif
+#endif
+#endif
+
+#ifdef VMS
+#include <ssdef.h>
+#define DISABLE_AST     long int ast_enable = sys$setast(0);
+#define ENABLE_AST      if (ast_enable == SS$_WASSET) sys$setast(1);
+#define dim_enable()    sys$setast(1);
+#endif
+
+#ifdef __unix__
+#include <signal.h>
+#include <unistd.h>
+
+#define DISABLE_AST     sigset_t set, oset; sigemptyset(&set);\
+						sigaddset(&set,SIGIO);\
+						sigaddset(&set,SIGALRM);\
+						sigprocmask(SIG_BLOCK,&set,&oset);\
+						DIM_LOCK
+#define ENABLE_AST      DIM_UNLOCK sigprocmask(SIG_SETMASK,&oset,0);
+
+#ifdef VxWorks
+#define DIM_LOCK taskLock();
+#define DIM_UNLOCK taskUnlock();
+#else
+
+#ifndef NOTHREADS
+#include <pthread.h>
+
+_DIM_PROTOE( void dim_lock,		() );
+_DIM_PROTOE( void dim_unlock,	() );
+_DIM_PROTOE( void dim_wait_cond,		() );
+_DIM_PROTOE( void dim_signal_cond,	() );
+
+#define DIM_LOCK 	dim_lock();
+#define DIM_UNLOCK	dim_unlock();
+
+#else
+#define DIM_LOCK
+#define DIM_UNLOCK
+#endif
+#endif
+#endif
+#ifdef OSK
+#define INC_LEVEL               1
+#define DEC_LEVEL               (-1)
+#define DISABLE_AST     sigmask(INC_LEVEL);
+#define ENABLE_AST      sigmask(DEC_LEVEL);
+#endif
+
+
+_DIM_PROTOE( int id_get,           (void *ptr, int type) );
+_DIM_PROTOE( void id_free,         (int id, int type) );
+_DIM_PROTOE( void *id_get_ptr,     (int id, int type) );
+
+_DIM_PROTOE( unsigned int dtq_sleep,	(unsigned int secs) );
+_DIM_PROTOE( void dtq_start_timer,      (int secs, void(*rout)(void*), void *tag) );
+_DIM_PROTOE( int dtq_stop_timer,		(void *tag) );
+_DIM_PROTOE( void dim_init,				() );
+_DIM_PROTOE( void dim_no_threads,		() );
+_DIM_PROTOE( void dna_set_test_write,	(int conn_id, int time) );
+_DIM_PROTOE( void dna_rem_test_write,	(int conn_id) );
+_DIM_PROTOE( int dim_set_dns_node,		(char *node) );
+_DIM_PROTOE( int dim_get_dns_node,		(char *node) );
+_DIM_PROTOE( int dim_set_dns_port,		(int port) );
+_DIM_PROTOE( int dim_get_dns_port,		() );
+_DIM_PROTOE( void dic_set_debug_on,		() );
+_DIM_PROTOE( void dic_set_debug_off,	() );
+_DIM_PROTOE( void dim_print_msg,		(char *msg, int severity) );
+_DIM_PROTOE( void dim_print_date_time,		() );
+_DIM_PROTOE( void dim_set_write_timeout,		(int secs) );
+_DIM_PROTOE( int dim_get_write_timeout,		() );
+_DIM_PROTOE( void dim_usleep,	(unsigned int t) );
+_DIM_PROTOE( int dim_wait,		(void) );
+_DIM_PROTOE( int dim_get_priority,		(int dim_thread, int prio) );
+_DIM_PROTOE( int dim_set_priority,		(int dim_thread, int *prio) );
+_DIM_PROTOE( int dim_set_scheduler_class,		(int sched_class) );
+_DIM_PROTOE( int dim_get_scheduler_class,		(int *sched_class) );
+_DIM_PROTOE( long dim_start_thread,    (void(*rout)(void*), void *tag) );
+_DIM_PROTOE( int dic_set_dns_node,		(char *node) );
+_DIM_PROTOE( int dic_get_dns_node,		(char *node) );
+_DIM_PROTOE( int dic_set_dns_port,		(int port) );
+_DIM_PROTOE( int dic_get_dns_port,		() );
+_DIM_PROTOE( int dis_set_dns_node,		(char *node) );
+_DIM_PROTOE( int dis_get_dns_node,		(char *node) );
+_DIM_PROTOE( int dis_set_dns_port,		(int port) );
+_DIM_PROTOE( int dis_get_dns_port,		() );
+_DIM_PROTOE( void dim_stop,				() );
+_DIM_PROTOE( int dim_stop_thread,		(long tid) );
+_DIM_PROTOE( long dis_add_dns,		(char *node, int port) );
+_DIM_PROTOE( long dic_add_dns,		(char *node, int port) );
+_DIM_PROTOE( int dim_get_env_var,		(char *env_var, char *value, int value_size) );
+_DIM_PROTOE( int dim_set_write_buffer_size,		(int bytes) );
+_DIM_PROTOE( int dim_get_write_buffer_size,		() );
+_DIM_PROTOE( int dim_set_read_buffer_size,		(int bytes) );
+_DIM_PROTOE( int dim_get_read_buffer_size,		() );
+
+#ifdef WIN32
+#define getpid _getpid
+_DIM_PROTOE( void dim_pause,		() );
+_DIM_PROTOE( void dim_wake_up,	() );
+_DIM_PROTOE( void dim_lock,		() );
+_DIM_PROTOE( void dim_unlock,	() );
+_DIM_PROTOE( void dim_sleep,	(unsigned int t) );
+_DIM_PROTOE( void dim_win_usleep,	(unsigned int t) );
+#define sleep(t)	dim_sleep(t);
+#define usleep(t)	dim_win_usleep(t);
+#define pause() 	dim_pause();
+#define wake_up()	dim_wake_up();
+#define DIM_LOCK 	dim_lock();
+#define DIM_UNLOCK	dim_unlock();
+#define DISABLE_AST	DIM_LOCK
+#define ENABLE_AST  DIM_UNLOCK
+#endif
+
+/* ctime usage */
+#if defined (solaris) || (defined (LYNXOS) && !defined (__Lynx__) )
+#define my_ctime(t,str,size) ctime_r(t,str,size)
+#else 
+#if defined (__linux__) || defined (__Lynx__)
+#define my_ctime(t,str,size) ctime_r(t,str)
+#else
+#define my_ctime(t,str,size) strcpy(str,(const char *)ctime(t))
+#endif
+#endif
+
+/* DIM Error Severities*/
+typedef enum { DIM_INFO, DIM_WARNING, DIM_ERROR, DIM_FATAL }DIM_SEVERITIES;
+/* DIM Error codes */
+#define DIMDNSUNDEF 0x1		/* DIM_DNS_NODE undefined			FATAL */
+#define DIMDNSREFUS 0x2		/* DIM_DNS refuses connection		FATAL */
+#define DIMDNSDUPLC 0x3		/* Service already exists in DNS	FATAL */
+#define DIMDNSEXIT  0x4		/* DNS requests server to EXIT		FATAL */
+#define DIMDNSTMOUT 0x5		/* Server failed sending Watchdog	WARNING */
+
+#define DIMSVCDUPLC 0x10	/* Service already exists in Server	ERROR */
+#define DIMSVCFORMT 0x11	/* Bat format string for service	ERROR */
+#define DIMSVCINVAL 0x12	/* Service ID invalid				ERROR */
+#define DIMSVCTOOLG 0x13	/* Service name too long			ERROR */
+
+#define DIMTCPRDERR	0x20	/* TCP/IP read error				ERROR */
+#define DIMTCPWRRTY	0x21	/* TCP/IP write	error - Retrying	WARNING */
+#define DIMTCPWRTMO	0x22	/* TCP/IP write error - Disconnect	ERROR */
+#define DIMTCPLNERR	0x23	/* TCP/IP listen error				ERROR */
+#define DIMTCPOPERR	0x24	/* TCP/IP open server error			ERROR */
+#define DIMTCPCNERR	0x25	/* TCP/IP connection error			ERROR */
+#define DIMTCPCNEST	0x26	/* TCP/IP connection established	INFO */
+
+#define DIMDNSCNERR	0x30	/* Connection to DNS failed			ERROR */
+#define DIMDNSCNEST	0x31	/* Connection to DNS established	INFO */
+		
+#endif                         
+
+
+
+
+
+
+
Index: /Evidence/DIM/dim_core.hxx
===================================================================
--- /Evidence/DIM/dim_core.hxx	(revision 127)
+++ /Evidence/DIM/dim_core.hxx	(revision 127)
@@ -0,0 +1,34 @@
+#ifndef DIM_CORE
+#define DIM_CORE
+
+   #if defined __cplusplus
+         /* If the functions in this header have C linkage, this
+           * will specify linkage for all C++ language compilers.
+           */
+         extern "C" {
+   #endif
+
+   # if defined __DECC || defined __DECCXX
+         /* If you are using pragmas that are only defined
+           * with DEC C and DEC C++, this line is necessary
+           * for both C and C++ compilers.   A common error
+           * is to only have #ifdef __DECC, which causes
+           * the compiler to skip the conditionalized
+           * code.
+           */
+   #    pragma __extern_model __save
+   #    pragma __extern_model __strict_refdef
+         extern const char some_definition [];
+   #    pragma __extern_model __restore
+   # endif
+
+    /* ...some data and function definitions go here... */
+
+#include "dis.h"
+#include "dic.h"
+
+   #if defined __cplusplus
+         }    /* matches the linkage specification at the beginning. */
+   #endif
+
+#endif
Index: /Evidence/DIM/dim_jni.h
===================================================================
--- /Evidence/DIM/dim_jni.h	(revision 127)
+++ /Evidence/DIM/dim_jni.h	(revision 127)
@@ -0,0 +1,70 @@
+#include <jni.h>
+/* Header for class dim_Native */
+
+#ifndef _Included_dim_Native
+#define _Included_dim_Native
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef dim_Native_ONCE_ONLY
+#define dim_Native_ONCE_ONLY 0x1L
+#undef dim_Native_TIMED
+#define dim_Native_TIMED 0x2L
+#undef dim_Native_MONITORED
+#define dim_Native_MONITORED 0x4L
+#undef dim_Native_MONIT_ONLY
+#define dim_Native_MONIT_ONLY 0x20L
+#undef dim_Native_UPDATE
+#define dim_Native_UPDATE 0x40L
+#undef dim_Native_TIMED_ONLY
+#define dim_Native_TIMED_ONLY	0x80L
+#undef dim_Native_MONIT_FIRST
+#define dim_Native_MONIT_FIRST 0x100L
+#undef dim_Native_F_STAMPED
+#define dim_Native_F_STAMPED /*4096L*/ 0x1000L
+#undef dim_Native_F_WAIT
+#define dim_Native_F_WAIT /*-2147483648L*/ 0x10000000L
+
+
+#undef dim_Dbg_MODULE
+#define dim_Dbg_MODULE 1L
+#undef dim_Dbg_TRANSACTIONS
+#define dim_Dbg_TRANSACTIONS 2L
+#undef dim_Dbg_SEND_CALLBACK
+#define dim_Dbg_SEND_CALLBACK 4L
+#undef dim_Dbg_SEND_NATIVE
+#define dim_Dbg_SEND_NATIVE 8L
+#undef dim_Dbg_INFO_CALLBACK
+#define dim_Dbg_INFO_CALLBACK 16L
+#undef dim_Dbg_INFO_SERVICE
+#define dim_Dbg_INFO_SERVICE 32L
+#undef dim_Dbg_SERVER
+#define dim_Dbg_SERVER 256L
+#undef dim_Dbg_SERVICE_CALLBACK
+#define dim_Dbg_SERVICE_CALLBACK 512L
+#undef dim_Dbg_ADD_SERVICE
+#define dim_Dbg_ADD_SERVICE 1024L
+#undef dim_Dbg_RELEASE_SERVICE
+#define dim_Dbg_RELEASE_SERVICE 2048L
+#undef dim_Dbg_CMND_CALLBACK
+#define dim_Dbg_CMND_CALLBACK 4096L
+#undef dim_Dbg_ADD_CMND
+#define dim_Dbg_ADD_CMND 8192L
+#undef dim_Dbg_UPDATE_SERVICE
+#define dim_Dbg_UPDATE_SERVICE 16384L
+#undef dim_Dbg_GETCLIENT
+#define dim_Dbg_GETCLIENT 32768L
+#undef dim_Dbg_SERIALIZER
+#define dim_Dbg_SERIALIZER 65536L
+#undef dim_Dbg_DESCRIPTORS
+#define dim_Dbg_DESCRIPTORS 131072L
+#undef dim_Dbg_FULL
+#define dim_Dbg_FULL -1L
+
+/* Inaccessible static: dim_version */
+/* Inaccessible static: dll_locations */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /Evidence/DIM/dim_tcpip.h
===================================================================
--- /Evidence/DIM/dim_tcpip.h	(revision 127)
+++ /Evidence/DIM/dim_tcpip.h	(revision 127)
@@ -0,0 +1,94 @@
+/* 
+ * DIM Include file for changing the number of open connections
+ * Date: 06-12-2007
+ * Author: C. Gaspar
+ */
+
+#ifdef WIN32
+#define FD_SETSIZE      8192
+#else
+#ifdef linux
+#ifndef NOMORECONNS
+/* CG: Copied here bits/typesizes.h */
+#ifndef	_BITS_TYPESIZES_H
+#define	_BITS_TYPESIZES_H	1
+
+/* See <bits/types.h> for the meaning of these macros.  This file exists so
+   that <bits/types.h> need not vary across different GNU platforms.  */
+
+#define __DEV_T_TYPE		__UQUAD_TYPE
+#define __UID_T_TYPE		__U32_TYPE
+#define __GID_T_TYPE		__U32_TYPE
+#define __INO_T_TYPE		__ULONGWORD_TYPE
+#define __INO64_T_TYPE		__UQUAD_TYPE
+#define __MODE_T_TYPE		__U32_TYPE
+#define __NLINK_T_TYPE		__UWORD_TYPE
+#define __OFF_T_TYPE		__SLONGWORD_TYPE
+#define __OFF64_T_TYPE		__SQUAD_TYPE
+#define __PID_T_TYPE		__S32_TYPE
+#define __RLIM_T_TYPE		__ULONGWORD_TYPE
+#define __RLIM64_T_TYPE		__UQUAD_TYPE
+#define	__BLKCNT_T_TYPE		__SLONGWORD_TYPE
+#define	__BLKCNT64_T_TYPE	__SQUAD_TYPE
+#define	__FSBLKCNT_T_TYPE	__ULONGWORD_TYPE
+#define	__FSBLKCNT64_T_TYPE	__UQUAD_TYPE
+#define	__FSFILCNT_T_TYPE	__ULONGWORD_TYPE
+#define	__FSFILCNT64_T_TYPE	__UQUAD_TYPE
+#define	__ID_T_TYPE		__U32_TYPE
+#define __CLOCK_T_TYPE		__SLONGWORD_TYPE
+#define __TIME_T_TYPE		__SLONGWORD_TYPE
+#define __USECONDS_T_TYPE	__U32_TYPE
+#define __SUSECONDS_T_TYPE	__SLONGWORD_TYPE
+#define __DADDR_T_TYPE		__S32_TYPE
+#define __SWBLK_T_TYPE		__SLONGWORD_TYPE
+#define __KEY_T_TYPE		__S32_TYPE
+#define __CLOCKID_T_TYPE	__S32_TYPE
+#define __TIMER_T_TYPE		__S32_TYPE
+#define __BLKSIZE_T_TYPE	__SLONGWORD_TYPE
+#define __FSID_T_TYPE		struct { int __val[2]; }
+#define __SSIZE_T_TYPE		__SWORD_TYPE
+
+/* Number of descriptors that can fit in an `fd_set'.  */
+#define	__FD_SETSIZE		8192
+
+#endif /* bits/typesizes.h */
+
+/* CG: Copied here linux/posix_types.h */
+#ifndef _LINUX_POSIX_TYPES_H
+#define _LINUX_POSIX_TYPES_H
+
+#include <linux/stddef.h>
+
+#undef __NFDBITS
+#define __NFDBITS	(8 * sizeof(unsigned long))
+
+#undef __FD_SETSIZE
+#define __FD_SETSIZE	8192
+
+#undef __FDSET_LONGS
+#define __FDSET_LONGS	(__FD_SETSIZE/__NFDBITS)
+
+#undef __FDELT
+#define	__FDELT(d)	((d) / __NFDBITS)
+
+#undef __FDMASK
+#define	__FDMASK(d)	(1UL << ((d) % __NFDBITS))
+
+typedef struct {
+	unsigned long fds_bits [__FDSET_LONGS];
+} __kernel_fd_set;
+
+/* Type of a signal handler.  */
+typedef void (*__kernel_sighandler_t)(int);
+
+/* Type of a SYSV IPC key.  */
+typedef int __kernel_key_t;
+
+#include <asm/posix_types.h>
+
+#endif /* _LINUX_POSIX_TYPES_H */
+
+#endif /* NOMORECONNS */
+#endif /* linux */
+
+#endif
Index: /Evidence/DIM/dis.h
===================================================================
--- /Evidence/DIM/dis.h	(revision 127)
+++ /Evidence/DIM/dis.h	(revision 127)
@@ -0,0 +1,64 @@
+#ifndef __DISDEFS
+#define __DISDEFS
+
+#include "dim_common.h"
+
+/* CFORTRAN interface */
+
+#define dis_start_serving dis_start_serving_
+#define dis_stop_serving dis_stop_serving_
+#define dis_get_next_cmnd dis_get_next_cmnd_
+#define dis_get_client dis_get_client_
+#define dis_add_service dis_add_service_
+#define dis_add_cmnd dis_add_cmnd_
+#define dis_add_client_exit_handler dis_add_client_exit_handler_
+#define dis_add_exit_handler dis_add_exit_handler_
+#define dis_set_client_exit_handler dis_set_client_exit_handler_
+#define dis_report_service dis_report_service_
+#define dis_update_service dis_update_service_
+#define dis_remove_service dis_remove_service_
+#define dis_send_service dis_send_service_
+#define dis_convert_str dis_convert_str_
+#define dis_set_quality dis_set_quality_
+#define dis_set_timestamp dis_set_timestamp_
+#define dis_selective_update_service dis_selective_update_service_
+
+_DIM_PROTOE( int dis_start_serving,    (char *task_name) );
+_DIM_PROTOE( void dis_stop_serving,    () );
+_DIM_PROTOE( int dis_get_next_cmnd,    (long *tag, int *buffer, int *size ) );
+_DIM_PROTOE( int dis_get_client,       (char *name ) );
+_DIM_PROTOE( int dis_get_conn_id,      () );
+_DIM_PROTOE( unsigned dis_add_service, (char *service_name, char *service_type,
+				   void *service_address, int service_size,
+				   void (*usr_routine)(void*,void**,int*,int*), long tag) );
+_DIM_PROTOE( unsigned dis_add_cmnd,        (char *service_name, char *service_type,
+			           void (*usr_routine)(void*,void*,int*), long tag) );
+_DIM_PROTOE( void dis_add_client_exit_handler,(void (*usr_routine)(int*)) );
+_DIM_PROTOE( void dis_set_client_exit_handler,(int conn_id, int tag) );
+_DIM_PROTOE( void dis_add_exit_handler,(void (*usr_routine)(int*)) );
+_DIM_PROTOE( void dis_add_error_handler,(void (*usr_routine)(int, int, char*)) );
+_DIM_PROTOE( void dis_report_service,  (char *service_name) );
+_DIM_PROTOE( int dis_update_service,   (unsigned service_id) );
+_DIM_PROTOE( int dis_remove_service,   (unsigned service_id) );
+_DIM_PROTOE( void dis_send_service,    (unsigned service_id, int *buffer,
+				   int size) );
+_DIM_PROTOE( int dis_set_buffer_size,  (int size) );
+_DIM_PROTOE( void dis_set_quality,     (unsigned service_id, int quality) );
+_DIM_PROTOE( void dis_set_timestamp,     (unsigned service_id, 
+					int secs, int millisecs) );
+_DIM_PROTOE( int dis_selective_update_service,   (unsigned service_id, 
+					int *client_id_list) );
+_DIM_PROTOE( void dis_disable_padding,      		() );
+_DIM_PROTOE( int dis_get_timeout,      		(unsigned service_id, int client_id) );
+_DIM_PROTOE( char *dis_get_error_services,	() );
+_DIM_PROTOE( char *dis_get_client_services,	(int conn_id) );
+_DIM_PROTOE( int dis_start_serving_dns,		(long dns_id, char *task_name/*, int *id_list*/) );
+_DIM_PROTOE( void dis_stop_serving_dns,		(long dns_id) );
+_DIM_PROTOE( unsigned dis_add_service_dns,	(long dns_id, char *service_name, char *service_type,
+				   void *service_address, int service_size,
+				   void (*usr_routine)(void*,void**,int*,int*), long tag) );
+_DIM_PROTOE( unsigned dis_add_cmnd_dns,		(long dns_id, char *service_name, char *service_type,
+			       void (*usr_routine)(void*,void*,int*), long tag) );
+_DIM_PROTOE( int dis_get_n_clients,	(unsigned service_id) );
+
+#endif
Index: /Evidence/DIM/dis.hxx
===================================================================
--- /Evidence/DIM/dis.hxx	(revision 127)
+++ /Evidence/DIM/dis.hxx	(revision 127)
@@ -0,0 +1,334 @@
+#ifndef __DISHHDEFS
+#define __DISHHDEFS
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef WIN32
+#include <unistd.h>
+#endif
+#ifdef __VMS
+#include <starlet.h>
+#endif
+#include "dim_core.hxx"
+#include "dim.hxx"
+/*
+#define DimSHORT	"S"
+#define DimINT		"I"
+#define DimLONG		"L"
+#define DimFLOAT	"F"
+#define DimDOUBLE	"D"
+#define DimSTRING	"C"
+#define DimXLONG	"X"
+*/
+enum DisTYPE {
+	DisPOINTER, DisSHORT, DisINT, DisFLOAT, DisDOUBLE, DisSTRING, DisXLONG, DisCOMMAND
+};
+
+class DimService;
+class DimCommand;
+
+class DllExp DimServiceHandler{
+public:
+	DimService *itsService;
+	DimService *getService() { return itsService; } ;
+	virtual void serviceHandler() = 0;
+	virtual ~DimServiceHandler() {};
+};
+
+class DllExp DimCommandHandler{
+public:
+	DimCommand *itsCommand;
+	DimCommand *getCommand() { return itsCommand; } ;
+	virtual void commandHandler() = 0;
+	virtual ~DimCommandHandler() {};
+};
+
+class DllExp DimClientExitHandler{
+public:
+	virtual void clientExitHandler() = 0;
+	virtual ~DimClientExitHandler() {};
+};
+
+class DllExp DimExitHandler{
+public:
+	virtual void exitHandler(int code) = 0;
+	virtual ~DimExitHandler() {};
+};
+
+class DllExp DimServerDns
+{
+public:
+	DimServerDns(const char *node);
+	DimServerDns(const char *node, int port);
+	DimServerDns(const char *node, int port, char *name);
+	~DimServerDns();
+	void init(const char *node, int port);
+	long getDnsId();
+	void setName(const char *name);
+	char *getName();
+	void autoStartOn();
+	void autoStartOff();
+	int isAutoStart();
+	void addServiceId(int id);
+	int *getServiceIdList();
+private:
+	char *itsNode;
+	int itsPort;
+	long itsDnsId;
+	char *itsName;
+	int autoStart;
+	int *itsServiceIdList;
+	int itsServiceIdListSize;
+	int itsNServiceIds;
+//	int itsNServices;
+};
+
+class DllExp DimServer : public DimServiceHandler, public DimCommandHandler,
+	public DimClientExitHandler, public DimExitHandler, public DimErrorHandler
+{
+public:
+	static char *clientName;
+	static char *itsName;
+	static char *dimDnsNode;
+	static int autoStart;
+	static DimClientExitHandler *itsClientExit;
+	static DimExitHandler *itsExit;
+	static DimErrorHandler *itsSrvError;
+//	static int itsNServices;
+	DimServer();
+	virtual ~DimServer();
+	static void start(const char *name);
+	static void start(DimServerDns *dns, const char *name);
+	static void start();
+	static void start(DimServerDns *dns);
+	static void stop();
+	static void stop(DimServerDns *dns);
+	static void autoStartOn();
+	static void autoStartOff();
+	// Get Current Client Identifier	
+	static int getClientId();
+	// Get Current Client Name	
+	static char *getClientName();
+	static void setClientExitHandler(int clientId);
+	static void clearClientExitHandler(int clientId);
+	static void addClientExitHandler(DimClientExitHandler *handler);
+	void addClientExitHandler();
+	static void addExitHandler(DimExitHandler *handler);
+	static void addErrorHandler(DimErrorHandler *handler);
+	static int setDnsNode(const char *node);
+	static int setDnsNode(const char *node, int port);
+	static long addDns(const char *node, int port);
+	static void stopDns(long dnsid);
+	static char *getDnsNode();
+	static int getDnsPort();
+	static void setWriteTimeout(int secs);
+	static int getWriteTimeout();
+	void addExitHandler();
+	void addErrorHandler();
+	virtual void clientExitHandler() {};
+	virtual void exitHandler(int /* code */) {};
+	virtual void errorHandler(int /* severity */, int /* code */, char* /* msg */) {};
+//	static char *getClientServices();
+//	static char *getClientServices(int clientId);
+	static char **getClientServices();
+
+	virtual void serviceHandler() {};
+	virtual void commandHandler() {};
+};
+
+class DllExp DimService : public DimServiceHandler {
+
+public :
+	DimServiceHandler *itsServiceHandler;
+
+	// The object contains the value to be published. Service to be updated with an argument of same type;
+	DimService();
+
+	DimService(const char *name, int &value);
+	DimService(const char *name, float &value);
+	DimService(const char *name, double &value);
+	DimService(const char *name, longlong &value);
+	DimService(const char *name, short &value);
+	DimService(const char *name, char *string);
+
+	DimService(const char *name, char *format, void *structure, int size);
+
+	DimService(const char *name, char *format, DimServiceHandler *handler);
+
+	DimService(DimServerDns *dns, const char *name, int &value);
+	DimService(DimServerDns *dns, const char *name, float &value);
+	DimService(DimServerDns *dns, const char *name, double &value);
+	DimService(DimServerDns *dns, const char *name, longlong &value);
+	DimService(DimServerDns *dns, const char *name, short &value);
+	DimService(DimServerDns *dns, const char *name, char *string);
+
+	DimService(DimServerDns *dns, const char *name, char *format, void *structure, int size);
+
+	DimService(DimServerDns *dns, const char *name, char *format, DimServiceHandler *handler);
+
+	virtual ~DimService();
+
+	// Update methods
+	int updateService();
+	// Update the value as well...
+	int updateService( int &value );
+	int updateService( float &value );
+	int updateService( double &value ) ;
+	int updateService( longlong &value );
+	int updateService( short &value );
+	int updateService( char *string );
+	
+	int updateService( void *structure, int size );
+	
+	// Selective Update methods
+	int selectiveUpdateService(int *cids);
+	// Update the value as well...
+	int selectiveUpdateService( int &value, int *cids);
+	int selectiveUpdateService( float &value, int *cids );
+	int selectiveUpdateService( double &value, int *cids );
+	int selectiveUpdateService( longlong &value, int *cids );
+	int selectiveUpdateService( short &value, int *cids );
+	int selectiveUpdateService( char *string, int *cids );
+	
+	int selectiveUpdateService( void *structure, int size, int *cids );
+	
+	void setQuality(int quality);
+	void setTimestamp(int secs, int millisecs);
+
+	void *itsData;
+	int itsDataSize;
+	int itsSize;
+	DisTYPE itsType;
+	void setData(void *data, int size);
+	void setData(int &data);
+	void setData(float &data);
+	void setData(double &data);
+	void setData(longlong &data);
+	void setData(short &data);
+	void setData(char *data);
+
+	virtual void serviceHandler() {};
+	// Accessors
+	char *getName();
+	int getTimeout(int clientId);
+	int getNClients();
+private :
+	char *itsName;
+	int itsId;
+	int itsTagId;
+	void declareIt(char *name, char *format, DimServiceHandler *handler, DimServerDns *dns);
+	void storeIt(void *data, int size);
+	DimServerDns *itsDns;
+};
+
+class DllExp CmndInfo : public SLLItem {
+	friend class DimCommand;
+	void *itsData;
+	int itsDataSize;
+public:
+	CmndInfo(void *data, int datasize);
+	~CmndInfo();
+};
+
+class DllExp DimCommand : public DimCommandHandler {
+
+public :
+	DimCommandHandler *itsCommandHandler;
+
+	DimCommand(const char *name, char *format);
+
+	DimCommand(const char *name, char *format, DimCommandHandler *handler);
+
+	DimCommand(DimServerDns *dns, const char *name, char *format);
+
+	DimCommand(DimServerDns *dns, const char *name, char *format, DimCommandHandler *handler);
+
+	int getNext();
+	void *itsData;
+	int itsSize;
+	void *getData();
+	int getInt();
+	float getFloat();
+	double getDouble();
+	longlong getLonglong();
+	short getShort();
+	char *getString();
+	int getSize();
+	char *getFormat();
+
+	virtual void commandHandler();
+
+	// Accessors
+	char *getName();
+	virtual ~DimCommand();
+
+private :
+	char *itsName;
+	int itsId;
+	int itsTagId;
+	char *itsFormat;
+	void declareIt(char *name, char *format, DimCommandHandler *handler, DimServerDns *dns);
+	CmndInfo *currCmnd;
+	SLList itsCmndList;
+	DimServerDns *itsDns;
+};
+
+class DllExp DimRpc
+{
+public :
+
+	// The object contains the value to be published. Service to be updated with an argument of same type;
+	DimRpc();
+
+	DimRpc(const char *name, const char *formatin, const char *formatout);
+
+	DimRpc(DimServerDns *dns, const char *name, const char *formatin, const char *formatout);
+
+	// Desctructor
+	virtual ~DimRpc();
+
+	void *itsDataIn;
+	int itsSizeIn;
+	void *getData();
+	int getInt();
+	float getFloat();
+	double getDouble();
+	longlong getLonglong();
+	short getShort();
+	char *getString();
+	int getSize();
+
+	void *itsDataOut;
+	int itsDataOutSize;
+	int itsSizeOut;
+
+	void setData(void *data, int size);
+	void setData(int &data);
+	void setData(float &data);
+	void setData(double &data);
+	void setData(longlong &data);
+	void setData(short &data);
+	void setData(char *data);
+
+	virtual void rpcHandler() = 0;
+	// Accessors
+	char *getName();
+	int itsIdIn;
+	int itsIdOut;
+private :
+	int itsTagId;
+	char *itsName;
+	char *itsNameIn;
+	char *itsNameOut;
+	void declareIt(char *name, char *formatin, char *formatout, DimServerDns *dns);
+	void storeIt(void *data, int size);
+	void timerHandler();
+	DimServerDns *itsDns;
+public:
+	int itsKilled;
+	int itsTimeout;
+};
+
+
+#endif
+
Index: /Evidence/DIM/dllist.hxx
===================================================================
--- /Evidence/DIM/dllist.hxx	(revision 127)
+++ /Evidence/DIM/dllist.hxx	(revision 127)
@@ -0,0 +1,105 @@
+#ifndef __DLLHHDEFS
+#define __DLLHHDEFS
+
+class DllExp DLLItem {
+	friend class DLList ;
+	DLLItem *next;
+	DLLItem *prev;
+public:
+	DLLItem(){
+		next = 0;
+		prev = 0;
+	};
+};
+
+class DllExp DLList {
+	DLLItem *head;
+	DLLItem *curr;
+public:
+	DLList (){
+		DISABLE_AST
+		head = new DLLItem();
+		head->next = head;
+		head->prev = head;
+		curr = head;
+		ENABLE_AST
+	}
+	~DLList()
+	{
+		DISABLE_AST
+		delete head;
+		ENABLE_AST
+	}
+    void add(DLLItem *item)
+	{
+		DLLItem *prevp;
+		DISABLE_AST
+		item->next = head;
+		prevp = head->prev;
+		item->prev = prevp;
+		prevp->next = item;
+		head->prev = item;
+		ENABLE_AST
+	}
+	DLLItem *getHead()
+	{
+		DISABLE_AST
+		if(head->next == head)
+		{
+			ENABLE_AST
+			return((DLLItem *)0);
+		}
+		curr = head->next;
+		ENABLE_AST
+		return( head->next );
+	}
+	DLLItem *getLast()
+	{
+		DISABLE_AST
+		if(head->prev == head)
+		{
+			ENABLE_AST
+			return((DLLItem *)0);
+		}
+		curr = head->prev;
+		ENABLE_AST
+		return( head->prev );
+	}
+	DLLItem *getNext()
+	{
+		DISABLE_AST
+		curr = curr->next;
+		if(curr == head)
+		{
+			ENABLE_AST
+			return((DLLItem *)0);
+		}
+		ENABLE_AST
+		return( curr );
+	}
+	DLLItem *removeHead()
+	{
+		DLLItem *item;
+		DISABLE_AST
+		item = head->next;
+		if(item == head)
+		{
+			ENABLE_AST
+			return((DLLItem *)0);
+		}
+		remove(item);
+		ENABLE_AST
+		return(item);
+	}
+	void remove(DLLItem *item)
+	{
+		DLLItem *prevp, *nextp;
+		DISABLE_AST
+		prevp = item->prev;
+		nextp = item->next;
+		prevp->next = item->next;
+		nextp->prev = prevp;
+		ENABLE_AST
+	}
+};
+#endif
Index: /Evidence/DIM/sllist.hxx
===================================================================
--- /Evidence/DIM/sllist.hxx	(revision 127)
+++ /Evidence/DIM/sllist.hxx	(revision 127)
@@ -0,0 +1,84 @@
+#ifndef __SLLHHDEFS
+#define __SLLHHDEFS
+
+class DllExp SLLItem {
+	friend class SLList ;
+	SLLItem *next;
+public:
+	SLLItem(){
+		next = 0;
+	};
+};
+
+class DllExp SLList {
+	SLLItem *head;
+	SLLItem *curr;
+public:
+	SLList (){
+		DISABLE_AST
+		head = new SLLItem();
+		curr = head;
+		ENABLE_AST
+	}
+	~SLList()
+	{
+		DISABLE_AST
+		delete head;
+		ENABLE_AST
+	}
+    void add(SLLItem *itemptr)
+	{
+		DISABLE_AST
+		SLLItem *ptr = head;
+		while(ptr->next)
+		{
+			ptr = ptr->next;
+		}
+		ptr->next = itemptr;
+		ENABLE_AST
+	}
+	SLLItem *getHead()
+	{
+		curr = head->next;
+		return( head->next );
+	}
+	SLLItem *getNext()
+	{
+		DISABLE_AST
+		if(!curr)
+			curr = head;
+		curr = curr->next;
+		ENABLE_AST
+		return( curr );
+	}
+	SLLItem *removeHead()
+	{
+		SLLItem *ptr;
+
+		DISABLE_AST
+		ptr = head->next;
+		if(ptr)
+		{
+			head->next = ptr->next;
+			curr = head->next;
+		}
+		ENABLE_AST
+		return( ptr);
+	}
+	void remove(SLLItem *itemptr)
+	{
+		SLLItem *ptr = head, *prev;
+		DISABLE_AST
+		while(ptr->next)
+		{
+			prev = ptr;
+			ptr = ptr->next;
+			if( itemptr == ptr )
+			{
+				prev->next = ptr->next;
+			}
+		}
+		ENABLE_AST
+	}
+};
+#endif
Index: /Evidence/DIM/test1.c
===================================================================
--- /Evidence/DIM/test1.c	(revision 127)
+++ /Evidence/DIM/test1.c	(revision 127)
@@ -0,0 +1,119 @@
+void register_services(flag)
+register int flag;
+{
+	register DIS_DNS_PACKET *dis_dns_p = &Dis_dns_packet;
+	register int n_services, tot_n_services;
+	register SERVICE *servp;
+	register SERVICE_REG *serv_regp;
+	SERVICE *dis_hash_service_get_next_register();
+	extern int get_node_addr();
+	int dis_hash_service_registered();
+
+	if(!dis_dns_p->src_type)
+	{
+		get_node_name( dis_dns_p->node_name );
+/*
+		strcpy( dis_dns_p->task_name, Task_name );
+*/
+		strncpy( dis_dns_p->task_name, Task_name,
+			MAX_TASK_NAME-4 );
+		dis_dns_p->task_name[MAX_TASK_NAME-4-1] = '\0';
+		get_node_addr( dis_dns_p->node_addr );
+/*
+		dis_dns_p->port = htovl(Port_number);
+*/
+		dis_dns_p->pid = htovl(getpid());
+		dis_dns_p->protocol = htovl(Protocol);
+		dis_dns_p->src_type = htovl(SRC_DIS);
+		dis_dns_p->format = htovl(MY_FORMAT);
+	}
+
+	dis_dns_p->port = htovl(Port_number);
+	serv_regp = dis_dns_p->services;
+	n_services = 0;
+	tot_n_services = 0;
+	if( flag == NONE ) {
+		dis_dns_p->n_services = htovl(n_services);
+		dis_dns_p->size = htovl( DIS_DNS_HEADER + 
+			(n_services*sizeof(SERVICE_REG)));
+		if(Dns_dis_conn_id > 0)
+		{
+			if(!dna_write(Dns_dis_conn_id, &Dis_dns_packet, 
+				DIS_DNS_HEADER + n_services*sizeof(SERVICE_REG)))
+			{
+				release_conn(Dns_dis_conn_id,0);
+			}
+		}
+		return;
+	}
+	if(flag == ALL)
+	{
+		servp = 0;
+		while( (servp = dis_hash_service_get_next(servp)))
+		{
+			servp->registered  = 0;
+		}
+	}
+	servp = 0;
+	while( (servp = dis_hash_service_get_next_register(servp)))
+	{
+		if( flag == MORE ) 
+		{
+			if( servp->registered )
+			{
+				continue;
+			}
+		}
+
+		strcpy( serv_regp->service_name, servp->name );
+		strcpy( serv_regp->service_def, servp->def );
+		if(servp->type == COMMAND)
+			serv_regp->service_id = htovl( servp->id | 0x10000000);
+		else
+			serv_regp->service_id = htovl( servp->id );
+
+		serv_regp++;
+		n_services++;
+		dis_hash_service_registered(servp);
+		if( n_services == MAX_SERVICE_UNIT )
+		{
+			dis_dns_p->n_services = htovl(n_services);
+			dis_dns_p->size = htovl(DIS_DNS_HEADER +
+				n_services * sizeof(SERVICE_REG));
+			if(Dns_dis_conn_id > 0)
+			{
+				if( !dna_write(Dns_dis_conn_id,
+					   &Dis_dns_packet, 
+					   DIS_DNS_HEADER + n_services *
+						sizeof(SERVICE_REG)) )
+				{
+					release_conn(Dns_dis_conn_id,0);
+				}
+			}
+			serv_regp = dis_dns_p->services;
+			tot_n_services += MAX_SERVICE_UNIT;
+			n_services = 0;
+			continue;
+		}
+	}
+	if( n_services ) 
+	{
+		dis_dns_p->n_services = htovl(n_services);
+		dis_dns_p->size = htovl(DIS_DNS_HEADER +
+					n_services * sizeof(SERVICE_REG));
+		if(Dns_dis_conn_id > 0)
+		{
+			if( !dna_write(Dns_dis_conn_id, &Dis_dns_packet,
+				DIS_DNS_HEADER + n_services * sizeof(SERVICE_REG)))
+			{
+				release_conn(Dns_dis_conn_id,0);
+			}
+
+		}
+		tot_n_services += n_services;
+	}
+	if(tot_n_services >= MAX_REGISTRATION_UNIT)
+	{
+	  send_dns_update_packet();
+	}
+}
Index: /Evidence/DIM/test2.c
===================================================================
--- /Evidence/DIM/test2.c	(revision 127)
+++ /Evidence/DIM/test2.c	(revision 127)
@@ -0,0 +1,101 @@
+void register_dns_services(flag)
+register int flag;
+{
+	register DIS_DNS_PACKET *dis_dns_p = &Dis_dns_packet;
+	register int n_services;
+	register SERVICE *servp;
+	register SERVICE_REG *serv_regp;
+	extern int get_node_addr(char *);
+	int dis_hash_service_registered();
+
+	if(!dis_dns_p->src_type)
+	{
+		get_node_name( dis_dns_p->node_name );
+/*
+		strcpy( dis_dns_p->task_name, Task_name );
+*/
+		strncpy( dis_dns_p->task_name, Task_name,
+			MAX_TASK_NAME-4 );
+		dis_dns_p->task_name[MAX_TASK_NAME-4-1] = '\0';
+		get_node_addr( dis_dns_p->node_addr );
+/*
+		dis_dns_p->port = htovl(Port_number);
+*/
+		dis_dns_p->pid = htovl(getpid());
+		dis_dns_p->protocol = htovl(Protocol);
+		dis_dns_p->src_type = htovl(SRC_DIS);
+		dis_dns_p->format = htovl(MY_FORMAT);
+	}
+	dis_dns_p->port = htovl(Port_number);
+	serv_regp = dis_dns_p->services;
+	n_services = 0;
+	if( flag == NONE ) {
+		dis_dns_p->n_services = htovl(n_services);
+		dis_dns_p->size = htovl( DIS_DNS_HEADER + 
+			(n_services*sizeof(SERVICE_REG)));
+		if(Dns_dis_conn_id > 0)
+		{
+			if(!dna_write(Dns_dis_conn_id, &Dis_dns_packet, 
+				DIS_DNS_HEADER + n_services*sizeof(SERVICE_REG)))
+			{
+				release_conn(Dns_dis_conn_id,0);
+			}
+		}
+		return;
+	}
+	servp = 0;
+	while( (servp = dis_hash_service_get_next(servp)))
+	{
+		if( flag == MORE ) 
+		{
+			if( servp->registered )
+			{
+				continue;
+			}
+		}
+		strcpy( serv_regp->service_name, servp->name );
+		strcpy( serv_regp->service_def, servp->def );
+		if(servp->type == COMMAND)
+			serv_regp->service_id = htovl( servp->id | 0x10000000);
+		else
+			serv_regp->service_id = htovl( servp->id );
+		serv_regp++;
+		n_services++;
+		dis_hash_service_registered(servp);
+/*
+		servp->registered = 1;
+*/
+		if( n_services == MAX_SERVICE_UNIT ) 
+		{
+			dis_dns_p->n_services = htovl(n_services);
+			dis_dns_p->size = htovl(DIS_DNS_HEADER +
+				n_services * sizeof(SERVICE_REG));
+			if(Dns_dis_conn_id > 0)
+			{
+				if( !dna_write(Dns_dis_conn_id,
+					   &Dis_dns_packet, 
+					   DIS_DNS_HEADER + n_services *
+						sizeof(SERVICE_REG)) )
+				{
+					release_conn(Dns_dis_conn_id,0);
+				}
+			}
+			serv_regp = dis_dns_p->services;
+			n_services = 0;
+		}
+	}
+	if( n_services ) 
+	{
+		dis_dns_p->n_services = htovl(n_services);
+		dis_dns_p->size = htovl(DIS_DNS_HEADER +
+					n_services * sizeof(SERVICE_REG));
+		if(Dns_dis_conn_id > 0)
+		{
+			if( !dna_write(Dns_dis_conn_id, &Dis_dns_packet,
+				DIS_DNS_HEADER + n_services * sizeof(SERVICE_REG)))
+			{
+				release_conn(Dns_dis_conn_id,0);
+			}
+		}
+	}
+}
Index: /Evidence/DIM/tokenstring.hxx
===================================================================
--- /Evidence/DIM/tokenstring.hxx	(revision 127)
+++ /Evidence/DIM/tokenstring.hxx	(revision 127)
@@ -0,0 +1,31 @@
+#ifndef __TOKENSTRINGDEFS
+#define __TOKENSTRINGDEFS
+#include <string.h>
+#include "dim_core.hxx"
+
+class DllExp TokenString
+{
+public:
+
+	TokenString(char *str);
+	TokenString(char *str, char *seps);
+	~TokenString();
+	int getToken(char *&token);
+	void pushToken();
+	void popToken();
+	int cmpToken(char *str);
+	int firstToken();
+	int getNTokens();
+	int getNTokens(char *str);
+
+private:
+	void store_str(char *str);
+	char *token_buff;
+	char *token_ptr;
+	char *curr_token_ptr;
+	char *push_token_ptr;
+	char *token_seps;
+	int n_tokens;
+};
+
+#endif
Index: /Evidence/Evidence.cc
===================================================================
--- /Evidence/Evidence.cc	(revision 127)
+++ /Evidence/Evidence.cc	(revision 127)
@@ -0,0 +1,186 @@
+/********************************************************************\
+
+  General code to start a server of the Evidence Control System
+  
+  - The server is started with the given name.
+  - DIM exit and error handlers are implemented.
+  - The Status service is published.
+    It can be updated with the Msg() method. The text will also be logged.
+  - Configuration data can be requested by GetConfig(). 
+  - Signal handlers to ignore common signals are installed.
+    These signals will then cause pause() to return which can be used
+	by the application to terminate gracefully.
+  - The static method ToString() converts the contents of a
+    DIMInfo service into text
+	
+  All memory allocated by the non-static methods will be freed by the
+  class destructor.
+  
+  Oliver Grimm, December 2009
+ 
+\********************************************************************/
+
+#include "Evidence.h"
+
+bool EvidenceServer::ExitRequest = false;
+
+// Constructor starts server with given name
+EvidenceServer::EvidenceServer(const char *Name) {
+
+  // Initialize
+  Status = NULL;
+  MsgBuffer = NULL;
+  ConfigList = NULL;
+  ConfigNum = 0;
+  
+  // Catch some signals
+  signal(SIGQUIT, &SignalHandler);  // CTRL-Backspace
+  signal(SIGTERM, &SignalHandler);  // Termination signal
+  signal(SIGINT, &SignalHandler);   // CTRL-C
+  signal(SIGHUP, &SignalHandler);   // Terminal closed
+  
+  // Create server name
+  if (asprintf(&ServerName, "%s/Status", Name) == -1) {
+    ServerName = NULL;
+    Msg(FATAL, "Could not generate service name, asprintf() failed");
+  }
+  
+  // Start server
+  static char InitMsg[] = "OK" "\0" "0";
+  Status = new DimService(ServerName, (char *) "C", InitMsg, sizeof(InitMsg));
+  DimServer::start(Name);
+  DimServer::addExitHandler(this);
+  
+  Msg(INFO, "Server started");
+}
+
+// Destructor: Frees all buffers
+EvidenceServer::~EvidenceServer() {
+
+  free(ServerName);
+  free(MsgBuffer);
+  
+  for (unsigned int i=0; i<ConfigNum; i++) {
+    delete *((DimRpcInfo **) ConfigList + i);
+  }
+  free(ConfigList);
+}
+
+// DIM exit handler
+void EvidenceServer::exitHandler(int Code) {
+  Msg(INFO, "Server stopped (DIM exit code %d)", Code);
+  exit(EXIT_SUCCESS);
+}
+
+// DIM error handler
+void EvidenceServer::errorHandler(int Severity, int Code, char *Message) {   
+  Msg(ERROR, "%s (DIM Error, code %d, severity %d)\n", Message, Code, Severity);
+}
+
+// Print message to screen, to log and to status
+//
+// The message format is special: after the string-terminating '\0'
+// the Severity is given, terminated by another '\0' 
+// The buffer must have the same lifetime as the DIM service.
+// If Severity is FATAL, exit() will be invoked.
+void EvidenceServer::Msg(MsgType Severity, const char *Format, ...) {
+
+  char *TmpBuffer;
+  int Size;
+  
+  static char DefaultMsg[]="vasprintf() or asprintf() failed, cannot process message" "\0" "2";   // Severity 'Error'
+   
+  // Assemble message from application
+  va_list ArgumentPointer;
+  va_start(ArgumentPointer, Format);
+  if (vasprintf(&TmpBuffer, Format, ArgumentPointer) == -1) TmpBuffer = NULL;
+  va_end(ArgumentPointer);
+
+  // Free previous message buffer if allocated dynamically
+  if (MsgBuffer != DefaultMsg) free(MsgBuffer);
+  
+  // Assemble final message including headers and Severity encoding
+  if (TmpBuffer == NULL) Size = -1;
+  else Size = asprintf(&MsgBuffer, "%s: %s%s*%d", ServerName,
+		(Severity==FATAL) ? "(Fatal) ":"", TmpBuffer,
+		(unsigned char) Severity);
+  free(TmpBuffer);
+
+  // If memory could not be allocated, show default message,
+  // otherwise replace '*' by '0' for severity encoding		
+  if (Size == -1) {
+    MsgBuffer = DefaultMsg;
+	Size = sizeof(DefaultMsg) - 1;
+  }
+  else *(strrchr(MsgBuffer, '*')) = '\0';
+
+  // Send message to console, log file and update DIM status service
+  printf("%s\n", MsgBuffer);
+  DimClient::sendCommand("DColl/Log", MsgBuffer);
+  if (Status != NULL) Status->updateService(MsgBuffer, Size+1);
+
+  // Terminate if message type is fatal
+  if (Severity == FATAL) exit(EXIT_FAILURE);
+}
+
+// Get configuration data (program terminates if data is missing)
+//
+// The memory allocated by all calls to this function will be freed by
+// the destructor.
+char* EvidenceServer::GetConfig(const char *Item) {
+
+  // Enlarge memory to hold new pointer
+  DimRpcInfo **Config = (DimRpcInfo **) realloc(ConfigList, sizeof(void *) * (++ConfigNum));
+  if (Config == NULL) {
+    Msg(WARN, "Could not realloc() memory for DimRpcInfo list (%s)", strerror(errno));
+    ConfigNum--;  
+  }
+  else ConfigList = (void *) Config;
+  
+  // Advance array pointer to position for new DimRpcInfo pointer 
+  Config += ConfigNum - 1;
+  
+  // Make configuration request
+  *Config = new DimRpcInfo((char *) "ConfigRequest", (char *) "");
+  (*Config)->setData((char *) Item);
+
+  // Terminate if not successful
+  if (strlen((*Config)->getString()) == 0) {
+    Msg(FATAL, "Missing configuration data '%s'", Item);
+  }
+
+  return (*Config)->getString();
+}
+
+
+// ====== Static methods ======
+
+// Signal handler (causes pause() to return)
+void EvidenceServer::SignalHandler(int) {
+  EvidenceServer::ExitRequest = true;
+}
+
+// Translates DIMInfo to string (memory has to be freed by caller)
+char *EvidenceServer::ToString(DimInfo *Item) {
+
+  char *Text;
+  int R;
+  
+  // Cannot handle complex data formats
+  if (strlen(Item->getFormat()) != 1) return NULL;
+  
+  // Interpret format
+  switch (*(Item->getFormat())) {
+    case 'I':  R = asprintf(&Text, "%d", Item->getInt());   break;
+    case 'C':  R = asprintf(&Text, "%s", Item->getString());   break;
+    case 'S':  R = asprintf(&Text, "%hd", Item->getShort());   break;
+    case 'F':  R = asprintf(&Text, "%.3f", Item->getFloat());   break;
+    case 'D':  R = asprintf(&Text, "%.3f", Item->getDouble());   break;
+    case 'X':  R = asprintf(&Text, "%lld", Item->getLonglong());   break;
+    default: return NULL;
+  }
+
+  // Check if aprintf() worked OK
+  if (R != -1) return Text;
+  else return NULL;
+}
Index: /Evidence/Evidence.h
===================================================================
--- /Evidence/Evidence.h	(revision 127)
+++ /Evidence/Evidence.h	(revision 127)
@@ -0,0 +1,45 @@
+#ifndef EVIDENCE_H_SEEN
+#define EVIDENCE_H_SEEN
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include "dis.hxx"
+#include "dic.hxx"
+
+
+// Declaration of item for history buffer (see DColl.cc)
+struct EvidenceHistoryItem {
+  int Seconds;
+  double Value;
+} __attribute__((__packed__));
+
+// Class declation of Evidence server
+class EvidenceServer: public DimExitHandler, public DimErrorHandler {
+
+  private:
+    char *ServerName;
+	char *MsgBuffer;
+	void *ConfigList;
+	unsigned int ConfigNum;
+    DimService *Status;
+
+    static void SignalHandler(int);  // static needed for signal() function
+	void errorHandler(int, int, char *);
+	void exitHandler(int);
+	
+  public:
+    EvidenceServer(const char *);
+	~EvidenceServer();
+	
+	enum MsgType {INFO=0, WARN=1, ERROR=2, FATAL=3};
+
+	void Msg(MsgType, const char *, ...);
+	char* GetConfig(const char *);
+	static char *ToString(DimInfo *);
+	
+    static bool ExitRequest;
+};
+
+#endif
Index: /Evidence/start
===================================================================
--- /Evidence/start	(revision 127)
+++ /Evidence/start	(revision 127)
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Script to start Evidence control system
+
+export DIM_DNS_NODE=ihp-pc26.ethz.ch 
+
+xterm -T 'FConSys: Config' -e 'cd Config; Config' &
+sleep 0.5
+
+xterm -T 'FConSys: DColl' -e 'cd DColl; DColl' &
+sleep 0.5
+
+xterm -T 'FConSys: Alarm' -e 'cd Alarm; Alarm' &
