Index: trunk/FACT++/dim/src/dic.c
===================================================================
--- trunk/FACT++/dim/src/dic.c	(revision 14403)
+++ trunk/FACT++/dim/src/dic.c	(revision 14575)
@@ -64,15 +64,15 @@
 				    int req_timeout, void *service_address,
 				    int service_size, void (*usr_routine)(void*,void*,int*),
-				    long tag, void *fill_addr, int fill_size, int stamped) );
+				    dim_long tag, void *fill_addr, int fill_size, int stamped) );
 _DIM_PROTO( int request_command,      (char *service_name, void *service_address,
 				    int service_size, void (*usr_routine)(void*,int*),
-				    long tag, int stamped) );
+				    dim_long tag, int stamped) );
 _DIM_PROTO( DIC_SERVICE *insert_service, (int type, int timeout, char *name,
 				  int *address, int size, void (*routine)(),
-				  long tag, int *fill_addr, int fill_size,
+				  dim_long tag, int *fill_addr, int fill_size,
 				  int pending, int stamped ) );
 _DIM_PROTO( void modify_service, (DIC_SERVICE *servp, int timeout,
 				  int *address, int size, void (*routine)(),
-				  long tag, int *fill_addr, int fill_size, int stamped) );
+				  dim_long tag, int *fill_addr, int fill_size, int stamped) );
 _DIM_PROTO( DIC_SERVICE *locate_command, (char *serv_name) );
 _DIM_PROTO( DIC_SERVICE *locate_pending, (char *serv_name) );
