Ejemplo n.º 1
0
bool
menu( game_t ** game )
{
	options_t options;
	char str[MAX_COM_LEN];
	modeOption_t modeOption;

	clearError();

	modeOption = chooseMode();

	raiseErrorIf( errorCode() == NOERROR, errorCode(), true );

	switch( modeOption ){
		case MODE0:
		case MODE1:
		case MODE2:
			options = chooseOptions( (modus_t)modeOption );
			raiseErrorIf( errorCode() == NOERROR, errorCode(), true );
			*game = newGame( &options );
			return true;
		case READFROMFILE:
			drawText("Enter the name of the file:\n");
			*game = readGame( askString( str ) );
			return true;
		case QUIT:
		default:
			return false;
	}
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
  
  DataCube dc(2); // datacube of dimension 2

  Vector<int> size(2); 
  size[1] = 5; // range of datacube in x-direction
  size[2] = 5; // range of datacube in y-direction

  Vector<double> spaceing(2);
  spaceing[1]=1.0;
  spaceing[2]=1.0;

  dc.SetCubeSizeAndSpaceing(size,spaceing); 
  dc.MallocCube();

  // define the dataarray
  for ( int i = 0; i < size[1]; i++ ){
    for ( int j = 0; j < size[2]; j++ ){

      if (  ( i == 2 ) || ( ( i > 1 ) && ( j == 2 ) ) )
	dc(i,j) = 1.0;

    } 
  }

  // test the calculation of moments

  //define volume
  Volume vol(0, 0, 0, 5, 5, spaceing[1], spaceing[2]);

  Moments mom(&dc);

  Vector<double> fp(2);
  int code = mom.focal_point( fp, vol );
  if ( code ) cout << errorCode(code);

  cout << "focal point: ( " << fp[1] << " " << fp[2] << " )" << endl;

  // caluclulate inertian tensor
  Vector<double> i_t(4);
  code = mom.inertian_tensor(i_t, vol );
  if ( code ) cout << errorCode(code);

  cout << "inertian tensor: ( " << i_t[1] << " " << i_t[2] << " )" << endl;
  cout << "                 ( " << i_t[3] << " " << i_t[4] << " )" << endl;

   // calculate inertian values

  Vector<double> ew(2);
  Vector<double> ev(4);
  code = mom.inertian_values(ew,ev,vol);
  if ( code ) cout << errorCode(code);

  cout << "eigenvektor: ( " << ev[1] << " " << ev[2] << " )" << endl;
  cout << "dazu eigenwert: " << ew[1] << endl;
  cout << "eigenvektor: ( " << ev[3] << " " << ev[4] << " )" << endl;
  cout << "dazu eigenwert: " << ew[2] << endl;
 
}
Ejemplo n.º 3
0
void ErrorCodeTest::TestSubclass() {
    int32_t countChecks=0;
    int32_t countDests=0;
    {
        MyErrorCode errorCode(countChecks, countDests);
        if( errorCode.get()!=U_ZERO_ERROR || !errorCode.isSuccess() || errorCode.isFailure() ||
            countChecks!=0 || countDests!=0
        ) {
            errln("ErrorCode did not initialize properly");
            return;
        }
        errorCode.assertSuccess();
        if(countChecks!=0) {
            errln("ErrorCode.assertSuccess() called handleFailure() despite success");
        }
        RefPlusOne(errorCode);
        if(errorCode.get()!=U_ILLEGAL_ARGUMENT_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) {
            errln("ErrorCode did not yield a writable reference");
        }
        errorCode.assertSuccess();
        if(countChecks!=1) {
            errln("ErrorCode.assertSuccess() did not handleFailure()");
        }
        PtrPlusTwo(errorCode);
        if(errorCode.get()!=U_INVALID_FORMAT_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) {
            errln("ErrorCode did not yield a writable pointer");
        }
        errorCode.assertSuccess();
        if(countChecks!=2) {
            errln("ErrorCode.assertSuccess() did not handleFailure()");
        }
        errorCode.set(U_PARSE_ERROR);
        if(errorCode.get()!=U_PARSE_ERROR || errorCode.isSuccess() || !errorCode.isFailure()) {
            errln("ErrorCode.set() failed");
        }
        if( errorCode.reset()!=U_PARSE_ERROR || errorCode.get()!=U_ZERO_ERROR ||
            !errorCode.isSuccess() || errorCode.isFailure()
        ) {
            errln("ErrorCode did not reset properly");
        }
        errorCode.assertSuccess();
        if(countChecks!=2) {
            errln("ErrorCode.assertSuccess() called handleFailure() despite success");
        }
    }
    if(countDests!=0) {
        errln("MyErrorCode destructor detected failure despite success");
    }
    countChecks=countDests=0;
    {
        MyErrorCode errorCode(countChecks, countDests);
        errorCode.set(U_PARSE_ERROR);
    }
    if(countDests!=1) {
        errln("MyErrorCode destructor failed to detect failure");
    }
}
Ejemplo n.º 4
0
void UTS46Test::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) {
    if(exec) {
        logln("TestSuite UTS46Test: ");
        if(trans==NULL) {
            IcuTestErrorCode errorCode(*this, "init/createUTS46Instance()");
            uint32_t commonOptions=
                UIDNA_USE_STD3_RULES|UIDNA_CHECK_BIDI|
                UIDNA_CHECK_CONTEXTJ|UIDNA_CHECK_CONTEXTO;
            trans=IDNA::createUTS46Instance(commonOptions, errorCode);
            nontrans=IDNA::createUTS46Instance(
                commonOptions|
                UIDNA_NONTRANSITIONAL_TO_ASCII|UIDNA_NONTRANSITIONAL_TO_UNICODE,
                errorCode);
            if(errorCode.logDataIfFailureAndReset("createUTS46Instance()")) {
                name="";
                return;
            }
        }
    }
    TESTCASE_AUTO_BEGIN;
    TESTCASE_AUTO(TestAPI);
    TESTCASE_AUTO(TestNotSTD3);
    TESTCASE_AUTO(TestSomeCases);
    TESTCASE_AUTO_END;
}
Ejemplo n.º 5
0
void UnicodeTest::TestBidiPairedBracketType() {
    // BidiBrackets-6.3.0.txt says:
    //
    // The set of code points listed in this file was originally derived
    // using the character properties General_Category (gc), Bidi_Class (bc),
    // Bidi_Mirrored (Bidi_M), and Bidi_Mirroring_Glyph (bmg), as follows:
    // two characters, A and B, form a pair if A has gc=Ps and B has gc=Pe,
    // both have bc=ON and Bidi_M=Y, and bmg of A is B. Bidi_Paired_Bracket
    // maps A to B and vice versa, and their Bidi_Paired_Bracket_Type
    // property values are Open and Close, respectively.
    IcuTestErrorCode errorCode(*this, "TestBidiPairedBracketType()");
    UnicodeSet bpt("[:^bpt=n:]", errorCode);
    assertTrue("bpt!=None is not empty", !bpt.isEmpty());
    // The following should always be true.
    UnicodeSet mirrored("[:Bidi_M:]", errorCode);
    UnicodeSet other_neutral("[:bc=ON:]", errorCode);
    assertTrue("bpt!=None is a subset of Bidi_M", mirrored.containsAll(bpt));
    assertTrue("bpt!=None is a subset of bc=ON", other_neutral.containsAll(bpt));
    // The following are true at least initially in Unicode 6.3.
    UnicodeSet bpt_open("[:bpt=o:]", errorCode);
    UnicodeSet bpt_close("[:bpt=c:]", errorCode);
    UnicodeSet ps("[:Ps:]", errorCode);
    UnicodeSet pe("[:Pe:]", errorCode);
    assertTrue("bpt=Open is a subset of Ps", ps.containsAll(bpt_open));
    assertTrue("bpt=Close is a subset of Pe", pe.containsAll(bpt_close));
}
Ejemplo n.º 6
0
/**
FreeReservedPhoneMemorySpace
*/
EXPORT_C TInt CSsmUiSpecific::FreeReservedPhoneMemorySpace(const TInt aSpaceToFree)
    {
	FUNC_LOG;
    TInt errorCode(KErrGeneral);
	INFO_2("Reserved memory is = %d bytes, Request to free memory is = %d bytes", iReservedPhoneMemory, aSpaceToFree);
    if(0 < iReservedPhoneMemory)
        {
		if(0 == aSpaceToFree)
		    {
		   	//Free complete reserved phone memory
			errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace( PhoneMemoryRootDriveId(), 0 );
			INFO_1("Freeing memory completed with = %d", errorCode);
			iReservedPhoneMemory = 0; 
		    }
		else
		    {
		    TInt newReserveSize = iReservedPhoneMemory - aSpaceToFree;
		    newReserveSize = newReserveSize >= 0 ? newReserveSize : 0;
		    errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace( PhoneMemoryRootDriveId(), newReserveSize );
			INFO_1("Freeing partial phone memory completed with = %d", errorCode);
		    if(KErrNone == errorCode)
			    {
			    iReservedPhoneMemory = newReserveSize;
			    }
		    }
		}
    return errorCode;
    }
