Index: dcmtk.spec =================================================================== --- dcmtk.spec (revision 0) +++ dcmtk.spec (revision 28) @@ -0,0 +1,58 @@ +Summary: DCMTK - DICOM Toolkit +%define version 3.5.4 +%define packer %(finger -lp `echo "$USER"` | head -n 1 | cut -d: -f 3) +License: MIT license +Group: Development/Libraries +Name: dcmtk +Prefix: /usr +Packager: %{packer} +Provides: dcmtk +Release: 1 +Source: dcmtk-%{version}.tar.gz +Patch: pdcmtk-r27.diff +URL: http://www.dcmtk.org/ +Version: %{version} +Buildroot: %{_tmppath}/%{name}-%{version}-root +%define mydocdir %{_docdir}/%{name}-%{version}/ + +%description +DCMTK is a collection of libraries and applications implementing large parts +the DICOM standard. It includes software for examining, constructing and +converting DICOM image files, handling offline media, sending and receiving +images over a network connection, as well as demonstrative image storage and +worklist servers. + +Contains patches against latest stable version from http://gna.org/projects/pdcmtk + +%prep +%setup -q +%patch -p0 + +%build +CFLAGS="$RPM_OPT_FLAGS -fPIC" CXXFLAGS="$RPM_OPT_FLAGS -fPIC" ./configure --prefix=%{_prefix} --mandir=%{_mandir} --libdir=%{_libdir} --includedir=%{_includedir} --bindir=%{_bindir} --datadir=%{_datadir} --sysconfdir=/etc +make + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} docdir=%{buildroot}/%{mydocdir} +make install-lib DESTDIR=%{buildroot} docdir=%{buildroot}/%{mydocdir} + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +%{_libdir}/* +%{_bindir}/* +%{_includedir}/* +%doc %{_mandir}/man1/* +%{_datadir}/dcmtk/* +%doc %{_docdir}/* +/etc/* + +%post +/sbin/ldconfig + +%changelog +* Fri Oct 31 2008 Per Inge Mathisen +- ver 1 Index: dcmimgle/include/dcmtk/dcmimgle/diinpxt.h =================================================================== --- dcmimgle/include/dcmtk/dcmimgle/diinpxt.h (revision 10) +++ dcmimgle/include/dcmtk/dcmimgle/diinpxt.h (working copy) @@ -356,6 +356,10 @@ const Uint16 bitsof_T2 = bitsof(T2); T1 *pixel; const Uint32 length_Bytes = getPixelData(pixelData, pixel); + if (pixel == NULL) + { + return; + } const Uint32 length_T1 = length_Bytes / sizeof(T1); Count = ((length_Bytes * 8) + bitsAllocated - 1) / bitsAllocated; register unsigned long i; @@ -365,7 +369,7 @@ #ifdef DEBUG if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_Informationals)) { - ofConsole.lockCerr() << bitsAllocated << " " << bitsStored << " " << highBit << " " << isSigned() << endl; + ofConsole.lockCerr() << bitsAllocated << " " << bitsStored << " " << highBit << " " << this->isSigned() << endl; ofConsole.unlockCerr(); } #endif Index: dcmimgle/include/dcmtk/dcmimgle/discalet.h =================================================================== --- dcmimgle/include/dcmtk/dcmimgle/discalet.h (revision 27) +++ dcmimgle/include/dcmtk/dcmimgle/discalet.h (working copy) @@ -181,7 +181,7 @@ { if ((src != NULL) && (dest != NULL)) { -#ifdef DEBUG +#ifdef REALLY_DEBUG_THIS if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_DebugMessages)) { ofConsole.lockCout() << "C/R: " << Columns << " " << Rows << endl Index: dcmimgle/libsrc/didocu.cc =================================================================== --- dcmimgle/libsrc/didocu.cc (revision 10) +++ dcmimgle/libsrc/didocu.cc (working copy) @@ -279,7 +279,8 @@ Uint16 *val; elem->getUint16Array(val); returnVal = val; - if (elem->getVR() == EVR_OW) + const DcmEVR vr = elem->getVR(); + if ((vr == EVR_OW) || (vr == EVR_lt)) return elem->getLength(Xfer) / sizeof(Uint16); return elem->getVM(); } @@ -335,7 +336,8 @@ Uint16 *val; // parameter has no 'const' qualifier OFconst_cast(DcmElement *, elem)->getUint16Array(val); // remove 'const' to use non-const methods returnVal = val; - if (OFconst_cast(DcmElement *, elem)->getVR() == EVR_OW) + const DcmEVR vr = OFconst_cast(DcmElement *, elem)->getVR(); + if ((vr == EVR_OW) || (vr == EVR_lt)) return OFconst_cast(DcmElement *, elem)->getLength(/*Xfer*/) / sizeof(Uint16); return OFconst_cast(DcmElement *, elem)->getVM(); } Index: dcmimgle/libsrc/diovpln.cc =================================================================== --- dcmimgle/libsrc/diovpln.cc (revision 10) +++ dcmimgle/libsrc/diovpln.cc (working copy) @@ -90,7 +90,7 @@ /* get overlay type */ tag.setElement(DCM_OverlayType.getElement()); const char *str; - if ((docu->getValue(tag, str) > 0) && (strcmp(str, "R") == 0)) + if ((docu->getValue(tag, str) > 0) && str && (strcmp(str, "R") == 0)) DefaultMode = Mode = EMO_RegionOfInterest; Sint32 sl = 0; /* multi-frame overlays */ Index: dcmdata/include/dcmtk/dcmdata/dctypes.h =================================================================== --- dcmdata/include/dcmtk/dcmdata/dctypes.h (revision 10) +++ dcmdata/include/dcmtk/dcmdata/dctypes.h (working copy) @@ -54,7 +54,6 @@ */ typedef Uint8 BYTE; -typedef Sint8 SBYTE; /* Index: dcmdata/libsrc/Makefile.in =================================================================== --- dcmdata/libsrc/Makefile.in (revision 27) +++ dcmdata/libsrc/Makefile.in (working copy) @@ -56,12 +56,12 @@ $(INSTALL_DATA) $(library) $(libdir)/$(library) install-support: $(DICTFILE) $(PRIVDICTFILE) - $(configdir)/mkinstalldirs $(libdir) + $(configdir)/mkinstalldirs $(datadir) if [ "x$(INSTALL_PRIVATE_DICTIONARY)" = "xYES" ] ; then \ cat $(DICTFILE) $(PRIVDICTFILE) >dicom.tmp ; \ - $(INSTALL_DATA) dicom.tmp $(libdir)/dicom.dic ; \ + $(INSTALL_DATA) dicom.tmp $(datadir)/dicom.dic ; \ else \ - $(INSTALL_DATA) $(DICTFILE) $(libdir)/dicom.dic ; \ + $(INSTALL_DATA) $(DICTFILE) $(datadir)/dicom.dic ; \ fi Index: dcmnet/apps/findscu.cc =================================================================== --- dcmnet/apps/findscu.cc (revision 10) +++ dcmnet/apps/findscu.cc (working copy) @@ -21,10 +21,10 @@ * * Purpose: Query/Retrieve Service Class User (C-FIND operation) * - * Last Update: $Author: meichel $ - * Update Date: $Date: 2005/12/08 15:44:19 $ + * Last Update: $Author: onken $ + * Update Date: $Date: 2006/01/17 15:38:50 $ * Source File: $Source: /share/dicom/cvs-depot/dcmtk/dcmnet/apps/findscu.cc,v $ - * CVS/RCS Revision: $Revision: 1.47 $ + * CVS/RCS Revision: $Revision: 1.48 $ * Status: $State: Exp $ * * CVS/RCS Log at end of file @@ -111,7 +111,6 @@ fprintf(stderr, "\n"); } - static void addOverrideKey(OFConsoleApplication& app, const char* s) { @@ -119,18 +118,29 @@ unsigned int e = 0xffff; int n = 0; char val[1024]; + OFString dicName, valStr; OFString msg; char msg2[200]; + val[0] = '\0'; - val[0] = '\0'; // try to parse group and element number n = sscanf(s, "%x,%x=%s", &g, &e, val); - - if (n != 2) { - // not a group-element pair, try to lookup in dictionary + OFString toParse = s; + size_t eqPos = toParse.find('='); + if (n < 2) // if at least no tag could be parsed + { + // if value is given, extract it (and extrect dictname) + if (eqPos != OFString_npos) + { + dicName = toParse.substr(0,eqPos).c_str(); + valStr = toParse.substr(eqPos+1,toParse.length()); + } + else // no value given, just dictionary name + dicName = s; // only dictionary name given (without value) + // try to lookup in dictionary DcmTagKey key(0xffff,0xffff); const DcmDataDictionary& globalDataDict = dcmDataDict.rdlock(); - const DcmDictEntry *dicent = globalDataDict.findEntry(s); + const DcmDictEntry *dicent = globalDataDict.findEntry(dicName.c_str()); dcmDataDict.unlock(); if (dicent!=NULL) { // found dictionary name, copy group and element number @@ -141,24 +151,15 @@ else { // not found in dictionary msg = "bad key format or dictionary name not found in dictionary: "; - msg += s; + msg += dicName; app.printError(msg.c_str()); } - } - const char* spos = s; - char ccc; - do + } // tag could be parsed, copy value if it exists + else { - ccc = *spos; - if (ccc == '=') break; - if (ccc == 0) { spos = NULL; break; } - spos++; - } while(1); - - if (spos && *(spos+1)) { - strcpy(val, spos+1); + if (eqPos != OFString_npos) + valStr = toParse.substr(eqPos+1,toParse.length()); } - DcmTag tag(g,e); if (tag.error() != EC_Normal) { sprintf(msg2, "unknown tag: (%04x,%04x)", g, e); @@ -169,26 +170,25 @@ sprintf(msg2, "cannot create element for tag: (%04x,%04x)", g, e); app.printError(msg2); } - if (strlen(val) > 0) { - elem->putString(val); - if (elem->error() != EC_Normal) + if (valStr.length() > 0) { + if (elem->putString(valStr.c_str()).bad()) { sprintf(msg2, "cannot put tag value: (%04x,%04x)=\"", g, e); msg = msg2; - msg += val; + msg += valStr; msg += "\""; app.printError(msg.c_str()); } } if (overrideKeys == NULL) overrideKeys = new DcmDataset; - overrideKeys->insert(elem, OFTrue); - if (overrideKeys->error() != EC_Normal) { + if (overrideKeys->insert(elem, OFTrue).bad()) { sprintf(msg2, "cannot insert tag: (%04x,%04x)", g, e); app.printError(msg2); } } + static OFCondition addPresentationContext(T_ASC_Parameters *params); static OFCondition @@ -1164,6 +1164,10 @@ /* ** CVS Log ** $Log: findscu.cc,v $ +** Revision 1.48 2006/01/17 15:38:50 onken +** Fixed "--key" option, which was broken when using the optional assignment ("=") +** operation inside the option value +** ** Revision 1.47 2005/12/08 15:44:19 meichel ** Changed include path schema for all DCMTK header files ** Index: dcmnet/apps/movescu.cc =================================================================== --- dcmnet/apps/movescu.cc (revision 10) +++ dcmnet/apps/movescu.cc (working copy) @@ -21,10 +21,10 @@ * * Purpose: Query/Retrieve Service Class User (C-MOVE operation) * - * Last Update: $Author: meichel $ - * Update Date: $Date: 2005/12/08 15:44:20 $ + * Last Update: $Author: onken $ + * Update Date: $Date: 2006/01/17 15:38:50 $ * Source File: $Source: /share/dicom/cvs-depot/dcmtk/dcmnet/apps/movescu.cc,v $ - * CVS/RCS Revision: $Revision: 1.59 $ + * CVS/RCS Revision: $Revision: 1.60 $ * Status: $State: Exp $ * * CVS/RCS Log at end of file @@ -148,17 +148,29 @@ unsigned int e = 0xffff; int n = 0; char val[1024]; + OFString dicName, valStr; OFString msg; char msg2[200]; + val[0] = '\0'; - val[0] = '\0'; + // try to parse group and element number n = sscanf(s, "%x,%x=%s", &g, &e, val); - - if (n != 2) { - // not a group-element pair, try to lookup in dictionary + OFString toParse = s; + size_t eqPos = toParse.find('='); + if (n < 2) // if at least no tag could be parsed + { + // if value is given, extract it (and extrect dictname) + if (eqPos != OFString_npos) + { + dicName = toParse.substr(0,eqPos).c_str(); + valStr = toParse.substr(eqPos+1,toParse.length()); + } + else // no value given, just dictionary name + dicName = s; // only dictionary name given (without value) + // try to lookup in dictionary DcmTagKey key(0xffff,0xffff); const DcmDataDictionary& globalDataDict = dcmDataDict.rdlock(); - const DcmDictEntry *dicent = globalDataDict.findEntry(s); + const DcmDictEntry *dicent = globalDataDict.findEntry(dicName.c_str()); dcmDataDict.unlock(); if (dicent!=NULL) { // found dictionary name, copy group and element number @@ -168,25 +180,16 @@ } else { // not found in dictionary - msg = "bad key format or key not found in dictionary: "; - msg += s; + msg = "bad key format or dictionary name not found in dictionary: "; + msg += dicName; app.printError(msg.c_str()); } - } - const char* spos = s; - char ccc; - do + } // tag could be parsed, copy value if it exists + else { - ccc = *spos; - if (ccc == '=') break; - if (ccc == 0) { spos = NULL; break; } - spos++; - } while(1); - - if (spos && *(spos+1)) { - strcpy(val, spos+1); + if (eqPos != OFString_npos) + valStr = toParse.substr(eqPos+1,toParse.length()); } - DcmTag tag(g,e); if (tag.error() != EC_Normal) { sprintf(msg2, "unknown tag: (%04x,%04x)", g, e); @@ -197,21 +200,19 @@ sprintf(msg2, "cannot create element for tag: (%04x,%04x)", g, e); app.printError(msg2); } - if (strlen(val) > 0) { - elem->putString(val); - if (elem->error() != EC_Normal) + if (valStr.length() > 0) { + if (elem->putString(valStr.c_str()).bad()) { sprintf(msg2, "cannot put tag value: (%04x,%04x)=\"", g, e); msg = msg2; - msg += val; + msg += valStr; msg += "\""; app.printError(msg.c_str()); } } if (overrideKeys == NULL) overrideKeys = new DcmDataset; - overrideKeys->insert(elem, OFTrue); - if (overrideKeys->error() != EC_Normal) { + if (overrideKeys->insert(elem, OFTrue).bad()) { sprintf(msg2, "cannot insert tag: (%04x,%04x)", g, e); app.printError(msg2); } @@ -1407,6 +1408,10 @@ ** CVS Log ** ** $Log: movescu.cc,v $ +** Revision 1.60 2006/01/17 15:38:50 onken +** Fixed "--key" option, which was broken when using the optional assignment ("=") +** operation inside the option value +** ** Revision 1.59 2005/12/08 15:44:20 meichel ** Changed include path schema for all DCMTK header files ** Index: dcmnet/apps/storescp.cc =================================================================== --- dcmnet/apps/storescp.cc (revision 10) +++ dcmnet/apps/storescp.cc (working copy) @@ -116,6 +116,8 @@ #define FILENAME_PLACEHOLDER "#f" #define CALLING_AETITLE_PLACEHOLDER "#a" #define CALLED_AETITLE_PLACEHOLDER "#c" +#define CALLING_PRESENTATION_ADDRESS_PLACEHOLDER "#r" +#define RECEIVED_DATE_PLACEHOLDER "#d" static OFCondition processCommands(T_ASC_Association *assoc); static OFCondition acceptAssociation(T_ASC_Network *net, DcmAssociationConfiguration& asccfg); @@ -165,6 +167,7 @@ OFBool opt_inetd_mode = OFFalse; OFString callingaetitle; // calling AE title will be stored here OFString calledaetitle; // called AE title will be stored here +OFString callingpresentationaddress; // calling Presentation Adress (remote_ip) will be stored here const char * opt_respondingaetitle = APPLICATIONTITLE; static OFBool opt_secureConnection = OFFalse; // default: no secure connection static OFString opt_outputDirectory("."); // default: output directory equals "." @@ -1508,6 +1511,9 @@ calledaetitle.clear(); } + // store for #r substitution + callingpresentationaddress = assoc->params->DULparams.callingPresentationAddress; + /* now do the real work, i.e. receive DIMSE commmands over the network connection */ /* which was established and handle these commands correspondingly. In case of */ /* storscp only C-ECHO-RQ and C-STORE-RQ commands can be processed. */ @@ -2114,7 +2120,6 @@ lastStudySubdirectoryPathAndName.clear(); } - static void executeOnReception() /* * This function deals with the execution of the command line which was passed @@ -2130,6 +2135,9 @@ */ { OFString cmd = opt_execOnReception; + time_t t = time( NULL ); + struct tm *tmp = localtime( &t ); + char outstr[80]; // in case a file was actually written if( !opt_ignore ) @@ -2152,6 +2160,15 @@ // perform substitution for placeholder #c cmd = replaceChars( cmd, OFString(CALLED_AETITLE_PLACEHOLDER), calledaetitle ); + // perform substitution for placeholder #r (remote ip address) + cmd = replaceChars( cmd, OFString(CALLING_PRESENTATION_ADDRESS_PLACEHOLDER), callingpresentationaddress ); + + // perform substitution for placeholder #d (received date) + if ( tmp && strftime(outstr, sizeof(outstr), "%F %T", tmp ) ) + { + cmd = replaceChars( cmd, OFString(RECEIVED_DATE_PLACEHOLDER), outstr ); + } + // Execute command in a new process executeCommand( cmd ); } @@ -2254,6 +2271,9 @@ */ { OFString cmd = opt_execOnEndOfStudy; + time_t t = time( NULL ); + struct tm *tmp = localtime( &t ); + char outstr[80]; // perform substitution for placeholder #p; #p will be substituted by lastStudySubdirectoryPathAndName cmd = replaceChars( cmd, OFString(PATH_PLACEHOLDER), lastStudySubdirectoryPathAndName ); @@ -2264,6 +2284,15 @@ // perform substitution for placeholder #c cmd = replaceChars( cmd, OFString(CALLED_AETITLE_PLACEHOLDER), calledaetitle ); + // perform substitution for placeholder #r (remote ip address) + cmd = replaceChars( cmd, OFString(CALLING_PRESENTATION_ADDRESS_PLACEHOLDER), callingpresentationaddress ); + + // perform substitution for placeholder #d (received date) + if ( tmp && strftime(outstr, sizeof(outstr), "%F %T", tmp ) ) + { + cmd = replaceChars( cmd, OFString(RECEIVED_DATE_PLACEHOLDER), outstr ); + } + // Execute command in a new process executeCommand( cmd ); } Index: dcmqrdb/apps/dcmqridx.cc =================================================================== --- dcmqrdb/apps/dcmqridx.cc (revision 10) +++ dcmqrdb/apps/dcmqridx.cc (working copy) @@ -176,10 +176,10 @@ if (DU_findSOPClassAndInstanceInFile(opt_imageFile, sclass, sinst)) { #ifdef DEBUG - if (DB_getDebugLevel() > 0) + if (hdl.getDebugLevel() > 0) { /*** Test what filename is recommended by DB_Module **/ - DB_makeNewStoreFileName (hdl, sclass, sinst, fname) ; + hdl.makeNewStoreFileName (sclass, sinst, fname) ; printf("DB_Module recommends %s for filename\n", fname) ; } #endif Index: dcmqrdb/include/dcmtk/dcmqrdb/dcmqrcbm.h =================================================================== --- dcmqrdb/include/dcmtk/dcmqrdb/dcmqrcbm.h (revision 10) +++ dcmqrdb/include/dcmtk/dcmqrdb/dcmqrcbm.h (working copy) @@ -76,7 +76,7 @@ // , origAETitle() // , origHostName() , priority(pr) -// , ourAETitle() + , ourAETitle() // , dstAETitle() , failedUIDs(NULL) , nRemaining(0) @@ -87,7 +87,6 @@ origAETitle[0] = '\0'; origHostName[0] = '\0'; dstAETitle[0] = '\0'; - ourAETitle[0] = '\0'; } /** callback handler called by the DIMSE_storeProvider callback function. Index: config/Makefile.def.in =================================================================== --- config/Makefile.def.in (revision 27) +++ config/Makefile.def.in (working copy) @@ -11,7 +11,7 @@ bindir = $(DESTDIR)@bindir@ etcdir = $(DESTDIR)@sysconfdir@ -datadir = $(DESTDIR)@datadir@/data +datadir = $(DESTDIR)@datadir@/dcmtk docdir = $(DESTDIR)@datadir@/doc mandir = $(DESTDIR)@mandir@ libdir = $(DESTDIR)@libdir@ Index: config/configure.in =================================================================== --- config/configure.in (revision 27) +++ config/configure.in (working copy) @@ -28,14 +28,9 @@ dnl Configuration Utilities dnl ------------------------------------------------------- -if test "x$prefix" = xNONE ; then -AC_DEFINE_UNQUOTED(DCMTK_PREFIX, "${ac_default_prefix}", [Define the DCMTK default path]) -eval dcm_dict="${ac_default_prefix}/lib/dicom.dic" -else AC_DEFINE_UNQUOTED(DCMTK_PREFIX, "${prefix}", [Define the DCMTK default path]) -eval dcm_dict="${datadir}/dcmtk/dicom.dic" -fi +eval dcm_dict="${datadir}/dcmtk/dicom.dic" AC_DEFINE_UNQUOTED(DCM_DICT_DEFAULT_PATH, "${dcm_dict}", [Define the default data dictionary path for the dcmdata library package]) AH_VERBATIM([PATH_SEPARATOR], [/* Define path separator */