@@ -586,5 +586,5 @@
 
 unsigned dic_info_service( char *serv_name, int req_type, int req_timeout, void *serv_address,
-			   int serv_size, void (*usr_routine)(), long tag, void *fill_addr, int fill_size )
+			   int serv_size, void (*usr_routine)(), dim_long tag, void *fill_addr, int fill_size )
 {
 	unsigned ret;
@@ -598,5 +598,5 @@
 
 unsigned dic_info_service_stamped( char *serv_name, int req_type, int req_timeout, void *serv_address,
-			   int serv_size, void (*usr_routine)(), long tag, void *fill_addr, int fill_size )
+			   int serv_size, void (*usr_routine)(), dim_long tag, void *fill_addr, int fill_size )
 {
 	unsigned ret;
@@ -610,5 +610,5 @@
 
 unsigned request_service( char *serv_name, int req_type, int req_timeout, void *serv_address,
-			   int serv_size, void (*usr_routine)(), long tag, void *fill_addr, int fill_size, int stamped )
+			   int serv_size, void (*usr_routine)(), dim_long tag, void *fill_addr, int fill_size, int stamped )
 {
 	register DIC_SERVICE *servp;
@@ -701,5 +701,5 @@
 
 int dic_cmnd_callback( char *serv_name, void *serv_address, int serv_size, 
-					  void (*usr_routine)(), long tag )
+					  void (*usr_routine)(), dim_long tag )
 {
 	int ret;
@@ -711,5 +711,5 @@
 
 int dic_cmnd_callback_stamped( char *serv_name, void *serv_address, int serv_size, 
-					  void (*usr_routine)(), long tag )
+					  void (*usr_routine)(), dim_long tag )
 {
 	int ret;
@@ -721,5 +721,5 @@
 
 int request_command(char *serv_name, void *serv_address, int serv_size, 
-					  void (*usr_routine)(), long tag, int stamped)
+					  void (*usr_routine)(), dim_long tag, int stamped)
 {
 	int conn_id, ret;
@@ -795,5 +795,5 @@
 
 DIC_SERVICE *insert_service( int type, int timeout, char *name, int *address, int size, 
-							void (*routine)(), long tag, int *fill_addr, int fill_size, 
+							void (*routine)(), dim_long tag, int *fill_addr, int fill_size, 
 							int pending, int stamped)
 {
@@ -869,5 +869,5 @@
 
 void modify_service( DIC_SERVICE *servp, int timeout, int *address, int size, void (*routine)(), 
-			 long tag, int *fill_addr, int fill_size, int stamped)
+			 dim_long tag, int *fill_addr, int fill_size, int stamped)
 {
 	int *fillp;
@@ -1153,5 +1153,5 @@
 int locate_service( DIC_SERVICE *servp )
 {
-	extern int open_dns(long, void (*)(), void (*)(), int, int, int);
+	extern int open_dns(dim_long, void (*)(), void (*)(), int, int, int);
 
 	if(!strcmp(servp->serv_name,"DIS_DNS/SERVER_INFO"))
@@ -1517,5 +1517,5 @@
 			if(tmout == 0)
 				tmout = 1;
-			dtq_start_timer(tmout, retry_bad_connection, (long)bad_connp);
+			dtq_start_timer(tmout, retry_bad_connection, (dim_long)bad_connp);
 			if(( servp->type == COMMAND )||( servp->type == ONCE_ONLY ))
 				return(0);
@@ -1987,5 +1987,5 @@
 		id = id_get((void *)itemp, SRC_DIC);
 */
-		dtq_start_timer(0, do_cmnd_callback, (long)itemp);
+		dtq_start_timer(0, do_cmnd_callback, (dim_long)itemp);
 /*
 		(servp->user_routine)( &servp->tag, &ret );
Index: trunk/FACT++/dim/src/diccpp.cxx
===================================================================
--- trunk/FACT++/dim/src/diccpp.cxx	(revision 14403)
+++ trunk/FACT++/dim/src/diccpp.cxx	(revision 14575)
@@ -20,16 +20,28 @@
 	if(DimClient::getNoDataCopy() == 0)
 	{
-		if(!t->itsDataSize)
-		{
-			t->itsData = new char[*size];
-			t->itsDataSize = *size;
-		}
-		else if(t->itsDataSize < *size)
-		{
-			delete[] (char *)(t->itsData);
-			t->itsData = new char[*size];
-			t->itsDataSize = *size;
-		}
-		memcpy(t->itsData, buf, *size);
+		if(*size > 0)
+		{
+			if(!t->itsDataSize)
+			{
+				t->itsData = new char[*size];
+				t->itsDataSize = *size;
+			}
+			else if(t->itsDataSize < *size)
+			{
+				delete[] (char *)(t->itsData);
+				t->itsData = new char[*size];
+				t->itsDataSize = *size;
+			}
+			memcpy(t->itsData, buf, *size);
+		}
+		else if (*size == 0)
+		{
+			if(t->itsDataSize)
+			{
+				delete[] (char *)(t->itsData);
+				t->itsDataSize = 0;
+			}
+			t->itsData = buf;
+		}
 	}
 	else
@@ -83,5 +95,5 @@
 	itsId = dic_info_service(itsName,itsType,itsTime, 0, 0,
 //		user_routine, itsTagId, 
-		user_routine, (long)this, 
+		user_routine, (dim_long)this, 
 		itsNolinkBuf, itsNolinkSize);
 	ENABLE_AST
@@ -134,5 +146,5 @@
 	itsId = dic_info_service(itsName,itsType,itsTime, 0, 0,
 //		user_routine, itsTagId, 
-		user_routine, (long)this, 
+		user_routine, (dim_long)this, 
 		itsNolinkBuf, itsNolinkSize);
 }
@@ -218,5 +230,5 @@
 	itsId = dic_info_service_stamped(itsName,itsType,itsTime, 0, 0,
 //		user_routine, itsTagId, 
-		user_routine, (long)this, 
+		user_routine, (dim_long)this, 
 		itsNolinkBuf, itsNolinkSize);
 	ENABLE_AST
@@ -276,5 +288,5 @@
 	itsId = dic_info_service_stamped(itsName,itsType,itsTime, 0, 0,
 //		user_routine, itsTagId, 
-		user_routine, (long)this, 
+		user_routine, (dim_long)this, 
 		itsNolinkBuf, itsNolinkSize);
 	ENABLE_AST
@@ -332,16 +344,28 @@
 //	t = (DimCurrentInfo *)id_get_ptr(id, SRC_DIC);
 	t = * (DimCurrentInfo **)tagp;
-	if(!t->itsDataSize)
-	{
-		t->itsData = new char[*size];
-		t->itsDataSize = *size;
-	}
-	else if(t->itsDataSize < *size)
-	{
-		delete[] (char *)(t->itsData);
-		t->itsData = new char[*size];
-		t->itsDataSize = *size;
-	}
-	memcpy(t->itsData, buf, *size);
+	if(*size > 0)
+	{
+		if(!t->itsDataSize)
+		{
+			t->itsData = new char[*size];
+			t->itsDataSize = *size;
+		}
+		else if(t->itsDataSize < *size)
+		{
+			delete[] (char *)(t->itsData);
+			t->itsData = new char[*size];
+			t->itsDataSize = *size;
+		}
+		memcpy(t->itsData, buf, *size);
+	}
+	else if (*size == 0)
+	{
+		if(t->itsDataSize)
+		{
+			delete[] (char *)(t->itsData);
+			t->itsDataSize = 0;
+		}
+		t->itsData = buf;
+	}
 	t->itsSize = *size;
 	t->wakeUp = 1;
@@ -390,5 +414,5 @@
 	dic_info_service(itsName,ONCE_ONLY,timeout, 0, 0,
 //		data_user_routine, itsTagId, 
-		data_user_routine, (long)this, 
+		data_user_routine, (dim_long)this, 
 		itsNolinkBuf, itsNolinkSize);
 }
@@ -464,5 +488,5 @@
 		dic_cmnd_callback(name, data, datasize, 
 //			cmnd_done, id);
-			cmnd_done, (long)this);
+			cmnd_done, (dim_long)this);
 		while(!wakeUp)
 		{
@@ -503,14 +527,25 @@
 	if(DimClient::getNoDataCopy() == 0)
 	{
-		if(!t->itsDataSize)
-		{
-			t->itsData = new char[size];
-			t->itsDataSize = size;
-		}
-		else if(t->itsDataSize < size)
-		{
-			delete[] (char *)(t->itsData);
-			t->itsData = new char[size];
-			t->itsDataSize = size;
+		if(size > 0)
+		{
+			if(!t->itsDataSize)
+			{
+				t->itsData = new char[size];
+				t->itsDataSize = size;
+			}
+			else if(t->itsDataSize < size)
+			{
+				delete[] (char *)(t->itsData);
+				t->itsData = new char[size];
+				t->itsDataSize = size;
+			}
+		}
+		else if (size == 0)
+		{
+			if(t->itsDataSize)
+			{
+				delete[] (char *)(t->itsData);
+				t->itsDataSize = 0;
+			}
 		}
 	}
@@ -525,5 +560,10 @@
 //printf("DIM RPC: Stopped Timer, Data Received for %s\n", t->getName());
 		if(DimClient::getNoDataCopy() == 0)
-			memcpy(t->itsData, buf, size);
+		{
+			if(size > 0)
+				memcpy(t->itsData, buf, size);
+			else
+				t->itsData = buf;
+		}
 		else
 			t->itsData = buf;
@@ -557,14 +597,25 @@
 	if(DimClient::getNoDataCopy() == 0)
 	{
-		if(!itsDataSize)
-		{
-			itsData = new char[size];
-			itsDataSize = size;
-		}
-		else if(itsDataSize < size)
-		{
-			delete[] (char *)(itsData);
-			itsData = new char[size];
-			itsDataSize = size;
+		if(size > 0)
+		{
+			if(!itsDataSize)
+			{
+				itsData = new char[size];
+				itsDataSize = size;
+			}
+			else if(itsDataSize < size)
+			{
+				delete[] (char *)(itsData);
+				itsData = new char[size];
+				itsDataSize = size;
+			}
+		}
+		else if (size == 0)
+		{
+			if(itsDataSize)
+			{
+				delete[] (char *)(itsData);
+				itsDataSize = 0;
+			}
 		}
 	}
@@ -572,5 +623,10 @@
 	{
 		if(DimClient::getNoDataCopy() == 0)
-			memcpy(itsData, buf, size);
+		{
+			if(size > 0)
+				memcpy(itsData, buf, size);
+			else
+				itsData = buf;
+		}
 		else
 			itsData = buf;
@@ -653,5 +709,5 @@
 				0, 0,
 //				rpc_user_routine, itsTagId, 
-				rpc_user_routine, (long)itsHandler, 
+				rpc_user_routine, (dim_long)itsHandler, 
 				itsNolinkBuf, itsNolinkSize);
 //			dim_usleep(200000);
@@ -704,5 +760,5 @@
 //printf("DIM RPC: Stopped Timer, Command failed for %s\n", itsName);
 //		rpc_user_routine((int *)&itsTagId, itsNolinkBuf, &itsNolinkSize);
-		rpc_user_routine((long *)&itsHandler, itsNolinkBuf, &itsNolinkSize);
+		rpc_user_routine((dim_long *)&itsHandler, itsNolinkBuf, &itsNolinkSize);
 	}
 /*
Index: trunk/FACT++/dim/src/dim_jni.c
===================================================================
--- trunk/FACT++/dim/src/dim_jni.c	(revision 14403)
+++ trunk/FACT++/dim/src/dim_jni.c	(revision 14575)
@@ -417,5 +417,5 @@
   int doit;
 
-  DBGe(dim_Dbg_SEND_CALLBACK) printf("DimJNI: client SEND_CALLBACK status %08lx:%d\n", (unsigned long)_status, *_status);
+  DBGe(dim_Dbg_SEND_CALLBACK) printf("DimJNI: client SEND_CALLBACK status %08lx:%d\n", (dim_long)_status, *_status);
 
   doit = dim_jni_attachThread(&env);
@@ -443,5 +443,5 @@
   jobject theSendSynchronizer;
   
-  extern int request_command(char *, void *, int , void (*)(), long, int);
+  extern int request_command(char *, void *, int , void (*)(), dim_long, int);
 
   const char* cmnd = (*env)->GetStringUTFChars(env, name, 0);
@@ -471,5 +471,5 @@
 
   // Send the request
-  ret = request_command((char *)cmnd, data_address, data_size, callback_funct, (long)callback_param, stamped);
+  ret = request_command((char *)cmnd, data_address, data_size, callback_funct, (dim_long)callback_param, stamped);
   DBGx(dim_Dbg_SEND_NATIVE) printf("DimJNI: Client.Send(%s,(%s) 0x%x) returns %d \n", cmnd, send_data_format, * (int*) data_address, ret);
 
@@ -868,5 +868,5 @@
 void info_service_callback(jobject* _theDataDecoder, void* dataAddress, int* _dataSize)
 {
-	DBGe(dim_Dbg_INFO_CALLBACK) printf("DimJNI: INFO_CALLBACK(data: %08lx(%08x))\n", (unsigned long) dataAddress, *_dataSize);
+	DBGe(dim_Dbg_INFO_CALLBACK) printf("DimJNI: INFO_CALLBACK(data: %08lx(%08x))\n", (dim_long) dataAddress, *_dataSize);
 
   decodeData(_theDataDecoder, dataAddress, _dataSize, 0);
@@ -877,5 +877,5 @@
 void info_service_callback_with_cleanup(jobject* _theDataDecoder, void* dataAddress, int* _dataSize)
 {
-	DBGe(dim_Dbg_INFO_CALLBACK) printf("DimJNI: INFO_CALLBACK/ONCE_ONLY(data: %08lx(%08x))\n", (unsigned long)dataAddress, *_dataSize);
+	DBGe(dim_Dbg_INFO_CALLBACK) printf("DimJNI: INFO_CALLBACK/ONCE_ONLY(data: %08lx(%08x))\n", (dim_long)dataAddress, *_dataSize);
 
   decodeData(_theDataDecoder, dataAddress, _dataSize, 1);
@@ -986,5 +986,5 @@
   const char* info = (*env)->GetStringUTFChars(env, name, 0);
   extern unsigned request_service(char *, int, int , void *, int , void (*)(),
-				    long, void *, int, int);
+				    dim_long, void *, int, int);
 
 //  DBGe(dim_Dbg_INFO_SERVICE); /* trap only, we report on exit */
@@ -1009,6 +1009,6 @@
 
 
-  ret = request_service((char *)info, service_type, timeout, 0, 0, callback_function, (long)callback_param, &no_link, 0, stamped);
-  DBGx(dim_Dbg_INFO_SERVICE) printf("DimJNI: client infoService(%s, DataDecoder@0x%08lx, mode=%d, timeout=%d ) returns %d\n", info, (unsigned long)theNativeDataDecoder, mode, timeout, ret);
+  ret = request_service((char *)info, service_type, timeout, 0, 0, callback_function, (dim_long)callback_param, &no_link, 0, stamped);
+  DBGx(dim_Dbg_INFO_SERVICE) printf("DimJNI: client infoService(%s, DataDecoder@0x%08lx, mode=%d, timeout=%d ) returns %d\n", info, (dim_long)theNativeDataDecoder, mode, timeout, ret);
   (*env)->ReleaseStringUTFChars(env, name, info);
 
@@ -1062,5 +1062,5 @@
 
 //printf("Stopping timer %08x %08X\n", callback_param, aDimTimer);
-  ret = dtq_stop_timer((long)callback_param);
+  ret = dtq_stop_timer((dim_long)callback_param);
  //printf("ret = %d\n", ret);
 
@@ -1263,5 +1263,5 @@
 //		printf("data address = %x, data size = %d\n",*address, *size);
 	}
-	DBGx(dim_Dbg_SERVICE_CALLBACK) printf("DimJNI: server_SERVICE_CALLBACK(dataEncoder=%08lx)\n        ==>    data: %08lx size %08x\n", (unsigned long)dataEncoder, (unsigned long) *address, *size); 
+	DBGx(dim_Dbg_SERVICE_CALLBACK) printf("DimJNI: server_SERVICE_CALLBACK(dataEncoder=%08lx)\n        ==>    data: %08lx size %08x\n", (dim_long)dataEncoder, (dim_long) *address, *size); 
 
 	if ((*env)->ExceptionOccurred(env)) (*env)->ExceptionDescribe(env); // clear any possible exception, if we do not do this, all further methods will fail!!
@@ -1409,5 +1409,5 @@
 	sid = dis_add_service(serviceNameUTF, serviceTypeUTF, 0, 0, server_getInfo_callback, dataEncoder);
 
-	DBGx(dim_Dbg_ADD_SERVICE) printf("DimJNI: Server.addService(%s,%s, @%08lx)=%d\n",serviceNameUTF, serviceTypeUTF, (unsigned long)dataEncoder, sid);
+	DBGx(dim_Dbg_ADD_SERVICE) printf("DimJNI: Server.addService(%s,%s, @%08lx)=%d\n",serviceNameUTF, serviceTypeUTF, (dim_long)dataEncoder, sid);
 
 	(*env)->ReleaseStringUTFChars(env, serviceName, serviceNameUTF);
@@ -1420,5 +1420,5 @@
 {
 
-	DBGe(dim_Dbg_CMND_CALLBACK) printf("DimJNI: server CMND_CALLBACK(data: %08lx(%08x))\n", (unsigned long) dataAddress, *_dataSize);
+	DBGe(dim_Dbg_CMND_CALLBACK) printf("DimJNI: server CMND_CALLBACK(data: %08lx(%08x))\n", (dim_long) dataAddress, *_dataSize);
 
   decodeData(_theDataDecoder, dataAddress, _dataSize, 0);
@@ -1443,5 +1443,5 @@
 	sid = dis_add_cmnd(serviceNameUTF, serviceTypeUTF, server_cmnd_callback, dataDecoder);
 
-	DBGx(dim_Dbg_ADD_CMND) printf("DimJNI: Server.addCmnd(%s,%s, @%08lx) = %d\n",serviceNameUTF, serviceTypeUTF, (unsigned long) dataDecoder, sid);
+	DBGx(dim_Dbg_ADD_CMND) printf("DimJNI: Server.addCmnd(%s,%s, @%08lx) = %d\n",serviceNameUTF, serviceTypeUTF, (dim_long) dataDecoder, sid);
 
 	(*env)->ReleaseStringUTFChars(env, serviceName, serviceNameUTF);
@@ -2396,6 +2396,6 @@
 	descriptor->maxEntries = maxEntries;
 
-	DBGx(dim_Dbg_DESCRIPTORS) printf("DimJNI: Native.newObjectDescriptor %08lx\n", (long)descriptor);
-	return (long) descriptor;
+	DBGx(dim_Dbg_DESCRIPTORS) printf("DimJNI: Native.newObjectDescriptor %08lx\n", (dim_long)descriptor);
+	return (dim_long) descriptor;
 }
 
@@ -2432,5 +2432,5 @@
 	// TODO throw an error if there is no such FieldID
 
-	DBGe(dim_Dbg_DESCRIPTORS) printf("DimJNI: Native.addFieldToObjectDescriptor %08lx Field %s Type %s\n", (long) desc, name, type);
+	DBGe(dim_Dbg_DESCRIPTORS) printf("DimJNI: Native.addFieldToObjectDescriptor %08lx Field %s Type %s\n", (dim_long) desc, name, type);
 	// TODO: if(entry==NULL) throw out-of-memory exception, set length to 0
 
@@ -2530,5 +2530,5 @@
  
 	if(nativeClass){}
-	DBGe(dim_Dbg_DESCRIPTORS) printf("DimJNI: Native.deleteObjectDescriptor %08lx\n", (long)desc);
+	DBGe(dim_Dbg_DESCRIPTORS) printf("DimJNI: Native.deleteObjectDescriptor %08lx\n", (dim_long)desc);
 	(*env)->DeleteGlobalRef(env, descriptor->objectClass);
 //printf("free descriptor\n");
@@ -2554,5 +2554,5 @@
 	jclass objectClass = descriptor->objectClass;
 
-	DBGe(dim_Dbg_DESCRIPTORS) printf("DimJNI: Native.copyIntoObject %08lx\n", (long)desc);
+	DBGe(dim_Dbg_DESCRIPTORS) printf("DimJNI: Native.copyIntoObject %08lx\n", (dim_long)desc);
 
 	if(nativeClass){}
Index: trunk/FACT++/dim/src/dim_thr.c
===================================================================
--- trunk/FACT++/dim/src/dim_thr.c	(revision 14403)
+++ trunk/FACT++/dim/src/dim_thr.c	(revision 14575)
@@ -225,5 +225,5 @@
 }
 
-long dim_start_thread(void *(*thread_ast)(void *), long tag)
+dim_long dim_start_thread(void *(*thread_ast)(void *), dim_long tag)
 {
 	pthread_t t_id;
@@ -237,8 +237,8 @@
 	pthread_create(&t_id, &attr, thread_ast, (void *)tag);
 #endif
-	return((long)t_id);
+	return((dim_long)t_id);
 }	
 
-int dim_stop_thread(long t_id)
+int dim_stop_thread(dim_long t_id)
 {
 	int ret;
@@ -533,12 +533,12 @@
 }
 
-long dim_start_thread(void (*thread_ast)(), long tag)
+dim_long dim_start_thread(void (*thread_ast)(), dim_long tag)
 
 {
 	printf("dim_start_thread: not available\n");
-	return (long)0;
-}
-
-int dim_stop_thread(long t_id)
+	return (dim_long)0;
+}
+
+int dim_stop_thread(dim_long t_id)
 {
 	printf("dim_stop_thread: not available\n");
@@ -563,12 +563,12 @@
 typedef struct{
 	void (*thread_ast)();
-	long tag;
+	dim_long tag;
 	
 }THREAD_PARAMS;
 
 #ifndef STDCALL
-long dim_start_thread(void (*thread_ast)(), long tag)
-#else
-long dim_start_thread(unsigned long (*thread_ast)(void *), void *tag)
+dim_long dim_start_thread(void (*thread_ast)(), dim_long tag)
+#else
+dim_long dim_start_thread(dim_long (*thread_ast)(void *), void *tag)
 #endif
 {
@@ -593,9 +593,9 @@
         &threadid);					 /* returns the thread identifier	*/
 #endif
-	return (long)hthread;
-}
-
-
-int dim_stop_thread(long thread_id)
+	return (dim_long)hthread;
+}
+
+
+int dim_stop_thread(dim_long thread_id)
 {
 	int ret;
Index: trunk/FACT++/dim/src/dis.c
===================================================================
--- trunk/FACT++/dim/src/dis.c	(revision 14403)
+++ trunk/FACT++/dim/src/dis.c	(revision 14575)
@@ -37,5 +37,5 @@
 	struct dis_dns_ent *next;
 	struct dis_dns_ent *prev;
-	long dnsid;
+	dim_long dnsid;
 	char task_name[MAX_NAME];
 	TIMR_ENT *dns_timr_ent;
@@ -78,5 +78,5 @@
 	int size;
 	void (*user_routine)();
-	long tag;
+	dim_long tag;
 	int registered;
 	int quality;
@@ -163,7 +163,7 @@
 _DIM_PROTO( void register_dns_services,  (int flag) );
 _DIM_PROTO( void register_services,  (DIS_DNS_CONN *dnsp, int flag, int dns_flag) );
-_DIM_PROTO( void std_cmnd_handler,   (long *tag, int *cmnd_buff, int *size) );
-_DIM_PROTO( void client_info,		(long *tag, int **bufp, int *size) );
-_DIM_PROTO( void service_info,	   (long *tag, int **bufp, int *size) );
+_DIM_PROTO( void std_cmnd_handler,   (dim_long *tag, int *cmnd_buff, int *size) );
+_DIM_PROTO( void client_info,		(dim_long *tag, int **bufp, int *size) );
+_DIM_PROTO( void service_info,	   (dim_long *tag, int **bufp, int *size) );
 _DIM_PROTO( void add_exit_handler,   (int *tag, int *bufp, int *size) );
 _DIM_PROTO( static void exit_handler,	   (int *tag, int *bufp, int *size) );
@@ -176,6 +176,6 @@
 _DIM_PROTO( SERVICE *dis_hash_service_get_next, (int *start, SERVICE *prev, int flag) );
 _DIM_PROTO( static unsigned do_dis_add_service_dns, (char *name, char *type, void *address, int size, 
-								   void (*user_routine)(), long tag, long dnsid ) );
-_DIM_PROTO( static DIS_DNS_CONN *create_dns, (long dnsid) );
+								   void (*user_routine)(), dim_long tag, dim_long dnsid ) );
+_DIM_PROTO( static DIS_DNS_CONN *create_dns, (dim_long dnsid) );
 
 void dis_set_debug_on()
