[med-svn] [conquest-dicom-server] 02/04: Imported Upstream version 1.4.17d

Pablo Lorenzzoni spectra at moszumanska.debian.org
Wed Mar 19 20:46:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

spectra pushed a commit to branch master
in repository conquest-dicom-server.

commit 3c0effe1a24c12041a1a35fd08acfaa4275e57e1
Author: Pablo Lorenzzoni <spectra at debian.org>
Date:   Wed Mar 19 16:47:41 2014 -0300

    Imported Upstream version 1.4.17d
---
 DicomConformance_FilesLST_Changes.pdf | Bin 599714 -> 602752 bytes
 aarj.cxx                              |   5 +-
 buffer.cxx                            |   3 +-
 dbsql.cpp                             |  44 +++++--
 device.cpp                            |  22 +++-
 dgate.cpp                             | 236 ++++++++++++++++++++++++++++++++--
 flpdu.cxx                             |  41 +++---
 linuxmanual.pdf                       | Bin 146456 -> 146426 bytes
 lua/anonymize_script.lua              |  10 +-
 lua/deanonymize_script.lua            |   3 +-
 lua/livecoding.lua                    |   7 +-
 lua/niftytest.lua                     |   4 +-
 lua/overview.lua                      |   5 +
 lua/welcome.lua                       |   4 +-
 nkiqrsop.cpp                          | 103 +++++++++++++--
 trnsyn.cxx                            |   7 +
 vrtosql.cpp                           |   8 +-
 windowsmanual.pdf                     | Bin 1383178 -> 1384733 bytes
 18 files changed, 430 insertions(+), 72 deletions(-)

diff --git a/DicomConformance_FilesLST_Changes.pdf b/DicomConformance_FilesLST_Changes.pdf
index 64a4e9e..85bac6c 100644
Binary files a/DicomConformance_FilesLST_Changes.pdf and b/DicomConformance_FilesLST_Changes.pdf differ
diff --git a/aarj.cxx b/aarj.cxx
index 6ada90d..536cc15 100644
--- a/aarj.cxx
+++ b/aarj.cxx
@@ -29,6 +29,7 @@
 
 /* bcb 20100619: Fix gcc4 warnings and improve speed.
    mvh 20100717: Merged
+   mvh 20140309: Default AAbort source to 0 (service-user initiated abort)
 */
 
 #	include	"dicom.hpp"
@@ -252,7 +253,7 @@ Reserved1(0),
 Length(0),
 Reserved2(0),
 Reserved3(0),
-Source(3),
+Source(0),
 Reason(1) {}
 #else
 	{
@@ -260,7 +261,7 @@ Reason(1) {}
 	Reserved1 = 0;
 	Reserved2 = 0;
 	Reserved3 = 0;
-	Source = 3;
+	Source = 0;
 	Reason = 1;
 	}
 #endif
diff --git a/buffer.cxx b/buffer.cxx
index 08130e0..eeb4d69 100644
--- a/buffer.cxx
+++ b/buffer.cxx
@@ -6,6 +6,7 @@
 /* mvh 20100717: Merged */
 /* mvh 20130416: Set DEFAULT_BREAK_SIZE for UNIX to 8192 to fix not understood 
                  ubuntu12.04 problem with zeros tranmitted after 1st 64k 
+Spectra-0009: Wed, 5 Feb 2014 10:57:52 +0000: Fix cppcheck bug #1
 */
 
 /****************************************************************************
@@ -437,7 +438,7 @@ BOOL	Buffer	::	Kill(UINT	Bytes)
         if (!Data) DicomError(DCM_ERROR_MEMORY, "Bufferspace: out of memory allocating %d bytes\n", Bytes+1);
 
 	Ret = Read(Data, Bytes);
-	delete Data;
+	delete [] Data;
 	return ( Ret );
 	}
 	
diff --git a/dbsql.cpp b/dbsql.cpp
index e364c13..5240a40 100644
--- a/dbsql.cpp
+++ b/dbsql.cpp
@@ -213,6 +213,7 @@
 20130807	mvh	Worked on accepting data without patient ID if AllowEmptyPatientID = 1
 20130808	mvh	Added substitution of patient ID for database purpose if AllowEmptyPatientID = 1
 20131013	mvh	Default TruncateFieldNames set to 10
+20140309	mvh	ChangeUID functions leave empty UID as is and escape '
 */
 
 #define NCACHE 256
@@ -1953,7 +1954,6 @@ dbGenUID(char	*oString)
 CRITICAL_SECTION ChangeUIDCritical;
 BOOL ChangeUIDCriticalInit=FALSE;
 
