[12062] Cleanup MaNGOS sources

This commit is contained in:
Schmoozerd 2012-07-19 22:03:32 +02:00
parent a4cbed3199
commit aeff8f9d1a
46 changed files with 1982 additions and 1864 deletions

View file

@ -65,7 +65,7 @@ bool ChatHandler::HandleDebugSendSpellFailCommand(char* args)
bool ChatHandler::HandleDebugSendPoiCommand(char* args) bool ChatHandler::HandleDebugSendPoiCommand(char* args)
{ {
Player *pPlayer = m_session->GetPlayer(); Player* pPlayer = m_session->GetPlayer();
Unit* target = getSelectedUnit(); Unit* target = getSelectedUnit();
if (!target) if (!target)
{ {
@ -118,7 +118,7 @@ bool ChatHandler::HandleDebugSendBuyErrorCommand(char* args)
bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/) bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
{ {
Unit *unit = getSelectedUnit(); Unit* unit = getSelectedUnit();
if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
unit = m_session->GetPlayer(); unit = m_session->GetPlayer();
@ -131,51 +131,51 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
WorldPacket data(opcode, 0); WorldPacket data(opcode, 0);
while(!ifs.eof()) while (!ifs.eof())
{ {
std::string type; std::string type;
ifs >> type; ifs >> type;
if(type == "") if (type == "")
break; break;
if(type == "uint8") if (type == "uint8")
{ {
uint16 val1; uint16 val1;
ifs >> val1; ifs >> val1;
data << uint8(val1); data << uint8(val1);
} }
else if(type == "uint16") else if (type == "uint16")
{ {
uint16 val2; uint16 val2;
ifs >> val2; ifs >> val2;
data << val2; data << val2;
} }
else if(type == "uint32") else if (type == "uint32")
{ {
uint32 val3; uint32 val3;
ifs >> val3; ifs >> val3;
data << val3; data << val3;
} }
else if(type == "uint64") else if (type == "uint64")
{ {
uint64 val4; uint64 val4;
ifs >> val4; ifs >> val4;
data << val4; data << val4;
} }
else if(type == "float") else if (type == "float")
{ {
float val5; float val5;
ifs >> val5; ifs >> val5;
data << val5; data << val5;
} }
else if(type == "string") else if (type == "string")
{ {
std::string val6; std::string val6;
ifs >> val6; ifs >> val6;
data << val6; data << val6;
} }
else if(type == "pguid") else if (type == "pguid")
{ {
data << unit->GetPackGUID(); data << unit->GetPackGUID();
} }
@ -281,7 +281,7 @@ bool ChatHandler::HandleDebugPlaySoundCommand(char* args)
//Send notification in channel //Send notification in channel
bool ChatHandler::HandleDebugSendChannelNotifyCommand(char* args) bool ChatHandler::HandleDebugSendChannelNotifyCommand(char* args)
{ {
const char *name = "test"; const char* name = "test";
uint32 code; uint32 code;
if (!ExtractUInt32(&args, code) || code > 255) if (!ExtractUInt32(&args, code) || code > 255)
@ -299,7 +299,7 @@ bool ChatHandler::HandleDebugSendChannelNotifyCommand(char* args)
//Send notification in chat //Send notification in chat
bool ChatHandler::HandleDebugSendChatMsgCommand(char* args) bool ChatHandler::HandleDebugSendChatMsgCommand(char* args)
{ {
const char *msg = "testtest"; const char* msg = "testtest";
uint32 type; uint32 type;
if (!ExtractUInt32(&args, type) || type > 255) if (!ExtractUInt32(&args, type) || type > 255)
@ -329,7 +329,7 @@ bool ChatHandler::HandleDebugGetLootRecipientCommand(char* /*args*/)
if (!target->HasLootRecipient()) if (!target->HasLootRecipient())
SendSysMessage("loot recipient: no loot recipient"); SendSysMessage("loot recipient: no loot recipient");
else if(Player* recipient = target->GetLootRecipient()) else if (Player* recipient = target->GetLootRecipient())
PSendSysMessage("loot recipient: %s with raw data %s from group %u", PSendSysMessage("loot recipient: %s with raw data %s from group %u",
recipient->GetGuidStr().c_str(), recipient->GetGuidStr().c_str(),
target->GetLootRecipientGuid().GetString().c_str(), target->GetLootRecipientGuid().GetString().c_str(),
@ -393,10 +393,10 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
SendSysMessage(state_str.c_str()); SendSysMessage(state_str.c_str());
for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
{ {
if(i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
continue; continue;
Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item) continue; if (!item) continue;
if (!item->IsBag()) if (!item->IsBag())
{ {
@ -406,7 +406,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
} }
else else
{ {
Bag *bag = (Bag*)item; Bag* bag = (Bag*)item;
for (uint8 j = 0; j < bag->GetBagSize(); ++j) for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{ {
Item* item2 = bag->GetItemByPos(j); Item* item2 = bag->GetItemByPos(j);
@ -421,17 +421,17 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
if (list_queue) if (list_queue)
{ {
std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
for(size_t i = 0; i < updateQueue.size(); ++i) for (size_t i = 0; i < updateQueue.size(); ++i)
{ {
Item *item = updateQueue[i]; Item* item = updateQueue[i];
if(!item) continue; if (!item) continue;
Bag *container = item->GetContainer(); Bag* container = item->GetContainer();
uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0); uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0);
std::string st; std::string st;
switch(item->GetState()) switch (item->GetState())
{ {
case ITEM_UNCHANGED: st = "unchanged"; break; case ITEM_UNCHANGED: st = "unchanged"; break;
case ITEM_CHANGED: st = "changed"; break; case ITEM_CHANGED: st = "changed"; break;
@ -449,13 +449,13 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
if (check_all) if (check_all)
{ {
bool error = false; bool error = false;
std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
{ {
if(i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
continue; continue;
Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item) continue; if (!item) continue;
if (item->GetSlot() != i) if (item->GetSlot() != i)
@ -473,7 +473,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
error = true; continue; error = true; continue;
} }
if (Bag *container = item->GetContainer()) if (Bag* container = item->GetContainer())
{ {
PSendSysMessage("%s at slot %u has a container %s from slot %u but shouldnt!", PSendSysMessage("%s at slot %u has a container %s from slot %u but shouldnt!",
item->GetGuidStr().c_str(), item->GetSlot(), item->GetGuidStr().c_str(), item->GetSlot(),
@ -513,9 +513,9 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
error = true; continue; error = true; continue;
} }
if(item->IsBag()) if (item->IsBag())
{ {
Bag *bag = (Bag*)item; Bag* bag = (Bag*)item;
for (uint8 j = 0; j < bag->GetBagSize(); ++j) for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{ {
Item* item2 = bag->GetItemByPos(j); Item* item2 = bag->GetItemByPos(j);
@ -536,7 +536,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
error = true; continue; error = true; continue;
} }
Bag *container = item2->GetContainer(); Bag* container = item2->GetContainer();
if (!container) if (!container)
{ {
PSendSysMessage("%s in bag %u at slot %u has no container!", PSendSysMessage("%s in bag %u at slot %u has no container!",
@ -587,10 +587,10 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
} }
} }
for(size_t i = 0; i < updateQueue.size(); ++i) for (size_t i = 0; i < updateQueue.size(); ++i)
{ {
Item *item = updateQueue[i]; Item* item = updateQueue[i];
if(!item) continue; if (!item) continue;
if (item->GetOwnerGuid() != player->GetObjectGuid()) if (item->GetOwnerGuid() != player->GetObjectGuid())
{ {
@ -608,7 +608,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
} }
if (item->GetState() == ITEM_REMOVED) continue; if (item->GetState() == ITEM_REMOVED) continue;
Item *test = player->GetItemByPos( item->GetBagSlot(), item->GetSlot()); Item* test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot());
if (test == NULL) if (test == NULL)
{ {
@ -646,7 +646,7 @@ bool ChatHandler::HandleDebugArenaCommand(char* /*args*/)
bool ChatHandler::HandleDebugSpellCheckCommand(char* /*args*/) bool ChatHandler::HandleDebugSpellCheckCommand(char* /*args*/)
{ {
sLog.outString( "Check expected in code spell properties base at table 'spell_check' content..."); sLog.outString("Check expected in code spell properties base at table 'spell_check' content...");
sSpellMgr.CheckUsedSpells("spell_check"); sSpellMgr.CheckUsedSpells("spell_check");
return true; return true;
} }
@ -655,7 +655,7 @@ bool ChatHandler::HandleDebugSendLargePacketCommand(char* /*args*/)
{ {
const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. "; const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. ";
std::ostringstream ss; std::ostringstream ss;
while(ss.str().size() < 128000) while (ss.str().size() < 128000)
ss << stuffingString; ss << stuffingString;
SendSysMessage(ss.str().c_str()); SendSysMessage(ss.str().c_str());
return true; return true;
@ -699,7 +699,7 @@ bool ChatHandler::HandleDebugSetAuraStateCommand(char* args)
if (!state) if (!state)
{ {
// reset all states // reset all states
for(int i = 1; i <= 32; ++i) for (int i = 1; i <= 32; ++i)
unit->ModifyAuraState(AuraState(i),false); unit->ModifyAuraState(AuraState(i),false);
return true; return true;
} }
@ -733,7 +733,7 @@ bool ChatHandler::HandleSetValueHelper(Object* target, uint32 field, char* typeS
else else
return false; return false;
if(base) if (base)
{ {
uint32 iValue; uint32 iValue;
if (!ExtractUInt32Base(&valStr, iValue, base)) if (!ExtractUInt32Base(&valStr, iValue, base))
@ -750,7 +750,7 @@ bool ChatHandler::HandleSetValueHelper(Object* target, uint32 field, char* typeS
return false; return false;
DEBUG_LOG(GetMangosString(LANG_SET_FLOAT), guid.GetString().c_str(), field, fValue); DEBUG_LOG(GetMangosString(LANG_SET_FLOAT), guid.GetString().c_str(), field, fValue);
target->SetFloatValue(field , fValue ); target->SetFloatValue(field , fValue);
PSendSysMessage(LANG_SET_FLOAT_FIELD, guid.GetString().c_str(), field, fValue); PSendSysMessage(LANG_SET_FLOAT_FIELD, guid.GetString().c_str(), field, fValue);
} }
@ -775,7 +775,7 @@ bool ChatHandler::HandleDebugSetItemValueCommand(char* args)
if (!valStr) if (!valStr)
return false; return false;
Item *item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid)); Item* item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid));
if (!item) if (!item)
return false; return false;
@ -785,7 +785,7 @@ bool ChatHandler::HandleDebugSetItemValueCommand(char* args)
bool ChatHandler::HandleDebugSetValueCommand(char* args) bool ChatHandler::HandleDebugSetValueCommand(char* args)
{ {
Unit* target = getSelectedUnit(); Unit* target = getSelectedUnit();
if(!target) if (!target)
{ {
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -835,7 +835,7 @@ bool ChatHandler::HandleGetValueHelper(Object* target, uint32 field, char* typeS
{ {
uint32 iValue = target->GetUInt32Value(field); uint32 iValue = target->GetUInt32Value(field);
switch(base) switch (base)
{ {
case 2: case 2:
{ {
@ -893,7 +893,7 @@ bool ChatHandler::HandleDebugGetItemValueCommand(char* args)
bool ChatHandler::HandleDebugGetValueCommand(char* args) bool ChatHandler::HandleDebugGetValueCommand(char* args)
{ {
Unit* target = getSelectedUnit(); Unit* target = getSelectedUnit();
if(!target) if (!target)
{ {
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -911,7 +911,7 @@ bool ChatHandler::HandleDebugGetValueCommand(char* args)
return HandleGetValueHelper(target, field, typeStr); return HandleGetValueHelper(target, field, typeStr);
} }
bool ChatHandler::HandlerDebugModValueHelper( Object* target, uint32 field, char* typeStr, char* valStr ) bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char* typeStr, char* valStr)
{ {
ObjectGuid guid = target->GetObjectGuid(); ObjectGuid guid = target->GetObjectGuid();
@ -944,7 +944,7 @@ bool ChatHandler::HandlerDebugModValueHelper( Object* target, uint32 field, char
uint32 value = target->GetUInt32Value(field); uint32 value = target->GetUInt32Value(field);
switch(type) switch (type)
{ {
default: default:
case 1: // int + case 1: // int +
@ -1008,7 +1008,7 @@ bool ChatHandler::HandleDebugModItemValueCommand(char* args)
if (!valStr) if (!valStr)
return false; return false;
Item *item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid)); Item* item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid));
if (!item) if (!item)
return false; return false;
@ -1018,7 +1018,7 @@ bool ChatHandler::HandleDebugModItemValueCommand(char* args)
bool ChatHandler::HandleDebugModValueCommand(char* args) bool ChatHandler::HandleDebugModValueCommand(char* args)
{ {
Unit* target = getSelectedUnit(); Unit* target = getSelectedUnit();
if(!target) if (!target)
{ {
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1046,7 +1046,7 @@ bool ChatHandler::HandleDebugSpellCoefsCommand(char* args)
if (!spellid) if (!spellid)
return false; return false;
SpellEntry const * spellEntry = sSpellStore.LookupEntry(spellid); SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellid);
if (!spellEntry) if (!spellEntry)
return false; return false;
@ -1056,11 +1056,11 @@ bool ChatHandler::HandleDebugSpellCoefsCommand(char* args)
float dot_calc = CalculateDefaultCoefficient(spellEntry, DOT); float dot_calc = CalculateDefaultCoefficient(spellEntry, DOT);
bool isDirectHeal = false; bool isDirectHeal = false;
for(int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
// Heals (Also count Mana Shield and Absorb effects as heals) // Heals (Also count Mana Shield and Absorb effects as heals)
if (spellEntry->Effect[i] == SPELL_EFFECT_HEAL || spellEntry->Effect[i] == SPELL_EFFECT_HEAL_MAX_HEALTH || if (spellEntry->Effect[i] == SPELL_EFFECT_HEAL || spellEntry->Effect[i] == SPELL_EFFECT_HEAL_MAX_HEALTH ||
(spellEntry->Effect[i] == SPELL_EFFECT_APPLY_AURA && (spellEntry->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_ABSORB || spellEntry->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_HEAL)) ) (spellEntry->Effect[i] == SPELL_EFFECT_APPLY_AURA && (spellEntry->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_ABSORB || spellEntry->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_HEAL)))
{ {
isDirectHeal = true; isDirectHeal = true;
break; break;
@ -1068,7 +1068,7 @@ bool ChatHandler::HandleDebugSpellCoefsCommand(char* args)
} }
bool isDotHeal = false; bool isDotHeal = false;
for(int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
// Periodic Heals // Periodic Heals
if (spellEntry->Effect[i] == SPELL_EFFECT_APPLY_AURA && spellEntry->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_HEAL) if (spellEntry->Effect[i] == SPELL_EFFECT_APPLY_AURA && spellEntry->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_HEAL)
@ -1117,7 +1117,7 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args)
if (!ExtractInt32(&args, value)) if (!ExtractInt32(&args, value))
return false; return false;
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);

View file

@ -39,7 +39,7 @@ void utf8print(void* arg, const char* str)
#if PLATFORM == PLATFORM_WINDOWS #if PLATFORM == PLATFORM_WINDOWS
wchar_t wtemp_buf[6000]; wchar_t wtemp_buf[6000];
size_t wtemp_len = 6000-1; size_t wtemp_len = 6000-1;
if(!Utf8toWStr(str,strlen(str),wtemp_buf,wtemp_len)) if (!Utf8toWStr(str,strlen(str),wtemp_buf,wtemp_len))
return; return;
char temp_buf[6000]; char temp_buf[6000];
@ -71,11 +71,11 @@ bool ChatHandler::HandleAccountDeleteCommand(char* args)
/// Commands not recommended call from chat, but support anyway /// Commands not recommended call from chat, but support anyway
/// can delete only for account with less security /// can delete only for account with less security
/// This is also reject self apply in fact /// This is also reject self apply in fact
if (HasLowerSecurityAccount (NULL, account_id, true)) if (HasLowerSecurityAccount(NULL, account_id, true))
return false; return false;
AccountOpResult result = sAccountMgr.DeleteAccount(account_id); AccountOpResult result = sAccountMgr.DeleteAccount(account_id);
switch(result) switch (result)
{ {
case AOR_OK: case AOR_OK:
PSendSysMessage(LANG_ACCOUNT_DELETED,account_name.c_str()); PSendSysMessage(LANG_ACCOUNT_DELETED,account_name.c_str());
@ -115,7 +115,7 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::s
// search by name // search by name
else else
{ {
if(!normalizePlayerName(searchString)) if (!normalizePlayerName(searchString))
return false; return false;
resultChar = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND deleteInfos_Name " _LIKE_ " " _CONCAT3_("'%%'", "'%s'", "'%%'"), searchString.c_str()); resultChar = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND deleteInfos_Name " _LIKE_ " " _CONCAT3_("'%%'", "'%s'", "'%%'"), searchString.c_str());
@ -137,12 +137,13 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::s
info.accountId = fields[2].GetUInt32(); info.accountId = fields[2].GetUInt32();
// account name will be empty for nonexistent account // account name will be empty for nonexistent account
sAccountMgr.GetName (info.accountId, info.accountName); sAccountMgr.GetName(info.accountId, info.accountName);
info.deleteDate = time_t(fields[3].GetUInt64()); info.deleteDate = time_t(fields[3].GetUInt64());
foundList.push_back(info); foundList.push_back(info);
} while (resultChar->NextRow()); }
while (resultChar->NextRow());
delete resultChar; delete resultChar;
} }
@ -161,7 +162,7 @@ std::string ChatHandler::GenerateDeletedCharacterGUIDsWhereStr(DeletedInfoList::
{ {
std::ostringstream wherestr; std::ostringstream wherestr;
wherestr << "guid IN ('"; wherestr << "guid IN ('";
for(; itr != itr_end; ++itr) for (; itr != itr_end; ++itr)
{ {
wherestr << itr->lowguid; wherestr << itr->lowguid;
@ -172,7 +173,7 @@ std::string ChatHandler::GenerateDeletedCharacterGUIDsWhereStr(DeletedInfoList::
} }
DeletedInfoList::const_iterator itr2 = itr; DeletedInfoList::const_iterator itr2 = itr;
if(++itr2 != itr_end) if (++itr2 != itr_end)
wherestr << "','"; wherestr << "','";
} }
wherestr << "')"; wherestr << "')";
@ -334,7 +335,7 @@ bool ChatHandler::HandleCharacterDeletedRestoreCommand(char* args)
if (newAccount && newAccount != delInfo.accountId) if (newAccount && newAccount != delInfo.accountId)
{ {
delInfo.accountId = newAccount; delInfo.accountId = newAccount;
sAccountMgr.GetName (newAccount, delInfo.accountName); sAccountMgr.GetName(newAccount, delInfo.accountName);
} }
HandleCharacterDeletedRestoreHelper(delInfo); HandleCharacterDeletedRestoreHelper(delInfo);
@ -375,7 +376,7 @@ bool ChatHandler::HandleCharacterDeletedDeleteCommand(char* args)
HandleCharacterDeletedListHelper(foundList); HandleCharacterDeletedListHelper(foundList);
// Call the appropriate function to delete them (current account for deleted characters is 0) // Call the appropriate function to delete them (current account for deleted characters is 0)
for(DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr) for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
Player::DeleteFromDB(ObjectGuid(HIGHGUID_PLAYER, itr->lowguid), 0, false, true); Player::DeleteFromDB(ObjectGuid(HIGHGUID_PLAYER, itr->lowguid), 0, false, true);
return true; return true;
@ -429,7 +430,7 @@ bool ChatHandler::HandleCharacterEraseCommand(char* args)
account_id = sObjectMgr.GetPlayerAccountIdByGUID(target_guid); account_id = sObjectMgr.GetPlayerAccountIdByGUID(target_guid);
std::string account_name; std::string account_name;
sAccountMgr.GetName (account_id,account_name); sAccountMgr.GetName(account_id,account_name);
Player::DeleteFromDB(target_guid, account_id, true, true); Player::DeleteFromDB(target_guid, account_id, true, true);
PSendSysMessage(LANG_CHARACTER_DELETED, target_name.c_str(), target_guid.GetCounter(), account_name.c_str(), account_id); PSendSysMessage(LANG_CHARACTER_DELETED, target_name.c_str(), target_guid.GetCounter(), account_name.c_str(), account_id);
@ -461,7 +462,7 @@ bool ChatHandler::HandleAccountOnlineListCommand(char* args)
///- Get the list of accounts ID logged to the realm ///- Get the list of accounts ID logged to the realm
// 0 1 2 3 4 // 0 1 2 3 4
QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE active_realm_id = %u", realmID); QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE active_realm_id = %u", realmID);
return ShowAccountListHelper(result,&limit); return ShowAccountListHelper(result,&limit);
} }
@ -470,9 +471,9 @@ bool ChatHandler::HandleAccountOnlineListCommand(char* args)
bool ChatHandler::HandleAccountCreateCommand(char* args) bool ChatHandler::HandleAccountCreateCommand(char* args)
{ {
///- %Parse the command line arguments ///- %Parse the command line arguments
char *szAcc = ExtractQuotedOrLiteralArg(&args); char* szAcc = ExtractQuotedOrLiteralArg(&args);
char *szPassword = ExtractQuotedOrLiteralArg(&args); char* szPassword = ExtractQuotedOrLiteralArg(&args);
if(!szAcc || !szPassword) if (!szAcc || !szPassword)
return false; return false;
// normalized in accmgr.CreateAccount // normalized in accmgr.CreateAccount
@ -480,7 +481,7 @@ bool ChatHandler::HandleAccountCreateCommand(char* args)
std::string password = szPassword; std::string password = szPassword;
AccountOpResult result = sAccountMgr.CreateAccount(account_name, password); AccountOpResult result = sAccountMgr.CreateAccount(account_name, password);
switch(result) switch (result)
{ {
case AOR_OK: case AOR_OK:
PSendSysMessage(LANG_ACCOUNT_CREATED,account_name.c_str()); PSendSysMessage(LANG_ACCOUNT_CREATED,account_name.c_str());
@ -512,13 +513,13 @@ bool ChatHandler::HandleServerLogFilterCommand(char* args)
if (!*args) if (!*args)
{ {
SendSysMessage(LANG_LOG_FILTERS_STATE_HEADER); SendSysMessage(LANG_LOG_FILTERS_STATE_HEADER);
for(int i = 0; i < LOG_FILTER_COUNT; ++i) for (int i = 0; i < LOG_FILTER_COUNT; ++i)
if (*logFilterData[i].name) if (*logFilterData[i].name)
PSendSysMessage(" %-20s = %s",logFilterData[i].name, GetOnOffStr(sLog.HasLogFilter(1 << i))); PSendSysMessage(" %-20s = %s",logFilterData[i].name, GetOnOffStr(sLog.HasLogFilter(1 << i)));
return true; return true;
} }
char *filtername = ExtractLiteralArg(&args); char* filtername = ExtractLiteralArg(&args);
if (!filtername) if (!filtername)
return false; return false;
@ -537,7 +538,7 @@ bool ChatHandler::HandleServerLogFilterCommand(char* args)
return true; return true;
} }
for(int i = 0; i < LOG_FILTER_COUNT; ++i) for (int i = 0; i < LOG_FILTER_COUNT; ++i)
{ {
if (!*logFilterData[i].name) if (!*logFilterData[i].name)
continue; continue;
@ -554,7 +555,7 @@ bool ChatHandler::HandleServerLogFilterCommand(char* args)
} }
/// Set the level of logging /// Set the level of logging
bool ChatHandler::HandleServerLogLevelCommand(char *args) bool ChatHandler::HandleServerLogLevelCommand(char* args)
{ {
if (!*args) if (!*args)
{ {
@ -605,32 +606,32 @@ void CliRunnable::run()
while (!World::IsStopped()) while (!World::IsStopped())
{ {
fflush(stdout); fflush(stdout);
#ifdef linux #ifdef linux
while (!kb_hit_return() && !World::IsStopped()) while (!kb_hit_return() && !World::IsStopped())
// With this, we limit CLI to 10commands/second // With this, we limit CLI to 10commands/second
usleep(100); usleep(100);
if (World::IsStopped()) if (World::IsStopped())
break; break;
#endif #endif
char *command_str = fgets(commandbuf,sizeof(commandbuf),stdin); char* command_str = fgets(commandbuf,sizeof(commandbuf),stdin);
if (command_str != NULL) if (command_str != NULL)
{ {
for(int x=0;command_str[x];x++) for (int x=0; command_str[x]; x++)
if(command_str[x]=='\r'||command_str[x]=='\n') if (command_str[x]=='\r'||command_str[x]=='\n')
{ {
command_str[x]=0; command_str[x]=0;
break; break;
} }
if(!*command_str) if (!*command_str)
{ {
printf("mangos>"); printf("mangos>");
continue; continue;
} }
std::string command; std::string command;
if(!consoleToUtf8(command_str,command)) // convert from console encoding to utf8 if (!consoleToUtf8(command_str,command)) // convert from console encoding to utf8
{ {
printf("mangos>"); printf("mangos>");
continue; continue;

View file

@ -24,7 +24,7 @@ void MaNGOSsoapRunnable::run()
{ {
// create pool // create pool
SOAPWorkingThread pool; SOAPWorkingThread pool;
pool.activate (THR_NEW_LWP | THR_JOINABLE, POOL_SIZE); pool.activate(THR_NEW_LWP | THR_JOINABLE, POOL_SIZE);
struct soap soap; struct soap soap;
int m, s; int m, s;
@ -46,7 +46,7 @@ void MaNGOSsoapRunnable::run()
sLog.outString("MaNGOSsoap: bound to http://%s:%d", m_host.c_str(), m_port); sLog.outString("MaNGOSsoap: bound to http://%s:%d", m_host.c_str(), m_port);
while(!World::IsStopped()) while (!World::IsStopped())
{ {
s = soap_accept(&soap); s = soap_accept(&soap);
@ -59,23 +59,23 @@ void MaNGOSsoapRunnable::run()
DEBUG_LOG("MaNGOSsoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF); DEBUG_LOG("MaNGOSsoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF);
struct soap* thread_soap = soap_copy(&soap);// make a safe copy struct soap* thread_soap = soap_copy(&soap);// make a safe copy
ACE_Message_Block *mb = new ACE_Message_Block(sizeof(struct soap*)); ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*));
ACE_OS::memcpy (mb->wr_ptr (), &thread_soap, sizeof(struct soap*)); ACE_OS::memcpy(mb->wr_ptr(), &thread_soap, sizeof(struct soap*));
pool.putq(mb); pool.putq(mb);
} }
pool.msg_queue ()->deactivate (); pool.msg_queue()->deactivate();
pool.wait (); pool.wait();
soap_done(&soap); soap_done(&soap);
} }
void SOAPWorkingThread::process_message (ACE_Message_Block *mb) void SOAPWorkingThread::process_message(ACE_Message_Block* mb)
{ {
ACE_TRACE (ACE_TEXT ("SOAPWorkingThread::process_message")); ACE_TRACE(ACE_TEXT("SOAPWorkingThread::process_message"));
struct soap* soap; struct soap* soap;
ACE_OS::memcpy (&soap, mb->rd_ptr (), sizeof(struct soap*)); ACE_OS::memcpy(&soap, mb->rd_ptr(), sizeof(struct soap*));
mb->release (); mb->release();
soap_serve(soap); soap_serve(soap);
soap_destroy(soap); // dealloc C++ data soap_destroy(soap); // dealloc C++ data
@ -98,25 +98,25 @@ int ns1__executeCommand(soap* soap, char* command, char** result)
} }
uint32 accountId = sAccountMgr.GetId(soap->userid); uint32 accountId = sAccountMgr.GetId(soap->userid);
if(!accountId) if (!accountId)
{ {
DEBUG_LOG("MaNGOSsoap: Client used invalid username '%s'", soap->userid); DEBUG_LOG("MaNGOSsoap: Client used invalid username '%s'", soap->userid);
return 401; return 401;
} }
if(!sAccountMgr.CheckPassword(accountId, soap->passwd)) if (!sAccountMgr.CheckPassword(accountId, soap->passwd))
{ {
DEBUG_LOG("MaNGOSsoap: invalid password for account '%s'", soap->userid); DEBUG_LOG("MaNGOSsoap: invalid password for account '%s'", soap->userid);
return 401; return 401;
} }
if(sAccountMgr.GetSecurity(accountId) < SEC_ADMINISTRATOR) if (sAccountMgr.GetSecurity(accountId) < SEC_ADMINISTRATOR)
{ {
DEBUG_LOG("MaNGOSsoap: %s's gmlevel is too low", soap->userid); DEBUG_LOG("MaNGOSsoap: %s's gmlevel is too low", soap->userid);
return 403; return 403;
} }
if(!command || !*command) if (!command || !*command)
return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string"); return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string");
DEBUG_LOG("MaNGOSsoap: got command '%s'", command); DEBUG_LOG("MaNGOSsoap: got command '%s'", command);
@ -132,7 +132,7 @@ int ns1__executeCommand(soap* soap, char* command, char** result)
// wait for callback to complete command // wait for callback to complete command
int acc = connection.pendingCommands.acquire(); int acc = connection.pendingCommands.acquire();
if(acc) if (acc)
{ {
sLog.outError("MaNGOSsoap: Error while acquiring lock, acc = %i, errno = %u", acc, errno); sLog.outError("MaNGOSsoap: Error while acquiring lock, acc = %i, errno = %u", acc, errno);
} }
@ -140,7 +140,7 @@ int ns1__executeCommand(soap* soap, char* command, char** result)
// alright, command finished // alright, command finished
char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str()); char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str());
if(connection.hasCommandSucceeded()) if (connection.hasCommandSucceeded())
{ {
*result = printBuffer; *result = printBuffer;
return SOAP_OK; return SOAP_OK;
@ -164,7 +164,8 @@ void SOAPCommand::commandFinished(void* soapconnection, bool success)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
struct Namespace namespaces[] = struct Namespace namespaces[] =
{ { "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" }, // must be first {
{ "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" }, // must be first
{ "SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/" }, // must be second { "SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/" }, // must be second
{ "xsi", "http://www.w3.org/1999/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance" }, { "xsi", "http://www.w3.org/1999/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance" },
{ "xsd", "http://www.w3.org/1999/XMLSchema", "http://www.w3.org/*/XMLSchema" }, { "xsd", "http://www.w3.org/1999/XMLSchema", "http://www.w3.org/*/XMLSchema" },

View file

@ -49,29 +49,29 @@ class MaNGOSsoapRunnable: public ACE_Based::Runnable
class SOAPWorkingThread : public ACE_Task<ACE_MT_SYNCH> class SOAPWorkingThread : public ACE_Task<ACE_MT_SYNCH>
{ {
public: public:
SOAPWorkingThread () SOAPWorkingThread()
{ } { }
virtual int svc (void) virtual int svc(void)
{ {
while (1) while (1)
{ {
ACE_Message_Block *mb = 0; ACE_Message_Block* mb = 0;
if (this->getq (mb) == -1) if (this->getq(mb) == -1)
{ {
ACE_DEBUG ((LM_INFO, ACE_DEBUG((LM_INFO,
ACE_TEXT ("(%t) Shutting down\n"))); ACE_TEXT("(%t) Shutting down\n")));
break; break;
} }
// Process the message. // Process the message.
process_message (mb); process_message(mb);
} }
return 0; return 0;
} }
private: private:
void process_message (ACE_Message_Block *mb); void process_message(ACE_Message_Block* mb);
}; };

View file

@ -58,33 +58,33 @@ DatabaseType LoginDatabase; ///< Accessor to the
uint32 realmID; ///< Id of the realm uint32 realmID; ///< Id of the realm
/// Print out the usage string for this program on the console. /// Print out the usage string for this program on the console.
void usage(const char *prog) void usage(const char* prog)
{ {
sLog.outString("Usage: \n %s [<options>]\n" sLog.outString("Usage: \n %s [<options>]\n"
" -v, --version print version and exist\n\r" " -v, --version print version and exist\n\r"
" -c config_file use config_file as configuration file\n\r" " -c config_file use config_file as configuration file\n\r"
" -a, --ahbot config_file use config_file as ahbot configuration file\n\r" " -a, --ahbot config_file use config_file as ahbot configuration file\n\r"
#ifdef WIN32 #ifdef WIN32
" Running as service functions:\n\r" " Running as service functions:\n\r"
" -s run run as service\n\r" " -s run run as service\n\r"
" -s install install service\n\r" " -s install install service\n\r"
" -s uninstall uninstall service\n\r" " -s uninstall uninstall service\n\r"
#else #else
" Running as daemon functions:\n\r" " Running as daemon functions:\n\r"
" -s run run as daemon\n\r" " -s run run as daemon\n\r"
" -s stop stop daemon\n\r" " -s stop stop daemon\n\r"
#endif #endif
,prog); ,prog);
} }
/// Launch the mangos server /// Launch the mangos server
extern int main(int argc, char **argv) extern int main(int argc, char** argv)
{ {
///- Command line parsing ///- Command line parsing
char const* cfg_file = _MANGOSD_CONFIG; char const* cfg_file = _MANGOSD_CONFIG;
char const *options = ":a:c:s:"; char const* options = ":a:c:s:";
ACE_Get_Opt cmd_opts(argc, argv, options); ACE_Get_Opt cmd_opts(argc, argv, options);
cmd_opts.long_option("version", 'v', ACE_Get_Opt::NO_ARG); cmd_opts.long_option("version", 'v', ACE_Get_Opt::NO_ARG);
@ -108,7 +108,7 @@ extern int main(int argc, char **argv)
return 0; return 0;
case 's': case 's':
{ {
const char *mode = cmd_opts.opt_arg(); const char* mode = cmd_opts.opt_arg();
if (!strcmp(mode, "run")) if (!strcmp(mode, "run"))
serviceDaemonMode = 'r'; serviceDaemonMode = 'r';
@ -179,8 +179,8 @@ extern int main(int argc, char **argv)
} }
#endif #endif
sLog.outString( "%s [world-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID) ); sLog.outString("%s [world-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID));
sLog.outString( "<Ctrl-C> to stop." ); sLog.outString("<Ctrl-C> to stop.");
sLog.outString("\n\n" sLog.outString("\n\n"
"MM MM MM MM MMMMM MMMM MMMMM\n" "MM MM MM MM MMMMM MMMM MMMMM\n"
"MM MM MM MM MMM MMM MM MM MMM MMM\n" "MM MM MM MM MMM MMM MM MM MMM MMM\n"
@ -196,7 +196,7 @@ extern int main(int argc, char **argv)
sLog.outString("Using configuration file %s.", cfg_file); sLog.outString("Using configuration file %s.", cfg_file);
DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
if (SSLeay() < 0x009080bfL ) if (SSLeay() < 0x009080bfL)
{ {
DETAIL_LOG("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!"); DETAIL_LOG("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!");
DETAIL_LOG("WARNING: Minimal required version [OpenSSL 0.9.8k]"); DETAIL_LOG("WARNING: Minimal required version [OpenSSL 0.9.8k]");

View file

@ -21,7 +21,7 @@
*/ */
#ifndef WIN32 #ifndef WIN32
#include "PosixDaemon.h" #include "PosixDaemon.h"
#endif #endif
#include "WorldSocketMgr.h" #include "WorldSocketMgr.h"
@ -53,13 +53,13 @@
extern int m_ServiceStatus; extern int m_ServiceStatus;
#endif #endif
INSTANTIATE_SINGLETON_1( Master ); INSTANTIATE_SINGLETON_1(Master);
volatile uint32 Master::m_masterLoopCounter = 0; volatile uint32 Master::m_masterLoopCounter = 0;
class FreezeDetectorRunnable : public ACE_Based::Runnable class FreezeDetectorRunnable : public ACE_Based::Runnable
{ {
public: public:
FreezeDetectorRunnable() { _delaytime = 0; } FreezeDetectorRunnable() { _delaytime = 0; }
uint32 m_loops, m_lastchange; uint32 m_loops, m_lastchange;
uint32 w_loops, w_lastchange; uint32 w_loops, w_lastchange;
@ -67,14 +67,14 @@ public:
void SetDelayTime(uint32 t) { _delaytime = t; } void SetDelayTime(uint32 t) { _delaytime = t; }
void run(void) void run(void)
{ {
if(!_delaytime) if (!_delaytime)
return; return;
sLog.outString("Starting up anti-freeze thread (%u seconds max stuck time)...",_delaytime/1000); sLog.outString("Starting up anti-freeze thread (%u seconds max stuck time)...",_delaytime/1000);
m_loops = 0; m_loops = 0;
w_loops = 0; w_loops = 0;
m_lastchange = 0; m_lastchange = 0;
w_lastchange = 0; w_lastchange = 0;
while(!World::IsStopped()) while (!World::IsStopped())
{ {
ACE_Based::Thread::Sleep(1000); ACE_Based::Thread::Sleep(1000);
@ -100,29 +100,29 @@ public:
class RARunnable : public ACE_Based::Runnable class RARunnable : public ACE_Based::Runnable
{ {
private: private:
ACE_Reactor *m_Reactor; ACE_Reactor* m_Reactor;
RASocket::Acceptor *m_Acceptor; RASocket::Acceptor* m_Acceptor;
public: public:
RARunnable() RARunnable()
{ {
ACE_Reactor_Impl* imp = 0; ACE_Reactor_Impl* imp = 0;
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) #if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
imp = new ACE_Dev_Poll_Reactor (); imp = new ACE_Dev_Poll_Reactor();
imp->max_notify_iterations (128); imp->max_notify_iterations(128);
imp->restart (1); imp->restart(1);
#else #else
imp = new ACE_TP_Reactor (); imp = new ACE_TP_Reactor();
imp->max_notify_iterations (128); imp->max_notify_iterations(128);
#endif #endif
m_Reactor = new ACE_Reactor (imp, 1 /* 1= delete implementation so we don't have to care */); m_Reactor = new ACE_Reactor(imp, 1 /* 1= delete implementation so we don't have to care */);
m_Acceptor = new RASocket::Acceptor; m_Acceptor = new RASocket::Acceptor;
@ -134,28 +134,28 @@ public:
delete m_Acceptor; delete m_Acceptor;
} }
void run () void run()
{ {
uint16 raport = sConfig.GetIntDefault ("Ra.Port", 3443); uint16 raport = sConfig.GetIntDefault("Ra.Port", 3443);
std::string stringip = sConfig.GetStringDefault ("Ra.IP", "0.0.0.0"); std::string stringip = sConfig.GetStringDefault("Ra.IP", "0.0.0.0");
ACE_INET_Addr listen_addr(raport, stringip.c_str()); ACE_INET_Addr listen_addr(raport, stringip.c_str());
if (m_Acceptor->open (listen_addr, m_Reactor, ACE_NONBLOCK) == -1) if (m_Acceptor->open(listen_addr, m_Reactor, ACE_NONBLOCK) == -1)
{ {
sLog.outError ("MaNGOS RA can not bind to port %d on %s", raport, stringip.c_str ()); sLog.outError("MaNGOS RA can not bind to port %d on %s", raport, stringip.c_str());
} }
sLog.outString ("Starting Remote access listner on port %d on %s", raport, stringip.c_str ()); sLog.outString("Starting Remote access listner on port %d on %s", raport, stringip.c_str());
while (!m_Reactor->reactor_event_loop_done()) while (!m_Reactor->reactor_event_loop_done())
{ {
ACE_Time_Value interval (0, 10000); ACE_Time_Value interval(0, 10000);
if (m_Reactor->run_reactor_event_loop (interval) == -1) if (m_Reactor->run_reactor_event_loop(interval) == -1)
break; break;
if(World::IsStopped()) if (World::IsStopped())
{ {
m_Acceptor->close(); m_Acceptor->close();
break; break;
@ -178,17 +178,17 @@ int Master::Run()
{ {
/// worldd PID file creation /// worldd PID file creation
std::string pidfile = sConfig.GetStringDefault("PidFile", ""); std::string pidfile = sConfig.GetStringDefault("PidFile", "");
if(!pidfile.empty()) if (!pidfile.empty())
{ {
uint32 pid = CreatePIDFile(pidfile); uint32 pid = CreatePIDFile(pidfile);
if( !pid ) if (!pid)
{ {
sLog.outError( "Cannot create PID file %s.\n", pidfile.c_str() ); sLog.outError("Cannot create PID file %s.\n", pidfile.c_str());
Log::WaitBeforeContinueIfNeed(); Log::WaitBeforeContinueIfNeed();
return 1; return 1;
} }
sLog.outString( "Daemon PID: %u\n", pid ); sLog.outString("Daemon PID: %u\n", pid);
} }
///- Start the databases ///- Start the databases
@ -201,9 +201,9 @@ int Master::Run()
///- Initialize the World ///- Initialize the World
sWorld.SetInitialWorldSettings(); sWorld.SetInitialWorldSettings();
#ifndef WIN32 #ifndef WIN32
detachDaemon(); detachDaemon();
#endif #endif
//server loaded successfully => enable async DB requests //server loaded successfully => enable async DB requests
//this is done to forbid any async transactions during server startup! //this is done to forbid any async transactions during server startup!
CharacterDatabase.AllowAsyncTransactions(); CharacterDatabase.AllowAsyncTransactions();
@ -237,33 +237,33 @@ int Master::Run()
} }
ACE_Based::Thread* rar_thread = NULL; ACE_Based::Thread* rar_thread = NULL;
if(sConfig.GetBoolDefault ("Ra.Enable", false)) if (sConfig.GetBoolDefault("Ra.Enable", false))
{ {
rar_thread = new ACE_Based::Thread(new RARunnable); rar_thread = new ACE_Based::Thread(new RARunnable);
} }
///- Handle affinity for multiple processors and process priority on Windows ///- Handle affinity for multiple processors and process priority on Windows
#ifdef WIN32 #ifdef WIN32
{ {
HANDLE hProcess = GetCurrentProcess(); HANDLE hProcess = GetCurrentProcess();
uint32 Aff = sConfig.GetIntDefault("UseProcessors", 0); uint32 Aff = sConfig.GetIntDefault("UseProcessors", 0);
if(Aff > 0) if (Aff > 0)
{ {
ULONG_PTR appAff; ULONG_PTR appAff;
ULONG_PTR sysAff; ULONG_PTR sysAff;
if(GetProcessAffinityMask(hProcess,&appAff,&sysAff)) if (GetProcessAffinityMask(hProcess,&appAff,&sysAff))
{ {
ULONG_PTR curAff = Aff & appAff; // remove non accessible processors ULONG_PTR curAff = Aff & appAff; // remove non accessible processors
if(!curAff ) if (!curAff)
{ {
sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for mangosd. Accessible processors bitmask (hex): %x",Aff,appAff); sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for mangosd. Accessible processors bitmask (hex): %x",Aff,appAff);
} }
else else
{ {
if(SetProcessAffinityMask(hProcess,curAff)) if (SetProcessAffinityMask(hProcess,curAff))
sLog.outString("Using processors (bitmask, hex): %x", curAff); sLog.outString("Using processors (bitmask, hex): %x", curAff);
else else
sLog.outError("Can't set used processors (hex): %x",curAff); sLog.outError("Can't set used processors (hex): %x",curAff);
@ -275,23 +275,23 @@ int Master::Run()
bool Prio = sConfig.GetBoolDefault("ProcessPriority", false); bool Prio = sConfig.GetBoolDefault("ProcessPriority", false);
// if(Prio && (m_ServiceStatus == -1)/* need set to default process priority class in service mode*/) // if(Prio && (m_ServiceStatus == -1)/* need set to default process priority class in service mode*/)
if(Prio) if (Prio)
{ {
if(SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS)) if (SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS))
sLog.outString("mangosd process priority class set to HIGH"); sLog.outString("mangosd process priority class set to HIGH");
else else
sLog.outError("Can't set mangosd process priority class."); sLog.outError("Can't set mangosd process priority class.");
sLog.outString(); sLog.outString();
} }
} }
#endif #endif
///- Start soap serving thread ///- Start soap serving thread
ACE_Based::Thread* soap_thread = NULL; ACE_Based::Thread* soap_thread = NULL;
if(sConfig.GetBoolDefault("SOAP.Enabled", false)) if (sConfig.GetBoolDefault("SOAP.Enabled", false))
{ {
MaNGOSsoapRunnable *runnable = new MaNGOSsoapRunnable(); MaNGOSsoapRunnable* runnable = new MaNGOSsoapRunnable();
runnable->setListenArguments(sConfig.GetStringDefault("SOAP.IP", "127.0.0.1"), sConfig.GetIntDefault("SOAP.Port", 7878)); runnable->setListenArguments(sConfig.GetStringDefault("SOAP.IP", "127.0.0.1"), sConfig.GetIntDefault("SOAP.Port", 7878));
soap_thread = new ACE_Based::Thread(runnable); soap_thread = new ACE_Based::Thread(runnable);
@ -299,27 +299,27 @@ int Master::Run()
///- Start up freeze catcher thread ///- Start up freeze catcher thread
ACE_Based::Thread* freeze_thread = NULL; ACE_Based::Thread* freeze_thread = NULL;
if(uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0)) if (uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0))
{ {
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable(); FreezeDetectorRunnable* fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay*1000); fdr->SetDelayTime(freeze_delay*1000);
freeze_thread = new ACE_Based::Thread(fdr); freeze_thread = new ACE_Based::Thread(fdr);
freeze_thread->setPriority(ACE_Based::Highest); freeze_thread->setPriority(ACE_Based::Highest);
} }
///- Launch the world listener socket ///- Launch the world listener socket
uint16 wsport = sWorld.getConfig (CONFIG_UINT32_PORT_WORLD); uint16 wsport = sWorld.getConfig(CONFIG_UINT32_PORT_WORLD);
std::string bind_ip = sConfig.GetStringDefault ("BindIP", "0.0.0.0"); std::string bind_ip = sConfig.GetStringDefault("BindIP", "0.0.0.0");
if (sWorldSocketMgr->StartNetwork (wsport, bind_ip) == -1) if (sWorldSocketMgr->StartNetwork(wsport, bind_ip) == -1)
{ {
sLog.outError ("Failed to start network"); sLog.outError("Failed to start network");
Log::WaitBeforeContinueIfNeed(); Log::WaitBeforeContinueIfNeed();
World::StopNow(ERROR_EXIT_CODE); World::StopNow(ERROR_EXIT_CODE);
// go down and shutdown the server // go down and shutdown the server
} }
sWorldSocketMgr->Wait (); sWorldSocketMgr->Wait();
///- Stop freeze protection before shutdown tasks ///- Stop freeze protection before shutdown tasks
if (freeze_thread) if (freeze_thread)
@ -329,7 +329,7 @@ int Master::Run()
} }
///- Stop soap thread ///- Stop soap thread
if(soap_thread) if (soap_thread)
{ {
soap_thread->wait(); soap_thread->wait();
soap_thread->destroy(); soap_thread->destroy();
@ -346,7 +346,7 @@ int Master::Run()
// since worldrunnable uses them, it will crash if unloaded after master // since worldrunnable uses them, it will crash if unloaded after master
world_thread.wait(); world_thread.wait();
if(rar_thread) if (rar_thread)
{ {
rar_thread->wait(); rar_thread->wait();
rar_thread->destroy(); rar_thread->destroy();
@ -364,11 +364,11 @@ int Master::Run()
WorldDatabase.HaltDelayThread(); WorldDatabase.HaltDelayThread();
LoginDatabase.HaltDelayThread(); LoginDatabase.HaltDelayThread();
sLog.outString( "Halting process..." ); sLog.outString("Halting process...");
if (cliThread) if (cliThread)
{ {
#ifdef WIN32 #ifdef WIN32
// this only way to terminate CLI thread exist at Win32 (alt. way exist only in Windows Vista API) // this only way to terminate CLI thread exist at Win32 (alt. way exist only in Windows Vista API)
//_exit(1); //_exit(1);
@ -407,11 +407,11 @@ int Master::Run()
cliThread->wait(); cliThread->wait();
#else #else
cliThread->destroy(); cliThread->destroy();
#endif #endif
delete cliThread; delete cliThread;
} }
@ -426,7 +426,7 @@ bool Master::_StartDB()
///- Get world database info from configuration file ///- Get world database info from configuration file
std::string dbstring = sConfig.GetStringDefault("WorldDatabaseInfo", ""); std::string dbstring = sConfig.GetStringDefault("WorldDatabaseInfo", "");
int nConnections = sConfig.GetIntDefault("WorldDatabaseConnections", 1); int nConnections = sConfig.GetIntDefault("WorldDatabaseConnections", 1);
if(dbstring.empty()) if (dbstring.empty())
{ {
sLog.outError("Database not specified in configuration file"); sLog.outError("Database not specified in configuration file");
return false; return false;
@ -434,13 +434,13 @@ bool Master::_StartDB()
sLog.outString("World Database total connections: %i", nConnections + 1); sLog.outString("World Database total connections: %i", nConnections + 1);
///- Initialise the world database ///- Initialise the world database
if(!WorldDatabase.Initialize(dbstring.c_str(), nConnections)) if (!WorldDatabase.Initialize(dbstring.c_str(), nConnections))
{ {
sLog.outError("Cannot connect to world database %s",dbstring.c_str()); sLog.outError("Cannot connect to world database %s",dbstring.c_str());
return false; return false;
} }
if(!WorldDatabase.CheckRequiredField("db_version",REVISION_DB_MANGOS)) if (!WorldDatabase.CheckRequiredField("db_version",REVISION_DB_MANGOS))
{ {
///- Wait for already started DB delay threads to end ///- Wait for already started DB delay threads to end
WorldDatabase.HaltDelayThread(); WorldDatabase.HaltDelayThread();
@ -449,7 +449,7 @@ bool Master::_StartDB()
dbstring = sConfig.GetStringDefault("CharacterDatabaseInfo", ""); dbstring = sConfig.GetStringDefault("CharacterDatabaseInfo", "");
nConnections = sConfig.GetIntDefault("CharacterDatabaseConnections", 1); nConnections = sConfig.GetIntDefault("CharacterDatabaseConnections", 1);
if(dbstring.empty()) if (dbstring.empty())
{ {
sLog.outError("Character Database not specified in configuration file"); sLog.outError("Character Database not specified in configuration file");
@ -460,7 +460,7 @@ bool Master::_StartDB()
sLog.outString("Character Database total connections: %i", nConnections + 1); sLog.outString("Character Database total connections: %i", nConnections + 1);
///- Initialise the Character database ///- Initialise the Character database
if(!CharacterDatabase.Initialize(dbstring.c_str(), nConnections)) if (!CharacterDatabase.Initialize(dbstring.c_str(), nConnections))
{ {
sLog.outError("Cannot connect to Character database %s",dbstring.c_str()); sLog.outError("Cannot connect to Character database %s",dbstring.c_str());
@ -469,7 +469,7 @@ bool Master::_StartDB()
return false; return false;
} }
if(!CharacterDatabase.CheckRequiredField("character_db_version",REVISION_DB_CHARACTERS)) if (!CharacterDatabase.CheckRequiredField("character_db_version",REVISION_DB_CHARACTERS))
{ {
///- Wait for already started DB delay threads to end ///- Wait for already started DB delay threads to end
WorldDatabase.HaltDelayThread(); WorldDatabase.HaltDelayThread();
@ -480,7 +480,7 @@ bool Master::_StartDB()
///- Get login database info from configuration file ///- Get login database info from configuration file
dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", ""); dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", "");
nConnections = sConfig.GetIntDefault("LoginDatabaseConnections", 1); nConnections = sConfig.GetIntDefault("LoginDatabaseConnections", 1);
if(dbstring.empty()) if (dbstring.empty())
{ {
sLog.outError("Login database not specified in configuration file"); sLog.outError("Login database not specified in configuration file");
@ -492,7 +492,7 @@ bool Master::_StartDB()
///- Initialise the login database ///- Initialise the login database
sLog.outString("Login Database total connections: %i", nConnections + 1); sLog.outString("Login Database total connections: %i", nConnections + 1);
if(!LoginDatabase.Initialize(dbstring.c_str(), nConnections)) if (!LoginDatabase.Initialize(dbstring.c_str(), nConnections))
{ {
sLog.outError("Cannot connect to login database %s",dbstring.c_str()); sLog.outError("Cannot connect to login database %s",dbstring.c_str());
@ -502,7 +502,7 @@ bool Master::_StartDB()
return false; return false;
} }
if(!LoginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD)) if (!LoginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD))
{ {
///- Wait for already started DB delay threads to end ///- Wait for already started DB delay threads to end
WorldDatabase.HaltDelayThread(); WorldDatabase.HaltDelayThread();
@ -513,7 +513,7 @@ bool Master::_StartDB()
///- Get the realm Id from the configuration file ///- Get the realm Id from the configuration file
realmID = sConfig.GetIntDefault("RealmID", 0); realmID = sConfig.GetIntDefault("RealmID", 0);
if(!realmID) if (!realmID)
{ {
sLog.outError("Realm ID not defined in configuration file"); sLog.outError("Realm ID not defined in configuration file");
@ -558,9 +558,9 @@ void Master::_OnSignal(int s)
World::StopNow(RESTART_EXIT_CODE); World::StopNow(RESTART_EXIT_CODE);
break; break;
case SIGTERM: case SIGTERM:
#ifdef _WIN32 #ifdef _WIN32
case SIGBREAK: case SIGBREAK:
#endif #endif
World::StopNow(SHUTDOWN_EXIT_CODE); World::StopNow(SHUTDOWN_EXIT_CODE);
break; break;
} }
@ -573,9 +573,9 @@ void Master::_HookSignals()
{ {
signal(SIGINT, _OnSignal); signal(SIGINT, _OnSignal);
signal(SIGTERM, _OnSignal); signal(SIGTERM, _OnSignal);
#ifdef _WIN32 #ifdef _WIN32
signal(SIGBREAK, _OnSignal); signal(SIGBREAK, _OnSignal);
#endif #endif
} }
/// Unhook the signals before leaving /// Unhook the signals before leaving
@ -583,7 +583,7 @@ void Master::_UnhookSignals()
{ {
signal(SIGINT, 0); signal(SIGINT, 0);
signal(SIGTERM, 0); signal(SIGTERM, 0);
#ifdef _WIN32 #ifdef _WIN32
signal(SIGBREAK, 0); signal(SIGBREAK, 0);
#endif #endif
} }

View file

@ -33,18 +33,18 @@
/// RASocket constructor /// RASocket constructor
RASocket::RASocket() RASocket::RASocket()
:RAHandler(), :RAHandler(),
pendingCommands(0, USYNC_THREAD, "pendingCommands"), pendingCommands(0, USYNC_THREAD, "pendingCommands"),
outActive(false), outActive(false),
inputBufferLen(0), inputBufferLen(0),
outputBufferLen(0), outputBufferLen(0),
stage(NONE) stage(NONE)
{ {
///- Get the config parameters ///- Get the config parameters
bSecure = sConfig.GetBoolDefault( "RA.Secure", true ); bSecure = sConfig.GetBoolDefault("RA.Secure", true);
bStricted = sConfig.GetBoolDefault( "RA.Stricted", false ); bStricted = sConfig.GetBoolDefault("RA.Stricted", false);
iMinLevel = AccountTypes(sConfig.GetIntDefault( "RA.MinLevel", SEC_ADMINISTRATOR )); iMinLevel = AccountTypes(sConfig.GetIntDefault("RA.MinLevel", SEC_ADMINISTRATOR));
reference_counting_policy ().value (ACE_Event_Handler::Reference_Counting_Policy::ENABLED); reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
} }
/// RASocket destructor /// RASocket destructor
@ -55,19 +55,19 @@ RASocket::~RASocket()
} }
/// Accept an incoming connection /// Accept an incoming connection
int RASocket::open(void* ) int RASocket::open(void*)
{ {
if (reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1) if (reactor()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1)
{ {
sLog.outError ("RASocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno)); sLog.outError("RASocket::open: unable to register client handler errno = %s", ACE_OS::strerror(errno));
return -1; return -1;
} }
ACE_INET_Addr remote_addr; ACE_INET_Addr remote_addr;
if (peer ().get_remote_addr (remote_addr) == -1) if (peer().get_remote_addr(remote_addr) == -1)
{ {
sLog.outError ("RASocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno)); sLog.outError("RASocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror(errno));
return -1; return -1;
} }
@ -84,7 +84,7 @@ int RASocket::open(void* )
int RASocket::close(int) int RASocket::close(int)
{ {
if(closing_) if (closing_)
return -1; return -1;
DEBUG_LOG("RASocket::close"); DEBUG_LOG("RASocket::close");
shutdown(); shutdown();
@ -95,45 +95,45 @@ int RASocket::close(int)
return 0; return 0;
} }
int RASocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask) int RASocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask)
{ {
if(closing_) if (closing_)
return -1; return -1;
DEBUG_LOG("RASocket::handle_close"); DEBUG_LOG("RASocket::handle_close");
ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, outBufferLock, -1); ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, outBufferLock, -1);
closing_ = true; closing_ = true;
if (h == ACE_INVALID_HANDLE) if (h == ACE_INVALID_HANDLE)
peer ().close_writer (); peer().close_writer();
remove_reference(); remove_reference();
return 0; return 0;
} }
int RASocket::handle_output (ACE_HANDLE) int RASocket::handle_output(ACE_HANDLE)
{ {
ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, outBufferLock, -1); ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, outBufferLock, -1);
if(closing_) if (closing_)
return -1; return -1;
if (!outputBufferLen) if (!outputBufferLen)
{ {
if(reactor()->cancel_wakeup(this, ACE_Event_Handler::WRITE_MASK) == -1) if (reactor()->cancel_wakeup(this, ACE_Event_Handler::WRITE_MASK) == -1)
{ {
sLog.outError ("RASocket::handle_output: error while cancel_wakeup"); sLog.outError("RASocket::handle_output: error while cancel_wakeup");
return -1; return -1;
} }
outActive = false; outActive = false;
return 0; return 0;
} }
#ifdef MSG_NOSIGNAL #ifdef MSG_NOSIGNAL
ssize_t n = peer ().send (outputBuffer, outputBufferLen, MSG_NOSIGNAL); ssize_t n = peer().send(outputBuffer, outputBufferLen, MSG_NOSIGNAL);
#else #else
ssize_t n = peer ().send (outputBuffer, outputBufferLen); ssize_t n = peer().send(outputBuffer, outputBufferLen);
#endif // MSG_NOSIGNAL #endif // MSG_NOSIGNAL
if(n<=0) if (n<=0)
return -1; return -1;
ACE_OS::memmove(outputBuffer, outputBuffer+n, outputBufferLen-n); ACE_OS::memmove(outputBuffer, outputBuffer+n, outputBufferLen-n);
@ -147,7 +147,7 @@ int RASocket::handle_output (ACE_HANDLE)
int RASocket::handle_input(ACE_HANDLE) int RASocket::handle_input(ACE_HANDLE)
{ {
DEBUG_LOG("RASocket::handle_input"); DEBUG_LOG("RASocket::handle_input");
if(closing_) if (closing_)
{ {
sLog.outError("Called RASocket::handle_input with closing_ = true"); sLog.outError("Called RASocket::handle_input with closing_ = true");
return -1; return -1;
@ -155,7 +155,7 @@ int RASocket::handle_input(ACE_HANDLE)
size_t readBytes = peer().recv(inputBuffer+inputBufferLen, RA_BUFF_SIZE-inputBufferLen-1); size_t readBytes = peer().recv(inputBuffer+inputBufferLen, RA_BUFF_SIZE-inputBufferLen-1);
if(readBytes <= 0) if (readBytes <= 0)
{ {
DEBUG_LOG("read %u bytes in RASocket::handle_input", readBytes); DEBUG_LOG("read %u bytes in RASocket::handle_input", readBytes);
return -1; return -1;
@ -163,7 +163,7 @@ int RASocket::handle_input(ACE_HANDLE)
///- Discard data after line break or line feed ///- Discard data after line break or line feed
bool gotenter=false; bool gotenter=false;
for(; readBytes > 0 ; --readBytes) for (; readBytes > 0 ; --readBytes)
{ {
char c = inputBuffer[inputBufferLen]; char c = inputBuffer[inputBufferLen];
if (c=='\r'|| c=='\n') if (c=='\r'|| c=='\n')
@ -178,7 +178,7 @@ int RASocket::handle_input(ACE_HANDLE)
{ {
inputBuffer[inputBufferLen]=0; inputBuffer[inputBufferLen]=0;
inputBufferLen=0; inputBufferLen=0;
switch(stage) switch (stage)
{ {
/// <ul> <li> If the input is '<username>' /// <ul> <li> If the input is '<username>'
case NONE: case NONE:
@ -188,11 +188,11 @@ int RASocket::handle_input(ACE_HANDLE)
accId = sAccountMgr.GetId(szLogin); accId = sAccountMgr.GetId(szLogin);
///- If the user is not found, deny access ///- If the user is not found, deny access
if(!accId) if (!accId)
{ {
sendf("-No such user.\r\n"); sendf("-No such user.\r\n");
sLog.outRALog("User %s does not exist.",szLogin.c_str()); sLog.outRALog("User %s does not exist.",szLogin.c_str());
if(bSecure) if (bSecure)
{ {
handle_output(); handle_output();
return -1; return -1;
@ -209,7 +209,7 @@ int RASocket::handle_input(ACE_HANDLE)
{ {
sendf("-Not enough privileges.\r\n"); sendf("-Not enough privileges.\r\n");
sLog.outRALog("User %s has no privilege.",szLogin.c_str()); sLog.outRALog("User %s has no privilege.",szLogin.c_str());
if(bSecure) if (bSecure)
{ {
handle_output(); handle_output();
return -1; return -1;
@ -229,7 +229,8 @@ int RASocket::handle_input(ACE_HANDLE)
} }
///<li> If the input is '<password>' (and the user already gave his username) ///<li> If the input is '<password>' (and the user already gave his username)
case LG: case LG:
{ //login+pass ok {
//login+pass ok
std::string pw = inputBuffer; std::string pw = inputBuffer;
if (sAccountMgr.CheckPassword(accId, pw)) if (sAccountMgr.CheckPassword(accId, pw))
@ -245,7 +246,7 @@ int RASocket::handle_input(ACE_HANDLE)
///- Else deny access ///- Else deny access
sendf("-Wrong pass.\r\n"); sendf("-Wrong pass.\r\n");
sLog.outRALog("User account %u has failed to log in.", accId); sLog.outRALog("User account %u has failed to log in.", accId);
if(bSecure) if (bSecure)
{ {
handle_output(); handle_output();
return -1; return -1;
@ -281,9 +282,9 @@ int RASocket::handle_input(ACE_HANDLE)
} }
/// Output function /// Output function
void RASocket::zprint(void* callbackArg, const char * szText ) void RASocket::zprint(void* callbackArg, const char* szText)
{ {
if( !szText ) if (!szText)
return; return;
((RASocket*)callbackArg)->sendf(szText); ((RASocket*)callbackArg)->sendf(szText);
@ -298,25 +299,25 @@ void RASocket::commandFinished(void* callbackArg, bool success)
int RASocket::sendf(const char* msg) int RASocket::sendf(const char* msg)
{ {
ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, outBufferLock, -1); ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, outBufferLock, -1);
if(closing_) if (closing_)
return -1; return -1;
int msgLen = strlen(msg); int msgLen = strlen(msg);
if(msgLen+outputBufferLen > RA_BUFF_SIZE) if (msgLen+outputBufferLen > RA_BUFF_SIZE)
return -1; return -1;
ACE_OS::memcpy(outputBuffer+outputBufferLen, msg, msgLen); ACE_OS::memcpy(outputBuffer+outputBufferLen, msg, msgLen);
outputBufferLen += msgLen; outputBufferLen += msgLen;
if(!outActive) if (!outActive)
{ {
if (reactor ()->schedule_wakeup if (reactor()->schedule_wakeup
(this, ACE_Event_Handler::WRITE_MASK) == -1) (this, ACE_Event_Handler::WRITE_MASK) == -1)
{ {
sLog.outError ("RASocket::sendf error while schedule_wakeup"); sLog.outError("RASocket::sendf error while schedule_wakeup");
return -1; return -1;
} }
outActive = true; outActive = true;

View file

@ -51,19 +51,19 @@ class RASocket: protected RAHandler
virtual ~RASocket(void); virtual ~RASocket(void);
/// Called on open ,the void* is the acceptor. /// Called on open ,the void* is the acceptor.
virtual int open (void *); virtual int open(void*);
/// Called on failures inside of the acceptor, don't call from your code. /// Called on failures inside of the acceptor, don't call from your code.
virtual int close (int); virtual int close(int);
/// Called when we can read from the socket. /// Called when we can read from the socket.
virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); virtual int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE);
/// Called when the socket can write. /// Called when the socket can write.
virtual int handle_output (ACE_HANDLE = ACE_INVALID_HANDLE); virtual int handle_output(ACE_HANDLE = ACE_INVALID_HANDLE);
/// Called when connection is closed or error happens. /// Called when connection is closed or error happens.
virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, virtual int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE,
ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
private: private:
@ -87,9 +87,9 @@ class RASocket: protected RAHandler
NONE, //initial value NONE, //initial value
LG, //only login was entered LG, //only login was entered
OK, //both login and pass were given, they were correct and user has enough priv. OK, //both login and pass were given, they were correct and user has enough priv.
}stage; } stage;
static void zprint(void* callbackArg, const char * szText ); static void zprint(void* callbackArg, const char* szText);
static void commandFinished(void* callbackArg, bool success); static void commandFinished(void* callbackArg, bool success);
}; };
#endif #endif

View file

@ -57,7 +57,7 @@ void WorldRunnable::run()
uint32 diff = WorldTimer::tick(); uint32 diff = WorldTimer::tick();
sWorld.Update( diff ); sWorld.Update(diff);
realPrevTime = realCurrTime; realPrevTime = realCurrTime;
// diff (D0) include time of previous sleep (d0) + tick time (t0) // diff (D0) include time of previous sleep (d0) + tick time (t0)
@ -72,14 +72,14 @@ void WorldRunnable::run()
else else
prevSleepTime = 0; prevSleepTime = 0;
#ifdef WIN32 #ifdef WIN32
if (m_ServiceStatus == 0) World::StopNow(SHUTDOWN_EXIT_CODE); if (m_ServiceStatus == 0) World::StopNow(SHUTDOWN_EXIT_CODE);
while (m_ServiceStatus == 2) Sleep(1000); while (m_ServiceStatus == 2) Sleep(1000);
#endif #endif
} }
sWorld.KickAll(); // save and kick all players sWorld.KickAll(); // save and kick all players
sWorld.UpdateSessions( 1 ); // real players unload required UpdateSessions call sWorld.UpdateSessions(1); // real players unload required UpdateSessions call
// unload battleground templates before different singletons destroyed // unload battleground templates before different singletons destroyed
sBattleGroundMgr.DeleteAllBattleGrounds(); sBattleGroundMgr.DeleteAllBattleGrounds();

File diff suppressed because it is too large Load diff

View file

@ -13,9 +13,9 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int); SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int); SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*); SOAP_FMAC3 void* SOAP_FMAC4 soap_getelement(struct soap*, int*);
#ifdef __cplusplus #ifdef __cplusplus
} }
@ -25,42 +25,42 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
#endif #endif
SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*); SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);
SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 void* SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*); SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);
SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*); SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);
#ifndef SOAP_TYPE_byte #ifndef SOAP_TYPE_byte
#define SOAP_TYPE_byte (3) #define SOAP_TYPE_byte (3)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char*, const char*);
SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*); SOAP_FMAC3 char* SOAP_FMAC4 soap_get_byte(struct soap*, char*, const char*, const char*);
SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*); SOAP_FMAC3 char* SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char*, const char*);
#ifndef SOAP_TYPE_int #ifndef SOAP_TYPE_int
#define SOAP_TYPE_int (1) #define SOAP_TYPE_int (1)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int*, const char*);
SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*); SOAP_FMAC3 int* SOAP_FMAC4 soap_get_int(struct soap*, int*, const char*, const char*);
SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*); SOAP_FMAC3 int* SOAP_FMAC4 soap_in_int(struct soap*, const char*, int*, const char*);
#ifndef WITH_NOGLOBAL #ifndef WITH_NOGLOBAL
#ifndef SOAP_TYPE_SOAP_ENV__Fault #ifndef SOAP_TYPE_SOAP_ENV__Fault
#define SOAP_TYPE_SOAP_ENV__Fault (18) #define SOAP_TYPE_SOAP_ENV__Fault (18)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault*);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*); SOAP_FMAC3 struct SOAP_ENV__Fault* SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault*, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*); SOAP_FMAC3 struct SOAP_ENV__Fault* SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault*, const char*);
SOAP_FMAC5 struct SOAP_ENV__Fault * SOAP_FMAC6 soap_new_SOAP_ENV__Fault(struct soap*, int); SOAP_FMAC5 struct SOAP_ENV__Fault* SOAP_FMAC6 soap_new_SOAP_ENV__Fault(struct soap*, int);
SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault*); SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault*);
SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 struct SOAP_ENV__Fault* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t);
#endif #endif
@ -70,15 +70,15 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, voi
#ifndef SOAP_TYPE_SOAP_ENV__Reason #ifndef SOAP_TYPE_SOAP_ENV__Reason
#define SOAP_TYPE_SOAP_ENV__Reason (17) #define SOAP_TYPE_SOAP_ENV__Reason (17)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason*);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*); SOAP_FMAC3 struct SOAP_ENV__Reason* SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason*, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*); SOAP_FMAC3 struct SOAP_ENV__Reason* SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason*, const char*);
SOAP_FMAC5 struct SOAP_ENV__Reason * SOAP_FMAC6 soap_new_SOAP_ENV__Reason(struct soap*, int); SOAP_FMAC5 struct SOAP_ENV__Reason* SOAP_FMAC6 soap_new_SOAP_ENV__Reason(struct soap*, int);
SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason*); SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason*);
SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 struct SOAP_ENV__Reason* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t);
#endif #endif
@ -88,15 +88,15 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, vo
#ifndef SOAP_TYPE_SOAP_ENV__Detail #ifndef SOAP_TYPE_SOAP_ENV__Detail
#define SOAP_TYPE_SOAP_ENV__Detail (14) #define SOAP_TYPE_SOAP_ENV__Detail (14)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail*);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*); SOAP_FMAC3 struct SOAP_ENV__Detail* SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail*, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*); SOAP_FMAC3 struct SOAP_ENV__Detail* SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail*, const char*);
SOAP_FMAC5 struct SOAP_ENV__Detail * SOAP_FMAC6 soap_new_SOAP_ENV__Detail(struct soap*, int); SOAP_FMAC5 struct SOAP_ENV__Detail* SOAP_FMAC6 soap_new_SOAP_ENV__Detail(struct soap*, int);
SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail*); SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail*);
SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 struct SOAP_ENV__Detail* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t);
#endif #endif
@ -106,15 +106,15 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, vo
#ifndef SOAP_TYPE_SOAP_ENV__Code #ifndef SOAP_TYPE_SOAP_ENV__Code
#define SOAP_TYPE_SOAP_ENV__Code (12) #define SOAP_TYPE_SOAP_ENV__Code (12)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code*);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*); SOAP_FMAC3 struct SOAP_ENV__Code* SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code*, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*); SOAP_FMAC3 struct SOAP_ENV__Code* SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code*, const char*);
SOAP_FMAC5 struct SOAP_ENV__Code * SOAP_FMAC6 soap_new_SOAP_ENV__Code(struct soap*, int); SOAP_FMAC5 struct SOAP_ENV__Code* SOAP_FMAC6 soap_new_SOAP_ENV__Code(struct soap*, int);
SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code*); SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code*);
SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 struct SOAP_ENV__Code* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t);
#endif #endif
@ -124,15 +124,15 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void
#ifndef SOAP_TYPE_SOAP_ENV__Header #ifndef SOAP_TYPE_SOAP_ENV__Header
#define SOAP_TYPE_SOAP_ENV__Header (11) #define SOAP_TYPE_SOAP_ENV__Header (11)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header*);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*); SOAP_FMAC3 struct SOAP_ENV__Header* SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header*, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*); SOAP_FMAC3 struct SOAP_ENV__Header* SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header*, const char*);
SOAP_FMAC5 struct SOAP_ENV__Header * SOAP_FMAC6 soap_new_SOAP_ENV__Header(struct soap*, int); SOAP_FMAC5 struct SOAP_ENV__Header* SOAP_FMAC6 soap_new_SOAP_ENV__Header(struct soap*, int);
SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header*); SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header*);
SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 struct SOAP_ENV__Header* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t);
#endif #endif
@ -140,29 +140,29 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, vo
#ifndef SOAP_TYPE_ns1__executeCommand #ifndef SOAP_TYPE_ns1__executeCommand
#define SOAP_TYPE_ns1__executeCommand (10) #define SOAP_TYPE_ns1__executeCommand (10)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommand(struct soap*, struct ns1__executeCommand *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommand(struct soap*, struct ns1__executeCommand*);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommand(struct soap*, const struct ns1__executeCommand *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommand(struct soap*, const struct ns1__executeCommand*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommand(struct soap*, const struct ns1__executeCommand *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommand(struct soap*, const struct ns1__executeCommand*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommand(struct soap*, const char*, int, const struct ns1__executeCommand *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommand(struct soap*, const char*, int, const struct ns1__executeCommand*, const char*);
SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_get_ns1__executeCommand(struct soap*, struct ns1__executeCommand *, const char*, const char*); SOAP_FMAC3 struct ns1__executeCommand* SOAP_FMAC4 soap_get_ns1__executeCommand(struct soap*, struct ns1__executeCommand*, const char*, const char*);
SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_in_ns1__executeCommand(struct soap*, const char*, struct ns1__executeCommand *, const char*); SOAP_FMAC3 struct ns1__executeCommand* SOAP_FMAC4 soap_in_ns1__executeCommand(struct soap*, const char*, struct ns1__executeCommand*, const char*);
SOAP_FMAC5 struct ns1__executeCommand * SOAP_FMAC6 soap_new_ns1__executeCommand(struct soap*, int); SOAP_FMAC5 struct ns1__executeCommand* SOAP_FMAC6 soap_new_ns1__executeCommand(struct soap*, int);
SOAP_FMAC5 void SOAP_FMAC6 soap_delete_ns1__executeCommand(struct soap*, struct ns1__executeCommand*); SOAP_FMAC5 void SOAP_FMAC6 soap_delete_ns1__executeCommand(struct soap*, struct ns1__executeCommand*);
SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_instantiate_ns1__executeCommand(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 struct ns1__executeCommand* SOAP_FMAC4 soap_instantiate_ns1__executeCommand(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommand(struct soap*, int, int, void*, size_t, const void*, size_t); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommand(struct soap*, int, int, void*, size_t, const void*, size_t);
#ifndef SOAP_TYPE_ns1__executeCommandResponse #ifndef SOAP_TYPE_ns1__executeCommandResponse
#define SOAP_TYPE_ns1__executeCommandResponse (9) #define SOAP_TYPE_ns1__executeCommandResponse (9)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse *); SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse*);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommandResponse(struct soap*, const struct ns1__executeCommandResponse *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommandResponse(struct soap*, const struct ns1__executeCommandResponse*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommandResponse(struct soap*, const struct ns1__executeCommandResponse *, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommandResponse(struct soap*, const struct ns1__executeCommandResponse*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommandResponse(struct soap*, const char*, int, const struct ns1__executeCommandResponse *, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommandResponse(struct soap*, const char*, int, const struct ns1__executeCommandResponse*, const char*);
SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_get_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse *, const char*, const char*); SOAP_FMAC3 struct ns1__executeCommandResponse* SOAP_FMAC4 soap_get_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse*, const char*, const char*);
SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_in_ns1__executeCommandResponse(struct soap*, const char*, struct ns1__executeCommandResponse *, const char*); SOAP_FMAC3 struct ns1__executeCommandResponse* SOAP_FMAC4 soap_in_ns1__executeCommandResponse(struct soap*, const char*, struct ns1__executeCommandResponse*, const char*);
SOAP_FMAC5 struct ns1__executeCommandResponse * SOAP_FMAC6 soap_new_ns1__executeCommandResponse(struct soap*, int); SOAP_FMAC5 struct ns1__executeCommandResponse* SOAP_FMAC6 soap_new_ns1__executeCommandResponse(struct soap*, int);
SOAP_FMAC5 void SOAP_FMAC6 soap_delete_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse*); SOAP_FMAC5 void SOAP_FMAC6 soap_delete_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse*);
SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_instantiate_ns1__executeCommandResponse(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 struct ns1__executeCommandResponse* SOAP_FMAC4 soap_instantiate_ns1__executeCommandResponse(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommandResponse(struct soap*, int, int, void*, size_t, const void*, size_t); SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommandResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
#ifndef WITH_NOGLOBAL #ifndef WITH_NOGLOBAL
@ -170,11 +170,11 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommandResponse(struct soap*, i
#ifndef SOAP_TYPE_PointerToSOAP_ENV__Reason #ifndef SOAP_TYPE_PointerToSOAP_ENV__Reason
#define SOAP_TYPE_PointerToSOAP_ENV__Reason (20) #define SOAP_TYPE_PointerToSOAP_ENV__Reason (20)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason* const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason* const*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char*, int, struct SOAP_ENV__Reason* const*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*); SOAP_FMAC3 struct SOAP_ENV__Reason** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason**, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*); SOAP_FMAC3 struct SOAP_ENV__Reason** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason**, const char*);
#endif #endif
@ -183,11 +183,11 @@ SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reas
#ifndef SOAP_TYPE_PointerToSOAP_ENV__Detail #ifndef SOAP_TYPE_PointerToSOAP_ENV__Detail
#define SOAP_TYPE_PointerToSOAP_ENV__Detail (19) #define SOAP_TYPE_PointerToSOAP_ENV__Detail (19)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail* const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail* const*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char*, int, struct SOAP_ENV__Detail* const*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*); SOAP_FMAC3 struct SOAP_ENV__Detail** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail**, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*); SOAP_FMAC3 struct SOAP_ENV__Detail** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail**, const char*);
#endif #endif
@ -196,42 +196,42 @@ SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Deta
#ifndef SOAP_TYPE_PointerToSOAP_ENV__Code #ifndef SOAP_TYPE_PointerToSOAP_ENV__Code
#define SOAP_TYPE_PointerToSOAP_ENV__Code (13) #define SOAP_TYPE_PointerToSOAP_ENV__Code (13)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code* const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code* const*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char*, int, struct SOAP_ENV__Code* const*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*); SOAP_FMAC3 struct SOAP_ENV__Code** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code**, const char*, const char*);
SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*); SOAP_FMAC3 struct SOAP_ENV__Code** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code**, const char*);
#endif #endif
#ifndef SOAP_TYPE_PointerTostring #ifndef SOAP_TYPE_PointerTostring
#define SOAP_TYPE_PointerTostring (7) #define SOAP_TYPE_PointerTostring (7)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTostring(struct soap*, char **const*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTostring(struct soap*, char** const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTostring(struct soap*, char **const*, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTostring(struct soap*, char** const*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTostring(struct soap*, const char *, int, char **const*, const char *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTostring(struct soap*, const char*, int, char** const*, const char*);
SOAP_FMAC3 char *** SOAP_FMAC4 soap_get_PointerTostring(struct soap*, char ***, const char*, const char*); SOAP_FMAC3 char*** SOAP_FMAC4 soap_get_PointerTostring(struct soap*, char***, const char*, const char*);
SOAP_FMAC3 char *** SOAP_FMAC4 soap_in_PointerTostring(struct soap*, const char*, char ***, const char*); SOAP_FMAC3 char*** SOAP_FMAC4 soap_in_PointerTostring(struct soap*, const char*, char***, const char*);
#ifndef SOAP_TYPE__QName #ifndef SOAP_TYPE__QName
#define SOAP_TYPE__QName (5) #define SOAP_TYPE__QName (5)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default__QName(struct soap*, char **); SOAP_FMAC3 void SOAP_FMAC4 soap_default__QName(struct soap*, char**);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize__QName(struct soap*, char *const*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize__QName(struct soap*, char* const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char* const*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char* const*, const char*);
SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*); SOAP_FMAC3 char** SOAP_FMAC4 soap_get__QName(struct soap*, char**, const char*, const char*);
SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*); SOAP_FMAC3 char** SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char**, const char*);
#ifndef SOAP_TYPE_string #ifndef SOAP_TYPE_string
#define SOAP_TYPE_string (4) #define SOAP_TYPE_string (4)
#endif #endif
SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **); SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char**);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char* const*);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char* const*, const char*, const char*);
SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char* const*, const char*);
SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*); SOAP_FMAC3 char** SOAP_FMAC4 soap_get_string(struct soap*, char**, const char*, const char*);
SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*); SOAP_FMAC3 char** SOAP_FMAC4 soap_in_string(struct soap*, const char*, char**, const char*);
#endif #endif

View file

@ -9,7 +9,7 @@
SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.7.10 2010-02-18 18:41:56 GMT") SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.7.10 2010-02-18 18:41:56 GMT")
SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap) SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap* soap)
{ {
#ifndef WITH_FASTCGI #ifndef WITH_FASTCGI
unsigned int k = soap->max_keep_alive; unsigned int k = soap->max_keep_alive;
@ -33,7 +33,8 @@ SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap)
#endif #endif
if (soap_begin_recv(soap)) if (soap_begin_recv(soap))
{ if (soap->error < SOAP_STOP) {
if (soap->error < SOAP_STOP)
{ {
#ifdef WITH_FASTCGI #ifdef WITH_FASTCGI
soap_send_fault(soap); soap_send_fault(soap);
@ -62,7 +63,8 @@ SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap)
#ifdef WITH_FASTCGI #ifdef WITH_FASTCGI
soap_destroy(soap); soap_destroy(soap);
soap_end(soap); soap_end(soap);
} while (1); }
while (1);
#else #else
} while (soap->keep_alive); } while (soap->keep_alive);
#endif #endif
@ -70,7 +72,7 @@ SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap)
} }
#ifndef WITH_NOSERVEREQUEST #ifndef WITH_NOSERVEREQUEST
SOAP_FMAC5 int SOAP_FMAC6 soap_serve_request(struct soap *soap) SOAP_FMAC5 int SOAP_FMAC6 soap_serve_request(struct soap* soap)
{ {
soap_peek_element(soap); soap_peek_element(soap);
if (!soap_match_tag(soap, soap->tag, "ns1:executeCommand")) if (!soap_match_tag(soap, soap->tag, "ns1:executeCommand"))
@ -79,10 +81,11 @@ SOAP_FMAC5 int SOAP_FMAC6 soap_serve_request(struct soap *soap)
} }
#endif #endif
SOAP_FMAC5 int SOAP_FMAC6 soap_serve_ns1__executeCommand(struct soap *soap) SOAP_FMAC5 int SOAP_FMAC6 soap_serve_ns1__executeCommand(struct soap* soap)
{ struct ns1__executeCommand soap_tmp_ns1__executeCommand; {
struct ns1__executeCommand soap_tmp_ns1__executeCommand;
struct ns1__executeCommandResponse soap_tmp_ns1__executeCommandResponse; struct ns1__executeCommandResponse soap_tmp_ns1__executeCommandResponse;
char * soap_tmp_string; char* soap_tmp_string;
soap_default_ns1__executeCommandResponse(soap, &soap_tmp_ns1__executeCommandResponse); soap_default_ns1__executeCommandResponse(soap, &soap_tmp_ns1__executeCommandResponse);
soap_tmp_string = NULL; soap_tmp_string = NULL;
soap_tmp_ns1__executeCommandResponse.result = &soap_tmp_string; soap_tmp_ns1__executeCommandResponse.result = &soap_tmp_string;
@ -102,7 +105,8 @@ SOAP_FMAC5 int SOAP_FMAC6 soap_serve_ns1__executeCommand(struct soap *soap)
if (soap_begin_count(soap)) if (soap_begin_count(soap))
return soap->error; return soap->error;
if (soap->mode & SOAP_IO_LENGTH) if (soap->mode & SOAP_IO_LENGTH)
{ if (soap_envelope_begin_out(soap) {
if (soap_envelope_begin_out(soap)
|| soap_putheader(soap) || soap_putheader(soap)
|| soap_body_begin_out(soap) || soap_body_begin_out(soap)
|| soap_put_ns1__executeCommandResponse(soap, &soap_tmp_ns1__executeCommandResponse, "ns1:executeCommandResponse", "") || soap_put_ns1__executeCommandResponse(soap, &soap_tmp_ns1__executeCommandResponse, "ns1:executeCommandResponse", "")

View file

@ -32,8 +32,8 @@
/* ns1:executeCommandResponse */ /* ns1:executeCommandResponse */
struct ns1__executeCommandResponse struct ns1__executeCommandResponse
{ {
public: public:
char **result; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* optional element of type xsd:string */ char** result; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* optional element of type xsd:string */
}; };
#endif #endif
@ -42,8 +42,8 @@ public:
/* ns1:executeCommand */ /* ns1:executeCommand */
struct ns1__executeCommand struct ns1__executeCommand
{ {
public: public:
char *command; /* optional element of type xsd:string */ char* command; /* optional element of type xsd:string */
}; };
#endif #endif
@ -53,7 +53,7 @@ public:
struct SOAP_ENV__Header struct SOAP_ENV__Header
{ {
#ifdef WITH_NOEMPTYSTRUCT #ifdef WITH_NOEMPTYSTRUCT
private: private:
char dummy; /* dummy member to enable compilation */ char dummy; /* dummy member to enable compilation */
#endif #endif
}; };
@ -64,9 +64,9 @@ private:
/* SOAP Fault Code: */ /* SOAP Fault Code: */
struct SOAP_ENV__Code struct SOAP_ENV__Code
{ {
public: public:
char *SOAP_ENV__Value; /* optional element of type xsd:QName */ char* SOAP_ENV__Value; /* optional element of type xsd:QName */
struct SOAP_ENV__Code *SOAP_ENV__Subcode; /* optional element of type SOAP-ENV:Code */ struct SOAP_ENV__Code* SOAP_ENV__Subcode; /* optional element of type SOAP-ENV:Code */
}; };
#endif #endif
@ -75,10 +75,10 @@ public:
/* SOAP-ENV:Detail */ /* SOAP-ENV:Detail */
struct SOAP_ENV__Detail struct SOAP_ENV__Detail
{ {
public: public:
int __type; /* any type of element (defined below) */ int __type; /* any type of element (defined below) */
void *fault; /* transient */ void* fault; /* transient */
char *__any; char* __any;
}; };
#endif #endif
@ -87,8 +87,8 @@ public:
/* SOAP-ENV:Reason */ /* SOAP-ENV:Reason */
struct SOAP_ENV__Reason struct SOAP_ENV__Reason
{ {
public: public:
char *SOAP_ENV__Text; /* optional element of type xsd:string */ char* SOAP_ENV__Text; /* optional element of type xsd:string */
}; };
#endif #endif
@ -97,16 +97,16 @@ public:
/* SOAP Fault: */ /* SOAP Fault: */
struct SOAP_ENV__Fault struct SOAP_ENV__Fault
{ {
public: public:
char *faultcode; /* optional element of type xsd:QName */ char* faultcode; /* optional element of type xsd:QName */
char *faultstring; /* optional element of type xsd:string */ char* faultstring; /* optional element of type xsd:string */
char *faultactor; /* optional element of type xsd:string */ char* faultactor; /* optional element of type xsd:string */
struct SOAP_ENV__Detail *detail; /* optional element of type SOAP-ENV:Detail */ struct SOAP_ENV__Detail* detail; /* optional element of type SOAP-ENV:Detail */
struct SOAP_ENV__Code *SOAP_ENV__Code; /* optional element of type SOAP-ENV:Code */ struct SOAP_ENV__Code* SOAP_ENV__Code; /* optional element of type SOAP-ENV:Code */
struct SOAP_ENV__Reason *SOAP_ENV__Reason; /* optional element of type SOAP-ENV:Reason */ struct SOAP_ENV__Reason* SOAP_ENV__Reason; /* optional element of type SOAP-ENV:Reason */
char *SOAP_ENV__Node; /* optional element of type xsd:string */ char* SOAP_ENV__Node; /* optional element of type xsd:string */
char *SOAP_ENV__Role; /* optional element of type xsd:string */ char* SOAP_ENV__Role; /* optional element of type xsd:string */
struct SOAP_ENV__Detail *SOAP_ENV__Detail; /* optional element of type SOAP-ENV:Detail */ struct SOAP_ENV__Detail* SOAP_ENV__Detail; /* optional element of type SOAP-ENV:Detail */
}; };
#endif #endif
@ -125,12 +125,12 @@ public:
#ifndef SOAP_TYPE__QName #ifndef SOAP_TYPE__QName
#define SOAP_TYPE__QName (5) #define SOAP_TYPE__QName (5)
typedef char *_QName; typedef char* _QName;
#endif #endif
#ifndef SOAP_TYPE__XML #ifndef SOAP_TYPE__XML
#define SOAP_TYPE__XML (6) #define SOAP_TYPE__XML (6)
typedef char *_XML; typedef char* _XML;
#endif #endif
@ -155,7 +155,7 @@ typedef char *_XML;
\******************************************************************************/ \******************************************************************************/
SOAP_FMAC5 int SOAP_FMAC6 ns1__executeCommand(struct soap*, char *command, char **result); SOAP_FMAC5 int SOAP_FMAC6 ns1__executeCommand(struct soap*, char* command, char** result);
/******************************************************************************\ /******************************************************************************\
* * * *
@ -164,7 +164,7 @@ SOAP_FMAC5 int SOAP_FMAC6 ns1__executeCommand(struct soap*, char *command, char
\******************************************************************************/ \******************************************************************************/
SOAP_FMAC5 int SOAP_FMAC6 soap_call_ns1__executeCommand(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *command, char **result); SOAP_FMAC5 int SOAP_FMAC6 soap_call_ns1__executeCommand(struct soap* soap, const char* soap_endpoint, const char* soap_action, char* command, char** result);
/******************************************************************************\ /******************************************************************************\
* * * *

View file

@ -31,17 +31,17 @@ AuthCrypt::~AuthCrypt()
} }
void AuthCrypt::Init(BigNumber *K) void AuthCrypt::Init(BigNumber* K)
{ {
uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 }; uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 };
HMACSHA1 serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey); HMACSHA1 serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey);
uint8 *encryptHash = serverEncryptHmac.ComputeHash(K); uint8* encryptHash = serverEncryptHmac.ComputeHash(K);
uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE }; uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE };
HMACSHA1 clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey); HMACSHA1 clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
uint8 *decryptHash = clientDecryptHmac.ComputeHash(K); uint8* decryptHash = clientDecryptHmac.ComputeHash(K);
//SARC4 _serverDecrypt(encryptHash); //SARC4 _serverDecrypt(encryptHash);
_clientDecrypt.Init(decryptHash); _clientDecrypt.Init(decryptHash);
@ -63,7 +63,7 @@ void AuthCrypt::Init(BigNumber *K)
_initialized = true; _initialized = true;
} }
void AuthCrypt::DecryptRecv(uint8 *data, size_t len) void AuthCrypt::DecryptRecv(uint8* data, size_t len)
{ {
if (!_initialized) if (!_initialized)
return; return;
@ -71,7 +71,7 @@ void AuthCrypt::DecryptRecv(uint8 *data, size_t len)
_clientDecrypt.UpdateData(len, data); _clientDecrypt.UpdateData(len, data);
} }
void AuthCrypt::EncryptSend(uint8 *data, size_t len) void AuthCrypt::EncryptSend(uint8* data, size_t len)
{ {
if (!_initialized) if (!_initialized)
return; return;

View file

@ -30,9 +30,9 @@ class AuthCrypt
AuthCrypt(); AuthCrypt();
~AuthCrypt(); ~AuthCrypt();
void Init(BigNumber *K); void Init(BigNumber* K);
void DecryptRecv(uint8 *, size_t); void DecryptRecv(uint8*, size_t);
void EncryptSend(uint8 *, size_t); void EncryptSend(uint8*, size_t);
bool IsInitialized() { return _initialized; } bool IsInitialized() { return _initialized; }

View file

@ -26,7 +26,7 @@ BigNumber::BigNumber()
_array = NULL; _array = NULL;
} }
BigNumber::BigNumber(const BigNumber &bn) BigNumber::BigNumber(const BigNumber& bn)
{ {
_bn = BN_dup(bn._bn); _bn = BN_dup(bn._bn);
_array = NULL; _array = NULL;
@ -42,7 +42,7 @@ BigNumber::BigNumber(uint32 val)
BigNumber::~BigNumber() BigNumber::~BigNumber()
{ {
BN_free(_bn); BN_free(_bn);
if(_array) delete[] _array; if (_array) delete[] _array;
} }
void BigNumber::SetDword(uint32 val) void BigNumber::SetDword(uint32 val)
@ -57,7 +57,7 @@ void BigNumber::SetQword(uint64 val)
BN_add_word(_bn, (uint32)(val & 0xFFFFFFFF)); BN_add_word(_bn, (uint32)(val & 0xFFFFFFFF));
} }
void BigNumber::SetBinary(const uint8 *bytes, int len) void BigNumber::SetBinary(const uint8* bytes, int len)
{ {
uint8 t[1000]; uint8 t[1000];
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
@ -65,7 +65,7 @@ void BigNumber::SetBinary(const uint8 *bytes, int len)
BN_bin2bn(t, len, _bn); BN_bin2bn(t, len, _bn);
} }
void BigNumber::SetHexStr(const char *str) void BigNumber::SetHexStr(const char* str)
{ {
BN_hex2bn(&_bn, str); BN_hex2bn(&_bn, str);
} }
@ -75,27 +75,27 @@ void BigNumber::SetRand(int numbits)
BN_rand(_bn, numbits, 0, 1); BN_rand(_bn, numbits, 0, 1);
} }
BigNumber BigNumber::operator=(const BigNumber &bn) BigNumber BigNumber::operator=(const BigNumber& bn)
{ {
BN_copy(_bn, bn._bn); BN_copy(_bn, bn._bn);
return *this; return *this;
} }
BigNumber BigNumber::operator+=(const BigNumber &bn) BigNumber BigNumber::operator+=(const BigNumber& bn)
{ {
BN_add(_bn, _bn, bn._bn); BN_add(_bn, _bn, bn._bn);
return *this; return *this;
} }
BigNumber BigNumber::operator-=(const BigNumber &bn) BigNumber BigNumber::operator-=(const BigNumber& bn)
{ {
BN_sub(_bn, _bn, bn._bn); BN_sub(_bn, _bn, bn._bn);
return *this; return *this;
} }
BigNumber BigNumber::operator*=(const BigNumber &bn) BigNumber BigNumber::operator*=(const BigNumber& bn)
{ {
BN_CTX *bnctx; BN_CTX* bnctx;
bnctx = BN_CTX_new(); bnctx = BN_CTX_new();
BN_mul(_bn, _bn, bn._bn, bnctx); BN_mul(_bn, _bn, bn._bn, bnctx);
@ -104,9 +104,9 @@ BigNumber BigNumber::operator*=(const BigNumber &bn)
return *this; return *this;
} }
BigNumber BigNumber::operator/=(const BigNumber &bn) BigNumber BigNumber::operator/=(const BigNumber& bn)
{ {
BN_CTX *bnctx; BN_CTX* bnctx;
bnctx = BN_CTX_new(); bnctx = BN_CTX_new();
BN_div(_bn, NULL, _bn, bn._bn, bnctx); BN_div(_bn, NULL, _bn, bn._bn, bnctx);
@ -115,9 +115,9 @@ BigNumber BigNumber::operator/=(const BigNumber &bn)
return *this; return *this;
} }
BigNumber BigNumber::operator%=(const BigNumber &bn) BigNumber BigNumber::operator%=(const BigNumber& bn)
{ {
BN_CTX *bnctx; BN_CTX* bnctx;
bnctx = BN_CTX_new(); bnctx = BN_CTX_new();
BN_mod(_bn, _bn, bn._bn, bnctx); BN_mod(_bn, _bn, bn._bn, bnctx);
@ -126,10 +126,10 @@ BigNumber BigNumber::operator%=(const BigNumber &bn)
return *this; return *this;
} }
BigNumber BigNumber::Exp(const BigNumber &bn) BigNumber BigNumber::Exp(const BigNumber& bn)
{ {
BigNumber ret; BigNumber ret;
BN_CTX *bnctx; BN_CTX* bnctx;
bnctx = BN_CTX_new(); bnctx = BN_CTX_new();
BN_exp(ret._bn, _bn, bn._bn, bnctx); BN_exp(ret._bn, _bn, bn._bn, bnctx);
@ -138,10 +138,10 @@ BigNumber BigNumber::Exp(const BigNumber &bn)
return ret; return ret;
} }
BigNumber BigNumber::ModExp(const BigNumber &bn1, const BigNumber &bn2) BigNumber BigNumber::ModExp(const BigNumber& bn1, const BigNumber& bn2)
{ {
BigNumber ret; BigNumber ret;
BN_CTX *bnctx; BN_CTX* bnctx;
bnctx = BN_CTX_new(); bnctx = BN_CTX_new();
BN_mod_exp(ret._bn, _bn, bn1._bn, bn2._bn, bnctx); BN_mod_exp(ret._bn, _bn, bn1._bn, bn2._bn, bnctx);
@ -165,7 +165,7 @@ bool BigNumber::isZero() const
return BN_is_zero(_bn)!=0; return BN_is_zero(_bn)!=0;
} }
uint8 *BigNumber::AsByteArray(int minSize, bool reverse) uint8* BigNumber::AsByteArray(int minSize, bool reverse)
{ {
int length = (minSize >= GetNumBytes()) ? minSize : GetNumBytes(); int length = (minSize >= GetNumBytes()) ? minSize : GetNumBytes();
@ -180,7 +180,7 @@ uint8 *BigNumber::AsByteArray(int minSize, bool reverse)
if (length > GetNumBytes()) if (length > GetNumBytes())
memset((void*)_array, 0, length); memset((void*)_array, 0, length);
BN_bn2bin(_bn, (unsigned char *)_array); BN_bn2bin(_bn, (unsigned char*)_array);
if (reverse) if (reverse)
std::reverse(_array, _array + length); std::reverse(_array, _array + length);
@ -188,12 +188,12 @@ uint8 *BigNumber::AsByteArray(int minSize, bool reverse)
return _array; return _array;
} }
const char *BigNumber::AsHexStr() const char* BigNumber::AsHexStr()
{ {
return BN_bn2hex(_bn); return BN_bn2hex(_bn);
} }
const char *BigNumber::AsDecStr() const char* BigNumber::AsDecStr()
{ {
return BN_bn2dec(_bn); return BN_bn2dec(_bn);
} }

View file

@ -27,45 +27,45 @@ class BigNumber
{ {
public: public:
BigNumber(); BigNumber();
BigNumber(const BigNumber &bn); BigNumber(const BigNumber& bn);
BigNumber(uint32); BigNumber(uint32);
~BigNumber(); ~BigNumber();
void SetDword(uint32); void SetDword(uint32);
void SetQword(uint64); void SetQword(uint64);
void SetBinary(const uint8 *bytes, int len); void SetBinary(const uint8* bytes, int len);
void SetHexStr(const char *str); void SetHexStr(const char* str);
void SetRand(int numbits); void SetRand(int numbits);
BigNumber operator=(const BigNumber &bn); BigNumber operator=(const BigNumber& bn);
BigNumber operator+=(const BigNumber &bn); BigNumber operator+=(const BigNumber& bn);
BigNumber operator+(const BigNumber &bn) BigNumber operator+(const BigNumber& bn)
{ {
BigNumber t(*this); BigNumber t(*this);
return t += bn; return t += bn;
} }
BigNumber operator-=(const BigNumber &bn); BigNumber operator-=(const BigNumber& bn);
BigNumber operator-(const BigNumber &bn) BigNumber operator-(const BigNumber& bn)
{ {
BigNumber t(*this); BigNumber t(*this);
return t -= bn; return t -= bn;
} }
BigNumber operator*=(const BigNumber &bn); BigNumber operator*=(const BigNumber& bn);
BigNumber operator*(const BigNumber &bn) BigNumber operator*(const BigNumber& bn)
{ {
BigNumber t(*this); BigNumber t(*this);
return t *= bn; return t *= bn;
} }
BigNumber operator/=(const BigNumber &bn); BigNumber operator/=(const BigNumber& bn);
BigNumber operator/(const BigNumber &bn) BigNumber operator/(const BigNumber& bn)
{ {
BigNumber t(*this); BigNumber t(*this);
return t /= bn; return t /= bn;
} }
BigNumber operator%=(const BigNumber &bn); BigNumber operator%=(const BigNumber& bn);
BigNumber operator%(const BigNumber &bn) BigNumber operator%(const BigNumber& bn)
{ {
BigNumber t(*this); BigNumber t(*this);
return t %= bn; return t %= bn;
@ -73,21 +73,21 @@ class BigNumber
bool isZero() const; bool isZero() const;
BigNumber ModExp(const BigNumber &bn1, const BigNumber &bn2); BigNumber ModExp(const BigNumber& bn1, const BigNumber& bn2);
BigNumber Exp(const BigNumber &); BigNumber Exp(const BigNumber&);
int GetNumBytes(void); int GetNumBytes(void);
struct bignum_st *BN() { return _bn; } struct bignum_st* BN() { return _bn; }
uint32 AsDword(); uint32 AsDword();
uint8* AsByteArray(int minSize = 0, bool reverse = true); uint8* AsByteArray(int minSize = 0, bool reverse = true);
const char *AsHexStr(); const char* AsHexStr();
const char *AsDecStr(); const char* AsDecStr();
private: private:
struct bignum_st *_bn; struct bignum_st* _bn;
uint8 *_array; uint8* _array;
}; };
#endif #endif

View file

@ -19,7 +19,7 @@
#include "Auth/HMACSHA1.h" #include "Auth/HMACSHA1.h"
#include "BigNumber.h" #include "BigNumber.h"
HMACSHA1::HMACSHA1(uint32 len, uint8 *seed) HMACSHA1::HMACSHA1(uint32 len, uint8* seed)
{ {
HMAC_CTX_init(&m_ctx); HMAC_CTX_init(&m_ctx);
HMAC_Init_ex(&m_ctx, seed, len, EVP_sha1(), NULL); HMAC_Init_ex(&m_ctx, seed, len, EVP_sha1(), NULL);
@ -30,17 +30,17 @@ HMACSHA1::~HMACSHA1()
HMAC_CTX_cleanup(&m_ctx); HMAC_CTX_cleanup(&m_ctx);
} }
void HMACSHA1::UpdateBigNumber(BigNumber *bn) void HMACSHA1::UpdateBigNumber(BigNumber* bn)
{ {
UpdateData(bn->AsByteArray(), bn->GetNumBytes()); UpdateData(bn->AsByteArray(), bn->GetNumBytes());
} }
void HMACSHA1::UpdateData(const uint8 *data, int length) void HMACSHA1::UpdateData(const uint8* data, int length)
{ {
HMAC_Update(&m_ctx, data, length); HMAC_Update(&m_ctx, data, length);
} }
void HMACSHA1::UpdateData(const std::string &str) void HMACSHA1::UpdateData(const std::string& str)
{ {
UpdateData((uint8 const*)str.c_str(), str.length()); UpdateData((uint8 const*)str.c_str(), str.length());
} }
@ -52,7 +52,7 @@ void HMACSHA1::Finalize()
MANGOS_ASSERT(length == SHA_DIGEST_LENGTH); MANGOS_ASSERT(length == SHA_DIGEST_LENGTH);
} }
uint8 *HMACSHA1::ComputeHash(BigNumber *bn) uint8* HMACSHA1::ComputeHash(BigNumber* bn)
{ {
HMAC_Update(&m_ctx, bn->AsByteArray(), bn->GetNumBytes()); HMAC_Update(&m_ctx, bn->AsByteArray(), bn->GetNumBytes());
Finalize(); Finalize();

View file

@ -30,14 +30,14 @@ class BigNumber;
class HMACSHA1 class HMACSHA1
{ {
public: public:
HMACSHA1(uint32 len, uint8 *seed); HMACSHA1(uint32 len, uint8* seed);
~HMACSHA1(); ~HMACSHA1();
void UpdateBigNumber(BigNumber *bn); void UpdateBigNumber(BigNumber* bn);
void UpdateData(const uint8 *data, int length); void UpdateData(const uint8* data, int length);
void UpdateData(const std::string &str); void UpdateData(const std::string& str);
void Finalize(); void Finalize();
uint8 *ComputeHash(BigNumber *bn); uint8* ComputeHash(BigNumber* bn);
uint8 *GetDigest() { return (uint8*)m_digest; } uint8* GetDigest() { return (uint8*)m_digest; }
int GetLength() { return SHA_DIGEST_LENGTH; } int GetLength() { return SHA_DIGEST_LENGTH; }
private: private:
HMAC_CTX m_ctx; HMAC_CTX m_ctx;

View file

@ -26,7 +26,7 @@ SARC4::SARC4(uint8 len)
EVP_CIPHER_CTX_set_key_length(&m_ctx, len); EVP_CIPHER_CTX_set_key_length(&m_ctx, len);
} }
SARC4::SARC4(uint8 *seed, uint8 len) SARC4::SARC4(uint8* seed, uint8 len)
{ {
EVP_CIPHER_CTX_init(&m_ctx); EVP_CIPHER_CTX_init(&m_ctx);
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL); EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
@ -39,12 +39,12 @@ SARC4::~SARC4()
EVP_CIPHER_CTX_cleanup(&m_ctx); EVP_CIPHER_CTX_cleanup(&m_ctx);
} }
void SARC4::Init(uint8 *seed) void SARC4::Init(uint8* seed)
{ {
EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL); EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL);
} }
void SARC4::UpdateData(int len, uint8 *data) void SARC4::UpdateData(int len, uint8* data)
{ {
int outlen = 0; int outlen = 0;
EVP_EncryptUpdate(&m_ctx, data, &outlen, data, len); EVP_EncryptUpdate(&m_ctx, data, &outlen, data, len);

View file

@ -26,10 +26,10 @@ class SARC4
{ {
public: public:
SARC4(uint8 len); SARC4(uint8 len);
SARC4(uint8 *seed, uint8 len); SARC4(uint8* seed, uint8 len);
~SARC4(); ~SARC4();
void Init(uint8 *seed); void Init(uint8* seed);
void UpdateData(int len, uint8 *data); void UpdateData(int len, uint8* data);
private: private:
EVP_CIPHER_CTX m_ctx; EVP_CIPHER_CTX m_ctx;
}; };

View file

@ -30,27 +30,27 @@ Sha1Hash::~Sha1Hash()
SHA1_Init(&mC); SHA1_Init(&mC);
} }
void Sha1Hash::UpdateData(const uint8 *dta, int len) void Sha1Hash::UpdateData(const uint8* dta, int len)
{ {
SHA1_Update(&mC, dta, len); SHA1_Update(&mC, dta, len);
} }
void Sha1Hash::UpdateData(const std::string &str) void Sha1Hash::UpdateData(const std::string& str)
{ {
UpdateData((uint8 const*)str.c_str(), str.length()); UpdateData((uint8 const*)str.c_str(), str.length());
} }
void Sha1Hash::UpdateBigNumbers(BigNumber *bn0, ...) void Sha1Hash::UpdateBigNumbers(BigNumber* bn0, ...)
{ {
va_list v; va_list v;
BigNumber *bn; BigNumber* bn;
va_start(v, bn0); va_start(v, bn0);
bn = bn0; bn = bn0;
while (bn) while (bn)
{ {
UpdateData(bn->AsByteArray(), bn->GetNumBytes()); UpdateData(bn->AsByteArray(), bn->GetNumBytes());
bn = va_arg(v, BigNumber *); bn = va_arg(v, BigNumber*);
} }
va_end(v); va_end(v);
} }

View file

@ -31,15 +31,15 @@ class Sha1Hash
Sha1Hash(); Sha1Hash();
~Sha1Hash(); ~Sha1Hash();
void UpdateBigNumbers(BigNumber *bn0, ...); void UpdateBigNumbers(BigNumber* bn0, ...);
void UpdateData(const uint8 *dta, int len); void UpdateData(const uint8* dta, int len);
void UpdateData(const std::string &str); void UpdateData(const std::string& str);
void Initialize(); void Initialize();
void Finalize(); void Finalize();
uint8 *GetDigest(void) { return mDigest; }; uint8* GetDigest(void) { return mDigest; };
int GetLength(void) { return SHA_DIGEST_LENGTH; }; int GetLength(void) { return SHA_DIGEST_LENGTH; };
private: private:

View file

@ -74,18 +74,18 @@ typedef struct md5_state_s
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
/* Initialize the algorithm. */ /* Initialize the algorithm. */
void md5_init(md5_state_t *pms); void md5_init(md5_state_t* pms);
/* Append a string to the message. */ /* Append a string to the message. */
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); void md5_append(md5_state_t* pms, const md5_byte_t* data, int nbytes);
/* Finish the message and return the digest. */ /* Finish the message and return the digest. */
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); void md5_finish(md5_state_t* pms, md5_byte_t digest[16]);
#ifdef __cplusplus #ifdef __cplusplus
} /* end extern "C" */ } /* end extern "C" */
#endif #endif
#endif /* md5_INCLUDED */ #endif /* md5_INCLUDED */

View file

@ -68,7 +68,7 @@ class ByteBuffer
} }
// copy constructor // copy constructor
ByteBuffer(const ByteBuffer &buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage) { } ByteBuffer(const ByteBuffer& buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage) { }
void clear() void clear()
{ {
@ -79,153 +79,153 @@ class ByteBuffer
template <typename T> void put(size_t pos,T value) template <typename T> void put(size_t pos,T value)
{ {
EndianConvert(value); EndianConvert(value);
put(pos,(uint8 *)&value,sizeof(value)); put(pos,(uint8*)&value,sizeof(value));
} }
ByteBuffer &operator<<(uint8 value) ByteBuffer& operator<<(uint8 value)
{ {
append<uint8>(value); append<uint8>(value);
return *this; return *this;
} }
ByteBuffer &operator<<(uint16 value) ByteBuffer& operator<<(uint16 value)
{ {
append<uint16>(value); append<uint16>(value);
return *this; return *this;
} }
ByteBuffer &operator<<(uint32 value) ByteBuffer& operator<<(uint32 value)
{ {
append<uint32>(value); append<uint32>(value);
return *this; return *this;
} }
ByteBuffer &operator<<(uint64 value) ByteBuffer& operator<<(uint64 value)
{ {
append<uint64>(value); append<uint64>(value);
return *this; return *this;
} }
// signed as in 2e complement // signed as in 2e complement
ByteBuffer &operator<<(int8 value) ByteBuffer& operator<<(int8 value)
{ {
append<int8>(value); append<int8>(value);
return *this; return *this;
} }
ByteBuffer &operator<<(int16 value) ByteBuffer& operator<<(int16 value)
{ {
append<int16>(value); append<int16>(value);
return *this; return *this;
} }
ByteBuffer &operator<<(int32 value) ByteBuffer& operator<<(int32 value)
{ {
append<int32>(value); append<int32>(value);
return *this; return *this;
} }
ByteBuffer &operator<<(int64 value) ByteBuffer& operator<<(int64 value)
{ {
append<int64>(value); append<int64>(value);
return *this; return *this;
} }
// floating points // floating points
ByteBuffer &operator<<(float value) ByteBuffer& operator<<(float value)
{ {
append<float>(value); append<float>(value);
return *this; return *this;
} }
ByteBuffer &operator<<(double value) ByteBuffer& operator<<(double value)
{ {
append<double>(value); append<double>(value);
return *this; return *this;
} }
ByteBuffer &operator<<(const std::string &value) ByteBuffer& operator<<(const std::string& value)
{ {
append((uint8 const *)value.c_str(), value.length()); append((uint8 const*)value.c_str(), value.length());
append((uint8)0); append((uint8)0);
return *this; return *this;
} }
ByteBuffer &operator<<(const char *str) ByteBuffer& operator<<(const char* str)
{ {
append((uint8 const *)str, str ? strlen(str) : 0); append((uint8 const*)str, str ? strlen(str) : 0);
append((uint8)0); append((uint8)0);
return *this; return *this;
} }
ByteBuffer &operator>>(bool &value) ByteBuffer& operator>>(bool& value)
{ {
value = read<char>() > 0 ? true : false; value = read<char>() > 0 ? true : false;
return *this; return *this;
} }
ByteBuffer &operator>>(uint8 &value) ByteBuffer& operator>>(uint8& value)
{ {
value = read<uint8>(); value = read<uint8>();
return *this; return *this;
} }
ByteBuffer &operator>>(uint16 &value) ByteBuffer& operator>>(uint16& value)
{ {
value = read<uint16>(); value = read<uint16>();
return *this; return *this;
} }
ByteBuffer &operator>>(uint32 &value) ByteBuffer& operator>>(uint32& value)
{ {
value = read<uint32>(); value = read<uint32>();
return *this; return *this;
} }
ByteBuffer &operator>>(uint64 &value) ByteBuffer& operator>>(uint64& value)
{ {
value = read<uint64>(); value = read<uint64>();
return *this; return *this;
} }
//signed as in 2e complement //signed as in 2e complement
ByteBuffer &operator>>(int8 &value) ByteBuffer& operator>>(int8& value)
{ {
value = read<int8>(); value = read<int8>();
return *this; return *this;
} }
ByteBuffer &operator>>(int16 &value) ByteBuffer& operator>>(int16& value)
{ {
value = read<int16>(); value = read<int16>();
return *this; return *this;
} }
ByteBuffer &operator>>(int32 &value) ByteBuffer& operator>>(int32& value)
{ {
value = read<int32>(); value = read<int32>();
return *this; return *this;
} }
ByteBuffer &operator>>(int64 &value) ByteBuffer& operator>>(int64& value)
{ {
value = read<int64>(); value = read<int64>();
return *this; return *this;
} }
ByteBuffer &operator>>(float &value) ByteBuffer& operator>>(float& value)
{ {
value = read<float>(); value = read<float>();
return *this; return *this;
} }
ByteBuffer &operator>>(double &value) ByteBuffer& operator>>(double& value)
{ {
value = read<double>(); value = read<double>();
return *this; return *this;
} }
ByteBuffer &operator>>(std::string& value) ByteBuffer& operator>>(std::string& value)
{ {
value.clear(); value.clear();
while (rpos() < size()) // prevent crash at wrong string format in packet while (rpos() < size()) // prevent crash at wrong string format in packet
@ -239,7 +239,7 @@ class ByteBuffer
} }
template<class T> template<class T>
ByteBuffer &operator>>(Unused<T> const&) ByteBuffer& operator>>(Unused<T> const&)
{ {
read_skip<T>(); read_skip<T>();
return *this; return *this;
@ -272,7 +272,7 @@ class ByteBuffer
void read_skip(size_t skip) void read_skip(size_t skip)
{ {
if(_rpos + skip > size()) if (_rpos + skip > size())
throw ByteBufferException(false, _rpos, skip, size()); throw ByteBufferException(false, _rpos, skip, size());
_rpos += skip; _rpos += skip;
} }
@ -286,16 +286,16 @@ class ByteBuffer
template <typename T> T read(size_t pos) const template <typename T> T read(size_t pos) const
{ {
if(pos + sizeof(T) > size()) if (pos + sizeof(T) > size())
throw ByteBufferException(false, pos, sizeof(T), size()); throw ByteBufferException(false, pos, sizeof(T), size());
T val = *((T const*)&_storage[pos]); T val = *((T const*)&_storage[pos]);
EndianConvert(val); EndianConvert(val);
return val; return val;
} }
void read(uint8 *dest, size_t len) void read(uint8* dest, size_t len)
{ {
if(_rpos + len > size()) if (_rpos + len > size())
throw ByteBufferException(false, _rpos, len, size()); throw ByteBufferException(false, _rpos, len, size());
memcpy(dest, &_storage[_rpos], len); memcpy(dest, &_storage[_rpos], len);
_rpos += len; _rpos += len;
@ -307,9 +307,9 @@ class ByteBuffer
uint8 guidmark = 0; uint8 guidmark = 0;
(*this) >> guidmark; (*this) >> guidmark;
for(int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
{ {
if(guidmark & (uint8(1) << i)) if (guidmark & (uint8(1) << i))
{ {
uint8 bit; uint8 bit;
(*this) >> bit; (*this) >> bit;
@ -320,7 +320,7 @@ class ByteBuffer
return guid; return guid;
} }
const uint8 *contents() const { return &_storage[0]; } const uint8* contents() const { return &_storage[0]; }
size_t size() const { return _storage.size(); } size_t size() const { return _storage.size(); }
bool empty() const { return _storage.empty(); } bool empty() const { return _storage.empty(); }
@ -343,17 +343,17 @@ class ByteBuffer
append((uint8 const*)str.c_str(), str.size() + 1); append((uint8 const*)str.c_str(), str.size() + 1);
} }
void append(const char *src, size_t cnt) void append(const char* src, size_t cnt)
{ {
return append((const uint8 *)src, cnt); return append((const uint8*)src, cnt);
} }
template<class T> void append(const T *src, size_t cnt) template<class T> void append(const T* src, size_t cnt)
{ {
return append((const uint8 *)src, cnt * sizeof(T)); return append((const uint8*)src, cnt * sizeof(T));
} }
void append(const uint8 *src, size_t cnt) void append(const uint8* src, size_t cnt)
{ {
if (!cnt) if (!cnt)
return; return;
@ -368,7 +368,7 @@ class ByteBuffer
void append(const ByteBuffer& buffer) void append(const ByteBuffer& buffer)
{ {
if(buffer.wpos()) if (buffer.wpos())
append(buffer.contents(), buffer.wpos()); append(buffer.contents(), buffer.wpos());
} }
@ -402,9 +402,9 @@ class ByteBuffer
append(packGUID, size); append(packGUID, size);
} }
void put(size_t pos, const uint8 *src, size_t cnt) void put(size_t pos, const uint8* src, size_t cnt)
{ {
if(pos + cnt > size()) if (pos + cnt > size())
throw ByteBufferException(true, pos, cnt, size()); throw ByteBufferException(true, pos, cnt, size());
memcpy(&_storage[pos], src, cnt); memcpy(&_storage[pos], src, cnt);
} }
@ -487,7 +487,7 @@ class ByteBuffer
template <typename T> void append(T value) template <typename T> void append(T value)
{ {
EndianConvert(value); EndianConvert(value);
append((uint8 *)&value, sizeof(value)); append((uint8*)&value, sizeof(value));
} }
protected: protected:
@ -496,7 +496,7 @@ class ByteBuffer
}; };
template <typename T> template <typename T>
inline ByteBuffer &operator<<(ByteBuffer &b, std::vector<T> const& v) inline ByteBuffer& operator<<(ByteBuffer& b, std::vector<T> const& v)
{ {
b << (uint32)v.size(); b << (uint32)v.size();
for (typename std::vector<T>::iterator i = v.begin(); i != v.end(); ++i) for (typename std::vector<T>::iterator i = v.begin(); i != v.end(); ++i)
@ -507,12 +507,12 @@ inline ByteBuffer &operator<<(ByteBuffer &b, std::vector<T> const& v)
} }
template <typename T> template <typename T>
inline ByteBuffer &operator>>(ByteBuffer &b, std::vector<T> &v) inline ByteBuffer& operator>>(ByteBuffer& b, std::vector<T>& v)
{ {
uint32 vsize; uint32 vsize;
b >> vsize; b >> vsize;
v.clear(); v.clear();
while(vsize--) while (vsize--)
{ {
T t; T t;
b >> t; b >> t;
@ -522,7 +522,7 @@ inline ByteBuffer &operator>>(ByteBuffer &b, std::vector<T> &v)
} }
template <typename T> template <typename T>
inline ByteBuffer &operator<<(ByteBuffer &b, std::list<T> const& v) inline ByteBuffer& operator<<(ByteBuffer& b, std::list<T> const& v)
{ {
b << (uint32)v.size(); b << (uint32)v.size();
for (typename std::list<T>::iterator i = v.begin(); i != v.end(); ++i) for (typename std::list<T>::iterator i = v.begin(); i != v.end(); ++i)
@ -533,12 +533,12 @@ inline ByteBuffer &operator<<(ByteBuffer &b, std::list<T> const& v)
} }
template <typename T> template <typename T>
inline ByteBuffer &operator>>(ByteBuffer &b, std::list<T> &v) inline ByteBuffer& operator>>(ByteBuffer& b, std::list<T>& v)
{ {
uint32 vsize; uint32 vsize;
b >> vsize; b >> vsize;
v.clear(); v.clear();
while(vsize--) while (vsize--)
{ {
T t; T t;
b >> t; b >> t;
@ -548,7 +548,7 @@ inline ByteBuffer &operator>>(ByteBuffer &b, std::list<T> &v)
} }
template <typename K, typename V> template <typename K, typename V>
inline ByteBuffer &operator<<(ByteBuffer &b, std::map<K, V> &m) inline ByteBuffer& operator<<(ByteBuffer& b, std::map<K, V>& m)
{ {
b << (uint32)m.size(); b << (uint32)m.size();
for (typename std::map<K, V>::iterator i = m.begin(); i != m.end(); ++i) for (typename std::map<K, V>::iterator i = m.begin(); i != m.end(); ++i)
@ -559,12 +559,12 @@ inline ByteBuffer &operator<<(ByteBuffer &b, std::map<K, V> &m)
} }
template <typename K, typename V> template <typename K, typename V>
inline ByteBuffer &operator>>(ByteBuffer &b, std::map<K, V> &m) inline ByteBuffer& operator>>(ByteBuffer& b, std::map<K, V>& m)
{ {
uint32 msize; uint32 msize;
b >> msize; b >> msize;
m.clear(); m.clear();
while(msize--) while (msize--)
{ {
K k; K k;
V v; V v;

View file

@ -18,7 +18,8 @@
#include "Common.h" #include "Common.h"
char const* localeNames[MAX_LOCALE] = { char const* localeNames[MAX_LOCALE] =
{
"enUS", // also enGB "enUS", // also enGB
"koKR", "koKR",
"frFR", "frFR",
@ -48,7 +49,7 @@ LocaleNameStr const fullLocaleNameList[] =
LocaleConstant GetLocaleByName(const std::string& name) LocaleConstant GetLocaleByName(const std::string& name)
{ {
for(LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr) for (LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr)
if (name==itr->name) if (name==itr->name)
return itr->locale; return itr->locale;

View file

@ -226,9 +226,9 @@ struct LocaleNameStr
extern LocaleNameStr const fullLocaleNameList[]; extern LocaleNameStr const fullLocaleNameList[];
//operator new[] based version of strdup() function! Release memory by using operator delete[] ! //operator new[] based version of strdup() function! Release memory by using operator delete[] !
inline char * mangos_strdup(const char * source) inline char* mangos_strdup(const char* source)
{ {
char * dest = new char[strlen(source) + 1]; char* dest = new char[strlen(source) + 1];
strcpy(dest, source); strcpy(dest, source);
return dest; return dest;
} }

View file

@ -23,7 +23,7 @@
INSTANTIATE_SINGLETON_1(Config); INSTANTIATE_SINGLETON_1(Config);
static bool GetValueHelper(ACE_Configuration_Heap *mConf, const char *name, ACE_TString &result) static bool GetValueHelper(ACE_Configuration_Heap* mConf, const char* name, ACE_TString& result)
{ {
if (!mConf) if (!mConf)
return false; return false;
@ -45,7 +45,7 @@ static bool GetValueHelper(ACE_Configuration_Heap *mConf, const char *name, ACE_
} }
Config::Config() Config::Config()
: mConf(NULL) : mConf(NULL)
{ {
} }
@ -54,7 +54,7 @@ Config::~Config()
delete mConf; delete mConf;
} }
bool Config::SetSource(const char *file) bool Config::SetSource(const char* file)
{ {
mFilename = file; mFilename = file;

View file

@ -32,7 +32,7 @@ class MANGOS_DLL_SPEC Config
Config(); Config();
~Config(); ~Config();
bool SetSource(const char *file); bool SetSource(const char* file);
bool Reload(); bool Reload();
std::string GetStringDefault(const char* name, const char* def); std::string GetStringDefault(const char* name, const char* def);
@ -45,7 +45,7 @@ class MANGOS_DLL_SPEC Config
private: private:
std::string mFilename; std::string mFilename;
ACE_Configuration_Heap *mConf; ACE_Configuration_Heap* mConf;
}; };
#define sConfig MaNGOS::Singleton<Config>::Instance() #define sConfig MaNGOS::Singleton<Config>::Instance()

View file

@ -62,7 +62,7 @@ namespace ACE_Based
//! Gets the next result in the queue, if any. //! Gets the next result in the queue, if any.
bool next(T& result) bool next(T& result)
{ {
ACE_GUARD_RETURN (LockType, g, this->_lock, false); ACE_GUARD_RETURN(LockType, g, this->_lock, false);
if (_queue.empty()) if (_queue.empty())
return false; return false;
@ -76,13 +76,13 @@ namespace ACE_Based
template<class Checker> template<class Checker>
bool next(T& result, Checker& check) bool next(T& result, Checker& check)
{ {
ACE_GUARD_RETURN (LockType, g, this->_lock, false); ACE_GUARD_RETURN(LockType, g, this->_lock, false);
if (_queue.empty()) if (_queue.empty())
return false; return false;
result = _queue.front(); result = _queue.front();
if(!check.Process(result)) if (!check.Process(result))
return false; return false;
_queue.pop_front(); _queue.pop_front();

View file

@ -30,7 +30,7 @@
#include "ace/OS_NS_unistd.h" #include "ace/OS_NS_unistd.h"
INSTANTIATE_SINGLETON_1( Log ); INSTANTIATE_SINGLETON_1(Log);
LogFilterData logFilterData[LOG_FILTER_COUNT] = LogFilterData logFilterData[LOG_FILTER_COUNT] =
{ {
@ -82,18 +82,18 @@ void Log::InitColors(const std::string& str)
std::istringstream ss(str); std::istringstream ss(str);
for(int i = 0; i < LogType_count; ++i) for (int i = 0; i < LogType_count; ++i)
{ {
ss >> color[i]; ss >> color[i];
if(!ss) if (!ss)
return; return;
if(color[i] < 0 || color[i] >= Color_count) if (color[i] < 0 || color[i] >= Color_count)
return; return;
} }
for(int i = 0; i < LogType_count; ++i) for (int i = 0; i < LogType_count; ++i)
m_colors[i] = Color(color[i]); m_colors[i] = Color(color[i]);
m_colored = true; m_colored = true;
@ -101,7 +101,7 @@ void Log::InitColors(const std::string& str)
void Log::SetColor(bool stdout_stream, Color color) void Log::SetColor(bool stdout_stream, Color color)
{ {
#if PLATFORM == PLATFORM_WINDOWS #if PLATFORM == PLATFORM_WINDOWS
static WORD WinColorFG[Color_count] = static WORD WinColorFG[Color_count] =
{ {
@ -128,9 +128,9 @@ void Log::SetColor(bool stdout_stream, Color color)
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
}; };
HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE ); HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
SetConsoleTextAttribute(hConsole, WinColorFG[color]); SetConsoleTextAttribute(hConsole, WinColorFG[color]);
#else #else
enum ANSITextAttr enum ANSITextAttr
{ {
@ -172,17 +172,17 @@ void Log::SetColor(bool stdout_stream, Color color)
}; };
fprintf((stdout_stream? stdout : stderr), "\x1b[%d%sm",UnixColorFG[color],(color>=YELLOW&&color<Color_count ?";1":"")); fprintf((stdout_stream? stdout : stderr), "\x1b[%d%sm",UnixColorFG[color],(color>=YELLOW&&color<Color_count ?";1":""));
#endif #endif
} }
void Log::ResetColor(bool stdout_stream) void Log::ResetColor(bool stdout_stream)
{ {
#if PLATFORM == PLATFORM_WINDOWS #if PLATFORM == PLATFORM_WINDOWS
HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE ); HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED ); SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
#else #else
fprintf(( stdout_stream ? stdout : stderr ), "\x1b[0m"); fprintf((stdout_stream ? stdout : stderr), "\x1b[0m");
#endif #endif
} }
void Log::SetLogLevel(char* level) void Log::SetLogLevel(char* level)
@ -271,7 +271,7 @@ void Log::Initialize()
InitColors(sConfig.GetStringDefault("LogColors", "")); InitColors(sConfig.GetStringDefault("LogColors", ""));
m_logFilter = 0; m_logFilter = 0;
for(int i = 0; i < LOG_FILTER_COUNT; ++i) for (int i = 0; i < LOG_FILTER_COUNT; ++i)
if (*logFilterData[i].name) if (*logFilterData[i].name)
if (sConfig.GetBoolDefault(logFilterData[i].configName, logFilterData[i].defaultState)) if (sConfig.GetBoolDefault(logFilterData[i].configName, logFilterData[i].defaultState))
m_logFilter |= (1 << i); m_logFilter |= (1 << i);
@ -353,18 +353,18 @@ void Log::outString()
{ {
if (m_includeTime) if (m_includeTime)
outTime(); outTime();
printf( "\n" ); printf("\n");
if (logfile) if (logfile)
{ {
outTimestamp(logfile); outTimestamp(logfile);
fprintf(logfile, "\n" ); fprintf(logfile, "\n");
fflush(logfile); fflush(logfile);
} }
fflush(stdout); fflush(stdout);
} }
void Log::outString( const char * str, ... ) void Log::outString(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -384,7 +384,7 @@ void Log::outString( const char * str, ... )
if (m_colored) if (m_colored)
ResetColor(true); ResetColor(true);
printf( "\n" ); printf("\n");
if (logfile) if (logfile)
{ {
@ -392,7 +392,7 @@ void Log::outString( const char * str, ... )
va_start(ap, str); va_start(ap, str);
vfprintf(logfile, str, ap); vfprintf(logfile, str, ap);
fprintf(logfile, "\n" ); fprintf(logfile, "\n");
va_end(ap); va_end(ap);
fflush(logfile); fflush(logfile);
@ -401,7 +401,7 @@ void Log::outString( const char * str, ... )
fflush(stdout); fflush(stdout);
} }
void Log::outError( const char * err, ... ) void Log::outError(const char* err, ...)
{ {
if (!err) if (!err)
return; return;
@ -421,17 +421,17 @@ void Log::outError( const char * err, ... )
if (m_colored) if (m_colored)
ResetColor(false); ResetColor(false);
fprintf( stderr, "\n" ); fprintf(stderr, "\n");
if (logfile) if (logfile)
{ {
outTimestamp(logfile); outTimestamp(logfile);
fprintf(logfile, "ERROR:" ); fprintf(logfile, "ERROR:");
va_start(ap, err); va_start(ap, err);
vfprintf(logfile, err, ap); vfprintf(logfile, err, ap);
va_end(ap); va_end(ap);
fprintf(logfile, "\n" ); fprintf(logfile, "\n");
fflush(logfile); fflush(logfile);
} }
@ -443,26 +443,26 @@ void Log::outErrorDb()
if (m_includeTime) if (m_includeTime)
outTime(); outTime();
fprintf( stderr, "\n" ); fprintf(stderr, "\n");
if (logfile) if (logfile)
{ {
outTimestamp(logfile); outTimestamp(logfile);
fprintf(logfile, "ERROR:\n" ); fprintf(logfile, "ERROR:\n");
fflush(logfile); fflush(logfile);
} }
if (dberLogfile) if (dberLogfile)
{ {
outTimestamp(dberLogfile); outTimestamp(dberLogfile);
fprintf(dberLogfile, "\n" ); fprintf(dberLogfile, "\n");
fflush(dberLogfile); fflush(dberLogfile);
} }
fflush(stderr); fflush(stderr);
} }
void Log::outErrorDb( const char * err, ... ) void Log::outErrorDb(const char* err, ...)
{ {
if (!err) if (!err)
return; return;
@ -482,18 +482,18 @@ void Log::outErrorDb( const char * err, ... )
if (m_colored) if (m_colored)
ResetColor(false); ResetColor(false);
fprintf( stderr, "\n" ); fprintf(stderr, "\n");
if (logfile) if (logfile)
{ {
outTimestamp(logfile); outTimestamp(logfile);
fprintf(logfile, "ERROR:" ); fprintf(logfile, "ERROR:");
va_start(ap, err); va_start(ap, err);
vfprintf(logfile, err, ap); vfprintf(logfile, err, ap);
va_end(ap); va_end(ap);
fprintf(logfile, "\n" ); fprintf(logfile, "\n");
fflush(logfile); fflush(logfile);
} }
@ -506,14 +506,14 @@ void Log::outErrorDb( const char * err, ... )
vfprintf(dberLogfile, err, ap); vfprintf(dberLogfile, err, ap);
va_end(ap); va_end(ap);
fprintf(dberLogfile, "\n" ); fprintf(dberLogfile, "\n");
fflush(dberLogfile); fflush(dberLogfile);
} }
fflush(stderr); fflush(stderr);
} }
void Log::outBasic( const char * str, ... ) void Log::outBasic(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -534,7 +534,7 @@ void Log::outBasic( const char * str, ... )
if (m_colored) if (m_colored)
ResetColor(true); ResetColor(true);
printf( "\n" ); printf("\n");
} }
if (logfile && m_logFileLevel >= LOG_LVL_BASIC) if (logfile && m_logFileLevel >= LOG_LVL_BASIC)
@ -543,7 +543,7 @@ void Log::outBasic( const char * str, ... )
outTimestamp(logfile); outTimestamp(logfile);
va_start(ap, str); va_start(ap, str);
vfprintf(logfile, str, ap); vfprintf(logfile, str, ap);
fprintf(logfile, "\n" ); fprintf(logfile, "\n");
va_end(ap); va_end(ap);
fflush(logfile); fflush(logfile);
} }
@ -551,7 +551,7 @@ void Log::outBasic( const char * str, ... )
fflush(stdout); fflush(stdout);
} }
void Log::outDetail( const char * str, ... ) void Log::outDetail(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -573,7 +573,7 @@ void Log::outDetail( const char * str, ... )
if (m_colored) if (m_colored)
ResetColor(true); ResetColor(true);
printf( "\n" ); printf("\n");
} }
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL) if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
@ -585,14 +585,14 @@ void Log::outDetail( const char * str, ... )
vfprintf(logfile, str, ap); vfprintf(logfile, str, ap);
va_end(ap); va_end(ap);
fprintf(logfile, "\n" ); fprintf(logfile, "\n");
fflush(logfile); fflush(logfile);
} }
fflush(stdout); fflush(stdout);
} }
void Log::outDebug( const char * str, ... ) void Log::outDebug(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -613,7 +613,7 @@ void Log::outDebug( const char * str, ... )
if (m_colored) if (m_colored)
ResetColor(true); ResetColor(true);
printf( "\n" ); printf("\n");
} }
if (logfile && m_logFileLevel >= LOG_LVL_DEBUG) if (logfile && m_logFileLevel >= LOG_LVL_DEBUG)
@ -625,14 +625,14 @@ void Log::outDebug( const char * str, ... )
vfprintf(logfile, str, ap); vfprintf(logfile, str, ap);
va_end(ap); va_end(ap);
fprintf(logfile, "\n" ); fprintf(logfile, "\n");
fflush(logfile); fflush(logfile);
} }
fflush(stdout); fflush(stdout);
} }
void Log::outCommand( uint32 account, const char * str, ... ) void Log::outCommand(uint32 account, const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -653,7 +653,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
if (m_colored) if (m_colored)
ResetColor(true); ResetColor(true);
printf( "\n" ); printf("\n");
} }
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL) if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
@ -662,20 +662,20 @@ void Log::outCommand( uint32 account, const char * str, ... )
outTimestamp(logfile); outTimestamp(logfile);
va_start(ap, str); va_start(ap, str);
vfprintf(logfile, str, ap); vfprintf(logfile, str, ap);
fprintf(logfile, "\n" ); fprintf(logfile, "\n");
va_end(ap); va_end(ap);
fflush(logfile); fflush(logfile);
} }
if (m_gmlog_per_account) if (m_gmlog_per_account)
{ {
if (FILE* per_file = openGmlogPerAccount (account)) if (FILE* per_file = openGmlogPerAccount(account))
{ {
va_list ap; va_list ap;
outTimestamp(per_file); outTimestamp(per_file);
va_start(ap, str); va_start(ap, str);
vfprintf(per_file, str, ap); vfprintf(per_file, str, ap);
fprintf(per_file, "\n" ); fprintf(per_file, "\n");
va_end(ap); va_end(ap);
fclose(per_file); fclose(per_file);
} }
@ -686,7 +686,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
outTimestamp(gmLogfile); outTimestamp(gmLogfile);
va_start(ap, str); va_start(ap, str);
vfprintf(gmLogfile, str, ap); vfprintf(gmLogfile, str, ap);
fprintf(gmLogfile, "\n" ); fprintf(gmLogfile, "\n");
va_end(ap); va_end(ap);
fflush(gmLogfile); fflush(gmLogfile);
} }
@ -694,7 +694,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
fflush(stdout); fflush(stdout);
} }
void Log::outChar(const char * str, ... ) void Log::outChar(const char* str, ...)
{ {
if (!str) if (!str)
@ -706,13 +706,13 @@ void Log::outChar(const char * str, ... )
outTimestamp(charLogfile); outTimestamp(charLogfile);
va_start(ap, str); va_start(ap, str);
vfprintf(charLogfile, str, ap); vfprintf(charLogfile, str, ap);
fprintf(charLogfile, "\n" ); fprintf(charLogfile, "\n");
va_end(ap); va_end(ap);
fflush(charLogfile); fflush(charLogfile);
} }
} }
void Log::outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming ) void Log::outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming)
{ {
if (!worldLogfile) if (!worldLogfile)
return; return;
@ -736,16 +736,16 @@ void Log::outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeNa
fflush(worldLogfile); fflush(worldLogfile);
} }
void Log::outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name ) void Log::outCharDump(const char* str, uint32 account_id, uint32 guid, const char* name)
{ {
if (charLogfile) if (charLogfile)
{ {
fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n",account_id,guid,name,str ); fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n",account_id,guid,name,str);
fflush(charLogfile); fflush(charLogfile);
} }
} }
void Log::outRALog( const char * str, ... ) void Log::outRALog(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -756,7 +756,7 @@ void Log::outRALog( const char * str, ... )
outTimestamp(raLogfile); outTimestamp(raLogfile);
va_start(ap, str); va_start(ap, str);
vfprintf(raLogfile, str, ap); vfprintf(raLogfile, str, ap);
fprintf(raLogfile, "\n" ); fprintf(raLogfile, "\n");
va_end(ap); va_end(ap);
fflush(raLogfile); fflush(raLogfile);
} }
@ -773,13 +773,13 @@ void Log::WaitBeforeContinueIfNeed()
printf("\nPress <Enter> for continue\n"); printf("\nPress <Enter> for continue\n");
std::string line; std::string line;
std::getline (std::cin, line); std::getline(std::cin, line);
} }
else if (mode > 0) else if (mode > 0)
{ {
printf("\nWait %u secs for continue.\n",mode); printf("\nWait %u secs for continue.\n",mode);
BarGoLink bar(mode); BarGoLink bar(mode);
for(int i = 0; i < mode; ++i) for (int i = 0; i < mode; ++i)
{ {
bar.step(); bar.step();
ACE_OS::sleep(1); ACE_OS::sleep(1);
@ -787,7 +787,7 @@ void Log::WaitBeforeContinueIfNeed()
} }
} }
void outstring_log(const char * str, ...) void outstring_log(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -801,7 +801,7 @@ void outstring_log(const char * str, ...)
sLog.outString("%s", buf); sLog.outString("%s", buf);
} }
void detail_log(const char * str, ...) void detail_log(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -815,7 +815,7 @@ void detail_log(const char * str, ...)
sLog.outDetail("%s", buf); sLog.outDetail("%s", buf);
} }
void debug_log(const char * str, ...) void debug_log(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -829,7 +829,7 @@ void debug_log(const char * str, ...)
DEBUG_LOG("%s", buf); DEBUG_LOG("%s", buf);
} }
void error_log(const char * str, ...) void error_log(const char* str, ...)
{ {
if (!str) if (!str)
return; return;
@ -843,7 +843,7 @@ void error_log(const char * str, ...)
sLog.outError("%s", buf); sLog.outError("%s", buf);
} }
void error_db_log(const char * str, ...) void error_db_log(const char* str, ...)
{ {
if (!str) if (!str)
return; return;

View file

@ -94,11 +94,11 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
~Log() ~Log()
{ {
if( logfile != NULL ) if (logfile != NULL)
fclose(logfile); fclose(logfile);
logfile = NULL; logfile = NULL;
if( gmLogfile != NULL ) if (gmLogfile != NULL)
fclose(gmLogfile); fclose(gmLogfile);
gmLogfile = NULL; gmLogfile = NULL;
@ -106,7 +106,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
fclose(charLogfile); fclose(charLogfile);
charLogfile = NULL; charLogfile = NULL;
if( dberLogfile != NULL ) if (dberLogfile != NULL)
fclose(dberLogfile); fclose(dberLogfile);
dberLogfile = NULL; dberLogfile = NULL;
@ -122,32 +122,32 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
void Initialize(); void Initialize();
void InitColors(const std::string& init_str); void InitColors(const std::string& init_str);
void outCommand( uint32 account, const char * str, ...) ATTR_PRINTF(3,4); void outCommand(uint32 account, const char* str, ...) ATTR_PRINTF(3,4);
void outString(); // any log level void outString(); // any log level
// any log level // any log level
void outString( const char * str, ... ) ATTR_PRINTF(2,3); void outString(const char* str, ...) ATTR_PRINTF(2,3);
// any log level // any log level
void outError( const char * err, ... ) ATTR_PRINTF(2,3); void outError(const char* err, ...) ATTR_PRINTF(2,3);
// log level >= 1 // log level >= 1
void outBasic( const char * str, ... ) ATTR_PRINTF(2,3); void outBasic(const char* str, ...) ATTR_PRINTF(2,3);
// log level >= 2 // log level >= 2
void outDetail( const char * str, ... ) ATTR_PRINTF(2,3); void outDetail(const char* str, ...) ATTR_PRINTF(2,3);
// log level >= 3 // log level >= 3
void outDebug( const char * str, ... ) ATTR_PRINTF(2,3); void outDebug(const char* str, ...) ATTR_PRINTF(2,3);
void outErrorDb(); // any log level void outErrorDb(); // any log level
// any log level // any log level
void outErrorDb( const char * str, ... ) ATTR_PRINTF(2,3); void outErrorDb(const char* str, ...) ATTR_PRINTF(2,3);
// any log level // any log level
void outChar( const char * str, ... ) ATTR_PRINTF(2,3); void outChar(const char* str, ...) ATTR_PRINTF(2,3);
// any log level // any log level
void outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming ); void outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming);
// any log level // any log level
void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name ); void outCharDump(const char* str, uint32 account_id, uint32 guid, const char* name);
void outRALog( const char * str, ... ) ATTR_PRINTF(2,3); void outRALog(const char* str, ...) ATTR_PRINTF(2,3);
uint32 GetLogLevel() const { return m_logLevel; } uint32 GetLogLevel() const { return m_logLevel; }
void SetLogLevel(char * Level); void SetLogLevel(char* Level);
void SetLogFileLevel(char * Level); void SetLogFileLevel(char* Level);
void SetColor(bool stdout_stream, Color color); void SetColor(bool stdout_stream, Color color);
void ResetColor(bool stdout_stream); void ResetColor(bool stdout_stream);
void outTime(); void outTime();
@ -239,9 +239,9 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
ERROR_DB_FILTER_LOG(LOG_FILTER_DB_STRICTED_CHECK, __VA_ARGS__) ERROR_DB_FILTER_LOG(LOG_FILTER_DB_STRICTED_CHECK, __VA_ARGS__)
// primary for script library // primary for script library
void MANGOS_DLL_SPEC outstring_log(const char * str, ...) ATTR_PRINTF(1,2); void MANGOS_DLL_SPEC outstring_log(const char* str, ...) ATTR_PRINTF(1,2);
void MANGOS_DLL_SPEC detail_log(const char * str, ...) ATTR_PRINTF(1,2); void MANGOS_DLL_SPEC detail_log(const char* str, ...) ATTR_PRINTF(1,2);
void MANGOS_DLL_SPEC debug_log(const char * str, ...) ATTR_PRINTF(1,2); void MANGOS_DLL_SPEC debug_log(const char* str, ...) ATTR_PRINTF(1,2);
void MANGOS_DLL_SPEC error_log(const char * str, ...) ATTR_PRINTF(1,2); void MANGOS_DLL_SPEC error_log(const char* str, ...) ATTR_PRINTF(1,2);
void MANGOS_DLL_SPEC error_db_log(const char * str, ...) ATTR_PRINTF(1,2); void MANGOS_DLL_SPEC error_db_log(const char* str, ...) ATTR_PRINTF(1,2);
#endif #endif

View file

@ -37,7 +37,8 @@ void daemonSignal(int s)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
if (sid) { if (sid)
{
kill(sid, s); kill(sid, s);
} }
@ -57,11 +58,13 @@ void startDaemon(uint32_t timeout)
sid = pid = fork(); sid = pid = fork();
if (pid < 0) { if (pid < 0)
{
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (pid > 0) { if (pid > 0)
{
alarm(timeout); alarm(timeout);
pause(); pause();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -71,11 +74,13 @@ void startDaemon(uint32_t timeout)
sid = setsid(); sid = setsid();
if (sid < 0) { if (sid < 0)
{
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if ((chdir("/")) < 0) { if ((chdir("/")) < 0)
{
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -87,7 +92,7 @@ void startDaemon(uint32_t timeout)
void stopDaemon() void stopDaemon()
{ {
std::string pidfile = sConfig.GetStringDefault("PidFile", ""); std::string pidfile = sConfig.GetStringDefault("PidFile", "");
if(!pidfile.empty()) if (!pidfile.empty())
{ {
std::fstream pf(pidfile.c_str(), std::ios::in); std::fstream pf(pidfile.c_str(), std::ios::in);
uint32_t pid = 0; uint32_t pid = 0;

View file

@ -52,7 +52,7 @@ BarGoLink::~BarGoLink()
if (!m_showOutput) if (!m_showOutput)
return; return;
printf( "\n" ); printf("\n");
fflush(stdout); fflush(stdout);
} }
@ -66,17 +66,17 @@ void BarGoLink::init(int row_count)
if (!m_showOutput) if (!m_showOutput)
return; return;
#ifdef _WIN32 #ifdef _WIN32
printf( "\x3D" ); printf("\x3D");
#else #else
printf( "[" ); printf("[");
#endif #endif
for ( int i = 0; i < indic_len; i++ ) printf( empty ); for (int i = 0; i < indic_len; i++) printf(empty);
#ifdef _WIN32 #ifdef _WIN32
printf( "\x3D 0%%\r\x3D" ); printf("\x3D 0%%\r\x3D");
#else #else
printf( "] 0%%\r[" ); printf("] 0%%\r[");
#endif #endif
fflush(stdout); fflush(stdout);
} }
@ -87,24 +87,24 @@ void BarGoLink::step()
int i, n; int i, n;
if ( num_rec == 0 ) return; if (num_rec == 0) return;
++rec_no; ++rec_no;
n = rec_no * indic_len / num_rec; n = rec_no * indic_len / num_rec;
if ( n != rec_pos ) if (n != rec_pos)
{ {
#ifdef _WIN32 #ifdef _WIN32
printf( "\r\x3D" ); printf("\r\x3D");
#else #else
printf( "\r[" ); printf("\r[");
#endif #endif
for ( i = 0; i < n; i++ ) printf( full ); for (i = 0; i < n; i++) printf(full);
for ( ; i < indic_len; i++ ) printf( empty ); for (; i < indic_len; i++) printf(empty);
float percent = (((float)n/(float)indic_len)*100); float percent = (((float)n/(float)indic_len)*100);
#ifdef _WIN32 #ifdef _WIN32
printf( "\x3D %i%% \r\x3D", (int)percent); printf("\x3D %i%% \r\x3D", (int)percent);
#else #else
printf( "] %i%% \r[", (int)percent); printf("] %i%% \r[", (int)percent);
#endif #endif
fflush(stdout); fflush(stdout);
rec_pos = n; rec_pos = n;

View file

@ -36,8 +36,8 @@ class MANGOS_DLL_SPEC BarGoLink
void init(int row_count); void init(int row_count);
static bool m_showOutput; // not recommended change with existed active bar static bool m_showOutput; // not recommended change with existed active bar
static char const * const empty; static char const* const empty;
static char const * const full; static char const* const full;
int rec_no; int rec_no;
int rec_pos; int rec_pos;

View file

@ -32,7 +32,7 @@
#endif #endif
#endif #endif
extern int main(int argc, char ** argv); extern int main(int argc, char** argv);
extern char serviceLongName[]; extern char serviceLongName[];
extern char serviceName[]; extern char serviceName[];
extern char serviceDescription[]; extern char serviceDescription[];
@ -43,7 +43,7 @@ SERVICE_STATUS serviceStatus;
SERVICE_STATUS_HANDLE serviceStatusHandle = 0; SERVICE_STATUS_HANDLE serviceStatusHandle = 0;
typedef WINADVAPI BOOL (WINAPI *CSD_T)(SC_HANDLE, DWORD, LPCVOID); typedef WINADVAPI BOOL (WINAPI* CSD_T)(SC_HANDLE, DWORD, LPCVOID);
bool WinServiceInstall() bool WinServiceInstall()
{ {
@ -58,7 +58,7 @@ bool WinServiceInstall()
} }
char path[_MAX_PATH + 10]; char path[_MAX_PATH + 10];
if (!GetModuleFileName( 0, path, sizeof(path)/sizeof(path[0]))) if (!GetModuleFileName(0, path, sizeof(path)/sizeof(path[0])))
{ {
CloseServiceHandle(serviceControlManager); CloseServiceHandle(serviceControlManager);
sLog.outError("SERVICE: Can't get service binary filename."); sLog.outError("SERVICE: Can't get service binary filename.");
@ -90,7 +90,7 @@ bool WinServiceInstall()
} }
advapi32 = GetModuleHandle("ADVAPI32.DLL"); advapi32 = GetModuleHandle("ADVAPI32.DLL");
if(!advapi32) if (!advapi32)
{ {
sLog.outError("SERVICE: Can't access ADVAPI32.DLL"); sLog.outError("SERVICE: Can't access ADVAPI32.DLL");
CloseServiceHandle(service); CloseServiceHandle(service);
@ -192,7 +192,7 @@ void WINAPI ServiceControlHandler(DWORD controlCode)
break; break;
default: default:
if ( controlCode >= 128 && controlCode <= 255 ) if (controlCode >= 128 && controlCode <= 255)
// user defined control code // user defined control code
break; break;
else else
@ -203,7 +203,7 @@ void WINAPI ServiceControlHandler(DWORD controlCode)
SetServiceStatus(serviceStatusHandle, &serviceStatus); SetServiceStatus(serviceStatusHandle, &serviceStatus);
} }
void WINAPI ServiceMain(DWORD argc, char *argv[]) void WINAPI ServiceMain(DWORD argc, char* argv[])
{ {
// initialise service status // initialise service status
serviceStatus.dwServiceType = SERVICE_WIN32; serviceStatus.dwServiceType = SERVICE_WIN32;
@ -216,7 +216,7 @@ void WINAPI ServiceMain(DWORD argc, char *argv[])
serviceStatusHandle = RegisterServiceCtrlHandler(serviceName, ServiceControlHandler); serviceStatusHandle = RegisterServiceCtrlHandler(serviceName, ServiceControlHandler);
if ( serviceStatusHandle ) if (serviceStatusHandle)
{ {
char path[_MAX_PATH + 1]; char path[_MAX_PATH + 1];
unsigned int i, last_slash = 0; unsigned int i, last_slash = 0;
@ -240,7 +240,7 @@ void WINAPI ServiceMain(DWORD argc, char *argv[])
// running // running
serviceStatus.dwControlsAccepted |= (SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN); serviceStatus.dwControlsAccepted |= (SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN);
serviceStatus.dwCurrentState = SERVICE_RUNNING; serviceStatus.dwCurrentState = SERVICE_RUNNING;
SetServiceStatus( serviceStatusHandle, &serviceStatus ); SetServiceStatus(serviceStatusHandle, &serviceStatus);
//////////////////////// ////////////////////////
// service main cycle // // service main cycle //

View file

@ -43,16 +43,16 @@ ThreadPriority::ThreadPriority()
pr_iter.next(); pr_iter.next();
} }
MANGOS_ASSERT (!_tmp.empty()); MANGOS_ASSERT(!_tmp.empty());
if(_tmp.size() >= MAXPRIORITYNUM) if (_tmp.size() >= MAXPRIORITYNUM)
{ {
const size_t max_pos = _tmp.size(); const size_t max_pos = _tmp.size();
size_t min_pos = 1; size_t min_pos = 1;
size_t norm_pos = 0; size_t norm_pos = 0;
for (size_t i = 0; i < max_pos; ++i) for (size_t i = 0; i < max_pos; ++i)
{ {
if(_tmp[i] == ACE_THR_PRI_OTHER_DEF) if (_tmp[i] == ACE_THR_PRI_OTHER_DEF)
{ {
norm_pos = i + 1; norm_pos = i + 1;
break; break;
@ -65,7 +65,7 @@ ThreadPriority::ThreadPriority()
//into ¹ piesces //into ¹ piesces
const size_t _divider = 4; const size_t _divider = 4;
size_t _div = (norm_pos - min_pos) / _divider; size_t _div = (norm_pos - min_pos) / _divider;
if(_div == 0) if (_div == 0)
_div = 1; _div = 1;
min_pos = (norm_pos - 1); min_pos = (norm_pos - 1);
@ -74,7 +74,7 @@ ThreadPriority::ThreadPriority()
m_priority[Lowest] = _tmp[min_pos -= _div ]; m_priority[Lowest] = _tmp[min_pos -= _div ];
_div = (max_pos - norm_pos) / _divider; _div = (max_pos - norm_pos) / _divider;
if(_div == 0) if (_div == 0)
_div = 1; _div = 1;
min_pos = norm_pos - 1; min_pos = norm_pos - 1;
@ -86,10 +86,10 @@ ThreadPriority::ThreadPriority()
int ThreadPriority::getPriority(Priority p) const int ThreadPriority::getPriority(Priority p) const
{ {
if(p < Idle) if (p < Idle)
p = Idle; p = Idle;
if(p > Realtime) if (p > Realtime)
p = Realtime; p = Realtime;
return m_priority[p]; return m_priority[p];
@ -113,7 +113,7 @@ Thread::Thread(Runnable* instance) : m_iThreadId(0), m_hThreadHandle(0), m_task(
m_task->incReference(); m_task->incReference();
bool _start = start(); bool _start = start();
MANGOS_ASSERT (_start); MANGOS_ASSERT(_start);
} }
Thread::~Thread() Thread::~Thread()
@ -181,9 +181,9 @@ void Thread::resume()
ACE_Thread::resume(m_hThreadHandle); ACE_Thread::resume(m_hThreadHandle);
} }
ACE_THR_FUNC_RETURN Thread::ThreadTask(void * param) ACE_THR_FUNC_RETURN Thread::ThreadTask(void* param)
{ {
Runnable * _task = (Runnable*)param; Runnable* _task = (Runnable*)param;
_task->run(); _task->run();
// task execution complete, free referecne added at // task execution complete, free referecne added at
@ -205,17 +205,17 @@ ACE_hthread_t Thread::currentHandle()
return _handle; return _handle;
} }
Thread * Thread::current() Thread* Thread::current()
{ {
Thread * _thread = m_ThreadStorage.ts_object(); Thread* _thread = m_ThreadStorage.ts_object();
if(!_thread) if (!_thread)
{ {
_thread = new Thread(); _thread = new Thread();
_thread->m_iThreadId = Thread::currentId(); _thread->m_iThreadId = Thread::currentId();
_thread->m_hThreadHandle = Thread::currentHandle(); _thread->m_hThreadHandle = Thread::currentHandle();
Thread * _oldValue = m_ThreadStorage.ts_object(_thread); Thread* _oldValue = m_ThreadStorage.ts_object(_thread);
if(_oldValue) if (_oldValue)
delete _oldValue; delete _oldValue;
} }
@ -228,7 +228,7 @@ void Thread::setPriority(Priority type)
int _priority = m_TpEnum.getPriority(type); int _priority = m_TpEnum.getPriority(type);
int _ok = ACE_Thread::setprio(m_hThreadHandle, _priority); int _ok = ACE_Thread::setprio(m_hThreadHandle, _priority);
//remove this ASSERT in case you don't want to know is thread priority change was successful or not //remove this ASSERT in case you don't want to know is thread priority change was successful or not
MANGOS_ASSERT (_ok == 0); MANGOS_ASSERT(_ok == 0);
#endif #endif
} }

View file

@ -35,7 +35,7 @@ namespace ACE_Based
void incReference() { ++m_refs; } void incReference() { ++m_refs; }
void decReference() void decReference()
{ {
if(!--m_refs) if (!--m_refs)
delete this; delete this;
} }
private: private:
@ -84,17 +84,17 @@ namespace ACE_Based
static void Sleep(unsigned long msecs); static void Sleep(unsigned long msecs);
static ACE_thread_t currentId(); static ACE_thread_t currentId();
static ACE_hthread_t currentHandle(); static ACE_hthread_t currentHandle();
static Thread * current(); static Thread* current();
private: private:
Thread(const Thread&); Thread(const Thread&);
Thread& operator=(const Thread&); Thread& operator=(const Thread&);
static ACE_THR_FUNC_RETURN ThreadTask(void * param); static ACE_THR_FUNC_RETURN ThreadTask(void* param);
ACE_thread_t m_iThreadId; ACE_thread_t m_iThreadId;
ACE_hthread_t m_hThreadHandle; ACE_hthread_t m_hThreadHandle;
Runnable * m_task; Runnable* m_task;
typedef ACE_TSS<Thread> ThreadStorage; typedef ACE_TSS<Thread> ThreadStorage;
//global object - container for Thread class representation of every thread //global object - container for Thread class representation of every thread

View file

@ -52,7 +52,7 @@ class WorldTimer
private: private:
WorldTimer(); WorldTimer();
WorldTimer(const WorldTimer& ); WorldTimer(const WorldTimer&);
//analogue to getMSTime() but it persists m_SystemTickTime //analogue to getMSTime() but it persists m_SystemTickTime
static uint32 getMSTime_internal(bool savetime = false); static uint32 getMSTime_internal(bool savetime = false);

View file

@ -68,47 +68,47 @@ uint32 WorldTimer::getMSTime_internal(bool savetime /*= false*/)
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int32 irand (int32 min, int32 max) int32 irand(int32 min, int32 max)
{ {
return int32 (mtRand->randInt (max - min)) + min; return int32(mtRand->randInt(max - min)) + min;
} }
uint32 urand (uint32 min, uint32 max) uint32 urand(uint32 min, uint32 max)
{ {
return mtRand->randInt (max - min) + min; return mtRand->randInt(max - min) + min;
} }
float frand (float min, float max) float frand(float min, float max)
{ {
return mtRand->randExc (max - min) + min; return mtRand->randExc(max - min) + min;
} }
int32 rand32 () int32 rand32()
{ {
return mtRand->randInt (); return mtRand->randInt();
} }
double rand_norm(void) double rand_norm(void)
{ {
return mtRand->randExc (); return mtRand->randExc();
} }
float rand_norm_f(void) float rand_norm_f(void)
{ {
return (float)mtRand->randExc (); return (float)mtRand->randExc();
} }
double rand_chance (void) double rand_chance(void)
{ {
return mtRand->randExc (100.0); return mtRand->randExc(100.0);
} }
float rand_chance_f(void) float rand_chance_f(void)
{ {
return (float)mtRand->randExc (100.0); return (float)mtRand->randExc(100.0);
} }
Tokens StrSplit(const std::string &src, const std::string &sep) Tokens StrSplit(const std::string& src, const std::string& sep)
{ {
Tokens r; Tokens r;
std::string s; std::string s;
@ -130,7 +130,7 @@ Tokens StrSplit(const std::string &src, const std::string &sep)
uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index) uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index)
{ {
if(index >= data.size()) if (index >= data.size())
return 0; return 0;
return (uint32)atoi(data[index].c_str()); return (uint32)atoi(data[index].c_str());
@ -145,18 +145,18 @@ float GetFloatValueFromArray(Tokens const& data, uint16 index)
return result; return result;
} }
void stripLineInvisibleChars(std::string &str) void stripLineInvisibleChars(std::string& str)
{ {
static std::string invChars = " \t\7\n"; static std::string invChars = " \t\7\n";
size_t wpos = 0; size_t wpos = 0;
bool space = false; bool space = false;
for(size_t pos = 0; pos < str.size(); ++pos) for (size_t pos = 0; pos < str.size(); ++pos)
{ {
if(invChars.find(str[pos])!=std::string::npos) if (invChars.find(str[pos])!=std::string::npos)
{ {
if(!space) if (!space)
{ {
str[wpos++] = ' '; str[wpos++] = ' ';
space = true; space = true;
@ -164,7 +164,7 @@ void stripLineInvisibleChars(std::string &str)
} }
else else
{ {
if(wpos!=pos) if (wpos!=pos)
str[wpos++] = str[pos]; str[wpos++] = str[pos];
else else
++wpos; ++wpos;
@ -172,7 +172,7 @@ void stripLineInvisibleChars(std::string &str)
} }
} }
if(wpos < str.size()) if (wpos < str.size())
str.erase(wpos,str.size()); str.erase(wpos,str.size());
} }
@ -184,15 +184,15 @@ std::string secsToTimeString(time_t timeInSecs, bool shortText, bool hoursOnly)
time_t days = timeInSecs / DAY; time_t days = timeInSecs / DAY;
std::ostringstream ss; std::ostringstream ss;
if(days) if (days)
ss << days << (shortText ? "d" : " Day(s) "); ss << days << (shortText ? "d" : " Day(s) ");
if(hours || hoursOnly) if (hours || hoursOnly)
ss << hours << (shortText ? "h" : " Hour(s) "); ss << hours << (shortText ? "h" : " Hour(s) ");
if(!hoursOnly) if (!hoursOnly)
{ {
if(minutes) if (minutes)
ss << minutes << (shortText ? "m" : " Minute(s) "); ss << minutes << (shortText ? "m" : " Minute(s) ");
if(secs || (!days && !hours && !minutes) ) if (secs || (!days && !hours && !minutes))
ss << secs << (shortText ? "s" : " Second(s)."); ss << secs << (shortText ? "s" : " Second(s).");
} }
@ -205,16 +205,16 @@ uint32 TimeStringToSecs(const std::string& timestring)
uint32 buffer = 0; uint32 buffer = 0;
uint32 multiplier = 0; uint32 multiplier = 0;
for(std::string::const_iterator itr = timestring.begin(); itr != timestring.end(); ++itr) for (std::string::const_iterator itr = timestring.begin(); itr != timestring.end(); ++itr)
{ {
if(isdigit(*itr)) if (isdigit(*itr))
{ {
buffer*=10; buffer*=10;
buffer+= (*itr)-'0'; buffer+= (*itr)-'0';
} }
else else
{ {
switch(*itr) switch (*itr)
{ {
case 'd': multiplier = DAY; break; case 'd': multiplier = DAY; break;
case 'h': multiplier = HOUR; break; case 'h': multiplier = HOUR; break;
@ -248,7 +248,7 @@ std::string TimeToTimestampStr(time_t t)
/// Check if the string is a valid ip address representation /// Check if the string is a valid ip address representation
bool IsIPAddress(char const* ipaddress) bool IsIPAddress(char const* ipaddress)
{ {
if(!ipaddress) if (!ipaddress)
return false; return false;
// Let the big boys do it. // Let the big boys do it.
@ -259,7 +259,7 @@ bool IsIPAddress(char const* ipaddress)
/// create PID file /// create PID file
uint32 CreatePIDFile(const std::string& filename) uint32 CreatePIDFile(const std::string& filename)
{ {
FILE * pid_file = fopen (filename.c_str(), "w" ); FILE* pid_file = fopen(filename.c_str(), "w");
if (pid_file == NULL) if (pid_file == NULL)
return 0; return 0;
@ -269,7 +269,7 @@ uint32 CreatePIDFile(const std::string& filename)
pid_t pid = getpid(); pid_t pid = getpid();
#endif #endif
fprintf(pid_file, "%d", pid ); fprintf(pid_file, "%d", pid);
fclose(pid_file); fclose(pid_file);
return (uint32)pid; return (uint32)pid;
@ -281,7 +281,7 @@ size_t utf8length(std::string& utf8str)
{ {
return utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); return utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size());
} }
catch(std::exception) catch (std::exception)
{ {
utf8str = ""; utf8str = "";
return 0; return 0;
@ -293,7 +293,7 @@ void utf8truncate(std::string& utf8str,size_t len)
try try
{ {
size_t wlen = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); size_t wlen = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size());
if(wlen <= len) if (wlen <= len)
return; return;
std::wstring wstr; std::wstring wstr;
@ -303,7 +303,7 @@ void utf8truncate(std::string& utf8str,size_t len)
char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str[0]); char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str[0]);
utf8str.resize(oend-(&utf8str[0])); // remove unused tail utf8str.resize(oend-(&utf8str[0])); // remove unused tail
} }
catch(std::exception) catch (std::exception)
{ {
utf8str = ""; utf8str = "";
} }
@ -314,9 +314,9 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
try try
{ {
size_t len = utf8::distance(utf8str,utf8str+csize); size_t len = utf8::distance(utf8str,utf8str+csize);
if(len > wsize) if (len > wsize)
{ {
if(wsize > 0) if (wsize > 0)
wstr[0] = L'\0'; wstr[0] = L'\0';
wsize = 0; wsize = 0;
return false; return false;
@ -326,9 +326,9 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
utf8::utf8to16(utf8str,utf8str+csize,wstr); utf8::utf8to16(utf8str,utf8str+csize,wstr);
wstr[len] = L'\0'; wstr[len] = L'\0';
} }
catch(std::exception) catch (std::exception)
{ {
if(wsize > 0) if (wsize > 0)
wstr[0] = L'\0'; wstr[0] = L'\0';
wsize = 0; wsize = 0;
return false; return false;
@ -347,7 +347,7 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
if (len) if (len)
utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]); utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]);
} }
catch(std::exception) catch (std::exception)
{ {
wstr = L""; wstr = L"";
return false; return false;
@ -367,7 +367,7 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str)
utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail
utf8str = utf8str2; utf8str = utf8str2;
} }
catch(std::exception) catch (std::exception)
{ {
utf8str = ""; utf8str = "";
return false; return false;
@ -387,7 +387,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str)
utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail
utf8str = utf8str2; utf8str = utf8str2;
} }
catch(std::exception) catch (std::exception)
{ {
utf8str = ""; utf8str = "";
return false; return false;
@ -401,7 +401,7 @@ typedef wchar_t const* const* wstrlist;
std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
{ {
// supported only Cyrillic cases // supported only Cyrillic cases
if(wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5) if (wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5)
return wname; return wname;
// Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently) // Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently)
@ -423,7 +423,8 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
static wchar_t const soft_End[] = { wchar_t(1), wchar_t(0x044C),wchar_t(0x0000)}; static wchar_t const soft_End[] = { wchar_t(1), wchar_t(0x044C),wchar_t(0x0000)};
static wchar_t const j_End[] = { wchar_t(1), wchar_t(0x0439),wchar_t(0x0000)}; static wchar_t const j_End[] = { wchar_t(1), wchar_t(0x0439),wchar_t(0x0000)};
static wchar_t const* const dropEnds[6][8] = { static wchar_t const* const dropEnds[6][8] =
{
{ &a_End[1], &o_End[1], &ya_End[1], &ie_End[1], &soft_End[1], &j_End[1], NULL, NULL }, { &a_End[1], &o_End[1], &ya_End[1], &ie_End[1], &soft_End[1], &j_End[1], NULL, NULL },
{ &a_End[1], &ya_End[1], &yeru_End[1], &i_End[1], NULL, NULL, NULL, NULL }, { &a_End[1], &ya_End[1], &yeru_End[1], &i_End[1], NULL, NULL, NULL, NULL },
{ &ie_End[1], &u_End[1], &yu_End[1], &i_End[1], NULL, NULL, NULL, NULL }, { &ie_End[1], &u_End[1], &yu_End[1], &i_End[1], NULL, NULL, NULL, NULL },
@ -432,11 +433,11 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
{ &ie_End[1], &i_End[1], NULL, NULL, NULL, NULL, NULL, NULL } { &ie_End[1], &i_End[1], NULL, NULL, NULL, NULL, NULL, NULL }
}; };
for(wchar_t const * const* itr = &dropEnds[declension][0]; *itr; ++itr) for (wchar_t const * const* itr = &dropEnds[declension][0]; *itr; ++itr)
{ {
size_t len = size_t((*itr)[-1]); // get length from string size field size_t len = size_t((*itr)[-1]); // get length from string size field
if(wname.substr(wname.size()-len,len)==*itr) if (wname.substr(wname.size()-len,len)==*itr)
return wname.substr(0,wname.size()-len); return wname.substr(0,wname.size()-len);
} }
@ -447,7 +448,7 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr)
{ {
#if PLATFORM == PLATFORM_WINDOWS #if PLATFORM == PLATFORM_WINDOWS
std::wstring wstr; std::wstring wstr;
if(!Utf8toWStr(utf8str,wstr)) if (!Utf8toWStr(utf8str,wstr))
return false; return false;
conStr.resize(wstr.size()); conStr.resize(wstr.size());
@ -479,19 +480,19 @@ bool Utf8FitTo(const std::string& str, std::wstring search)
{ {
std::wstring temp; std::wstring temp;
if(!Utf8toWStr(str,temp)) if (!Utf8toWStr(str,temp))
return false; return false;
// converting to lower case // converting to lower case
wstrToLower( temp ); wstrToLower(temp);
if(temp.find(search) == std::wstring::npos) if (temp.find(search) == std::wstring::npos)
return false; return false;
return true; return true;
} }
void utf8printf(FILE *out, const char *str, ...) void utf8printf(FILE* out, const char* str, ...)
{ {
va_list ap; va_list ap;
va_start(ap, str); va_start(ap, str);
@ -499,7 +500,7 @@ void utf8printf(FILE *out, const char *str, ...)
va_end(ap); va_end(ap);
} }
void vutf8printf(FILE *out, const char *str, va_list* ap) void vutf8printf(FILE* out, const char* str, va_list* ap)
{ {
#if PLATFORM == PLATFORM_WINDOWS #if PLATFORM == PLATFORM_WINDOWS
char temp_buf[32*1024]; char temp_buf[32*1024];
@ -520,13 +521,13 @@ void vutf8printf(FILE *out, const char *str, va_list* ap)
void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result) void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result)
{ {
std::ostringstream ss; std::ostringstream ss;
for(uint32 i=0; i<arrayLen; ++i) for (uint32 i=0; i<arrayLen; ++i)
{ {
for(uint8 j=0; j<2; ++j) for (uint8 j=0; j<2; ++j)
{ {
unsigned char nibble = 0x0F & (bytes[i]>>((1-j)*4)); unsigned char nibble = 0x0F & (bytes[i]>>((1-j)*4));
char encodedNibble; char encodedNibble;
if(nibble < 0x0A) if (nibble < 0x0A)
encodedNibble = '0'+nibble; encodedNibble = '0'+nibble;
else else
encodedNibble = 'A'+nibble-0x0A; encodedNibble = 'A'+nibble-0x0A;

View file

@ -26,11 +26,11 @@
typedef std::vector<std::string> Tokens; typedef std::vector<std::string> Tokens;
Tokens StrSplit(const std::string &src, const std::string &sep); Tokens StrSplit(const std::string& src, const std::string& sep);
uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index); uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
float GetFloatValueFromArray(Tokens const& data, uint16 index); float GetFloatValueFromArray(Tokens const& data, uint16 index);
void stripLineInvisibleChars(std::string &src); void stripLineInvisibleChars(std::string& src);
std::string secsToTimeString(time_t timeInSecs, bool shortText = false, bool hoursOnly = false); std::string secsToTimeString(time_t timeInSecs, bool shortText = false, bool hoursOnly = false);
uint32 TimeStringToSecs(const std::string& timestring); uint32 TimeStringToSecs(const std::string& timestring);
@ -85,7 +85,7 @@ inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply)
{ {
int32 cur = var; int32 cur = var;
cur += (apply ? val : -val); cur += (apply ? val : -val);
if(cur < 0) if (cur < 0)
cur = 0; cur = 0;
var = cur; var = cur;
} }
@ -93,7 +93,7 @@ inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply)
inline void ApplyModFloatVar(float& var, float val, bool apply) inline void ApplyModFloatVar(float& var, float val, bool apply)
{ {
var += (apply ? val : -val); var += (apply ? val : -val);
if(var < 0) if (var < 0)
var = 0; var = 0;
} }
@ -121,60 +121,60 @@ void utf8truncate(std::string& utf8str,size_t len);
inline bool isBasicLatinCharacter(wchar_t wchar) inline bool isBasicLatinCharacter(wchar_t wchar)
{ {
if(wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
return true; return true;
if(wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z
return true; return true;
return false; return false;
} }
inline bool isExtendedLatinCharacter(wchar_t wchar) inline bool isExtendedLatinCharacter(wchar_t wchar)
{ {
if(isBasicLatinCharacter(wchar)) if (isBasicLatinCharacter(wchar))
return true; return true;
if(wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
return true; return true;
if(wchar >= 0x00D8 && wchar <= 0x00DF) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN if (wchar >= 0x00D8 && wchar <= 0x00DF) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
return true; return true;
if(wchar == 0x00DF) // LATIN SMALL LETTER SHARP S if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
return true; return true;
if(wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
return true; return true;
if(wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
return true; return true;
if(wchar >= 0x0100 && wchar <= 0x012F) // LATIN CAPITAL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK if (wchar >= 0x0100 && wchar <= 0x012F) // LATIN CAPITAL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK
return true; return true;
if(wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
return true; return true;
return false; return false;
} }
inline bool isCyrillicCharacter(wchar_t wchar) inline bool isCyrillicCharacter(wchar_t wchar)
{ {
if(wchar >= 0x0410 && wchar <= 0x044F) // CYRILLIC CAPITAL LETTER A - CYRILLIC SMALL LETTER YA if (wchar >= 0x0410 && wchar <= 0x044F) // CYRILLIC CAPITAL LETTER A - CYRILLIC SMALL LETTER YA
return true; return true;
if(wchar == 0x0401 || wchar == 0x0451) // CYRILLIC CAPITAL LETTER IO, CYRILLIC SMALL LETTER IO if (wchar == 0x0401 || wchar == 0x0451) // CYRILLIC CAPITAL LETTER IO, CYRILLIC SMALL LETTER IO
return true; return true;
return false; return false;
} }
inline bool isEastAsianCharacter(wchar_t wchar) inline bool isEastAsianCharacter(wchar_t wchar)
{ {
if(wchar >= 0x1100 && wchar <= 0x11F9) // Hangul Jamo if (wchar >= 0x1100 && wchar <= 0x11F9) // Hangul Jamo
return true; return true;
if(wchar >= 0x3041 && wchar <= 0x30FF) // Hiragana + Katakana if (wchar >= 0x3041 && wchar <= 0x30FF) // Hiragana + Katakana
return true; return true;
if(wchar >= 0x3131 && wchar <= 0x318E) // Hangul Compatibility Jamo if (wchar >= 0x3131 && wchar <= 0x318E) // Hangul Compatibility Jamo
return true; return true;
if(wchar >= 0x31F0 && wchar <= 0x31FF) // Katakana Phonetic Ext. if (wchar >= 0x31F0 && wchar <= 0x31FF) // Katakana Phonetic Ext.
return true; return true;
if(wchar >= 0x3400 && wchar <= 0x4DB5) // CJK Ideographs Ext. A if (wchar >= 0x3400 && wchar <= 0x4DB5) // CJK Ideographs Ext. A
return true; return true;
if(wchar >= 0x4E00 && wchar <= 0x9FC3) // Unified CJK Ideographs if (wchar >= 0x4E00 && wchar <= 0x9FC3) // Unified CJK Ideographs
return true; return true;
if(wchar >= 0xAC00 && wchar <= 0xD7A3) // Hangul Syllables if (wchar >= 0xAC00 && wchar <= 0xD7A3) // Hangul Syllables
return true; return true;
if(wchar >= 0xFF01 && wchar <= 0xFFEE) // Halfwidth forms if (wchar >= 0xFF01 && wchar <= 0xFFEE) // Halfwidth forms
return true; return true;
return false; return false;
} }
@ -201,7 +201,7 @@ inline bool isNumericOrSpace(wchar_t wchar)
inline bool isNumeric(char const* str) inline bool isNumeric(char const* str)
{ {
for(char const* c = str; *c; ++c) for (char const* c = str; *c; ++c)
if (!isNumeric(*c)) if (!isNumeric(*c))
return false; return false;
@ -210,7 +210,7 @@ inline bool isNumeric(char const* str)
inline bool isNumeric(std::string const& str) inline bool isNumeric(std::string const& str)
{ {
for(std::string::const_iterator itr = str.begin(); itr != str.end(); ++itr) for (std::string::const_iterator itr = str.begin(); itr != str.end(); ++itr)
if (!isNumeric(*itr)) if (!isNumeric(*itr))
return false; return false;
@ -219,7 +219,7 @@ inline bool isNumeric(std::string const& str)
inline bool isNumeric(std::wstring const& str) inline bool isNumeric(std::wstring const& str)
{ {
for(std::wstring::const_iterator itr = str.begin(); itr != str.end(); ++itr) for (std::wstring::const_iterator itr = str.begin(); itr != str.end(); ++itr)
if (!isNumeric(*itr)) if (!isNumeric(*itr))
return false; return false;
@ -228,64 +228,64 @@ inline bool isNumeric(std::wstring const& str)
inline bool isBasicLatinString(std::wstring wstr, bool numericOrSpace) inline bool isBasicLatinString(std::wstring wstr, bool numericOrSpace)
{ {
for(size_t i = 0; i < wstr.size(); ++i) for (size_t i = 0; i < wstr.size(); ++i)
if(!isBasicLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i]))) if (!isBasicLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
return false; return false;
return true; return true;
} }
inline bool isExtendedLatinString(std::wstring wstr, bool numericOrSpace) inline bool isExtendedLatinString(std::wstring wstr, bool numericOrSpace)
{ {
for(size_t i = 0; i < wstr.size(); ++i) for (size_t i = 0; i < wstr.size(); ++i)
if(!isExtendedLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i]))) if (!isExtendedLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
return false; return false;
return true; return true;
} }
inline bool isCyrillicString(std::wstring wstr, bool numericOrSpace) inline bool isCyrillicString(std::wstring wstr, bool numericOrSpace)
{ {
for(size_t i = 0; i < wstr.size(); ++i) for (size_t i = 0; i < wstr.size(); ++i)
if(!isCyrillicCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i]))) if (!isCyrillicCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
return false; return false;
return true; return true;
} }
inline bool isEastAsianString(std::wstring wstr, bool numericOrSpace) inline bool isEastAsianString(std::wstring wstr, bool numericOrSpace)
{ {
for(size_t i = 0; i < wstr.size(); ++i) for (size_t i = 0; i < wstr.size(); ++i)
if(!isEastAsianCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i]))) if (!isEastAsianCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
return false; return false;
return true; return true;
} }
inline void strToUpper(std::string& str) inline void strToUpper(std::string& str)
{ {
std::transform( str.begin(), str.end(), str.begin(), toupper ); std::transform(str.begin(), str.end(), str.begin(), toupper);
} }
inline void strToLower(std::string& str) inline void strToLower(std::string& str)
{ {
std::transform( str.begin(), str.end(), str.begin(), tolower ); std::transform(str.begin(), str.end(), str.begin(), tolower);
} }
inline wchar_t wcharToUpper(wchar_t wchar) inline wchar_t wcharToUpper(wchar_t wchar)
{ {
if(wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
return wchar_t(uint16(wchar)-0x0020); return wchar_t(uint16(wchar)-0x0020);
if(wchar == 0x00DF) // LATIN SMALL LETTER SHARP S if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
return wchar_t(0x1E9E); return wchar_t(0x1E9E);
if(wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
return wchar_t(uint16(wchar)-0x0020); return wchar_t(uint16(wchar)-0x0020);
if(wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
return wchar_t(uint16(wchar)-0x0020); return wchar_t(uint16(wchar)-0x0020);
if(wchar >= 0x0101 && wchar <= 0x012F) // LATIN SMALL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK (only %2=1) if (wchar >= 0x0101 && wchar <= 0x012F) // LATIN SMALL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK (only %2=1)
{ {
if(wchar % 2 == 1) if (wchar % 2 == 1)
return wchar_t(uint16(wchar)-0x0001); return wchar_t(uint16(wchar)-0x0001);
} }
if(wchar >= 0x0430 && wchar <= 0x044F) // CYRILLIC SMALL LETTER A - CYRILLIC SMALL LETTER YA if (wchar >= 0x0430 && wchar <= 0x044F) // CYRILLIC SMALL LETTER A - CYRILLIC SMALL LETTER YA
return wchar_t(uint16(wchar)-0x0020); return wchar_t(uint16(wchar)-0x0020);
if(wchar == 0x0451) // CYRILLIC SMALL LETTER IO if (wchar == 0x0451) // CYRILLIC SMALL LETTER IO
return wchar_t(0x0401); return wchar_t(0x0401);
return wchar; return wchar;
@ -298,22 +298,22 @@ inline wchar_t wcharToUpperOnlyLatin(wchar_t wchar)
inline wchar_t wcharToLower(wchar_t wchar) inline wchar_t wcharToLower(wchar_t wchar)
{ {
if(wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z
return wchar_t(uint16(wchar)+0x0020); return wchar_t(uint16(wchar)+0x0020);
if(wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
return wchar_t(uint16(wchar)+0x0020); return wchar_t(uint16(wchar)+0x0020);
if(wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN if (wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
return wchar_t(uint16(wchar)+0x0020); return wchar_t(uint16(wchar)+0x0020);
if(wchar >= 0x0100 && wchar <= 0x012E) // LATIN CAPITAL LETTER A WITH MACRON - LATIN CAPITAL LETTER I WITH OGONEK (only %2=0) if (wchar >= 0x0100 && wchar <= 0x012E) // LATIN CAPITAL LETTER A WITH MACRON - LATIN CAPITAL LETTER I WITH OGONEK (only %2=0)
{ {
if(wchar % 2 == 0) if (wchar % 2 == 0)
return wchar_t(uint16(wchar)+0x0001); return wchar_t(uint16(wchar)+0x0001);
} }
if(wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
return wchar_t(0x00DF); return wchar_t(0x00DF);
if(wchar == 0x0401) // CYRILLIC CAPITAL LETTER IO if (wchar == 0x0401) // CYRILLIC CAPITAL LETTER IO
return wchar_t(0x0451); return wchar_t(0x0451);
if(wchar >= 0x0410 && wchar <= 0x042F) // CYRILLIC CAPITAL LETTER A - CYRILLIC CAPITAL LETTER YA if (wchar >= 0x0410 && wchar <= 0x042F) // CYRILLIC CAPITAL LETTER A - CYRILLIC CAPITAL LETTER YA
return wchar_t(uint16(wchar)+0x0020); return wchar_t(uint16(wchar)+0x0020);
return wchar; return wchar;
@ -321,12 +321,12 @@ inline wchar_t wcharToLower(wchar_t wchar)
inline void wstrToUpper(std::wstring& str) inline void wstrToUpper(std::wstring& str)
{ {
std::transform( str.begin(), str.end(), str.begin(), wcharToUpper ); std::transform(str.begin(), str.end(), str.begin(), wcharToUpper);
} }
inline void wstrToLower(std::wstring& str) inline void wstrToLower(std::wstring& str)
{ {
std::transform( str.begin(), str.end(), str.begin(), wcharToLower ); std::transform(str.begin(), str.end(), str.begin(), wcharToLower);
} }
std::wstring GetMainPartOfName(std::wstring wname, uint32 declension); std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
@ -334,8 +334,8 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
bool utf8ToConsole(const std::string& utf8str, std::string& conStr); bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
bool consoleToUtf8(const std::string& conStr,std::string& utf8str); bool consoleToUtf8(const std::string& conStr,std::string& utf8str);
bool Utf8FitTo(const std::string& str, std::wstring search); bool Utf8FitTo(const std::string& str, std::wstring search);
void utf8printf(FILE *out, const char *str, ...); void utf8printf(FILE* out, const char* str, ...);
void vutf8printf(FILE *out, const char *str, va_list* ap); void vutf8printf(FILE* out, const char* str, va_list* ap);
bool IsIPAddress(char const* ipaddress); bool IsIPAddress(char const* ipaddress);
uint32 CreatePIDFile(const std::string& filename); uint32 CreatePIDFile(const std::string& filename);

File diff suppressed because it is too large Load diff

View file

@ -72,39 +72,39 @@ class WheatyExceptionReport
{ {
public: public:
WheatyExceptionReport( ); WheatyExceptionReport();
~WheatyExceptionReport( ); ~WheatyExceptionReport();
// entry point where control comes on an unhandled exception // entry point where control comes on an unhandled exception
static LONG WINAPI WheatyUnhandledExceptionFilter( static LONG WINAPI WheatyUnhandledExceptionFilter(
PEXCEPTION_POINTERS pExceptionInfo ); PEXCEPTION_POINTERS pExceptionInfo);
static void printTracesForAllThreads(); static void printTracesForAllThreads();
private: private:
// where report info is extracted and generated // where report info is extracted and generated
static void GenerateExceptionReport( PEXCEPTION_POINTERS pExceptionInfo ); static void GenerateExceptionReport(PEXCEPTION_POINTERS pExceptionInfo);
static void PrintSystemInfo(); static void PrintSystemInfo();
static BOOL _GetWindowsVersion(TCHAR* szVersion, DWORD cntMax); static BOOL _GetWindowsVersion(TCHAR* szVersion, DWORD cntMax);
static BOOL _GetProcessorName(TCHAR* sProcessorName, DWORD maxcount); static BOOL _GetProcessorName(TCHAR* sProcessorName, DWORD maxcount);
// Helper functions // Helper functions
static LPTSTR GetExceptionString( DWORD dwCode ); static LPTSTR GetExceptionString(DWORD dwCode);
static BOOL GetLogicalAddress( PVOID addr, PTSTR szModule, DWORD len, static BOOL GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len,
DWORD& section, DWORD_PTR& offset ); DWORD& section, DWORD_PTR& offset);
static void WriteStackDetails( PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle); static void WriteStackDetails(PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle);
static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID); static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID);
static bool FormatSymbolValue( PSYMBOL_INFO, STACKFRAME *, char * pszBuffer, unsigned cbBuffer ); static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME*, char* pszBuffer, unsigned cbBuffer);
static char * DumpTypeIndex( char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool & , char*); static char* DumpTypeIndex(char*, DWORD64, DWORD, unsigned, DWORD_PTR, bool& , char*);
static char * FormatOutputValue( char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress ); static char* FormatOutputValue(char* pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress);
static BasicType GetBasicType( DWORD typeIndex, DWORD64 modBase ); static BasicType GetBasicType(DWORD typeIndex, DWORD64 modBase);
static int __cdecl _tprintf(const TCHAR * format, ...); static int __cdecl _tprintf(const TCHAR* format, ...);
// Variables used by the class // Variables used by the class
static TCHAR m_szLogFileName[MAX_PATH]; static TCHAR m_szLogFileName[MAX_PATH];

View file

@ -33,7 +33,7 @@ class WorldPacket : public ByteBuffer
} }
explicit WorldPacket(uint16 opcode, size_t res=200) : ByteBuffer(res), m_opcode(opcode) { } explicit WorldPacket(uint16 opcode, size_t res=200) : ByteBuffer(res), m_opcode(opcode) { }
// copy constructor // copy constructor
WorldPacket(const WorldPacket &packet) : ByteBuffer(packet), m_opcode(packet.m_opcode) WorldPacket(const WorldPacket& packet) : ByteBuffer(packet), m_opcode(packet.m_opcode)
{ {
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12061" #define REVISION_NR "12062"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__

View file

@ -49,7 +49,7 @@ void extractDataFromSvn(FILE* EntriesFile, bool url, RawData& data)
fgets(buf,200,EntriesFile); fgets(buf,200,EntriesFile);
fgets(buf,200,EntriesFile); sscanf(buf,"%10sT%8s",data.date_str,data.time_str); fgets(buf,200,EntriesFile); sscanf(buf,"%10sT%8s",data.date_str,data.time_str);
if(url) if (url)
sprintf(data.rev_str,"%s at %s",num_str,repo_str); sprintf(data.rev_str,"%s at %s",num_str,repo_str);
else else
strcpy(data.rev_str,num_str); strcpy(data.rev_str,num_str);
@ -64,16 +64,16 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
char url_str[200]; char url_str[200];
bool found = false; bool found = false;
while(fgets(buf,200,EntriesFile)) while (fgets(buf,200,EntriesFile))
{ {
if(sscanf(buf,"%s\t\tbranch %s of %s",hash_str,branch_str,url_str)==3) if (sscanf(buf,"%s\t\tbranch %s of %s",hash_str,branch_str,url_str)==3)
{ {
found = true; found = true;
break; break;
} }
} }
if(!found) if (!found)
{ {
strcpy(data.rev_str,"*"); strcpy(data.rev_str,"*");
strcpy(data.date_str,"*"); strcpy(data.date_str,"*");
@ -81,7 +81,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
return; return;
} }
if(url) if (url)
{ {
char* host_str = NULL; char* host_str = NULL;
char* acc_str = NULL; char* acc_str = NULL;
@ -90,7 +90,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
// parse URL like git@github.com:mangos/mangos // parse URL like git@github.com:mangos/mangos
char url_buf[200]; char url_buf[200];
int res = sscanf(url_str,"git@%s",url_buf); int res = sscanf(url_str,"git@%s",url_buf);
if(res) if (res)
{ {
host_str = strtok(url_buf,":"); host_str = strtok(url_buf,":");
acc_str = strtok(NULL,"/"); acc_str = strtok(NULL,"/");
@ -99,7 +99,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
else else
{ {
res = sscanf(url_str,"git://%s",url_buf); res = sscanf(url_str,"git://%s",url_buf);
if(res) if (res)
{ {
host_str = strtok(url_buf,"/"); host_str = strtok(url_buf,"/");
acc_str = strtok(NULL,"/"); acc_str = strtok(NULL,"/");
@ -108,7 +108,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
} }
// can generate nice link // can generate nice link
if(res) if (res)
sprintf(data.rev_str,"http://%s/%s/%s/commit/%s",host_str,acc_str,repo_str,hash_str); sprintf(data.rev_str,"http://%s/%s/%s/commit/%s",host_str,acc_str,repo_str,hash_str);
// unknonw URL format, use as-is // unknonw URL format, use as-is
else else
@ -120,18 +120,18 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
time_t rev_time = 0; time_t rev_time = 0;
// extracting date/time // extracting date/time
FILE* LogFile = fopen((path+".git/logs/HEAD").c_str(), "r"); FILE* LogFile = fopen((path+".git/logs/HEAD").c_str(), "r");
if(LogFile) if (LogFile)
{ {
while(fgets(buf,200,LogFile)) while (fgets(buf,200,LogFile))
{ {
char buf2[200]; char buf2[200];
char new_hash[200]; char new_hash[200];
int unix_time = 0; int unix_time = 0;
int res2 = sscanf(buf,"%s %s %s %s %i",buf2,new_hash,buf2,buf2,&unix_time); int res2 = sscanf(buf,"%s %s %s %s %i",buf2,new_hash,buf2,buf2,&unix_time);
if(res2!=5) if (res2!=5)
continue; continue;
if(strcmp(hash_str,new_hash)) if (strcmp(hash_str,new_hash))
continue; continue;
rev_time = unix_time; rev_time = unix_time;
@ -140,7 +140,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
fclose(LogFile); fclose(LogFile);
if(rev_time) if (rev_time)
{ {
tm* aTm = localtime(&rev_time); tm* aTm = localtime(&rev_time);
// YYYY year // YYYY year
@ -168,7 +168,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
bool extractDataFromSvn(std::string filename, bool url, RawData& data) bool extractDataFromSvn(std::string filename, bool url, RawData& data)
{ {
FILE* EntriesFile = fopen(filename.c_str(), "r"); FILE* EntriesFile = fopen(filename.c_str(), "r");
if(!EntriesFile) if (!EntriesFile)
return false; return false;
extractDataFromSvn(EntriesFile,url,data); extractDataFromSvn(EntriesFile,url,data);
@ -179,7 +179,7 @@ bool extractDataFromSvn(std::string filename, bool url, RawData& data)
bool extractDataFromGit(std::string filename, std::string path, bool url, RawData& data) bool extractDataFromGit(std::string filename, std::string path, bool url, RawData& data)
{ {
FILE* EntriesFile = fopen(filename.c_str(), "r"); FILE* EntriesFile = fopen(filename.c_str(), "r");
if(!EntriesFile) if (!EntriesFile)
return false; return false;
extractDataFromGit(EntriesFile,path,url,data); extractDataFromGit(EntriesFile,path,url,data);
@ -199,7 +199,7 @@ std::string generateHeader(char const* rev_str, char const* date_str, char const
return newData.str(); return newData.str();
} }
int main(int argc, char **argv) int main(int argc, char** argv)
{ {
bool use_url = false; bool use_url = false;
bool svn_prefered = false; bool svn_prefered = false;
@ -212,20 +212,20 @@ int main(int argc, char **argv)
// -r use only revision (without repo URL) (default) // -r use only revision (without repo URL) (default)
// -u include repositire URL as commit URL or "rev at URL" // -u include repositire URL as commit URL or "rev at URL"
// -o <file> write header to specified target file // -o <file> write header to specified target file
for(int k = 1; k <= argc; ++k) for (int k = 1; k <= argc; ++k)
{ {
if(!argv[k] || !*argv[k]) if (!argv[k] || !*argv[k])
break; break;
if(argv[k][0]!='-') if (argv[k][0]!='-')
{ {
path = argv[k]; path = argv[k];
if(path.size() > 0 && (path[path.size()-1]!='/' || path[path.size()-1]!='\\')) if (path.size() > 0 && (path[path.size()-1]!='/' || path[path.size()-1]!='\\'))
path += '/'; path += '/';
break; break;
} }
switch(argv[k][1]) switch (argv[k][1])
{ {
case 'g': case 'g':
svn_prefered = false; svn_prefered = false;
@ -259,7 +259,7 @@ int main(int argc, char **argv)
bool res = false; bool res = false;
if(svn_prefered) if (svn_prefered)
{ {
/// SVN data /// SVN data
res = extractDataFromSvn(path+".svn/entries",use_url,data); res = extractDataFromSvn(path+".svn/entries",use_url,data);
@ -280,7 +280,7 @@ int main(int argc, char **argv)
res = extractDataFromSvn(path+"_svn/entries",use_url,data); res = extractDataFromSvn(path+"_svn/entries",use_url,data);
} }
if(res) if (res)
newData = generateHeader(data.rev_str,data.date_str,data.time_str); newData = generateHeader(data.rev_str,data.date_str,data.time_str);
else else
newData = generateHeader("*", "*", "*"); newData = generateHeader("*", "*", "*");
@ -289,12 +289,12 @@ int main(int argc, char **argv)
/// get existed header data for compare /// get existed header data for compare
std::string oldData; std::string oldData;
if(FILE* HeaderFile = fopen(outfile.c_str(),"rb")) if (FILE* HeaderFile = fopen(outfile.c_str(),"rb"))
{ {
while(!feof(HeaderFile)) while (!feof(HeaderFile))
{ {
int c = fgetc(HeaderFile); int c = fgetc(HeaderFile);
if(c < 0) if (c < 0)
break; break;
oldData += (char)c; oldData += (char)c;
} }
@ -303,9 +303,9 @@ int main(int argc, char **argv)
} }
/// update header only if different data /// update header only if different data
if(newData != oldData) if (newData != oldData)
{ {
if(FILE* OutputFile = fopen(outfile.c_str(),"wb")) if (FILE* OutputFile = fopen(outfile.c_str(),"wb"))
{ {
fprintf(OutputFile,"%s",newData.c_str()); fprintf(OutputFile,"%s",newData.c_str());
fclose(OutputFile); fclose(OutputFile);