@@ -232,5 +232,5 @@
 
 static unsigned do_dis_add_service_dns( char *name, char *type, void *address, int size, 
-								   void (*user_routine)(), long tag, long dnsid )
+								   void (*user_routine)(), dim_long tag, dim_long dnsid )
 {
 	register SERVICE *new_serv;
@@ -239,5 +239,5 @@
 	int dis_hash_service_insert();
 	DIS_DNS_CONN *dnsp;
-	extern DIS_DNS_CONN *dis_find_dns(long);
+	extern DIS_DNS_CONN *dis_find_dns(dim_long);
 
 	dis_init();
@@ -324,5 +324,5 @@
 
 static unsigned do_dis_add_service( char *name, char *type, void *address, int size, 
-								   void (*user_routine)(), long tag )
+								   void (*user_routine)(), dim_long tag )
 {
 	return do_dis_add_service_dns( name, type, address, size, 
@@ -369,5 +369,5 @@
 
 unsigned dis_add_service( char *name, char *type, void *address, int size, 
-						 void (*user_routine)(), long tag)
+						 void (*user_routine)(), dim_long tag)
 {
 	unsigned ret;
@@ -389,6 +389,6 @@
 }
 
-unsigned dis_add_service_dns( long dnsid, char *name, char *type, void *address, int size, 
-							 void (*user_routine)(), long tag)
+unsigned dis_add_service_dns( dim_long dnsid, char *name, char *type, void *address, int size, 
+							 void (*user_routine)(), dim_long tag)
 {
 	unsigned ret;
@@ -410,5 +410,5 @@
 }
 
-static unsigned do_dis_add_cmnd_dns( char *name, char *type, void (*user_routine)(), long tag, long dnsid )
+static unsigned do_dis_add_cmnd_dns( char *name, char *type, void (*user_routine)(), dim_long tag, dim_long dnsid )
 {
 	register SERVICE *new_serv;
@@ -417,5 +417,5 @@
 	int dis_hash_service_insert();
 	DIS_DNS_CONN *dnsp;
-	extern DIS_DNS_CONN *dis_find_dns(long);
+	extern DIS_DNS_CONN *dis_find_dns(dim_long);
 
 	dis_init();
@@ -488,10 +488,10 @@
 }
 
-static unsigned do_dis_add_cmnd( char *name, char *type, void (*user_routine)(), long tag)
+static unsigned do_dis_add_cmnd( char *name, char *type, void (*user_routine)(), dim_long tag)
 {
 	return do_dis_add_cmnd_dns(name, type, user_routine, tag, 0);
 }
 
-unsigned dis_add_cmnd( char *name, char *type, void (*user_routine)(), long tag ) 
+unsigned dis_add_cmnd( char *name, char *type, void (*user_routine)(), dim_long tag ) 
 {
 	unsigned ret;
@@ -507,5 +507,5 @@
 }
 
-unsigned dis_add_cmnd_dns( long dnsid, char *name, char *type, void (*user_routine)(), long tag ) 
+unsigned dis_add_cmnd_dns( dim_long dnsid, char *name, char *type, void (*user_routine)(), dim_long tag ) 
 {
 	unsigned ret;
@@ -643,5 +643,5 @@
 	int dns_timr_time;
 	extern int rand_tmout(int, int);
-	extern int open_dns(long, void (*)(), void (*)(), int, int, int);
+	extern int open_dns(dim_long, void (*)(), void (*)(), int, int, int);
 	extern DIS_DNS_CONN *find_dns_by_conn_id(int);
 	extern void do_register_services(DIS_DNS_CONN *);
@@ -1044,5 +1044,5 @@
 }
 
-static DIS_DNS_CONN *create_dns(long dnsid)
+static DIS_DNS_CONN *create_dns(dim_long dnsid)
 {
 	DIS_DNS_CONN *dnsp;
@@ -1090,5 +1090,5 @@
 }
 
-int dis_start_serving_dns(long dnsid, char *task/*, int *idlist*/)
+int dis_start_serving_dns(dim_long dnsid, char *task/*, int *idlist*/)
 {
 	char str0[MAX_NAME], str1[MAX_NAME],str2[MAX_NAME],
@@ -1096,5 +1096,5 @@
 	char task_name_aux[MAX_TASK_NAME];
 	extern int open_dns();
-	extern DIS_DNS_CONN *dis_find_dns(long);
+	extern DIS_DNS_CONN *dis_find_dns(dim_long);
 	DIS_DNS_CONN *dnsp;
 	int more_ids[10] = {0};
@@ -1161,7 +1161,7 @@
 				 sizeof(Version_number), 0, 0, dnsid );
 
-		more_ids[1] = do_dis_add_service_dns( str1, "C", 0, 0, client_info, (long)dnsp, dnsid );
+		more_ids[1] = do_dis_add_service_dns( str1, "C", 0, 0, client_info, (dim_long)dnsp, dnsid );
 		dnsp->dis_client_id = more_ids[1];
-		more_ids[2] = do_dis_add_service_dns( str2, "C", 0, 0, service_info, (long)dnsp, dnsid );
+		more_ids[2] = do_dis_add_service_dns( str2, "C", 0, 0, service_info, (dim_long)dnsp, dnsid );
 		dnsp->dis_service_id = more_ids[2];
 		more_ids[3] = do_dis_add_cmnd_dns( str3, "L:1", add_exit_handler, 0, dnsid );
@@ -1757,6 +1757,6 @@
 dim_print_date_time();
 printf("Updating %s (id = %d, ptr = %08lX) for %s@%s (req_id = %d, req_ptr = %08lX)\n",
-	   servp->name, (int)service_id, (unsigned long)servp, 
-	   Net_conns[reqp->conn_id].task, Net_conns[reqp->conn_id].node, reqp->req_id, (unsigned long)reqp);
+	   servp->name, (int)service_id, (unsigned dim_long)servp, 
+	   Net_conns[reqp->conn_id].task, Net_conns[reqp->conn_id].node, reqp->req_id, (unsigned dim_long)reqp);
 }
 */
