Ticket #18119: patch-dcmnet-apps-findscu.cc.diff
File patch-dcmnet-apps-findscu.cc.diff, 4.0 KB (added by guidolorenz@…, 16 years ago) |
---|
-
dcmnet/apps/findscu.cc
old new 21 21 * 22 22 * Purpose: Query/Retrieve Service Class User (C-FIND operation) 23 23 * 24 * Last Update: $Author: meichel$25 * Update Date: $Date: 200 5/12/08 15:44:19$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/findscu.cc,v $ 27 * CVS/RCS Revision: $Revision: 1.4 7$27 * CVS/RCS Revision: $Revision: 1.48 $ 28 28 * Status: $State: Exp $ 29 29 * 30 30 * CVS/RCS Log at end of file … … 111 111 fprintf(stderr, "\n"); 112 112 } 113 113 114 115 114 static void 116 115 addOverrideKey(OFConsoleApplication& app, const char* s) 117 116 { … … 119 118 unsigned int e = 0xffff; 120 119 int n = 0; 121 120 char val[1024]; 121 OFString dicName, valStr; 122 122 OFString msg; 123 123 char msg2[200]; 124 125 124 val[0] = '\0'; 125 126 126 // try to parse group and element number 127 127 n = sscanf(s, "%x,%x=%s", &g, &e, val); 128 129 if (n != 2) { 130 // not a group-element pair, try to lookup in dictionary 128 OFString toParse = s; 129 size_t eqPos = toParse.find('='); 130 if (n < 2) // if at least no tag could be parsed 131 { 132 // if value is given, extract it (and extrect dictname) 133 if (eqPos != OFString_npos) 134 { 135 dicName = toParse.substr(0,eqPos).c_str(); 136 valStr = toParse.substr(eqPos+1,toParse.length()); 137 } 138 else // no value given, just dictionary name 139 dicName = s; // only dictionary name given (without value) 140 // try to lookup in dictionary 131 141 DcmTagKey key(0xffff,0xffff); 132 142 const DcmDataDictionary& globalDataDict = dcmDataDict.rdlock(); 133 const DcmDictEntry *dicent = globalDataDict.findEntry( s);143 const DcmDictEntry *dicent = globalDataDict.findEntry(dicName.c_str()); 134 144 dcmDataDict.unlock(); 135 145 if (dicent!=NULL) { 136 146 // found dictionary name, copy group and element number … … 141 151 else { 142 152 // not found in dictionary 143 153 msg = "bad key format or dictionary name not found in dictionary: "; 144 msg += s;154 msg += dicName; 145 155 app.printError(msg.c_str()); 146 156 } 147 } 148 const char* spos = s; 149 char ccc; 150 do 157 } // tag could be parsed, copy value if it exists 158 else 151 159 { 152 ccc = *spos; 153 if (ccc == '=') break; 154 if (ccc == 0) { spos = NULL; break; } 155 spos++; 156 } while(1); 157 158 if (spos && *(spos+1)) { 159 strcpy(val, spos+1); 160 if (eqPos != OFString_npos) 161 valStr = toParse.substr(eqPos+1,toParse.length()); 160 162 } 161 162 163 DcmTag tag(g,e); 163 164 if (tag.error() != EC_Normal) { 164 165 sprintf(msg2, "unknown tag: (%04x,%04x)", g, e); … … 169 170 sprintf(msg2, "cannot create element for tag: (%04x,%04x)", g, e); 170 171 app.printError(msg2); 171 172 } 172 if (strlen(val) > 0) { 173 elem->putString(val); 174 if (elem->error() != EC_Normal) 173 if (valStr.length() > 0) { 174 if (elem->putString(valStr.c_str()).bad()) 175 175 { 176 176 sprintf(msg2, "cannot put tag value: (%04x,%04x)=\"", g, e); 177 177 msg = msg2; 178 msg += val ;178 msg += valStr; 179 179 msg += "\""; 180 180 app.printError(msg.c_str()); 181 181 } 182 182 } 183 183 184 184 if (overrideKeys == NULL) overrideKeys = new DcmDataset; 185 overrideKeys->insert(elem, OFTrue); 186 if (overrideKeys->error() != EC_Normal) { 185 if (overrideKeys->insert(elem, OFTrue).bad()) { 187 186 sprintf(msg2, "cannot insert tag: (%04x,%04x)", g, e); 188 187 app.printError(msg2); 189 188 } 190 189 } 191 190 191 192 192 static OFCondition addPresentationContext(T_ASC_Parameters *params); 193 193 194 194 static OFCondition … … 1164 1164 /* 1165 1165 ** CVS Log 1166 1166 ** $Log: findscu.cc,v $ 1167 ** Revision 1.48 2006/01/17 15:38:50 onken 1168 ** Fixed "--key" option, which was broken when using the optional assignment ("=") 1169 ** operation inside the option value 1170 ** 1167 1171 ** Revision 1.47 2005/12/08 15:44:19 meichel 1168 1172 ** Changed include path schema for all DCMTK header files 1169 1173 **