Ejemplo n.º 7
0
void BytesTrieTest::TestTruncatingIteratorFromLinearMatchLong() {
    static const StringAndValue data[]={
        { "abcdef", 10 },
        { "abcdepq", 200 },
        { "abcdeyz", 3000 }
    };
    LocalPointer<BytesTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
    if(trie.isNull()) {
        return;  // buildTrie() reported an error
    }
    // Go into a linear-match node.
    trie->next('a');
    trie->next('b');
    trie->next('c');
    IcuTestErrorCode errorCode(*this, "TestTruncatingIteratorFromLinearMatchLong()");
    // Truncate after the linear-match node.
    BytesTrie::Iterator iter(*trie, 3, errorCode);
    if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
        return;
    }
    static const StringAndValue expected[]={
        { "def", 10 },
        { "dep", -1 },
        { "dey", -1 }
    };
    checkIterator(iter, expected, UPRV_LENGTHOF(expected));
    // Reset, and we should get the same result.
    logln("after iter.reset()");
    checkIterator(iter.reset(), expected, UPRV_LENGTHOF(expected));
}
// -----------------------------------------------------------------------------
// CAknFileSelectionModel::AddFolderL
//
//
// -----------------------------------------------------------------------------
//
TInt CAknFileSelectionModel::AddFolderL( const TDesC& aFolder )
    {
    // Cache the directory level because SetPath resets it
    TInt level( iDirectoryLevel );

    // The engine only supports adding one folder at a time
    if ( AknCFDUtility::DirectoryCount( aFolder ) !=  1 )
        {
        return KErrNotSupported;
        }

    //TPath currentPath( iCurrentPath.DriveAndPath() );

    HBufC * bufCurrentPath = HBufC::NewLC(KMaxPath);
    *bufCurrentPath = iCurrentPath.DriveAndPath();
    TPtr currentPath = bufCurrentPath->Des();

    currentPath.Append( aFolder );

    TInt errorCode( SetPathL( currentPath ) );

    CleanupStack::PopAndDestroy(); //bufCurrentPath

    if ( errorCode < KErrNone )
        {
        return errorCode;
        }

    iDirectoryLevel = ++level;

    return errorCode;
    }
