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  
    2121 *
    2222 *  Purpose: Query/Retrieve Service Class User (C-FIND operation)
    2323 *
    24  *  Last Update:      $Author: meichel $
    25  *  Update Date:      $Date: 2005/12/08 15:44:19 $
     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/findscu.cc,v $
    27  *  CVS/RCS Revision: $Revision: 1.47 $
     27 *  CVS/RCS Revision: $Revision: 1.48 $
    2828 *  Status:           $State: Exp $
    2929 *
    3030 *  CVS/RCS Log at end of file
     
    111111    fprintf(stderr, "\n");
    112112}
    113113
    114 
    115114static void
    116115addOverrideKey(OFConsoleApplication& app, const char* s)
    117116{
     
    119118    unsigned int e = 0xffff;
    120119    int n = 0;
    121120    char val[1024];
     121    OFString dicName, valStr;
    122122    OFString msg;
    123123    char msg2[200];
    124 
    125124    val[0] = '\0';
     125
    126126    // try to parse group and element number
    127127    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
    131141      DcmTagKey key(0xffff,0xffff);
    132142      const DcmDataDictionary& globalDataDict = dcmDataDict.rdlock();
    133       const DcmDictEntry *dicent = globalDataDict.findEntry(s);
     143      const DcmDictEntry *dicent = globalDataDict.findEntry(dicName.c_str());
    134144      dcmDataDict.unlock();
    135145      if (dicent!=NULL) {
    136146        // found dictionary name, copy group and element number
     
    141151      else {
    142152        // not found in dictionary
    143153        msg = "bad key format or dictionary name not found in dictionary: ";
    144         msg += s;
     154        msg += dicName;
    145155        app.printError(msg.c_str());
    146156      }
    147     }
    148     const char* spos = s;
    149     char ccc;
    150     do
     157    } // tag could be parsed, copy value if it exists
     158    else
    151159    {
    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());
    160162    }
    161 
    162163    DcmTag tag(g,e);
    163164    if (tag.error() != EC_Normal) {
    164165        sprintf(msg2, "unknown tag: (%04x,%04x)", g, e);
     
    169170        sprintf(msg2, "cannot create element for tag: (%04x,%04x)", g, e);
    170171        app.printError(msg2);
    171172    }
    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())
    175175        {
    176176            sprintf(msg2, "cannot put tag value: (%04x,%04x)=\"", g, e);
    177177            msg = msg2;
    178             msg += val;
     178            msg += valStr;
    179179            msg += "\"";
    180180            app.printError(msg.c_str());
    181181        }
    182182    }
    183183
    184184    if (overrideKeys == NULL) overrideKeys = new DcmDataset;
    185     overrideKeys->insert(elem, OFTrue);
    186     if (overrideKeys->error() != EC_Normal) {
     185    if (overrideKeys->insert(elem, OFTrue).bad()) {
    187186        sprintf(msg2, "cannot insert tag: (%04x,%04x)", g, e);
    188187        app.printError(msg2);
    189188    }
    190189}
    191190
     191
    192192static OFCondition addPresentationContext(T_ASC_Parameters *params);
    193193
    194194static OFCondition
     
    11641164/*
    11651165** CVS Log
    11661166** $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**
    11671171** Revision 1.47  2005/12/08 15:44:19  meichel
    11681172** Changed include path schema for all DCMTK header files
    11691173**