Ticket #18119: patch-dcmnet-apps-movescu.cc.diff
File patch-dcmnet-apps-movescu.cc.diff, 3.9 KB (added by guidolorenz@…, 16 years ago) |
---|
-
dcmnet/apps/movescu.cc
old new 21 21 * 22 22 * Purpose: Query/Retrieve Service Class User (C-MOVE operation) 23 23 * 24 * Last Update: $Author: meichel$25 * Update Date: $Date: 200 5/12/08 15:44:20 $24 * Last Update: $Author: onken $ 25 * Update Date: $Date: 2006/01/17 15:38:50 $ 26 26 * Source File: $Source: /share/dicom/cvs-depot/dcmtk/dcmnet/apps/movescu.cc,v $ 27 * CVS/RCS Revision: $Revision: 1. 59$27 * CVS/RCS Revision: $Revision: 1.60 $ 28 28 * Status: $State: Exp $ 29 29 * 30 30 * CVS/RCS Log at end of file … … 148 148 unsigned int e = 0xffff; 149 149 int n = 0; 150 150 char val[1024]; 151 OFString dicName, valStr; 151 152 OFString msg; 152 153 char msg2[200]; 153 154 154 val[0] = '\0'; 155 n = sscanf(s, "%x,%x=%s", &g, &e, val);156 155 157 if (n != 2) { 158 // not a group-element pair, try to lookup in dictionary 156 // try to parse group and element number 157 n = sscanf(s, "%x,%x=%s", &g, &e, val); 158 OFString toParse = s; 159 size_t eqPos = toParse.find('='); 160 if (n < 2) // if at least no tag could be parsed 161 { 162 // if value is given, extract it (and extrect dictname) 163 if (eqPos != OFString_npos) 164 { 165 dicName = toParse.substr(0,eqPos).c_str(); 166 valStr = toParse.substr(eqPos+1,toParse.length()); 167 } 168 else // no value given, just dictionary name 169 dicName = s; // only dictionary name given (without value) 170 // try to lookup in dictionary 159 171 DcmTagKey key(0xffff,0xffff); 160 172 const DcmDataDictionary& globalDataDict = dcmDataDict.rdlock(); 161 const DcmDictEntry *dicent = globalDataDict.findEntry( s);173 const DcmDictEntry *dicent = globalDataDict.findEntry(dicName.c_str()); 162 174 dcmDataDict.unlock(); 163 175 if (dicent!=NULL) { 164 176 // found dictionary name, copy group and element number … … 168 180 } 169 181 else { 170 182 // not found in dictionary 171 msg = "bad key format or keynot found in dictionary: ";172 msg += s;183 msg = "bad key format or dictionary name not found in dictionary: "; 184 msg += dicName; 173 185 app.printError(msg.c_str()); 174 186 } 187 } // tag could be parsed, copy value if it exists 188 else 189 { 190 if (eqPos != OFString_npos) 191 valStr = toParse.substr(eqPos+1,toParse.length()); 175 192 } 176 const char* spos = s;177 char ccc;178 do179 {180 ccc = *spos;181 if (ccc == '=') break;182 if (ccc == 0) { spos = NULL; break; }183 spos++;184 } while(1);185 186 if (spos && *(spos+1)) {187 strcpy(val, spos+1);188 }189 190 193 DcmTag tag(g,e); 191 194 if (tag.error() != EC_Normal) { 192 195 sprintf(msg2, "unknown tag: (%04x,%04x)", g, e); … … 197 200 sprintf(msg2, "cannot create element for tag: (%04x,%04x)", g, e); 198 201 app.printError(msg2); 199 202 } 200 if (strlen(val) > 0) { 201 elem->putString(val); 202 if (elem->error() != EC_Normal) 203 if (valStr.length() > 0) { 204 if (elem->putString(valStr.c_str()).bad()) 203 205 { 204 206 sprintf(msg2, "cannot put tag value: (%04x,%04x)=\"", g, e); 205 207 msg = msg2; 206 msg += val ;208 msg += valStr; 207 209 msg += "\""; 208 210 app.printError(msg.c_str()); 209 211 } 210 212 } 211 213 212 214 if (overrideKeys == NULL) overrideKeys = new DcmDataset; 213 overrideKeys->insert(elem, OFTrue); 214 if (overrideKeys->error() != EC_Normal) { 215 if (overrideKeys->insert(elem, OFTrue).bad()) { 215 216 sprintf(msg2, "cannot insert tag: (%04x,%04x)", g, e); 216 217 app.printError(msg2); 217 218 } … … 1407 1408 ** CVS Log 1408 1409 ** 1409 1410 ** $Log: movescu.cc,v $ 1411 ** Revision 1.60 2006/01/17 15:38:50 onken 1412 ** Fixed "--key" option, which was broken when using the optional assignment ("=") 1413 ** operation inside the option value 1414 ** 1410 1415 ** Revision 1.59 2005/12/08 15:44:20 meichel 1411 1416 ** Changed include path schema for all DCMTK header files 1412 1417 **