tests/tools/scu.cc
// Returns the presentation context ID that best matches the given abstract syntax UID and
// transfer syntax UID.
Returns the presentation context ID that best matches the given abstract syntax UID and
transfer syntax UID.
Returns the presentation context ID that best matches the given abstract syntax UID and transfer syntax UID .
T_ASC_PresentationContextID DcmSCU::findAnyPresentationContextID(const OFString &abstractSyntax,
                                                                 const OFString &transferSyntax)
{
  if (m_assoc == NULL)
    return 0;
  DUL_PRESENTATIONCONTEXT *pc;
  LST_HEAD **l;
  OFBool found = OFFalse;
  if (abstractSyntax.empty()) return 0;
  l = &m_assoc->params->DULparams.acceptedPresentationContext;
  pc = (DUL_PRESENTATIONCONTEXT*) LST_Head(l);
  (void)LST_Position(l, (LST_NODE*)pc);
  while (pc && !found)
  {
    found = (strcmp(pc->abstractSyntax, abstractSyntax.c_str()) == 0);
    found &= (pc->result == ASC_P_ACCEPTANCE);
    if (!transferSyntax.empty())  
      found &= (strcmp(pc->acceptedTransferSyntax, transferSyntax.c_str()) == 0);
    if (!found) pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l);
  }
  if (found) return pc->presentationContextID;
  l = &m_assoc->params->DULparams.acceptedPresentationContext;
  pc = (DUL_PRESENTATIONCONTEXT*) LST_Head(l);
  (void)LST_Position(l, (LST_NODE*)pc);
  while (pc && !found)
  {
    found =  (strcmp(pc->abstractSyntax, abstractSyntax.c_str()) == 0)
          && (pc->result == ASC_P_ACCEPTANCE)
          && ((strcmp(pc->acceptedTransferSyntax, UID_LittleEndianExplicitTransferSyntax) == 0)
          || (strcmp(pc->acceptedTransferSyntax, UID_BigEndianExplicitTransferSyntax) == 0));
    if (!found) pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l);
  }
  if (found) return pc->presentationContextID;
  l = &m_assoc->params->DULparams.acceptedPresentationContext;
  pc = (DUL_PRESENTATIONCONTEXT*) LST_Head(l);
  (void)LST_Position(l, (LST_NODE*)pc);
  while (pc && !found)
  {
    found = (strcmp(pc->abstractSyntax, abstractSyntax.c_str()) == 0)
          && (pc->result == ASC_P_ACCEPTANCE)
          && (strcmp(pc->acceptedTransferSyntax, UID_LittleEndianImplicitTransferSyntax) == 0);
    if (!found) pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l);
  }
  if (found) return pc->presentationContextID;
  return ASC_findAcceptedPresentationContextID(m_assoc, abstractSyntax.c_str());
}
T_ASC_PresentationContextID DcmSCU :: findAnyPresentationContextID ( const OFString & abstractSyntax , const OFString & transferSyntax ) { if ( m_assoc == NULL ) return 0 ; DUL_PRESENTATIONCONTEXT * pc ; LST_HEAD * * l ; OFBool found = OFFalse ; if ( abstractSyntax . empty ( ) ) return 0 ; l = & m_assoc -> params -> DULparams . acceptedPresentationContext ; pc = ( DUL_PRESENTATIONCONTEXT * ) LST_Head ( l ) ; ( void ) LST_Position ( l , ( LST_NODE * ) pc ) ; while ( pc && ! found ) { found = ( strcmp ( pc -> abstractSyntax , abstractSyntax . c_str ( ) ) == 0 ) ; found &= ( pc -> result == ASC_P_ACCEPTANCE ) ; if ( ! transferSyntax . empty ( ) ) found &= ( strcmp ( pc -> acceptedTransferSyntax , transferSyntax . c_str ( ) ) == 0 ) ; if ( ! found ) pc = ( DUL_PRESENTATIONCONTEXT * ) LST_Next ( l ) ; } if ( found ) return pc -> presentationContextID ; l = & m_assoc -> params -> DULparams . acceptedPresentationContext ; pc = ( DUL_PRESENTATIONCONTEXT * ) LST_Head ( l ) ; ( void ) LST_Position ( l , ( LST_NODE * ) pc ) ; while ( pc && ! found ) { found = ( strcmp ( pc -> abstractSyntax , abstractSyntax . c_str ( ) ) == 0 ) && ( pc -> result == ASC_P_ACCEPTANCE ) && ( ( strcmp ( pc -> acceptedTransferSyntax , UID_LittleEndianExplicitTransferSyntax ) == 0 ) || ( strcmp ( pc -> acceptedTransferSyntax , UID_BigEndianExplicitTransferSyntax ) == 0 ) ) ; if ( ! found ) pc = ( DUL_PRESENTATIONCONTEXT * ) LST_Next ( l ) ; } if ( found ) return pc -> presentationContextID ; l = & m_assoc -> params -> DULparams . acceptedPresentationContext ; pc = ( DUL_PRESENTATIONCONTEXT * ) LST_Head ( l ) ; ( void ) LST_Position ( l , ( LST_NODE * ) pc ) ; while ( pc && ! found ) { found = ( strcmp ( pc -> abstractSyntax , abstractSyntax . c_str ( ) ) == 0 ) && ( pc -> result == ASC_P_ACCEPTANCE ) && ( strcmp ( pc -> acceptedTransferSyntax , UID_LittleEndianImplicitTransferSyntax ) == 0 ) ; if ( ! found ) pc = ( DUL_PRESENTATIONCONTEXT * ) LST_Next ( l ) ; } if ( found ) return pc -> presentationContextID ; return ASC_findAcceptedPresentationContextID ( m_assoc , abstractSyntax . c_str ( ) ) ; }
Returns the presentation context ID that best matches the given abstract syntax UID and
transfer syntax UID.
Returns the presentation context ID that best matches the given abstract syntax UID and transfer syntax UID .
/* first of all we look for a presentation context
   * matching both abstract and transfer syntax
   */ // ignore transfer syntax if not specified /* now we look for an explicit VR uncompressed PC. */ /* now we look for an implicit VR uncompressed PC. */ /* finally we accept everything we get.
     returns 0 if abstract syntax is not supported
  */