extern "C" CK_DECLARE_FUNCTION(CK_RV,C_WrapKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hWrappingKey, CK_OBJECT_HANDLE hKey, CK_BYTE_PTR pWrappedKey, CK_ULONG_PTR pulWrappedKeyLen))
{
  _log("RETURNING CKR_FUNCTION_NOT_SUPPORTED");
	return CKR_FUNCTION_NOT_SUPPORTED;
}
Example #2
0
int bartlby_extension_shutdown(int scheduler_end_code) {
	_log(LH_MOD, B_LOG_INFO, "helloworld: scheduler ended with %d", scheduler_end_code);
	
	return EXTENSION_OK;
}
static void certDeallocate(NPObject *obj) {
    _log("");
    delete (CertInstance*)obj;
}
Example #4
0
void NPCAIMgr::Process() {
    if(!m_processTimer.Check())
        return;

    // Test to see if we have a Shield Booster
    if( m_shieldBoosterTimer.Enabled() )
    {
        // It's time to recharge?
        if( m_shieldBoosterTimer.Check() )
        {
            m_npc->UseShieldRecharge();
        }
    }
    // Test to see if we have an Armor Repair
    if( m_armorRepairTimer.Enabled() )
    {
        // It's time to recharge?
        if( m_armorRepairTimer.Check() )
        {
            m_npc->UseArmorRepairer();
        }
    }

    switch(m_state) {
    case Idle:
        //TODO: wander around?
        //TODO: look around for shit to shoot at?
        //         The parameter proximityRange tells us how far we "see"
        break;

    case Chasing: {
        //NOTE: getting our target like this is pretty weak...
        SystemEntity *target = m_npc->targets.GetFirstTarget(false);
        if(target == NULL) {
            //no valid target...
            if(m_npc->targets.HasNoTargets()) {
                _log(NPC__AI_TRACE, "[%u] Stopped chasing, no targets remain.", m_npc->GetID());
                m_state = Idle;
                return;
            }
            //else, still locking or something.
            return;
        }

        if(m_npc->DistanceTo2(target) < m_entityAttackRange2.get_float()) {
            //we caught up... off to follow mode. Should orbit, but that
            //isnt working yet.
            _log(NPC__AI_TRACE, "[%u] Was chasing %u, but they are close enough now. Following.", m_npc->GetID(), target->GetID());
            _EnterFollowing(target);
            return;
        }

        //else, we continue chasing... should we shoot?
        CheckAttacks(target);
    } break;

    case Following: {
        //NOTE: getting our target like this is pretty weak...
        SystemEntity *target = m_npc->targets.GetFirstTarget(false);
        if(target == NULL) {
            //no valid target...
            if(m_npc->targets.HasNoTargets()) {
                _log(NPC__AI_TRACE, "[%u] Stopped chasing, no targets remain.", m_npc->GetID());
                m_state = Idle;
                return;
            }
            //else, still locking or something.
            return;
        }

        if(m_npc->DistanceTo2(target) > m_entityChaseMaxDistance2.get_float()) {
            //they are too far away now...
            _log(NPC__AI_TRACE, "[%u] Was chasing with %u, but they are too far away now. Chasing.", m_npc->GetID(), target->GetID());
            _EnterChasing(target);
            return;
        }

        //ok, we are close enough...
        CheckAttacks(target);
    } break;

    case Engaged: {
        //NOTE: getting our target like this is pretty weak...
        SystemEntity *target = m_npc->targets.GetFirstTarget(false);
        if(target == NULL) {
            //no valid target...
            if(m_npc->targets.HasNoTargets()) {
                _log(NPC__AI_TRACE, "[%u] Stopped chasing, no targets remain.", m_npc->GetID());
                _EnterIdle();
                return;
            }
            //else, still locking or something.
            return;
        }

        if(m_npc->DistanceTo2(target) > m_entityAttackRange2.get_float()) {
            //they are too far away now...
            _log(NPC__AI_TRACE, "[%u] Was engaged with %u, but they are too far away now. Following.", m_npc->GetID(), target->GetID());
            _EnterFollowing(target);
            return;
        }

        //ok, we are close enough...
        CheckAttacks(target);
    } break;
    //no default on purpose
    }
}
Example #5
0
File: cmd.cpp Project: ATNoG/ODiMM
void cmd::mp_send_handler(const boost::system::error_code& ec)
{
	if (ec && ec != boost::system::errc::make_error_condition(boost::system::errc::operation_canceled))
		_log(0, "PBA sender error: ", ec.message());
}
Example #6
0
bool BaseGuildManager::LoadGuilds() {

	ClearGuilds();

	if(m_db == nullptr) {
		_log(GUILDS__DB, "Requested to load guilds when we have no database object.");
		return(false);
	}

	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;
	std::map<uint32, GuildInfo *>::iterator res;

	// load up all the guilds
	if (!m_db->RunQuery(query, MakeAnyLenString(&query,
		"SELECT id, name, leader, minstatus, motd, motd_setter,channel,url FROM guilds"), errbuf, &result)) {
		_log(GUILDS__ERROR, "Error loading guilds '%s': %s", query, errbuf);
		safe_delete_array(query);
		return(false);
	}
	safe_delete_array(query);
	while ((row = mysql_fetch_row(result))) {
		_CreateGuild(atoi(row[0]), row[1], atoi(row[2]), atoi(row[3]), row[4], row[5], row[6], row[7]);
	}
	mysql_free_result(result);

	//load up the rank info for each guild.
	if (!m_db->RunQuery(query, MakeAnyLenString(&query,
		"SELECT guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace FROM guild_ranks"), errbuf, &result)) {
		_log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query, errbuf);
		safe_delete_array(query);
		return(false);
	}
	safe_delete_array(query);
	while ((row = mysql_fetch_row(result))) {
		uint32 guild_id = atoi(row[0]);
		uint8 rankn = atoi(row[1]);
		if(rankn > GUILD_MAX_RANK) {
			_log(GUILDS__ERROR, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
			continue;
		}

		res = m_guilds.find(guild_id);
		if(res == m_guilds.end()) {
			_log(GUILDS__ERROR, "Found rank %d for non-existent guild %d, skipping.", rankn, guild_id);
			continue;
		}

		RankInfo &rank = res->second->ranks[rankn];

		rank.name = row[2];
		rank.permissions[GUILD_HEAR] = (row[3][0] == '1')?true:false;
		rank.permissions[GUILD_SPEAK] = (row[4][0] == '1')?true:false;
		rank.permissions[GUILD_INVITE] = (row[5][0] == '1')?true:false;
		rank.permissions[GUILD_REMOVE] = (row[6][0] == '1')?true:false;
		rank.permissions[GUILD_PROMOTE] = (row[7][0] == '1')?true:false;
		rank.permissions[GUILD_DEMOTE] = (row[8][0] == '1')?true:false;
		rank.permissions[GUILD_MOTD] = (row[9][0] == '1')?true:false;
		rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1')?true:false;
	}
	mysql_free_result(result);

	return(true);
}
Example #7
0
void Character::SaveBoosters() const
{
	_log( ITEM__TRACE, "Saving Boosters of character %u", itemID() );

	m_factory.db().SaveBoosters( itemID(), m_boosters );
}
Example #8
0
/**
 * Create  a timer object.
 *     This service may panic if err parameter is null and:
 *         callback parameter is null, or
 *         no timer is available.
 *
 * Authorized execution levels:  task, fiber, ISR
 *
 * @param callback: pointer to the function to be executed.
 * @param privData: pointer to data that shall be passed to the callback
 * @param delay: number of milliseconds between function executions
 * @param repeat: specifies if the timer shall be re-started after each execution of the callback
 * @param startup : specifies if the timer shall be start immediately
 * @param err (out): execution status:
 *         E_OS_OK : callback is programmed
 *         E_OS_ERR: no timer is available, or callback parameter is null
 *
 * @return Handler on the timer, NULL if the service fails (e.g. no available
 *         timer or callback is a null pointer).
 */
T_TIMER timer_create(T_ENTRY_POINT callback, void* privData, uint32_t delay, bool repeat, bool startup, OS_ERR_TYPE* err)
{
    T_TIMER_LIST_ELT* timer = NULL;
#ifdef CONFIG_NANOKERNEL /********************** NANO KERNEL SPECIFIC:  */
    if (delay> 0 && delay < NANO_TICK ) {
      delay= NANO_TICK;
    }
#endif
    /* check input parameters */
    if ((NULL != callback) && (OS_WAIT_FOREVER != delay))
    {
        /* delay should be set to 0 if startup flag is false
         * otherwise delay should be a positive value if startup flag is true */
        if (((0 < delay) && (true == startup)) || ((0 <= delay) && (false == startup)))
        {
            /* find and reserve a timer resource from g_TimerPool_elements */
            /* rem: timer points to an element from the global g_TimerPool_elements */
            timer = g_TimerPool_alloc();
            if (timer != NULL)
            {
                /* initialize timer descriptor */
                timer->desc.callback = callback;
                timer->desc.data = privData;
                timer->desc.delay =  CONVERT_MS_TO_TICKS ( delay );
                timer->desc.repeat = repeat;
                timer->desc.status = E_TIMER_READY;

                /* insert timer in the list of active timers */
                if (startup)
                {
                    timer->desc.expiration = _GET_TICK() + timer->desc.delay;
                    disable_scheduling();
                    add_timer(timer);
                    if ( g_CurrentTimerHead == timer )
                    {
                        /* new timer is the next to expire, unblock timer_task to assess the change */
                        signal_timer_task();
                    }
                    enable_scheduling();
                }

    #ifdef __DEBUG_OS_ABSTRACTION_TIMER
                _log ("\nINFO : timer_create : new timer will expire at %u (now = %u ) - addr = 0x%x",timer->desc.expiration,_GET_TICK(), (uint32) timer);
    #endif
                error_management (err, E_OS_OK);
            }
            else
            {
                /* all timers from the pool are already being used */
                error_management (err, E_OS_ERR_NO_MEMORY);
            }
        }
        else
        { /* delay and startup parameter are inconsistent */
            error_management (err, E_OS_ERR);
        }
    }
    else
    { /* callback == NULL or delay == 0 : at least one parameter is invalid */
        error_management (err, E_OS_ERR);
    }
    return ((T_TIMER) timer);
}
Example #9
0
/**
 * Main function of the timer task. This function is in charge of
 *    calling the callbacks associated with the timers.
 *
 *    This function is run in a high priority task on microkernel builds.
 *    This function is run in a high priority fiber on nanokernel builds.
 *    It implements an infinite loop that waits for any of the semaphores from
 *    g_TimerSem.
 *    When a semaphore is signaled, this function fetches the pointer to the
 *    associated callback in g_TimerDesc, then calls it.
 *
 * @param dummy1 not used (required by ZEPHYR API)
 * @param dummy2 not used (required by ZEPHYR API) *
 *
 */