@@ -2225,5 +2225,5 @@
 int dis_no_dns();
 int hash_index, old_index;
-extern int close_dns(long, int);
+extern int close_dns(dim_long, int);
 CLIENT *clip, *cprevp;
 
@@ -2332,5 +2332,5 @@
 }
 
-void dis_stop_serving_dns(long dnsid)
+void dis_stop_serving_dns(dim_long dnsid)
 {
 	DIS_DNS_CONN *dnsp, *dis_find_dns();
@@ -2726,5 +2726,5 @@
 typedef struct cmnds{
 	struct cmnds *next;
-	long tag;
+	dim_long tag;
 	int size;
 	int buffer[1];
@@ -2733,5 +2733,5 @@
 static DIS_CMND *Cmnds_head = (DIS_CMND *)0;
 
-void std_cmnd_handler(long *tag, int *cmnd_buff, int *size)
+void std_cmnd_handler(dim_long *tag, int *cmnd_buff, int *size)
 {
 	register DIS_CMND *new_cmnd;
@@ -2751,5 +2751,5 @@
 }
 
-int dis_get_next_cmnd(long *tag, int *buffer, int *size)
+int dis_get_next_cmnd(dim_long *tag, int *buffer, int *size)
 {
 	register DIS_CMND *cmndp;
@@ -2829,5 +2829,5 @@
 #endif
 
-void client_info(long *tag, int **bufp, int *size, int *first_time)
+void client_info(dim_long *tag, int **bufp, int *size, int *first_time)
 {
 	register CLIENT *clip;
@@ -2953,5 +2953,5 @@
 }
 
-void service_info(long *tag, int **bufp, int *size, int *first_time)
+void service_info(dim_long *tag, int **bufp, int *size, int *first_time)
 {
 	register SERVICE *servp;
@@ -3334,5 +3334,5 @@
 }
 
-DIS_DNS_CONN *dis_find_dns(long dnsid)
+DIS_DNS_CONN *dis_find_dns(dim_long dnsid)
 {
 	DIS_DNS_CONN *dnsp;
@@ -3369,6 +3369,6 @@
 {
 	DIS_DNS_CONN *dnsp;
-	extern long dns_get_dnsid();
-	long dnsid;
+	extern dim_long dns_get_dnsid();
+	dim_long dnsid;
 
 	dnsid = dns_get_dnsid(conn_id, SRC_DIS);
Index: trunk/FACT++/dim/src/discpp.cxx
===================================================================
--- trunk/FACT++/dim/src/discpp.cxx	(revision 14403)
+++ trunk/FACT++/dim/src/discpp.cxx	(revision 14575)
@@ -61,5 +61,5 @@
 		itsId = dis_add_service( name, format, NULL, 0, 
 //				user_routine, itsTagId);
-				user_routine, (long)this);
+				user_routine, (dim_long)this);
 		DimServer::start();
 	}
@@ -68,5 +68,5 @@
 		itsId = dis_add_service_dns( itsDns->getDnsId(), name, format, NULL, 0, 
 //				user_routine, itsTagId);
-				user_routine, (long)this);
+				user_routine, (dim_long)this);
 //		itsDns->addServiceId(itsId);
 		DimServer::start(itsDns);
@@ -139,5 +139,5 @@
 		itsId = dis_add_cmnd( name, format, command_routine,
 //				itsTagId);
-				(long)this);
+				(dim_long)this);
 		DimServer::start();
 	}