Ejemplo n.º 9
0
std::string WindowsServicePrincipalName::toString() {
    DWORD length = 512;
    DWORD status = ERROR_BUFFER_OVERFLOW;
    bool firstCall = true;
    std::string str;

    while (status == ERROR_BUFFER_OVERFLOW) {
        std::vector<wchar_t> value(length);

        /* length after this call will contain the required length if current length is not enough - so the next call should succeed */
        status = dsMakeSpn(&length, vecptr(value));
        if (status == ERROR_SUCCESS) {
            str = convertWStringToString(std::wstring(vecptr(value), length-1 /* trailing 0 character */));
            break;
        }

        if ((firstCall == false) || (status != ERROR_BUFFER_OVERFLOW)) {
            std::stringstream errorString;
            boost::system::error_code errorCode(status, boost::system::system_category());

            errorString << "Error creating Service Principal Name: status: 0x" << std::hex << status << ": " << errorCode.message();

            /* Any other error will be a programming error */
            throw std::runtime_error(errorString.str());
        }

        firstCall = false;
    }

    SWIFT_LOG(debug) << "SPN: " << str << std::endl;
    return str;
}
Ejemplo n.º 10
0
void BytesTrieTest::TestIteratorFromLinearMatch() {
    LocalPointer<BytesTrie> trie(buildMonthsTrie(USTRINGTRIE_BUILD_SMALL));
    if(trie.isNull()) {
        return;  // buildTrie() reported an error
    }
    // Go into a linear-match node.
    trie->next('j');
    trie->next('a');
    trie->next('n');
    trie->next('u');
    trie->next('a');
    IcuTestErrorCode errorCode(*this, "TestIteratorFromLinearMatch()");
    BytesTrie::Iterator iter(*trie, 0, errorCode);
    if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
        return;
    }
    // Expected data: Same as in buildMonthsTrie(), except only the suffixes
    // following "janua".
    static const StringAndValue data[]={
        { "r", 1 },
        { "ry", 1 }
    };
    checkIterator(iter, data, UPRV_LENGTHOF(data));
    // Reset, and we should get the same result.
    logln("after iter.reset()");
    checkIterator(iter.reset(), data, UPRV_LENGTHOF(data));
}
Ejemplo n.º 11
0
// ---------------------------------------------------------------------------
// CMmTsyFax::Write
// Send fax data in descriptor to fax module, asynchronously.
// Returns: Error value
// ---------------------------------------------------------------------------
//
TInt CMmTsyFax::Write(
        const TTsyReqHandle aTsyReqHandle, 
        TDesC8* aDes )                     
    {
OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMTSYFAX_WRITE_1, "TSY: CMmTsyFax::Write : %d" , aTsyReqHandle);

    TInt errorCode( KErrNone );

    if ( !iFaxExt->GetFaxSession() 
         || iFaxExt->GetCallStatus() != RCall::EStatusConnected )
        {
        // not ready
        ReqCompleted( aTsyReqHandle, KErrNotReady );
        errorCode = KErrNone;
        }
    else
        {
        if( iTerminate )
            {
            errorCode = KErrGeneral;
            }
        else
            {
            // Prevent the machine powering down due to inactivity during a 
            // long fax send.
            User::ResetInactivityTime();
            iDataDirection = ESendData;
            CFaxSession* session = iFaxExt->GetFaxSession();
            // Request handle for CMmFaxCompletion object.
            iFaxExt->ConfigureCompletion( aTsyReqHandle, this );
            session->TxFaxData( *aDes );
            }
        }
    return errorCode;
    }