void timer_task(int dummy1, int dummy2)
{
    uint32_t timeout;
    uint32_t now;

    UNUSED(dummy1);
    UNUSED(dummy2);

    timeout = OS_WAIT_FOREVER;

    while (1) /* the Timer task shall never stop */
    {
#ifdef CONFIG_MICROKERNEL /********************** MICRO KERNEL SPECIFIC:  */
        /* block until g_TimerSem is signaled or until the next timeout expires */
        (void) task_sem_take_wait_timeout(g_TimerSem, timeout);
#else
        if (NULL == g_CurrentTimerHead)
        {
            /* Start a background timer with max positive delay */
            nano_fiber_timer_start (&g_NanoTimer, 0x7FFFFFFF);
            /* wait until the next timer expires or one is added or removed */
            nano_fiber_timer_wait (&g_NanoTimer);
        }
#endif
        now = _GET_TICK();
        /* task is unblocked: check for expired timers */
        while (is_after_expiration (now, &(g_CurrentTimerHead->desc)))
        {
            execute_callback(g_CurrentTimerHead);
        }
        /* Compute timeout until the expiration of the next timer */
        if ( NULL != g_CurrentTimerHead )
        {
            now = _GET_TICK();
            /* In micro kernel context, timeout = 0 or timeout < 0 works.
             * In nano kernel context timeout must be a positive value.
            */
#ifdef CONFIG_NANOKERNEL
            if (g_CurrentTimerHead->desc.expiration > now)
            {
#endif
                timeout = g_CurrentTimerHead->desc.expiration - now;
                if (OS_WAIT_FOREVER == timeout)
                { /* cannot have timeout = OS_WAIT_FOREVER while there is
                    still at least one active timer */
                    timeout++;
                }
#ifdef CONFIG_NANOKERNEL
                nano_fiber_timer_start (&g_NanoTimer, timeout);
                /* wait until the next timer expires or one is added or removed */
                nano_fiber_timer_wait (&g_NanoTimer);
                /* nano_fiber_timer_wait will wait until "natural" timer
                * expiration, or until nano_fiber_timer_stop(&g_NanoTimer)
                * is called by the timer_callback or by timer_stop() */
            }
#endif
        }
#ifdef CONFIG_MICROKERNEL
        else
        {
            timeout = OS_WAIT_FOREVER;
        }
#endif

#ifdef __DEBUG_OS_ABSTRACTION_TIMER
        if (NULL != g_CurrentTimerHead )
            _log ("\nINFO : timer_task : now = %u, next timer expires at %u, timeout = %u", _GET_TICK() , g_CurrentTimerHead->desc.expiration, timeout );
        else
            _log ("\nINFO : timer_task : now = %u, no next timer, timeout = OS_WAIT_FOREVER", _GET_TICK() );
#endif

    } /* end while(1) */
}
Example #10
0
int main() {
	RegisterExecutablePlatform(ExePlatformQueryServ);
	set_exception_handler();

	Timer LFGuildExpireTimer(60000);

	Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect

	_log(QUERYSERV__INIT, "Starting EQEmu QueryServ.");

	if (!queryservconfig::LoadConfig()) {

		_log(QUERYSERV__INIT, "Loading server configuration failed.");

		return 1;
	}

	Config = queryservconfig::get();

	if(!load_log_settings(Config->LogSettingsFile.c_str()))
		_log(QUERYSERV__INIT, "Warning: Unable to read %s", Config->LogSettingsFile.c_str());
	else
		_log(QUERYSERV__INIT, "Log settings loaded from %s", Config->LogSettingsFile.c_str());

	WorldShortName = Config->ShortName;

	_log(QUERYSERV__INIT, "Connecting to MySQL...");

	if (!database.Connect(
		Config->QSDatabaseHost.c_str(),
		Config->QSDatabaseUsername.c_str(),
		Config->QSDatabasePassword.c_str(),
		Config->QSDatabaseDB.c_str(),
		Config->QSDatabasePort)) {
		_log(WORLD__INIT_ERR, "Cannot continue without a database connection.");
		return 1;
	}

	if (signal(SIGINT, CatchSignal) == SIG_ERR)	{
		_log(QUERYSERV__ERROR, "Could not set signal handler");
		return 1;
	}
	if (signal(SIGTERM, CatchSignal) == SIG_ERR)	{
		_log(QUERYSERV__ERROR, "Could not set signal handler");
		return 1;
	}

	worldserver = new WorldServer;

	worldserver->Connect();

	lfguildmanager.LoadDatabase();

	while(RunLoops) {

		Timer::SetCurrentTime();

		if(LFGuildExpireTimer.Check())
			lfguildmanager.ExpireEntries();

		if (InterserverTimer.Check()) {
			if (worldserver->TryReconnect() && (!worldserver->Connected()))
				worldserver->AsyncConnect();
		}
		worldserver->Process();

		timeout_manager.CheckTimeouts();

		Sleep(100);
	}
}
Example #11
0
bool ZoneServer::Process() {
	if (!tcpc->Connected())
		return false;
	if(ls_zboot.Check()){
		LSBootUpdate(GetZoneID(), true);
		ls_zboot.Disable();
	}
	ServerPacket *pack = 0;
	while((pack = tcpc->PopPacket())) {
		_hex(WORLD__ZONE_TRACE,pack->pBuffer,pack->size);
		if (!authenticated) {
			if (WorldConfig::get()->SharedKey.length() > 0) {
				if (pack->opcode == ServerOP_ZAAuth && pack->size == 16) {
					uint8 tmppass[16];
					MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass);
					if (memcmp(pack->pBuffer, tmppass, 16) == 0)
						authenticated = true;
					else {
						struct in_addr  in;
						in.s_addr = GetIP();
						zlog(WORLD__ZONE_ERR,"Zone authorization failed.");
						ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
						SendPacket(pack);
						delete pack;
						Disconnect();
						return false;
					}
				}
				else {
					struct in_addr  in;
					in.s_addr = GetIP();
					zlog(WORLD__ZONE_ERR,"Zone authorization failed.");
					ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
					SendPacket(pack);
					delete pack;
					Disconnect();
					return false;
				}
			}
			else
			{
				_log(WORLD__ZONE,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access.");
				authenticated = true;
			}
		}
		switch(pack->opcode) {
		case 0:
			break;
		case ServerOP_KeepAlive: {
			// ignore this
			break;
		}
		case ServerOP_ZAAuth: {
			break;
		}
		case ServerOP_LSZoneBoot:{
			if(pack->size==sizeof(ZoneBoot_Struct)){
				ZoneBoot_Struct* zbs= (ZoneBoot_Struct*)pack->pBuffer;
				SetCompile(zbs->compile_time);
			}
			break;
		}
		case ServerOP_GroupInvite: {
			if(pack->size != sizeof(GroupInvite_Struct))
				break;

			GroupInvite_Struct* gis = (GroupInvite_Struct*) pack->pBuffer;

			client_list.SendPacket(gis->invitee_name, pack);
			break;
		}
		case ServerOP_GroupFollow: {
			if(pack->size != sizeof(ServerGroupFollow_Struct))
				break;

			ServerGroupFollow_Struct *sgfs = (ServerGroupFollow_Struct *) pack->pBuffer;

			client_list.SendPacket(sgfs->gf.name1, pack);
			break;
		}
		case ServerOP_GroupFollowAck: {
			if(pack->size != sizeof(ServerGroupFollowAck_Struct))
				break;

			ServerGroupFollowAck_Struct *sgfas = (ServerGroupFollowAck_Struct *) pack->pBuffer;

			client_list.SendPacket(sgfas->Name, pack);
			break;
		}
		case ServerOP_GroupCancelInvite: {
			if(pack->size != sizeof(GroupCancel_Struct))
				break;

			GroupCancel_Struct *gcs = (GroupCancel_Struct *) pack->pBuffer;

			client_list.SendPacket(gcs->name1, pack);
			break;
		}
		case ServerOP_GroupIDReq: {
			SendGroupIDs();
			break;
		}
		case ServerOP_GroupLeave: {
			if(pack->size != sizeof(ServerGroupLeave_Struct))
				break;
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_GroupJoin: {
			if(pack->size != sizeof(ServerGroupJoin_Struct))
				break;
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_ForceGroupUpdate: {
			if(pack->size != sizeof(ServerForceGroupUpdate_Struct))
				break;
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_OOZGroupMessage: {
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_DisbandGroup: {
			if(pack->size != sizeof(ServerDisbandGroup_Struct))
				break;
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_RaidAdd:{
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidRemove: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidDisband: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidLockFlag: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidChangeGroup: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_UpdateGroup: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupDisband: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupAdd: {
			if(pack->size != sizeof(ServerRaidGroupAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupRemove: {
			if(pack->size != sizeof(ServerRaidGroupAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupSay: {
			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidSay: {
			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupLeader: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidLeader: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_DetailsChange: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_SpawnCondition: {
			if(pack->size != sizeof(ServerSpawnCondition_Struct))
				break;
			//bounce the packet to the correct zone server, if its up
			ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer;
			zoneserver_list.SendPacket(ssc->zoneID, ssc->instanceID, pack);
			break;
		}
		case ServerOP_SpawnEvent: {
			if(pack->size != sizeof(ServerSpawnEvent_Struct))
				break;
			//bounce the packet to the correct zone server, if its up
			ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer;
			zoneserver_list.SendPacket(sse->zoneID, 0, pack);
			break;
		}
		case ServerOP_ChannelMessage: {
			ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer;
			if(scm->chan_num == 20)
			{
				UCSLink.SendMessage(scm->from, scm->message);
				break;
			}
			if (scm->chan_num == 7 || scm->chan_num == 14) {
				if (scm->deliverto[0] == '*') {
					Console* con = 0;
					con = console_list.FindByAccountName(&scm->deliverto[1]);
					if (((!con) || (!con->SendChannelMessage(scm))) && (!scm->noreply))
						zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
					break;
				}
				ClientListEntry* cle = client_list.FindCharacter(scm->deliverto);
				if (cle == 0 || cle->Online() < CLE_Status_Zoning || (cle->TellsOff() && ((cle->Anon() == 1 && scm->fromadmin < cle->Admin()) || scm->fromadmin < 80))) {
					if (!scm->noreply)
						zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
				}
				else if (cle->Online() == CLE_Status_Zoning) {
					if (!scm->noreply) {
						char errbuf[MYSQL_ERRMSG_SIZE];
						char *query = 0;
						MYSQL_RES *result;
						//MYSQL_ROW row;   Trumpcard - commenting.  Currently unused.
						time_t rawtime;
						struct tm * timeinfo;
						time ( &rawtime );
						timeinfo = localtime ( &rawtime );
						char *telldate=asctime(timeinfo);
						if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT name from character_ where name='%s'",scm->deliverto), errbuf, &result)) {
							safe_delete(query);
							if (result!=0) {
								if (database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO tellque (Date,Receiver,Sender,Message) values('%s','%s','%s','%s')",telldate,scm->deliverto,scm->from,scm->message), errbuf, &result))
									zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "Your message has been added to the %s's que.", scm->to);
								else
									zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
								safe_delete(query);
							}
							else
								zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
							mysql_free_result(result);
						}
						else
							safe_delete(query);
					}
				//		zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
				}
				else if (cle->Server() == 0) {
					if (!scm->noreply)
						zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not contactable at this time'", scm->to, scm->to);
				}
				else
					cle->Server()->SendPacket(pack);
			}
			else {
				if (scm->chan_num == 5 || scm->chan_num == 6 || scm->chan_num == 11) {
					console_list.SendChannelMessage(scm);
				}
				zoneserver_list.SendPacket(pack);
			}
			break;
		}
		case ServerOP_EmoteMessage: {
			ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer;
			zoneserver_list.SendEmoteMessageRaw(sem->to, sem->guilddbid, sem->minstatus, sem->type, sem->message);
			break;
		}
		case ServerOP_VoiceMacro: {

			ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*) pack->pBuffer;
			
			if(svm->Type == VoiceMacroTell) {

				ClientListEntry* cle = client_list.FindCharacter(svm->To);

				if (!cle || (cle->Online() < CLE_Status_Zoning) || !cle->Server())  {

					zoneserver_list.SendEmoteMessage(svm->From, 0, 0, 0, "'%s is not online at this time'", svm->To);

					break;
				}

				cle->Server()->SendPacket(pack);
			}
			else
				zoneserver_list.SendPacket(pack);

			break;
		}

		case ServerOP_RezzPlayerAccept: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_RezzPlayer: {

			RezzPlayer_Struct* sRezz = (RezzPlayer_Struct*) pack->pBuffer;
			if (zoneserver_list.SendPacket(pack)){
				zlog(WORLD__ZONE,"Sent Rez packet for %s",sRezz->rez.your_name);
			}
			else {
				zlog(WORLD__ZONE,"Could not send Rez packet for %s",sRezz->rez.your_name);
			}
			break;
		}
		case ServerOP_RezzPlayerReject:
		{
			char *Recipient = (char *)pack->pBuffer;
			client_list.SendPacket(Recipient, pack);
			break;
		}

		case ServerOP_MultiLineMsg: {
			ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*) pack->pBuffer;
			client_list.SendPacket(mlm->to, pack);
			break;
		}
		case ServerOP_SetZone: {
			if(pack->size != sizeof(SetZone_Struct))
				break;

			SetZone_Struct* szs = (SetZone_Struct*) pack->pBuffer;	
			if (szs->zoneid != 0) {
				if(database.GetZoneName(szs->zoneid))
					SetZone(szs->zoneid, szs->instanceid, szs->staticzone);
				else
					SetZone(0);
			}
			else
				SetZone(0);

			break;
		}
		case ServerOP_SetConnectInfo: {
			if (pack->size != sizeof(ServerConnectInfo))
					break;
			ServerConnectInfo* sci = (ServerConnectInfo*) pack->pBuffer;

			if (!sci->port) {
				clientport=zoneserver_list.GetAvailableZonePort();

				ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo));
				memset(p.pBuffer,0,sizeof(ServerConnectInfo));
				ServerConnectInfo* sci = (ServerConnectInfo*) p.pBuffer;
				sci->port = clientport;
				SendPacket(&p);
				zlog(WORLD__ZONE,"Auto zone port configuration.  Telling zone to use port %d",clientport);
			} else {
				clientport=sci->port;
				zlog(WORLD__ZONE,"Zone specified port %d, must be a previously allocated zone reconnecting.",clientport);
			}

		}
		case ServerOP_SetLaunchName: {
			if(pack->size != sizeof(LaunchName_Struct))
				break;
			const LaunchName_Struct* ln = (const LaunchName_Struct*)pack->pBuffer;
			launcher_name = ln->launcher_name;
			launched_name = ln->zone_name;
			zlog(WORLD__ZONE, "Zone started with name %s by launcher %s", launched_name.c_str(), launcher_name.c_str());
			break;
		}
		case ServerOP_ShutdownAll: {
			if(pack->size==0){
				zoneserver_list.SendPacket(pack);
				zoneserver_list.Process();
				CatchSignal(2);
			}
			else{
				WorldShutDown_Struct* wsd=(WorldShutDown_Struct*)pack->pBuffer;
				if(wsd->time==0 && wsd->interval==0 && zoneserver_list.shutdowntimer->Enabled()){
					zoneserver_list.shutdowntimer->Disable();
					zoneserver_list.reminder->Disable();
				}
				else{
					zoneserver_list.shutdowntimer->SetTimer(wsd->time);
					zoneserver_list.reminder->SetTimer(wsd->interval-1000);
					zoneserver_list.reminder->SetAtTrigger(wsd->interval);
					zoneserver_list.shutdowntimer->Start();
					zoneserver_list.reminder->Start();
				}
			}
			break;
		}
		case ServerOP_ZoneShutdown: {
			ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer;
			ZoneServer* zs = 0;
			if (s->ZoneServerID != 0)
				zs = zoneserver_list.FindByID(s->ZoneServerID);
			else if (s->zoneid != 0)
				zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid));
			else
				zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: neither ID nor name specified");

			if (zs == 0)
				zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: zoneserver not found");
			else
				zs->SendPacket(pack);
			break;
		}
		case ServerOP_ZoneBootup: {
			ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer;
			zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, database.GetZoneName(s->zoneid), s->makestatic);
			break;
		}
		case ServerOP_ZoneStatus: {
			if (pack->size >= 1)
				zoneserver_list.SendZoneStatus((char *) &pack->pBuffer[1], (uint8) pack->pBuffer[0], this);
			break;

		}
		case ServerOP_AcceptWorldEntrance: {
			if(pack->size != sizeof(WorldToZone_Struct))
				break;

			WorldToZone_Struct* wtz = (WorldToZone_Struct*) pack->pBuffer;
			Client* client = 0;
			client = client_list.FindByAccountID(wtz->account_id);
			if(client != 0)
				client->Clearance(wtz->response);
		}
		case ServerOP_ZoneToZoneRequest: {
		//
		// solar: ZoneChange is received by the zone the player is in, then the
		// zone sends a ZTZ which ends up here.  This code then find the target
		// (ingress point) and boots it if needed, then sends the ZTZ to it.
		// The ingress server will decide wether the player can enter, then will
		// send back the ZTZ to here.  This packet is passed back to the egress
		// server, which will send a ZoneChange response back to the client
		// which can be an error, or a success, in which case the client will
		// disconnect, and their zone location will be saved when ~Client is
		// called, so it will be available when they ask to zone.
		//

			
			if(pack->size != sizeof(ZoneToZone_Struct))
				break;
			ZoneToZone_Struct* ztz = (ZoneToZone_Struct*) pack->pBuffer;
			ClientListEntry* client = NULL;
			if(WorldConfig::get()->UpdateStats)
				client = client_list.FindCharacter(ztz->name);

			zlog(WORLD__ZONE,"ZoneToZone request for %s current zone %d req zone %d\n",
				ztz->name, ztz->current_zone_id, ztz->requested_zone_id);

			if(GetZoneID() == ztz->current_zone_id && GetInstanceID() == ztz->current_instance_id)	// this is a request from the egress zone
			{
				zlog(WORLD__ZONE,"Processing ZTZ for egress from zone for client %s\n", ztz->name);

				if
				(
					ztz->admin < 80 &&
					ztz->ignorerestrictions < 2 &&
					zoneserver_list.IsZoneLocked(ztz->requested_zone_id)
				)
				{
					ztz->response = 0;
					SendPacket(pack);
					break;
				}

				ZoneServer *ingress_server = NULL;
				if(ztz->requested_instance_id > 0)
				{
					ingress_server = zoneserver_list.FindByInstanceID(ztz->requested_instance_id);
				}
				else
				{
					ingress_server = zoneserver_list.FindByZoneID(ztz->requested_zone_id);

				}

				if(ingress_server)	// found a zone already running
				{
					_log(WORLD__ZONE,"Found a zone already booted for %s\n", ztz->name);
					ztz->response = 1;
				}
				else	// need to boot one
				{
					int server_id;
					if ((server_id = zoneserver_list.TriggerBootup(ztz->requested_zone_id, ztz->requested_instance_id))){
						_log(WORLD__ZONE,"Successfully booted a zone for %s\n", ztz->name);
						// bootup successful, ready to rock
						ztz->response = 1;
						ingress_server = zoneserver_list.FindByID(server_id);
					}
					else
					{
						_log(WORLD__ZONE_ERR,"FAILED to boot a zone for %s\n", ztz->name);
						// bootup failed, send back error code 0
						ztz->response = 0;
					}
				}
				if(ztz->response!=0 && client)
					client->LSZoneChange(ztz);
				SendPacket(pack);	// send back to egress server
				if(ingress_server)	// if we couldn't boot one, this is 0
				{
					ingress_server->SendPacket(pack);	// inform target server
				}
			}
			else	// this is response from the ingress server, route it back to the egress server
			{
				zlog(WORLD__ZONE,"Processing ZTZ for ingress to zone for client %s\n", ztz->name);
				ZoneServer *egress_server = NULL;
				if(ztz->current_instance_id > 0)
				{
					egress_server = zoneserver_list.FindByInstanceID(ztz->current_instance_id);
				}
				else
				{
					egress_server = zoneserver_list.FindByZoneID(ztz->current_zone_id);
				}

				if(egress_server)
				{
					egress_server->SendPacket(pack);
				}
			}

			break;
		}
		case ServerOP_ClientList: {
			if (pack->size != sizeof(ServerClientList_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_ClientList. Got: %d, Expected: %d",pack->size,sizeof(ServerClientList_Struct));
				break;
			}
			client_list.ClientUpdate(this, (ServerClientList_Struct*) pack->pBuffer);
			break;
		}
		case ServerOP_ClientListKA: {
			ServerClientListKeepAlive_Struct* sclka = (ServerClientListKeepAlive_Struct*) pack->pBuffer;
			if (pack->size < 4 || pack->size != 4 + (4 * sclka->numupdates)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_ClientListKA. Got: %d, Expected: %d",pack->size, (4 + (4 * sclka->numupdates)));
				break;
			}
			client_list.CLEKeepAlive(sclka->numupdates, sclka->wid);
			break;
		}
		case ServerOP_Who: {
			ServerWhoAll_Struct* whoall = (ServerWhoAll_Struct*) pack->pBuffer;
			Who_All_Struct* whom = new Who_All_Struct;
			memset(whom,0,sizeof(Who_All_Struct));
			whom->gmlookup = whoall->gmlookup;
			whom->lvllow = whoall->lvllow;
			whom->lvlhigh = whoall->lvlhigh;
			whom->wclass = whoall->wclass;
			whom->wrace = whoall->wrace;
			strcpy(whom->whom,whoall->whom);
			client_list.SendWhoAll(whoall->fromid,whoall->from, whoall->admin, whom, this);
			delete whom;
			break;
		}
		case ServerOP_RequestOnlineGuildMembers:
		{
			ServerRequestOnlineGuildMembers_Struct *srogms = (ServerRequestOnlineGuildMembers_Struct*) pack->pBuffer;
			zlog(GUILDS__IN_PACKETS, "ServerOP_RequestOnlineGuildMembers Recieved. FromID=%i GuildID=%i", srogms->FromID, srogms->GuildID);	
			client_list.SendOnlineGuildMembers(srogms->FromID, srogms->GuildID);
			break;
		}
		case ServerOP_ClientVersionSummary:
		{
			ServerRequestClientVersionSummary_Struct *srcvss = (ServerRequestClientVersionSummary_Struct*) pack->pBuffer;
			client_list.SendClientVersionSummary(srcvss->Name);
			break;
		}
		case ServerOP_ReloadRules:
		{
			zoneserver_list.SendPacket(pack);
			rules->LoadRules(&database, "default");
			break;
		}
		case ServerOP_ReloadRulesWorld:
		{
			rules->LoadRules(&database, "default");
			break;
		}
		case ServerOP_CameraShake:
		{
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_FriendsWho: {
			ServerFriendsWho_Struct* FriendsWho = (ServerFriendsWho_Struct*) pack->pBuffer;
			client_list.SendFriendsWho(FriendsWho, this);
			break;
		}
		case ServerOP_LFGMatches: {
			ServerLFGMatchesRequest_Struct* smrs = (ServerLFGMatchesRequest_Struct*) pack->pBuffer;
			client_list.SendLFGMatches(smrs);
			break;
		}
		case ServerOP_LFPMatches: {
			ServerLFPMatchesRequest_Struct* smrs = (ServerLFPMatchesRequest_Struct*) pack->pBuffer;
			LFPGroupList.SendLFPMatches(smrs);
			break;
		}
		case ServerOP_LFPUpdate: {
			ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*) pack->pBuffer;	
			if(sus->Action) 
				LFPGroupList.UpdateGroup(sus);
			else
				LFPGroupList.RemoveGroup(sus);
			break;
		}
		case ServerOP_ZonePlayer: {
			//ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer;
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_KickPlayer: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_KillPlayer: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		
		case ServerOP_GuildRankUpdate:
		{
			zoneserver_list.SendPacket(pack);
			break;
		}
		//these opcodes get processed by the guild manager.
		case ServerOP_RefreshGuild:
		case ServerOP_DeleteGuild:
		case ServerOP_GuildCharRefresh:
		case ServerOP_GuildMemberUpdate: {
			guild_mgr.ProcessZonePacket(pack);
			break;
		}
		
		case ServerOP_FlagUpdate: {
			ClientListEntry* cle = client_list.FindCLEByAccountID(*((uint32*) pack->pBuffer));
			if (cle)
				cle->SetAdmin(*((int16*) &pack->pBuffer[4]));
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_GMGoto: {
			if (pack->size != sizeof(ServerGMGoto_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_GMGoto. Got: %d, Expected: %d",pack->size,sizeof(ServerGMGoto_Struct));
				break;
			}
			ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*) pack->pBuffer;
			ClientListEntry* cle = client_list.FindCharacter(gmg->gotoname);
			if (cle != 0) {
				if (cle->Server() == 0)
					this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: Cannot identify %s's zoneserver.", gmg->gotoname);
				else if (cle->Anon() == 1 && cle->Admin() > gmg->admin) // no snooping for anon GMs
					this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname);
				else
					cle->Server()->SendPacket(pack);
			}
			else {
				this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname);
			}
			break;
		}
		case ServerOP_Lock: {
			if (pack->size != sizeof(ServerLock_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_Lock. Got: %d, Expected: %d",pack->size,sizeof(ServerLock_Struct));
				break;
			}
			ServerLock_Struct* slock = (ServerLock_Struct*) pack->pBuffer;
  			if (slock->mode >= 1) 
				WorldConfig::LockWorld();
			else
				WorldConfig::UnlockWorld();
			if (loginserverlist.Connected()) {
				loginserverlist.SendStatus();
				if (slock->mode >= 1)
					this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked");
				else
					this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked");
			}
			else {
				if (slock->mode >= 1)
					this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked, but login server not connected.");
				else 
					this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked, but login server not conencted.");
			}
			break;
							}
		case ServerOP_Motd: {
			if (pack->size != sizeof(ServerMotd_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_Motd. Got: %d, Expected: %d",pack->size,sizeof(ServerMotd_Struct));
				break;
			}
			ServerMotd_Struct* smotd = (ServerMotd_Struct*) pack->pBuffer;
			database.SetVariable("MOTD",smotd->motd);
			//this->SendEmoteMessage(smotd->myname, 0, 0, 13, "Updated Motd.");
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_Uptime: {
			if (pack->size != sizeof(ServerUptime_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_Uptime. Got: %d, Expected: %d",pack->size,sizeof(ServerUptime_Struct));
				break;
			}
			ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer;
			if (sus->zoneserverid == 0) {
				ZSList::ShowUpTime(this, sus->adminname);
			}
			else {
				ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid);
				if (zs)
					zs->SendPacket(pack);
			}
			break;
							  }
		case ServerOP_Petition: {
			zoneserver_list.SendPacket(pack);
			break;
								}
		case ServerOP_GetWorldTime: {
			zlog(WORLD__ZONE,"Broadcasting a world time update");
			ServerPacket* pack = new ServerPacket;
			
			pack->opcode = ServerOP_SyncWorldTime;
			pack->size = sizeof(eqTimeOfDay);
			pack->pBuffer = new uchar[pack->size];
			memset(pack->pBuffer, 0, pack->size);
			eqTimeOfDay* tod = (eqTimeOfDay*) pack->pBuffer;
			tod->start_eqtime=zoneserver_list.worldclock.getStartEQTime();
			tod->start_realtime=zoneserver_list.worldclock.getStartRealTime();
			SendPacket(pack);
			delete pack;
			break;
									}
		case ServerOP_SetWorldTime: {
			zlog(WORLD__ZONE,"Received SetWorldTime");
			eqTimeOfDay* newtime = (eqTimeOfDay*) pack->pBuffer;
			zoneserver_list.worldclock.setEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime);
			zlog(WORLD__ZONE,"New time = %d-%d-%d %d:%d (%d)\n", newtime->start_eqtime.year, newtime->start_eqtime.month, (int)newtime->start_eqtime.day, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.minute, (int)newtime->start_realtime);
			zoneserver_list.worldclock.saveFile(WorldConfig::get()->EQTimeFile.c_str());
			zoneserver_list.SendTimeSync();
			break;
		}
		case ServerOP_IPLookup: {
			if (pack->size < sizeof(ServerGenericWorldQuery_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_IPLookup. Got: %d, Expected (at least): %d",pack->size,sizeof(ServerGenericWorldQuery_Struct));
				break;
			}
			ServerGenericWorldQuery_Struct* sgwq = (ServerGenericWorldQuery_Struct*) pack->pBuffer;
			if (pack->size == sizeof(ServerGenericWorldQuery_Struct))
				client_list.SendCLEList(sgwq->admin, sgwq->from, this);
			else
				client_list.SendCLEList(sgwq->admin, sgwq->from, this, sgwq->query);
			break;
		}
		case ServerOP_LockZone: {
			if (pack->size < sizeof(ServerLockZone_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_LockZone. Got: %d, Expected: %d",pack->size,sizeof(ServerLockZone_Struct));
				break;
			}
			ServerLockZone_Struct* s = (ServerLockZone_Struct*) pack->pBuffer;
			switch (s->op) {
				case 0:
					zoneserver_list.ListLockedZones(s->adminname, this);
					break;
				case 1:
					if (zoneserver_list.SetLockedZone(s->zoneID, true))
						zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", database.GetZoneName(s->zoneID));
					else
						this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
					break;
				case 2:
					if (zoneserver_list.SetLockedZone(s->zoneID, false))
						zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", database.GetZoneName(s->zoneID));
					else
						this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
					break;
			}
			break;
		}
		case ServerOP_ItemStatus: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_OOCMute: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_Revoke: {
			RevokeStruct* rev = (RevokeStruct*)pack->pBuffer;
			ClientListEntry* cle = client_list.FindCharacter(rev->name);
			if (cle != 0 && cle->Server() != 0)
			{
				cle->Server()->SendPacket(pack);
			}
			break;
		}
		case ServerOP_SpawnPlayerCorpse: {
			SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer;
			ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id);
			if(zs) {
				if (zs->SendPacket(pack)) {
					zlog(WORLD__ZONE,"Sent request to spawn player corpse id %i in zone %u.",s->player_corpse_id, s->zone_id);
				}
				else {
					zlog(WORLD__ZONE_ERR,"Could not send request to spawn player corpse id %i in zone %u.",s->player_corpse_id, s->zone_id);
				}
			}
			break;
		}
	    case ServerOP_Consent: {
			// Message string id's likely to be used here are:
			// CONSENT_YOURSELF = 399
			// CONSENT_INVALID_NAME = 397
			// TARGET_NOT_FOUND = 101
			ZoneServer* zs;
			ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
			ClientListEntry* cle = client_list.FindCharacter(s->grantname);
			if(cle) {
				if(cle->instance() != 0)
				{
					zs = zoneserver_list.FindByInstanceID(cle->instance());
					if(zs) {
						if(zs->SendPacket(pack)) {
							zlog(WORLD__ZONE, "Sent consent packet from player %s to player %s in zone %u.", s->ownername, s->grantname, cle->instance());
						}
						else {
							zlog(WORLD__ZONE_ERR, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent operation.", s->instance_id);
						}
					}
					else
					{
						delete pack;
						pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
						ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer;
						strcpy(scs->grantname, s->grantname);
						strcpy(scs->ownername, s->ownername);
						scs->permission = s->permission;
						scs->zone_id = s->zone_id;
						scs->instance_id = s->instance_id;
						scs->message_string_id = 101;
						zs = zoneserver_list.FindByInstanceID(s->instance_id);
						if(zs) {
							if(!zs->SendPacket(pack))
								zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in instance %u.", s->ownername, zs->GetInstanceID());
						}
						else {
							zlog(WORLD__ZONE_ERR, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent_Response operation.", s->instance_id);
						}
					}
				}
				else
				{
					zs = zoneserver_list.FindByZoneID(cle->zone());
					if(zs) {
						if(zs->SendPacket(pack)) {
							zlog(WORLD__ZONE, "Sent consent packet from player %s to player %s in zone %u.", s->ownername, s->grantname, cle->zone());
						}
						else {
							zlog(WORLD__ZONE_ERR, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent operation.", s->zone_id);
						}
					}
					else {
						// send target not found back to requester
						delete pack;
						pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
						ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer;
						strcpy(scs->grantname, s->grantname);
						strcpy(scs->ownername, s->ownername);
						scs->permission = s->permission;
						scs->zone_id = s->zone_id;
						scs->message_string_id = 101;
						zs = zoneserver_list.FindByZoneID(s->zone_id);
						if(zs) {
							if(!zs->SendPacket(pack))
								zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in zone %s.", s->ownername, zs->GetZoneName());
						}
						else {
							zlog(WORLD__ZONE_ERR, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id);
						}
					}
				}
			}
			else {
				// send target not found back to requester
				delete pack;
				pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
				ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer;
				strcpy(scs->grantname, s->grantname);
				strcpy(scs->ownername, s->ownername);
				scs->permission = s->permission;
				scs->zone_id = s->zone_id;
				scs->message_string_id = 397;
				zs = zoneserver_list.FindByZoneID(s->zone_id);
				if(zs) {
					if(!zs->SendPacket(pack))
						zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in zone %s.", s->ownername, zs->GetZoneName());
				}
				else {
					zlog(WORLD__ZONE_ERR, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id);
				}
			}
			break;
		}
		case ServerOP_Consent_Response: {
			// Message string id's likely to be used here are:
			// CONSENT_YOURSELF = 399
			// CONSENT_INVALID_NAME = 397
			// TARGET_NOT_FOUND = 101
			ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
			if(s->instance_id != 0)
			{
				ZoneServer* zs = zoneserver_list.FindByInstanceID(s->instance_id);
				if(zs) {
					if(!zs->SendPacket(pack))
						zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in instance %u.", s->ownername, zs->GetInstanceID());
				}
				else {
					zlog(WORLD__ZONE_ERR, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent_Response operation.", s->instance_id);
				}
			}
			else
			{
				ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id);
				if(zs) {
					if(!zs->SendPacket(pack))
						zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in zone %s.", s->ownername, zs->GetZoneName());
				}
				else {
					zlog(WORLD__ZONE_ERR, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id);
				}
			}
			break;
		}

		case ServerOP_InstanceUpdateTime :
		{
			ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer;
			ZoneServer *zm = zoneserver_list.FindByInstanceID(iut->instance_id);
			if(zm)
			{
				zm->SendPacket(pack);
			}
			break;
		}
		case ServerOP_QGlobalUpdate:
		{
			if(pack->size != sizeof(ServerQGlobalUpdate_Struct))
			{
				break;
			}

			zoneserver_list.SendPacket(pack);
			break;		
		}

		case ServerOP_QGlobalDelete:
		{
			if(pack->size != sizeof(ServerQGlobalDelete_Struct))
			{
				break;
			}

			zoneserver_list.SendPacket(pack);
			break;		
		}

		case ServerOP_AdventureRequest:
		{
			adventure_manager.CalculateAdventureRequestReply((const char*)pack->pBuffer);
			break;
		}

		case ServerOP_AdventureRequestCreate:
		{
			adventure_manager.TryAdventureCreate((const char*)pack->pBuffer);
			break;
		}

		case ServerOP_AdventureDataRequest:
		{
			AdventureFinishEvent fe;
			while(adventure_manager.PopFinishedEvent((const char*)pack->pBuffer, fe))
			{
				adventure_manager.SendAdventureFinish(fe);
			}
			adventure_manager.GetAdventureData((const char*)pack->pBuffer);
			break;
		}

		case ServerOP_AdventureClickDoor:
		{
			ServerPlayerClickedAdventureDoor_Struct *pcad = (ServerPlayerClickedAdventureDoor_Struct*)pack->pBuffer;
			adventure_manager.PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id);
			break;
		}

		case ServerOP_AdventureLeave:
		{
			adventure_manager.LeaveAdventure((const char*)pack->pBuffer);
			break;
		}

		case ServerOP_AdventureCountUpdate:
		{
			ServerAdventureCount_Struct *sc = (ServerAdventureCount_Struct*)pack->pBuffer;
			adventure_manager.IncrementCount(sc->instance_id);
			break;
		}

		case ServerOP_AdventureAssaCountUpdate:
		{
			adventure_manager.IncrementAssassinationCount(*((uint16*)pack->pBuffer));
			break;
		}

		case ServerOP_AdventureZoneData:
		{
			adventure_manager.GetZoneData(*((uint16*)pack->pBuffer));
			break;
		}

		case ServerOP_AdventureLeaderboard:
		{
			ServerLeaderboardRequest_Struct *lr = (ServerLeaderboardRequest_Struct*)pack->pBuffer;
			adventure_manager.DoLeaderboardRequest(lr->player, lr->type);
			break;
		}

		case ServerOP_LSAccountUpdate:
		{
			zlog(WORLD__ZONE, "Received ServerOP_LSAccountUpdate packet from zone");
			loginserverlist.SendAccountUpdate(pack);
			break;
		}

		case ServerOP_UCSMailMessage: 
		{
			UCSLink.SendPacket(pack);
			break;
		}

		case ServerOP_QueryServGeneric:
		case ServerOP_Speech:
		case ServerOP_QSPlayerLogTrades:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSPlayerLogHandins:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSPlayerLogNPCKills:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSPlayerLogDeletes:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSPlayerLogMoves:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSMerchantLogTransactions:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_CZSignalClientByName:
		case ServerOP_CZMessagePlayer:
		case ServerOP_CZSignalClient:
		{
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_DepopAllPlayersCorpses:
		case ServerOP_DepopPlayerCorpse:
		case ServerOP_ReloadTitles:
		case ServerOP_SpawnStatusChange:
		case ServerOP_ReloadTasks:
		case ServerOP_ReloadWorld:
		case ServerOP_UpdateSpawn:
		{
			zoneserver_list.SendPacket(pack);
			break;
		}
		default:
		{
			zlog(WORLD__ZONE_ERR,"Unknown ServerOPcode from zone 0x%04x, size %d",pack->opcode,pack->size);
			DumpPacket(pack->pBuffer, pack->size);
			break;
		}
		}

		delete pack;
	} 
	return true;
}
Example #12
0
extern "C" CK_DECLARE_FUNCTION(CK_RV,C_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR)) {
  _log("RETURNING CKR_GENERAL_ERROR");
  return CKR_FUNCTION_NOT_SUPPORTED;
}
Example #13
0
extern "C" CK_DECLARE_FUNCTION(CK_RV,C_CancelFunction(CK_SESSION_HANDLE hSession))
{
  _log("RETURNING CKR_FUNCTION_NOT_SUPPORTED");
	return CKR_FUNCTION_NOT_SUPPORTED;
}
Example #14
0
extern "C" CK_DECLARE_FUNCTION(CK_RV,C_DeriveKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hBaseKey, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey))
{
  _log("RETURNING CKR_FUNCTION_NOT_SUPPORTED");
	return CKR_FUNCTION_NOT_SUPPORTED;
}
Example #15
0
bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
	if(m_db == nullptr) {
		_log(GUILDS__DB, "Requested to refresh guild %d when we have no database object.", guild_id);
		return(false);
	}

	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;
	std::map<uint32, GuildInfo *>::iterator res;
	GuildInfo *info;

	// load up all the guilds
	if (!m_db->RunQuery(query, MakeAnyLenString(&query,
		"SELECT name, leader, minstatus, motd, motd_setter, channel,url FROM guilds WHERE id=%lu", (unsigned long)guild_id), errbuf, &result)) {
		_log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query, errbuf);
		safe_delete_array(query);
		return(false);
	}
	safe_delete_array(query);
	if ((row = mysql_fetch_row(result))) {
		//delete the old entry and create the new one.
		info = _CreateGuild(guild_id, row[0], atoi(row[1]), atoi(row[2]), row[3], row[4], row[5], row[6]);
	} else {
		_log(GUILDS__ERROR, "Unable to find guild %d in the database.", guild_id);
		return(false);
	}
	mysql_free_result(result);

	//load up the rank info for each guild.
	if (!m_db->RunQuery(query, MakeAnyLenString(&query,
		"SELECT guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace "
		"FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id), errbuf, &result)) {
		_log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query, errbuf);
		safe_delete_array(query);
		return(false);
	}
	safe_delete_array(query);

	while((row = mysql_fetch_row(result))) {
		uint8 rankn = atoi(row[1]);
		if(rankn > GUILD_MAX_RANK) {
			_log(GUILDS__ERROR, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
			continue;
		}
		RankInfo &rank = info->ranks[rankn];

		rank.name = row[2];
		rank.permissions[GUILD_HEAR] = (row[3][0] == '1')?true:false;
		rank.permissions[GUILD_SPEAK] = (row[4][0] == '1')?true:false;
		rank.permissions[GUILD_INVITE] = (row[5][0] == '1')?true:false;
		rank.permissions[GUILD_REMOVE] = (row[6][0] == '1')?true:false;
		rank.permissions[GUILD_PROMOTE] = (row[7][0] == '1')?true:false;
		rank.permissions[GUILD_DEMOTE] = (row[8][0] == '1')?true:false;
		rank.permissions[GUILD_MOTD] = (row[9][0] == '1')?true:false;
		rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1')?true:false;
	}
	mysql_free_result(result);

	_log(GUILDS__DB, "Successfully refreshed guild %d from the database.", guild_id);

	return(true);
}
Example #16
0
File: log.c Project: rajbot/gphoto
void
_log_msg(char *file, int line, char *msg)
{
	_log(file, line, "MSG", msg );
}
Example #17
0
bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
	if(m_db == nullptr) {
		_log(GUILDS__DB, "Requested to store guild %d when we have no database object.", guild_id);
		return(false);
	}

	std::map<uint32, GuildInfo *>::const_iterator res;
	res = m_guilds.find(guild_id);
	if(res == m_guilds.end()) {
		_log(GUILDS__DB, "Requested to store non-existent guild %d", guild_id);
		return(false);
	}
	GuildInfo *info = res->second;

	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;

	//clear out old `guilds` entry
	if (!m_db->RunQuery(query, MakeAnyLenString(&query,
		"DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id), errbuf))
	{
		_log(GUILDS__ERROR, "Error clearing old guild record when storing %d '%s': %s", guild_id, query, errbuf);
	}
	safe_delete_array(query);

	//clear out old `guild_ranks` entries
	if (!m_db->RunQuery(query, MakeAnyLenString(&query,
		"DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id), errbuf))
	{
		_log(GUILDS__ERROR, "Error clearing old guild_ranks records when storing %d '%s': %s", guild_id, query, errbuf);
	}
	safe_delete_array(query);

	//escape our strings.
	char *name_esc = new char[info->name.length()*2+1];
	char *motd_esc = new char[info->motd.length()*2+1];
	char *motd_set_esc = new char[info->motd_setter.length()*2+1];
	m_db->DoEscapeString(name_esc, info->name.c_str(), info->name.length());
	m_db->DoEscapeString(motd_esc, info->motd.c_str(), info->motd.length());
	m_db->DoEscapeString(motd_set_esc, info->motd_setter.c_str(), info->motd_setter.length());

	//insert the new `guilds` entry
	if (!m_db->RunQuery(query, MakeAnyLenString(&query,
		"INSERT INTO guilds (id,name,leader,minstatus,motd,motd_setter) VALUES(%lu,'%s',%lu,%d,'%s', '%s')",
		(unsigned long)guild_id, name_esc, (unsigned long)info->leader_char_id, info->minstatus, motd_esc, motd_set_esc), errbuf))
	{
		_log(GUILDS__ERROR, "Error inserting new guild record when storing %d. Giving up. '%s': %s", guild_id, query, errbuf);
		safe_delete_array(query);
		safe_delete_array(name_esc);
		safe_delete_array(motd_esc);
		safe_delete_array(motd_set_esc);
		return(false);
	}
	safe_delete_array(query);
	safe_delete_array(name_esc);
	safe_delete_array(motd_esc);
	safe_delete_array(motd_set_esc);

	//now insert the new ranks
	uint8 rank;
	for(rank = 0; rank <= GUILD_MAX_RANK; rank++) {
		const RankInfo &r = info->ranks[rank];

		char *title_esc = new char[r.name.length()*2+1];
		m_db->DoEscapeString(title_esc, r.name.c_str(), r.name.length());

		if (!m_db->RunQuery(query, MakeAnyLenString(&query,
		"INSERT INTO guild_ranks (guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace)"
		" VALUES(%d,%d,'%s',%d,%d,%d,%d,%d,%d,%d,%d)",
			guild_id, rank, title_esc,
			r.permissions[GUILD_HEAR],
			r.permissions[GUILD_SPEAK],
			r.permissions[GUILD_INVITE],
			r.permissions[GUILD_REMOVE],
			r.permissions[GUILD_PROMOTE],
			r.permissions[GUILD_DEMOTE],
			r.permissions[GUILD_MOTD],
			r.permissions[GUILD_WARPEACE]), errbuf))
		{
			_log(GUILDS__ERROR, "Error inserting new guild rank record when storing %d for %d. Giving up. '%s': %s", rank, guild_id, query, errbuf);
			safe_delete_array(query);
			safe_delete_array(title_esc);
			return(false);
		}
		safe_delete_array(query);
		safe_delete_array(title_esc);
	}

	_log(GUILDS__DB, "Stored guild %d in the database", guild_id);

	return(true);
}
Example #18
0
bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
	if(m_db == nullptr) {
		_log(GUILDS__DB, "Requested to refresh guild %d when we have no database object.", guild_id);
		return(false);
	}

	std::string query = StringFormat("SELECT name, leader, minstatus, motd, motd_setter, channel,url FROM guilds WHERE id=%lu", (unsigned long)guild_id);
	std::map<uint32, GuildInfo *>::iterator res;
	GuildInfo *info;

	// load up all the guilds
	auto results = m_db->QueryDatabase(query);

	if (!results.Success())
	{
		_log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query.c_str(), results.ErrorMessage().c_str());
		return false;
	}

	if (results.RowCount() == 0)
	{
		_log(GUILDS__ERROR, "Unable to find guild %d in the database.", guild_id);
		return false;
	}

	auto row = results.begin();

	info = _CreateGuild(guild_id, row[0], atoi(row[1]), atoi(row[2]), row[3], row[4], row[5], row[6]);

    query = StringFormat("SELECT guild_id, rank, title, can_hear, can_speak, can_invite, can_remove, can_promote, can_demote, can_motd, can_warpeace "
                        "FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id);
	results = m_db->QueryDatabase(query);

	if (!results.Success())
	{
		_log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query.c_str(), results.ErrorMessage().c_str());
		return false;
	}

	for (auto row=results.begin();row!=results.end();++row)
	{
		uint8 rankn = atoi(row[1]);

		if(rankn > GUILD_MAX_RANK) {
			_log(GUILDS__ERROR, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
			continue;
		}

		RankInfo &rank = info->ranks[rankn];

		rank.name = row[2];
		rank.permissions[GUILD_HEAR] = (row[3][0] == '1') ? true: false;
		rank.permissions[GUILD_SPEAK] = (row[4][0] == '1') ? true: false;
		rank.permissions[GUILD_INVITE] = (row[5][0] == '1') ? true: false;
		rank.permissions[GUILD_REMOVE] = (row[6][0] == '1') ? true: false;
		rank.permissions[GUILD_PROMOTE] = (row[7][0] == '1') ? true: false;
		rank.permissions[GUILD_DEMOTE] = (row[8][0] == '1') ? true: false;
		rank.permissions[GUILD_MOTD] = (row[9][0] == '1') ? true: false;
		rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1') ? true: false;
	}

	_log(GUILDS__DB, "Successfully refreshed guild %d from the database.", guild_id);

	return true;
}
Example #19
0
void Character::SaveCharacter()
{
    _log( ITEM__TRACE, "Saving character %u.", itemID() );

    sLog.Debug( "Character::SaveCharacter()", "Saving all character info and skill attribute info to DB for character %s...", itemName().c_str() );
    // character data
    m_factory.db().SaveCharacter(
        itemID(),
        CharacterData(
            accountID(),
            title().c_str(),
            description().c_str(),
            gender(),
            bounty(),
            balance(),
            securityRating(),
            logonMinutes(),
            corporationID(),
            allianceID(),
            warFactionID(),
            stationID(),
            solarSystemID(),
            constellationID(),
            regionID(),
            ancestryID(),
            careerID(),
            schoolID(),
            careerSpecialityID(),
            startDateTime(),
            createDateTime(),
            corporationDateTime()
        )
    );

    // corporation data
    m_factory.db().SaveCorpMemberInfo(
        itemID(),
        CorpMemberInfo(
            corporationHQ(),
            corpRole(),
            rolesAtAll(),
            rolesAtBase(),
            rolesAtHQ(),
            rolesAtOther()
        )
    );

    // Save this character's own attributes:
    SaveAttributes();

    // Loop through all skills and invoke mAttributeMap.SaveAttributes() for each
    std::vector<InventoryItemRef> skills;
    GetSkillsList( skills );
    std::vector<InventoryItemRef>::iterator cur, end;
    cur = skills.begin();
    end = skills.end();
    for(; cur != end; cur++)
        cur->get()->SaveAttributes();
        //cur->get()->mAttributeMap.Save();
	SaveCertificates();
	SaveBoosters();
}
Example #20
0
bool BaseGuildManager::LoadGuilds() {

	ClearGuilds();

	if(m_db == nullptr) {
		_log(GUILDS__DB, "Requested to load guilds when we have no database object.");
		return(false);
	}

	std::string query("SELECT id, name, leader, minstatus, motd, motd_setter,channel,url FROM guilds");
	std::map<uint32, GuildInfo *>::iterator res;

	auto results = m_db->QueryDatabase(query);

	if (!results.Success())
	{
		_log(GUILDS__ERROR, "Error loading guilds '%s': %s", query.c_str(), results.ErrorMessage().c_str());
		return false;
	}

	for (auto row=results.begin();row!=results.end();++row)
		_CreateGuild(atoi(row[0]), row[1], atoi(row[2]), atoi(row[3]), row[4], row[5], row[6], row[7]);

    query = "SELECT guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace FROM guild_ranks";
	results = m_db->QueryDatabase(query);

	if (!results.Success())
	{
		_log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query.c_str(), results.ErrorMessage().c_str());
		return false;
	}

	for (auto row=results.begin();row!=results.end();++row)
	{
		uint32 guild_id = atoi(row[0]);
		uint8 rankn = atoi(row[1]);

		if(rankn > GUILD_MAX_RANK) {
			_log(GUILDS__ERROR, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
			continue;
		}

		res = m_guilds.find(guild_id);
		if(res == m_guilds.end()) {
			_log(GUILDS__ERROR, "Found rank %d for non-existent guild %d, skipping.", rankn, guild_id);
			continue;
		}

		RankInfo &rank = res->second->ranks[rankn];

		rank.name = row[2];
		rank.permissions[GUILD_HEAR] = (row[3][0] == '1')?true:false;
		rank.permissions[GUILD_SPEAK] = (row[4][0] == '1')?true:false;
		rank.permissions[GUILD_INVITE] = (row[5][0] == '1')?true:false;
		rank.permissions[GUILD_REMOVE] = (row[6][0] == '1')?true:false;
		rank.permissions[GUILD_PROMOTE] = (row[7][0] == '1')?true:false;
		rank.permissions[GUILD_DEMOTE] = (row[8][0] == '1')?true:false;
		rank.permissions[GUILD_MOTD] = (row[9][0] == '1')?true:false;
		rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1')?true:false;
	}

	return true;
}
Example #21
0
void Character::UpdateSkillQueue()
{
    Client *c = m_factory.entity_list.FindCharacter( itemID() );

    SkillRef currentTraining = GetSkillInTraining();
    if( currentTraining )
    {
        if( m_skillQueue.empty()
            || currentTraining->typeID() != m_skillQueue.front().typeID )
        {
            // either queue is empty or skill with different typeID is in training ...
            // stop training:
            _log( ITEM__ERROR, "%s (%u): Stopping training of skill %s (%u).", itemName().c_str(), itemID(), currentTraining->itemName().c_str(), currentTraining->itemID() );

            /*
            uint64 timeEndTrain = currentTraining->expiryTime();
            if(timeEndTrain != 0)
            {
                double nextLevelSP = currentTraining->GetSPForLevel( currentTraining->skillLevel() + 1 );
                double SPPerMinute = GetSPPerMin( currentTraining );
                double minRemaining = (double)(timeEndTrain - Win32TimeNow()) / (double)Win32Time_Minute;

                currentTraining->Set_skillPoints( nextLevelSP - (minRemaining * SPPerMinute) );
            }

            currentTraining->Clear_expiryTime();
            */

            EvilNumber timeEndTrain = currentTraining->GetAttribute(AttrExpiryTime);
            if (timeEndTrain != 0) {
                EvilNumber nextLevelSP = currentTraining->GetSPForLevel( currentTraining->GetAttribute(AttrSkillLevel) + 1 );
                EvilNumber SPPerMinute = GetSPPerMin( currentTraining );
                EvilNumber minRemaining = (timeEndTrain - EvilNumber(Win32TimeNow())) / (double)Win32Time_Minute;

                //currentTraining->Set_skillPoints( nextLevelSP - (minRemaining * SPPerMinute) );
                currentTraining->SetAttribute(AttrSkillPoints, nextLevelSP - (minRemaining * SPPerMinute));
            }

            currentTraining->SetAttribute(AttrExpiryTime, 0);

            currentTraining->MoveInto( *this, flagSkill, true );

            if( c != NULL )
            {
                OnSkillTrainingStopped osst;
                osst.itemID = currentTraining->itemID();
                osst.endOfTraining = 0;

                PyTuple* tmp = osst.Encode();
                c->QueueDestinyEvent( &tmp );
                PySafeDecRef( tmp );

                c->UpdateSkillTraining();
            }

            // nothing currently in training
            currentTraining = SkillRef();
        }
    }

    EvilNumber nextStartTime = EvilTimeNow();
    
    while( !m_skillQueue.empty() )
    {
        if( !currentTraining )
        {
            // something should be trained, get desired skill
            uint32 skillTypeID = m_skillQueue.front().typeID;

            currentTraining = GetSkill( skillTypeID );
            if( !currentTraining )
            {
                _log( ITEM__ERROR, "%s (%u): Skill %u to train was not found.", itemName().c_str(), itemID(), skillTypeID );
                break;
            }

            _log( ITEM__TRACE, "%s (%u): Starting training of skill %s (%u).", m_itemName.c_str(), m_itemID, currentTraining->itemName().c_str(), currentTraining->itemID() );

            EvilNumber SPPerMinute = GetSPPerMin( currentTraining );
            //  double SPToNextLevel = currentTraining->GetSPForLevel( currentTraining->skillLevel() + 1 ) - currentTraining->skillPoints();
            EvilNumber SPToNextLevel = currentTraining->GetSPForLevel( currentTraining->GetAttribute(AttrSkillLevel) + 1) - currentTraining->GetAttribute(AttrSkillPoints);

            //uint64 timeTraining = nextStartTime + Win32Time_Minute * SPToNextLevel / SPPerMinute;
            EvilNumber timeTraining = nextStartTime + EvilTime_Minute * SPToNextLevel / SPPerMinute;

            currentTraining->MoveInto( *this, flagSkillInTraining );
            //currentTraining->Set_expiryTime( timeTraining );
            currentTraining->SetAttribute(AttrExpiryTime, timeTraining);

            if( c != NULL )
            {
                OnSkillStartTraining osst;
                osst.itemID = currentTraining->itemID();
                osst.endOfTraining = timeTraining.get_int();

                PyTuple* tmp = osst.Encode();
                c->QueueDestinyEvent( &tmp );
                PySafeDecRef( tmp );

                c->UpdateSkillTraining();
            }
        }

        //if( currentTraining->expiryTime() <= Win32TimeNow() )
        if( currentTraining->GetAttribute(AttrExpiryTime) <= EvilTimeNow() ) {
            // training has been finished:
            _log( ITEM__ERROR, "%s (%u): Finishing training of skill %s (%u).", itemName().c_str(), itemID(), currentTraining->itemName().c_str(), currentTraining->itemID() );

            //currentTraining->Set_skillLevel( currentTraining->skillLevel() + 1 );
            //currentTraining->Set_skillPoints( currentTraining->GetSPForLevel( currentTraining->skillLevel() ) );

            //nextStartTime = currentTraining->expiryTime();
            //currentTraining->Clear_expiryTime();

            currentTraining->SetAttribute(AttrSkillLevel, currentTraining->GetAttribute(AttrSkillLevel) + 1 );
            currentTraining->SetAttribute(AttrSkillPoints,  currentTraining->GetSPForLevel( currentTraining->GetAttribute(AttrSkillLevel) ) );

            nextStartTime = currentTraining->GetAttribute(AttrExpiryTime);
            currentTraining->SetAttribute(AttrExpiryTime, 0);

            currentTraining->MoveInto( *this, flagSkill, true );

            if( c != NULL )
            {
                OnSkillTrained ost;
                ost.itemID = currentTraining->itemID();

                PyTuple* tmp = ost.Encode();
                c->QueueDestinyEvent( &tmp );
                PySafeDecRef( tmp );

                c->UpdateSkillTraining();
            }

            // erase first element in skill queue
            m_skillQueue.erase( m_skillQueue.begin() );

            // nothing currently in training
            currentTraining = SkillRef();
        }
        // else the skill is in training ...
        else
            break;
    }

    // Re-Calculate total SP trained and store in internal variable:
    _CalculateTotalSPTrained();

    // Save character and skill data:
    SaveCharacter();
    SaveSkillQueue();
}
Example #22
0
/**
 * Insert a timer in the list of active timer,
 *    according to its expiration date.
 *
 * @param newTimer pointer on the timer to insert
 *
 * WARNING: newTimer MUST NOT be null (rem: static function )
 *
 */
static void add_timer(T_TIMER_LIST_ELT *newTimer)
{
	T_TIMER_LIST_ELT *insertionPoint;
	T_TIMER_LIST_ELT *listTail;
	bool found;

#ifdef __DEBUG_OS_ABSTRACTION_TIMER
	_log(
		"\nINFO : add_timer - start: adding 0x%x to expire at %d (now = %d - delay = %d - ticktime = %d)",
		(uint32_t)newTimer, newTimer->desc.expiration,
		get_uptime_ms(), newTimer->desc.delay, sys_clock_us_per_tick);
	display_list();
#endif


	if (NULL == g_CurrentTimerHead) {
		/* there is no active timer, make newTimer the head timer */
		g_CurrentTimerHead = newTimer;
		newTimer->prev = NULL;
		newTimer->next = NULL;
	} else {
		/* find the next timer to expire after newTimer->desc.expiration */
		insertionPoint = g_CurrentTimerHead;
		listTail = g_CurrentTimerHead;
		found = false;
		while ((NULL != insertionPoint) && (false == found)) {
			if (!is_after_expiration(newTimer->desc.expiration,
						 &(insertionPoint->desc))) { /* newTimer is due to expire before insertionPoint */
				if (g_CurrentTimerHead == insertionPoint) { /*  insert newTimer before the head timer  */
					g_CurrentTimerHead->prev = newTimer;
					newTimer->prev = NULL;
					newTimer->next = g_CurrentTimerHead;
					g_CurrentTimerHead = newTimer;
				} else { /* insert newTimer between insertionPoint and insertionPoint->prev */
					newTimer->prev = insertionPoint->prev;
					newTimer->next = insertionPoint;
					insertionPoint->prev = newTimer;
					newTimer->prev->next = newTimer;
				}
				/* done */
				found = true;
			} else { /* newTimer is due to expire after insertionPoint, continue searching */
				listTail = insertionPoint; /* update list head marker = last non null insertionPoint */
				/* move downward */
				insertionPoint = insertionPoint->next;
			}
		}

		if ((false == found) && (NULL != listTail)) {
			/* newTimer is due to expire after all others have expired */
			listTail->next = newTimer;
			newTimer->prev = listTail;
		}
	}

	newTimer->desc.status = E_TIMER_RUNNING;

#ifdef __DEBUG_OS_ABSTRACTION_TIMER
	_log("\nINFO : add_timer - end "); display_list();
	display_list();
#endif
}
Example #23
0
File: cmd.cpp Project: ATNoG/ODiMM
void cmd::proxy_binding_ack(const proxy_binding_info& pbinfo, chrono& delay)
{
	bulist_entry* be = _bulist.find(pbinfo.id);
	if (!be) {
		_log(0, "PBA error: binding update list entry not found [id = ", pbinfo.id, ", cmd = ", pbinfo.address, "]");
		return;
	}

	if (be->cmd_address() != pbinfo.address) {
		_log(0, "PBA error: not this CMD [id = ", pbinfo.id, ", cmd = ", pbinfo.address, "]");
		return;
	}

	if (pbinfo.status == ip::mproto::pba::status_bad_sequence) {
		_log(0, "PBA error: bad sequence number [id = ", pbinfo.id,
		                                      ", cmd = ", pbinfo.address,
		                                      ", sequence = ", be->sequence_number,
		                                      ", last accepted sequence = ", pbinfo.sequence, "]");

		be->sequence_number = pbinfo.sequence;

		proxy_binding_info pbinfo;

		pbinfo.id = be->mn_id();
		pbinfo.address = be->cmd_address();
		pbinfo.handoff = ip::mproto::option::handoff::k_unknown;
		pbinfo.sequence = ++be->sequence_number;
		pbinfo.lifetime = (be->bind_status != bulist_entry::k_bind_detach) ? be->lifetime : 0;
		pbinfo.prefix_list = be->mn_prefix_list();

		pbu_sender_ptr pbus(new pbu_sender(pbinfo));

		pbus->async_send(_mp_sock, boost::bind(&mag::mp_send_handler, this, _1));
		be->timer.cancel();
		be->timer.expires_from_now(boost::posix_time::milliseconds(1500));
		be->timer.async_wait(_service.wrap(boost::bind(&mag::proxy_binding_retry, this, _1, pbinfo)));

		return;
	}

	if (pbinfo.sequence != be->sequence_number) {
		_log(0, "PBA error: sequence number invalid [id = ", pbinfo.id,
		                                          ", cmd = ", pbinfo.address,
		                                          ", sequence = ", pbinfo.sequence,
		                                          " != ", be->sequence_number, "]");
		return;
	}

	if (pbinfo.lifetime && (be->bind_status == bulist_entry::k_bind_requested
		                    || be->bind_status == bulist_entry::k_bind_renewing)) {

		boost::system::error_code ec;

		if (pbinfo.status == ip::mproto::pba::status_ok) {
			if (be->bind_status == bulist_entry::k_bind_requested)
				add_route_entries(*be);
		} else {
			ec = boost::system::error_code(pbinfo.status, pba_error_category());
		}

		be->timer.cancel();
		be->handover_delay.stop();

		if (be->bind_status == bulist_entry::k_bind_requested) {
			report_completion(_service, be->completion, ec);
			_log(0, "PBA registration [delay = ", be->handover_delay.get(),
			                        ", id = ", pbinfo.id,
			                        ", cmd = ", pbinfo.address,
			                        ", status = ", pbinfo.status, "]");
		} else {
			_log(0, "PBA re-registration [delay = ", be->handover_delay.get(),
			                           ", id = ", pbinfo.id,
			                           ", cmd = ", pbinfo.address,
			                           ", status = ", pbinfo.status, "]");
		}


		be->bind_status = bulist_entry::k_bind_ack;

		if (pbinfo.status == ip::mproto::pba::status_ok) {
			//Will try to renew 3 seconds before binding expires or 1 second if lifetime <= 6
			uint expire = (pbinfo.lifetime <= 6) ? pbinfo.lifetime - 1 : pbinfo.lifetime - 3; //FIXME Check used values

			be->timer.expires_from_now(boost::posix_time::seconds(expire));
			be->timer.async_wait(_service.wrap(boost::bind(&mag::proxy_binding_renew, this, _1, pbinfo.id)));
		} else {
			_bulist.remove(be);
		}

		delay.stop();
		_log(0, "PBA register process delay ", delay.get());

	} else 	if (!pbinfo.lifetime && be->bind_status == bulist_entry::k_bind_detach) {
		boost::system::error_code ec;

		if (pbinfo.status == ip::mproto::pba::status_ok)
			ec = boost::system::error_code(pbinfo.status, pba_error_category());

		be->timer.cancel();
		be->handover_delay.stop();

		report_completion(_service, be->completion, ec);
		_log(0, "PBA de-registration [delay = ", be->handover_delay.get(),
		                           ", id = ", pbinfo.id,
		                           ", cmd = ", pbinfo.address, "]");

		_bulist.remove(be);

		delay.stop();
		_log(0, "PBA de-register process delay ", delay.get());

	} else {
		_log(0, "PBA ignored [id = ", pbinfo.id, ", cmd = ", pbinfo.address, ", status = ", be->bind_status, "]");
	}
}
int dhcp_packet_parser(unsigned char *data, int data_len, struct dhcp_packet_info *dhcp_info) {
    struct bootp_msg *msg;
    unsigned char *p;
    unsigned char *end;
    int iphdr_len, udphdr_len;
    int dhcp_msg_type = 0;
    unsigned int lease_time = -1;
    int length = 0;
    char hostname[DHCP_HOSTNAME_MAX_LEN] = { 0 };
    unsigned char ifname[6] = {0};
    unsigned char uplink_mac[6] = {0};
    //char ifname_type[3] = "eth";
	
    /* IP header */
    struct iphdr *piphdr = (struct iphdr *)data;
    iphdr_len = piphdr->ihl * 4;

    /* UDP header */
    udphdr_len = sizeof(struct udphdr);

    /* For bootp Application data */
    msg = (struct bootp_msg *)(data + iphdr_len + udphdr_len);
    p = msg->options + 4;   /* offset of magic cookie */
    end = msg->options + sizeof(msg->options);
    /* ****** option structure *****
         * |-opt id-|-length-|-variable value-|
         */
    while (p < end) {
        switch(*p) {
	 case dhcpPrivateOption:
		length = p[1];
		_log(APP_DEBUG, "DHCP message private length: %d",length);
		os_memcpy(uplink_mac, &p[3 + (length - 18)], 6);
	       _log(APP_DEBUG, "nflog packet recv:"MAC_FORMAT, MAC_ADDR(uplink_mac));
		os_memcpy(ifname, &p[10 + (length - 18)], 4);
		_log(APP_DEBUG, "nflog packet recv sta type: %02x %02x %02x %02x", ifname[0], ifname[1], ifname[2], ifname[3]);
	       p += p[1];
	       p += 2;
		break;
        case endOption:
            goto OUT;
        case padOption:
            p++;
            break;
        case dhcpIPaddrLeaseTime:
            if (p[1]){
		#define GET_UINT32(_val) \
			memcpy (&_val, &p[2], sizeof (uint32_t));
		#define GET_UINT32_H(_val) \
			GET_UINT32 (_val); \
			_val = ntohl (_val);
		GET_UINT32_H(lease_time);
	     }
            p += p[1];
            p += 2;
            break;
        case hostName:
            if (p[1])
                os_memcpy(hostname, &p[2], MIN(p[1], DHCP_HOSTNAME_MAX_LEN));
            p += p[1];
            p += 2;
            break;
        case dhcpMessageType:
            if (p[1])
                dhcp_msg_type = p[2];
            p += p[1];
            p += 2;
            break;
        default:
            p += p[1];
            p += 2;
            break;
        }
    }
OUT:
    dhcp_info->dhcp_msg_type = dhcp_msg_type;
    _log(APP_DEBUG, "DHCP message type: %d", dhcp_msg_type);
    switch(dhcp_msg_type) {
    case DHCP_OFFER:
    case DHCP_ACK:     
        if(dhcp_msg_type == DHCP_ACK)
            inet_ntop(AF_INET, &msg->yiaddr, dhcp_info->sta_ip, INET_ADDRSTRLEN);
        dhcp_info->lease_time = lease_time;
        os_memcpy(dhcp_info->sta_mac, msg->chaddr, sizeof(dhcp_info->sta_mac));
        break;
    case DHCP_DISCOVER:
    case DHCP_REQUEST:
    //case DHCP_INFORM:
        inet_ntop(AF_INET, &msg->ciaddr, dhcp_info->sta_ip, INET_ADDRSTRLEN);
        os_memcpy(dhcp_info->sta_mac, msg->chaddr, sizeof(dhcp_info->sta_mac));
        os_memcpy(dhcp_info->sta_hostname, hostname, MIN(sizeof(dhcp_info->sta_hostname), DHCP_HOSTNAME_MAX_LEN));
        os_memcpy(dhcp_info->uplink_mac, uplink_mac, sizeof(dhcp_info->uplink_mac));
        os_memcpy(dhcp_info->ifname, ifname, sizeof(dhcp_info->ifname));
        break;
    case DHCP_RELEASE:
        os_memcpy(dhcp_info->sta_mac, msg->chaddr, sizeof(dhcp_info->sta_mac));
    case DHCP_NAK:
        os_memcpy(dhcp_info->sta_mac, msg->chaddr, sizeof(dhcp_info->sta_mac));
	 break;
    default:
        break;
    }    
    
    return 0;
}
Example #25
0
void bartlby_perf_track(struct service * svc,char * return_buffer, int return_bytes, char * cfgfile) {
	
	struct stat perf_s;
	//char perf_out[2048];
	char * cfg_perf_dir;
	char * perf_trigger;
	char * perf_enabled;
	//int perf_child;
	struct timeval stat_end, stat_start;
	char my_own_handler[1024];
	char * found_my_own;
	
	FILE * phandler;
	char dummy_buffer[1024];
	
	
	//signal(SIGCHLD, SIG_IGN);
	sprintf(my_own_handler, "perfhandler_enabled_%ld", svc->service_id);
	
	
	perf_enabled=getConfigValue("perfhandler_enabled", cfgfile);
	found_my_own=getConfigValue(my_own_handler, cfgfile);
	
	if(perf_enabled == NULL) {
		perf_enabled=strdup("true");
		//sprintf(perf_enabled, "true");
	}
	if(found_my_own == NULL) {
		found_my_own=strdup("false");
		//sprintf(perf_enabled, "true");
	}
	
	if(strcmp(perf_enabled, "false") == 0 && strcmp(found_my_own, "false") == 0)  {
		free(perf_enabled);
		free(found_my_own);
		return;
			
	}
	free(found_my_own);
	free(perf_enabled);
	
	cfg_perf_dir=getConfigValue("performance_dir", cfgfile);
	if(cfg_perf_dir != NULL) {
		CHECKED_ASPRINTF(&perf_trigger, "%s/%s", cfg_perf_dir, svc->plugin);
		if(stat(perf_trigger, &perf_s) < 0) {
			_log(LH_PERF, B_LOG_CRIT,"Performance Trigger: %s not found", perf_trigger);	
		} else {
			free(perf_trigger);
			CHECKED_ASPRINTF(&perf_trigger, "%s/%s %ld %s 2>&1 > /dev/null", cfg_perf_dir, svc->plugin, svc->service_id, return_buffer);

			//FIXME WORKER MODE -> http://www4.informatik.uni-erlangen.de/DE/Lehre/WS01/V_SP1/Uebung/tsh.c block_signal
			signal(SIGPIPE,SIG_DFL);
			signal(SIGCHLD,SIG_DFL);
			gettimeofday(&stat_start,NULL);
			
			
			phandler=popen(perf_trigger, "r");
			if(phandler != NULL) {
				if(fgets(dummy_buffer, 1024, phandler) == NULL) { 
					if(!feof(phandler)) {
						_log(LH_PERF, B_LOG_CRIT,"Performance Trigger: %s fgets failed (%s)", perf_trigger, strerror(errno));	
					}
				}
				pclose(phandler);	
				
			} else {
				_log(LH_PERF, B_LOG_CRIT,"Performance Trigger: %s failed popen", perf_trigger);	
			}
			
			gettimeofday(&stat_end,NULL);
			//_log("@PERF@%d|%s:%d/%s", bartlby_milli_timediff(stat_end,stat_start),svc->server_name,svc->client_port, svc->service_name);
			/*
			switch(perf_child=fork()) {
				case -1:
					_log("fork error");
				break;
				
				case 0:
					gettimeofday(&stat_start,NULL);
					system(perf_trigger);
					gettimeofday(&stat_end,NULL);
					//_log("@PERF@%d|%s:%d/%s", bartlby_milli_timediff(stat_end,stat_start),svc->server_name,svc->client_port, svc->service_name);
					exit(1);
				break;	
				default:
					//_log("Forked perf trigger %s", perf_trigger);
					
				break;
			}
			
			*/
		}
		free(perf_trigger);
		
		free(cfg_perf_dir);	
	}	
	
}
Example #26
0
int main(int, char ** argv) {
		const long double clock1 = clock();
		
		SysLog_t _log(argv[ 0 ]);
		log = &_log;

		try {
				wiki_storage = new WikiStorage_t( WIKI_STORAGE_LOCATION );

		} catch( std::bad_alloc ex ) {
				log->alert("%s", "Memory allocation faild.");
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( std::io_error ex ) {
				log->alert("%s: %s", "InOut error occured", ex.what());
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;				

		} catch( std::invalid_argument ex ) {
				log->alert("%s: %s", "Wrong storage configuration", ex.what());
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( ... ) {
				log->emergency("%s", "main(): unknown exception.");
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;
		}

		try {
				cgi_request::construct( 0 );
				cgi_responde::construct();

				if( strncmp("HTTP", cgi_request::get_server_protocol(), 4) )
						throw std::invalid_argument("There is not supported server protocol.");

				script_name.append(cgi_request::get_script_name());
				server_url.append("http://");
				server_url.append(cgi_request::get_server_name());
				
				if( 80 != atoi(cgi_request::get_server_port()) )
						server_url.append(':').append(cgi_request::get_server_port());

		} catch( std::bad_alloc ex ) {
				log->alert("%s", "Memory allocation faild.");
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( std::invalid_argument ex ) {
				log->emergency("%s: %s", "Wrong script running", ex.what());
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( std::io_error ex ) {
				log->alert("%s: %s", "InOut error occured", ex.what());
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;				

		} catch( std::length_error ex ) {
				log->notice("%s: %s", "Too lagre request", ex.what());
				cgi_responde::send_extra(cgi_responde::status_413_request_entity_too_large);
				return -1;

		} catch( std::logic_error ex ) {
				log->emergency("%s", ex.what());
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( ... ) {
				log->emergency("%s", "main(): unknown exception.");
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;
		}

		try {
#ifndef NDEBUG
				{
						const char * gateway_interface = cgi_request::get_gateway_interface();
						const char * script_name = cgi_request::get_script_name();
						const char * path_info = cgi_request::get_path_info();
						const char * request_method = cgi_request::get_request_method();

						log->debug("%s", util_ctime());
						log->debug("### connection ###");
						log->debug("# cgi input");
						log->debug("  gateway interface: %s", gateway_interface);
						log->debug("  script_name: %s", script_name);
						log->debug("  path_info: %s", path_info ? path_info : "");
						log->debug("  request_method: %s", request_method);
						log->flush();
				}
#endif
				build();
				
#ifndef NDEBUG
				{
						const char * status = cgi_responde::get_status();
						const char * location = cgi_responde::get_location();
						const char * content_type = cgi_responde::get_content_type();

						log->debug("# cgi output");
						log->debug("  status: %s", status ? status : "");
						log->debug("  location: %s", location ? location : "");
						log->debug("  content-type: %s", content_type ? content_type : "");
						log->flush();
				}
#endif

				cgi_responde::send();

		} catch( std::bad_alloc ex ) {
				log->alert("%s", "Memory allocation faild.");
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( std::io_error ex ) {
				log->alert("%s: %s", "InOut error occured", ex.what());
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( const std::invalid_argument ex ) {
				log->warning("%s: %s", "Wrong request", ex.what());
				cgi_responde::send_extra(cgi_responde::status_400_bad_request);
				return -1;

		} catch( const std::out_of_range ex ) {
				log->emergency("%s: %s", "Internal overful", ex.what());
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( std::logic_error ex ) {
				log->emergency("%s: %s", "Incorrect arhitechure", ex.what());
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;

		} catch( ... ) {
				log->emergency("%s", "main(): unknown exception.");
				cgi_responde::send_extra(cgi_responde::status_500_internal_server_error);
				return -1;
		}

		cgi_request::destruct();
		cgi_responde::destruct();
		
		delete wiki_storage;

		const long double clock2 = clock();

		util_printf("\r\n<!-- clock: %.3Lf -->", (clock2 - clock1) / CLOCKS_PER_SEC);

		return 0;
}
static NPObject *certAllocate(NPP npp, NPClass *theClass) {
    _log("");
    return new CertInstance;
}
Example #28
0
bool EVENotificationStream::Decode(const std::string &pkt_type, const std::string &notify_type, PyTuple *&in_payload) {
    PyTuple *payload = in_payload;   //consume
    in_payload = NULL;

    PySafeDecRef(args);
    args = NULL;

    if(pkt_type != "macho.Notification") {
        codelog(NET__PACKET_ERROR, "notification payload has unknown string type %s", pkt_type.c_str());
        PyDecRef(payload);
        return false;
    }

    //decode payload tuple
    if(payload->items.size() != 2) {
        codelog(NET__PACKET_ERROR, "invalid tuple length %lu", payload->items.size());
        PyDecRef(payload);
        return false;
    }
    if(!payload->items[0]->IsTuple()) {
        codelog(NET__PACKET_ERROR, "non-tuple payload[0]");
        PyDecRef(payload);
        return false;
    }
    PyTuple *payload2 = (PyTuple *) payload->items[0];
    if(payload2->items.size() != 2) {
        codelog(NET__PACKET_ERROR, "invalid tuple2 length %lu", payload2->items.size());
        PyDecRef(payload);
        return false;
    }

    //decode inner payload tuple
    //ignore tuple 0, it should be an int, dont know what it is
    if(!payload2->items[1]->IsSubStream()) {
        codelog(NET__PACKET_ERROR, "non-substream type");
        PyDecRef(payload);
        return false;
    }
    PySubStream *ss = (PySubStream *) payload2->items[1];

    ss->DecodeData();
    if(ss->decoded() == NULL) {
        codelog(NET__PACKET_ERROR, "Unable to decode call stream");
        PyDecRef(payload);
        return false;
    }

    if(!ss->decoded()->IsTuple()) {
        codelog(NET__PACKET_ERROR, "packet body does not contain a tuple");
        PyDecRef(payload);
        return false;
    }

    PyTuple *robjt = (PyTuple *) ss->decoded();
    if(robjt->items.size() != 2) {
        codelog(NET__PACKET_ERROR, "packet body has %lu elements, expected %d", robjt->items.size(), 2);
        PyDecRef(payload);
        return false;
    }

    //parse first tuple element, remote object
    if(robjt->items[0]->IsInt()) {
        PyInt *tuple0 = (PyInt *) robjt->items[0];
        remoteObject = tuple0->value();
        remoteObjectStr = "";
    } else if(robjt->items[0]->IsString()) {
        PyString *tuple0 = (PyString *) robjt->items[0];
        remoteObject = 0;
        remoteObjectStr = tuple0->content();
    } else {
        codelog(NET__PACKET_ERROR, "main tuple[0] has invalid type %s", robjt->items[0]->TypeString());
        _log(NET__PACKET_ERROR, " in:");
        payload->Dump( NET__PACKET_ERROR, "" );
        PyDecRef(payload);
        return false;
    }

    if(!robjt->items[1]->IsTuple()) {
        codelog(NET__PACKET_ERROR, "main tuple[1] has non-tuple type %s", robjt->items[0]->TypeString());
        _log(NET__PACKET_ERROR, " it is:");
        payload->Dump( NET__PACKET_ERROR, "" );
        PyDecRef(payload);
        return false;
    }



    PyTuple *subt = (PyTuple *) robjt->items[1];
    if(subt->items.size() != 2) {
        codelog(NET__PACKET_ERROR, "packet body has %lu elements, expected %d", subt->items.size(), 2);
        PyDecRef(payload);
        return false;
    }

    //parse first tuple element, remote object
    if(subt->items[0]->IsInt()) {
        //PyInt *tuple0 = (PyInt *) maint->items[0];
        //no idea what this is.
    } else {
        codelog(NET__PACKET_ERROR, "sub tuple[0] has invalid type %s", subt->items[0]->TypeString());
        _log(NET__PACKET_ERROR, " in:");
        payload->Dump( NET__PACKET_ERROR, "" );
        PyDecRef(payload);
        return false;
    }



    if(!subt->items[1]->IsTuple()) {
        codelog(NET__PACKET_ERROR, "subt tuple[1] has non-tuple type %s", robjt->items[0]->TypeString());
        _log(NET__PACKET_ERROR, " it is:");
        payload->Dump( NET__PACKET_ERROR, "" );
        PyDecRef(payload);
        return false;
    }

    args = (PyTuple *) subt->items[1];
    subt->items[1] = NULL;

    notifyType = notify_type;

    PyDecRef(payload);
    return true;
}
static void certInvalidate(NPObject *obj) {
    _log("");
}
Example #30
0
extern "C" CK_DECLARE_FUNCTION(CK_RV,C_GenerateKeyPair(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_ATTRIBUTE_PTR pPublicKeyTemplate, CK_ULONG ulPublicKeyAttributeCount, CK_ATTRIBUTE_PTR pPrivateKeyTemplate, CK_ULONG ulPrivateKeyAttributeCount, CK_OBJECT_HANDLE_PTR phPublicKey, CK_OBJECT_HANDLE_PTR phPrivateKey))
{
  _log("RETURNING CKR_FUNCTION_NOT_SUPPORTED");
	return CKR_FUNCTION_NOT_SUPPORTED;
}