Пример #1
0
int Basic(char *sql_file, char *log_file)
{
	if (check_environment(arbordir, arbordata, ds_database, dbms, arbordbu, \
				server_name) == FAILURE)
	{
		trc(ERROR,"Environment is not set up correctly. Exiting ...");
		exit(FAILURE);
	}

	if (open_log_sql(arbordata, sql_file) == FAILURE)
	{
		trc(ERROR,"Can not open sql log file %s in %s. Exiting ...");
		exit(FAILURE);
	}

	if (get_password(arbordir, arbor_password) == FAILURE)
	{
		trc(ERROR,"Can not read password file. Exiting ...");
		exit(FAILURE);
	}

	if (log_and_initialize(arbordbu, arbor_password, ds_database) == FAILURE)
	{
		trc(ERROR,"Can not log into database. Exiting ...");
		exit(FAILURE);
	}

	abp_set_date_format("MON DD YYYY");

	return 0;
}
Пример #2
0
// Algorithm version overrides.
static MPMasterKey mpw_masterKey_v3(
        const char *fullName, const char *masterPassword) {

    const char *keyScope = mpw_scopeForPurpose( MPKeyPurposeAuthentication );
    trc( "keyScope: %s", keyScope );

    // Calculate the master key salt.
    trc( "masterKeySalt: keyScope=%s | #fullName=%s | fullName=%s",
            keyScope, mpw_hex_l( (uint32_t)strlen( fullName ) ), fullName );
    size_t masterKeySaltSize = 0;
    uint8_t *masterKeySalt = NULL;
    mpw_push_string( &masterKeySalt, &masterKeySaltSize, keyScope );
    mpw_push_int( &masterKeySalt, &masterKeySaltSize, (uint32_t)strlen( fullName ) );
    mpw_push_string( &masterKeySalt, &masterKeySaltSize, fullName );
    if (!masterKeySalt) {
        err( "Could not allocate master key salt: %s", strerror( errno ) );
        return NULL;
    }
    trc( "  => masterKeySalt.id: %s", mpw_id_buf( masterKeySalt, masterKeySaltSize ) );

    // Calculate the master key.
    trc( "masterKey: scrypt( masterPassword, masterKeySalt, N=%lu, r=%u, p=%u )", MP_N, MP_r, MP_p );
    MPMasterKey masterKey = mpw_kdf_scrypt( MPMasterKeySize,
            (uint8_t *)masterPassword, strlen( masterPassword ), masterKeySalt, masterKeySaltSize, MP_N, MP_r, MP_p );
    mpw_free( &masterKeySalt, masterKeySaltSize );
    if (!masterKey) {
        err( "Could not derive master key: %s", strerror( errno ) );
        return NULL;
    }
    trc( "  => masterKey.id: %s", mpw_id_buf( masterKey, MPMasterKeySize ) );

    return masterKey;
}
Пример #3
0
MPSiteKey mpw_siteKey(
        MPMasterKey masterKey, const char *siteName, const MPCounterValue siteCounter,
        const MPKeyPurpose keyPurpose, const char *keyContext, const MPAlgorithmVersion algorithmVersion) {

    if (keyContext && !strlen( keyContext ))
        keyContext = NULL;

    trc( "-- mpw_siteKey (algorithm: %u)", algorithmVersion );
    trc( "siteName: %s", siteName );
    trc( "siteCounter: %d", siteCounter );
    trc( "keyPurpose: %d (%s)", keyPurpose, mpw_nameForPurpose( keyPurpose ) );
    trc( "keyContext: %s", keyContext );
    if (!masterKey || !siteName)
        return NULL;

    switch (algorithmVersion) {
        case MPAlgorithmVersion0:
            return mpw_siteKey_v0( masterKey, siteName, siteCounter, keyPurpose, keyContext );
        case MPAlgorithmVersion1:
            return mpw_siteKey_v1( masterKey, siteName, siteCounter, keyPurpose, keyContext );
        case MPAlgorithmVersion2:
            return mpw_siteKey_v2( masterKey, siteName, siteCounter, keyPurpose, keyContext );
        case MPAlgorithmVersion3:
            return mpw_siteKey_v3( masterKey, siteName, siteCounter, keyPurpose, keyContext );
        default:
            err( "Unsupported version: %d", algorithmVersion );
            return NULL;
    }
}
Пример #4
0
MPMasterKey mpw_masterKey(const char *fullName, const char *masterPassword, const MPAlgorithmVersion algorithmVersion) {

    if (fullName && !strlen( fullName ))
        fullName = NULL;
    if (masterPassword && !strlen( masterPassword ))
        masterPassword = NULL;

    trc( "-- mpw_masterKey (algorithm: %u)", algorithmVersion );
    trc( "fullName: %s", fullName );
    trc( "masterPassword.id: %s", masterPassword? mpw_id_buf( masterPassword, strlen( masterPassword ) ): NULL );
    if (!fullName || !masterPassword)
        return NULL;

    switch (algorithmVersion) {
        case MPAlgorithmVersion0:
            return mpw_masterKey_v0( fullName, masterPassword );
        case MPAlgorithmVersion1:
            return mpw_masterKey_v1( fullName, masterPassword );
        case MPAlgorithmVersion2:
            return mpw_masterKey_v2( fullName, masterPassword );
        case MPAlgorithmVersion3:
            return mpw_masterKey_v3( fullName, masterPassword );
        default:
            err( "Unsupported version: %d", algorithmVersion );
            return NULL;
    }
}
Пример #5
0
const char *mpw_siteState(
        MPMasterKey masterKey, const char *siteName, const MPCounterValue siteCounter,
        const MPKeyPurpose keyPurpose, const char *keyContext,
        const MPResultType resultType, const char *resultParam,
        const MPAlgorithmVersion algorithmVersion) {

    if (keyContext && !strlen( keyContext ))
        keyContext = NULL;
    if (resultParam && !strlen( resultParam ))
        resultParam = NULL;

    MPSiteKey siteKey = mpw_siteKey( masterKey, siteName, siteCounter, keyPurpose, keyContext, algorithmVersion );
    if (!siteKey)
        return NULL;

    trc( "-- mpw_siteState (algorithm: %u)", algorithmVersion );
    trc( "resultType: %d (%s)", resultType, mpw_nameForType( resultType ) );
    trc( "resultParam: %zu bytes = %s", sizeof( resultParam ), resultParam );
    if (!masterKey || !resultParam)
        return NULL;

    switch (algorithmVersion) {
        case MPAlgorithmVersion0:
            return mpw_siteState_v0( masterKey, siteKey, resultType, resultParam );
        case MPAlgorithmVersion1:
            return mpw_siteState_v1( masterKey, siteKey, resultType, resultParam );
        case MPAlgorithmVersion2:
            return mpw_siteState_v2( masterKey, siteKey, resultType, resultParam );
        case MPAlgorithmVersion3:
            return mpw_siteState_v3( masterKey, siteKey, resultType, resultParam );
        default:
            err( "Unsupported version: %d", algorithmVersion );
            return NULL;
    }
}
Пример #6
0
int log_and_initialize(char *arbordbu, char *arbor_password, char *ds_database)
{
	dbcatalog = abp_db_login(arbordbu, arbor_password, API_TEST);
	if (dbcatalog == NULL)
	{
		trc(ERROR,"Catalog DB logging failed. Exiting ..." );
		return (FAILURE);
	}
	else
		trc(INFO,"I am now logged into the catalog db...");


	dbcust = abp_cust_server_login(dbcatalog, 0, server_name, ds_database, \
					arbordbu, arbor_password, API_TEST );

	if (dbcust  == NULL)
	{
		trc(ERROR,"Customer DB logging failed. Exiting ..." );
		return (FAILURE);
	}

	abp_initialize_message_system( dbcust, API_TEST);
	trc(INFO,"Successfully logged into customer database");

	return(SUCCESS);
}
void GUIWebPageOrganizer::Update(float dt)
{
	IGUIElement::Update(dt);
	if(m_pages.size()==0)
		return;
	float speed=10;
	if(m_fullScreen)
	{
		math::rectf trc=math::rectf(0,GetSize());
		math::rectf rc=m_pages[m_activePage]->GetDefaultRegion()->GetRect();

		rc.ULPoint+=(trc.ULPoint-rc.ULPoint)*speed*dt;
		rc.BRPoint+=(trc.BRPoint-rc.BRPoint)*speed*dt;
		m_pages[m_activePage]->SetPosition(rc.ULPoint);
		m_pages[m_activePage]->SetSize(rc.getSize());
	}else
	{
		for(int i=0;i<m_pages.size();++i)
		{
			math::rectf trc(100+i*50,100+i*20,500+i*50,500+i*20);
			math::rectf rc=m_pages[i]->GetDefaultRegion()->GetRect();

			rc.ULPoint+=(trc.ULPoint-rc.ULPoint)*speed*dt;
			rc.BRPoint+=(trc.BRPoint-rc.BRPoint)*speed*dt;
			m_pages[i]->SetPosition(rc.ULPoint);
			m_pages[i]->SetSize(rc.getSize());
		}
	}
}
Пример #8
0
void iHeroChild::OnCompose()
{
	iRect rc = GetScrRect();
	gGfxMgr.BlitTile(PDGG_BKTILE, gApp.Surface(),rc);
	gApp.Surface().Darken25Rect(rc);

	check(m_pHero);

	// Name
	iRect trc(rc.x,rc.y,rc.w,17);
	ButtonFrame(gApp.Surface(),trc,0);
	iStringT txt;
	txt.Addf(_T("#S0#FEEE%s#S2#FAFF %s #S0#FEEE%s %d"),gTextMgr[TRID_HERO_TYPE_KNIGHT+m_pHero->Type()],m_pHero->Name().CStr(),gTextMgr[TRID_LEVEL],m_pHero->Level());
	gTextComposer.TextOut(gApp.Surface(),trc,txt,trc,AlignCenter);
	gApp.Surface().HLine(iPoint(rc.x,rc.y+17),rc.x2(),cColor_Black);

	rc.DeflateRect(0,18,0,0);

	// Portrait
	/*
	gApp.Surface().FrameRect(iRect(rc.x+2,rc.y+1,50,50),cColor_Black);
	gGfxMgr.Blit(m_pHero->Proto()->m_icn48,gApp.Surface(),iPoint(rc.x+3,rc.y+2));
	ButtonFrame(gApp.Surface(),iRect(rc.x+3,rc.y+2,48,48),0);
	*/
}
Пример #9
0
// TODO:
//   really I want just the function here, tbh.  Also a nice way would
//   be to have a thread-makign wrapper and various helpers to.
//
// this is identical to the sdl outputter.  Maybe I can abstract all
// the monitor stuff and just return buffers.   The ideal would be
// that when the input is over, I wait forever inside the monitor
// bit and stay there until the thread is finally closed.  Then the
// entire code is:
//
//   // I guess a real output will always want these structs.
//   void initialise(spec, *got_spec) {
//   }
//
//   // will be necesasy I'm sure - tricky because we need to wait until
//   // the very end of the sond before we actually organise this.  Means
//   // that the output callback needs to wait somehow.  Either that or
//   // we use libsamplerate to resample.  Currently I think that reinitting
//   // for each track is going to cause issues because some sound cards
//   // won't support the right rate.  Yah.  Sample rate is the only way
//   // to go.
//   void reinitialise(spec, *got_spec) {}
//
//   void my_output_plugin(void *output, std::size_t length) {
//     again:
//     buffer = pop_buffer();
//     std::memcpy(output, buffer, length);
//   }
//
//   void shutdown() {
//   }
//
// The real choice is whether to use C++ or C.
void dump_to_file(std::size_t buffer_len) {
  typedef sync_traits_type::monitor_type monitor_type;

  // trc("callback");
  void *buffer = NULL;
  while (true) {
    {
      trc("wait here...");
      monitor_type m(synced_queue, &continue_predicate);
      trc("woke up");

      synced_type::value_type &q = synced_queue.data();
      if (finished && q.empty()) {
        {
          // unconditional monitor - it's a write_ptr again
          trc("notifying exit");
          boost::unique_lock<boost::mutex> lk(finish_mut);
          output_closed = true;
          finish_cond.notify_all();
        }
        boost::thread::yield();
        // out.close();
        return;
      }
      else {
        assert(! q.empty());
        buffer = q.front();
        q.pop();
      }
    }

    trc("write " << buffer  << " with length " << buffer_len);
    // f**k you bullshit iostreams
    // assert(out.is_open());
    // out.write((const char *)buffer, buffer_len);
    // assert(! out.bad());
    // trc("wrote: " << v);
    // std::free(buffer);
    //
    std::size_t w = fwrite(buffer, 1, buffer_len, outfile);
    assert(w == buffer_len);
    fflush(outfile);
#ifndef WIN32
    fsync(fileno(outfile));
#endif
  }
}
Пример #10
0
    note_sequence(settings &set) {
      if (set.note_mode() == settings::note_mode_list) {
        impl_.reset(new detail::listed_sqeuence(
              set.concert_pitch(),
              set.note_list().begin(), set.note_list().end(),
              set.note_list().size()));
      }
      else {
        assert(set.note_mode() == settings::note_mode_start);
        trc("using a start note and distance");
        int start_offset = parse_note(set.start_note().c_str());

        int stop_offset;
        if (! set.end_note().empty()) {
          stop_offset = parse_note(set.end_note().c_str());
        }
        else if (set.num_notes() >= 0) {
          stop_offset = start_offset + set.num_notes() * set.note_distance();
        }
        else {
          stop_offset = start_offset + 12;
        }

        int step = set.note_distance();
        if (start_offset > stop_offset && step > 0) {
          std::cerr << "warning: making the step negative since the end note is lower than the start note." << std::endl;
          step = -step;
        }
        else if (start_offset < stop_offset && step < 0) {
          std::cerr << "warning: making the step positive since the end note is higher than the start note." << std::endl;
          step = -step;
        }

        trc("start: " << start_offset);
        trc("stop:  " << stop_offset);
        trc("step:  " << step);

        impl_.reset(
          new detail::generated_sequence(
            set.concert_pitch(), start_offset, stop_offset, step
          )
        );
        trc("done");
        assert(impl_.get());
      }
    }