Ejemplo n.º 12
0
void UTS46Test::TestNotSTD3() {
    IcuTestErrorCode errorCode(*this, "TestNotSTD3()");
    char buffer[400];
    LocalPointer<IDNA> not3(IDNA::createUTS46Instance(UIDNA_CHECK_BIDI, errorCode));
    if(errorCode.isFailure()) {
        return;
    }
    UnicodeString input=UNICODE_STRING_SIMPLE("\\u0000A_2+2=4\\u000A.e\\u00DFen.net").unescape();
    UnicodeString result;
    IDNAInfo info;
    if( not3->nameToUnicode(input, result, info, errorCode)!=
            UNICODE_STRING_SIMPLE("\\u0000a_2+2=4\\u000A.essen.net").unescape() ||
        info.hasErrors()
    ) {
        prettify(result).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
        errln("notSTD3.nameToUnicode(non-LDH ASCII) unexpected errors %04lx string %s",
              (long)info.getErrors(), buffer);
    }
    // A space (BiDi class WS) is not allowed in a BiDi domain name.
    input=UNICODE_STRING_SIMPLE("a z.xn--4db.edu");
    not3->nameToASCII(input, result, info, errorCode);
    if(result!=input || info.getErrors()!=UIDNA_ERROR_BIDI) {
        errln("notSTD3.nameToASCII(ASCII-with-space.alef.edu) failed");
    }
    // Characters that are canonically equivalent to sequences with non-LDH ASCII.
    input=UNICODE_STRING_SIMPLE("a\\u2260b\\u226Ec\\u226Fd").unescape();
    not3->nameToUnicode(input, result, info, errorCode);
    if(result!=input || info.hasErrors()) {
        prettify(result).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
        errln("notSTD3.nameToUnicode(equiv to non-LDH ASCII) unexpected errors %04lx string %s",
              (long)info.getErrors(), buffer);
    }
}
Ejemplo n.º 13
0
// TODO: Move to a common place (IntlTest?) to avoid duplication with UnicodeTest (ucdtest.cpp).
char *BiDiConformanceTest::getUnidataPath(char path[]) {
    IcuTestErrorCode errorCode(*this, "getUnidataPath");
    const int kUnicodeDataTxtLength=15;  // strlen("UnicodeData.txt")

    // Look inside ICU_DATA first.
    strcpy(path, pathToDataDirectory());
    strcat(path, "unidata" U_FILE_SEP_STRING "UnicodeData.txt");
    FILE *f=fopen(path, "r");
    if(f!=NULL) {
        fclose(f);
        *(strchr(path, 0)-kUnicodeDataTxtLength)=0;  // Remove the basename.
        return path;
    }

    // As a fallback, try to guess where the source data was located
    // at the time ICU was built, and look there.
#   ifdef U_TOPSRCDIR
        strcpy(path, U_TOPSRCDIR  U_FILE_SEP_STRING "data");
#   else
        strcpy(path, loadTestData(errorCode));
        strcat(path, U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".."
                     U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".."
                     U_FILE_SEP_STRING "data");
#   endif
    strcat(path, U_FILE_SEP_STRING);
    strcat(path, "unidata" U_FILE_SEP_STRING "UnicodeData.txt");
    f=fopen(path, "r");
    if(f!=NULL) {
        fclose(f);
        *(strchr(path, 0)-kUnicodeDataTxtLength)=0;  // Remove the basename.
        return path;
    }
    return NULL;
}
Ejemplo n.º 14
0
// Create the sprite from the property tree node
bool BSIconLoader::CreateFromPropertyTreeNode(GTTreeNode *pTreeNode)
{
	if(NULL == pTreeNode)
	{
		return false;
	}


	bool res = false;
	GTString errorCode("");
		
	//get wild symbol ID
	GTTreeNode* pWildIconNode = pTreeNode->GetChild(PROPERTY_TAG_WILDICON);
	if(NULL == pWildIconNode)
	{
		return false;
	}
	m_wildIconID = pWildIconNode->GetValue().ToInt();


	//get bonus symbol ID
	GTTreeNode* pBonusIconNode = pTreeNode->GetChild(PROPERTY_TAG_BONUSICON);
	if(NULL == pBonusIconNode)
	{
		return false;
	}
	m_bonusIconID = pBonusIconNode->GetValue().ToInt();
	

	//load all reel icons;
	int id = 0;
	do 
	{
		//set reel name
		GTString iconName = PROPERTY_TAG_REELICON;
		iconName.Append(GTString::From(id));// + GTString::FormatFrom(id);
		GTTreeNode* pReelIconFile = pTreeNode->GetChild(iconName.ToCharString());

		if(pReelIconFile == NULL)
			break;

		GTString filename = pReelIconFile->GetValue();

		GSprite* pSprite = GameObjectCreation::CreateAnimatedSprite(
			filename,
			GameGeneral::GetInstance()->GetZOrderIdSprite()
			);
		if(NULL == pSprite)
		{
			break;
		}
		else
		{
			ReelIcon* reelIcon = new ReelIcon(id++, pSprite);
			m_reelIcons.AddToTail(reelIcon);
		}
	} while (true);

	return res;
}
Ejemplo n.º 15
0
// This method is called before first OnUpdate
int32 BSWinlineLoader::OnStart(void)
{
	GTBehaviour::OnStart();
	
	bool res = false;
	GTString errorCode("");

	GTString winlineSpriteKey = PROPERTY_TAG_WINLINE_SPRITE_KEY;
	GTGameObject * childGO = m_pGameObject->FindChild(winlineSpriteKey.ToCharString(), true);
	if(childGO != NULL)
	{	
		m_winlineSprite = (BSSprite*)(childGO->GetBehaviour(CTEXT("BSSprite")));
		if(m_winlineSprite == NULL)
		{
			res = false;
			errorCode = winlineSpriteKey;
		}
		else
			res = true;
	}

	if(!res)
		GTLogManager::SLogFormatError(CTEXT("Error!!! BSWinlineLoader can not find BSSprite: %s "), errorCode.ToCharString());

	m_winlineSprite->SetZOrder(UI_ZOrder::WINLINE);
	return 1;
}
Ejemplo n.º 16
0
 BytesTrieDictLookup(const DictionaryTriePerfTest &perfTest)
         : DictLookup(perfTest), trie(NULL), noDict(FALSE) {
     IcuToolErrorCode errorCode("BytesTrieDictLookup()");
     builder=new BytesTrieBuilder(errorCode);
     CharString str;
     const ULine *lines=perf.getCachedLines();
     int32_t numLines=perf.getNumLines();
     for(int32_t i=0; i<numLines; ++i) {
         // Skip comment lines (start with a character below 'A').
         if(lines[i].name[0]<0x41) {
             continue;
         }
         if(!thaiWordToBytes(lines[i].name, lines[i].len, str.clear(), errorCode)) {
             fprintf(stderr, "thaiWordToBytes(): failed for word %ld (0-based)\n", (long)i);
             noDict=TRUE;
             break;
         }
         builder->add(str.toStringPiece(), 0, errorCode);
     }
     if(!noDict) {
         int32_t length=builder->buildStringPiece(USTRINGTRIE_BUILD_SMALL, errorCode).length();
         printf("size of BytesTrie:           %6ld bytes\n", (long)length);
         trie=builder->build(USTRINGTRIE_BUILD_SMALL, errorCode);
     }
 }