-
 BOOL
 ChangeUID(char *OldUID, const char *Type, char *NewUID)
 	{
@@ -1962,6 +1962,12 @@ ChangeUID(char *OldUID, const char *Type, char *NewUID)
 	Database	DB;
 	SQLLEN		sdword;
 
+	if (OldUID[0]==0) 
+		{
+		*NewUID = 0;
+		return TRUE;
+		}
+
 	if (!ChangeUIDCriticalInit)
 	{ InitializeCriticalSection(&ChangeUIDCritical);
 	  ChangeUIDCriticalInit = TRUE;
@@ -1974,8 +1980,12 @@ ChangeUID(char *OldUID, const char *Type, char *NewUID)
 		}
 
 	EnterCriticalSection(&ChangeUIDCritical);
+	
+	char old[512];
+	strcpy(old, OldUID);
+	DICOM2SQLValue(old);
 
-	sprintf(s, "OldUID = '%s'", OldUID);
+	sprintf(s, "OldUID = %s", old);
 	if(!DB.Query("UIDMODS", "NewUID", s, NULL))
 		{
 		SystemDebug.printf("***Unable to query UIDMODS table\n");
@@ -1995,9 +2005,9 @@ ChangeUID(char *OldUID, const char *Type, char *NewUID)
 		dbGenUID(NewUID);
 		SystemDebug.printf("NewUID for %s = %s\n", Type, NewUID);
 
-		sprintf(Values, "%u, '", (unsigned int)time(NULL));
-		strcat(Values, OldUID);
-		strcat(Values, "', '");
+		sprintf(Values, "%u, ", (unsigned int)time(NULL));
+		strcat(Values, old);
+		strcat(Values, ", '");
 		strcat(Values, Type);
 		strcat(Values, "', '");
 		strcat(Values, NewUID);
@@ -2029,6 +2039,12 @@ ChangeUIDTo(char *OldUID, char *Type, char *NewUID)
 	Database	DB;
 	SQLLEN		sdword;
 
+	if (OldUID[0]==0) 
+		{
+		*NewUID = 0;
+		return TRUE;
+		}
+
 	if (!ChangeUIDCriticalInit)
 	{ InitializeCriticalSection(&ChangeUIDCritical);
 	  ChangeUIDCriticalInit = TRUE;
@@ -2043,7 +2059,11 @@ ChangeUIDTo(char *OldUID, char *Type, char *NewUID)
 		return ( FALSE );
 		}
 
-	sprintf(s, "OldUID = '%s'", OldUID);
+	char old[512];
+	strcpy(old, OldUID);
+	DICOM2SQLValue(old);
+
+	sprintf(s, "OldUID = %s", old);
 	if(!DB.Query("UIDMODS", "NewUID", s, NULL))
 		{
 		SystemDebug.printf("***Unable to query UIDMODS table\n");
@@ -2062,9 +2082,9 @@ ChangeUIDTo(char *OldUID, char *Type, char *NewUID)
 		{
 		SystemDebug.printf("NewUID for %s = %s\n", Type, NewUID);
 
-		sprintf(Values, "%u, '", (unsigned int)time(NULL));
-		strcat(Values, OldUID);
-		strcat(Values, "', '");
+		sprintf(Values, "%u, ", (unsigned int)time(NULL));
+		strcat(Values, old);
+		strcat(Values, ", '");
 		strcat(Values, Type);
 		strcat(Values, "', '");
 		strcat(Values, NewUID);
@@ -2094,6 +2114,12 @@ ChangeUIDBack(char *NewUID, char *OldUID)
 	Database	DB;
 	SQLLEN		sdword;
 
+	if (NewUID[0]==0) 
+		{
+		*OldUID = 0;
+		return TRUE;
+		}
+
 	if (!DB.Open ( DataSource, UserName, Password, DataHost ) )
 		{
 		SystemDebug.printf("***ChangeUIDBack: Unable to connect to SQL\n");
diff --git a/device.cpp b/device.cpp
index 02cf3cd..9022481 100644
--- a/device.cpp
+++ b/device.cpp
@@ -106,6 +106,10 @@
 20110904	mvh	Fixed leak in InitializeDeviceTable (occurs in read_ini command)
 20120723	mvh	Fixed string overflow found by bcb in MakeListOfLRUPatients
 20130817	mvh	TestFile will uncompress all read data to test it
+Spectra0011 Wed, 5 Feb 2014 14:36:36 +0000: Fix cppcheck bug #4 (strncpy termination)
+Spectra0010 Wed, 5 Feb 2014 11:54:40 +0000: Fix cppcheck bug #3 (and others in same function)
+20140215	mvh	Fixed potential Patlist memory leaks; and also always free PatientIDList in calling;
+
 */
 
 #ifndef UNUSED_ARGUMENT
@@ -782,6 +786,7 @@ CheckFreeStoreOnCACHEDevice(
         if (CACHENumber >= CACHEDevices || CACHENumber < 0) return 0; 
 
         strncpy(s, CACHEDeviceTable[CACHENumber], 1023); 
+	s[1023] = '\0';
 
         if ((chp = strchr(s, '%'))) 
         { 
@@ -2867,6 +2872,7 @@ MakeListOfPatientsOnDevice(char *Device, char **PatientIDList)
 	int 			Patients, NPat, MAXPATIENTS = 10000, i;
 	char			*PatList;
 	
+	*PatientIDList = NULL;
 	
 	if (!DB.Open ( DataSource, UserName, Password, DataHost ) )
 		return -1;
@@ -2894,10 +2900,16 @@ MakeListOfPatientsOnDevice(char *Device, char **PatientIDList)
 		if (PatList==NULL) return -1;
 
 		if (!DB.QueryDistinct(PatientTableName, "PatientID", "", "DICOMPatients.AccessTime"))
+			{
+			free(PatList);
 			return -1;
+			}
 
 		if(!DB.BindField (1, SQL_C_CHAR, PatientID, 68, &sdword))
+			{
+			free(PatList);
 			return -1;
+			}
 
 		NPat = 0;
 		while(DB.NextRecord())
@@ -2930,7 +2942,6 @@ MakeListOfPatientsOnDevice(char *Device, char **PatientIDList)
 			if (!DB.Query(ImageTableName, "ImagePat", QueryString, ""))
 				{
 				free (PatList);
-				free (PatientIDList);
 				return -1;
 				}
 
@@ -2970,7 +2981,8 @@ MakeListOfPatientsOnDevice(char *Device, char **PatientIDList)
 		return -1;
 
 	*PatientIDList = (char *)malloc(256 * MAXPATIENTS);
-	if (*PatientIDList==NULL) return -1;
+	if (*PatientIDList==NULL) 
+		return -1;
 
 	Patients       = 0;
 
@@ -3291,6 +3303,7 @@ PrepareBunchForBurning(char *DeviceFrom, char *DeviceTo)
 	if (NPatients < 0)
 		{
 		OperatorConsole.printf("Archival: *** could not create patient list\n");
+		free (PatientIDList);
 		return FALSE;
 		}
 
@@ -3483,6 +3496,7 @@ MoveDataToDevice(char *DeviceFrom, char *DeviceTo)
 	if (NPatients < 0)
 		{
 		OperatorConsole.printf("MoveDataToDevice: *** could not create patient list\n");
+		free (PatientIDList);
 		return FALSE;
 		}
 
@@ -3753,6 +3767,7 @@ CompareBunchAfterBurning(char *DeviceTo)
 	if (NPatients < 0)
 		{
 		OperatorConsole.printf("Archival: *** could not create patient list\n");
+		free (PatientIDList);
 		return FALSE;
 		}
 
@@ -3815,6 +3830,7 @@ DeleteBunchAfterBurning(char *DeviceTo)
 	if (NPatients < 0)
 		{
 		OperatorConsole.printf("Archival: *** could not create patient list\n");
+		free (PatientIDList);
 		return FALSE;
 		}
 
@@ -3910,6 +3926,7 @@ VerifyMirrorDisk(char *DeviceFrom)
 	if (NPatients < 0)
 		{
 		OperatorConsole.printf("Archival: *** could not create patient list\n");
+		free (PatientIDList);
 		return FALSE;
 		}
 
@@ -3955,6 +3972,7 @@ TestImages(char *DeviceFrom)
 	if (NPatients < 0)
 		{
 		OperatorConsole.printf("Archival: *** could not create patient list\n");
+		free (PatientIDList);
 		return FALSE;
 		}
 
diff --git a/dgate.cpp b/dgate.cpp
index 20c6e3f..99e5f70 100644
--- a/dgate.cpp
+++ b/dgate.cpp
@@ -984,11 +984,22 @@ mvh 20090616: Add ^/~ after % command to convert to upper/lowercase, %^ %~ %[; f
 20131103	mvh	Fix in VirtualServerPerSeries when exact #images, would omit SOP tag but set level to IMAGE
 20131104        mvh     Reversed logic: 1 image gives IMAGE move and SOP uid
 20131107        mvh     Added quality clause to save jpg; Release 1.4.17c
+20131219        mvh     Fixed that MIRRORDevice0 setting starts mirror copy thread
+20140128        mvh     added copydicom(source) DicomObject:Copy(); DicomObject:Compress(string)
+20140209        mvh     Added dgate --compress: command
+Spectra0008 Tue, 4 Feb 2014 17:40:17 -0200: Fix cppcheck bug #6 'items[4]' index 4 out of bounds
+Spectra0012 Wed, 5 Feb 2014 16:37:14 -0200: Fix cppcheck bug #5.5 printf format string has 1 parameters but only 0 are given
+Spectra0013 Wed, 5 Feb 2014 16:57:49 -0200: Fix cppcheck bugs #8 e #9
+20140215        mvh     Processed Pablo's cppcheck issues
+20140219	mvh 	Added generic decompressor dgate -nu file_in file_out (works for XDR and DCM)
+20140304	mvh 	Detect Data:Read() and do not crash server on it (just fails)
+20140309	mvh 	fixed lua/file.lua returns status rc; newuids no longer generated or changes empty uids
+			lua mkdir(), dicomquery() now returns raw; fixed luacompress and luacopy; dicomquery2 old one; linux warnings
 
 ENDOFUPDATEHISTORY
 */
 
-#define DGATE_VERSION "1.4.17c"
+#define DGATE_VERSION "1.4.17d"
 
 //#define DO_LEAK_DETECTION	1
 //#define DO_VIOLATION_DETECTION	1
@@ -2601,7 +2612,10 @@ NewUIDsInDICOMObject(DICOMObject *DO, const char *Exceptions, const char *Reason
 				{
 				memcpy(s, vr->Data, vr->Length);
 				s[vr->Length]=0;
-				if (strlen(s)==0) GenUID(s);
+
+				// 20140309: blocked
+				// if (strlen(s)==0) GenUID(s);
+
 				strcat(s, ";");
 				sprintf(name, "%04x,%04x|", vr->Group, vr->Element);
 
@@ -5952,7 +5966,6 @@ extern "C"
     if (items[1]) for (i=0; i<strlen(items[1]); i++) if (items[1][i]==',') flds++;
     if (items[2]) if (*items[2]==0) items[2]=NULL;
     if (items[3]) if (*items[3]==0) items[3]=NULL;
-    if (items[4]) if (*items[4]==0) items[4]=NULL;
 
     Database DB;
     if (DB.Open ( DataSource, UserName, Password, DataHost ) )
@@ -5974,7 +5987,7 @@ extern "C"
   }
   static int luasql(lua_State *L)
   { const char *sql = lua_tostring(L,1);
-    BOOL f;
+    BOOL f=FALSE;
 
     Database DB;
     if (DB.Open ( DataSource, UserName, Password, DataHost ) )
@@ -5989,7 +6002,7 @@ extern "C"
     else
       return 0;
   }
-  static int luadicomquery(lua_State *L)
+  static int luadicomquery2(lua_State *L)
   { const char *ae    = lua_tostring(L,1);
     const char *level = lua_tostring(L,2);
     if (lua_isuserdata(L, 3)) 
@@ -6008,6 +6021,9 @@ extern "C"
     }
     return 0;
   }
+
+  static int luadicomquery(lua_State *L);
+  
   static int luadicommove(lua_State *L)
   { const char *source = lua_tostring(L,1);
     const char *dest   = lua_tostring(L,2);
@@ -6328,6 +6344,10 @@ extern "C"
         lua_getfield(L, -1, "DDO");  P = (DICOMDataObject *) lua_topointer(L, -1); lua_pop(L, 1);
 	char name[512];
         strcpy(name, (char *)lua_tostring(L,2));
+        if (sd->DDO == P)
+        { lua_pop(L, 1);
+          return 0;
+        }
         O = LoadForGUI(name);
         if (!O) 
         { lua_pop(L, 1);
@@ -6363,6 +6383,49 @@ extern "C"
     return 0;
   }
 
+  // copydicom(source), Data:Copy()
+  static int luacopydicom(lua_State *L)
+  { struct scriptdata *sd = getsd(L);
+    if (lua_isuserdata(L,1)) 
+    { DICOMDataObject *O = NULL;
+      lua_getmetatable(L, 1);
+        lua_getfield(L, -1, "DDO");  O = (DICOMDataObject *) lua_topointer(L, -1); lua_pop(L, 1);
+      lua_pop(L, 1);
+
+      if (O)
+      { DICOMDataObject *pDDO = MakeCopy(O);
+        luaCreateObject(L, pDDO, NULL, TRUE); 
+        return 1;
+      }
+    }
+    return 0;
+  }
+
+  // compressdicom(source, string), Data:Compress(string)
+  static int luacompressdicom(lua_State *L)
+  { struct scriptdata *sd = getsd(L);
+    char name[512];
+    strcpy(name, (char *)lua_tostring(L,2));
+    if (lua_isuserdata(L,1)) 
+    { DICOMDataObject *O = NULL;
+      lua_getmetatable(L, 1);
+        lua_getfield(L, -1, "DDO");  O = (DICOMDataObject *) lua_topointer(L, -1); lua_pop(L, 1);
+      lua_pop(L, 1);
+
+      if (O)
+      { DICOMDataObject *pDDO = MakeCopy(O);
+        char cmd[512];
+	sprintf(cmd, "compression %s", name);
+        CallImportConverterN(pDDO, -1, sd->pszModality, sd->pszStationName, sd->pszSop, sd->patid, sd->PDU, sd->Storage, cmd);
+	//BOOL StripGroup2 = memicmp(name, "as", 2)!=0 && memicmp(name, "is", 2)!=0;
+	//recompress(&pDDO, name, "", StripGroup2, sd->PDU);
+        luaCreateObject(L, pDDO, NULL, TRUE);
+        return 1;
+      }
+    }
+    return 0;
+  }
+
   // Data:writeheader(filename) or writeheader(filename)
   static int luawriteheader(lua_State *L) 
   { struct scriptdata *sd = getsd(L);
@@ -6408,7 +6471,7 @@ extern "C"
   static int luadeletedicomobject(lua_State *L)
   { struct scriptdata *sd = getsd(L);
     DICOMDataObject *O = NULL;
-    int owned;
+    int owned=0;
     Array < DICOMDataObject * > *A = NULL;
     if (lua_isuserdata(L,1)) 
     { lua_getmetatable(L, 1);
@@ -6501,7 +6564,7 @@ extern "C"
         DICOMDataObject *P = MakeCopy(O);
 	int rc = SaveToDisk(DB, P, rFilename, TRUE, &PDU, 0, TRUE);
 	if (!rc)
-	{ OperatorConsole.printf("***[lua addimage] Error entering object into server%s\n");
+	{ OperatorConsole.printf("***[lua addimage] Error entering object into server%s\n", DataHost);
 	}
 	else
         { if (rc==2) OperatorConsole.printf("Lua script rewritten file: %s\n", rFilename);
@@ -6512,7 +6575,21 @@ extern "C"
     return 0;
   }
 
-
+  static int luamkdir(lua_State *L)
+  { if (lua_isstring(L,1)) 
+    { char cline[512], s[512];
+      strcpy(cline, lua_tostring(L,1));
+      for (int sIndex = 0; sIndex<=strlen(cline); sIndex++)
+	if (cline[sIndex]==PATHSEPCHAR)
+	{ strcpy(s, cline);
+	  s[sIndex]='\0';
+	  mkdir(s);
+	}
+        mkdir(cline);
+    }
+    return 0;
+  }
+  
 static void HTML(const char *string, ...);
 static int CGI(char *out, const char *name, const char *def);
 
@@ -6643,6 +6720,8 @@ static int CGI(char *out, const char *name, const char *def);
     if (strcmp(s, "SetImage")==0) return luasetimage(L);
     if (strcmp(s, "Script")==0)   return luascript(L);
     if (strcmp(s, "AddImage")==0) return luaaddimage(L);
+    if (strcmp(s, "Copy")==0)     return luacopydicom(L);
+    if (strcmp(s, "Compress")==0) return luacompressdicom(L);
 
     if (strcmp(s, "new")==0)      return luanewdicomobject(L);
     if (strcmp(s, "newarray")==0) return luanewdicomarray(L);
@@ -6746,7 +6825,7 @@ static int CGI(char *out, const char *name, const char *def);
       { lua_pushstring(L, sd->Storage);
         return 1;
       }
-      else if (strstr("Write|Read|Dump|GetVR|SetVR|GetPixel|SetPixel|GetRow|SetRow|GetColumn|SetColumn|GetImage|SetImage|Script|new|newarray|free|AddImage", lua_tostring(L,2))) 
+      else if (strstr("Write|Read|Dump|GetVR|SetVR|GetPixel|SetPixel|GetRow|SetRow|GetColumn|SetColumn|GetImage|SetImage|Script|new|newarray|free|AddImage|Copy|Compress", lua_tostring(L,2))) 
       { lua_pushvalue(L, 2);
 	lua_pushcclosure(L, luaSeqClosure, 1);
 	return 1;
@@ -7135,6 +7214,7 @@ const char *do_lua(lua_State **L, char *cmd, struct scriptdata *sd)
     lua_register      (*L, "dbquery",       luadbquery);
     lua_register      (*L, "sql",           luasql);
     lua_register      (*L, "dicomquery",    luadicomquery);
+    lua_register      (*L, "dicomquery2",   luadicomquery2);
     lua_register      (*L, "dicommove",     luadicommove);
     lua_register      (*L, "dicomdelete",   luadicomdelete);
     lua_register      (*L, "debuglog",      luadebuglog);
@@ -7148,6 +7228,8 @@ const char *do_lua(lua_State **L, char *cmd, struct scriptdata *sd)
     lua_register      (*L, "getimage",      luagetimage);
     lua_register      (*L, "setimage",      luasetimage);
     lua_register      (*L, "readdicom",     luareaddicom);
+    lua_register      (*L, "copydicom",     luacopydicom);
+    lua_register      (*L, "compressdicom", luacompressdicom);
     lua_register      (*L, "writedicom",    luawritedicom);
     lua_register      (*L, "writeheader",   luawriteheader);
     lua_register      (*L, "newdicomobject",luanewdicomobject);
@@ -7167,6 +7249,7 @@ const char *do_lua(lua_State **L, char *cmd, struct scriptdata *sd)
     lua_register      (*L, "system",        luasystem);
     lua_register      (*L, "sleep",         luasleep);
     lua_register      (*L, "addimage",      luaaddimage);
+    lua_register      (*L, "mkdir",         luamkdir);
     
     lua_createtable   (*L, 0, 0); 
     lua_createtable   (*L, 0, 0);
@@ -9256,8 +9339,9 @@ int CallImportConverterN(DICOMDataObject *DDO, int N, char *pszModality, char *p
 	    // note; threadnum and dco not implemented
             struct scriptdata sd = {PDU, NULL, DDO, N, pszModality, pszStationName, pszSop, patid, Storage, 0, 0};
     	    SystemDebug.printf("Importconverter%d.%d: %s\n", N, part, script);
+    	    sd.rc = 1;
             do_lua(&(PDU->L), script, &sd);
-            rc = sd.rc;
+            ret = sd.rc;
           }
 	  else
 	  { SystemDebug.printf("%sconverter%d.%d: %s\n", ininame, N, part, line);
@@ -11316,6 +11400,7 @@ PrintOptions ()
         fprintf(stderr, "    --extract_frames:file,out,first,last Select frames of DICOM file\n");
 	fprintf(stderr, "    --count_frames:file                  report # frames in DICOM file\n");
         fprintf(stderr, "    --uncompress:file,out                Uncompress DICOM\n");
+        fprintf(stderr, "    --compress:file,mode,out             Compress DICOM to mode e.g. J2\n");
         fprintf(stderr, "    --wadorequest:parameters             Internal WADO server\n");
 	fprintf(stderr, "\n");
 	fprintf(stderr, "Database options:\n");
@@ -11383,6 +11468,7 @@ _SQLConfigDataSource __SQLConfigDataSource;
 #endif
 
 static char ServerCommandAddress[64] = "127.0.0.1";
+BOOL DecompressNKI(char *file_in, char *file_out);
 
 // Main routine for parsing the command line; return FALSE when not running
 // as server or a socket # when running as server thread
@@ -11419,7 +11505,7 @@ ParseArgs (int	argc, char	*argv[], ExtendedPDU_Service *PDU)
 				case	'H':
 #ifdef WIN32
 					getch();
-#endif WIN32
+#endif
 					break;	//Done already.
 
 				case	'w':	// set workdir for ini, map, dic
@@ -12082,6 +12168,11 @@ ParseArgs (int	argc, char	*argv[], ExtendedPDU_Service *PDU)
 							exit(1);
 						}
 
+					if (argv[valid_argc][2] == 'u' || argv[valid_argc][2] == 'U')
+						{
+						DecompressNKI(argv[valid_argc+1], argv[valid_argc+2]);
+						}
+
 					if (argv[valid_argc][2] == 'c' || argv[valid_argc][2] == 'C')
 						{
 						//int dum;
@@ -12167,7 +12258,7 @@ ParseArgs (int	argc, char	*argv[], ExtendedPDU_Service *PDU)
 						//SystemDebug.On();
 						LoadKFactorFile((char*)KFACTORFILE);
 					  	InitACRNemaAddressArray();
-						struct scriptdata sd = {&globalPDU, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL, 0, NULL};
+						struct scriptdata sd = {&globalPDU, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL, 0, 0};
 						globalPDU.SetLocalAddress ( (BYTE *)"global" );
 						globalPDU.SetRemoteAddress ( (BYTE *)"dolua" );
 						globalPDU.ThreadNum = 0;
@@ -20256,6 +20347,26 @@ BOOL StorageApp	::	ServerChild (int theArg )
 						}
 					}
 
+				else if (memcmp(SilentText, "compress:", 9)==0)
+					{
+					DICOMDataObject *pDDO;
+					if (p) 
+					{ *p++=0;				// points after 1st comma
+                                    	  q = strchr(p, ',');
+                                    	  if (q) 
+					    *q++=0;				// points after 2nd comma
+					}
+					pDDO = LoadForGUI(SilentText+9);
+
+					if (pDDO) 
+						{
+						recompress(&pDDO, p, "", p[0]=='n' || p[0]=='N', &PDU);
+      						SaveDICOMDataObject(q, pDDO);
+						ImagesToDicomFromGui++;
+                                        	delete pDDO;
+						}
+					}
+
 				else if (memcmp(SilentText, "extract_frames:", 15)==0)
 					{
 					DICOMDataObject *pDDO;
@@ -21304,7 +21415,7 @@ main ( int	argc, char	*argv[] )
 			}
 
 			// Start queue for mirror copy (may reprocess previously failed requests)
-			MyGetPrivateProfileString(szRootSC, "MIRROR0", "-1", szTemp, 32, ConfigFile);
+			MyGetPrivateProfileString(szRootSC, "MIRRORDevice0", "-1", szTemp, 32, ConfigFile);
 			if (atoi(szTemp)!=-1 && !NoThread) 
 			{ mirrorcopy_queue(NULL, NULL);
 			  OperatorConsole.printf("Started mirror copy queue thread\n");
@@ -24319,4 +24430,101 @@ char *heapinfo( void )
   return s;
 }
 
-#endif WIN32
+#endif
+
+ static int luadicomquery(lua_State *L)
+  { const char *ae    = lua_tostring(L,1);
+    const char *Level = lua_tostring(L,2);
+    if (lua_isuserdata(L, 3)) 
+    { DICOMDataObject *O = NULL;
+      lua_getmetatable(L, 3);
+        lua_getfield(L, -1, "DDO");  O = (DICOMDataObject *) lua_topointer(L, -1); lua_pop(L, 1);
+      lua_pop(L, 1);
+      Array < DICOMDataObject * > *A = new Array < DICOMDataObject * >;
+      luaCreateObject(L, NULL, A, TRUE); 
+      if (O) 
+      { DICOMDataObject *P = MakeCopy(O);
+
+        unsigned char 	ip[64], port[64], compress[64], SOP[66];
+	VR		*vr;
+	UID		uid;
+	DICOMCommandObject	DCO;
+	LE_UINT16	command, datasettype, messageid, priority;
+	DICOMDataObject	*DDOPtr;
+	int		level;
+		
+	level=0;
+	if      (strncmp(Level, "PATIENT", 7)==0) level=1;
+	else if (strncmp(Level, "STUDY",   5)==0) level=2;
+	else if (strncmp(Level, "SERIES",  6)==0) level=3;
+	else if (strncmp(Level, "IMAGE",   5)==0) level=4;
+	else if (strncmp(Level, "WORKLIST",8)==0) level=5;
+
+	ExtendedPDU_Service PDU;
+	PDU.AttachRTC(&VRType);
+
+	if(!GetACRNema((char *)ae, (char *)ip, (char *)port, (char *)compress))
+		return 0;
+
+	PDU.ClearAbstractSyntaxs();
+	PDU.SetLocalAddress(MYACRNEMA);
+	PDU.SetRemoteAddress((unsigned char *)ae);
+
+	uid.Set("1.2.840.10008.3.1.1.1");
+	PDU.SetApplicationContext(uid);
+
+	if      (level==1) uid.Set("1.2.840.10008.5.1.4.1.2.1.1"); // PatientRootQuery
+	else if (level==5) uid.Set("1.2.840.10008.5.1.4.31");      // WorkListQuery
+	else               uid.Set("1.2.840.10008.5.1.4.1.2.2.1"); // StudyRootQuery
+	PDU.AddAbstractSyntax(uid);
+
+	PDU.SetTimeOut(TCPIPTimeOut);
+
+	// Make the association for the FIND on port/ip
+	if(!PDU.Connect(ip, port))
+		return ( 0 );
+
+	// Start a Patient/StudyRootQuery
+
+	if (level==1)      strcpy((char*) SOP, "1.2.840.10008.5.1.4.1.2.1.1"); // PatientRootQuery
+	else if (level==5) strcpy((char*) SOP, "1.2.840.10008.5.1.4.31");      // WorklistQuery
+	else               strcpy((char*) SOP, "1.2.840.10008.5.1.4.1.2.2.1"); // StudyRootQuery
+	vr = new VR (0x0000, 0x0002, strlen((char*)SOP), (void*) SOP, FALSE);
+	DCO.Push(vr);
+	command = 0x0020;
+	vr = new VR (0x0000, 0x0100, 0x0002, &command, FALSE);
+	DCO.Push(vr);
+	priority = 0;	// MEDIUM
+	vr = new VR (0x0000, 0x0700, 0x0002, &priority, FALSE);
+	DCO.Push(vr);
+	datasettype = 0x0102;	
+	vr = new VR (0x0000, 0x0800, 0x0002, &datasettype, FALSE);
+	DCO.Push(vr);
+	messageid = 0x0003;
+	vr = new VR (0x0000, 0x0110, 0x0002, &messageid, FALSE);
+	DCO.Push(vr);
+
+	// Use passed data object and Level for query
+
+	P->ChangeVR(0x0008, 0x0052, Level, 'CS', TRUE);
+
+	vr = P->GetVR(0x0002, 0x0010); // delete transfer syntax
+	if (vr) P->DeleteVR(vr);
+
+	MyPatientRootQuery mq;
+	MyStudyRootQuery sq;
+	MyModalityWorkListQuery wq;
+
+	if      (level==1) mq.Write(&PDU, P, A);
+	else if (level==5) wq.Write(&PDU, P, A);
+	else               sq.Write(&PDU, P, A);
+	
+	PDU.Close();
+        delete P;
+	return 1;
+      }
+      return 1;
+    }
+    return 0;
+  }
+ 
diff --git a/flpdu.cxx b/flpdu.cxx
index 0af7b5e..f430fe7 100644
--- a/flpdu.cxx
+++ b/flpdu.cxx
@@ -6,6 +6,7 @@
 20100309	bcb	Commented out unused variable (gcc4.2 Warnings)
 20100619	bcb	Fix gcc4 warnings and improve speed
 20100717	mvh	Merged
+Spectra 0014 - Wed, 12 Feb 2014 15:48:27 -0200: Patch mismatches new/delete in flpdu.cxx
 */
 
 /****************************************************************************
@@ -456,12 +457,12 @@ CheckedPDU_Service	::	ReleaseMemory ()
 		Index = 0;
 		while ( Index < SOPUIDListCount )
 			{
-			delete SOPUIDList [ Index ] ;
-			delete SOPUIDListNames [ Index ] ;
+			delete [] SOPUIDList [ Index ] ;
+			delete [] SOPUIDListNames [ Index ] ;
 			++Index;
 			}
-		delete SOPUIDList;
-		delete SOPUIDListNames;
+		delete [] SOPUIDList;
+		delete [] SOPUIDListNames;
 		SOPUIDList = NULL;
 		SOPUIDListNames = NULL;
 		SOPUIDListCount = 0;
@@ -472,12 +473,12 @@ CheckedPDU_Service	::	ReleaseMemory ()
 		Index = 0;
 		while ( Index < TransferUIDListCount )
 			{
-			delete TransferUIDList [ Index ] ;
-			delete TransferUIDListNames [ Index ] ;
+			delete [] TransferUIDList [ Index ] ;
+			delete [] TransferUIDListNames [ Index ] ;
 			++Index;
 			}
-		delete TransferUIDList;
-		delete TransferUIDListNames;
+		delete [] TransferUIDList;
+		delete [] TransferUIDListNames;
 		TransferUIDList = NULL;
 		TransferUIDListNames = NULL;
 		TransferUIDListCount = 0;
@@ -488,12 +489,12 @@ CheckedPDU_Service	::	ReleaseMemory ()
 		Index = 0;
 		while ( Index < ApplicationUIDListCount )
 			{
-			delete ApplicationUIDList [ Index ] ;
-			delete ApplicationUIDListNames [ Index ] ;
+			delete [] ApplicationUIDList [ Index ] ;
+			delete [] ApplicationUIDListNames [ Index ] ;
 			++Index;
 			}
-		delete ApplicationUIDList;
-		delete ApplicationUIDListNames;
+		delete [] ApplicationUIDList;
+		delete [] ApplicationUIDListNames;
 		ApplicationUIDList = NULL;
 		ApplicationUIDListNames = NULL;
 		ApplicationUIDListCount = 0;
@@ -503,12 +504,12 @@ CheckedPDU_Service	::	ReleaseMemory ()
 		Index = 0;
 		while ( Index < RemoteAEListCount )
 			{
-			delete RemoteAEList [ Index ] ;
-			delete RemoteAEListNames [ Index ] ;
+			delete [] RemoteAEList [ Index ] ;
+			delete [] RemoteAEListNames [ Index ] ;
 			++Index;
 			}
-		delete RemoteAEList;
-		delete RemoteAEListNames;
+		delete [] RemoteAEList;
+		delete [] RemoteAEListNames;
 		RemoteAEList = NULL;
 		RemoteAEListNames = NULL;
 		RemoteAEListCount = 0;
@@ -518,12 +519,12 @@ CheckedPDU_Service	::	ReleaseMemory ()
 		Index = 0;
 		while ( Index < LocalAEListCount )
 			{
-			delete LocalAEList [ Index ] ;
-			delete LocalAEListNames [ Index ] ;
+			delete [] LocalAEList [ Index ] ;
+			delete [] LocalAEListNames [ Index ] ;
 			++Index;
 			}
-		delete LocalAEList;
-		delete LocalAEListNames;
+		delete [] LocalAEList;
+		delete [] LocalAEListNames;
 		LocalAEList = NULL;
 		LocalAEListNames = NULL;
 		LocalAEListCount = 0;
diff --git a/linuxmanual.pdf b/linuxmanual.pdf
index 4e9f0b8..d969361 100644
Binary files a/linuxmanual.pdf and b/linuxmanual.pdf differ
diff --git a/lua/anonymize_script.lua b/lua/anonymize_script.lua
index 4c318cc..1e877b9 100644
--- a/lua/anonymize_script.lua
+++ b/lua/anonymize_script.lua
@@ -11,9 +11,11 @@
 -- 20130522	mvh	Cleanup for release; fixed when birthdate empty
 -- 20130718	mvh	Set logroot not to c:\DicomAnonymized but to DicomAnonymized_Log
 -- 20130813	mvh	Command line overrules generated patientid and patientname
+-- 20140304	mvh	Remove OtherPatienIDSequence
+-- 20140309	mvh	Protect against any missing data
 -- =============================================================================
 
-local scriptversion = "1.4; date 20130813"
+local scriptversion = "1.5; date 20140309"
 
 ---------------------------------- configuration -----------------------------
 -- entries that show up in log but are NOT modified (except implicitly the UIDs)
@@ -38,7 +40,7 @@ local TagsToRemove = {
 "PatientInsurancePlanCodeSequence", "PatientBirthName", "PatientAddress", "InsurancePlanIdentification",
 "PatientMotherBirthName", "MilitaryRank", "BranchOfService", "RegionOfResidence",
 "PatientTelephoneNumbers", "PatientComments", "StudyComments", "ScheduledPerformingPhysicianName",
-"PerformingPhysicianIdentificationSequence" }
+"PerformingPhysicianIdentificationSequence", "OtherPatientIDsSequence" }
 
 local MaintainAge = false
 local MaintainSex = false
@@ -61,7 +63,7 @@ local pid = string.gsub(Data.PatientID, '[\\/:*?"<>|]', '_')
 -- Log file handling (trailing backslash required for mkdir)
 local logdir = logroot..pid.."\\";
 -- 
-local logfile = pid..'_'..Data.StudyDate..'_'..Data.Modality..'_'..Data.SOPInstanceUID..'.log'
+local logfile = pid..'_'..(Data.StudyDate or '19700101')..'_'..(Data.Modality or 'UN')..'_'..(Data.SOPInstanceUID or 'unknown')..'.log'
 script('mkdir '..logdir);
 
 local f = io.open(logdir .. logfile, "wt");
@@ -130,7 +132,7 @@ if Data.PatientBirthDate~='' then
   f:write('Changed patient birthdate to: ', tostring(Data.PatientBirthDate), "\n");
 end
 if (MaintainSex==false) and (Data.PatientSex~='') then
-  local org = Data.PatientSex;
+  local org = Data.PatientSex or 'UN';
   Data.PatientSex = '';
   f:write('Made patient sex empty: ', tostring(Data.PatientSex), "\n");
   if reversible==true then
diff --git a/lua/deanonymize_script.lua b/lua/deanonymize_script.lua
index 1499d43..43be9f7 100644
--- a/lua/deanonymize_script.lua
+++ b/lua/deanonymize_script.lua
@@ -6,6 +6,7 @@
 -- 20130522	mvh	Cleanup for release
 -- 20130718	mvh	Moved log folder
 -- 20130802	mvh	Detect if patientID cannot be deanonymized
+-- 20140309	mvh	Protect against any missing data
 -- =============================================================================
 
 --[[ To test; r-click evaluate in console after project-run:
@@ -34,7 +35,7 @@ local pid2 = string.gsub(pid, '[\\/:*?"<>|]', '_')
 
 -- Log file handling (trailing backslash required for mkdir)
 local logdir = "DicomAnonymized_Log\\"..pid2.."\\";
-local logfile = pid2..'_'..Data.StudyDate..'_'..Data.Modality..'_'..Data.SOPInstanceUID..'.deanonymize.log'
+local logfile = pid2..'_'..(Data.StudyDate or '19700101')..'_'..(Data.Modality or 'UN')..'_'..(Data.SOPInstanceUID or 'unknown')..'.deanonymize.log'
 script('mkdir '..logdir);
 
 f = io.open(logdir .. logfile, "wt");
diff --git a/lua/livecoding.lua b/lua/livecoding.lua
index e87ae68..edabefc 100644
--- a/lua/livecoding.lua
+++ b/lua/livecoding.lua
@@ -1,10 +1,9 @@
+-- 1.4.17d
 a=DicomObject:new()
 a.QueryRetrieveLevel='STUDY'
 a.StudyInstanceUID=''
-a.StudyDate='20090101-20130404'
+a.StudyDate='19980101-20010404'
 b=dicomquery('CONQUESTSRV1', 'STUDY', a)
-f=io.open('file.txt', 'wt')
 for i=0, #b-1 do
-  f:write(b[i].StudyInstanceUID .. '\n')
+  print(b[i].StudyInstanceUID)
 end
-f:close()
\ No newline at end of file
diff --git a/lua/niftytest.lua b/lua/niftytest.lua
index 05a4ceb..0d10e7e 100644
--- a/lua/niftytest.lua
+++ b/lua/niftytest.lua
@@ -1,6 +1,6 @@
---[[add the following 2 lines to dicom.ini for automatic processing of series sent to SMOOTH after 10 s
+--[[add the following 2 lines to dicom.ini for automatic processing of series sent to server after 10 s
 [lua]
-importconverter0 = if Association.Called=="SMOOTH" then script("process series after 10 by lua/niftytest.lua " .. Data.PatientID .. ":" .. Data.SeriesInstanceUID) end
+importconverter0 = if Association.Called=="CONQUESTSRV!" then script("process series after 10 by lua/niftytest.lua " .. Data.PatientID .. ":" .. Data.SeriesInstanceUID) end
 ]]--
 
 require('niftyutil')
diff --git a/lua/overview.lua b/lua/overview.lua
index 0ad3f92..bb515c5 100644
--- a/lua/overview.lua
+++ b/lua/overview.lua
@@ -240,6 +240,11 @@ Data:SetImage(frame, a)
 -- read a from a floating point image, i.e., it has 4 bytes per pixel, scale passed
 -- setimage(frame, a, 1000); Data:SetImage(frame, a, 1000)
 
+-- copy a dicom object
+local c = Data:Copy()
+c:Write('c:\\copy.dcm')
+c:free()
+
 -- create/read/write/destroy a dicom object
 print('------ test create/read/write dicom object --------')
 a = newdicomobject()
diff --git a/lua/welcome.lua b/lua/welcome.lua
index 7eccdde..26740fd 100644
--- a/lua/welcome.lua
+++ b/lua/welcome.lua
@@ -1,6 +1,6 @@
+-- 1.4.17d
 --[[ These are sample scripts that can be run by [Conquest DICOM server](http://forum.image-systems.biz/viewforum.php?f=33).
-You need to use version 1.4.17beta or later for this to work and copy
-mobdebug.lua from the .
+You need to use version 1.4.17 or later for most samples to work
  
 - Switch to a standalone Conquest interpreter by going to `Project | Lua Interpreter | Conquest DICOM Utility`.
 - Connect to a running Conquest server by going to `Project | Lua Interpreter | Conquest DICOM Server`.
diff --git a/nkiqrsop.cpp b/nkiqrsop.cpp
index 7ffa5a5..f90b4d0 100644
--- a/nkiqrsop.cpp
+++ b/nkiqrsop.cpp
@@ -226,6 +226,11 @@
 20130823	mvh	Fixed lossy jpeg compression for 12 bits data
 20130920        ea      Corrected the calculation of new pixel spacing in MaybeDownsize
 20131013	mvh	Default UseBuiltInJPEG set to 1; added quality parameter to ToJPG
+20140207	mvh 	Fixed RLE (signed char 127)+1 gave overflow, now use (int)cCurrent+1
+20140209	mvh 	Fix decompressjpegl here: fix lossless colorspace to RGB
+20140219	mvh 	Added generic DecompressNKI (works for XDR and DCM)
+20140309	mvh 	Catch error if no image VR present in jpeg2000 decompression
+			linux issue on previous change
 */
 
 #define bool BOOL
@@ -1256,6 +1261,11 @@ int get_nki_private_compress_mode(signed char *src)
   return mode;
 }
 
+int get_nki_private_compressed_length(signed char *src)
+{ int nchar = *(int *)(src+8);
+  return nchar;
+}
+
 /* decoder for NKI private compressed pixel data - faster and safe version
    arguments: dest    = (in) points to area where destination data is written (short)
               src     = (in) points compressed source data (byte stream)
@@ -1672,6 +1682,74 @@ BOOL DecompressNKI(DICOMDataObject* pDDO)
   return TRUE;
 }
 
+void SaveDICOMDataObject(char *Filename, DICOMDataObject* pDDO);
+
+BOOL DecompressNKI(char *file_in, char *file_out)
+{ FILE *f = fopen(file_in, "rb");
+  fseek(f, 0, SEEK_END);
+  int fileLength = ftell(f);
+  fseek(f, 0, SEEK_SET);
+  char *buffer = (char *)malloc(fileLength);
+  if (!buffer)
+  { fclose(f);
+    return FALSE;
+  }
+  fread(buffer, 1, fileLength, f);
+  fclose(f);
+  if (fileLength>20)
+  { if (memcmp(buffer, "# AVS", 5)==0)
+    { int start;
+      for (int i=0; i<fileLength; i++)
+      if (buffer[i]==0x0c)
+      { buffer[i]=0;
+        char *p = strstr(buffer, "nki_compression=");
+	if (p) 
+	{ if (atoi(p+16)==0) 
+	    return FALSE;
+	  p[16]='0';
+	}
+        int iDecompressedLength = get_nki_private_decompressed_length((signed char *)buffer+i+2);
+        int iCompressedLength = get_nki_private_compressed_length((signed char *)buffer+i+2)+20;
+        if (!iDecompressedLength)
+          return FALSE;
+	char *buffer2 = (char *)malloc(iDecompressedLength);
+        if (!buffer2)
+          return FALSE;
+	int InLen = nki_private_decompress((short *)buffer2, (signed char *)buffer+i+2, fileLength-i-2);
+	if (InLen==0)
+          return FALSE;
+        FILE *g = fopen(file_out, "wb");
+	fwrite(buffer, i, 1, g);
+	fputc(12, g);
+	fputc(12, g);
+	swab(buffer2, buffer2, iDecompressedLength);
+	fwrite(buffer2, iDecompressedLength, 1, g);
+	printf("remaining: %d; InLen: %d; FileLen=%d; iDecompressedLength=%d", 
+	      fileLength-i-2-iCompressedLength, iCompressedLength, fileLength, iDecompressedLength);
+	fwrite(buffer+i+2+iCompressedLength, fileLength-i-2-iCompressedLength, 1, g);
+	fclose(f);
+	free(buffer);
+	free(buffer2);
+        return TRUE;
+      }
+    }
+    else
+    { free(buffer);
+      DICOMDataObject		*pDDO;
+      PDU_Service		PDU;
+      PDU.AttachRTC(&VRType);
+      pDDO = PDU.LoadDICOMDataObject(file_in);
+      if(!pDDO)
+	return FALSE;
+      int Changed;
+      if(!DecompressImage(&pDDO, &Changed)) return FALSE;
+      SaveDICOMDataObject(file_out, pDDO);
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
 BOOL CompressNKI(DICOMDataObject* pDDO, int CompressMode /* = 2 */)
 { VR*		pVR;
   VR*		pNewVR;
@@ -2690,13 +2768,13 @@ static int DecompressRLE(SLICE_INFO* pSliceInfo, VR* pSequence,
             cCurrent = pIn[iNbCompressed++];// Det the count.
             if (cCurrent >= 0)// Positive is a Literal Run.
             {// Check the length in & out?
-                cCurrent++;// The real count
-                if ((iNbCompressed + (int)cCurrent <= iCompressedSize) && 
-                    (*hSeq + cCurrent <= endSeqPtr))
+                //cCurrent++;// The real count
+                if ((iNbCompressed + (int)cCurrent + 1 <= iCompressedSize) && 
+                    (*hSeq + cCurrent + 1 <= endSeqPtr))
                     { // Good, room to copy
-                        memcpy(*hSeq, pIn + iNbCompressed, cCurrent);
-                        iNbCompressed   += cCurrent;
-                        *hSeq += cCurrent;
+                        memcpy(*hSeq, pIn + iNbCompressed, (int)cCurrent+1);
+                        iNbCompressed   += (int)cCurrent+1;
+                        *hSeq += (int)cCurrent+1;
                     }
                 else // What happened, no room or seq ending 0?
                     break;// Run away!
@@ -6649,7 +6727,7 @@ BOOL DecompressJPEGL(DICOMDataObject* pDDO)
 	  DDO = ArrayPtr->Get(currSQObject );//Get the array.
 	  vrImage = DDO->GetVR(0xfffe, 0xe000);//Get the data
 //Look for size and jpeg SOI marker 
-	  if((vrImage->Length) && ((unsigned char *)vrImage->Data)[0] == 0xFF &&
+	  if(vrImage && (vrImage->Length) && ((unsigned char *)vrImage->Data)[0] == 0xFF &&
 			   ((unsigned char *)vrImage->Data)[1] == 0xD8)break;
 	  currSQObject++;
 	}
@@ -6725,7 +6803,16 @@ BOOL DecompressJPEGL(DICOMDataObject* pDDO)
 	}
 	color = TRUE;
   }
-// Time to make an output image buffer.
+
+  // 20140209: lossless color jpeg must be RGB
+  if (cinfo.process == JPROC_LOSSLESS && 
+      cinfo.jpeg_color_space != JCS_RGB &&
+      cinfo.out_color_components == 3) 
+  { OperatorConsole.printf("DecompressJPEGL: forced jpeg colorspace for lossless to RGB\n");
+    cinfo.jpeg_color_space = JCS_RGB;
+  }
+
+ // Time to make an output image buffer.
   if(cinfo.data_precision_other > 8) outBytes = 2;
   else outBytes = 1;
   rowWidth =  cinfo.output_width * cinfo.output_components * outBytes;
diff --git a/trnsyn.cxx b/trnsyn.cxx
index 4ced130..99f88c5 100644
--- a/trnsyn.cxx
+++ b/trnsyn.cxx
@@ -59,6 +59,7 @@
 20130523   mvh   Merged Big Endian parse fix not strnlen32u()
 20130619   lsp   Fixed problem in GetTransferSyntaxUID() indicated by Klocwork
 20130711   lsp   Merged
+20140125   mvh   Set TypeCode to SQ if SQObjectArray defined and TypeCode was UN
 */
 
 /*
@@ -1100,6 +1101,9 @@ BOOL	PDU_Service	::	Explicit_ParseDCMIntoRawVR (
 
 		if (vr->TypeCode == 0)
 			vr->TypeCode = 'UN';
+			
+		if (vr->SQObjectArray && vr->TypeCode == 'UN')
+			vr->TypeCode = 'SQ';
 
 		Pack(vr->TypeCode, s1[0], s1[1]);
 		lVRBuffer << s1[0];lVRBuffer<<s1[1];
@@ -1814,6 +1818,9 @@ BOOL	PDU_Service	::	Dynamic_ParseDCMIntoRawVR(
 
 			if (vr->TypeCode == 0)
 				vr->TypeCode = 'UN';
+			
+			if (vr->SQObjectArray && vr->TypeCode == 'UN')
+				vr->TypeCode = 'SQ';
 
 			Pack(vr->TypeCode, s1[0], s1[1]);
 			lVRBuffer << s1[0];lVRBuffer<<s1[1];
diff --git a/vrtosql.cpp b/vrtosql.cpp
index d68ab33..27c6488 100644
--- a/vrtosql.cpp
+++ b/vrtosql.cpp
@@ -70,6 +70,8 @@
 20120422	mvh	Fix search in DT_MSTR with embedded _ to use  =, was a LIKE that failed for MySQL
 20120624	mvh	Fix DT_MSTR for DoubleBackSlashToDB (mysql and pgsql): requires 4 backslashses (!)
 20120701	mvh	Fix in BuildSearchString for UseEscapeStringConstants for DT_MSTR and DT_DATE
+20131013	mvh	DT_MSTR warning for DBASEIII reports now to console
+20131017        ea      Put the changes of 20120701 back because dgate fails for PatientID with '_'
 */
 
 #ifndef	WHEDGE
@@ -351,8 +353,8 @@ MakeSafeString (
 	
 	// redone these special characters: mvh 20110105
 	//20120701: seems this is not needed and highly complicates further processing
-	//if (AddEscape && db->db_type==DT_POSTGRES) strcpy(sout-1, " ESCAPE E'\\\\'");
-	//else if (AddEscape) strcpy(sout-1, " ESCAPE '\\'");
+	if (AddEscape && db->db_type==DT_POSTGRES) strcpy(sout-1, " ESCAPE E'\\\\'");
+	else if (AddEscape) strcpy(sout-1, " ESCAPE '\\'");
 	// end redone these special characters: mvh 20110105
 
 	delete s;
@@ -570,7 +572,7 @@ BuildSearchString(Database *DB, DBENTRY	*DBE, char	*TableName, VR	*vr, char	*Sea
 					escape, search);
 
 				if (DBE[Index].DICOMType==DT_MSTR)
-					SystemDebug.printf("warning: query for this multi-valued item (%s) will not test individual values\n", DBE[Index].SQLColumn);
+					OperatorConsole.printf("warning: query for this multi-valued item (%s) will not test individual values\n", DBE[Index].SQLColumn);
 				}
 
 			}
diff --git a/windowsmanual.pdf b/windowsmanual.pdf
index cac78c3..ec01a9b 100644
Binary files a/windowsmanual.pdf and b/windowsmanual.pdf differ

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/conquest-dicom-server.git



More information about the debian-med-commit mailing list