Merge branch 'master' of https://github.com/huoji120/csgo2_tiny_server_plugin_system
This commit is contained in:
77
csgo2/Server.cpp
Normal file
77
csgo2/Server.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "server.h"
|
||||
namespace Server {
|
||||
size_t receive_data(void* contents, size_t size, size_t nmemb, void* stream) {
|
||||
std::string* str = (std::string*)stream;
|
||||
(*str).append((char*)contents, size * nmemb);
|
||||
return size * nmemb;
|
||||
}
|
||||
CURLcode HttpGet(const std::string& strUrl, std::string& strResponse,
|
||||
std::string header, int nTimeout) {
|
||||
CURLcode res;
|
||||
CURL* pCURL = curl_easy_init();
|
||||
if (pCURL == NULL) {
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
struct curl_slist* headers = NULL;
|
||||
|
||||
if (header.empty() == false) {
|
||||
headers = curl_slist_append(headers, (char*)header.c_str());
|
||||
}
|
||||
headers = curl_slist_append(headers, "Accept: application/json");
|
||||
headers = curl_slist_append(headers,
|
||||
"Content-Type: application/json"); // text/html
|
||||
headers = curl_slist_append(headers, "charsets: utf-8");
|
||||
curl_easy_setopt(pCURL, CURLOPT_HTTPHEADER, headers);
|
||||
curl_easy_setopt(pCURL, CURLOPT_URL, strUrl.c_str());
|
||||
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(pCURL, CURLOPT_NOSIGNAL, 1L);
|
||||
curl_easy_setopt(pCURL, CURLOPT_TIMEOUT, nTimeout);
|
||||
curl_easy_setopt(pCURL, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_easy_setopt(pCURL, CURLOPT_NOPROGRESS, 1L);
|
||||
curl_easy_setopt(pCURL, CURLOPT_WRITEFUNCTION, receive_data);
|
||||
curl_easy_setopt(pCURL, CURLOPT_WRITEDATA, (void*)&strResponse);
|
||||
res = curl_easy_perform(pCURL);
|
||||
curl_slist_free_all(headers);
|
||||
curl_easy_cleanup(pCURL);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
CURLcode HttpPost(const std::string& strUrl, std::string header,
|
||||
std::string szJson, std::string& strResponse, int nTimeout) {
|
||||
CURLcode res;
|
||||
CURL* pCURL = curl_easy_init();
|
||||
struct curl_slist* headers = NULL;
|
||||
if (pCURL == NULL) {
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
if (header.empty() == false) {
|
||||
headers = curl_slist_append(headers, (char*)header.c_str());
|
||||
}
|
||||
CURLcode ret;
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_URL, strUrl.c_str());
|
||||
// std::string data = curl_easy_escape(pCURL, szJson.c_str(),
|
||||
// szJson.size());
|
||||
std::string data = szJson;
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_POST, 1L);
|
||||
// headers = curl_slist_append(headers, "expect: ");
|
||||
headers = curl_slist_append(headers, "Accept: application/json");
|
||||
headers = curl_slist_append(headers,
|
||||
"Content-Type: application/json"); // text/html
|
||||
headers = curl_slist_append(headers, "charsets: utf-8");
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_HTTPHEADER, headers);
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_POSTFIELDS, data.c_str());
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_TIMEOUT, 60);
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_NOSIGNAL, 1);
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_TIMEOUT_MS, 60000);
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_SSL_VERIFYPEER, false);
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_NOPROGRESS, 1L);
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_WRITEFUNCTION, receive_data);
|
||||
ret = curl_easy_setopt(pCURL, CURLOPT_WRITEDATA, (void*)&strResponse);
|
||||
res = curl_easy_perform(pCURL);
|
||||
curl_slist_free_all(headers);
|
||||
curl_easy_cleanup(pCURL);
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace Server
|
||||
9
csgo2/Server.h
Normal file
9
csgo2/Server.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "head.h"
|
||||
#include "libcurl/libcurl.h"
|
||||
namespace Server {
|
||||
CURLcode HttpPost(const std::string& strUrl, std::string header,
|
||||
std::string szJson, std::string& strResponse, int nTimeout);
|
||||
CURLcode HttpGet(const std::string& strUrl, std::string& strResponse,
|
||||
std::string header, int nTimeout);
|
||||
} // namespace Server
|
||||
@@ -82,12 +82,14 @@
|
||||
<IncludePath>$(MSBuildProjectDirectory)\sdk\protobuf-2.6.1\src;$(MSBuildProjectDirectory)\LuaBridge;$(IncludePath)</IncludePath>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<LibraryPath>$(ProjectDir)libcurl\lib\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(MSBuildProjectDirectory)\sdk\protobuf-2.6.1\src;$(MSBuildProjectDirectory)\LuaBridge;$(IncludePath)</IncludePath>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<LibraryPath>$(ProjectDir)libcurl\lib\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -137,6 +139,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -150,6 +153,8 @@
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -157,6 +162,7 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -166,6 +172,7 @@
|
||||
<ClInclude Include="head.h" />
|
||||
<ClInclude Include="hooks.h" />
|
||||
<ClInclude Include="interface.h" />
|
||||
<ClInclude Include="luaCjson\strbuf.h" />
|
||||
<ClInclude Include="lua\lapi.h" />
|
||||
<ClInclude Include="lua\lauxlib.h" />
|
||||
<ClInclude Include="lua\lcode.h" />
|
||||
@@ -241,6 +248,7 @@
|
||||
<ClInclude Include="sdk\tier1\UtlString.hpp" />
|
||||
<ClInclude Include="sdk\tier1\UtlVector.hpp" />
|
||||
<ClInclude Include="sdk_tools.h" />
|
||||
<ClInclude Include="Server.h" />
|
||||
<ClInclude Include="stb.hh" />
|
||||
<ClInclude Include="timer.h" />
|
||||
<ClInclude Include="tools.h" />
|
||||
@@ -256,6 +264,9 @@
|
||||
<ClCompile Include="global.cpp" />
|
||||
<ClCompile Include="hooks.cpp" />
|
||||
<ClCompile Include="interface.cpp" />
|
||||
<ClCompile Include="luaCjson\fpconv.c" />
|
||||
<ClCompile Include="luaCjson\lua_cjson.c" />
|
||||
<ClCompile Include="luaCjson\strbuf.c" />
|
||||
<ClCompile Include="lua\lapi.c" />
|
||||
<ClCompile Include="lua\lauxlib.c" />
|
||||
<ClCompile Include="lua\lbaselib.c" />
|
||||
@@ -311,6 +322,7 @@
|
||||
<ClCompile Include="sdk\convar\convar.cpp" />
|
||||
<ClCompile Include="sdk\tier1\UtlString.cpp" />
|
||||
<ClCompile Include="sdk_tools.cpp" />
|
||||
<ClCompile Include="Server.cpp" />
|
||||
<ClCompile Include="timer.cpp" />
|
||||
<ClCompile Include="tools.cpp" />
|
||||
<ClCompile Include="version_hijack.cpp" />
|
||||
|
||||
@@ -85,6 +85,15 @@
|
||||
<Filter Include="源文件\hijack">
|
||||
<UniqueIdentifier>{23cedcbc-aa1d-444b-baf2-0f55c87c525e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="源文件\script_engine\lua_cjson">
|
||||
<UniqueIdentifier>{40443ff4-f9c7-4ed8-824e-244fc667bcf3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="源文件\http">
|
||||
<UniqueIdentifier>{766101f1-81fc-457d-b23e-f896d2582e12}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="头文件\http">
|
||||
<UniqueIdentifier>{6733acfb-5291-4538-9448-3e945dc649ce}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
@@ -354,6 +363,12 @@
|
||||
<ClInclude Include="sdk\public\Vector_Sdk.h">
|
||||
<Filter>头文件\sdk\public</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Server.h">
|
||||
<Filter>头文件\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="luaCjson\strbuf.h">
|
||||
<Filter>源文件\script_engine\lua_cjson</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
@@ -536,6 +551,18 @@
|
||||
<ClCompile Include="version_hijack.cpp">
|
||||
<Filter>源文件\hijack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Server.cpp">
|
||||
<Filter>源文件\http</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="luaCjson\lua_cjson.c">
|
||||
<Filter>源文件\script_engine\lua_cjson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="luaCjson\strbuf.c">
|
||||
<Filter>源文件\script_engine\lua_cjson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="luaCjson\fpconv.c">
|
||||
<Filter>源文件\script_engine\lua_cjson</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
||||
@@ -37,6 +37,7 @@ auto init(void* ctx) -> bool {
|
||||
|
||||
Sleep(200);
|
||||
}
|
||||
global::isMetaModInit = (GetModuleHandleA("metamod.2.cs2.dll") != nullptr);
|
||||
if (Offset::Init() == false) {
|
||||
LOG("Offset::Init() == false !\n");
|
||||
return false;
|
||||
|
||||
158
csgo2/events.cpp
158
csgo2/events.cpp
@@ -1,57 +1,56 @@
|
||||
#include "events.h"
|
||||
|
||||
namespace events {
|
||||
auto OnPlayerTeamChangeEevent(IGameEvent* event) -> void {
|
||||
GameEventKeySymbol_t userIdNameParams{"userid"};
|
||||
GameEventKeySymbol_t teamNameParams{"team"};
|
||||
GameEventKeySymbol_t oldteamNameParams{"oldteam"};
|
||||
GameEventKeySymbol_t disconnectNameParams{"disconnect"};
|
||||
GameEventKeySymbol_t silentNameParams{"silent"};
|
||||
GameEventKeySymbol_t isbotParams{"isbot"};
|
||||
|
||||
const auto PlayerPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
event->GetPlayerPawn(userIdNameParams));
|
||||
if (PlayerPawn == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (PlayerPawn->IsBasePlayerController() == false) {
|
||||
return;
|
||||
}
|
||||
const auto Player = PlayerPawn->GetPlayerController();
|
||||
if (Player == nullptr) {
|
||||
return;
|
||||
}
|
||||
const auto playerIndex = Player->GetRefEHandle().GetEntryIndex();
|
||||
auto team = event->GetInt(teamNameParams);
|
||||
auto oldTeam = event->GetInt(oldteamNameParams);
|
||||
auto disconnect = event->GetBool(disconnectNameParams);
|
||||
auto slient = event->GetBool(silentNameParams);
|
||||
auto isBot = event->GetBool(isbotParams);
|
||||
if (ScriptCallBacks::luaCall_onPlayerTeamChange(
|
||||
playerIndex, team, oldTeam, disconnect, slient, isBot) == true) {
|
||||
event->SetBool(silentNameParams, true);
|
||||
}
|
||||
}
|
||||
auto OnPlayerHurtEvent(IGameEvent* event) -> void {
|
||||
/*
|
||||
auto luaCall_onPlayerHurt(int userid, int attacker, int health, int armor,
|
||||
const char* weapon, int dmg_health, int dmg_armor,
|
||||
int hitgroup) -> void
|
||||
*/
|
||||
UnkGameEventStruct_t userIdNameParams{"userid"};
|
||||
UnkGameEventStruct_t attackerNameParams{"attacker"};
|
||||
UnkGameEventStruct_t healthNameParams{"health"};
|
||||
UnkGameEventStruct_t armorNameParams{0};
|
||||
UnkGameEventStruct_t weaponNameParams{0};
|
||||
UnkGameEventStruct_t dmg_healthNameParams{0};
|
||||
UnkGameEventStruct_t dmg_armorNameParams{0};
|
||||
UnkGameEventStruct_t hitgroupNameParams{0};
|
||||
|
||||
static const auto healthStr = "health";
|
||||
static const auto armorStr = "armor";
|
||||
static const auto weaponStr = "weapon";
|
||||
static const auto dmg_healthStr = "dmg_health";
|
||||
static const auto dmg_armorStr = "dmg_armor";
|
||||
static const auto hitgroupStr = "hitgroup";
|
||||
|
||||
// healthNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
// healthStr, sizeof healthStr, SERVER_HASH_FUCNTION_KEY);
|
||||
// healthNameParams.m_Key = healthStr;
|
||||
|
||||
armorNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
armorStr, sizeof armorStr, SERVER_HASH_FUCNTION_KEY);
|
||||
armorNameParams.m_Key = armorStr;
|
||||
|
||||
weaponNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
weaponStr, sizeof weaponStr, SERVER_HASH_FUCNTION_KEY);
|
||||
|
||||
weaponNameParams.m_Key = weaponStr;
|
||||
|
||||
dmg_healthNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
dmg_healthStr, sizeof dmg_healthStr, SERVER_HASH_FUCNTION_KEY);
|
||||
dmg_healthNameParams.m_Key = dmg_healthStr;
|
||||
|
||||
dmg_armorNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
dmg_armorStr, sizeof dmg_armorStr, SERVER_HASH_FUCNTION_KEY);
|
||||
dmg_armorNameParams.m_Key = dmg_armorStr;
|
||||
|
||||
hitgroupNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
hitgroupStr, sizeof hitgroupStr, SERVER_HASH_FUCNTION_KEY);
|
||||
hitgroupNameParams.m_Key = hitgroupStr;
|
||||
GameEventKeySymbol_t userIdNameParams{"userid"};
|
||||
GameEventKeySymbol_t attackerNameParams{"attacker"};
|
||||
GameEventKeySymbol_t healthNameParams{"health"};
|
||||
GameEventKeySymbol_t armorNameParams{"armor"};
|
||||
GameEventKeySymbol_t weaponNameParams{"weapon"};
|
||||
GameEventKeySymbol_t dmg_healthNameParams{"dmg_health"};
|
||||
GameEventKeySymbol_t dmg_armorNameParams{"dmg_armor"};
|
||||
GameEventKeySymbol_t hitgroupNameParams{"hitgroup"};
|
||||
|
||||
const auto victimPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
event->GetPlayerPawn(&userIdNameParams));
|
||||
event->GetPlayerPawn(userIdNameParams));
|
||||
const auto attackerPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
event->GetPlayerPawn(&attackerNameParams));
|
||||
event->GetPlayerPawn(attackerNameParams));
|
||||
if (victimPawn == nullptr || attackerPawn == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -67,12 +66,12 @@ auto OnPlayerHurtEvent(IGameEvent* event) -> void {
|
||||
const auto victimIndex = victim->GetRefEHandle().GetEntryIndex();
|
||||
const auto attackerIndex = attacker->GetRefEHandle().GetEntryIndex();
|
||||
|
||||
auto health = event->GetInt(&healthNameParams);
|
||||
auto armor = event->GetInt(&armorNameParams);
|
||||
auto weapon = event->GetString(&weaponNameParams);
|
||||
auto dmg_health = event->GetInt(&dmg_healthNameParams);
|
||||
auto dmg_armor = event->GetInt(&dmg_armorNameParams);
|
||||
auto hitgroup = event->GetInt(&hitgroupNameParams);
|
||||
auto health = event->GetInt(healthNameParams);
|
||||
auto armor = event->GetInt(armorNameParams);
|
||||
auto weapon = event->GetString(weaponNameParams);
|
||||
auto dmg_health = event->GetInt(dmg_healthNameParams);
|
||||
auto dmg_armor = event->GetInt(dmg_armorNameParams);
|
||||
auto hitgroup = event->GetInt(hitgroupNameParams);
|
||||
ScriptCallBacks::luaCall_onPlayerHurt(victimIndex, attackerIndex, health,
|
||||
armor, weapon, dmg_health, dmg_armor,
|
||||
hitgroup);
|
||||
@@ -84,45 +83,25 @@ auto OnRoundEndEvent(IGameEvent* event) -> void {
|
||||
"message" "string" // end round message
|
||||
*/
|
||||
|
||||
UnkGameEventStruct_t winnerNameParams{0};
|
||||
UnkGameEventStruct_t reasonNameParams{0};
|
||||
UnkGameEventStruct_t messageNameParams{0};
|
||||
GameEventKeySymbol_t winnerNameParams{"winner"};
|
||||
GameEventKeySymbol_t reasonNameParams{"reason"};
|
||||
GameEventKeySymbol_t messageNameParams{"message"};
|
||||
|
||||
static const auto winnerStr = "winner";
|
||||
static const auto reasonStr = "reason";
|
||||
static const auto messageStr = "message";
|
||||
|
||||
winnerNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
winnerStr, sizeof winnerStr, SERVER_HASH_FUCNTION_KEY);
|
||||
winnerNameParams.m_Key = winnerStr;
|
||||
|
||||
reasonNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
reasonStr, sizeof reasonStr, SERVER_HASH_FUCNTION_KEY);
|
||||
reasonNameParams.m_Key = reasonStr;
|
||||
|
||||
messageNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
messageStr, sizeof messageStr, SERVER_HASH_FUCNTION_KEY);
|
||||
messageNameParams.m_Key = messageStr;
|
||||
|
||||
const auto message = event->GetString(&messageNameParams);
|
||||
const auto winner = event->GetInt(&winnerNameParams);
|
||||
const auto reason = event->GetInt(&reasonNameParams);
|
||||
const auto message = event->GetString(messageNameParams);
|
||||
const auto winner = event->GetInt(winnerNameParams);
|
||||
const auto reason = event->GetInt(reasonNameParams);
|
||||
|
||||
ScriptCallBacks::luaCall_onRoundEnd(winner, reason, message);
|
||||
}
|
||||
auto OnRoundStartEvent(IGameEvent* event) -> void {
|
||||
UnkGameEventStruct_t timelimitNameParams{0};
|
||||
static const auto timelimitStr = "timelimit";
|
||||
timelimitNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
timelimitStr, sizeof timelimitStr, SERVER_HASH_FUCNTION_KEY);
|
||||
timelimitNameParams.m_Key = timelimitStr;
|
||||
const auto timelimit = event->GetInt(&timelimitNameParams);
|
||||
GameEventKeySymbol_t timelimitNameParams{"timelimit"};
|
||||
const auto timelimit = event->GetInt(timelimitNameParams);
|
||||
ScriptCallBacks::luaCall_onRoundStart(timelimit);
|
||||
}
|
||||
auto OnPlayerSpawnEvent(IGameEvent* event) -> void {
|
||||
UnkGameEventStruct_t userIdNameParams{"userid"};
|
||||
GameEventKeySymbol_t userIdNameParams{"userid"};
|
||||
const auto playerPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
event->GetPlayerPawn(&userIdNameParams));
|
||||
event->GetPlayerPawn(userIdNameParams));
|
||||
if (playerPawn == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -134,18 +113,15 @@ auto OnPlayerSpawnEvent(IGameEvent* event) -> void {
|
||||
ScriptCallBacks::luaCall_onPlayerSpawn(playerIndex);
|
||||
}
|
||||
auto OnPlayerDeathEvent(IGameEvent* event) -> void {
|
||||
UnkGameEventStruct_t userIdNameParams{"userid"};
|
||||
UnkGameEventStruct_t attackerNameParams{"attacker"};
|
||||
UnkGameEventStruct_t headshotNameParams{0};
|
||||
static const auto headShotStr = "headshot";
|
||||
headshotNameParams.m_Unk = Offset::FnServerHashFunction(
|
||||
headShotStr, sizeof headShotStr, SERVER_HASH_FUCNTION_KEY);
|
||||
headshotNameParams.m_Key = headShotStr;
|
||||
GameEventKeySymbol_t userIdNameParams{"userid"};
|
||||
GameEventKeySymbol_t attackerNameParams{"attacker"};
|
||||
GameEventKeySymbol_t headshotNameParams{"headshot"};
|
||||
|
||||
const auto victimPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
event->GetPlayerPawn(&userIdNameParams));
|
||||
event->GetPlayerPawn(userIdNameParams));
|
||||
const auto attackerPawn = reinterpret_cast<CCSPlayerPawn*>(
|
||||
event->GetPlayerPawn(&attackerNameParams));
|
||||
const auto isHeadShot = event->GetBool(&headshotNameParams);
|
||||
event->GetPlayerPawn(attackerNameParams));
|
||||
const auto isHeadShot = event->GetBool(headshotNameParams);
|
||||
if (victimPawn == nullptr || attackerPawn == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -165,6 +141,9 @@ auto OnPlayerDeathEvent(IGameEvent* event) -> void {
|
||||
// printf("player[%p] %s kill[%p] %llu\n", attacker,
|
||||
// &attacker->m_iszPlayerName(), victim, &victim->m_steamID());
|
||||
}
|
||||
auto OnConsoleChat(std::string message) -> bool {
|
||||
return ScriptCallBacks::luaCall_onPlayerSpeak(-1, static_cast<int>(_ChatType::kConsole), message);
|
||||
}
|
||||
auto OnPlayerChat(CCSPlayerController* player, std::string message) -> bool {
|
||||
auto [procesChatSuccess, chatType, chatCtx] =
|
||||
SdkTools::ProcessChatString(message);
|
||||
@@ -172,7 +151,8 @@ auto OnPlayerChat(CCSPlayerController* player, std::string message) -> bool {
|
||||
return false;
|
||||
}
|
||||
return ScriptCallBacks::luaCall_onPlayerSpeak(
|
||||
player->GetRefEHandle().GetEntryIndex(), chatType, chatCtx);
|
||||
player->GetRefEHandle().GetEntryIndex(), static_cast<int>(chatType),
|
||||
chatCtx);
|
||||
}
|
||||
auto OnPlayerConnect(int slot, const char* pszName, uint64_t xuid,
|
||||
const char* pszNetworkID, const char* pszAddress,
|
||||
|
||||
@@ -4,6 +4,7 @@ class CCSPlayerController;
|
||||
namespace events {
|
||||
auto OnPlayerDeathEvent(IGameEvent* event) -> void;
|
||||
auto OnPlayerChat(CCSPlayerController* player, std::string message) -> bool;
|
||||
auto OnConsoleChat(std::string message) -> bool;
|
||||
auto OnPlayerConnect(int slot, const char* pszName, uint64_t xuid,
|
||||
const char* pszNetworkID, const char* pszAddress,
|
||||
bool bFakePlayer) -> void;
|
||||
@@ -14,4 +15,5 @@ auto OnPlayerSpawnEvent(IGameEvent* event) -> void;
|
||||
auto OnRoundStartEvent(IGameEvent* event) -> void;
|
||||
auto OnRoundEndEvent(IGameEvent* event) -> void;
|
||||
auto OnPlayerHurtEvent(IGameEvent* event) -> void;
|
||||
auto OnPlayerTeamChangeEevent(IGameEvent* event) -> void;
|
||||
} // namespace events
|
||||
|
||||
@@ -7,4 +7,5 @@ namespace global {
|
||||
CGlobalVars* GlobalVars;
|
||||
float m_flUniversalTime;
|
||||
float m_flLastTickedTime;
|
||||
bool isMetaModInit;
|
||||
}
|
||||
@@ -10,4 +10,5 @@ namespace global {
|
||||
extern CGlobalVars* GlobalVars;
|
||||
extern float m_flUniversalTime;
|
||||
extern float m_flLastTickedTime;
|
||||
extern bool isMetaModInit;
|
||||
}
|
||||
@@ -62,3 +62,4 @@ static void DebugPrintA(const char* format, ...) {
|
||||
#include "script_callbacks.h"
|
||||
#include "timer.h"
|
||||
#include "weapon.h"
|
||||
#include "Server.h"
|
||||
@@ -13,7 +13,7 @@ Host_Say_t original_Host_Say = NULL;
|
||||
StartupServer_t origin_StartServer = NULL;
|
||||
GameFrame_t origin_GameFrame = NULL;
|
||||
CCSWeaponBase_Spawn_t origin_CCSWeaponBase_Spawn = NULL;
|
||||
|
||||
// https://github.com/Source2ZE/CS2Fixes/blob/main/src/commands.cpp#L494
|
||||
void __fastcall hook_CCSWeaponBase_Spawn(CBaseEntity* pThis, void* a2) {
|
||||
const char* pszClassName = pThis->m_pEntity()->m_designerName;
|
||||
|
||||
@@ -31,14 +31,26 @@ void __fastcall hook_CCSWeaponBase_Spawn(CBaseEntity* pThis, void* a2) {
|
||||
pWeapon->m_AttributeManager()->m_Item()->m_bInitialized()) {
|
||||
break;
|
||||
}
|
||||
if (GameWeapons::WeaponMap.find(pszClassName) ==
|
||||
GameWeapons::WeaponMap.end()) {
|
||||
const auto weaponName = Tools::toLower(std::string(pszClassName));
|
||||
auto lookupWeaponSimpleName = std::string();
|
||||
for (const auto& weapon : GameWeapons::WeaponMap) {
|
||||
const auto& key = weapon.first;
|
||||
const auto& [fullWeaponName, weaponItemDefIndex] = weapon.second;
|
||||
if (fullWeaponName.find(weaponName) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
lookupWeaponSimpleName = key;
|
||||
break;
|
||||
}
|
||||
if (lookupWeaponSimpleName.size() <= 1) {
|
||||
break;
|
||||
}
|
||||
// lazy , fix me
|
||||
const auto [fullWeaponName, weaponiItemDefIndex] =
|
||||
GameWeapons::WeaponMap.at(pszClassName);
|
||||
GameWeapons::WeaponMap.at(lookupWeaponSimpleName);
|
||||
|
||||
LOG("Fixing a %s with index = %d and initialized = %d\n", pszClassName,
|
||||
LOG("Fixing a %s with index = %d and initialized = %d\n",
|
||||
fullWeaponName.c_str(),
|
||||
pWeapon->m_AttributeManager()->m_Item()->m_iItemDefinitionIndex(),
|
||||
pWeapon->m_AttributeManager()->m_Item()->m_bInitialized());
|
||||
|
||||
@@ -56,22 +68,23 @@ void __fastcall hook_GameFrame(void* rcx, bool simulating, bool bFirstTick,
|
||||
* true | game is ticking
|
||||
* false | game is not ticking
|
||||
*/
|
||||
if (simulating && global::HasTicked) {
|
||||
global::m_flUniversalTime +=
|
||||
global::GlobalVars->curtime - global::m_flLastTickedTime;
|
||||
} else {
|
||||
global::m_flUniversalTime += global::GlobalVars->interval_per_tick;
|
||||
if (global::GlobalVars != nullptr) {
|
||||
if (simulating && global::HasTicked) {
|
||||
global::m_flUniversalTime +=
|
||||
global::GlobalVars->curtime - global::m_flLastTickedTime;
|
||||
} else {
|
||||
global::m_flUniversalTime += global::GlobalVars->interval_per_tick;
|
||||
}
|
||||
|
||||
global::m_flLastTickedTime = global::GlobalVars->curtime;
|
||||
global::HasTicked = true;
|
||||
|
||||
GameTimer::ExcuteTimers();
|
||||
GameTickRunTime::ExcuteTickFunctions();
|
||||
}
|
||||
|
||||
global::m_flLastTickedTime = global::GlobalVars->curtime;
|
||||
global::HasTicked = true;
|
||||
|
||||
if (global::EntitySystem == nullptr) {
|
||||
global::EntitySystem = CGameEntitySystem::GetInstance();
|
||||
}
|
||||
|
||||
GameTimer::ExcuteTimers();
|
||||
GameTickRunTime::ExcuteTickFunctions();
|
||||
return origin_GameFrame(rcx, simulating, bFirstTick, bLastTick);
|
||||
}
|
||||
void __fastcall hook_StartServer(void* rcx,
|
||||
@@ -126,11 +139,17 @@ void __fastcall hook_Host_Say(void* pEntity, void* args, bool teamonly,
|
||||
char* pos = nullptr;
|
||||
bool blockMsg = false;
|
||||
do {
|
||||
if (theArgs == nullptr || theEntity == nullptr) {
|
||||
if (theArgs == nullptr) {
|
||||
break;
|
||||
}
|
||||
const auto message = std::string(theArgs->GetCommandString());
|
||||
|
||||
if (theEntity == nullptr) {
|
||||
if (events::OnConsoleChat(message) == true) {
|
||||
blockMsg = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (events::OnPlayerChat(theEntity, message) == true) {
|
||||
blockMsg = true;
|
||||
break;
|
||||
@@ -169,6 +188,7 @@ bool __fastcall hook_FireEventServerSide(CGameEventManager* rcx,
|
||||
static constexpr auto round_start = hash_32_fnv1a_const("round_start");
|
||||
static constexpr auto round_end = hash_32_fnv1a_const("round_end");
|
||||
static constexpr auto player_hurt = hash_32_fnv1a_const("player_hurt");
|
||||
static constexpr auto player_team = hash_32_fnv1a_const("player_team");
|
||||
|
||||
switch (hash_32_fnv1a_const(eventName)) {
|
||||
case player_death:
|
||||
@@ -186,6 +206,9 @@ bool __fastcall hook_FireEventServerSide(CGameEventManager* rcx,
|
||||
case player_hurt:
|
||||
events::OnPlayerHurtEvent(event);
|
||||
break;
|
||||
case player_team:
|
||||
events::OnPlayerTeamChangeEevent(event);
|
||||
break;
|
||||
// V<><56>bug,<2C>ⲻ<EFBFBD><E2B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/*
|
||||
case player_chat:
|
||||
@@ -258,6 +281,9 @@ auto initVmtHook() -> bool {
|
||||
return original_OnClientConnected && original_OnClientDisconnect &&
|
||||
origin_StartServer && origin_GameFrame;
|
||||
}
|
||||
auto initConVarHooks() -> void {
|
||||
// Offset::InterFaces::IVEngineCvar->RegisterConVar
|
||||
}
|
||||
auto init() -> bool {
|
||||
bool isSuccess = initMinHook() && initVmtHook();
|
||||
// bool isSuccess = initVmtHook();
|
||||
|
||||
14
csgo2/libcurl/inc/README.md
Normal file
14
csgo2/libcurl/inc/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# include
|
||||
|
||||
Public include files for libcurl, external users.
|
||||
|
||||
They're all placed in the curl subdirectory here for better fit in any kind of
|
||||
environment. You must include files from here using...
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
... style and point the compiler's include path to the directory holding the
|
||||
curl subdirectory. It makes it more likely to survive future modifications.
|
||||
|
||||
The public curl include files can be shared freely between different platforms
|
||||
and different architectures.
|
||||
3
csgo2/libcurl/inc/curl/.gitignore
vendored
Normal file
3
csgo2/libcurl/inc/curl/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
curlver.h.dist
|
||||
stamp-h2
|
||||
stamp-h3
|
||||
39
csgo2/libcurl/inc/curl/Makefile.am
Normal file
39
csgo2/libcurl/inc/curl/Makefile.am
Normal file
@@ -0,0 +1,39 @@
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
###########################################################################
|
||||
pkginclude_HEADERS = \
|
||||
curl.h curlver.h easy.h mprintf.h stdcheaders.h multi.h \
|
||||
typecheck-gcc.h system.h urlapi.h options.h
|
||||
|
||||
pkgincludedir= $(includedir)/curl
|
||||
|
||||
CHECKSRC = $(CS_$(V))
|
||||
CS_0 = @echo " RUN " $@;
|
||||
CS_1 =
|
||||
CS_ = $(CS_0)
|
||||
|
||||
checksrc:
|
||||
$(CHECKSRC)@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(top_srcdir)/include/curl $(pkginclude_HEADERS)
|
||||
|
||||
if CURLDEBUG
|
||||
# for debug builds, we scan the sources on all regular make invokes
|
||||
all-local: checksrc
|
||||
endif
|
||||
3037
csgo2/libcurl/inc/curl/curl.h
Normal file
3037
csgo2/libcurl/inc/curl/curl.h
Normal file
File diff suppressed because it is too large
Load Diff
77
csgo2/libcurl/inc/curl/curlver.h
Normal file
77
csgo2/libcurl/inc/curl/curlver.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef CURLINC_CURLVER_H
|
||||
#define CURLINC_CURLVER_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* This header file contains nothing but libcurl version info, generated by
|
||||
a script at release-time. This was made its own header file in 7.11.2 */
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2020 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.75.0-DEV"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 75
|
||||
#define LIBCURL_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will
|
||||
always follow this syntax:
|
||||
|
||||
0xXXYYZZ
|
||||
|
||||
Where XX, YY and ZZ are the main version, release and patch numbers in
|
||||
hexadecimal (using 8 bits each). All three numbers are always represented
|
||||
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
|
||||
appears as "0x090b07".
|
||||
|
||||
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
|
||||
Note: This define is the full hex number and _does not_ use the
|
||||
CURL_VERSION_BITS() macro since curl's own configure script greps for it
|
||||
and needs it to contain the full number.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x074b00
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
* timestamp is not stored in git, as the timestamp is properly set in the
|
||||
* tarballs by the maketgz script.
|
||||
*
|
||||
* The format of the date follows this template:
|
||||
*
|
||||
* "2007-11-23"
|
||||
*/
|
||||
#define LIBCURL_TIMESTAMP "[unreleased]"
|
||||
|
||||
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
|
||||
#define CURL_AT_LEAST_VERSION(x,y,z) \
|
||||
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
|
||||
|
||||
#endif /* CURLINC_CURLVER_H */
|
||||
123
csgo2/libcurl/inc/curl/easy.h
Normal file
123
csgo2/libcurl/inc/curl/easy.h
Normal file
@@ -0,0 +1,123 @@
|
||||
#ifndef CURLINC_EASY_H
|
||||
#define CURLINC_EASY_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Flag bits in the curl_blob struct: */
|
||||
#define CURL_BLOB_COPY 1 /* tell libcurl to copy the data */
|
||||
#define CURL_BLOB_NOCOPY 0 /* tell libcurl to NOT copy the data */
|
||||
|
||||
struct curl_blob {
|
||||
void *data;
|
||||
size_t len;
|
||||
unsigned int flags; /* bit 0 is defined, the rest are reserved and should be
|
||||
left zeroes */
|
||||
};
|
||||
|
||||
CURL_EXTERN CURL *curl_easy_init(void);
|
||||
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
|
||||
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
|
||||
CURL_EXTERN void curl_easy_cleanup(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_getinfo()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Request internal information from the curl session with this function. The
|
||||
* third argument MUST be a pointer to a long, a pointer to a char * or a
|
||||
* pointer to a double (as the documentation describes elsewhere). The data
|
||||
* pointed to will be filled in accordingly and can be relied upon only if the
|
||||
* function returns CURLE_OK. This function is intended to get used *AFTER* a
|
||||
* performed transfer, all results from this function are undefined until the
|
||||
* transfer is completed.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_duphandle()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Creates a new curl session handle with the same options set for the handle
|
||||
* passed in. Duplicating a handle could only be a matter of cloning data and
|
||||
* options, internal state info and things like persistent connections cannot
|
||||
* be transferred. It is useful in multithreaded applications when you can run
|
||||
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||
* curl_easy_setopt() invokes in every thread.
|
||||
*/
|
||||
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_reset()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Re-initializes a CURL handle to the default values. This puts back the
|
||||
* handle to the same state as it was in when it was just created.
|
||||
*
|
||||
* It does keep: live connections, the Session ID cache, the DNS cache and the
|
||||
* cookies.
|
||||
*/
|
||||
CURL_EXTERN void curl_easy_reset(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_recv()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Receives data from the connected socket. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
|
||||
size_t *n);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_send()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Sends data over the connected socket. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
|
||||
size_t buflen, size_t *n);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_upkeep()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Performs connection upkeep for the given session handle.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
50
csgo2/libcurl/inc/curl/mprintf.h
Normal file
50
csgo2/libcurl/inc/curl/mprintf.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef CURLINC_MPRINTF_H
|
||||
#define CURLINC_MPRINTF_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h> /* needed for FILE */
|
||||
#include "curl.h" /* for CURL_EXTERN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
CURL_EXTERN int curl_mprintf(const char *format, ...);
|
||||
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
|
||||
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
|
||||
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
|
||||
const char *format, ...);
|
||||
CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
|
||||
const char *format, va_list args);
|
||||
CURL_EXTERN char *curl_maprintf(const char *format, ...);
|
||||
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_MPRINTF_H */
|
||||
456
csgo2/libcurl/inc/curl/multi.h
Normal file
456
csgo2/libcurl/inc/curl/multi.h
Normal file
@@ -0,0 +1,456 @@
|
||||
#ifndef CURLINC_MULTI_H
|
||||
#define CURLINC_MULTI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
This is an "external" header file. Don't give away any internals here!
|
||||
|
||||
GOALS
|
||||
|
||||
o Enable a "pull" interface. The application that uses libcurl decides where
|
||||
and when to ask libcurl to get/send data.
|
||||
|
||||
o Enable multiple simultaneous transfers in the same thread without making it
|
||||
complicated for the application.
|
||||
|
||||
o Enable the application to select() on its own file descriptors and curl's
|
||||
file descriptors simultaneous easily.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header file should not really need to include "curl.h" since curl.h
|
||||
* itself includes this file and we expect user applications to do #include
|
||||
* <curl/curl.h> without the need for especially including multi.h.
|
||||
*
|
||||
* For some reason we added this include here at one point, and rather than to
|
||||
* break existing (wrongly written) libcurl applications, we leave it as-is
|
||||
* but with this warning attached.
|
||||
*/
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
|
||||
typedef struct Curl_multi CURLM;
|
||||
#else
|
||||
typedef void CURLM;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
||||
curl_multi_socket*() soon */
|
||||
CURLM_OK,
|
||||
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
|
||||
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
|
||||
CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
|
||||
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
|
||||
attempted to get added - again */
|
||||
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
|
||||
callback */
|
||||
CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
|
||||
CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
|
||||
CURLM_LAST
|
||||
} CURLMcode;
|
||||
|
||||
/* just to make code nicer when using curl_multi_socket() you can now check
|
||||
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
|
||||
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
||||
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
||||
|
||||
/* bitmask bits for CURLMOPT_PIPELINING */
|
||||
#define CURLPIPE_NOTHING 0L
|
||||
#define CURLPIPE_HTTP1 1L
|
||||
#define CURLPIPE_MULTIPLEX 2L
|
||||
|
||||
typedef enum {
|
||||
CURLMSG_NONE, /* first, not used */
|
||||
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
||||
the CURLcode of the transfer */
|
||||
CURLMSG_LAST /* last, not used */
|
||||
} CURLMSG;
|
||||
|
||||
struct CURLMsg {
|
||||
CURLMSG msg; /* what this message means */
|
||||
CURL *easy_handle; /* the handle it concerns */
|
||||
union {
|
||||
void *whatever; /* message-specific data */
|
||||
CURLcode result; /* return code for transfer */
|
||||
} data;
|
||||
};
|
||||
typedef struct CURLMsg CURLMsg;
|
||||
|
||||
/* Based on poll(2) structure and values.
|
||||
* We don't use pollfd and POLL* constants explicitly
|
||||
* to cover platforms without poll(). */
|
||||
#define CURL_WAIT_POLLIN 0x0001
|
||||
#define CURL_WAIT_POLLPRI 0x0002
|
||||
#define CURL_WAIT_POLLOUT 0x0004
|
||||
|
||||
struct curl_waitfd {
|
||||
curl_socket_t fd;
|
||||
short events;
|
||||
short revents; /* not supported yet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Name: curl_multi_init()
|
||||
*
|
||||
* Desc: inititalize multi-style curl usage
|
||||
*
|
||||
* Returns: a new CURLM handle to use in all 'curl_multi' functions.
|
||||
*/
|
||||
CURL_EXTERN CURLM *curl_multi_init(void);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_add_handle()
|
||||
*
|
||||
* Desc: add a standard curl handle to the multi stack
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_remove_handle()
|
||||
*
|
||||
* Desc: removes a curl handle from the multi stack again
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_fdset()
|
||||
*
|
||||
* Desc: Ask curl for its fd_set sets. The app can use these to select() or
|
||||
* poll() on. We want curl_multi_perform() called as soon as one of
|
||||
* them are ready.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wait()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_poll()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wakeup()
|
||||
*
|
||||
* Desc: wakes up a sleeping curl_multi_poll call.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_perform()
|
||||
*
|
||||
* Desc: When the app thinks there's data available for curl it calls this
|
||||
* function to read/write whatever there is right now. This returns
|
||||
* as soon as the reads and writes are done. This function does not
|
||||
* require that there actually is data available for reading or that
|
||||
* data can be written, it can be called just in case. It returns
|
||||
* the number of handles that still transfer data in the second
|
||||
* argument's integer-pointer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
||||
* returns errors etc regarding the whole multi stack. There might
|
||||
* still have occurred problems on individual transfers even when
|
||||
* this returns OK.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_cleanup()
|
||||
*
|
||||
* Desc: Cleans up and removes a whole multi stack. It does not free or
|
||||
* touch any individual easy handles in any way. We need to define
|
||||
* in what state those handles will be if this function is called
|
||||
* in the middle of a transfer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_info_read()
|
||||
*
|
||||
* Desc: Ask the multi handle if there's any messages/informationals from
|
||||
* the individual transfers. Messages include informationals such as
|
||||
* error code from the transfer or just the fact that a transfer is
|
||||
* completed. More details on these should be written down as well.
|
||||
*
|
||||
* Repeated calls to this function will return a new struct each
|
||||
* time, until a special "end of msgs" struct is returned as a signal
|
||||
* that there is no more to get at this point.
|
||||
*
|
||||
* The data the returned pointer points to will not survive calling
|
||||
* curl_multi_cleanup().
|
||||
*
|
||||
* The 'CURLMsg' struct is meant to be very simple and only contain
|
||||
* very basic information. If more involved information is wanted,
|
||||
* we will provide the particular "transfer handle" in that struct
|
||||
* and that should/could/would be used in subsequent
|
||||
* curl_easy_getinfo() calls (or similar). The point being that we
|
||||
* must never expose complex structs to applications, as then we'll
|
||||
* undoubtably get backwards compatibility problems in the future.
|
||||
*
|
||||
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
|
||||
* of structs. It also writes the number of messages left in the
|
||||
* queue (after this read) in the integer the second argument points
|
||||
* to.
|
||||
*/
|
||||
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_strerror()
|
||||
*
|
||||
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
|
||||
* value into the equivalent human readable error string. This is
|
||||
* useful for printing meaningful error messages.
|
||||
*
|
||||
* Returns: A pointer to a null-terminated error message.
|
||||
*/
|
||||
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_socket() and
|
||||
* curl_multi_socket_all()
|
||||
*
|
||||
* Desc: An alternative version of curl_multi_perform() that allows the
|
||||
* application to pass in one of the file descriptors that have been
|
||||
* detected to have "action" on them and let libcurl perform.
|
||||
* See man page for details.
|
||||
*/
|
||||
#define CURL_POLL_NONE 0
|
||||
#define CURL_POLL_IN 1
|
||||
#define CURL_POLL_OUT 2
|
||||
#define CURL_POLL_INOUT 3
|
||||
#define CURL_POLL_REMOVE 4
|
||||
|
||||
#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
|
||||
|
||||
#define CURL_CSELECT_IN 0x01
|
||||
#define CURL_CSELECT_OUT 0x02
|
||||
#define CURL_CSELECT_ERR 0x04
|
||||
|
||||
typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
|
||||
curl_socket_t s, /* socket */
|
||||
int what, /* see above */
|
||||
void *userp, /* private callback
|
||||
pointer */
|
||||
void *socketp); /* private socket
|
||||
pointer */
|
||||
/*
|
||||
* Name: curl_multi_timer_callback
|
||||
*
|
||||
* Desc: Called by libcurl whenever the library detects a change in the
|
||||
* maximum number of milliseconds the app is allowed to wait before
|
||||
* curl_multi_socket() or curl_multi_perform() must be called
|
||||
* (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: The callback should return zero.
|
||||
*/
|
||||
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
|
||||
long timeout_ms, /* see above */
|
||||
void *userp); /* private callback
|
||||
pointer */
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
|
||||
curl_socket_t s,
|
||||
int ev_bitmask,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
|
||||
/* This macro below was added in 7.16.3 to push users who recompile to use
|
||||
the new curl_multi_socket_action() instead of the old curl_multi_socket()
|
||||
*/
|
||||
#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Name: curl_multi_timeout()
|
||||
*
|
||||
* Desc: Returns the maximum number of milliseconds the app is allowed to
|
||||
* wait before curl_multi_socket() or curl_multi_perform() must be
|
||||
* called (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
|
||||
typedef enum {
|
||||
/* This is the socket callback function pointer */
|
||||
CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1),
|
||||
|
||||
/* This is the argument passed to the socket callback */
|
||||
CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2),
|
||||
|
||||
/* set to 1 to enable pipelining for this multi handle */
|
||||
CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3),
|
||||
|
||||
/* This is the timer callback function pointer */
|
||||
CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4),
|
||||
|
||||
/* This is the argument passed to the timer callback */
|
||||
CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5),
|
||||
|
||||
/* maximum number of entries in the connection cache */
|
||||
CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6),
|
||||
|
||||
/* maximum number of (pipelining) connections to one host */
|
||||
CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7),
|
||||
|
||||
/* maximum number of requests in a pipeline */
|
||||
CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8),
|
||||
|
||||
/* a connection with a content-length longer than this
|
||||
will not be considered for pipelining */
|
||||
CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9),
|
||||
|
||||
/* a connection with a chunk length longer than this
|
||||
will not be considered for pipelining */
|
||||
CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10),
|
||||
|
||||
/* a list of site names(+port) that are blocked from pipelining */
|
||||
CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11),
|
||||
|
||||
/* a list of server types that are blocked from pipelining */
|
||||
CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12),
|
||||
|
||||
/* maximum number of open connections in total */
|
||||
CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13),
|
||||
|
||||
/* This is the server push callback function pointer */
|
||||
CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14),
|
||||
|
||||
/* This is the argument passed to the server push callback */
|
||||
CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15),
|
||||
|
||||
/* maximum number of concurrent streams to support on a connection */
|
||||
CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16),
|
||||
|
||||
CURLMOPT_LASTENTRY /* the last unused */
|
||||
} CURLMoption;
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_setopt()
|
||||
*
|
||||
* Desc: Sets options for the multi handle.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_assign()
|
||||
*
|
||||
* Desc: This function sets an association in the multi handle between the
|
||||
* given socket and a private pointer of the application. This is
|
||||
* (only) useful for curl_multi_socket uses.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
||||
curl_socket_t sockfd, void *sockp);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_push_callback
|
||||
*
|
||||
* Desc: This callback gets called when a new stream is being pushed by the
|
||||
* server. It approves or denies the new stream. It can also decide
|
||||
* to completely fail the connection.
|
||||
*
|
||||
* Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT
|
||||
*/
|
||||
#define CURL_PUSH_OK 0
|
||||
#define CURL_PUSH_DENY 1
|
||||
#define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */
|
||||
|
||||
struct curl_pushheaders; /* forward declaration only */
|
||||
|
||||
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
|
||||
size_t num);
|
||||
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
|
||||
const char *name);
|
||||
|
||||
typedef int (*curl_push_callback)(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
68
csgo2/libcurl/inc/curl/options.h
Normal file
68
csgo2/libcurl/inc/curl/options.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef CURLINC_OPTIONS_H
|
||||
#define CURLINC_OPTIONS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CURLOT_LONG, /* long (a range of values) */
|
||||
CURLOT_VALUES, /* (a defined set or bitmask) */
|
||||
CURLOT_OFF_T, /* curl_off_t (a range of values) */
|
||||
CURLOT_OBJECT, /* pointer (void *) */
|
||||
CURLOT_STRING, /* (char * to zero terminated buffer) */
|
||||
CURLOT_SLIST, /* (struct curl_slist *) */
|
||||
CURLOT_CBPTR, /* (void * passed as-is to a callback) */
|
||||
CURLOT_BLOB, /* blob (struct curl_blob *) */
|
||||
CURLOT_FUNCTION /* function pointer */
|
||||
} curl_easytype;
|
||||
|
||||
/* Flag bits */
|
||||
|
||||
/* "alias" means it is provided for old programs to remain functional,
|
||||
we prefer another name */
|
||||
#define CURLOT_FLAG_ALIAS (1<<0)
|
||||
|
||||
/* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size
|
||||
to use for curl_easy_setopt() for the given id */
|
||||
struct curl_easyoption {
|
||||
const char *name;
|
||||
CURLoption id;
|
||||
curl_easytype type;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_by_name(const char *name);
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_by_id (CURLoption id);
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_next(const struct curl_easyoption *prev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
#endif /* CURLINC_OPTIONS_H */
|
||||
33
csgo2/libcurl/inc/curl/stdcheaders.h
Normal file
33
csgo2/libcurl/inc/curl/stdcheaders.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef CURLINC_STDCHEADERS_H
|
||||
#define CURLINC_STDCHEADERS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
size_t fread(void *, size_t, size_t, FILE *);
|
||||
size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
|
||||
int strcasecmp(const char *, const char *);
|
||||
int strncasecmp(const char *, const char *, size_t);
|
||||
|
||||
#endif /* CURLINC_STDCHEADERS_H */
|
||||
504
csgo2/libcurl/inc/curl/system.h
Normal file
504
csgo2/libcurl/inc/curl/system.h
Normal file
@@ -0,0 +1,504 @@
|
||||
#ifndef CURLINC_SYSTEM_H
|
||||
#define CURLINC_SYSTEM_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* Try to keep one section per platform, compiler and architecture, otherwise,
|
||||
* if an existing section is reused for a different one and later on the
|
||||
* original is adjusted, probably the piggybacking one can be adversely
|
||||
* changed.
|
||||
*
|
||||
* In order to differentiate between platforms/compilers/architectures use
|
||||
* only compiler built in predefined preprocessor symbols.
|
||||
*
|
||||
* curl_off_t
|
||||
* ----------
|
||||
*
|
||||
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
|
||||
* wide signed integral data type. The width of this data type must remain
|
||||
* constant and independent of any possible large file support settings.
|
||||
*
|
||||
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
|
||||
* wide signed integral data type if there is no 64-bit type.
|
||||
*
|
||||
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
|
||||
* only be violated if off_t is the only 64-bit data type available and the
|
||||
* size of off_t is independent of large file support settings. Keep your
|
||||
* build on the safe side avoiding an off_t gating. If you have a 64-bit
|
||||
* off_t then take for sure that another 64-bit data type exists, dig deeper
|
||||
* and you will find it.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__DJGPP__) || defined(__GO32__)
|
||||
# if defined(__DJGPP__) && (__DJGPP__ > 1)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__SALFORDC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# if (__BORLANDC__ < 0x520)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TURBOC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__386__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__POCC__)
|
||||
# if (__POCC__ < 280)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# elif defined(_MSC_VER)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__LCC__)
|
||||
# if defined(__e2k__) /* MCST eLbrus C Compiler */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# else /* Local (or Little) C Compiler */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
# endif
|
||||
|
||||
#elif defined(__SYMBIAN32__)
|
||||
# if defined(__EABI__) /* Treat all ARM compilers equally */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__CW32__)
|
||||
# pragma longlong on
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__VC32__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__MWERKS__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(_WIN32_WCE)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_WS2TCPIP_H 1
|
||||
|
||||
#elif defined(__VMS)
|
||||
# if defined(__VAX)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__OS400__)
|
||||
# if defined(__ILEC400__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(__MVS__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(__370__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(TPF)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TINYC__) /* also known as tcc */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
|
||||
# if !defined(__LP64) && (defined(__ILP32) || \
|
||||
defined(__i386) || \
|
||||
defined(__sparcv8) || \
|
||||
defined(__sparcv8plus))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64) || \
|
||||
defined(__amd64) || defined(__sparcv9)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__xlc__) /* IBM xlc compiler */
|
||||
# if !defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP MSVC THE PENULTIMATE ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP GENERIC GCC THE LAST ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(__GNUC__) && !defined(_SCO_DS)
|
||||
# if !defined(__LP64__) && \
|
||||
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
|
||||
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
|
||||
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
|
||||
defined(__XTENSA__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64__) || \
|
||||
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
|
||||
defined(__e2k__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#else
|
||||
/* generic "safe guess" on old 32 bit style */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
/* AIX needs <sys/poll.h> */
|
||||
#define CURL_PULL_SYS_POLL_H
|
||||
#endif
|
||||
|
||||
|
||||
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
|
||||
/* ws2tcpip.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_WS2TCPIP_H
|
||||
# include <winsock2.h>
|
||||
# include <windows.h>
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
|
||||
/* sys/types.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
|
||||
/* sys/socket.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
|
||||
/* sys/poll.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_socklen_t. */
|
||||
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_off_t. */
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
||||
* these to be visible and exported by the external libcurl interface API,
|
||||
* while also making them visible to the library internals, simply including
|
||||
* curl_setup.h, without actually needing to include curl.h internally.
|
||||
* If some day this section would grow big enough, all this should be moved
|
||||
* to its own header file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Figure out if we can use the ## preprocessor operator, which is supported
|
||||
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
|
||||
* or __cplusplus so we need to carefully check for them too.
|
||||
*/
|
||||
|
||||
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
|
||||
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
|
||||
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
|
||||
defined(__ILEC400__)
|
||||
/* This compiler is believed to have an ISO compatible preprocessor */
|
||||
#define CURL_ISOCPP
|
||||
#else
|
||||
/* This compiler is believed NOT to have an ISO compatible preprocessor */
|
||||
#undef CURL_ISOCPP
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
||||
*/
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
||||
# define CURLINC_OFF_T_C_HLPR2(x) x
|
||||
# define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x)
|
||||
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
||||
#else
|
||||
# ifdef CURL_ISOCPP
|
||||
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
||||
# else
|
||||
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
||||
# endif
|
||||
# define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix)
|
||||
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_SYSTEM_H */
|
||||
705
csgo2/libcurl/inc/curl/typecheck-gcc.h
Normal file
705
csgo2/libcurl/inc/curl/typecheck-gcc.h
Normal file
@@ -0,0 +1,705 @@
|
||||
#ifndef CURLINC_TYPECHECK_GCC_H
|
||||
#define CURLINC_TYPECHECK_GCC_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* wraps curl_easy_setopt() with typechecking */
|
||||
|
||||
/* To add a new kind of warning, add an
|
||||
* if(curlcheck_sometype_option(_curl_opt))
|
||||
* if(!curlcheck_sometype(value))
|
||||
* _curl_easy_setopt_err_sometype();
|
||||
* block and define curlcheck_sometype_option, curlcheck_sometype and
|
||||
* _curl_easy_setopt_err_sometype below
|
||||
*
|
||||
* NOTE: We use two nested 'if' statements here instead of the && operator, in
|
||||
* order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
|
||||
* when compiling with -Wlogical-op.
|
||||
*
|
||||
* To add an option that uses the same type as an existing option, you'll just
|
||||
* need to extend the appropriate _curl_*_option macro
|
||||
*/
|
||||
#define curl_easy_setopt(handle, option, value) \
|
||||
__extension__({ \
|
||||
__typeof__(option) _curl_opt = option; \
|
||||
if(__builtin_constant_p(_curl_opt)) { \
|
||||
if(curlcheck_long_option(_curl_opt)) \
|
||||
if(!curlcheck_long(value)) \
|
||||
_curl_easy_setopt_err_long(); \
|
||||
if(curlcheck_off_t_option(_curl_opt)) \
|
||||
if(!curlcheck_off_t(value)) \
|
||||
_curl_easy_setopt_err_curl_off_t(); \
|
||||
if(curlcheck_string_option(_curl_opt)) \
|
||||
if(!curlcheck_string(value)) \
|
||||
_curl_easy_setopt_err_string(); \
|
||||
if(curlcheck_write_cb_option(_curl_opt)) \
|
||||
if(!curlcheck_write_cb(value)) \
|
||||
_curl_easy_setopt_err_write_callback(); \
|
||||
if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
|
||||
if(!curlcheck_resolver_start_callback(value)) \
|
||||
_curl_easy_setopt_err_resolver_start_callback(); \
|
||||
if((_curl_opt) == CURLOPT_READFUNCTION) \
|
||||
if(!curlcheck_read_cb(value)) \
|
||||
_curl_easy_setopt_err_read_cb(); \
|
||||
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
|
||||
if(!curlcheck_ioctl_cb(value)) \
|
||||
_curl_easy_setopt_err_ioctl_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
|
||||
if(!curlcheck_sockopt_cb(value)) \
|
||||
_curl_easy_setopt_err_sockopt_cb(); \
|
||||
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
|
||||
if(!curlcheck_opensocket_cb(value)) \
|
||||
_curl_easy_setopt_err_opensocket_cb(); \
|
||||
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
|
||||
if(!curlcheck_progress_cb(value)) \
|
||||
_curl_easy_setopt_err_progress_cb(); \
|
||||
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
|
||||
if(!curlcheck_debug_cb(value)) \
|
||||
_curl_easy_setopt_err_debug_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
|
||||
if(!curlcheck_ssl_ctx_cb(value)) \
|
||||
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
||||
if(curlcheck_conv_cb_option(_curl_opt)) \
|
||||
if(!curlcheck_conv_cb(value)) \
|
||||
_curl_easy_setopt_err_conv_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
|
||||
if(!curlcheck_seek_cb(value)) \
|
||||
_curl_easy_setopt_err_seek_cb(); \
|
||||
if(curlcheck_cb_data_option(_curl_opt)) \
|
||||
if(!curlcheck_cb_data(value)) \
|
||||
_curl_easy_setopt_err_cb_data(); \
|
||||
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
|
||||
if(!curlcheck_error_buffer(value)) \
|
||||
_curl_easy_setopt_err_error_buffer(); \
|
||||
if((_curl_opt) == CURLOPT_STDERR) \
|
||||
if(!curlcheck_FILE(value)) \
|
||||
_curl_easy_setopt_err_FILE(); \
|
||||
if(curlcheck_postfields_option(_curl_opt)) \
|
||||
if(!curlcheck_postfields(value)) \
|
||||
_curl_easy_setopt_err_postfields(); \
|
||||
if((_curl_opt) == CURLOPT_HTTPPOST) \
|
||||
if(!curlcheck_arr((value), struct curl_httppost)) \
|
||||
_curl_easy_setopt_err_curl_httpost(); \
|
||||
if((_curl_opt) == CURLOPT_MIMEPOST) \
|
||||
if(!curlcheck_ptr((value), curl_mime)) \
|
||||
_curl_easy_setopt_err_curl_mimepost(); \
|
||||
if(curlcheck_slist_option(_curl_opt)) \
|
||||
if(!curlcheck_arr((value), struct curl_slist)) \
|
||||
_curl_easy_setopt_err_curl_slist(); \
|
||||
if((_curl_opt) == CURLOPT_SHARE) \
|
||||
if(!curlcheck_ptr((value), CURLSH)) \
|
||||
_curl_easy_setopt_err_CURLSH(); \
|
||||
} \
|
||||
curl_easy_setopt(handle, _curl_opt, value); \
|
||||
})
|
||||
|
||||
/* wraps curl_easy_getinfo() with typechecking */
|
||||
#define curl_easy_getinfo(handle, info, arg) \
|
||||
__extension__({ \
|
||||
__typeof__(info) _curl_info = info; \
|
||||
if(__builtin_constant_p(_curl_info)) { \
|
||||
if(curlcheck_string_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), char *)) \
|
||||
_curl_easy_getinfo_err_string(); \
|
||||
if(curlcheck_long_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), long)) \
|
||||
_curl_easy_getinfo_err_long(); \
|
||||
if(curlcheck_double_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), double)) \
|
||||
_curl_easy_getinfo_err_double(); \
|
||||
if(curlcheck_slist_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_slist *)) \
|
||||
_curl_easy_getinfo_err_curl_slist(); \
|
||||
if(curlcheck_tlssessioninfo_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \
|
||||
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
|
||||
if(curlcheck_certinfo_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_certinfo *)) \
|
||||
_curl_easy_getinfo_err_curl_certinfo(); \
|
||||
if(curlcheck_socket_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), curl_socket_t)) \
|
||||
_curl_easy_getinfo_err_curl_socket(); \
|
||||
if(curlcheck_off_t_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), curl_off_t)) \
|
||||
_curl_easy_getinfo_err_curl_off_t(); \
|
||||
} \
|
||||
curl_easy_getinfo(handle, _curl_info, arg); \
|
||||
})
|
||||
|
||||
/*
|
||||
* For now, just make sure that the functions are called with three arguments
|
||||
*/
|
||||
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
|
||||
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
|
||||
|
||||
|
||||
/* the actual warnings, triggered by calling the _curl_easy_setopt_err*
|
||||
* functions */
|
||||
|
||||
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
|
||||
#define CURLWARNING(id, message) \
|
||||
static void __attribute__((__warning__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) { __asm__(""); }
|
||||
|
||||
CURLWARNING(_curl_easy_setopt_err_long,
|
||||
"curl_easy_setopt expects a long argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_off_t,
|
||||
"curl_easy_setopt expects a curl_off_t argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_string,
|
||||
"curl_easy_setopt expects a "
|
||||
"string ('char *' or char[]) argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_write_callback,
|
||||
"curl_easy_setopt expects a curl_write_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_resolver_start_callback,
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_resolver_start_callback argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_read_cb,
|
||||
"curl_easy_setopt expects a curl_read_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_ioctl_cb,
|
||||
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_sockopt_cb,
|
||||
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_opensocket_cb,
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_opensocket_callback argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_progress_cb,
|
||||
"curl_easy_setopt expects a curl_progress_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_debug_cb,
|
||||
"curl_easy_setopt expects a curl_debug_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_ssl_ctx_cb,
|
||||
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_conv_cb,
|
||||
"curl_easy_setopt expects a curl_conv_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_seek_cb,
|
||||
"curl_easy_setopt expects a curl_seek_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_cb_data,
|
||||
"curl_easy_setopt expects a "
|
||||
"private data pointer as argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_error_buffer,
|
||||
"curl_easy_setopt expects a "
|
||||
"char buffer of CURL_ERROR_SIZE as argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_FILE,
|
||||
"curl_easy_setopt expects a 'FILE *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_postfields,
|
||||
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_httpost,
|
||||
"curl_easy_setopt expects a 'struct curl_httppost *' "
|
||||
"argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_mimepost,
|
||||
"curl_easy_setopt expects a 'curl_mime *' "
|
||||
"argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_slist,
|
||||
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_CURLSH,
|
||||
"curl_easy_setopt expects a CURLSH* argument for this option")
|
||||
|
||||
CURLWARNING(_curl_easy_getinfo_err_string,
|
||||
"curl_easy_getinfo expects a pointer to 'char *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_long,
|
||||
"curl_easy_getinfo expects a pointer to long for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_double,
|
||||
"curl_easy_getinfo expects a pointer to double for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_slist,
|
||||
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
|
||||
"curl_easy_getinfo expects a pointer to "
|
||||
"'struct curl_tlssessioninfo *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_certinfo,
|
||||
"curl_easy_getinfo expects a pointer to "
|
||||
"'struct curl_certinfo *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_socket,
|
||||
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
|
||||
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
|
||||
|
||||
/* groups of curl_easy_setops options that take the same type of argument */
|
||||
|
||||
/* To add a new option to one of the groups, just add
|
||||
* (option) == CURLOPT_SOMETHING
|
||||
* to the or-expression. If the option takes a long or curl_off_t, you don't
|
||||
* have to do anything
|
||||
*/
|
||||
|
||||
/* evaluates to true if option takes a long argument */
|
||||
#define curlcheck_long_option(option) \
|
||||
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
|
||||
|
||||
#define curlcheck_off_t_option(option) \
|
||||
(((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB))
|
||||
|
||||
/* evaluates to true if option takes a char* argument */
|
||||
#define curlcheck_string_option(option) \
|
||||
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
|
||||
(option) == CURLOPT_ACCEPT_ENCODING || \
|
||||
(option) == CURLOPT_ALTSVC || \
|
||||
(option) == CURLOPT_CAINFO || \
|
||||
(option) == CURLOPT_CAPATH || \
|
||||
(option) == CURLOPT_COOKIE || \
|
||||
(option) == CURLOPT_COOKIEFILE || \
|
||||
(option) == CURLOPT_COOKIEJAR || \
|
||||
(option) == CURLOPT_COOKIELIST || \
|
||||
(option) == CURLOPT_CRLFILE || \
|
||||
(option) == CURLOPT_CUSTOMREQUEST || \
|
||||
(option) == CURLOPT_DEFAULT_PROTOCOL || \
|
||||
(option) == CURLOPT_DNS_INTERFACE || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP4 || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP6 || \
|
||||
(option) == CURLOPT_DNS_SERVERS || \
|
||||
(option) == CURLOPT_DOH_URL || \
|
||||
(option) == CURLOPT_EGDSOCKET || \
|
||||
(option) == CURLOPT_FTPPORT || \
|
||||
(option) == CURLOPT_FTP_ACCOUNT || \
|
||||
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
|
||||
(option) == CURLOPT_HSTS || \
|
||||
(option) == CURLOPT_INTERFACE || \
|
||||
(option) == CURLOPT_ISSUERCERT || \
|
||||
(option) == CURLOPT_KEYPASSWD || \
|
||||
(option) == CURLOPT_KRBLEVEL || \
|
||||
(option) == CURLOPT_LOGIN_OPTIONS || \
|
||||
(option) == CURLOPT_MAIL_AUTH || \
|
||||
(option) == CURLOPT_MAIL_FROM || \
|
||||
(option) == CURLOPT_NETRC_FILE || \
|
||||
(option) == CURLOPT_NOPROXY || \
|
||||
(option) == CURLOPT_PASSWORD || \
|
||||
(option) == CURLOPT_PINNEDPUBLICKEY || \
|
||||
(option) == CURLOPT_PRE_PROXY || \
|
||||
(option) == CURLOPT_PROXY || \
|
||||
(option) == CURLOPT_PROXYPASSWORD || \
|
||||
(option) == CURLOPT_PROXYUSERNAME || \
|
||||
(option) == CURLOPT_PROXYUSERPWD || \
|
||||
(option) == CURLOPT_PROXY_CAINFO || \
|
||||
(option) == CURLOPT_PROXY_CAPATH || \
|
||||
(option) == CURLOPT_PROXY_CRLFILE || \
|
||||
(option) == CURLOPT_PROXY_ISSUERCERT || \
|
||||
(option) == CURLOPT_PROXY_KEYPASSWD || \
|
||||
(option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
|
||||
(option) == CURLOPT_PROXY_SERVICE_NAME || \
|
||||
(option) == CURLOPT_PROXY_SSLCERT || \
|
||||
(option) == CURLOPT_PROXY_SSLCERTTYPE || \
|
||||
(option) == CURLOPT_PROXY_SSLKEY || \
|
||||
(option) == CURLOPT_PROXY_SSLKEYTYPE || \
|
||||
(option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
|
||||
(option) == CURLOPT_PROXY_TLS13_CIPHERS || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
|
||||
(option) == CURLOPT_RANDOM_FILE || \
|
||||
(option) == CURLOPT_RANGE || \
|
||||
(option) == CURLOPT_REFERER || \
|
||||
(option) == CURLOPT_REQUEST_TARGET || \
|
||||
(option) == CURLOPT_RTSP_SESSION_ID || \
|
||||
(option) == CURLOPT_RTSP_STREAM_URI || \
|
||||
(option) == CURLOPT_RTSP_TRANSPORT || \
|
||||
(option) == CURLOPT_SASL_AUTHZID || \
|
||||
(option) == CURLOPT_SERVICE_NAME || \
|
||||
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
|
||||
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
|
||||
(option) == CURLOPT_SSH_KNOWNHOSTS || \
|
||||
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
|
||||
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
|
||||
(option) == CURLOPT_SSLCERT || \
|
||||
(option) == CURLOPT_SSLCERTTYPE || \
|
||||
(option) == CURLOPT_SSLENGINE || \
|
||||
(option) == CURLOPT_SSLKEY || \
|
||||
(option) == CURLOPT_SSLKEYTYPE || \
|
||||
(option) == CURLOPT_SSL_CIPHER_LIST || \
|
||||
(option) == CURLOPT_TLS13_CIPHERS || \
|
||||
(option) == CURLOPT_TLSAUTH_PASSWORD || \
|
||||
(option) == CURLOPT_TLSAUTH_TYPE || \
|
||||
(option) == CURLOPT_TLSAUTH_USERNAME || \
|
||||
(option) == CURLOPT_UNIX_SOCKET_PATH || \
|
||||
(option) == CURLOPT_URL || \
|
||||
(option) == CURLOPT_USERAGENT || \
|
||||
(option) == CURLOPT_USERNAME || \
|
||||
(option) == CURLOPT_AWS_SIGV4 || \
|
||||
(option) == CURLOPT_USERPWD || \
|
||||
(option) == CURLOPT_XOAUTH2_BEARER || \
|
||||
(option) == CURLOPT_SSL_EC_CURVES || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a curl_write_callback argument */
|
||||
#define curlcheck_write_cb_option(option) \
|
||||
((option) == CURLOPT_HEADERFUNCTION || \
|
||||
(option) == CURLOPT_WRITEFUNCTION)
|
||||
|
||||
/* evaluates to true if option takes a curl_conv_callback argument */
|
||||
#define curlcheck_conv_cb_option(option) \
|
||||
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
|
||||
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
|
||||
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
|
||||
|
||||
/* evaluates to true if option takes a data argument to pass to a callback */
|
||||
#define curlcheck_cb_data_option(option) \
|
||||
((option) == CURLOPT_CHUNK_DATA || \
|
||||
(option) == CURLOPT_CLOSESOCKETDATA || \
|
||||
(option) == CURLOPT_DEBUGDATA || \
|
||||
(option) == CURLOPT_FNMATCH_DATA || \
|
||||
(option) == CURLOPT_HEADERDATA || \
|
||||
(option) == CURLOPT_HSTSREADDATA || \
|
||||
(option) == CURLOPT_HSTSWRITEDATA || \
|
||||
(option) == CURLOPT_INTERLEAVEDATA || \
|
||||
(option) == CURLOPT_IOCTLDATA || \
|
||||
(option) == CURLOPT_OPENSOCKETDATA || \
|
||||
(option) == CURLOPT_PROGRESSDATA || \
|
||||
(option) == CURLOPT_READDATA || \
|
||||
(option) == CURLOPT_SEEKDATA || \
|
||||
(option) == CURLOPT_SOCKOPTDATA || \
|
||||
(option) == CURLOPT_SSH_KEYDATA || \
|
||||
(option) == CURLOPT_SSL_CTX_DATA || \
|
||||
(option) == CURLOPT_WRITEDATA || \
|
||||
(option) == CURLOPT_RESOLVER_START_DATA || \
|
||||
(option) == CURLOPT_TRAILERDATA || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a POST data argument (void* or char*) */
|
||||
#define curlcheck_postfields_option(option) \
|
||||
((option) == CURLOPT_POSTFIELDS || \
|
||||
(option) == CURLOPT_COPYPOSTFIELDS || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a struct curl_slist * argument */
|
||||
#define curlcheck_slist_option(option) \
|
||||
((option) == CURLOPT_HTTP200ALIASES || \
|
||||
(option) == CURLOPT_HTTPHEADER || \
|
||||
(option) == CURLOPT_MAIL_RCPT || \
|
||||
(option) == CURLOPT_POSTQUOTE || \
|
||||
(option) == CURLOPT_PREQUOTE || \
|
||||
(option) == CURLOPT_PROXYHEADER || \
|
||||
(option) == CURLOPT_QUOTE || \
|
||||
(option) == CURLOPT_RESOLVE || \
|
||||
(option) == CURLOPT_TELNETOPTIONS || \
|
||||
(option) == CURLOPT_CONNECT_TO || \
|
||||
0)
|
||||
|
||||
/* groups of curl_easy_getinfo infos that take the same type of argument */
|
||||
|
||||
/* evaluates to true if info expects a pointer to char * argument */
|
||||
#define curlcheck_string_info(info) \
|
||||
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \
|
||||
(info) != CURLINFO_PRIVATE)
|
||||
|
||||
/* evaluates to true if info expects a pointer to long argument */
|
||||
#define curlcheck_long_info(info) \
|
||||
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
|
||||
|
||||
/* evaluates to true if info expects a pointer to double argument */
|
||||
#define curlcheck_double_info(info) \
|
||||
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
|
||||
|
||||
/* true if info expects a pointer to struct curl_slist * argument */
|
||||
#define curlcheck_slist_info(info) \
|
||||
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
|
||||
|
||||
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
|
||||
#define curlcheck_tlssessioninfo_info(info) \
|
||||
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
|
||||
|
||||
/* true if info expects a pointer to struct curl_certinfo * argument */
|
||||
#define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
|
||||
|
||||
/* true if info expects a pointer to struct curl_socket_t argument */
|
||||
#define curlcheck_socket_info(info) \
|
||||
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
|
||||
|
||||
/* true if info expects a pointer to curl_off_t argument */
|
||||
#define curlcheck_off_t_info(info) \
|
||||
(CURLINFO_OFF_T < (info))
|
||||
|
||||
|
||||
/* typecheck helpers -- check whether given expression has requested type*/
|
||||
|
||||
/* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros,
|
||||
* otherwise define a new macro. Search for __builtin_types_compatible_p
|
||||
* in the GCC manual.
|
||||
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
|
||||
* the actual expression passed to the curl_easy_setopt macro. This
|
||||
* means that you can only apply the sizeof and __typeof__ operators, no
|
||||
* == or whatsoever.
|
||||
*/
|
||||
|
||||
/* XXX: should evaluate to true if expr is a pointer */
|
||||
#define curlcheck_any_ptr(expr) \
|
||||
(sizeof(expr) == sizeof(void *))
|
||||
|
||||
/* evaluates to true if expr is NULL */
|
||||
/* XXX: must not evaluate expr, so this check is not accurate */
|
||||
#define curlcheck_NULL(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
|
||||
|
||||
/* evaluates to true if expr is type*, const type* or NULL */
|
||||
#define curlcheck_ptr(expr, type) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), type *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), const type *))
|
||||
|
||||
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
|
||||
#define curlcheck_arr(expr, type) \
|
||||
(curlcheck_ptr((expr), type) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), type []))
|
||||
|
||||
/* evaluates to true if expr is a string */
|
||||
#define curlcheck_string(expr) \
|
||||
(curlcheck_arr((expr), char) || \
|
||||
curlcheck_arr((expr), signed char) || \
|
||||
curlcheck_arr((expr), unsigned char))
|
||||
|
||||
/* evaluates to true if expr is a long (no matter the signedness)
|
||||
* XXX: for now, int is also accepted (and therefore short and char, which
|
||||
* are promoted to int when passed to a variadic function) */
|
||||
#define curlcheck_long(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed char) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
|
||||
|
||||
/* evaluates to true if expr is of type curl_off_t */
|
||||
#define curlcheck_off_t(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
|
||||
|
||||
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
|
||||
/* XXX: also check size of an char[] array? */
|
||||
#define curlcheck_error_buffer(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char[]))
|
||||
|
||||
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
|
||||
#if 0
|
||||
#define curlcheck_cb_data(expr) \
|
||||
(curlcheck_ptr((expr), void) || \
|
||||
curlcheck_ptr((expr), FILE))
|
||||
#else /* be less strict */
|
||||
#define curlcheck_cb_data(expr) \
|
||||
curlcheck_any_ptr(expr)
|
||||
#endif
|
||||
|
||||
/* evaluates to true if expr is of type FILE* */
|
||||
#define curlcheck_FILE(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
|
||||
|
||||
/* evaluates to true if expr can be passed as POST data (void* or char*) */
|
||||
#define curlcheck_postfields(expr) \
|
||||
(curlcheck_ptr((expr), void) || \
|
||||
curlcheck_arr((expr), char) || \
|
||||
curlcheck_arr((expr), unsigned char))
|
||||
|
||||
/* helper: __builtin_types_compatible_p distinguishes between functions and
|
||||
* function pointers, hide it */
|
||||
#define curlcheck_cb_compatible(func, type) \
|
||||
(__builtin_types_compatible_p(__typeof__(func), type) || \
|
||||
__builtin_types_compatible_p(__typeof__(func) *, type))
|
||||
|
||||
/* evaluates to true if expr is of type curl_resolver_start_callback */
|
||||
#define curlcheck_resolver_start_callback(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_resolver_start_callback))
|
||||
|
||||
/* evaluates to true if expr is of type curl_read_callback or "similar" */
|
||||
#define curlcheck_read_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), __typeof__(fread) *) || \
|
||||
curlcheck_cb_compatible((expr), curl_read_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback6))
|
||||
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
|
||||
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
|
||||
typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
|
||||
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_write_callback or "similar" */
|
||||
#define curlcheck_write_cb(expr) \
|
||||
(curlcheck_read_cb(expr) || \
|
||||
curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \
|
||||
curlcheck_cb_compatible((expr), curl_write_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback6))
|
||||
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
|
||||
const void *);
|
||||
typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
|
||||
typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
|
||||
const void *);
|
||||
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
|
||||
#define curlcheck_ioctl_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_ioctl_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback4))
|
||||
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
|
||||
#define curlcheck_sockopt_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_sockopt_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_sockopt_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_sockopt_callback2))
|
||||
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
|
||||
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
|
||||
curlsocktype);
|
||||
|
||||
/* evaluates to true if expr is of type curl_opensocket_callback or
|
||||
"similar" */
|
||||
#define curlcheck_opensocket_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_opensocket_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback4))
|
||||
typedef curl_socket_t (*_curl_opensocket_callback1)
|
||||
(void *, curlsocktype, struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback2)
|
||||
(void *, curlsocktype, const struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback3)
|
||||
(const void *, curlsocktype, struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback4)
|
||||
(const void *, curlsocktype, const struct curl_sockaddr *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
|
||||
#define curlcheck_progress_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_progress_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_progress_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_progress_callback2))
|
||||
typedef int (*_curl_progress_callback1)(void *,
|
||||
double, double, double, double);
|
||||
typedef int (*_curl_progress_callback2)(const void *,
|
||||
double, double, double, double);
|
||||
|
||||
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
|
||||
#define curlcheck_debug_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_debug_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback6) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback7) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback8))
|
||||
typedef int (*_curl_debug_callback1) (CURL *,
|
||||
curl_infotype, char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback2) (CURL *,
|
||||
curl_infotype, char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback3) (CURL *,
|
||||
curl_infotype, const char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback4) (CURL *,
|
||||
curl_infotype, const char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback5) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback6) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback7) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback8) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
|
||||
/* this is getting even messier... */
|
||||
#define curlcheck_ssl_ctx_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback6) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback7) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback8))
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
|
||||
const void *);
|
||||
#ifdef HEADER_SSL_H
|
||||
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
|
||||
* this will of course break if we're included before OpenSSL headers...
|
||||
*/
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,
|
||||
const void *);
|
||||
#else
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
|
||||
#endif
|
||||
|
||||
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
|
||||
#define curlcheck_conv_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_conv_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback4))
|
||||
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
|
||||
|
||||
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
|
||||
#define curlcheck_seek_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_seek_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_seek_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_seek_callback2))
|
||||
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
|
||||
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
|
||||
|
||||
|
||||
#endif /* CURLINC_TYPECHECK_GCC_H */
|
||||
125
csgo2/libcurl/inc/curl/urlapi.h
Normal file
125
csgo2/libcurl/inc/curl/urlapi.h
Normal file
@@ -0,0 +1,125 @@
|
||||
#ifndef CURLINC_URLAPI_H
|
||||
#define CURLINC_URLAPI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* the error codes for the URL API */
|
||||
typedef enum {
|
||||
CURLUE_OK,
|
||||
CURLUE_BAD_HANDLE, /* 1 */
|
||||
CURLUE_BAD_PARTPOINTER, /* 2 */
|
||||
CURLUE_MALFORMED_INPUT, /* 3 */
|
||||
CURLUE_BAD_PORT_NUMBER, /* 4 */
|
||||
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
|
||||
CURLUE_URLDECODE, /* 6 */
|
||||
CURLUE_OUT_OF_MEMORY, /* 7 */
|
||||
CURLUE_USER_NOT_ALLOWED, /* 8 */
|
||||
CURLUE_UNKNOWN_PART, /* 9 */
|
||||
CURLUE_NO_SCHEME, /* 10 */
|
||||
CURLUE_NO_USER, /* 11 */
|
||||
CURLUE_NO_PASSWORD, /* 12 */
|
||||
CURLUE_NO_OPTIONS, /* 13 */
|
||||
CURLUE_NO_HOST, /* 14 */
|
||||
CURLUE_NO_PORT, /* 15 */
|
||||
CURLUE_NO_QUERY, /* 16 */
|
||||
CURLUE_NO_FRAGMENT /* 17 */
|
||||
} CURLUcode;
|
||||
|
||||
typedef enum {
|
||||
CURLUPART_URL,
|
||||
CURLUPART_SCHEME,
|
||||
CURLUPART_USER,
|
||||
CURLUPART_PASSWORD,
|
||||
CURLUPART_OPTIONS,
|
||||
CURLUPART_HOST,
|
||||
CURLUPART_PORT,
|
||||
CURLUPART_PATH,
|
||||
CURLUPART_QUERY,
|
||||
CURLUPART_FRAGMENT,
|
||||
CURLUPART_ZONEID /* added in 7.65.0 */
|
||||
} CURLUPart;
|
||||
|
||||
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
|
||||
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
|
||||
if the port number matches the
|
||||
default for the scheme */
|
||||
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
|
||||
missing */
|
||||
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
|
||||
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
|
||||
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
|
||||
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
|
||||
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
|
||||
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
|
||||
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
|
||||
#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the
|
||||
scheme is unknown. */
|
||||
|
||||
typedef struct Curl_URL CURLU;
|
||||
|
||||
/*
|
||||
* curl_url() creates a new CURLU handle and returns a pointer to it.
|
||||
* Must be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url(void);
|
||||
|
||||
/*
|
||||
* curl_url_cleanup() frees the CURLU handle and related resources used for
|
||||
* the URL parsing. It will not free strings previously returned with the URL
|
||||
* API.
|
||||
*/
|
||||
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
|
||||
|
||||
/*
|
||||
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
|
||||
* handle must also be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
|
||||
|
||||
/*
|
||||
* curl_url_get() extracts a specific part of the URL from a CURLU
|
||||
* handle. Returns error code. The returned pointer MUST be freed with
|
||||
* curl_free() afterwards.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
|
||||
char **part, unsigned int flags);
|
||||
|
||||
/*
|
||||
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
|
||||
* error code. The passed in string will be copied. Passing a NULL instead of
|
||||
* a part string, clears that part.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
|
||||
const char *part, unsigned int flags);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_URLAPI_H */
|
||||
BIN
csgo2/libcurl/lib/_x32/_Debug/libcurld.lib
Normal file
BIN
csgo2/libcurl/lib/_x32/_Debug/libcurld.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x32/_Debug/libeay32.lib
Normal file
BIN
csgo2/libcurl/lib/_x32/_Debug/libeay32.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x32/_Debug/ssleay32.lib
Normal file
BIN
csgo2/libcurl/lib/_x32/_Debug/ssleay32.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x32/_Release/libcurl.lib
Normal file
BIN
csgo2/libcurl/lib/_x32/_Release/libcurl.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x32/_Release/libeay32.lib
Normal file
BIN
csgo2/libcurl/lib/_x32/_Release/libeay32.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x32/_Release/ssleay32.lib
Normal file
BIN
csgo2/libcurl/lib/_x32/_Release/ssleay32.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x64/_Debug/libcurld.lib
Normal file
BIN
csgo2/libcurl/lib/_x64/_Debug/libcurld.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x64/_Debug/libeay32.lib
Normal file
BIN
csgo2/libcurl/lib/_x64/_Debug/libeay32.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x64/_Debug/ssleay32.lib
Normal file
BIN
csgo2/libcurl/lib/_x64/_Debug/ssleay32.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x64/_Release/libcurl.lib
Normal file
BIN
csgo2/libcurl/lib/_x64/_Release/libcurl.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x64/_Release/libeay32.lib
Normal file
BIN
csgo2/libcurl/lib/_x64/_Release/libeay32.lib
Normal file
Binary file not shown.
BIN
csgo2/libcurl/lib/_x64/_Release/ssleay32.lib
Normal file
BIN
csgo2/libcurl/lib/_x64/_Release/ssleay32.lib
Normal file
Binary file not shown.
159
csgo2/libcurl/libcurl.cpp
Normal file
159
csgo2/libcurl/libcurl.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
#include "libcurl.h"
|
||||
|
||||
CRITICAL_SECTION curl_critical;
|
||||
|
||||
size_t writer(char* data, size_t size, size_t nmemb, std::string* writer_data)
|
||||
{
|
||||
size_t sizes = size * nmemb;
|
||||
|
||||
if (NULL == writer_data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
writer_data->append(data, sizes);
|
||||
return sizes;
|
||||
}
|
||||
|
||||
bool curl_get(std::string url, std::string* pbuffer, curl_slist* headers, bool tls, bool proxy)
|
||||
{
|
||||
curl_code code;
|
||||
curl_handle handle;
|
||||
|
||||
handle = curl_easy_init();
|
||||
if (NULL == handle) {
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writer);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_WRITEDATA, pbuffer);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
if (tls) {
|
||||
code = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, false);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, true);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (proxy) {
|
||||
curl_easy_setopt(handle, CURLOPT_PROXY, "127.0.0.1");
|
||||
curl_easy_setopt(handle, CURLOPT_PROXYPORT, 7890);
|
||||
curl_easy_setopt(handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&curl_critical);
|
||||
code = curl_easy_perform(handle);
|
||||
LeaveCriticalSection(&curl_critical);
|
||||
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
curl_easy_cleanup(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool curl_post(std::string url, std::string* pbuffer, std::string data, curl_slist* headers, bool tls, bool proxy)
|
||||
{
|
||||
curl_code code;
|
||||
curl_handle handle;
|
||||
|
||||
handle = curl_easy_init();
|
||||
if (NULL == handle) {
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writer);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_WRITEDATA, pbuffer);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
if (tls) {
|
||||
code = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, false);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, true);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_POST, true);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_POSTFIELDS, data.c_str());
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
code = curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (proxy) {
|
||||
curl_easy_setopt(handle, CURLOPT_PROXY, "127.0.0.1");
|
||||
curl_easy_setopt(handle, CURLOPT_PROXYPORT, 7890);
|
||||
curl_easy_setopt(handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&curl_critical);
|
||||
code = curl_easy_perform(handle);
|
||||
LeaveCriticalSection(&curl_critical);
|
||||
|
||||
if (code != CURLE_OK) {
|
||||
curl_easy_cleanup(handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
curl_easy_cleanup(handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
void curl_init()
|
||||
{
|
||||
InitializeCriticalSection(&curl_critical);
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
}
|
||||
|
||||
void curl_cleanup()
|
||||
{
|
||||
curl_global_cleanup();
|
||||
DeleteCriticalSection(&curl_critical);
|
||||
}
|
||||
42
csgo2/libcurl/libcurl.h
Normal file
42
csgo2/libcurl/libcurl.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#define CURL_STATICLIB
|
||||
#include "inc/curl/curl.h"
|
||||
#pragma comment(lib,"crypt32.lib")
|
||||
#pragma comment(lib,"ws2_32.lib")
|
||||
#pragma comment(lib,"wldap32.lib")
|
||||
|
||||
#ifndef _WIN64
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib,"_x32/_Debug/libeay32.lib")
|
||||
#pragma comment(lib,"_x32/_Debug/ssleay32.lib")
|
||||
#pragma comment(lib,"_x32/_Debug/libcurld.lib")
|
||||
#else
|
||||
#pragma comment(lib,"_x32/_Release/libeay32.lib")
|
||||
#pragma comment(lib,"_x32/_Release/ssleay32.lib")
|
||||
#pragma comment(lib,"_x32/_Release/libcurl.lib")
|
||||
#endif
|
||||
#else
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib,"_x64/_Debug/libeay32.lib")
|
||||
#pragma comment(lib,"_x64/_Debug/ssleay32.lib")
|
||||
#pragma comment(lib,"_x64/_Debug/libcurld.lib")
|
||||
#else
|
||||
#pragma comment(lib,"_x64/_Release/libeay32.lib")
|
||||
#pragma comment(lib,"_x64/_Release/ssleay32.lib")
|
||||
#pragma comment(lib,"_x64/_Release/libcurl.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern "C" unsigned char* MD5(const unsigned char* d, size_t n, unsigned char* md);
|
||||
extern "C" unsigned char* SHA1(const unsigned char* d, size_t n, unsigned char* md);
|
||||
|
||||
typedef CURL* curl_handle;
|
||||
typedef CURLcode curl_code;
|
||||
|
||||
bool curl_get(std::string url, std::string* pbuffer, curl_slist* headers, bool tls, bool proxy);
|
||||
bool curl_post(std::string url, std::string* pbuffer, std::string data, curl_slist* headers, bool tls, bool proxy);
|
||||
void curl_init();
|
||||
void curl_cleanup();
|
||||
6205
csgo2/luaCjson/dtoa.c
Normal file
6205
csgo2/luaCjson/dtoa.c
Normal file
File diff suppressed because it is too large
Load Diff
78
csgo2/luaCjson/dtoa_config.h
Normal file
78
csgo2/luaCjson/dtoa_config.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef _DTOA_CONFIG_H
|
||||
#define _DTOA_CONFIG_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Ensure dtoa.c does not USE_LOCALE. Lua CJSON must not use locale
|
||||
* aware conversion routines. */
|
||||
#undef USE_LOCALE
|
||||
|
||||
/* dtoa.c should not touch errno, Lua CJSON does not use it, and it
|
||||
* may not be threadsafe */
|
||||
#define NO_ERRNO
|
||||
|
||||
#define Long int32_t
|
||||
#define ULong uint32_t
|
||||
#define Llong int64_t
|
||||
#define ULLong uint64_t
|
||||
|
||||
#ifdef IEEE_BIG_ENDIAN
|
||||
#define IEEE_MC68k
|
||||
#else
|
||||
#define IEEE_8087
|
||||
#endif
|
||||
|
||||
#define MALLOC xmalloc
|
||||
|
||||
static void *xmalloc(size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = malloc(size);
|
||||
if (!p) {
|
||||
fprintf(stderr, "Out of memory");
|
||||
abort();
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef MULTIPLE_THREADS
|
||||
|
||||
/* Enable locking to support multi-threaded applications */
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
static pthread_mutex_t private_dtoa_lock[2] = {
|
||||
PTHREAD_MUTEX_INITIALIZER,
|
||||
PTHREAD_MUTEX_INITIALIZER
|
||||
};
|
||||
|
||||
#define dtoa_get_threadno pthread_self
|
||||
void
|
||||
set_max_dtoa_threads(unsigned int n);
|
||||
|
||||
#define ACQUIRE_DTOA_LOCK(n) do { \
|
||||
int r = pthread_mutex_lock(&private_dtoa_lock[n]); \
|
||||
if (r) { \
|
||||
fprintf(stderr, "pthread_mutex_lock failed with %d\n", r); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FREE_DTOA_LOCK(n) do { \
|
||||
int r = pthread_mutex_unlock(&private_dtoa_lock[n]); \
|
||||
if (r) { \
|
||||
fprintf(stderr, "pthread_mutex_unlock failed with %d\n", r);\
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif /* MULTIPLE_THREADS */
|
||||
|
||||
#endif /* _DTOA_CONFIG_H */
|
||||
|
||||
/* vi:ai et sw=4 ts=4:
|
||||
*/
|
||||
211
csgo2/luaCjson/fpconv.c
Normal file
211
csgo2/luaCjson/fpconv.c
Normal file
@@ -0,0 +1,211 @@
|
||||
/* fpconv - Floating point conversion routines
|
||||
*
|
||||
* Copyright (c) 2011-2012 Mark Pulford <mark@kyne.com.au>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* JSON uses a '.' decimal separator. strtod() / sprintf() under C libraries
|
||||
* with locale support will break when the decimal separator is a comma.
|
||||
*
|
||||
* fpconv_* will around these issues with a translation buffer if required.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fpconv.h"
|
||||
|
||||
/* Workaround for MSVC */
|
||||
#ifdef _MSC_VER
|
||||
#define inline __inline
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
/* Lua CJSON assumes the locale is the same for all threads within a
|
||||
* process and doesn't change after initialisation.
|
||||
*
|
||||
* This avoids the need for per thread storage or expensive checks
|
||||
* for call. */
|
||||
static char locale_decimal_point = '.';
|
||||
|
||||
/* In theory multibyte decimal_points are possible, but
|
||||
* Lua CJSON only supports UTF-8 and known locales only have
|
||||
* single byte decimal points ([.,]).
|
||||
*
|
||||
* localconv() may not be thread safe (=>crash), and nl_langinfo() is
|
||||
* not supported on some platforms. Use sprintf() instead - if the
|
||||
* locale does change, at least Lua CJSON won't crash. */
|
||||
static void fpconv_update_locale(void)
|
||||
{
|
||||
char buf[8];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%g", 0.5);
|
||||
|
||||
/* Failing this test might imply the platform has a buggy dtoa
|
||||
* implementation or wide characters */
|
||||
if (buf[0] != '0' || buf[2] != '5' || buf[3] != 0) {
|
||||
fprintf(stderr, "Error: wide characters found or printf() bug.");
|
||||
abort();
|
||||
}
|
||||
|
||||
locale_decimal_point = buf[1];
|
||||
}
|
||||
|
||||
/* Check for a valid number character: [-+0-9a-yA-Y.]
|
||||
* Eg: -0.6e+5, infinity, 0xF0.F0pF0
|
||||
*
|
||||
* Used to find the probable end of a number. It doesn't matter if
|
||||
* invalid characters are counted - strtod() will find the valid
|
||||
* number if it exists. The risk is that slightly more memory might
|
||||
* be allocated before a parse error occurs. */
|
||||
static inline int valid_number_character(char ch)
|
||||
{
|
||||
char lower_ch;
|
||||
|
||||
if ('0' <= ch && ch <= '9')
|
||||
return 1;
|
||||
if (ch == '-' || ch == '+' || ch == '.')
|
||||
return 1;
|
||||
|
||||
/* Hex digits, exponent (e), base (p), "infinity",.. */
|
||||
lower_ch = ch | 0x20;
|
||||
if ('a' <= lower_ch && lower_ch <= 'y')
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Calculate the size of the buffer required for a strtod locale
|
||||
* conversion. */
|
||||
static int strtod_buffer_size(const char *s)
|
||||
{
|
||||
const char *p = s;
|
||||
|
||||
while (valid_number_character(*p))
|
||||
p++;
|
||||
|
||||
return p - s;
|
||||
}
|
||||
|
||||
/* Similar to strtod(), but must be passed the current locale's decimal point
|
||||
* character. Guaranteed to be called at the start of any valid number in a string */
|
||||
double fpconv_strtod(const char *nptr, char **endptr)
|
||||
{
|
||||
char localbuf[FPCONV_G_FMT_BUFSIZE];
|
||||
char *buf, *endbuf, *dp;
|
||||
int buflen;
|
||||
double value;
|
||||
|
||||
/* System strtod() is fine when decimal point is '.' */
|
||||
if (locale_decimal_point == '.')
|
||||
return strtod(nptr, endptr);
|
||||
|
||||
buflen = strtod_buffer_size(nptr);
|
||||
if (!buflen) {
|
||||
/* No valid characters found, standard strtod() return */
|
||||
*endptr = (char *)nptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Duplicate number into buffer */
|
||||
if (buflen >= FPCONV_G_FMT_BUFSIZE) {
|
||||
/* Handle unusually large numbers */
|
||||
buf = malloc(buflen + 1);
|
||||
if (!buf) {
|
||||
fprintf(stderr, "Out of memory");
|
||||
abort();
|
||||
}
|
||||
} else {
|
||||
/* This is the common case.. */
|
||||
buf = localbuf;
|
||||
}
|
||||
memcpy(buf, nptr, buflen);
|
||||
buf[buflen] = 0;
|
||||
|
||||
/* Update decimal point character if found */
|
||||
dp = strchr(buf, '.');
|
||||
if (dp)
|
||||
*dp = locale_decimal_point;
|
||||
|
||||
value = strtod(buf, &endbuf);
|
||||
*endptr = (char *)&nptr[endbuf - buf];
|
||||
if (buflen >= FPCONV_G_FMT_BUFSIZE)
|
||||
free(buf);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/* "fmt" must point to a buffer of at least 6 characters */
|
||||
static void set_number_format(char *fmt, int precision)
|
||||
{
|
||||
int d1, d2, i;
|
||||
|
||||
assert(1 <= precision && precision <= 16);
|
||||
|
||||
/* Create printf format (%.14g) from precision */
|
||||
d1 = precision / 10;
|
||||
d2 = precision % 10;
|
||||
fmt[0] = '%';
|
||||
fmt[1] = '.';
|
||||
i = 2;
|
||||
if (d1) {
|
||||
fmt[i++] = '0' + d1;
|
||||
}
|
||||
fmt[i++] = '0' + d2;
|
||||
fmt[i++] = 'g';
|
||||
fmt[i] = 0;
|
||||
}
|
||||
|
||||
/* Assumes there is always at least 32 characters available in the target buffer */
|
||||
int fpconv_g_fmt(char *str, double num, int precision)
|
||||
{
|
||||
char buf[FPCONV_G_FMT_BUFSIZE];
|
||||
char fmt[6];
|
||||
int len;
|
||||
char *b;
|
||||
|
||||
set_number_format(fmt, precision);
|
||||
|
||||
/* Pass through when decimal point character is dot. */
|
||||
if (locale_decimal_point == '.')
|
||||
return snprintf(str, FPCONV_G_FMT_BUFSIZE, fmt, num);
|
||||
|
||||
/* snprintf() to a buffer then translate for other decimal point characters */
|
||||
len = snprintf(buf, FPCONV_G_FMT_BUFSIZE, fmt, num);
|
||||
|
||||
/* Copy into target location. Translate decimal point if required */
|
||||
b = buf;
|
||||
do {
|
||||
*str++ = (*b == locale_decimal_point ? '.' : *b);
|
||||
} while(*b++);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void fpconv_init(void)
|
||||
{
|
||||
fpconv_update_locale();
|
||||
}
|
||||
|
||||
/* vi:ai et sw=4 ts=4:
|
||||
*/
|
||||
32
csgo2/luaCjson/fpconv.h
Normal file
32
csgo2/luaCjson/fpconv.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Lua CJSON floating point conversion routines */
|
||||
|
||||
/* Buffer required to store the largest string representation of a double.
|
||||
*
|
||||
* Longest double printed with %.14g is 21 characters long:
|
||||
* -1.7976931348623e+308 */
|
||||
# define FPCONV_G_FMT_BUFSIZE 32
|
||||
|
||||
#ifdef USE_INTERNAL_FPCONV
|
||||
#ifdef MULTIPLE_THREADS
|
||||
#include "dtoa_config.h"
|
||||
#include <unistd.h>
|
||||
static inline void fpconv_init()
|
||||
{
|
||||
// Add one to try and avoid core id multiplier alignment
|
||||
set_max_dtoa_threads((sysconf(_SC_NPROCESSORS_CONF) + 1) * 3);
|
||||
}
|
||||
#else
|
||||
static inline void fpconv_init()
|
||||
{
|
||||
/* Do nothing - not required */
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
extern void fpconv_init(void);
|
||||
#endif
|
||||
|
||||
extern int fpconv_g_fmt(char*, double, int);
|
||||
extern double fpconv_strtod(const char*, char**);
|
||||
|
||||
/* vi:ai et sw=4 ts=4:
|
||||
*/
|
||||
111
csgo2/luaCjson/g_fmt.c
Normal file
111
csgo2/luaCjson/g_fmt.c
Normal file
@@ -0,0 +1,111 @@
|
||||
/****************************************************************
|
||||
*
|
||||
* The author of this software is David M. Gay.
|
||||
*
|
||||
* Copyright (c) 1991, 1996 by Lucent Technologies.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose without fee is hereby granted, provided that this entire notice
|
||||
* is included in all copies of any software which is or includes a copy
|
||||
* or modification of this software and in all copies of the supporting
|
||||
* documentation for such software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
|
||||
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
||||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
||||
*
|
||||
***************************************************************/
|
||||
|
||||
/* g_fmt(buf,x) stores the closest decimal approximation to x in buf;
|
||||
* it suffices to declare buf
|
||||
* char buf[32];
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern char *dtoa(double, int, int, int *, int *, char **);
|
||||
extern int g_fmt(char *, double, int);
|
||||
extern void freedtoa(char*);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
fpconv_g_fmt(char *b, double x, int precision)
|
||||
{
|
||||
register int i, k;
|
||||
register char *s;
|
||||
int decpt, j, sign;
|
||||
char *b0, *s0, *se;
|
||||
|
||||
b0 = b;
|
||||
#ifdef IGNORE_ZERO_SIGN
|
||||
if (!x) {
|
||||
*b++ = '0';
|
||||
*b = 0;
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
s = s0 = dtoa(x, 2, precision, &decpt, &sign, &se);
|
||||
if (sign)
|
||||
*b++ = '-';
|
||||
if (decpt == 9999) /* Infinity or Nan */ {
|
||||
while((*b++ = *s++));
|
||||
/* "b" is used to calculate the return length. Decrement to exclude the
|
||||
* Null terminator from the length */
|
||||
b--;
|
||||
goto done0;
|
||||
}
|
||||
if (decpt <= -4 || decpt > precision) {
|
||||
*b++ = *s++;
|
||||
if (*s) {
|
||||
*b++ = '.';
|
||||
while((*b = *s++))
|
||||
b++;
|
||||
}
|
||||
*b++ = 'e';
|
||||
/* sprintf(b, "%+.2d", decpt - 1); */
|
||||
if (--decpt < 0) {
|
||||
*b++ = '-';
|
||||
decpt = -decpt;
|
||||
}
|
||||
else
|
||||
*b++ = '+';
|
||||
for(j = 2, k = 10; 10*k <= decpt; j++, k *= 10);
|
||||
for(;;) {
|
||||
i = decpt / k;
|
||||
*b++ = i + '0';
|
||||
if (--j <= 0)
|
||||
break;
|
||||
decpt -= i*k;
|
||||
decpt *= 10;
|
||||
}
|
||||
*b = 0;
|
||||
}
|
||||
else if (decpt <= 0) {
|
||||
*b++ = '0';
|
||||
*b++ = '.';
|
||||
for(; decpt < 0; decpt++)
|
||||
*b++ = '0';
|
||||
while((*b++ = *s++));
|
||||
b--;
|
||||
}
|
||||
else {
|
||||
while((*b = *s++)) {
|
||||
b++;
|
||||
if (--decpt == 0 && *s)
|
||||
*b++ = '.';
|
||||
}
|
||||
for(; decpt > 0; decpt--)
|
||||
*b++ = '0';
|
||||
*b = 0;
|
||||
}
|
||||
done0:
|
||||
freedtoa(s0);
|
||||
#ifdef IGNORE_ZERO_SIGN
|
||||
done:
|
||||
#endif
|
||||
return b - b0;
|
||||
}
|
||||
1623
csgo2/luaCjson/lua_cjson.c
Normal file
1623
csgo2/luaCjson/lua_cjson.c
Normal file
File diff suppressed because it is too large
Load Diff
199
csgo2/luaCjson/strbuf.c
Normal file
199
csgo2/luaCjson/strbuf.c
Normal file
@@ -0,0 +1,199 @@
|
||||
/* strbuf - String buffer routines
|
||||
*
|
||||
* Copyright (c) 2010-2012 Mark Pulford <mark@kyne.com.au>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "strbuf.h"
|
||||
|
||||
static void die(const char *fmt, ...)
|
||||
{
|
||||
va_list arg;
|
||||
|
||||
va_start(arg, fmt);
|
||||
vfprintf(stderr, fmt, arg);
|
||||
va_end(arg);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
void strbuf_init(strbuf_t *s, size_t len)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (!len)
|
||||
size = STRBUF_DEFAULT_SIZE;
|
||||
else
|
||||
size = len + 1;
|
||||
if (size < len)
|
||||
die("Overflow, len: %zu", len);
|
||||
s->buf = NULL;
|
||||
s->size = size;
|
||||
s->length = 0;
|
||||
s->dynamic = 0;
|
||||
s->reallocs = 0;
|
||||
s->debug = 0;
|
||||
|
||||
s->buf = malloc(size);
|
||||
if (!s->buf)
|
||||
die("Out of memory");
|
||||
|
||||
strbuf_ensure_null(s);
|
||||
}
|
||||
|
||||
strbuf_t *strbuf_new(size_t len)
|
||||
{
|
||||
strbuf_t *s;
|
||||
|
||||
s = malloc(sizeof(strbuf_t));
|
||||
if (!s)
|
||||
die("Out of memory");
|
||||
|
||||
strbuf_init(s, len);
|
||||
|
||||
/* Dynamic strbuf allocation / deallocation */
|
||||
s->dynamic = 1;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static inline void debug_stats(strbuf_t *s)
|
||||
{
|
||||
if (s->debug) {
|
||||
fprintf(stderr, "strbuf(%lx) reallocs: %d, length: %zd, size: %zd\n",
|
||||
(long)s, s->reallocs, s->length, s->size);
|
||||
}
|
||||
}
|
||||
|
||||
/* If strbuf_t has not been dynamically allocated, strbuf_free() can
|
||||
* be called any number of times strbuf_init() */
|
||||
void strbuf_free(strbuf_t *s)
|
||||
{
|
||||
debug_stats(s);
|
||||
|
||||
if (s->buf) {
|
||||
free(s->buf);
|
||||
s->buf = NULL;
|
||||
}
|
||||
if (s->dynamic)
|
||||
free(s);
|
||||
}
|
||||
|
||||
char *strbuf_free_to_string(strbuf_t *s, size_t *len)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
debug_stats(s);
|
||||
|
||||
strbuf_ensure_null(s);
|
||||
|
||||
buf = s->buf;
|
||||
if (len)
|
||||
*len = s->length;
|
||||
|
||||
if (s->dynamic)
|
||||
free(s);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static size_t calculate_new_size(strbuf_t *s, size_t len)
|
||||
{
|
||||
size_t reqsize, newsize;
|
||||
|
||||
if (len <= 0)
|
||||
die("BUG: Invalid strbuf length requested");
|
||||
|
||||
/* Ensure there is room for optional NULL termination */
|
||||
reqsize = len + 1;
|
||||
if (reqsize < len)
|
||||
die("Overflow, len: %zu", len);
|
||||
|
||||
/* If the user has requested to shrink the buffer, do it exactly */
|
||||
if (s->size > reqsize)
|
||||
return reqsize;
|
||||
|
||||
newsize = s->size;
|
||||
if (reqsize >= SIZE_MAX / 2) {
|
||||
newsize = reqsize;
|
||||
} else {
|
||||
/* Exponential sizing */
|
||||
while (newsize < reqsize)
|
||||
newsize *= 2;
|
||||
}
|
||||
|
||||
if (newsize < reqsize)
|
||||
die("BUG: strbuf length would overflow, len: %zu", len);
|
||||
|
||||
|
||||
return newsize;
|
||||
}
|
||||
|
||||
|
||||
/* Ensure strbuf can handle a string length bytes long (ignoring NULL
|
||||
* optional termination). */
|
||||
void strbuf_resize(strbuf_t *s, size_t len)
|
||||
{
|
||||
size_t newsize;
|
||||
|
||||
newsize = calculate_new_size(s, len);
|
||||
|
||||
if (s->debug > 1) {
|
||||
fprintf(stderr, "strbuf(%lx) resize: %zd => %zd\n",
|
||||
(long)s, s->size, newsize);
|
||||
}
|
||||
|
||||
s->size = newsize;
|
||||
s->buf = realloc(s->buf, s->size);
|
||||
if (!s->buf)
|
||||
die("Out of memory, len: %zu", len);
|
||||
s->reallocs++;
|
||||
}
|
||||
|
||||
void strbuf_append_string(strbuf_t *s, const char *str)
|
||||
{
|
||||
int i;
|
||||
size_t space;
|
||||
|
||||
space = strbuf_empty_length(s);
|
||||
|
||||
for (i = 0; str[i]; i++) {
|
||||
if (space < 1) {
|
||||
strbuf_resize(s, s->length + 1);
|
||||
space = strbuf_empty_length(s);
|
||||
}
|
||||
|
||||
s->buf[s->length] = str[i];
|
||||
s->length++;
|
||||
space--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* vi:ai et sw=4 ts=4:
|
||||
*/
|
||||
157
csgo2/luaCjson/strbuf.h
Normal file
157
csgo2/luaCjson/strbuf.h
Normal file
@@ -0,0 +1,157 @@
|
||||
/* strbuf - String buffer routines
|
||||
*
|
||||
* Copyright (c) 2010-2012 Mark Pulford <mark@kyne.com.au>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Workaround for MSVC */
|
||||
#ifdef _MSC_VER
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
/* Size: Total bytes allocated to *buf
|
||||
* Length: String length, excluding optional NULL terminator.
|
||||
* Dynamic: True if created via strbuf_new()
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char *buf;
|
||||
size_t size;
|
||||
size_t length;
|
||||
int dynamic;
|
||||
int reallocs;
|
||||
int debug;
|
||||
} strbuf_t;
|
||||
|
||||
#ifndef STRBUF_DEFAULT_SIZE
|
||||
#define STRBUF_DEFAULT_SIZE 1023
|
||||
#endif
|
||||
|
||||
/* Initialise */
|
||||
extern strbuf_t *strbuf_new(size_t len);
|
||||
extern void strbuf_init(strbuf_t *s, size_t len);
|
||||
|
||||
/* Release */
|
||||
extern void strbuf_free(strbuf_t *s);
|
||||
extern char *strbuf_free_to_string(strbuf_t *s, size_t *len);
|
||||
|
||||
/* Management */
|
||||
extern void strbuf_resize(strbuf_t *s, size_t len);
|
||||
static size_t strbuf_empty_length(strbuf_t *s);
|
||||
static size_t strbuf_length(strbuf_t *s);
|
||||
static char *strbuf_string(strbuf_t *s, size_t *len);
|
||||
static void strbuf_ensure_empty_length(strbuf_t *s, size_t len);
|
||||
static char *strbuf_empty_ptr(strbuf_t *s);
|
||||
static void strbuf_extend_length(strbuf_t *s, size_t len);
|
||||
static void strbuf_set_length(strbuf_t *s, int len);
|
||||
|
||||
/* Update */
|
||||
static void strbuf_append_mem(strbuf_t *s, const char *c, size_t len);
|
||||
extern void strbuf_append_string(strbuf_t *s, const char *str);
|
||||
static void strbuf_append_char(strbuf_t *s, const char c);
|
||||
static void strbuf_ensure_null(strbuf_t *s);
|
||||
|
||||
/* Reset string for before use */
|
||||
static inline void strbuf_reset(strbuf_t *s)
|
||||
{
|
||||
s->length = 0;
|
||||
}
|
||||
|
||||
static inline int strbuf_allocated(strbuf_t *s)
|
||||
{
|
||||
return s->buf != NULL;
|
||||
}
|
||||
|
||||
/* Return bytes remaining in the string buffer
|
||||
* Ensure there is space for a NULL terminator. */
|
||||
static inline size_t strbuf_empty_length(strbuf_t *s)
|
||||
{
|
||||
return s->size - s->length - 1;
|
||||
}
|
||||
|
||||
static inline void strbuf_ensure_empty_length(strbuf_t *s, size_t len)
|
||||
{
|
||||
if (len > strbuf_empty_length(s))
|
||||
strbuf_resize(s, s->length + len);
|
||||
}
|
||||
|
||||
static inline char *strbuf_empty_ptr(strbuf_t *s)
|
||||
{
|
||||
return s->buf + s->length;
|
||||
}
|
||||
|
||||
static inline void strbuf_set_length(strbuf_t *s, int len)
|
||||
{
|
||||
s->length = len;
|
||||
}
|
||||
|
||||
static inline void strbuf_extend_length(strbuf_t *s, size_t len)
|
||||
{
|
||||
s->length += len;
|
||||
}
|
||||
|
||||
static inline size_t strbuf_length(strbuf_t *s)
|
||||
{
|
||||
return s->length;
|
||||
}
|
||||
|
||||
static inline void strbuf_append_char(strbuf_t *s, const char c)
|
||||
{
|
||||
strbuf_ensure_empty_length(s, 1);
|
||||
s->buf[s->length++] = c;
|
||||
}
|
||||
|
||||
static inline void strbuf_append_char_unsafe(strbuf_t *s, const char c)
|
||||
{
|
||||
s->buf[s->length++] = c;
|
||||
}
|
||||
|
||||
static inline void strbuf_append_mem(strbuf_t *s, const char *c, size_t len)
|
||||
{
|
||||
strbuf_ensure_empty_length(s, len);
|
||||
memcpy(s->buf + s->length, c, len);
|
||||
s->length += len;
|
||||
}
|
||||
|
||||
static inline void strbuf_append_mem_unsafe(strbuf_t *s, const char *c, size_t len)
|
||||
{
|
||||
memcpy(s->buf + s->length, c, len);
|
||||
s->length += len;
|
||||
}
|
||||
|
||||
static inline void strbuf_ensure_null(strbuf_t *s)
|
||||
{
|
||||
s->buf[s->length] = 0;
|
||||
}
|
||||
|
||||
static inline char *strbuf_string(strbuf_t *s, size_t *len)
|
||||
{
|
||||
if (len)
|
||||
*len = s->length;
|
||||
|
||||
return s->buf;
|
||||
}
|
||||
|
||||
/* vi:ai et sw=4 ts=4:
|
||||
*/
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "memory.h"
|
||||
namespace Memory {
|
||||
auto PathVscript() -> void {
|
||||
CModule vscript_old("vscript_old.dll");
|
||||
CModule vscript("vscript.dll");
|
||||
|
||||
uint64_t vscriptPathAddr = 0;
|
||||
if (vscript_old.IsLoaded() == true) {
|
||||
vscript_old.FindPattern(Offset::pattern_VscriptPath).Get(vscriptPathAddr);
|
||||
}
|
||||
else {
|
||||
vscript.FindPattern(Offset::pattern_VscriptPath).Get(vscriptPathAddr);
|
||||
}
|
||||
if (vscriptPathAddr != 0) {
|
||||
const static char PatchVScriptEnable[] = { 0xBE, 0x02 };
|
||||
DWORD oldProtect;
|
||||
VirtualProtect(reinterpret_cast<void*>(vscriptPathAddr), sizeof(PatchVScriptEnable), PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
memcpy(reinterpret_cast<void*>(vscriptPathAddr), PatchVScriptEnable, sizeof(PatchVScriptEnable));
|
||||
VirtualProtect(reinterpret_cast<void*>(vscriptPathAddr), sizeof(PatchVScriptEnable), oldProtect, &oldProtect);
|
||||
LOG("success patch vscript at %llx \n", vscriptPathAddr);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -14,5 +14,5 @@ namespace Memory {
|
||||
ReadProcessMemory(GetCurrentProcess(), (void*)address, &buffer, sizeof(T), 0);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
auto PathVscript() -> void;
|
||||
};
|
||||
@@ -2,6 +2,10 @@
|
||||
#include "head.h"
|
||||
#define IS_WINDOWS 1
|
||||
class InterfaceReg;
|
||||
//cancer fix me plz
|
||||
namespace global {
|
||||
extern bool isMetaModInit;
|
||||
};
|
||||
// Pointer arithmetic utility class.
|
||||
struct UTILPtr {
|
||||
public:
|
||||
@@ -65,10 +69,8 @@ class CModule {
|
||||
UTILPtr GetProcAddress(const char* procName) const {
|
||||
UTILPtr rv = 0;
|
||||
if (this->IsLoaded()) {
|
||||
#ifdef IS_WINDOWS
|
||||
rv = ::GetProcAddress(static_cast<HMODULE>(this->m_handle),
|
||||
procName);
|
||||
#endif
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@@ -77,11 +79,7 @@ class CModule {
|
||||
if (this->IsLoaded()) {
|
||||
UTILPtr pCreateInterface = this->GetProcAddress("CreateInterface");
|
||||
if (!pCreateInterface.IsValid()) return rv;
|
||||
|
||||
InterfaceReg* s_pInterfaceRegs = pCreateInterface.ToAbsolute(3, 0)
|
||||
.Dereference(1)
|
||||
.Get<InterfaceReg*>();
|
||||
|
||||
auto s_pInterfaceRegs = pCreateInterface.ToAbsolute(3, 0).Dereference(1).Get<InterfaceReg*>();
|
||||
for (; s_pInterfaceRegs;
|
||||
s_pInterfaceRegs = s_pInterfaceRegs->m_pNext) {
|
||||
if (strcmp(version, s_pInterfaceRegs->m_pName) == 0) {
|
||||
@@ -121,9 +119,36 @@ class CModule {
|
||||
|
||||
private:
|
||||
void InitializeHandle() {
|
||||
#ifdef IS_WINDOWS
|
||||
this->m_handle = static_cast<void*>(GetModuleHandleA(this->GetName()));
|
||||
#endif
|
||||
if (global::isMetaModInit == false) {
|
||||
this->m_handle = static_cast<void*>(GetModuleHandleA(this->GetName()));
|
||||
return;
|
||||
}
|
||||
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
DWORD cbNeeded;
|
||||
|
||||
// Call EnumProcessModules with a null hMods parameter to get the needed size.
|
||||
EnumProcessModules(hProcess, nullptr, 0, &cbNeeded);
|
||||
int moduleCount = cbNeeded / sizeof(HMODULE);
|
||||
std::vector<HMODULE> hMods(moduleCount);
|
||||
|
||||
if (EnumProcessModules(hProcess, hMods.data(), cbNeeded, &cbNeeded))
|
||||
{
|
||||
for (const auto& hMod : hMods)
|
||||
{
|
||||
char szModName[MAX_PATH];
|
||||
|
||||
if (GetModuleFileNameExA(hProcess, hMod, szModName, sizeof(szModName) / sizeof(char)))
|
||||
{
|
||||
const auto fullModulePath = std::string(szModName);
|
||||
if (fullModulePath.find("metamod") == std::string::npos && fullModulePath.ends_with(this->GetName()) == true) {
|
||||
this->m_handle = static_cast<void*>(hMod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(hProcess);
|
||||
}
|
||||
void InitializeBounds() {
|
||||
if (!this->IsLoaded()) return;
|
||||
|
||||
@@ -100,8 +100,7 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t* tableMap,
|
||||
|
||||
for (int i = 0; i < fieldsSize; ++i) {
|
||||
SchemaClassFieldData_t& field = pFields[i];
|
||||
// LOG("%s::%s found at -> 0x%X - %llx\n", className, field.m_name,
|
||||
// field.m_offset, &field);
|
||||
LOG("%s::%s found at -> 0x%X - %llx\n", className, field.m_name, field.m_offset, &field);
|
||||
|
||||
keyValueMap->Insert(hash_32_fnv1a_const(field.m_name),
|
||||
{field.m_offset, IsFieldNetworked(field)});
|
||||
|
||||
@@ -85,7 +85,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void;
|
||||
static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
|
||||
\
|
||||
static const auto m_key = \
|
||||
schema::GetOffset(ThisClass, datatable_hash, #varName, prop_hash); \
|
||||
schema::GetOffset(datatableName, datatable_hash, #varName, prop_hash); \
|
||||
\
|
||||
return *reinterpret_cast<std::add_pointer_t<type>>( \
|
||||
(uintptr_t)(this) + m_key.offset + extra_offset); \
|
||||
@@ -96,7 +96,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void;
|
||||
static constexpr auto prop_hash = hash_32_fnv1a_const(#varName); \
|
||||
\
|
||||
static const auto m_key = \
|
||||
schema::GetOffset(ThisClass, datatable_hash, #varName, prop_hash); \
|
||||
schema::GetOffset(datatableName, datatable_hash, #varName, prop_hash); \
|
||||
\
|
||||
static const auto m_chain = schema::FindChainOffset(ThisClass); \
|
||||
\
|
||||
@@ -111,7 +111,7 @@ extern auto SetStateChanged(Z_CBaseEntity* pEntity, int offset) -> void;
|
||||
middle of a class will need to have their this pointer \
|
||||
corrected by the offset .*/ \
|
||||
LOG("Attempting to call SetStateChanged on on %s::%s\n", \
|
||||
ThisClass, #varName); \
|
||||
datatableName, #varName); \
|
||||
if (!OffsetIsStruct) \
|
||||
SetStateChanged((Z_CBaseEntity*)this, \
|
||||
m_key.offset + extra_offset); \
|
||||
@@ -380,13 +380,7 @@ class CGlowProperty {
|
||||
SCHEMA_FIELD(bool, m_bFlashing)
|
||||
SCHEMA_FIELD(bool, m_bGlowing)
|
||||
};
|
||||
class CBaseModelEntity {
|
||||
public:
|
||||
DECLARE_CLASS(CBaseModelEntity);
|
||||
|
||||
SCHEMA_FIELD(CCollisionProperty, m_Collision)
|
||||
SCHEMA_FIELD(CGlowProperty, m_Glow)
|
||||
};
|
||||
class CBaseEntity : public CEntityInstance {
|
||||
public:
|
||||
DECLARE_CLASS(CBaseEntity);
|
||||
@@ -396,11 +390,17 @@ class CBaseEntity : public CEntityInstance {
|
||||
// SCHEMA_FIELD(Vector, m_vecBaseVelocity)
|
||||
SCHEMA_FIELD(CCollisionProperty*, m_pCollision)
|
||||
SCHEMA_FIELD(Vector, m_vecBaseVelocity)
|
||||
SCHEMA_FIELD_EX(CGlowProperty, "CBaseModelEntity", m_Glow);
|
||||
//SCHEMA_FIELD_EX(CGlowProperty, "CBaseModelEntity", m_Glow);
|
||||
auto IsBasePlayerController() -> bool;
|
||||
auto SpawnClientEntity() -> void;
|
||||
};
|
||||
class CBaseModelEntity : public CBaseEntity {
|
||||
public:
|
||||
DECLARE_CLASS(CBaseModelEntity);
|
||||
|
||||
SCHEMA_FIELD(CCollisionProperty, m_Collision)
|
||||
SCHEMA_FIELD(CGlowProperty, m_Glow)
|
||||
};
|
||||
class CBasePlayerController : public CBaseEntity {
|
||||
public:
|
||||
DECLARE_CLASS(CBasePlayerController);
|
||||
|
||||
@@ -11,7 +11,7 @@ uint64_t MaxPlayerNumsPtr;
|
||||
HashFunction_t FnServerHashFunction;
|
||||
StateChanged_t FnStateChanged;
|
||||
NetworkStateChanged_t FnNetworkStateChanged;
|
||||
RespawnPlayer_t FnRespawnPlayer;
|
||||
RespawnPlayerInDeathMatch_t FnRespawnPlayerInDeathMatch;
|
||||
GiveNamedItem_t FnGiveNamedItem;
|
||||
EntityRemove_t FnEntityRemove;
|
||||
UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
|
||||
@@ -49,11 +49,14 @@ auto SafeDelayInit(void* ctx) -> void {
|
||||
LOG("m_bForceTeamChangeSilent: %d \n",
|
||||
InterFaces::CCSGameRulesInterFace->m_bForceTeamChangeSilent());
|
||||
}
|
||||
|
||||
auto Init() -> bool {
|
||||
CModule server("server.dll");
|
||||
CModule schemasystem("schemasystem.dll");
|
||||
CModule engine("engine2.dll");
|
||||
CModule localize("localize.dll");
|
||||
CModule tier0("tier0.dll");
|
||||
Memory::PathVscript();
|
||||
|
||||
// engine.dll
|
||||
engine.FindPattern(pattern_MaxPlayerNumsPtr)
|
||||
@@ -71,11 +74,11 @@ auto Init() -> bool {
|
||||
server.FindPattern(pattern_CreateCCSGameRulesInterFacePtr)
|
||||
.ToAbsolute(3, 0)
|
||||
.Get(CCSGameRulesInterFacePtr);
|
||||
server.FindPattern(pattern_FnRespawnPlayer).Get(FnRespawnPlayer);
|
||||
server.FindPattern(pattern_FnRespawnPlayerInDeathMatch).Get(FnRespawnPlayerInDeathMatch);
|
||||
server.FindPattern(pattern_FnEntityRemove).Get(FnEntityRemove);
|
||||
server.FindPattern(pattern_FnGiveNamedItemPtr).Get(FnGiveNamedItem);
|
||||
server.FindPattern(pattern_fnHost_SayPtr).Get(Host_SayPtr);
|
||||
server.FindPattern(pattern_ServerHashFunctionPtr).Get(FnServerHashFunction);
|
||||
//server.FindPattern(pattern_ServerHashFunctionPtr).Get(FnServerHashFunction);
|
||||
server.FindPattern(pattern_UTIL_ClientPrintAll).Get(FnUTIL_ClientPrintAll);
|
||||
server.FindPattern(pattern_FnClientPrint).Get(FnClientPrint);
|
||||
|
||||
@@ -89,7 +92,7 @@ auto Init() -> bool {
|
||||
InterFaces::ILocalize = reinterpret_cast<CLocalize*>(
|
||||
localize.FindInterface("Localize_001").Get());
|
||||
InterFaces::IVEngineCvar = reinterpret_cast<ICvar*>(
|
||||
engine.FindInterface("VEngineCvar007").Get());
|
||||
tier0.FindInterface("VEngineCvar007").Get());
|
||||
|
||||
InterFaces::GameResourceServiceServer =
|
||||
reinterpret_cast<CGameResourceService*>(
|
||||
@@ -121,9 +124,9 @@ auto Init() -> bool {
|
||||
LOG("[huoji]FireEventServerSidePtr : %llx \n", FireEventServerSidePtr);
|
||||
LOG("[huoji]Host_SayPtr : %llx \n", Host_SayPtr);
|
||||
LOG("[huoji]FnNetworkStateChanged : %llx \n", FnNetworkStateChanged);
|
||||
LOG("[huoji]FnServerHashFunction : %llx \n", FnServerHashFunction);
|
||||
//LOG("[huoji]FnServerHashFunction : %llx \n", FnServerHashFunction);
|
||||
LOG("[huoji]FnStateChanged : %llx \n", FnStateChanged);
|
||||
LOG("[huoji]FnRespawnPlayer : %llx \n", FnRespawnPlayer);
|
||||
LOG("[huoji]FnRespawnPlayerInDeathMatch : %llx \n", FnRespawnPlayerInDeathMatch);
|
||||
LOG("[huoji]FnGiveNamedItem : %llx \n", FnGiveNamedItem);
|
||||
LOG("[huoji]FnClientPrint : %llx \n", FnClientPrint);
|
||||
LOG("[huoji]FnUTIL_ClientPrintAll : %llx \n", FnUTIL_ClientPrintAll);
|
||||
@@ -154,8 +157,7 @@ auto Init() -> bool {
|
||||
0, NULL);
|
||||
// LOG("FnServerHashFunction: %llx \n", FnServerHashFunction("here",
|
||||
// sizeof("here") - 1, 0x31415926));
|
||||
return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayer && FnGiveNamedItem &&
|
||||
FnServerHashFunction && Host_SayPtr && InterFaces::IVEngineServer &&
|
||||
return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayerInDeathMatch && FnGiveNamedItem && Host_SayPtr && InterFaces::IVEngineServer &&
|
||||
InterFaces::GameResourceServiceServer &&
|
||||
InterFaces::IServerGameClient && InterFaces::GameEventManager &&
|
||||
InterFaces::SchemaSystem && FireEventServerSidePtr &&
|
||||
|
||||
@@ -14,7 +14,7 @@ typedef void(__fastcall* StateChanged_t)(void* networkTransmitComponent,
|
||||
typedef void(__fastcall* NetworkStateChanged_t)(uintptr_t chainEntity,
|
||||
uintptr_t offset, uintptr_t a3);
|
||||
typedef void*(__fastcall* CreateGameRuleInterFace_t)();
|
||||
typedef bool(__fastcall* RespawnPlayer_t)(CCSPlayerPawn* player);
|
||||
typedef bool(__fastcall* RespawnPlayerInDeathMatch_t)(CCSPlayerPawn* player);
|
||||
typedef void(__fastcall* GiveNamedItem_t)(void* itemService,
|
||||
const char* pchName, void* iSubType,
|
||||
void* pScriptItem, void* a5,
|
||||
@@ -26,7 +26,6 @@ typedef void*(__fastcall* UTIL_SayTextFilter_t)(IRecipientFilter&, const char*,
|
||||
typedef void(__fastcall* UTIL_ClientPrintAll_t)(int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
|
||||
typedef void(__fastcall* ClientPrint_t)(CCSPlayerController* player, int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4);
|
||||
typedef void(__fastcall* CCSWeaponBase_Spawn_t)(CBaseEntity*, void*);
|
||||
|
||||
class CSchemaSystem;
|
||||
class CGameResourceService;
|
||||
class CLocalize;
|
||||
@@ -45,6 +44,7 @@ extern ISource2Server* ISource2ServerInterFace;
|
||||
extern CCSGameRules* CCSGameRulesInterFace;
|
||||
extern ICvar* IVEngineCvar;
|
||||
}; // namespace InterFaces
|
||||
static const auto pattern_VscriptPath = THE_GAME_SIG("BE 01 ?? ?? ?? 2B D6 74 ?? 3B D6");
|
||||
static const auto pattern_CGameEventManager = THE_GAME_SIG(
|
||||
"48 ?? ?? ?? ?? ?? ?? 48 89 ?? ?? ?? 48 89 01 48 8B D9 48 ?? ?? ?? ?? ?? "
|
||||
"?? 48 89 ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? ?? ?? ?? ??");
|
||||
@@ -79,6 +79,8 @@ static const auto pattern_CreateCCSGameRulesInterFacePtr = THE_GAME_SIG(
|
||||
"?? ?? 4C 8D ?? ?? ?? 49 8B ?? ?? 49 8B ?? ?? 49 8B ?? ?? 49 8B E3 41 5F "
|
||||
"41 5E 5F C3");
|
||||
static const auto pattern_FnRespawnPlayer = THE_GAME_SIG(
|
||||
"48 89 ?? ?? ?? 48 89 ?? ?? ?? 56 48 ?? ?? ?? ?? ?? ?? 48 8B DA 48 8B E9 48 85 D2 0F ?? ?? ?? ?? ?? 48 8B 02 48 8B CA FF ?? ?? ?? ?? ?? 84 C0 0F ?? ?? ?? ?? ?? 83 BB ?? ?? ?? ?? ?? 0F ?? ?? ?? ?? ??");
|
||||
static const auto pattern_FnRespawnPlayerInDeathMatch = THE_GAME_SIG(
|
||||
"48 89 ?? ?? ?? 57 48 ?? ?? ?? 48 8D ?? ?? ?? 48 8B F9 E8 ?? ?? ?? ?? 83 "
|
||||
"?? ?? 74 ?? 48 ?? ?? ?? ?? ?? ?? 48 8B CF 48 8B 10 48 8B ?? ?? ?? ?? ?? "
|
||||
"48 8D ?? ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? ?? ?? ?? ??");
|
||||
@@ -102,7 +104,7 @@ extern uint64_t MaxPlayerNumsPtr;
|
||||
extern HashFunction_t FnServerHashFunction;
|
||||
extern StateChanged_t FnStateChanged;
|
||||
extern NetworkStateChanged_t FnNetworkStateChanged;
|
||||
extern RespawnPlayer_t FnRespawnPlayer;
|
||||
extern RespawnPlayerInDeathMatch_t FnRespawnPlayerInDeathMatch;
|
||||
extern GiveNamedItem_t FnGiveNamedItem;
|
||||
extern EntityRemove_t FnEntityRemove;
|
||||
extern UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
|
||||
|
||||
@@ -111,6 +111,7 @@ auto luaApi_SetPlayerCurrentWeaponAmmo(lua_State* luaVm) -> int {
|
||||
lua_pop(luaVm, 3);
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
auto luaApi_RespawnPlayer(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
int playerArmorValue = 0;
|
||||
@@ -120,7 +121,20 @@ auto luaApi_RespawnPlayer(lua_State* luaVm) -> int {
|
||||
if (playerPawn == nullptr) {
|
||||
return;
|
||||
}
|
||||
Offset::FnRespawnPlayer(playerPawn);
|
||||
Offset::InterFaces::CCSGameRulesInterFace->PlayerRespawn(playerPawn);
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_RespawnPlayerInDeathMatch(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
int playerArmorValue = 0;
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
const auto playerPawn =
|
||||
playerController->m_hPawn().Get<CCSPlayerPawn>();
|
||||
if (playerPawn == nullptr) {
|
||||
return;
|
||||
}
|
||||
Offset::FnRespawnPlayerInDeathMatch(playerPawn);
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
@@ -580,7 +594,7 @@ auto luaApi_SendToPlayerChat(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto hudType = lua_tointeger(luaVm, 2);
|
||||
const auto message = lua_tostring(luaVm, 3);
|
||||
if (hudType >= _HubType::kMax || hudType < _HubType::kNotify) {
|
||||
if (hudType >= static_cast<int>(_HubType::kMax) || hudType < static_cast<int>(_HubType::kNotify)) {
|
||||
lua_pop(luaVm, 3);
|
||||
return 0;
|
||||
}
|
||||
@@ -595,7 +609,7 @@ auto luaApi_SentToAllPlayerChat(lua_State* luaVm) -> int {
|
||||
// param: playerIndex:int, message:string
|
||||
const auto message = lua_tostring(luaVm, 1);
|
||||
const auto hudType = lua_tointeger(luaVm, 2);
|
||||
if (hudType >= _HubType::kMax || hudType < _HubType::kNotify) {
|
||||
if (hudType >= static_cast<int>(_HubType::kMax) || hudType < static_cast<int>(_HubType::kNotify)) {
|
||||
lua_pop(luaVm, 3);
|
||||
return 0;
|
||||
}
|
||||
@@ -661,7 +675,7 @@ auto luaApi_SetPlayerGlowColor(lua_State* luaVm) -> int {
|
||||
const auto b = lua_tonumber(luaVm, 4);
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
playerController->m_hPawn()
|
||||
.Get<CCSPlayerPawn>()
|
||||
.Get<CBaseModelEntity>()
|
||||
->m_Glow()
|
||||
.m_glowColorOverride(Color(r, g, b, 230));
|
||||
});
|
||||
@@ -673,10 +687,67 @@ auto luaApi_SetPlayerGlowEnable(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto isEnable = lua_toboolean(luaVm, 2);
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
playerController->m_hPawn().Get<CCSPlayerPawn>()->m_Glow().m_bGlowing(
|
||||
LOG("glow set %d to %d \n",
|
||||
playerController->m_hPawn()
|
||||
.Get<CBaseModelEntity>()
|
||||
->m_Glow()
|
||||
.m_bGlowing(),
|
||||
isEnable);
|
||||
playerController->m_hPawn().Get<CCSPlayerPawn>()->m_Glow().m_iGlowType(
|
||||
3);
|
||||
playerController->m_hPawn()
|
||||
.Get<CBaseModelEntity>()
|
||||
->m_Glow()
|
||||
.m_bGlowing(isEnable);
|
||||
playerController->m_hPawn()
|
||||
.Get<CBaseModelEntity>()
|
||||
->m_Glow()
|
||||
.m_iGlowType(3);
|
||||
playerController->m_hPawn()
|
||||
.Get<CBaseModelEntity>()
|
||||
->m_Glow()
|
||||
.m_glowColorOverride(Color(201, 0, 118, 230));
|
||||
});
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_RunServerCommand(lua_State* luaVm) -> int {
|
||||
const auto command = lua_tostring(luaVm, 1);
|
||||
Offset::InterFaces::IVEngineServer->ServerCommand(command);
|
||||
lua_pop(luaVm, 1);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_RunClientCommand(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto command = lua_tostring(luaVm, 2);
|
||||
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
Offset::InterFaces::IVEngineServer->ClientCommand(EntityIndex_to_PlayerSlot(playerIndex), command);
|
||||
});
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_GetPlayerSteamId(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
std::string steamid;
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
steamid = std::to_string(playerController->m_steamID());
|
||||
});
|
||||
lua_pop(luaVm, 1);
|
||||
lua_pushstring(luaVm, steamid.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto luaApi_KickPlayer(lua_State* luaVm) -> int {
|
||||
const auto playerIndex = lua_tointeger(luaVm, 1);
|
||||
const auto reason = lua_tostring(luaVm, 2);
|
||||
ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) {
|
||||
auto playerSlot = EntityIndex_to_PlayerSlot(playerIndex);
|
||||
if (playerSlot == -1) {
|
||||
return;
|
||||
}
|
||||
const auto theReason =
|
||||
"You have kicked by server , reason: " + std::string(reason);
|
||||
Offset::InterFaces::IVEngineServer->DisconnectClient(playerSlot, 39);
|
||||
SdkTools::SentChatToClient(playerController, _HubType::kTalk,
|
||||
theReason.c_str());
|
||||
});
|
||||
lua_pop(luaVm, 2);
|
||||
return 0;
|
||||
@@ -694,10 +765,10 @@ auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int {
|
||||
auto player = EntitySystem->GetBaseEntity(i);
|
||||
|
||||
if (player == nullptr) {
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (player->IsBasePlayerController() == false) {
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
lua_pushinteger(luaVm, player->GetRefEHandle().GetEntryIndex());
|
||||
lua_rawseti(luaVm, -2, index++);
|
||||
@@ -705,6 +776,160 @@ auto luaApi_GetAllPlayerIndex(lua_State* luaVm) -> int {
|
||||
} while (false);
|
||||
return 1;
|
||||
}
|
||||
auto luaApi_HttpGet(lua_State* luaVm) -> int {
|
||||
// param: url:string header:string timeOut:int
|
||||
const auto url = lua_tostring(luaVm, 1);
|
||||
const auto header = lua_tostring(luaVm, 2);
|
||||
const auto timeOut = lua_tointeger(luaVm, 3);
|
||||
auto strHeader = std::string(header);
|
||||
std::string response;
|
||||
auto result = Server::HttpGet(url, response, strHeader, timeOut);
|
||||
lua_pushinteger(luaVm, result);
|
||||
lua_pushstring(luaVm, response.c_str());
|
||||
return 2;
|
||||
}
|
||||
auto luaApi_HttpPost(lua_State* luaVm) -> int {
|
||||
// param: url:string header:string postdata:string timeOut:int
|
||||
const auto url = lua_tostring(luaVm, 1);
|
||||
const auto header = lua_tostring(luaVm, 2);
|
||||
const auto postdata = lua_tostring(luaVm, 3);
|
||||
const auto timeOut = lua_tointeger(luaVm, 4);
|
||||
auto strHeader = std::string(header);
|
||||
std::string response;
|
||||
auto result = Server::HttpPost(url, strHeader, postdata, response, timeOut);
|
||||
lua_pushinteger(luaVm, result);
|
||||
lua_pushstring(luaVm, response.c_str());
|
||||
return 2;
|
||||
}
|
||||
auto luaApi_HttpAsyncPost(lua_State* luaVm) -> int {
|
||||
// param: url:string header:string postdata:string timeOut:int
|
||||
// metadata:string
|
||||
const auto url = lua_tostring(luaVm, 1);
|
||||
const auto header = lua_tostring(luaVm, 2);
|
||||
const auto postdata = lua_tostring(luaVm, 3);
|
||||
const auto theTimeOut = lua_tointeger(luaVm, 4);
|
||||
const auto metadata = lua_tostring(luaVm, 5);
|
||||
struct _ctx {
|
||||
std::shared_ptr<std::string> url;
|
||||
std::shared_ptr<std::string> header;
|
||||
std::shared_ptr<std::string> postdata;
|
||||
std::shared_ptr<std::string> metadata;
|
||||
long timeOut;
|
||||
};
|
||||
_ctx* ctx = new _ctx{
|
||||
.url = std::make_shared<std::string>(url),
|
||||
.header = std::make_shared<std::string>(header),
|
||||
.postdata = std::make_shared<std::string>(postdata),
|
||||
.metadata = std::make_shared<std::string>(metadata),
|
||||
.timeOut = (int)theTimeOut,
|
||||
};
|
||||
if (ctx) {
|
||||
CreateThread(
|
||||
nullptr, 0,
|
||||
[](void* ctx) -> DWORD {
|
||||
const auto theCtx = reinterpret_cast<_ctx*>(ctx);
|
||||
auto strHeader = std::string(*theCtx->header.get());
|
||||
std::string response;
|
||||
auto result = Server::HttpPost(*theCtx->url.get(), strHeader,
|
||||
*theCtx->postdata.get(),
|
||||
response, theCtx->timeOut);
|
||||
ScriptCallBacks::luaCall_onHttpRequest(
|
||||
*theCtx->url.get(), *theCtx->metadata.get(),
|
||||
response.c_str(), result);
|
||||
delete theCtx;
|
||||
return 0;
|
||||
},
|
||||
ctx, 0, nullptr);
|
||||
}
|
||||
lua_pop(luaVm, 5);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_HttpAsyncGet(lua_State* luaVm) -> int {
|
||||
// param: url:string header:string timeOut:int
|
||||
// metadata:string
|
||||
const auto url = lua_tostring(luaVm, 1);
|
||||
const auto header = lua_tostring(luaVm, 2);
|
||||
const auto theTimeOut = lua_tointeger(luaVm, 3);
|
||||
const auto metadata = lua_tostring(luaVm, 4);
|
||||
struct _ctx {
|
||||
std::shared_ptr<std::string> url;
|
||||
std::shared_ptr<std::string> header;
|
||||
std::shared_ptr<std::string> metadata;
|
||||
long timeOut;
|
||||
};
|
||||
_ctx* ctx = new _ctx{
|
||||
.url = std::make_shared<std::string>(url),
|
||||
.header = std::make_shared<std::string>(header),
|
||||
.metadata = std::make_shared<std::string>(metadata),
|
||||
.timeOut = (long)theTimeOut,
|
||||
};
|
||||
if (ctx) {
|
||||
CreateThread(
|
||||
nullptr, 0,
|
||||
[](void* ctx) -> DWORD {
|
||||
const auto theCtx = reinterpret_cast<_ctx*>(ctx);
|
||||
std::string response;
|
||||
auto httpCode =
|
||||
Server::HttpGet(*theCtx->url.get(), response,
|
||||
*theCtx->header.get(), theCtx->timeOut);
|
||||
ScriptCallBacks::luaCall_onHttpRequest(
|
||||
*theCtx->url.get(), *theCtx->metadata.get(),
|
||||
response.c_str(), httpCode);
|
||||
delete theCtx;
|
||||
return 0;
|
||||
},
|
||||
const_cast<_ctx*>(ctx), 0, nullptr);
|
||||
}
|
||||
lua_pop(luaVm, 4);
|
||||
return 0;
|
||||
}
|
||||
auto luaApi_GetConVarString(lua_State* luaVm) -> int {
|
||||
// param: convarObject:int
|
||||
const auto inputData = lua_tointeger(luaVm, 1);
|
||||
std::string value;
|
||||
if (inputData != NULL) {
|
||||
ConVarHandle theConvarHandle{};
|
||||
theConvarHandle.Set(inputData);
|
||||
if (theConvarHandle.IsValid()) {
|
||||
const auto convarData =
|
||||
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
||||
if (convarData) {
|
||||
const auto address = convarData->values;
|
||||
const auto valueData = reinterpret_cast<char*>(address);
|
||||
value = valueData ? std::string(valueData) : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
lua_pop(luaVm, 1);
|
||||
lua_pushstring(luaVm, value.c_str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
auto luaApi_GetConVarInt(lua_State* luaVm) -> int {
|
||||
// param: convarObject:int
|
||||
const auto inputData = lua_tointeger(luaVm, 1);
|
||||
if (inputData)
|
||||
{
|
||||
ConVarHandle theConvarHandle{};
|
||||
theConvarHandle.Set(inputData);
|
||||
int value = -1;
|
||||
if (theConvarHandle.IsValid()) {
|
||||
const auto convarData =
|
||||
Offset::InterFaces::IVEngineCvar->GetConVar(theConvarHandle);
|
||||
value = convarData ? reinterpret_cast<int>(convarData->values) : -1;
|
||||
}
|
||||
lua_pop(luaVm, 1);
|
||||
lua_pushinteger(luaVm, value);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
auto luaApi_GetConVarObject(lua_State* luaVm) -> int {
|
||||
// param: name:string
|
||||
const auto name = lua_tostring(luaVm, 1);
|
||||
lua_pushnumber(luaVm,
|
||||
Offset::InterFaces::IVEngineCvar->FindConVar(name).Get());
|
||||
return 1;
|
||||
}
|
||||
auto initFunciton(lua_State* luaVm) -> void {
|
||||
lua_register(luaVm, "ListenToGameEvent", luaApi_ListenToGameEvent);
|
||||
lua_register(luaVm, "luaApi_SetPlayerCurrentWeaponAmmo",
|
||||
@@ -716,6 +941,8 @@ auto initFunciton(lua_State* luaVm) -> void {
|
||||
lua_register(luaVm, "luaApi_SetPlayerArmorValue",
|
||||
luaApi_SetPlayerArmorValue);
|
||||
lua_register(luaVm, "luaApi_RespawnPlayer", luaApi_RespawnPlayer);
|
||||
lua_register(luaVm, "luaApi_RespawnPlayerInDeathMatch",
|
||||
luaApi_RespawnPlayerInDeathMatch);
|
||||
lua_register(luaVm, "luaApi_CreateTimer", luaApi_CreateTimer);
|
||||
lua_register(luaVm, "luaApi_CreateTickRunFunction",
|
||||
luaApi_CreateTickRunFunction);
|
||||
@@ -746,6 +973,20 @@ auto initFunciton(lua_State* luaVm) -> void {
|
||||
luaApi_SetPlayerGlowEnable);
|
||||
lua_register(luaVm, "luaApi_SetPlayerGlowColor", luaApi_SetPlayerGlowColor);
|
||||
lua_register(luaVm, "luaApi_GetAllPlayerIndex", luaApi_GetAllPlayerIndex);
|
||||
lua_register(luaVm, "luaApi_RunServerCommand", luaApi_RunServerCommand);
|
||||
lua_register(luaVm, "luaApi_KickPlayer", luaApi_KickPlayer);
|
||||
lua_register(luaVm, "luaApi_HttpGet", luaApi_HttpGet);
|
||||
lua_register(luaVm, "luaApi_HttpPost", luaApi_HttpPost);
|
||||
lua_register(luaVm, "luaApi_HttpAsyncGet", luaApi_HttpAsyncGet);
|
||||
lua_register(luaVm, "luaApi_HttpAsyncPost", luaApi_HttpAsyncPost);
|
||||
lua_register(luaVm, "luaApi_GetConVarObject", luaApi_GetConVarObject);
|
||||
|
||||
lua_register(luaVm, "luaApi_GetConVarString", luaApi_GetConVarString);
|
||||
lua_register(luaVm, "luaApi_GetConVarInt", luaApi_GetConVarInt);
|
||||
lua_register(luaVm, "luaApi_GetPlayerSteamId", luaApi_GetPlayerSteamId);
|
||||
lua_register(luaVm, "luaApi_RunClientCommand", luaApi_RunClientCommand);
|
||||
|
||||
// lua_register(luaVm, "luaApi_TeleportPlayer", luaApi_TeleportPlayer);
|
||||
|
||||
luabridge::getGlobalNamespace(luaVm)
|
||||
.beginClass<_luaApi_WeaponInfo>("WeaponInfo")
|
||||
|
||||
@@ -14,6 +14,9 @@ std::unordered_map<uint32_t, _CallbackNames> callbackNameWithEnumMap{
|
||||
{hash_32_fnv1a_const("round_start"), _CallbackNames::kOnRoundStart},
|
||||
{hash_32_fnv1a_const("round_end"), _CallbackNames::kOnRoundEnd},
|
||||
{hash_32_fnv1a_const("player_hurt"), _CallbackNames::kOnPlayerHurt},
|
||||
{hash_32_fnv1a_const("player_team"), _CallbackNames::kOnPlayerTeamChange},
|
||||
{hash_32_fnv1a_const("http_request"), _CallbackNames::kOnHttpRequest},
|
||||
|
||||
};
|
||||
auto CallBackNameToEnum(const char* name) -> _CallbackNames {
|
||||
if (name == nullptr) {
|
||||
@@ -205,4 +208,51 @@ auto luaCall_onPlayerHurt(int userid, int attacker, int health, int armor,
|
||||
}
|
||||
});
|
||||
}
|
||||
auto luaCall_onPlayerTeamChange(int userid, int team, int oldteam,
|
||||
bool disconnect, bool slient, bool isBot)
|
||||
-> bool {
|
||||
bool result = false;
|
||||
ExcuteCallbackInAllLuaVm(_CallbackNames::kOnPlayerTeamChange,
|
||||
[&](lua_State* luaVm, int refIndex) -> void {
|
||||
lua_rawgeti(luaVm, LUA_REGISTRYINDEX,
|
||||
refIndex);
|
||||
if (lua_isfunction(luaVm, -1)) {
|
||||
lua_pushinteger(luaVm, userid);
|
||||
lua_pushinteger(luaVm, team);
|
||||
lua_pushinteger(luaVm, oldteam);
|
||||
lua_pushboolean(luaVm, disconnect);
|
||||
lua_pushboolean(luaVm, slient);
|
||||
lua_pushboolean(luaVm, isBot);
|
||||
|
||||
if (lua_pcall(luaVm, 6, 1, 0) != LUA_OK) {
|
||||
LOG("Error calling Lua callback: %s\n",
|
||||
lua_tostring(luaVm, -1));
|
||||
lua_pop(luaVm, 1);
|
||||
}
|
||||
if (lua_isboolean(luaVm, -1)) {
|
||||
result = lua_toboolean(luaVm, -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
auto luaCall_onHttpRequest(std::string url, std::string metaData,
|
||||
std::string respon, int statusCode) -> void {
|
||||
ExcuteCallbackInAllLuaVm(_CallbackNames::kOnHttpRequest,
|
||||
[&](lua_State* luaVm, int refIndex) -> void {
|
||||
lua_rawgeti(luaVm, LUA_REGISTRYINDEX,
|
||||
refIndex);
|
||||
if (lua_isfunction(luaVm, -1)) {
|
||||
lua_pushstring(luaVm, url.c_str());
|
||||
lua_pushstring(luaVm, metaData.c_str());
|
||||
lua_pushstring(luaVm, respon.c_str());
|
||||
lua_pushinteger(luaVm, statusCode);
|
||||
if (lua_pcall(luaVm, 4, 0, 0) != LUA_OK) {
|
||||
LOG("Error calling Lua callback: %s\n",
|
||||
lua_tostring(luaVm, -1));
|
||||
lua_pop(luaVm, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} // namespace ScriptCallBacks
|
||||
|
||||
@@ -11,7 +11,9 @@ enum class _CallbackNames {
|
||||
kOnPlayerSpawn,
|
||||
kOnRoundStart,
|
||||
kOnRoundEnd,
|
||||
kOnPlayerHurt
|
||||
kOnPlayerHurt,
|
||||
kOnPlayerTeamChange,
|
||||
kOnHttpRequest
|
||||
};
|
||||
extern std::unordered_map<lua_State*, std::unordered_map<_CallbackNames, int>>
|
||||
callbackList;
|
||||
@@ -33,4 +35,9 @@ auto luaCall_onRoundEnd(int winnerTeam, int reason, const char* message)
|
||||
auto luaCall_onPlayerHurt(int userid, int attacker, int health, int armor,
|
||||
const char* weapon, int dmg_health, int dmg_armor,
|
||||
int hitgroup) -> void;
|
||||
auto luaCall_onPlayerTeamChange(int userid, int team, int oldteam,
|
||||
bool disconnect, bool slient, bool isBot)
|
||||
-> bool;
|
||||
auto luaCall_onHttpRequest(std::string url, std::string metaData,
|
||||
std::string respon, int statusCode) -> void;
|
||||
} // namespace ScriptCallBacks
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "script_engine.h"
|
||||
extern "C" int luaopen_cjson(lua_State * L);
|
||||
|
||||
namespace ScriptEngine {
|
||||
std::string luaPath;
|
||||
std::map<std::string, lua_State*> pluginEnvs;
|
||||
@@ -44,6 +46,10 @@ auto initLuaScripts() -> void {
|
||||
lua_State* L = luaL_newstate();
|
||||
|
||||
luaL_openlibs(L);
|
||||
|
||||
luaL_requiref(L, "cjson", luaopen_cjson, 1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
ScriptApis::initFunciton(L);
|
||||
|
||||
pluginEnvs[dirName] = L;
|
||||
@@ -59,15 +65,20 @@ auto initLuaScripts() -> void {
|
||||
|
||||
std::string scriptDir = dirPath;
|
||||
lua_getglobal(L, "package");
|
||||
lua_getfield(L, -1, "path"); // get field "path" from table at top of stack (-1)
|
||||
std::string cur_path = lua_tostring(L, -1); // grab path string from top of stack
|
||||
cur_path.append(";"); // do your path magic here
|
||||
lua_getfield(
|
||||
L, -1, "path"); // get field "path" from table at top of stack (-1)
|
||||
std::string cur_path =
|
||||
lua_tostring(L, -1); // grab path string from top of stack
|
||||
cur_path.append(";"); // do your path magic here
|
||||
cur_path.append(scriptDir);
|
||||
cur_path.append("\\?.lua");
|
||||
lua_pop(L, 1); // get rid of the string on the stack we just pushed on line 5
|
||||
lua_pushstring(L, cur_path.c_str()); // push the new one
|
||||
lua_setfield(L, -2, "path"); // set the field "path" in table at -2 with value at top of stack
|
||||
lua_pop(L, 1); // get rid of package table from top of stack
|
||||
lua_pop(
|
||||
L,
|
||||
1); // get rid of the string on the stack we just pushed on line 5
|
||||
lua_pushstring(L, cur_path.c_str()); // push the new one
|
||||
lua_setfield(L, -2, "path"); // set the field "path" in table at -2
|
||||
// with value at top of stack
|
||||
lua_pop(L, 1); // get rid of package table from top of stack
|
||||
|
||||
if (luaL_dofile(L, file.c_str())) {
|
||||
LOG("dofile_err:%s\n\n", lua_tostring(L, -1));
|
||||
|
||||
@@ -9,87 +9,168 @@ class CUtlString;
|
||||
class IToolGameEventAPI {
|
||||
virtual void unk001(void*) = 0;
|
||||
};
|
||||
struct UnkGameEventStruct_t {
|
||||
UnkGameEventStruct_t(const char* keyName) {
|
||||
m_Unk = 0;
|
||||
m_Key = keyName;
|
||||
|
||||
static auto MurmurHash2(const void* key, int len, uint32 seed) -> uint32_t
|
||||
{
|
||||
#define LittleDWord( val ) ( val )
|
||||
|
||||
// 'm' and 'r' are mixing constants generated offline.
|
||||
// They're not really 'magic', they just happen to work well.
|
||||
|
||||
const uint32 m = 0x5bd1e995;
|
||||
const int r = 24;
|
||||
|
||||
// Initialize the hash to a 'random' value
|
||||
|
||||
uint32 h = seed ^ len;
|
||||
|
||||
// Mix 4 bytes at a time into the hash
|
||||
|
||||
const unsigned char* data = (const unsigned char*)key;
|
||||
|
||||
while (len >= 4)
|
||||
{
|
||||
uint32 k = LittleDWord(*(uint32*)data);
|
||||
|
||||
k *= m;
|
||||
k ^= k >> r;
|
||||
k *= m;
|
||||
|
||||
h *= m;
|
||||
h ^= k;
|
||||
|
||||
data += 4;
|
||||
len -= 4;
|
||||
}
|
||||
|
||||
uint64_t m_Unk;
|
||||
const char* m_Key;
|
||||
// Handle the last few bytes of the input array
|
||||
|
||||
switch (len)
|
||||
{
|
||||
case 3: h ^= data[2] << 16;
|
||||
case 2: h ^= data[1] << 8;
|
||||
case 1: h ^= data[0];
|
||||
h *= m;
|
||||
};
|
||||
|
||||
// Do a few final mixes of the hash to ensure the last few
|
||||
// bytes are well-incorporated.
|
||||
|
||||
h ^= h >> 13;
|
||||
h *= m;
|
||||
h ^= h >> 15;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
struct GameEventKeySymbol_t {
|
||||
GameEventKeySymbol_t(const char* keyName) {
|
||||
if (keyName != nullptr) {
|
||||
m_nHashCode = MurmurHash2(keyName, strlen(keyName), 0x31415926);
|
||||
m_pszKeyName = keyName;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t m_nHashCode;
|
||||
const char* m_pszKeyName;
|
||||
};
|
||||
|
||||
class IGameEvent {
|
||||
class IHandleEntity
|
||||
{
|
||||
virtual void Schema_DynamicBinding(void**) = 0;
|
||||
public:
|
||||
virtual ~IHandleEntity() = 0;
|
||||
virtual const CEntityHandle GetRefEHandle() const = 0;
|
||||
};
|
||||
class IGameEvent{
|
||||
public:
|
||||
// 0
|
||||
virtual ~IGameEvent(){};
|
||||
virtual ~IGameEvent() {};
|
||||
virtual const char* GetName() const = 0; // get event name
|
||||
virtual int GetID() const = 0;
|
||||
|
||||
virtual bool IsReliable() const = 0; // if event handled reliable
|
||||
virtual bool IsLocal() const = 0; // if event is never networked
|
||||
virtual bool IsEmpty(
|
||||
const char* keyName = NULL) = 0; // check if data field exists
|
||||
virtual bool IsEmpty(const GameEventKeySymbol_t
|
||||
& keySymbol) = 0; // check if data field exists
|
||||
|
||||
// Data access index 6
|
||||
virtual bool GetBool(UnkGameEventStruct_t* keyName = NULL,
|
||||
// Data access
|
||||
virtual bool GetBool(const GameEventKeySymbol_t& keySymbol,
|
||||
bool defaultValue = false) = 0;
|
||||
virtual int GetInt(UnkGameEventStruct_t* keyName = NULL,
|
||||
virtual int GetInt(const GameEventKeySymbol_t& keySymbol,
|
||||
int defaultValue = 0) = 0;
|
||||
virtual uint64_t GetUint64(const char* keyName = NULL,
|
||||
uint64_t defaultValue = 0) = 0;
|
||||
virtual float GetFloat(const char* keyName = NULL,
|
||||
virtual uint64 GetUint64(const GameEventKeySymbol_t& keySymbol,
|
||||
uint64 defaultValue = 0) = 0;
|
||||
virtual float GetFloat(const GameEventKeySymbol_t& keySymbol,
|
||||
float defaultValue = 0.0f) = 0;
|
||||
virtual const char* GetString(UnkGameEventStruct_t* keyName = NULL,
|
||||
virtual const char* GetString(const GameEventKeySymbol_t& keySymbol,
|
||||
const char* defaultValue = "") = 0;
|
||||
virtual void* GetPtr(const char* keyName = NULL,
|
||||
void* defaultValue = NULL) = 0;
|
||||
virtual void* GetPtr(const GameEventKeySymbol_t& keySymbol) = 0;
|
||||
|
||||
/* These function prototypes and names are very speculative and might be
|
||||
* incorrect */
|
||||
virtual CEntityHandle GetEHandle(UnkGameEventStruct_t* keyName,
|
||||
CEntityHandle defaultValue) = 0;
|
||||
virtual CEntityHandle GetStrictEHandle(UnkGameEventStruct_t* keyName,
|
||||
CEntityHandle defaultValue) = 0;
|
||||
virtual CEntityHandle GetEHandle2(UnkGameEventStruct_t* keyName,
|
||||
CEntityHandle defaultValue) = 0;
|
||||
virtual CEntityHandle GetEHandle(
|
||||
const GameEventKeySymbol_t& keySymbol,
|
||||
CEntityHandle defaultValue = CEntityHandle()) = 0;
|
||||
|
||||
virtual CPlayerSlot* GetPlayerSlot(
|
||||
UnkGameEventStruct_t* keyName = NULL) = 0;
|
||||
virtual CBasePlayer* GetPlayer(UnkGameEventStruct_t* keyName = NULL) = 0;
|
||||
// Returns the entity instance, mostly used for _pawn keys, might return 0
|
||||
// if used on any other key (even on a controller).
|
||||
virtual IHandleEntity* GetEntity(
|
||||
const GameEventKeySymbol_t& keySymbol,
|
||||
IHandleEntity* fallbackInstance = NULL) = 0;
|
||||
virtual CEntityIndex GetEntityIndex(
|
||||
const GameEventKeySymbol_t& keySymbol,
|
||||
CEntityIndex defaultValue = CEntityIndex(-1)) = 0;
|
||||
|
||||
virtual void* GetPlayerPawn(UnkGameEventStruct_t* keyName = NULL) = 0;
|
||||
virtual CEntityHandle GetPlayerControllerEHandle(
|
||||
UnkGameEventStruct_t* keyName = NULL) = 0;
|
||||
virtual CEntityHandle GetPlayerControllerEHandle2(
|
||||
UnkGameEventStruct_t* keyName = NULL) = 0;
|
||||
/* ============================================================ */
|
||||
virtual CPlayerSlot GetPlayerSlot(
|
||||
const GameEventKeySymbol_t& keySymbol) = 0;
|
||||
|
||||
virtual void SetBool(const char* keyName, bool value) = 0;
|
||||
virtual void SetInt(const char* keyName, int value) = 0;
|
||||
virtual void SetUint64(const char* keyName, uint64_t value) = 0;
|
||||
virtual void SetFloat(const char* keyName, float value) = 0;
|
||||
virtual void SetString(const char* keyName, const char* value) = 0;
|
||||
virtual void SetPtr(const char* keyName, void* value) = 0;
|
||||
virtual IHandleEntity* GetPlayerController(
|
||||
const GameEventKeySymbol_t& keySymbol) = 0;
|
||||
virtual IHandleEntity* GetPlayerPawn(
|
||||
const GameEventKeySymbol_t& keySymbol) = 0;
|
||||
|
||||
/* These function prototypes and names are very speculative and might be
|
||||
* incorrect */
|
||||
virtual void SetEHandleStrict(const char* keyName,
|
||||
CEntityHandle handle) = 0;
|
||||
virtual void SetEHandle(const char* keyName, CEntityHandle handle) = 0;
|
||||
// Returns the EHandle for the _pawn entity.
|
||||
virtual CEntityHandle GetPawnEHandle(
|
||||
const GameEventKeySymbol_t& keySymbol) = 0;
|
||||
// Returns the CEntityIndex for the _pawn entity.
|
||||
virtual CEntityIndex GetPawnEntityIndex(
|
||||
const GameEventKeySymbol_t& keySymbol) = 0;
|
||||
|
||||
virtual void SetBool(const GameEventKeySymbol_t& keySymbol, bool value) = 0;
|
||||
virtual void SetInt(const GameEventKeySymbol_t& keySymbol, int value) = 0;
|
||||
virtual void SetUint64(const GameEventKeySymbol_t& keySymbol,
|
||||
uint64 value) = 0;
|
||||
virtual void SetFloat(const GameEventKeySymbol_t& keySymbol,
|
||||
float value) = 0;
|
||||
virtual void SetString(const GameEventKeySymbol_t& keySymbol,
|
||||
const char* value) = 0;
|
||||
virtual void SetPtr(const GameEventKeySymbol_t& keySymbol, void* value) = 0;
|
||||
|
||||
virtual void SetEntity(const GameEventKeySymbol_t& keySymbol,
|
||||
CEntityIndex value) = 0;
|
||||
virtual void SetEntity(const GameEventKeySymbol_t& keySymbol,
|
||||
IHandleEntity* value) = 0;
|
||||
|
||||
// Also sets the _pawn key
|
||||
virtual void SetPlayerSlot(const char* keyName, CPlayerSlot value) = 0;
|
||||
virtual void SetPlayer(const char* keyName, CBasePlayer* value) = 0;
|
||||
/* ============================================================ */
|
||||
virtual void SetPlayer(const GameEventKeySymbol_t& keySymbol,
|
||||
CPlayerSlot value) = 0;
|
||||
// Also sets the _pawn key (Expects pawn entity to be passed)
|
||||
virtual void SetPlayer(const GameEventKeySymbol_t& keySymbol,
|
||||
IHandleEntity* pawn) = 0;
|
||||
|
||||
virtual bool HasKey(const char* keyName) = 0;
|
||||
// Expects pawn entity to be passed, will set the controller entity as a
|
||||
// controllerKeyName and pawn entity as a pawnKeyName.
|
||||
virtual void SetPlayerRaw(const GameEventKeySymbol_t& controllerKeySymbol,
|
||||
const GameEventKeySymbol_t& pawnKeySymbol,
|
||||
IHandleEntity* pawn) = 0;
|
||||
|
||||
virtual bool HasKey(const GameEventKeySymbol_t& keySymbol) = 0;
|
||||
|
||||
// Something script vm related
|
||||
virtual void unk001() = 0;
|
||||
|
||||
// virtual KeyValues* GetDataKeys() const = 0;
|
||||
// Not based on keyvalues anymore as it seems like
|
||||
virtual void* GetDataKeys() const = 0;
|
||||
};
|
||||
|
||||
class IGameEventListener2 {
|
||||
public:
|
||||
virtual ~IGameEventListener2(void){};
|
||||
|
||||
@@ -313,6 +313,7 @@ public:
|
||||
|
||||
virtual void ServerConVarChanged(const char* pVarName, const char* pValue) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Interface the engine exposes to the game DLL
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -326,6 +327,7 @@ public:
|
||||
virtual void unk003() = 0;
|
||||
virtual void unk004() = 0;
|
||||
virtual void unk005() = 0;
|
||||
virtual void unk006() = 0;
|
||||
|
||||
|
||||
// Tell engine to change level ( "changelevel s1\n" or "changelevel2 s1 s2\n" )
|
||||
@@ -417,7 +419,7 @@ public:
|
||||
|
||||
virtual void SetTimescale(float flTimescale) = 0;
|
||||
|
||||
virtual uint32_t GetAppID() = 0;
|
||||
virtual uint32 GetAppID() = 0;
|
||||
|
||||
// Returns the SteamID of the specified player. It'll be NULL if the player hasn't authenticated yet.
|
||||
virtual const CSteamID* GetClientSteamID(CPlayerSlot clientIndex) = 0;
|
||||
@@ -451,7 +453,7 @@ public:
|
||||
virtual bool GetPlayerInfo(CPlayerSlot clientIndex, google::protobuf::Message& info) = 0;
|
||||
|
||||
// Returns the XUID of the specified player. It'll be NULL if the player hasn't connected yet.
|
||||
virtual uint64_t GetClientXUID(CPlayerSlot clientIndex) = 0;
|
||||
virtual uint64 GetClientXUID(CPlayerSlot clientIndex) = 0;
|
||||
|
||||
virtual void* GetPVSForSpawnGroup(SpawnGroupHandle_t spawnGroup) = 0;
|
||||
virtual SpawnGroupHandle_t FindSpawnGroupByName(const char* szName) = 0;
|
||||
@@ -463,45 +465,57 @@ public:
|
||||
|
||||
virtual bool IsClientLowViolence(CEntityIndex clientIndex) = 0;
|
||||
|
||||
#if 0 // Don't really match the binary
|
||||
// Kicks the slot with the specified NetworkDisconnectionReason
|
||||
virtual void DisconnectClient(CEntityIndex clientIndex, /* ENetworkDisconnectionReason */ int reason) = 0;
|
||||
|
||||
#if 0 // Don't really match the binary
|
||||
virtual void GetAllSpawnGroupsWithPVS(CUtlVector<SpawnGroupHandle_t>* spawnGroups, CUtlVector<IPVS*>* pOut) = 0;
|
||||
|
||||
virtual void P2PGroupChanged() = 0;
|
||||
#endif
|
||||
|
||||
virtual void unk006() = 0;
|
||||
virtual void unk007() = 0;
|
||||
virtual void unk008() = 0;
|
||||
virtual void unk009() = 0;
|
||||
virtual void unk010() = 0;
|
||||
virtual void unk011() = 0;
|
||||
virtual void unk012() = 0;
|
||||
virtual void unk013() = 0;
|
||||
virtual void unk101() = 0;
|
||||
virtual void unk102() = 0;
|
||||
virtual void unk103() = 0;
|
||||
virtual void unk104() = 0;
|
||||
virtual void unk105() = 0;
|
||||
virtual void unk106() = 0;
|
||||
virtual void unk107() = 0;
|
||||
|
||||
virtual void OnKickClient(const CCommandContext& context, const CCommand& cmd) = 0;
|
||||
|
||||
// Kicks the slot with the specified NetworkDisconnectionReason.
|
||||
// Kicks and bans the slot.
|
||||
// Note that the internal reason is never displayed to the user.
|
||||
// ENetworkDisconnectionReason reason is ignored, client is always kicked with ENetworkDisconnectionReason::NETWORK_DISCONNECT_KICKBANADDED
|
||||
//
|
||||
// AM TODO: add header ref for ENetworkDisconnectReason from proto header
|
||||
virtual void KickClient(CPlayerSlot slot, const char* szInternalReason, /*ENetworkDisconnectionReason*/ char reason) = 0;
|
||||
virtual void BanClient(CPlayerSlot slot, const char* szInternalReason, /*ENetworkDisconnectionReason*/ char reason) = 0;
|
||||
|
||||
virtual void unk015() = 0;
|
||||
virtual void unk016() = 0;
|
||||
virtual void unk017() = 0;
|
||||
virtual void unk018() = 0;
|
||||
virtual void unk019() = 0;
|
||||
virtual void unk020() = 0;
|
||||
virtual void unk021() = 0;
|
||||
virtual void unk022() = 0;
|
||||
virtual void unk023() = 0;
|
||||
virtual void unk200() = 0;
|
||||
virtual void unk201() = 0;
|
||||
virtual void unk202() = 0;
|
||||
virtual void unk203() = 0;
|
||||
virtual void unk204() = 0;
|
||||
virtual void unk205() = 0;
|
||||
virtual void unk206() = 0;
|
||||
virtual void unk207() = 0;
|
||||
virtual void unk208() = 0;
|
||||
|
||||
virtual void SetClientUpdateRate(CEntityIndex clientIndex, float flUpdateRate) = 0;
|
||||
|
||||
virtual void unk024() = 0;
|
||||
virtual void unk025() = 0;
|
||||
virtual void unk300() = 0;
|
||||
virtual void unk301() = 0;
|
||||
};
|
||||
|
||||
class IServerGCLobby
|
||||
{
|
||||
public:
|
||||
virtual bool HasLobby() const = 0;
|
||||
virtual bool SteamIDAllowedToConnect(const CSteamID& steamId) const = 0;
|
||||
virtual void UpdateServerDetails(void) = 0;
|
||||
virtual bool ShouldHibernate() = 0;
|
||||
virtual bool SteamIDAllowedToP2PConnect(const CSteamID& steamId) const = 0;
|
||||
virtual bool LobbyAllowsCheats(void) const = 0;
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Player / Client related functions
|
||||
|
||||
@@ -38,7 +38,7 @@ auto SentChatToClient(CCSPlayerController* player, _HubType hubtype, const char*
|
||||
|
||||
va_end(args);
|
||||
|
||||
Offset::FnClientPrint(player, hubtype, buf, nullptr, nullptr, nullptr, nullptr);
|
||||
Offset::FnClientPrint(player, static_cast<int>(hubtype), buf, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
auto SendConsoleChat(_HubType hubtype, const char* msg, ...) -> void
|
||||
{
|
||||
@@ -50,6 +50,6 @@ auto SendConsoleChat(_HubType hubtype, const char* msg, ...) -> void
|
||||
|
||||
va_end(args);
|
||||
|
||||
Offset::FnUTIL_ClientPrintAll(hubtype, buf, nullptr, nullptr, nullptr, nullptr);
|
||||
Offset::FnUTIL_ClientPrintAll(static_cast<int>(hubtype), buf, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
}; // namespace SdkTools
|
||||
|
||||
@@ -8,8 +8,8 @@ inline int EntityIndex_to_PlayerSlot(int EntityIndex) {
|
||||
#define HUD_PRINTCONSOLE 2
|
||||
#define HUD_PRINTTALK 3
|
||||
#define HUD_PRINTCENTER 4
|
||||
enum _ChatType { kTeam, kAll };
|
||||
enum _HubType { kNotify = 1, kConsole, kTalk, kCenter, kMax };
|
||||
enum class _ChatType { kTeam, kAll, kConsole };
|
||||
enum class _HubType { kNotify = 1, kConsole, kTalk, kCenter, kMax };
|
||||
|
||||
namespace SdkTools {
|
||||
auto ProcessChatString(const std::string& input)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
#include "tools.h"
|
||||
namespace Tools {
|
||||
auto toLower(const std::string& str) -> std::string{
|
||||
std::string lowerStr = str;
|
||||
std::transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
return lowerStr;
|
||||
}
|
||||
auto GetDirs(const std::string& path)
|
||||
-> std::pair<std::vector<std::string>, std::vector<std::string>> {
|
||||
std::vector<std::string> dirPaths;
|
||||
|
||||
@@ -6,4 +6,5 @@ auto GetExePath() -> std::string;
|
||||
auto GetFiles(const std::string& path, std::vector<std::string>& files) -> void;
|
||||
auto GetDirs(const std::string& path)
|
||||
-> std::pair<std::vector<std::string>, std::vector<std::string>>;
|
||||
auto toLower(const std::string& str) -> std::string;
|
||||
}; // namespace Tools
|
||||
|
||||
Reference in New Issue
Block a user