Ejemplo n.º 17
0
 BytesTriePackageLookup(const DictionaryTriePerfTest &perf)
         : PackageLookup(perf) {
     IcuToolErrorCode errorCode("BinarySearchPackageLookup()");
     builder=new BytesTrieBuilder(errorCode);
     int32_t count=pkg.getItemCount();
     for(int32_t i=0; i<count; ++i) {
         // The Package class removes the "icudt46l/" prefix.
         // We restore that here for a fair performance test.
         // We store all full names so that we do not have to reconstruct them
         // in the call() function.
         const char *name=pkg.getItem(i)->name;
         int32_t offset=itemNames.length();
         itemNames.append("icudt46l/", errorCode);
         itemNames.append(name, -1, errorCode);
         // As value, set the data item index.
         // In a real implementation, we would use that to get the
         // start and limit offset of the data item.
         StringPiece fullName(itemNames.toStringPiece());
         fullName.remove_prefix(offset);
         builder->add(fullName, i, errorCode);
         // NUL-terminate the name for call() to find the next one.
         itemNames.append(0, errorCode);
     }
     int32_t length=builder->buildStringPiece(USTRINGTRIE_BUILD_SMALL, errorCode).length();
     printf("size of BytesTrie:   %6ld\n", (long)length);
     // count+1: +1 for the last-item limit offset which we should have always had
     printf("size of dataOffsets:%6ld\n", (long)((count+1)*4));
     printf("total index size:   %6ld\n", (long)(length+(count+1)*4));
 }