@@ -146,5 +146,5 @@
 		itsId = dis_add_cmnd_dns( itsDns->getDnsId(), name, format, command_routine,
 //			itsTagId);
-			(long)this);
+			(dim_long)this);
 //		itsDns->addServiceId(itsId);
 		DimServer::start(itsDns);
@@ -248,8 +248,8 @@
 		itsIdIn = dis_add_cmnd( itsNameIn, formatin, 
 //			rpcin_routine, itsTagId);
-			rpcin_routine, (long)this);
+			rpcin_routine, (dim_long)this);
 		itsIdOut = dis_add_service( itsNameOut, formatout, 0,0, 
 //			rpcout_routine, itsTagId);
-			rpcout_routine, (long)this);
+			rpcout_routine, (dim_long)this);
 		DimServer::start();
 	}
@@ -258,8 +258,8 @@
 		itsIdIn = dis_add_cmnd_dns( itsDns->getDnsId(), itsNameIn, formatin, 
 //			rpcin_routine, itsTagId);
-			rpcin_routine, (long)this);
+			rpcin_routine, (dim_long)this);
 		itsIdOut = dis_add_service_dns( itsDns->getDnsId(), itsNameOut, formatout, 0,0, 
 //			rpcout_routine, itsTagId);
-			rpcout_routine, (long)this);
+			rpcout_routine, (dim_long)this);
 //		itsDns->addServiceId(itsIdIn);
 //		itsDns->addServiceId(itsIdOut);
