Ticket #18119: patch-dcmnet-apps-movescu.cc.diff

File patch-dcmnet-apps-movescu.cc.diff, 3.9 KB (added by guidolorenz@…, 15 years ago)
  • dcmnet/apps/movescu.cc

    old new  
    2121 *
    2222 *  Purpose: Query/Retrieve Service Class User (C-MOVE operation)
    2323 *
    24  *  Last Update:      $Author: meichel $
    25  *  Update Date:      $Date: 2005/12/08 15:44:20 $
     24 *  Last Update:      $Author: onken $
     25 *  Update Date:      $Date: 2006/01/17 15:38:50 $
    2626 *  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 $
    2828 *  Status:           $State: Exp $
    2929 *
    3030 *  CVS/RCS Log at end of file
     
    148148    unsigned int e = 0xffff;
    149149    int n = 0;
    150150    char val[1024];
     151    OFString dicName, valStr;
    151152    OFString msg;
    152153    char msg2[200];
    153 
    154154    val[0] = '\0';
    155     n = sscanf(s, "%x,%x=%s", &g, &e, val);
    156155
    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
    159171      DcmTagKey key(0xffff,0xffff);
    160172      const DcmDataDictionary& globalDataDict = dcmDataDict.rdlock();
    161       const DcmDictEntry *dicent = globalDataDict.findEntry(s);
     173      const DcmDictEntry *dicent = globalDataDict.findEntry(dicName.c_str());
    162174      dcmDataDict.unlock();
    163175      if (dicent!=NULL) {
    164176        // found dictionary name, copy group and element number
     
    168180      }
    169181      else {
    170182        // not found in dictionary
    171         msg = "bad key format or key not found in dictionary: ";
    172         msg += s;
     183        msg = "bad key format or dictionary name not found in dictionary: ";
     184        msg += dicName;
    173185        app.printError(msg.c_str());
    174186      }
     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());
    175192    }
    176     const char* spos = s;
    177     char ccc;
    178     do
    179     {
    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 
    190193    DcmTag tag(g,e);
    191194    if (tag.error() != EC_Normal) {
    192195        sprintf(msg2, "unknown tag: (%04x,%04x)", g, e);
     
    197200        sprintf(msg2, "cannot create element for tag: (%04x,%04x)", g, e);
    198201        app.printError(msg2);
    199202    }
    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())
    203205        {
    204206            sprintf(msg2, "cannot put tag value: (%04x,%04x)=\"", g, e);
    205207            msg = msg2;
    206             msg += val;
     208            msg += valStr;
    207209            msg += "\"";
    208210            app.printError(msg.c_str());
    209211        }
    210212    }
    211213
    212214    if (overrideKeys == NULL) overrideKeys = new DcmDataset;
    213     overrideKeys->insert(elem, OFTrue);
    214     if (overrideKeys->error() != EC_Normal) {
     215    if (overrideKeys->insert(elem, OFTrue).bad()) {
    215216        sprintf(msg2, "cannot insert tag: (%04x,%04x)", g, e);
    216217        app.printError(msg2);
    217218    }
     
    14071408** CVS Log
    14081409**
    14091410** $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**
    14101415** Revision 1.59  2005/12/08 15:44:20  meichel
    14111416** Changed include path schema for all DCMTK header files
    14121417**