Ejemplo n.º 18
0
DWORD WindowsServicePrincipalName::dsMakeSpn(DWORD* length, wchar_t* value) {
    DWORD status;

#ifdef UNICODE
    SWIFT_LOG(debug) << "UNICODE is defined" << std::endl;
#else
    SWIFT_LOG(debug) << "UNICODE is not defined" << std::endl;
#endif

    SWIFT_LOG(debug) << "serviceClass_: " << convertWStringToString(serviceClass_.c_str()) << std::endl;
    SWIFT_LOG(debug) << "serviceName_: " << convertWStringToString(serviceName_.c_str()) << std::endl;
    SWIFT_LOG(debug) << "instanceName_: " << convertWStringToString(instanceName_.c_str()) << std::endl;
    SWIFT_LOG(debug) << "referrer_: " << convertWStringToString(referrer_.c_str()) << std::endl;
    SWIFT_LOG(debug) << "instancePort_: " << instancePort_ << std::endl;
    SWIFT_LOG(debug) << "length: " << *length << std::endl;

    /* Call the Unicode function because that is recommended:
https://msdn.microsoft.com/en-us/library/windows/desktop/ff381407%28v=vs.85%29.aspx */
    status =  DsMakeSpnW(
            serviceClass_.c_str(),
            serviceName_.c_str(),
            instanceName_.empty() ? NULL : instanceName_.c_str(),
            instancePort_,
            referrer_.empty() ? NULL : referrer_.c_str(),
            length,
            value);
    if (status != ERROR_SUCCESS) {
        boost::system::error_code errorCode(status, boost::system::system_category());

        SWIFT_LOG(debug) << std::hex << "status: 0x" << status << ": " << errorCode.message() << std::endl;
    }

    return status;
}
// ---------------------------------------------------------------------------
// Handles the result of a LIW command
// ---------------------------------------------------------------------------
//
TInt CMPXBackSteppingUtilityImp::HandleResultL()
    {
    MPX_DEBUG1( "-->CMPXBackSteppingUtilityImp::HandleResultL" );
    TInt statusInfo( KErrNotFound );
    
    TInt posErr( 0 );
    iOutParamList->FindFirst( posErr, LIW::EGenericParamError );
    if( posErr != KErrNotFound )
        {
        // error code found - extract and handle
        TInt errorCode( KErrNone );
        (*iOutParamList)[posErr].Value().Get( errorCode );
        
        User::LeaveIfError( errorCode );
        }

    // if no error returned, carry on
    TInt posStat( 0 );
    iOutParamList->FindFirst( posStat, KBSOutParamStatusInfo );
    if( posStat != KErrNotFound )
        {
        // status info present - extract and return
        (*iOutParamList)[posStat].Value().Get( statusInfo );
        }
    else
        {
        // no return value
        // this should not happen
        User::Leave( KErrNotFound );
        }

    MPX_DEBUG2( "<--CMPXBackSteppingUtilityImp::HandleResultL statusInfo=%d", statusInfo );
    return statusInfo;
    }
Ejemplo n.º 20
0
void BytesTrieTest::checkIterator(const BytesTrie &trie,
                                  const StringAndValue data[], int32_t dataLength) {
    IcuTestErrorCode errorCode(*this, "checkIterator()");
    BytesTrie::Iterator iter(trie, 0, errorCode);
    if(errorCode.logIfFailureAndReset("BytesTrie::Iterator(trie) constructor")) {
        return;
    }
    checkIterator(iter, data, dataLength);
}
Ejemplo n.º 21
0
void CollationRegressionTest::TestTrailingComment() {
    // ICU ticket #8070:
    // Check that the rule parser handles a comment without terminating end-of-line.
    IcuTestErrorCode errorCode(*this, "TestTrailingComment");
    RuleBasedCollator coll(UNICODE_STRING_SIMPLE("&c<b#comment1\n<a#comment2"), errorCode);
    UnicodeString a((UChar)0x61), b((UChar)0x62), c((UChar)0x63);
    assertTrue("c<b", coll.compare(c, b) < 0);
    assertTrue("b<a", coll.compare(b, a) < 0);
}
Ejemplo n.º 22
0
static char *
askString( char * str )
{
	char c;
	static char error[MAX_ERR_LEN];
	static char buffer[MAX_COM_LEN];

	do{
		clearScreen();
		drawText( NULL );
		drawPanel( error );
		askCommand( buffer );
		raiseErrorIf( errorCode() == NOERROR, errorCode(), NULL );
		error[0] = 0;
		if( ( c = sscanf( buffer, " %s", str ) ) != 1 && buffer[0] != '\n' )
			sprintf( error, "Format error:\nMust be a string" );
	}while( c != 1 );
	return str;
}
void PluralRulesTest::testOrdinal() {
    IcuTestErrorCode errorCode(*this, "testOrdinal");
    LocalPointer<PluralRules> pr(PluralRules::forLocale("en", UPLURAL_TYPE_ORDINAL, errorCode));
    if (errorCode.logIfFailureAndReset("PluralRules::forLocale(en, UPLURAL_TYPE_ORDINAL) failed")) {
        return;
    }
    UnicodeString keyword = pr->select(2.);
    if (keyword != UNICODE_STRING("two", 3)) {
        dataerrln("PluralRules(en-ordinal).select(2) failed");
    }
}
Ejemplo n.º 24
0
/*
 * get or create a Norm unit;
 * get or create the intermediate trie entries for it as well
 */