@@ -369,5 +369,5 @@
 }
 
-long DimServerDns::getDnsId()
+dim_long DimServerDns::getDnsId()
 {
 	return itsDnsId;
@@ -445,5 +445,5 @@
 void DimServer::start(DimServerDns *dns, const char *name)
 {
-	long dnsid;
+	dim_long dnsid;
 
 	DISABLE_AST
@@ -487,5 +487,5 @@
 void DimServer::start(DimServerDns *dns)
 {
-	long dnsid;
+	dim_long dnsid;
 	char *name;
 	int isAuto;
@@ -669,5 +669,5 @@
 }
 
-long DimServer::addDns(const char *node, int port) 
+dim_long DimServer::addDns(const char *node, int port) 
 {
 	return dis_add_dns((char *)node, port); 
Index: trunk/FACT++/dim/src/dtq.c
===================================================================
--- trunk/FACT++/dim/src/dtq.c	(revision 14403)
+++ trunk/FACT++/dim/src/dtq.c	(revision 14575)
@@ -389,5 +389,5 @@
 }
 	
-TIMR_ENT *dtq_add_entry(int queue_id, int time, void (*user_routine)(), long tag)
+TIMR_ENT *dtq_add_entry(int queue_id, int time, void (*user_routine)(), dim_long tag)
 {
 	TIMR_ENT *new_entry, *queue_head, *auxp, *prevp;
@@ -780,5 +780,5 @@
 }
 
-void dtq_start_timer(int time, void (*user_routine)(), long tag)
+void dtq_start_timer(int time, void (*user_routine)(), dim_long tag)
 {
 	extern void dim_init_threads();
@@ -796,5 +796,5 @@
 
 
-int dtq_stop_timer(long tag)
+int dtq_stop_timer(dim_long tag)
 {
 	TIMR_ENT *entry, *queue_head;
@@ -816,5 +816,5 @@
 static int Dtq_sleeping = 0;
 
-void dtq_sleep_rout(long tag)
+void dtq_sleep_rout(dim_long tag)
 {
 	if(tag){}
Index: trunk/FACT++/dim/src/examples/rpc_client.cxx
===================================================================
--- trunk/FACT++/dim/src/examples/rpc_client.cxx	(revision 14403)
+++ trunk/FACT++/dim/src/examples/rpc_client.cxx	(revision 14575)
@@ -41,5 +41,5 @@
 	int out, in;
 	
-	sprintf(name,"TESTRPC%d/INT",(long)tag);
+	sprintf(name,"TESTRPC%d/INT",(dim_long)tag);
 	myRpc = new DimRpcInfo(name, 10, -1);
 //	myRpc = new Rpc(name);
@@ -54,5 +54,5 @@
 dim_lock();
 dim_print_date_time();
-cout << "Instance "<<(long)tag<<" sent "<<out<< " got "<<in <<endl;
+cout << "Instance "<<(dim_long)tag<<" sent "<<out<< " got "<<in <<endl;
 dim_unlock();
 		out++;
Index: trunk/FACT++/dim/src/examples/test_client.c
===================================================================
--- trunk/FACT++/dim/src/examples/test_client.c	(revision 14403)
+++ trunk/FACT++/dim/src/examples/test_client.c	(revision 14575)
@@ -57,5 +57,5 @@
 {
 	if(tag){}
-	printf("Received VERSION %lx, %d\n", (long)buf, *size);
+	printf("Received VERSION %lx, %d\n", (dim_long)buf, *size);
 }
 
Index: trunk/FACT++/dim/src/examples/test_server.c
===================================================================
--- trunk/FACT++/dim/src/examples/test_server.c	(revision 14403)
+++ trunk/FACT++/dim/src/examples/test_server.c	(revision 14575)
@@ -70,5 +70,5 @@
 	int on = 0;
 */
-	long dnsid = 0;
+	dim_long dnsid = 0;
 	char extra_dns[128];
 	int new_dns = 0;
Index: trunk/FACT++/dim/src/open_dns.c
===================================================================
--- trunk/FACT++/dim/src/open_dns.c	(revision 14403)
+++ trunk/FACT++/dim/src/open_dns.c	(revision 14575)
@@ -173,5 +173,5 @@
 	char node[MAX_DNS_NODE];
 	int port;
-	long sid, cid;
+	dim_long sid, cid;
 
 	DISABLE_AST
@@ -235,5 +235,5 @@
 }
 
-long dis_add_dns(char *node_name, int port_number)
+dim_long dis_add_dns(char *node_name, int port_number)
 {
 	DNS_CONN *connp;
@@ -253,8 +253,8 @@
 		dll_insert_queue( (DLL *) DNS_conn_head, (DLL *) connp );
 	}
-	return (long)connp;
-}
-
-long dic_add_dns(char *node_name, int port_number)
+	return (dim_long)connp;
+}
+
+dim_long dic_add_dns(char *node_name, int port_number)
 {
 	DNS_CONN *connp;
@@ -274,5 +274,5 @@
 		dll_insert_queue( (DLL *) DNS_conn_head, (DLL *) connp );
 	}
-	return (long)connp;
+	return (dim_long)connp;
 }
 
@@ -296,5 +296,5 @@
 }
 
-int close_dns(long dnsid, SRC_TYPES src_type)
+int close_dns(dim_long dnsid, SRC_TYPES src_type)
 {
 	DNS_CONN *connp;
@@ -311,5 +311,5 @@
 }
 
-int open_dns(long dnsid, void (*recv_rout)(), void (*error_rout)(), int tmout_min, int tmout_max, SRC_TYPES src_type )
+int open_dns(dim_long dnsid, void (*recv_rout)(), void (*error_rout)(), int tmout_min, int tmout_max, SRC_TYPES src_type )
 {
 	char nodes[MAX_DNS_NODE];
@@ -424,5 +424,5 @@
 }	
 
-long dns_get_dnsid(int conn_id, SRC_TYPES src_type)
+dim_long dns_get_dnsid(int conn_id, SRC_TYPES src_type)
 {
 	DNS_CONN *connp;
@@ -449,11 +449,11 @@
 		if(connp == DNS_ids[src_type])
 		{
-			return (long)0;
+			return (dim_long)0;
 		}
 		else
 		{
-			return (long)connp;
-		}
-	}
-	return (long)-1;
-}
+			return (dim_long)connp;
+		}
+	}
+	return (dim_long)-1;
+}
