Ejemplo n.º 1
0
void 
MySQLLibrary::Init( )
{
    if ( ! m_initialized )
    {
        int initRslt = mysql_library_init( 0, 0, 0 );
        if ( initRslt != 0 )
        {
            string msg( "mysql_library_init returned " );
            msg += IntToString( initRslt );
            MySQLException exception( msg );
            throw exception;
        }
        m_initialized = true;
    }
}
Ejemplo n.º 2
0
void Iax2Sessions::ReportIax2New(Iax2NewInfoRef& invite)
{
	char szFromIax2Ip[16];
	std::map<CStdString, Iax2SessionRef>::iterator pair;

	ACE_OS::inet_ntop(AF_INET, (void*)&invite->m_senderIp, szFromIax2Ip, sizeof(szFromIax2Ip));
	CStdString IpAndCallNo = CStdString(szFromIax2Ip) + "," + invite->m_callNo;

	pair = m_bySrcIpAndCallNo.find(IpAndCallNo);
	if (pair != m_bySrcIpAndCallNo.end()) {
		// The session already exists, check the state
		CStdString logmsg;

		Iax2SessionRef session = pair->second;

		if(session.get() != NULL) {
			if(session->m_iax2_state == IAX2_STATE_UP) {
				CStdString log_msg;

				log_msg.Format("[%s] is in the UP state but we've "
					"got another NEW from this same IP %s and same "
					"source call number %s", session->m_trackingId,
					szFromIax2Ip, invite->m_callNo);
	
				LOG4CXX_ERROR(m_log, log_msg);
				return;
			}
		}

		/* Stop this session and proceed */
		Stop(session);
	}

	/* Create a new session */
	CStdString trackingId = m_alphaCounter.GetNext();
	Iax2SessionRef session(new Iax2Session(trackingId));
	session->m_srcIpAndCallNo = IpAndCallNo;
	session->ReportIax2New(invite);
	m_bySrcIpAndCallNo.insert(std::make_pair(session->m_srcIpAndCallNo, session));

	CStdString numSessions = IntToString(m_bySrcIpAndCallNo.size());
	LOG4CXX_DEBUG(m_log, CStdString("BySrcIpAndCallNo: ") + numSessions);

	CStdString inviteString;
	invite->ToString(inviteString);
	LOG4CXX_INFO(m_log, "[" + trackingId + "] created by IAX2 NEW:" + inviteString + " for " + session->m_srcIpAndCallNo);
}
Ejemplo n.º 3
0
void Msg_SQ::Parser()
{

   Server* ServerPtr = Network::Interface.FindServerByName(Parameters[0]);

   if (NULL == ServerPtr)
   {
   	debug << "Error: Trying to SQ server " << Parameters[0] << ". Server doesn't exist in db." << endb;
   	return;
   }

   if (Parameters[1] == IntToString(ServerPtr->GetLinkTime()) || Parameters[1] == "0")
   {
   	if (!Network::Interface.DelServerByNumeric(ServerPtr->GetNumeric()))
   	   debug << "Could not delete server " << Parameters[0] << endb;
   }
}
Ejemplo n.º 4
0
// 输出http协议头部
int Page_Download::OutHead()
{
    FUNCTION_TRACK(); // 函数轨迹跟综

    Connect * const connect = m_request->GetConnect();
    string filename = m_request->GetField("file");
    string fullpath = "";


    /*
     * 打开用户文件,如:
     *  http://192.168.1.100:17890/download?file=logo.gif
     */
    const string &username = m_request->GetCurrentUser();
    const string &key = GetCurrentKey();
    User *user = User::Get( username );
    fullpath = user->AttachDir() + key + "." + filename;

    LOG_DEBUG("file=[%s]", fullpath.c_str());

    if( "" == filename || !m_file.Open(fullpath) )
    {
        Page::OutHead();

        const string str = HtmlAlert("没有文件: " + filename + ",可能文件已被删除。");
        LOG_ERROR("Can't open file: [%s]", fullpath.c_str());
        // 发送到浏览器
        connect->Send(str);
        return ERR;
    }

    const string &size = IntToString(m_file.Size());

    // 文件下载头部格式
    const string html = ""
                        "HTTP/1.1 200 OK\n"
                        "Accept-Ranges: bytes\n"
                        "Content-Disposition: attachment; filename=\"" + FilenameDecode(filename) + "\"\n"
                        "Content-length: " + size + "\n"
                        "Connection: Keep-Alive\n"
                        "Content-Type: application/ms-excel\n"
                        "\n";

    // 发送
    return connect->Send(html) == html.length() ? OK : ERR;
}
Ejemplo n.º 5
0
bool IsDirectoryWritable(std::string directory) {
    int rand = random(0, 1000000);
    std::string tempFile = directory.append("\\phpdesktop")\
            .append(IntToString(rand)).append(".tmp");
    HANDLE handle = CreateFile(Utf8ToWide(tempFile).c_str(), 
            GENERIC_WRITE,
            (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE),
            NULL, OPEN_ALWAYS, 
            (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE),
            NULL);
    if (handle == INVALID_HANDLE_VALUE) {
        return false;
    } else {
        CloseHandle(handle);
        return true;
    }    
}
Ejemplo n.º 6
0
AString CInArchive::ReadStringA(UInt32 pos) const
{
  AString s;
  if (pos >= _size)
    return IntToString((Int32)pos);
  UInt32 offset = GetOffset() + _stringsPos + pos;
  for (;;)
  {
    if (offset >= _size)
      break; // throw 1;
    char c = _data[offset++];
    if (c == 0)
      break;
    s += c;
  }
  return s;
}
Ejemplo n.º 7
0
void Iax2Session::Start()
{
	CaptureEventRef startEvent(new CaptureEvent);

	m_started = true;
	time(&m_beginDate);
	GenerateOrkUid();
	startEvent->m_type = CaptureEvent::EtStart;
	startEvent->m_timestamp = m_beginDate;
	startEvent->m_value = m_trackingId;
	CStdString timestamp = IntToString(startEvent->m_timestamp);

	LOG4CXX_INFO(m_log,  "[" + m_trackingId + "] " + m_capturePort + " " +
			IAX2_PROTOCOL_STR + " Session start, timestamp:" + timestamp);

	g_captureEventCallBack(startEvent, m_capturePort);
}
Ejemplo n.º 8
0
DecodingResult TF_DecryptorBase::Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs &parameters) const
{
	if (ciphertextLength != FixedCiphertextLength())
	{
		char Name[128] = "";
		AlgorithmName(Name);
		throw InvalidArgument(std::string(Name) + ": ciphertext length of " + IntToString(ciphertextLength) + " doesn't match the required length of " + IntToString(FixedCiphertextLength()) + " for this key");
		//throw InvalidArgument(AlgorithmName() + ": ciphertext length of " + IntToString(ciphertextLength) + " doesn't match the required length of " + IntToString(FixedCiphertextLength()) + " for this key");
	}

	SecByteBlock paddedBlock(PaddedBlockByteLength());
	Integer x = GetTrapdoorFunctionInterface().CalculateInverse(rng, Integer(ciphertext, ciphertextLength));
	if (x.ByteCount() > paddedBlock.size())
		x = Integer::Zero();	// don't return false here to prevent timing attack
	x.Encode(paddedBlock, paddedBlock.size());
	return GetMessageEncodingInterface().Unpad(paddedBlock, PaddedBlockBitLength(), plaintext, parameters);
}
Ejemplo n.º 9
0
int32 SetPlotFlag(int32 plotIndex, int64 nPlotFlag, int32 nPlotValue)
{
	//update the actual Plot table in Party
	for (int32 j = 0; j < GetParty()->Plots[plotIndex].StatusList.Num(); j++)
	{
		if (GetParty()->Plots[plotIndex].StatusList[j].pNode.Flag == nPlotFlag)
		{
			GetParty()->Plots[plotIndex].StatusList[j].pValue = nPlotValue;
			return TRUE_;
		}
	}
#ifdef DEBUG
	LogError("SetPlotFlag: plot not found with flag " + IntToString(nPlotFlag));
#endif // DEBUG

	return FALSE_;
}
Ejemplo n.º 10
0
void Player::NextMap(){
	//次のマップ名をstringで作成
	string str=map_name_;
	str.insert(8,"-");
	str.insert(9,(IntToString(next_map_count_)));

	//char型に変換
	 int len = str.length();
	char* c = new char[len+1];
	memcpy(c, str.c_str(), len+1);
	next_map_=c;


	next_map_flag_ = true;
	next_map_count_++;
	
}
Ejemplo n.º 11
0
bool Socket::connect(std::string url, int port, bool throwError, size_t MaxTries)
{
  try {
    if(isalpha(url[0]))
      url = SocketSystem().getIpFromName(url);
  }
  catch(...)
  {
    if(throwError)
      throw std::exception(ss_.GetLastMsg(true).c_str());
    return false;
  }
  SOCKADDR_IN tcpAddr;
  tcpAddr.sin_family = AF_INET;
  tcpAddr.sin_addr.s_addr = inet_addr(url.c_str());
  tcpAddr.sin_port = htons(port);
  if(s_ == INVALID_SOCKET)
  {
    s_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  }
  size_t tryCount = 0;
  std::string countStr;
  while(true)
  {
    ++tryCount;
    TRACE("attempt to connect #" + IntToString(tryCount));
    int err = ::connect(s_, (sockaddr*)&tcpAddr, sizeof(tcpAddr));
     //std::string rip = System().getRemoteIP(this);
    int rport = System().getRemotePort(this);

    // error return from connect does not appear to be reliable
  
    if(err != SOCKET_ERROR && rport != -1)
      break;
    if(tryCount >= MaxTries)
    {
      if(throwError)
        throw std::exception(ss_.GetLastMsg(true).c_str());
      return false;
    }
    ::Sleep(100);
  }
  
  TRACE("I believe we are connected to " + url);
  return true;
}
Ejemplo n.º 12
0
void NetworkSession::UpdateIncomingInOrderTrafficForConn(NetConnection* conn, NetMessages& incomingMessages, NetSender* netSenderForPacket) {
	if (conn) {
		//pop messages off the order list
		while (conn->m_incomingOrderedReliables.size() > 0) {
			NetMessage orderedMsg = (NetMessage)conn->m_incomingOrderedReliables.top();
			incomingMessages.push_back(orderedMsg);
			conn->m_incomingOrderedReliables.pop();
		}

		//add the msgs to the in order list
		for (NetMessagesIterator it = incomingMessages.begin(); it != incomingMessages.end(); ) {
			NetMessage& msg = (*it);
			if (msg.IsInOrder()) {
				std::string inOrderDebugString;
				inOrderDebugString += "conn: " + conn->GetName();

				inOrderDebugString += "nextIncomingOrderID: " + IntToString(conn->m_nextIncomingOrderID);

				//if match, process as normal and increment orderID
				if (msg.GetOrderID() == conn->m_nextIncomingOrderID) {
					
					conn->m_nextIncomingOrderID++;
					if (conn->m_nextIncomingOrderID > BIT(16)) {
						conn->m_nextIncomingOrderID = 0;
					}
					
					ProcessMessage(netSenderForPacket, msg);
					it = incomingMessages.erase(it);
					continue;
				}
				else {
					//save it off to process later
					conn->m_incomingOrderedReliables.push(msg);

					it = incomingMessages.erase(it);
				}//end of inner if/else

			}//end of if
			else {
				++it;
			}
		}//end of for

	}
}
Ejemplo n.º 13
0
void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char *displayName=NULLPTR, const NameValuePairs &params = g_nullNameValuePairs)
{
	std::string name(factoryName ? factoryName : "");
	member_ptr<T_FactoryOutput> obj(ObjectFactoryRegistry<T_FactoryOutput>::Registry().CreateObject(name.c_str()));

	if (!keyLength)
		keyLength = obj->DefaultKeyLength();

	if (displayName)
		name = displayName;
	else if (keyLength)
		name += " (" + IntToString(keyLength * 8) + "-bit key)";

	const int blockSize = params.GetIntValueWithDefault(Name::BlockSize(), 0);
	obj->SetKey(defaultKey, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), ConstByteArrayParameter(defaultKey, blockSize ? blockSize : obj->IVSize()), false)));
	BenchMark(name.c_str(), *static_cast<T_Interface *>(obj.get()), g_allocatedTime);
	BenchMarkKeying(*obj, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), ConstByteArrayParameter(defaultKey, blockSize ? blockSize : obj->IVSize()), false)));
}
Ejemplo n.º 14
0
bool IsRunningInGDB() {
	#ifndef _WIN32
	char buf[1024];

	std::string fname = "/proc/" + IntToString(getppid(), "%d") + "/cmdline";
	std::ifstream f(fname.c_str());

	if (!f.good())
		return false;

	f.read(buf, sizeof(buf));
	f.close();

	return (strstr(buf, "gdb") != NULL);
	#else
	return false;
	#endif
}
Ejemplo n.º 15
0
void TF_EncryptorBase::Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs &parameters) const
{
	if (plaintextLength > FixedMaxPlaintextLength())
	{
		char Name[128] = "";
		AlgorithmName(Name);
		if (FixedMaxPlaintextLength() < 1)
			throw InvalidArgument(std::string(Name) + ": this key is too short to encrypt any messages");
			//throw InvalidArgument(AlgorithmName() + ": this key is too short to encrypt any messages");
		else
			throw InvalidArgument(std::string(Name) + ": message length of " + IntToString(plaintextLength) + " exceeds the maximum of " + IntToString(FixedMaxPlaintextLength()) + " for this public key");
			//throw InvalidArgument(AlgorithmName() + ": message length of " + IntToString(plaintextLength) + " exceeds the maximum of " + IntToString(FixedMaxPlaintextLength()) + " for this public key");
	}

	SecByteBlock paddedBlock(PaddedBlockByteLength());
	GetMessageEncodingInterface().Pad(rng, plaintext, plaintextLength, paddedBlock, PaddedBlockBitLength(), parameters);
	GetTrapdoorFunctionInterface().ApplyRandomizedFunction(rng, Integer(paddedBlock, paddedBlock.size())).Encode(ciphertext, FixedCiphertextLength());
}
void
ShowTypeOids( SQLDatabase * pDB )
{
    const string typeNames[]
            = { //integer
                "smallint", "integer", "serial", 
                //long int
                "bigint", "bigserial",
                //real
                "real", "double precision", "decimal", "numeric",
                //text
                "text", "char(10)", "varchar(100)",
                //blob
                "bytea",
                //date
                "date",
                //time
                "time",
                //datetime
                "timestamp"
            };

    string command = "CREATE TABLE Types ( ";
    for ( int i = 0; i < ARRAYSIZE( typeNames ); ++i )
    {
        if ( i != 0 )
            command += ", ";
        command += "f" + IntToString( i ) + " " + typeNames[i];
    }
    command += " )";
    pDB->DoCommand( command );

    string query = "SELECT * FROM Types";
    SQLResult * result = pDB->DoQuery( query );

    cout << endl << "Type Oids:" << endl;
    for ( int i = 0; i < ARRAYSIZE( typeNames ); ++i )
    {
        cout << typeNames[i] << ": ";
        //Relies on FieldType displaying the Oid for this purpose.
        result->FieldType( i );
    }
    cout << endl;
}
Ejemplo n.º 17
0
bool TDogUnit::ReadDogSN(long * Info)
{
	long CurrentNo;
	pmhp->Command = 5;

	iRetValue = MHDog(pmhp);
	CurrentNo = *(long *)pmhp->DogData;

	if ( iRetValue != 0 )
	{
		LOG4CXX_ERROR(LOG.rootLog, ("GetCurrentNo function return code is " + IntToString(iRetValue)).c_str());
		return false;
	}
	else
	{
		*Info = CurrentNo;
		return true;
	}
}
Ejemplo n.º 18
0
void CBaseObject::ValidateInitCalled(void)
{
	CChars	szObject;

	if (miPreInits != miPostInits)
	{
		szObject.Init();
		PrintObject(&szObject, IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} has pre-inits [", IntToString(miPreInits), "] not equal to post inits [", IntToString(miPostInits), "].", NULL);
		szObject.Kill();
	}
	else if (miPreInits == 0)
	{
		szObject.Init();
		PrintObject(&szObject, IsEmbedded());
		gcLogger.Error2(__METHOD__, " Object {", szObject.Text(), "} has a pre-init of zero.", NULL);
		szObject.Kill();
	}
}
Ejemplo n.º 19
0
void CObject::SetPointedTosDistToRoot(int iDistToRoot)
{
	int				i;
	CBaseObject*	pcPointedTo;
	CPointer**		ppPointer;
	int				iNumPointers;
	CBaseObject*	pcContainer;

	if (iDistToRoot >= ROOT_DIST_TO_ROOT)
	{
		iNumPointers = mapPointers.NumElements();

		for (i = 0; i < iNumPointers; i++)
		{
			ppPointer = mapPointers.Get(i);
			pcPointedTo = (**ppPointer).BaseObject();
			if (pcPointedTo)
			{
				pcContainer = pcPointedTo->GetEmbeddingContainer();
				pcContainer->SetExpectedDistToRoot(iDistToRoot + 1);
			}
		}
	}
	else if (iDistToRoot == UNATTACHED_DIST_TO_ROOT)
	{
		iNumPointers = mapPointers.NumElements();

		for (i = 0; i < iNumPointers; i++)
		{
			ppPointer = mapPointers.Get(i);
			pcPointedTo = (**ppPointer).BaseObject();
			if (pcPointedTo)
			{
				pcContainer = pcPointedTo->GetEmbeddingContainer();
				pcContainer->SetCalculatedDistToRoot();
			}
		}
	}
	else
	{
		gcLogger.Error2(__METHOD__, "Don't know how to set dist to root to [", IntToString(iDistToRoot), "].", NULL);
	}
}
Ejemplo n.º 20
0
string Area::get_directory() {
  string filename = (*this).conference_path + "/data/paths.dat";
  ifstream is(filename.c_str(), ios::in);
    
  if(is.fail()) {
    throw runtime_error("Cannot read " + filename);
  }
    
  char buf[256];
  for(int i = 1; i <= (*this).directory; ++i) {
    is.getline(buf, 256);
     
    if(is.fail() || is.eof()) {
      throw runtime_error("Cannot find dir for " + (*this).conference_path + " " + IntToString(i));
    }
  }
  
  return buf;
}
Ejemplo n.º 21
0
void Shape::collectOrb(PhysicsActor* orb) {
  String orb_name = orb->GetName();
  sysLog.Log("Collected Orb: " + orb_name);
  _inventory->add_orb();

  int num_orbs = _inventory->total_orbs();

  String s = "Total orbs: " + IntToString(num_orbs);
  sysLog.Log(s);

  theSound.PlaySound(_orbSound, 1.0f);

  if (num_orbs == 6) {
    TextActor* t = new TextActor("Console", "You beat the game!", TXT_Center);
    Vector2 blocky_pos = GetPosition();
    t->SetPosition(blocky_pos.X, blocky_pos.Y + 5.0f);
    theWorld.Add(t, 2);
  }
}
Ejemplo n.º 22
0
void SQDbgServer::RemoveBreakpoint(BreakPoint &bp)
{
	BreakPointSetItor itor=_breakpoints.find(bp);
	if(itor==_breakpoints.end()){
		BeginDocument();
			BeginElement(_SC("break"));
				Attribute(_SC("desc"),_SC("the breakpoint doesn't exists"));
			EndElement(_SC("break"));
		EndDocument();
	}
	else{
		BeginDocument();
			BeginElement(_SC("removebreakpoint"));
				Attribute(_SC("line"),IntToString(bp._line));
				Attribute(_SC("src"),bp._src.c_str());
			EndElement(_SC("removebreakpoint"));
		EndDocument();
		_breakpoints.erase(itor);
	}
}
Ejemplo n.º 23
0
Reply Reply::StockReply(Reply::status_type status)
{
    Reply rep;
    rep.status = status;
    rep.content.clear();

    const std::string status_string = rep.ToString(status);
    rep.content.insert(rep.content.end(), status_string.begin(), status_string.end());
    rep.headers.resize(3);
    rep.headers[0].name = "Access-Control-Allow-Origin";
    rep.headers[0].value = "*";
    rep.headers[1].name = "Content-Length";

    std::string size_string = IntToString(rep.content.size());

    rep.headers[1].value = size_string;
    rep.headers[2].name = "Content-Type";
    rep.headers[2].value = "text/html";
    return rep;
}
Ejemplo n.º 24
0
 string ConcreteValueBase::ToSimpleString() const
 {
     ostringstream sstr;
     if(Type == NULL) {
         sstr << "Undefined";
         return sstr.str();
     }
     switch(Type->GetBaseType()) {
     case BaseTypeBool:
         return BoolToString(true);
     case BaseTypeInt:
         return IntToString(true);
     case BaseTypeEnum:
         return EnumTypeToString(true);
     case BaseTypeBitVector:
         return BVToString(true);
     default:
         return "(Undefined: due to weird type)";
     }
 }