Norm *Normalizer2DataBuilder::createNorm(UChar32 c) {
    uint32_t i=utrie2_get32(normTrie, c);
    if(i!=0) {
        return norms+i;
    } else {
        /* allocate Norm */
        Norm *p=allocNorm();
        IcuToolErrorCode errorCode("gennorm2/createNorm()");
        utrie2_set32(normTrie, c, (uint32_t)(p-norms), errorCode);
        return p;
    }
}
Ejemplo n.º 25
0
 PackageLookup(const DictionaryTriePerfTest &perf) {
     IcuToolErrorCode errorCode("PackageLookup()");
     CharString filename(perf.getSourceDir(), errorCode);
     int32_t filenameLength=filename.length();
     if(filenameLength>0 && filename[filenameLength-1]!=U_FILE_SEP_CHAR &&
                            filename[filenameLength-1]!=U_FILE_ALT_SEP_CHAR) {
         filename.append(U_FILE_SEP_CHAR, errorCode);
     }
     filename.append(U_ICUDATA_NAME, errorCode);
     filename.append(".dat", errorCode);
     pkg.readPackage(filename.data());
 }
Ejemplo n.º 26
0
/***********************************************************************************************************************************
Remote command
***********************************************************************************************************************************/
void
cmdRemote(int handleRead, int handleWrite)
{
    FUNCTION_LOG_VOID(logLevelDebug);

    MEM_CONTEXT_TEMP_BEGIN()
    {
        String *name = strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u", cfgOptionUInt(cfgOptProcess));
        IoRead *read = ioHandleReadNew(name, handleRead, (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
        ioReadOpen(read);
        IoWrite *write = ioHandleWriteNew(name, handleWrite);
        ioWriteOpen(write);

        ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_REMOTE_STR, read, write);
        protocolServerHandlerAdd(server, storageRemoteProtocol);
        protocolServerHandlerAdd(server, configProtocol);

        // Acquire a lock if this command needs one.  We'll use the noop that is always sent from the client right after the
        // handshake to return an error.
        volatile bool success = false;

        TRY_BEGIN()
        {
            // Read the command.  No need to parse it since we know this is the first noop.
            ioReadLine(read);

            // Only try the lock if this is process 0, i.e. the remote started from the main process
            if (cfgOptionUInt(cfgOptProcess) == 0)
            {
                ConfigCommand commandId = cfgCommandId(strPtr(cfgOptionStr(cfgOptCommand)));

                // Acquire a lock if this command requires a lock
                if (cfgLockRemoteRequired(commandId))
                    lockAcquire(cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), cfgLockRemoteType(commandId), 0, true);
            }

            protocolServerResponse(server, NULL);
            success = true;
        }
        CATCH_ANY()
        {
            protocolServerError(server, errorCode(), STR(errorMessage()), STR(errorStackTrace()));
        }
        TRY_END();

        // If not successful we'll just exit
        if (success)
            protocolServerProcess(server);
    }
    MEM_CONTEXT_TEMP_END();

    FUNCTION_LOG_RETURN_VOID();
}
Ejemplo n.º 27
0
static void
ask2Int( int a1, int * n1, int b1, int a2, int * n2, int b2 )
{
	char c;
	static char error[MAX_ERR_LEN];
	static char buffer[MAX_COM_LEN];

	error[0] = 0;
	do{
		clearScreen();
		drawText( NULL );
		drawPanel( error );
		askCommand( buffer );
		raiseErrorIf( errorCode() == NOERROR, errorCode(), );
		error[0] = 0;
		if( ( c = sscanf( buffer, " %d %d %c", n1, n2, &c ) ) != 2 && buffer[0] != '\n' )
			sprintf( error, "Format error:\nMust be two integers, "
						"space separated" );
	}while( c != 2 || !validateInt( a1, *n1, b1+1, error ) ||
						!validateInt( a2, *n2, b2+1, error ) );
}
Ejemplo n.º 28
0
void LocalPointerTest::TestLocalXyzPointerMoveSwap() {
#if !UCONFIG_NO_NORMALIZATION
    IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerMoveSwap");
    const UNormalizer2 *nfc=unorm2_getNFCInstance(errorCode);
    const UNormalizer2 *nfd=unorm2_getNFDInstance(errorCode);
    if(errorCode.logIfFailureAndReset("unorm2_getNF[CD]Instance()")) {
        return;
    }
    UnicodeSet emptySet;
    UNormalizer2 *p1 = unorm2_openFiltered(nfc, emptySet.toUSet(), errorCode);
    UNormalizer2 *p2 = unorm2_openFiltered(nfd, emptySet.toUSet(), errorCode);
    LocalUNormalizer2Pointer f1(p1);
    LocalUNormalizer2Pointer f2(p2);
    if(errorCode.logIfFailureAndReset("unorm2_openFiltered()")) {
        return;
    }
    if(f1.isNull() || f2.isNull()) {
        errln("LocalUNormalizer2Pointer failure");
        return;
    }
    f1.swap(f2);
    if(f1.getAlias() != p2 || f2.getAlias() != p1) {
        errln("LocalUNormalizer2Pointer.swap() did not swap");
    }
    swap(f1, f2);
    if(f1.getAlias() != p1 || f2.getAlias() != p2) {
        errln("swap(LocalUNormalizer2Pointer) did not swap back");
    }
    LocalUNormalizer2Pointer f3;
    f3.moveFrom(f1);
    if(f3.getAlias() != p1 || f1.isValid()) {
        errln("LocalUNormalizer2Pointer.moveFrom() did not move");
    }
#if U_HAVE_RVALUE_REFERENCES
    infoln("TestLocalXyzPointerMoveSwap() with rvalue references");
    f1 = static_cast<LocalUNormalizer2Pointer &&>(f3);
    if(f1.getAlias() != p1 || f3.isValid()) {
        errln("LocalUNormalizer2Pointer move assignment operator did not move");
    }
    LocalUNormalizer2Pointer f4(static_cast<LocalUNormalizer2Pointer &&>(f2));
    if(f4.getAlias() != p2 || f2.isValid()) {
        errln("LocalUNormalizer2Pointer move constructor did not move");
    }
#else
    infoln("TestLocalXyzPointerMoveSwap() without rvalue references");
#endif
    // Move self assignment leaves the object valid but in an undefined state.
    // Do it to make sure there is no crash,
    // but do not check for any particular resulting value.
    f1.moveFrom(f1);
    f3.moveFrom(f3);
#endif /* !UCONFIG_NO_NORMALIZATION */
}
Ejemplo n.º 29
0
static int
askInt( int a, int b )
{
	int sol;
	char c;
	static char error[MAX_ERR_LEN];
	static char buffer[MAX_COM_LEN];

	error[0] = 0;
	do{
		clearScreen();
		drawText( NULL );
		drawPanel( error );
		askCommand( buffer );
		raiseErrorIf( errorCode() == NOERROR, errorCode(), -1 );
		error[0] = 0;
		if ( ( c = sscanf( buffer, " %d %c ", &sol, &c ) ) != 1 && buffer[0] != '\n' )
			sprintf( error, "Format error:\nMust be an integer" );
	}while( c != 1 || !validateInt( a, sol, b+1, error ) );

	return sol;
}
Ejemplo n.º 30
0
void
StringTest::TestCharString() {
    IcuTestErrorCode errorCode(*this, "TestCharString()");
    char expected[400];
    static const char longStr[] =
        "This is a long string that is meant to cause reallocation of the internal buffer of CharString.";
    CharString chStr(longStr, errorCode);
    if (0 != strcmp(longStr, chStr.data()) || (int32_t)strlen(longStr) != chStr.length()) {
        errln("CharString(longStr) failed.");
    }
    CharString test("Test", errorCode);
    CharString copy(test,errorCode);
    copy.copyFrom(chStr, errorCode);
    if (0 != strcmp(longStr, copy.data()) || (int32_t)strlen(longStr) != copy.length()) {
        errln("CharString.copyFrom() failed.");
    }
    StringPiece sp(chStr.toStringPiece());
    sp.remove_prefix(4);
    chStr.append(sp, errorCode).append(chStr, errorCode);
    strcpy(expected, longStr);
    strcat(expected, longStr+4);
    strcat(expected, longStr);
    strcat(expected, longStr+4);
    if (0 != strcmp(expected, chStr.data()) || (int32_t)strlen(expected) != chStr.length()) {
        errln("CharString(longStr).append(substring of self).append(self) failed.");
    }
    chStr.clear().append("abc", errorCode).append("defghij", 3, errorCode);
    if (0 != strcmp("abcdef", chStr.data()) || 6 != chStr.length()) {
        errln("CharString.clear().append(abc).append(defghij, 3) failed.");
    }
    chStr.appendInvariantChars(UNICODE_STRING_SIMPLE(
        "This is a long string that is meant to cause reallocation of the internal buffer of CharString."),
        errorCode);
    strcpy(expected, "abcdef");
    strcat(expected, longStr);
    if (0 != strcmp(expected, chStr.data()) || (int32_t)strlen(expected) != chStr.length()) {
        errln("CharString.appendInvariantChars(longStr) failed.");
    }
    int32_t appendCapacity = 0;
    char *buffer = chStr.getAppendBuffer(5, 10, appendCapacity, errorCode);
    if (errorCode.isFailure()) {
        return;
    }
    memcpy(buffer, "*****", 5);
    chStr.append(buffer, 5, errorCode);
    chStr.truncate(chStr.length()-3);
    strcat(expected, "**");
    if (0 != strcmp(expected, chStr.data()) || (int32_t)strlen(expected) != chStr.length()) {
        errln("CharString.getAppendBuffer().append(**) failed.");
    }
}