Пример #11
0
static MPSiteKey mpw_siteKey_v2(
        MPMasterKey masterKey, const char *siteName, MPCounterValue siteCounter,
        MPKeyPurpose keyPurpose, const char *keyContext) {

    const char *keyScope = mpw_scopeForPurpose( keyPurpose );
    trc( "keyScope: %s", keyScope );

    // OTP counter value.
    if (siteCounter == MPCounterValueTOTP)
        siteCounter = ((uint32_t)time( NULL ) / MP_otp_window) * MP_otp_window;

    // Calculate the site seed.
    trc( "siteSalt: keyScope=%s | #siteName=%s | siteName=%s | siteCounter=%s | #keyContext=%s | keyContext=%s",
            keyScope, mpw_hex_l( (uint32_t)strlen( siteName ) ), siteName, mpw_hex_l( siteCounter ),
            keyContext? mpw_hex_l( (uint32_t)strlen( keyContext ) ): NULL, keyContext );
    size_t siteSaltSize = 0;
    uint8_t *siteSalt = NULL;
    mpw_push_string( &siteSalt, &siteSaltSize, keyScope );
    mpw_push_int( &siteSalt, &siteSaltSize, (uint32_t)strlen( siteName ) );
    mpw_push_string( &siteSalt, &siteSaltSize, siteName );
    mpw_push_int( &siteSalt, &siteSaltSize, siteCounter );
    if (keyContext) {
        mpw_push_int( &siteSalt, &siteSaltSize, (uint32_t)strlen( keyContext ) );
        mpw_push_string( &siteSalt, &siteSaltSize, keyContext );
    }
    if (!siteSalt) {
        err( "Could not allocate site salt: %s", strerror( errno ) );
        return NULL;
    }
    trc( "  => siteSalt.id: %s", mpw_id_buf( siteSalt, siteSaltSize ) );

    trc( "siteKey: hmac-sha256( masterKey.id=%s, siteSalt )",
            mpw_id_buf( masterKey, MPMasterKeySize ) );
    MPSiteKey siteKey = mpw_hash_hmac_sha256( masterKey, MPMasterKeySize, siteSalt, siteSaltSize );
    mpw_free( &siteSalt, siteSaltSize );
    if (!siteKey) {
        err( "Could not derive site key: %s", strerror( errno ) );
        return NULL;
    }
    trc( "  => siteKey.id: %s", mpw_id_buf( siteKey, MPSiteKeySize ) );

    return siteKey;
}
Пример #12
0
int open_log_sql(char *arbordata, char *sql_file)
{
	char temp[120] = "\0";

	strcat(temp, sql_file );
	strcat(temp, "_");
	strcat(temp, dbms);
	trc(INFO,"sql logs files = %s", temp);
	abp_copy_sql_to_file(temp);
	return(SUCCESS);
}
Пример #13
0
int get_password(char *arbordir, char *password)
{
	FILE *passw_fp;
	char passw_file[120] = "\0";
	int c;
	int k;

	strcpy(passw_file, arbordir );
	strcat(passw_file, FILE_SEP);
	strcat(passw_file, ARBOR_PASSWORD_FILENAME);

	passw_fp = fopen( passw_file, "r");
	if ( passw_fp == NULL )
	{
		trc(ERROR,"Can not open arbor password file %s. Exiting ...", passw_file);
		return(FAILURE);
	}

	k = 0;
	c = fgetc(passw_fp);
	while (c != EOF)
	{
		arbor_password[k] = c;
	 	c = fgetc(passw_fp);
	  	k++;
	}

	if (arbor_password[k-1] == '\n' )
    		arbor_password[k-1] = '\0';
	else
	    	arbor_password[k] = '\0';

	if (arbor_password == NULL )
	{
	   	trc(ERROR,"Arbor password is not defined. Exiting ...");
	    return(FAILURE);
	}

	strcpy( password, arbor_password);
	return(SUCCESS);
}
Пример #14
0
bool
StoreBuffer::MonoTypeBuffer<StoreBuffer::WholeObjectEdges>::accumulateEdges(EdgeSet &edges)
{
    compact();
    AccumulateEdgesTracer trc(owner->runtime, &edges);
    StoreBuffer::WholeObjectEdges *cursor = base;
    while (cursor != pos) {
        cursor->tenured->markChildren(&trc);
        cursor++;
    }
    return true;
}
Пример #15
0
static const uint8_t *mpw_masterKeyForUser_v1(const char *fullName, const char *masterPassword) {

    const char *mpKeyScope = mpw_scopeForVariant( MPSiteVariantPassword );
    trc( "algorithm: v%d\n", 1 );
    trc( "fullName: %s (%zu)\n", fullName, mpw_utf8_strlen( fullName ) );
    trc( "masterPassword: %s\n", masterPassword );
    trc( "key scope: %s\n", mpKeyScope );

    // Calculate the master key salt.
    // masterKeySalt = mpKeyScope . #fullName . fullName
    size_t masterKeySaltSize = 0;
    uint8_t *masterKeySalt = NULL;
    mpw_push_string( &masterKeySalt, &masterKeySaltSize, mpKeyScope );
    mpw_push_int( &masterKeySalt, &masterKeySaltSize, htonl( mpw_utf8_strlen( fullName ) ) );
    mpw_push_string( &masterKeySalt, &masterKeySaltSize, fullName );
    if (!masterKeySalt) {
        ftl( "Could not allocate master key salt: %d\n", errno );
        return NULL;
    }
    trc( "masterKeySalt ID: %s\n", mpw_id_buf( masterKeySalt, masterKeySaltSize ) );

    // Calculate the master key.
    // masterKey = scrypt( masterPassword, masterKeySalt )
    const uint8_t *masterKey = mpw_scrypt( MP_dkLen, masterPassword, masterKeySalt, masterKeySaltSize, MP_N, MP_r, MP_p );
    mpw_free( masterKeySalt, masterKeySaltSize );
    if (!masterKey) {
        ftl( "Could not allocate master key: %d\n", errno );
        return NULL;
    }
    trc( "masterKey ID: %s\n", mpw_id_buf( masterKey, MP_dkLen ) );

    return masterKey;
}
Пример #16
0
trigger_cell_xptr find_trigger(const char* title)
{
    trigger_cell_cptr trc(title);

    if (!trc.found())
    {
        return XNULL;
    }
    else
    {
        return trc.ptr();
    }
}
Пример #17
0
static const char *mpw_passwordForSite_v1(const uint8_t *masterKey, const char *siteName, const MPSiteType siteType, const uint32_t siteCounter,
        const MPSiteVariant siteVariant, const char *siteContext) {

    const char *siteScope = mpw_scopeForVariant( siteVariant );
    trc( "algorithm: v%d\n", 1 );
    trc( "siteName: %s\n", siteName );
    trc( "siteCounter: %d\n", siteCounter );
    trc( "siteVariant: %d\n", siteVariant );
    trc( "siteType: %d\n", siteType );
    trc( "site scope: %s, context: %s\n", siteScope, siteContext? "<empty>": siteContext );
    trc( "seed from: hmac-sha256(masterKey, %s | %s | %s | %s | %s | %s)\n",
            siteScope, mpw_hex_l( htonl( strlen( siteName ) ) ), siteName,
            mpw_hex_l( htonl( siteCounter ) ),
            mpw_hex_l( htonl( siteContext? strlen( siteContext ): 0 ) ), siteContext? "(null)": siteContext );

    // Calculate the site seed.
    // sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
    size_t sitePasswordInfoSize = 0;
    uint8_t *sitePasswordInfo = NULL;
    mpw_push_string( &sitePasswordInfo, &sitePasswordInfoSize, siteScope );
    mpw_push_int( &sitePasswordInfo, &sitePasswordInfoSize, htonl( mpw_utf8_strlen( siteName ) ) );
    mpw_push_string( &sitePasswordInfo, &sitePasswordInfoSize, siteName );
    mpw_push_int( &sitePasswordInfo, &sitePasswordInfoSize, htonl( siteCounter ) );
    if (siteContext) {
        mpw_push_int( &sitePasswordInfo, &sitePasswordInfoSize, htonl( mpw_utf8_strlen( siteContext ) ) );
        mpw_push_string( &sitePasswordInfo, &sitePasswordInfoSize, siteContext );
    }
    if (!sitePasswordInfo) {
        ftl( "Could not allocate site seed info: %d\n", errno );
        return NULL;
    }
    trc( "sitePasswordInfo ID: %s\n", mpw_id_buf( sitePasswordInfo, sitePasswordInfoSize ) );

    const uint8_t *sitePasswordSeed = mpw_hmac_sha256( masterKey, MP_dkLen, sitePasswordInfo, sitePasswordInfoSize );
    mpw_free( sitePasswordInfo, sitePasswordInfoSize );
    if (!sitePasswordSeed) {
        ftl( "Could not allocate site seed: %d\n", errno );
        return NULL;
    }
    trc( "sitePasswordSeed ID: %s\n", mpw_id_buf( sitePasswordSeed, 32 ) );

    // Determine the template.
    const char *template = mpw_templateForType( siteType, sitePasswordSeed[0] );
Пример #18
0
void process_message(ABP_DBHANDLE dbhandle, int retval)
{
	int msgno, sev, type;
	
	switch(retval)
	{
	case ABP_DBERR:
		trc(ERROR,abp_get_db_message(dbhandle, &msgno, &sev, &type));
		break;
	case ABP_MISC_ERR:
		trc(ERROR,abp_get_misc_message(dbhandle, &msgno, &sev, &type));
		break;
	case ABP_ARGERR:
		trc(ERROR,"Argument error");
		break;
	case ABP_SYSERR:
		perror(NULL);
		break;
	default:
		trc(ERROR,"Unknown retval: %d", retval);
		break;
	}
}
Пример #19
0
void iDlg_CreatInfo::DoCompose(const iRect& clRect)
{
	iRect rc(clRect);

	// title
	gTextComposer.TextOut(dlgfc_hdr, gApp.Surface(),rc.point(),gTextMgr[m_cGroup.Type()*3+TRID_CREATURE_PEASANT_F2], iRect(rc.x,rc.y,rc.w,15),AlignCenter);
	rc.y+=15;

	// icon
	BlitIcon(gApp.Surface(),PDGG_MINIMON+m_cGroup.Type(),iRect(rc.x,rc.y,rc.w,45));
	rc.y+=45;

	// Perks
	if (CREAT_DESC[m_cGroup.Type()].perks != CPERK_NONE) rc.y+=15;

	// props
	iRect trc(rc.x,rc.y,90,12);
	iTextComposer::FontConfig fc(iTextComposer::FS_SMALL, RGB16(192,192,255));
	gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_ATTACK])+_T(" :"),trc,AlignTopRight); trc.y+=10;
	gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_DEFENCE])+_T(" :"),trc,AlignTopRight); trc.y+=10;
	gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_SHOTS])+_T(" :"),trc,AlignTopRight); trc.y+=10;
	gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_DAMAGE])+_T(" :"),trc,AlignTopRight); trc.y+=10;
	gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_HEALTH])+_T(" :"),trc,AlignTopRight); trc.y+=10;
	gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_SPEED])+_T(" :"),trc,AlignTopRight); trc.y+=10;
	gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_MORALE])+_T(" :"),trc,AlignTopRight); trc.y+=10;
	gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_LUCK])+_T(" :"),trc,AlignTopRight); trc.y+=10;

	trc = iRect(rc.x+95,rc.y,rc.w-105,12);
	iTextComposer::FontConfig tfc(iTextComposer::FS_SMALL, RGB16(255,220,192));
	iStringT tout;

	tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].attack, CREAT_DESC[m_cGroup.Type()].attack+m_furtSkills.Value(FSK_ATTACK));
	gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10;
	tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].defence, CREAT_DESC[m_cGroup.Type()].defence+m_furtSkills.Value(FSK_DEFENCE));
	gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10;
	if (CREAT_DESC[m_cGroup.Type()].shots) tout.Setf(_T("%d"),CREAT_DESC[m_cGroup.Type()].shots);
	else tout.Setf(_T("-"));
	gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10;
	tout.Setf(_T("%d - %d"),CREAT_DESC[m_cGroup.Type()].damage_min,CREAT_DESC[m_cGroup.Type()].damage_max);
	gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10;
	tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].hits, CREAT_DESC[m_cGroup.Type()].hits+m_furtSkills.Value(FSK_HITS));
	gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10;
	tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].speed, CREAT_DESC[m_cGroup.Type()].speed+m_furtSkills.Value(FSK_SPEED));
	gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10;
	sint32 morale = (CREAT_DESC[m_cGroup.Type()].perks&CPERK_UNDEAD)?0:(m_furtSkills.Value(FSK_MORALE)+m_moraleMod);
	gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),FormatNumber(morale,true),trc,AlignTopLeft); trc.y+=10;
	gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),FormatNumber(m_furtSkills.Value(FSK_LUCK),true),trc,AlignTopLeft); trc.y+=10;
}
JSObject*
CreateGlobalObject(JSContext* cx, const JSClass* clasp, nsIPrincipal* principal,
                   JS::CompartmentOptions& aOptions)
{
    MOZ_ASSERT(NS_IsMainThread(), "using a principal off the main thread?");
    MOZ_ASSERT(principal);

    MOZ_RELEASE_ASSERT(principal != nsContentUtils::GetNullSubjectPrincipal(),
                       "The null subject principal is getting inherited - fix that!");

    RootedObject global(cx,
                        JS_NewGlobalObject(cx, clasp, nsJSPrincipals::get(principal),
                                           JS::DontFireOnNewGlobalHook, aOptions));
    if (!global)
        return nullptr;
    JSAutoCompartment ac(cx, global);

    // The constructor automatically attaches the scope to the compartment private
    // of |global|.
    (void) new XPCWrappedNativeScope(cx, global);

    if (clasp->flags & JSCLASS_DOM_GLOBAL) {
#ifdef DEBUG
        // Verify that the right trace hook is called. Note that this doesn't
        // work right for wrapped globals, since the tracing situation there is
        // more complicated. Manual inspection shows that they do the right
        // thing.  Also note that we only check this for JSCLASS_DOM_GLOBAL
        // classes because xpc::TraceXPCGlobal won't call
        // TraceProtoAndIfaceCache unless that flag is set.
        if (!((const js::Class*)clasp)->isWrappedNative())
        {
            VerifyTraceProtoAndIfaceCacheCalledTracer trc(JS_GetRuntime(cx));
            TraceChildren(&trc, GCCellPtr(global.get()));
            MOZ_ASSERT(trc.ok, "Trace hook on global needs to call TraceXPCGlobal for XPConnect compartments.");
        }
#endif

        const char* className = clasp->name;
        AllocateProtoAndIfaceCache(global,
                                   (strcmp(className, "Window") == 0 ||
                                    strcmp(className, "ChromeWindow") == 0)
                                   ? ProtoAndIfaceCache::WindowLike
                                   : ProtoAndIfaceCache::NonWindowLike);
    }

    return global;
}
Пример #21
0
void sdl_callback(void*,uint8_t *stream, int length) {
  typedef sync_traits_type::monitor_type monitor_type;

  // trc("callback");
  void *buffer = NULL;
  {
    monitor_type m(synced_queue, &continue_predicate);
    // trc("woke up");

    synced_type::value_type &q = synced_queue.data();
    if (finished && q.empty()) {
      {
        // TODO:
        //   should use a proper monitor here, or at least a better way of
        //   storing these sync primitives.
        trc("notifying exit");
        boost::unique_lock<boost::mutex> lk(finish_mut);
        output_closed = true;
        finish_cond.notify_all();
      }
      boost::thread::yield();

      // normally we would just return from the thread here, but SDL controls
      // it so we have to wait for the main thread to shut sdl down.  We DON'T
      // wait on anything because otherwise we end up deadlocking; we might have
      // to deal with calling this code path a couple of times until SDL finally
      // terminates.
      return;
    }
    else {
      assert(! q.empty());
      buffer = q.front();
      q.pop();
    }
  }

  // trc("writing output data of length " << length);
  std::memcpy(stream, buffer, length);
  // pool.deallocate(buffer);
  // trc("freeing " << buffer);
  std::free(buffer);
}
Пример #22
0
int check_environment(char *arbordir, char *arbordata, char *ds_database, char *dbms, \
char *arbordbu, char *server_name)
{
	int retval;

	parbordir = getenv("ARBORDIR");
	if (parbordir == NULL)
	{
		trc(ERROR,"ARBODIR is not defined. Exiting ...");
		return(FAILURE);
	}
	else
		strcpy(arbordir, parbordir);

	parbordata = getenv("ARBORDATA");
	if (parbordata == NULL)
	{
		trc(ERROR,"ARBORDATA is not defined. Exiting ...");
		return(FAILURE);
	}
	else
		strcpy(arbordata, parbordata);

	pds_database = getenv("DS_DATABASE");
	if ( pds_database == NULL)
	{
		trc(ERROR,"DS_DATABASE is not defined. Exiting ...");
		return(FAILURE);
	}
	else
	{	
		strcpy( ds_database, pds_database);
		trc(INFO,"database = %s", ds_database); 
	}

	pdbms = getenv("DBMS");
	if (pdbms == NULL)
	{
		trc(ERROR,"DBMS is not defined. Exiting ...");
		return(FAILURE);
	}
	else
		strcpy(dbms, pdbms);

	parbordbu = getenv("ARBORDBU");
	if( parbordbu == NULL) 
	{
		trc(ERROR,"ARBORDBU is not defined. Exiting ...");
		return(FAILURE);
	}
	else
		strcpy( arbordbu, parbordbu );

	pserver_name = getenv("DSQUERY");
	if( pserver_name == NULL )
	{
		trc(ERROR,"DSQUERY is not defined..." );
		return (FAILURE);
	}
	else
		strcpy(server_name, pserver_name);


	retval = abp_set_dbserver(getenv("ARBOR_CATALOG_QUERY"));
	if (retval != ABP_STATUS_OK)
	{
		trc(ERROR,"Failed getting ARBOR_CATALOG_QUERY..." );
		return (FAILURE);
	}

	retval = abp_set_database( getenv("ARBOR_CATALOG_DATABASE"));
	if (retval != ABP_STATUS_OK)
	{
		trc(ERROR,"Failed getting ARBOR_CATALOG_DATABASE" );
		return (FAILURE);
	}

	return (SUCCESS);
}
Пример #23
0
trigger_cell_xptr create_trigger (enum trigger_time tr_time,
                                  enum trigger_event tr_event,
                                  xpath::PathExpression *trigger_path,
                                  enum trigger_granularity tr_gran,
                                  scheme_list* action,
                                  inserting_node innode,
                                  xpath::PathExpression *path_to_parent,
                                  doc_schema_node_xptr schemaroot,
                                  const char * trigger_title,
                                  const char* doc_name,
                                  bool is_doc)
{
    // I. Create and fill new trigger cell
    if (find_trigger(trigger_title) != XNULL)
    {
        throw USER_EXCEPTION(SE3200);
    }
    down_concurrent_micro_ops_number();

    trigger_cell_cptr trc(trigger_cell_object::create(trigger_title, schemaroot), true);

    schemaroot.modify()->full_trigger_list->add(trc.ptr());
    trc->trigger_path        = trigger_path;
    trc->trigger_event       = tr_event;
    trc->trigger_time        = tr_time;
    trc->trigger_granularity = tr_gran;

    if (rcv_tac != NULL) // recovery mode
    {
        trc->trigger_action = rcv_tac; // trigger_action_cell sequence has already been recovered from logical log
        rcv_tac = NULL;
    }
    else
    {
        trc->trigger_action = (trigger_action_cell*)malloc(sizeof(trigger_action_cell));
        trigger_action_cell* trac = trc->trigger_action;
        for (std::vector<scm_elem>::size_type i = 0; i < action->size(); i++)
        {
            trac->statement = (char*)malloc(strlen(action->at(i).internal.str)+1);
            strcpy(trac->statement,action->at(i).internal.str);

            if (i == action->size() - 1)
                trac->next = NULL;
            else
                trac->next = (trigger_action_cell*)malloc(sizeof(trigger_action_cell));

            trac = trac->next;
            RECOVERY_CRASH;
        }
    }

    // if the trigger is on before insert and statement level
    if((trc->trigger_event == TRIGGER_INSERT_EVENT) &&
       (trc->trigger_time == TRIGGER_BEFORE) &&
       (trc->trigger_granularity == TRIGGER_FOR_EACH_NODE)&&
       (path_to_parent))
    {
        trc->path_to_parent = path_to_parent;
        trc->innode = inserting_node(innode.name, innode.type);
    }
    else
    {
        trc->path_to_parent = NULL;
    }
    trc->doc_name = (char*)malloc(strlen(doc_name)+1);
    strcpy(trc->doc_name,doc_name);
    trc->is_doc=is_doc;

    hl_logical_log_trigger(tr_time, tr_event, trigger_path, tr_gran, trc->trigger_action, trc->innode, path_to_parent, trigger_title, doc_name, is_doc, true);

    //II. Execute abs path (object_path) on the desriptive schema
    t_scmnodes sobj;
    executePathExpression(schemaroot, *trigger_path, &sobj, NULL, NULL);

    //III. For each schema node found (sn_obj)
    std::vector<xptr> start_nodes;
    for (size_t i = 0; i < sobj.size(); i++)
    {
        sobj[i].modify()->trigger_list->add(trc.ptr());
        RECOVERY_CRASH;
    }

    up_concurrent_micro_ops_number();

    return trc.ptr();
}
Пример #24
0
const char *mpw_siteResult(
        MPMasterKey masterKey, const char *siteName, const MPCounterValue siteCounter,
        const MPKeyPurpose keyPurpose, const char *keyContext,
        const MPResultType resultType, const char *resultParam,
        const MPAlgorithmVersion algorithmVersion) {

    if (keyContext && !strlen( keyContext ))
        keyContext = NULL;
    if (resultParam && !strlen( resultParam ))
        resultParam = NULL;

    MPSiteKey siteKey = mpw_siteKey( masterKey, siteName, siteCounter, keyPurpose, keyContext, algorithmVersion );
    if (!siteKey)
        return NULL;

    trc( "-- mpw_siteResult (algorithm: %u)", algorithmVersion );
    trc( "resultType: %d (%s)", resultType, mpw_nameForType( resultType ) );
    trc( "resultParam: %s", resultParam );

    char *sitePassword = NULL;
    if (resultType & MPResultTypeClassTemplate) {
        switch (algorithmVersion) {
            case MPAlgorithmVersion0:
                return mpw_sitePasswordFromTemplate_v0( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion1:
                return mpw_sitePasswordFromTemplate_v1( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion2:
                return mpw_sitePasswordFromTemplate_v2( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion3:
                return mpw_sitePasswordFromTemplate_v3( masterKey, siteKey, resultType, resultParam );
            default:
                err( "Unsupported version: %d", algorithmVersion );
                return NULL;
        }
    }
    else if (resultType & MPResultTypeClassStateful) {
        switch (algorithmVersion) {
            case MPAlgorithmVersion0:
                return mpw_sitePasswordFromCrypt_v0( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion1:
                return mpw_sitePasswordFromCrypt_v1( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion2:
                return mpw_sitePasswordFromCrypt_v2( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion3:
                return mpw_sitePasswordFromCrypt_v3( masterKey, siteKey, resultType, resultParam );
            default:
                err( "Unsupported version: %d", algorithmVersion );
                return NULL;
        }
    }
    else if (resultType & MPResultTypeClassDerive) {
        switch (algorithmVersion) {
            case MPAlgorithmVersion0:
                return mpw_sitePasswordFromDerive_v0( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion1:
                return mpw_sitePasswordFromDerive_v1( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion2:
                return mpw_sitePasswordFromDerive_v2( masterKey, siteKey, resultType, resultParam );
            case MPAlgorithmVersion3:
                return mpw_sitePasswordFromDerive_v3( masterKey, siteKey, resultType, resultParam );
            default:
                err( "Unsupported version: %d", algorithmVersion );
                return NULL;
        }
    }
    else {
        err( "Unsupported password type: %d", resultType );
    }

    return sitePassword;
}
Пример #25
0
void
ForkJoinNursery::pjsCollection(int op)
{
    JS_ASSERT((op & Collect) != (op & Evacuate));

    bool evacuate = op & Evacuate;
    bool recreate = op & Recreate;

    JS_ASSERT(!isEvacuating_);
    JS_ASSERT(!evacuationZone_);
    JS_ASSERT(!head_);
    JS_ASSERT(tail_ == &head_);

    JSRuntime *const rt = shared_->runtime();
    const unsigned currentNumActiveChunks_ = numActiveChunks_;
    const char *msg = "";

    JS_ASSERT(!rt->needsBarrier());

    TIME_START(pjsCollection);

    rt->incFJMinorCollecting();
    if (evacuate) {
        isEvacuating_ = true;
        evacuationZone_ = shared_->zone();
    }

    flip();
    if (recreate) {
        initNewspace();
        // newspace must be at least as large as fromSpace
        numActiveChunks_ = currentNumActiveChunks_;
    }
    ForkJoinNurseryCollectionTracer trc(rt, this);
    forwardFromRoots(&trc);
    collectToFixedPoint(&trc);
#ifdef JS_ION
    jit::UpdateJitActivationsForMinorGC(TlsPerThreadData.get(), &trc);
#endif
    freeFromspace();

    size_t live = movedSize_;
    computeNurserySizeAfterGC(live, &msg);

    sweepHugeSlots();
    JS_ASSERT(hugeSlots[hugeSlotsFrom].empty());
    JS_ASSERT_IF(isEvacuating_, hugeSlots[hugeSlotsNew].empty());

    isEvacuating_ = false;
    evacuationZone_ = nullptr;
    head_ = nullptr;
    tail_ = &head_;
    movedSize_ = 0;

    rt->decFJMinorCollecting();

    TIME_END(pjsCollection);

    // Note, the spew is awk-friendly, non-underlined words serve as markers:
    //   FJGC _tag_ us _value_ copied _value_ size _value_ _message-word_ ...
    shared_->spewGC("FJGC %s us %5" PRId64 "  copied %7" PRIu64 "  size %" PRIu64 "  %s",
                    (evacuate ? "evacuate " : "collect  "),
                    TIME_TOTAL(pjsCollection),
                    (uint64_t)live,
                    (uint64_t)numActiveChunks_*1024*1024,
                    msg);
}