Ejemplo n.º 25
0
void NetworkSession::StartHost(const std::string& connPortService, const Byte& numConnections) {
	
	//add connection to self at index 0

	//RemoveConnection(m_netAddress, 0xff);

	m_connSelf = AddConnectionToSelf(0, connPortService);
	m_connSelf->SetConnIndex(0);


	m_currentJoinableConnIndex = 0;
	m_joinable = true;
	m_maxConnections = numConnections;

	std::string hostDebugString;
	hostDebugString += "\nHosting on port: " + connPortService + "|  Max Conns: " + IntToString(numConnections);

	ConsolePrintString(hostDebugString);
	OUTPUT_STRING_TO_CONSOLE(hostDebugString, 1000);

}
Ejemplo n.º 26
0
void CMusikPrefs::SavePrefs()
{
	UnparseColors();

	// main dialog
	config->SetValue( "Dialog", "Dialog Size", CSizeToString( m_Dlg_Size ) );
	config->SetValue( "Dialog", "Dialog Position", CPointToString( m_Dlg_Pos ) );
	config->SetValue( "Dialog", "Maximized", BoolToString( m_Dlg_Maximized ) );
	config->SetValue( "Dialog", "Reset UI", BoolToString( m_Dlg_ResetUI ) );

	// selection area
	config->SetValue( "Selection Area", "Count", IntToString( (int)m_SelectionBox_Count ) );

	// playlist
	config->SetValue( "Playlist", "Column Order", CIntArrayToString( m_Playlist_Order ) );
	config->SetValue( "Playlist", "Column Sizes", CIntArrayToString( m_Playlist_Sizes ) );

	// now playing
	config->SetValue( "Now Playing", "Caption Font Size", IntToString( m_NowPlaying_CaptionFont ) );

	// player
	config->SetValue( "Player", "Driver", IntToString( m_Player_Driver ) );
	config->SetValue( "Player", "Device", IntToString( m_Player_Device ) );
	config->SetValue( "Player", "Rate", IntToString( m_Player_Rate ) );
	config->SetValue( "Player", "Maximum Channels", IntToString( m_Player_Max_Channels ) );

	// crossfader
	config->SetValue( "Crossfader", "Enabled", BoolToString( m_Crossfader_Enabled ) );
	config->SetValue( "Crossfader", "Set Name", m_Crossfader_Current );	
	config->SetValue( "Crossfader", "Values", CrossfaderToString( m_Crossfader_Default ) );

	// dialog colors
	config->SetValue( "Dialog Colors", "Active Caption", COLORREFToString( MUSIK_COLOR_ACTIVECAPTION ) );
	config->SetValue( "Dialog Colors", "Active Caption Text", COLORREFToString( MUSIK_COLOR_CAPTIONTEXT ) );
	config->SetValue( "Dialog Colors", "Inactive Caption", COLORREFToString( MUSIK_COLOR_INACTIVECAPTION ) );
	config->SetValue( "Dialog Colors", "Inactive Caption Text", COLORREFToString( MUSIK_COLOR_INACTIVECAPTIONTEXT ) );
	config->SetValue( "Dialog Colors", "Button Face", COLORREFToString( MUSIK_COLOR_BTNFACE ) );
	config->SetValue( "Dialog Colors", "Button Text", COLORREFToString( MUSIK_COLOR_BTNTEXT ) );
	config->SetValue( "Dialog Colors", "Button Highlight", COLORREFToString( MUSIK_COLOR_BTNHILIGHT ) );
	config->SetValue( "Dialog Colors", "Button Shadow", COLORREFToString( MUSIK_COLOR_BTNSHADOW ) );
	config->SetValue( "Dialog Colors", "List Background", COLORREFToString( MUSIK_COLOR_LISTCTRL ) );
	config->SetValue( "Dialog Colors", "List Text", COLORREFToString( MUSIK_COLOR_LISTCTRLTEXT ) );
	config->SetValue( "Dialog Colors", "Color Highlight", COLORREFToString( MUSIK_COLOR_HIGHLIGHT ) );
	config->SetValue( "Dialog Colors", "Color Highlight Text", COLORREFToString( MUSIK_COLOR_HIGHLIGHTTEXT ) );

	// write to ini file
	config->WriteFile();
}
Ejemplo n.º 27
0
void WaitObjectContainer::DetectNoWait(LastResultType result, CallStack const& callStack)
{
	if (result == m_lastResult && m_noWaitTimer.ElapsedTime() > 1000)
	{
		if (m_sameResultCount > m_noWaitTimer.ElapsedTime())
		{
			if (m_tracer)
			{
				std::string desc = "No wait loop detected - m_lastResult: ";
				desc.append(IntToString(m_lastResult)).append(", call stack:");
				for (CallStack const* cs = &callStack; cs; cs = cs->Prev())
					desc.append("\n- ").append(cs->Format());
				m_tracer->TraceNoWaitLoop(desc);
			}
			try { throw 0; } catch (...) {}		// help debugger break
		}

		m_noWaitTimer.StartTimer();
		m_sameResultCount = 0;
	}
}
Ejemplo n.º 28
0
CCArray* GlobalData::getCardProfile(int group)
{
	arrayCardProfile = CCArray::create();

	sqlite3 *pDB = NULL;
	char* errMsg = NULL;
	

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	std::string dbPath = getWritablePath();
#else
	std::string dbPath = CCFileUtils::sharedFileUtils()->fullPathForFilename("card.s3db");
#endif

	int result = sqlite3_open_v2(dbPath.c_str(),&pDB,SQLITE_OPEN_READONLY, NULL);
	if (result!=SQLITE_OK) {
		CCLOG("status=================:%d ",result);
		return arrayCardProfile;
	} else {
		CCLOG("status=================:%d ",result);
	}

	std::string szSql = "select * from card";
	if (group>=0)
	{
		szSql.append(" where game_group_id = ");
		szSql.append(IntToString(group));
	}

	const char *argc = QUERY_CATEGORY_CARDBYGROUP;
	result = sqlite3_exec(pDB,szSql.c_str(), sqliteExecCallBack, (void *)argc, &errMsg);
	if (result!=SQLITE_OK) {
		CCLOG("status=================:%d ",result);
		return arrayCardProfile;
	} else {
		CCLOG("status=================:%d ",result);
	}

	return arrayCardProfile;
}
Ejemplo n.º 29
0
static void Info(win* Win,node* Node,winunit* y,int Name)
{
	int No;
	datadef DataDef;

	if (Name)
		WinPropLabel(Win,y,LangStr(MEDIAINFO_ID,Name),LangStr(Node->Class,NODE_NAME));

	for (No=0;NodeEnum(Node,No,&DataDef)==ERR_NONE;++No)
		if (!(DataDef.Flags & (DF_OUTPUT|DF_HIDDEN)))
		{
			tchar_t s[256];
			tick_t Tick;
			int i;
			bool_t Ok = 0;

			switch (DataDef.Type)
			{
			case TYPE_TICK:
				Ok = Node->Get(Node,DataDef.No,&Tick,sizeof(Tick))==ERR_NONE;
				TickToString(s,TSIZEOF(s),Tick,0,1,0);
				break;

			case TYPE_INT:
				Ok = Node->Get(Node,DataDef.No,&i,sizeof(i))==ERR_NONE;
				IntToString(s,TSIZEOF(s),i,(DataDef.Flags & DF_HEX)!=0);
				if (DataDef.Flags & DF_KBYTE)
					tcscat_s(s,TSIZEOF(s),T(" KB"));
				break;

			case TYPE_STRING:
				Ok = Node->Get(Node,DataDef.No,s,sizeof(s))==ERR_NONE;
				break;					
			}

			if (Ok)
				WinPropLabel(Win,y,DataDef.Name,s);
		}
}
Ejemplo n.º 30
0
void ClientSetup::LoadFromStartScript(const std::string& setup)
{
	TdfParser file(setup.c_str(), setup.length());

	if (!file.SectionExist("GAME")) {
		throw content_error("GAME-section does not exist in script.txt");
	}

	// Technical parameters
	file.GetDef(hostIP,       hostIP, "GAME\\HostIP");
	file.GetDef(hostPort,     IntToString(hostPort), "GAME\\HostPort");

	file.GetDef(myPlayerName, "", "GAME\\MyPlayerName");
	file.GetDef(myPasswd,     "", "GAME\\MyPasswd");

	if (!file.GetValue(isHost, "GAME\\IsHost")) {
		LOG_L(L_WARNING, "script.txt is missing the IsHost-entry. Assuming this is a client.");
	}
#ifdef DEDICATED
	if (!isHost) {
		handleerror(NULL, "Error: Dedicated server needs to be host, but the start script does not have \"IsHost=1\".", "Start script error", MBF_OK|MBF_EXCL);
	}
#endif

	//FIXME WTF
	std::string sourceport, autohostip, autohostport;
	if (file.SGetValue(sourceport, "GAME\\SourcePort")) {
		configHandler->SetString("SourcePort", sourceport, true);
	}
	if (file.SGetValue(autohostip, "GAME\\AutohostIP")) {
		configHandler->SetString("AutohostIP", autohostip, true);
	}
	if (file.SGetValue(autohostport, "GAME\\AutohostPort")) {
		configHandler->SetString("AutohostPort", autohostport, true);
	}

	file.GetDef(saveFile, "", "GAME\\SaveFile");
	file.GetDef(demoFile, "", "GAME\\DemoFile");
}