anisette is done, how to sign?
This commit is contained in:
@@ -1,9 +1,30 @@
|
|||||||
#include "appleauth/iauth.h"
|
#include "appleauth/iauth.h"
|
||||||
#include "tier2/fileformats/xml.h"
|
#include "tier2/fileformats/plist.h"
|
||||||
#include "http/http.h"
|
#include "http/http.h"
|
||||||
|
#include "openssl/srp.h"
|
||||||
|
#include "openssl/sha.h"
|
||||||
|
#include "tier0/rand.h"
|
||||||
|
|
||||||
IHTTPClientManager *g_pHttpClientMgr = NULL;
|
IHTTPClientManager *g_pHttpClientMgr = NULL;
|
||||||
|
|
||||||
|
// autogenerated
|
||||||
|
#define APPLE_LOCAL_USER "e2e70285da39596ef06153b9c4e1e5dc8d2f983bc5cd63f5b1e292207060d931"
|
||||||
|
#define APPLE_HTTP_HEADER \
|
||||||
|
{ \
|
||||||
|
{"X-Apple-I-Client-Time", "2026-1-1T12:00:00"}, \
|
||||||
|
{"X-Apple-Locale", "en_US"}, \
|
||||||
|
{"X-Apple-I-TimeZone", "Europe/Kyiv"}, \
|
||||||
|
{"X-Mme-Client-Info", "<MacBookPro13,2> <macOS;13.1;22C65> <com.apple.AuthKit/1 (com.apple.dt.Xcode/3594.4.19)>"}, \
|
||||||
|
{"User-Agent", "akd/1.0 CFNetwork/808.1.4"}, \
|
||||||
|
{"X-Apple-I-MD-LU", APPLE_LOCAL_USER}, \
|
||||||
|
{"X-Apple-I-MD-M", "0"}, \
|
||||||
|
{"X-Apple-I-SRL-NO", "0"}, \
|
||||||
|
{"X-Mme-Device-Id", "0"}, \
|
||||||
|
{"Content-Type", "text/x-xml-plist"}, \
|
||||||
|
{"Accept", "*/*"}, \
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class CAppleAuth: public IAppleAuth
|
class CAppleAuth: public IAppleAuth
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -12,47 +33,197 @@ public:
|
|||||||
virtual EAppleAuthStatus SubmitLoginData( const char *szEmail, const char *szPassword ) override;
|
virtual EAppleAuthStatus SubmitLoginData( const char *szEmail, const char *szPassword ) override;
|
||||||
virtual EAppleAuthStatus Submit2FA( const char *szCode ) override;
|
virtual EAppleAuthStatus Submit2FA( const char *szCode ) override;
|
||||||
|
|
||||||
|
CUtlString FetchADIPB();
|
||||||
|
void FetchHeaders( CUtlString szAdiPb );
|
||||||
|
|
||||||
IHTTPClient *m_pANIClient;
|
IHTTPClient *m_pANIClient;
|
||||||
IHTTPClient *m_pGrandSlamClient;
|
IHTTPClient *m_pGrandSlamClient;
|
||||||
|
|
||||||
CUtlString m_szProvisionStart = "/";
|
CUtlString m_szProvisionStart = "/grandslam/MidService/startMachineProvisioning";
|
||||||
CUtlString m_szProvisionFinish = "/";
|
CUtlString m_szProvisionFinish = "/grandslam/MidService/finishMachineProvisioning";
|
||||||
|
IJSONObject *pHeader;
|
||||||
|
|
||||||
|
CUtlString m_szAppleIMD;
|
||||||
|
CUtlString m_szAppleIMDM;
|
||||||
|
CUtlString m_szAppleIMDRINFO;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void CAppleAuth::Init()
|
CUtlString CAppleAuth::FetchADIPB()
|
||||||
{
|
{
|
||||||
CreateInterfaceFn fnHttpFactory = Sys_GetFactory("funnyhttp");
|
|
||||||
g_pHttpClientMgr = (IHTTPClientManager*)fnHttpFactory(HTTP_CLIENT_INTERFACE_VERSION, NULL);
|
|
||||||
|
|
||||||
|
CUtlString szProvisionExpectedInputRaw = NULL;
|
||||||
|
IJSONObject *pObject = NULL;
|
||||||
|
IJSONObject *pPlistObject = NULL;
|
||||||
|
CUtlString szProvisionExpectedInput = NULL;
|
||||||
|
CUtlString szAdiPb = NULL;
|
||||||
|
|
||||||
m_pANIClient = g_pHttpClientMgr->Connect("ani.sidestore.io", true, NULL);
|
m_pANIClient = g_pHttpClientMgr->Connect("ani.sidestore.io", true, NULL);
|
||||||
m_pGrandSlamClient = g_pHttpClientMgr->Connect("gsa.apple.com", true, NULL);
|
m_pGrandSlamClient = g_pHttpClientMgr->Connect("gsa.apple.com", true, NULL);
|
||||||
|
|
||||||
{
|
{
|
||||||
HTTPHeaderParam_t params[] = {
|
HTTPHeaderParam_t params[] = APPLE_HTTP_HEADER;
|
||||||
{"X-Apple-I-Client-Time", "2026-1-1T12:00:00"},
|
|
||||||
{"X-Apple-Locale", "en_US"},
|
|
||||||
{"X-Apple-I-TimeZone", "Europe/Kyiv"},
|
|
||||||
{"X-Mme-Client-Info", "<MacBookPro13,2> <macOS;13.1;22C65> <com.apple.AuthKit/1 (com.apple.dt.Xcode/3594.4.19)>"},
|
|
||||||
{"User-Agent", "akd/1.0 CFNetwork/808.1.4"},
|
|
||||||
{"X-Apple-I-MD-LU", "user"},
|
|
||||||
{"X-Apple-I-MD-M", "0"},
|
|
||||||
{"X-Apple-I-SRL-NO", "0"},
|
|
||||||
{"X-Mme-Device-Id", "0"},
|
|
||||||
{"Content-Type", "text/x-xml-plist"},
|
|
||||||
{"Accept", "*/*"},
|
|
||||||
};
|
|
||||||
HTTPHeader_t header = {
|
HTTPHeader_t header = {
|
||||||
sizeof(params)/sizeof(HTTPHeaderParam_t),
|
sizeof(params)/sizeof(HTTPHeaderParam_t),
|
||||||
params,
|
params,
|
||||||
};
|
};
|
||||||
m_pGrandSlamClient->Get("/grandslam/GsService2/lookup", &header);
|
m_pGrandSlamClient->Get("/grandslam/GsService2/lookup", &header);
|
||||||
HTTPResponse_t r = m_pGrandSlamClient->GetResponse();
|
HTTPResponse_t r = m_pGrandSlamClient->GetResponse();
|
||||||
if (r.m_uCode == 200)
|
if ( r.m_uCode != 200 )
|
||||||
|
{
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pANIClient);
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pGrandSlamClient);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !m_pANIClient->WebSocket_Connect("/v3/provisioning_session") )
|
||||||
|
Plat_FatalErrorFunc("Failed to init AppleAuth websocket\n");
|
||||||
|
|
||||||
|
// Getting adipb
|
||||||
|
while ( ( szProvisionExpectedInputRaw = m_pANIClient->WebSocket_RecvText() ) != NULL )
|
||||||
|
{
|
||||||
|
pObject = JSONManager()->ReadString(szProvisionExpectedInputRaw);
|
||||||
|
szProvisionExpectedInput = pObject->GetValue("result")->GetStringValue();
|
||||||
|
V_printf("%s\n",szProvisionExpectedInput.GetString());
|
||||||
|
if ( szProvisionExpectedInput == "GiveIdentifier" )
|
||||||
|
{
|
||||||
|
m_pANIClient->WebSocket_SendText("{\"identifier\": \"" APPLE_LOCAL_USER "\"}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( szProvisionExpectedInput == "GiveStartProvisioningData" )
|
||||||
|
{
|
||||||
|
const char *plist =
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "
|
||||||
|
"\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||||
|
"<plist version=\"1.0\">\n"
|
||||||
|
"<dict>\n"
|
||||||
|
"\t<key>Header</key>\n"
|
||||||
|
"\t<dict/>\n"
|
||||||
|
"\t<key>Request</key>\n"
|
||||||
|
"\t<dict/>\n"
|
||||||
|
"</dict>\n"
|
||||||
|
"</plist>\n";
|
||||||
|
|
||||||
|
HTTPHeaderParam_t params[] = APPLE_HTTP_HEADER;
|
||||||
|
HTTPHeader_t header = {
|
||||||
|
sizeof(params)/sizeof(HTTPHeaderParam_t),
|
||||||
|
params,
|
||||||
|
};
|
||||||
|
m_pGrandSlamClient->Post(m_szProvisionStart, &header, V_strlen(plist), plist);
|
||||||
|
HTTPResponse_t r = m_pGrandSlamClient->GetResponse();
|
||||||
|
if ( r.m_uCode != 200 )
|
||||||
|
{
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pANIClient);
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pGrandSlamClient);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
IJSONObject *pObject = PropertyListManager()->ReadString(r.m_message);
|
||||||
|
CUtlString spim = pObject->GetValue("Response")->GetObject()->GetValue("spim")->GetStringValue();
|
||||||
|
m_pANIClient->WebSocket_SendText(CUtlString("{\"spim\": \"%s\"}", spim.GetString()));
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( szProvisionExpectedInput == "GiveEndProvisioningData" )
|
||||||
|
{
|
||||||
|
CUtlString cpim = pObject->GetValue("cpim")->GetStringValue();
|
||||||
|
|
||||||
|
CUtlString plist = CUtlString(
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "
|
||||||
|
"\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||||
|
"<plist version=\"1.0\">\n"
|
||||||
|
"<dict>\n"
|
||||||
|
"\t<key>Header</key>\n"
|
||||||
|
"\t<dict/>\n"
|
||||||
|
"\t<key>Request</key>\n"
|
||||||
|
"\t<dict>\n"
|
||||||
|
"\t<key>cpim</key>\n"
|
||||||
|
"\t<string>%s</string>\n"
|
||||||
|
"\t</dict>\n"
|
||||||
|
"</dict>\n"
|
||||||
|
"</plist>\n", cpim.GetString());
|
||||||
|
|
||||||
|
HTTPHeaderParam_t params[] = APPLE_HTTP_HEADER;
|
||||||
|
HTTPHeader_t header = {
|
||||||
|
sizeof(params)/sizeof(HTTPHeaderParam_t),
|
||||||
|
params,
|
||||||
|
};
|
||||||
|
m_pGrandSlamClient->Post(m_szProvisionFinish, &header, V_strlen(plist), plist);
|
||||||
|
HTTPResponse_t r = m_pGrandSlamClient->GetResponse();
|
||||||
|
if ( r.m_uCode != 200 )
|
||||||
|
{
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pANIClient);
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pGrandSlamClient);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
IJSONObject *pObject = PropertyListManager()->ReadString(r.m_message);
|
||||||
|
CUtlString tk = pObject->GetValue("Response")->GetObject()->GetValue("tk")->GetStringValue();
|
||||||
|
CUtlString ptm = pObject->GetValue("Response")->GetObject()->GetValue("ptm")->GetStringValue();
|
||||||
|
|
||||||
|
V_printf("%s\n",CUtlString("{\"tk\": \"%s\", \"ptm\": \"%s\"}", tk.GetString(), ptm.GetString()).GetString());
|
||||||
|
m_pANIClient->WebSocket_SendText(CUtlString("{\"tk\": \"%s\", \"ptm\": \"%s\"}", tk.GetString(), ptm.GetString()));
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( szProvisionExpectedInput == "ProvisioningSuccess" )
|
||||||
|
{
|
||||||
|
szAdiPb = pObject->GetValue("adi_pb")->GetStringValue();
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pANIClient);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( szProvisionExpectedInput == "Timeout" )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pANIClient);
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pGrandSlamClient);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pANIClient);
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pGrandSlamClient);
|
||||||
|
return szAdiPb;
|
||||||
|
}
|
||||||
|
void CAppleAuth::FetchHeaders( CUtlString szAdiPb )
|
||||||
|
{
|
||||||
|
// Get header
|
||||||
|
HTTPHeaderParam_t params[] = {
|
||||||
|
"Content-Type", "application/json",
|
||||||
|
};
|
||||||
|
HTTPHeader_t header = {
|
||||||
|
sizeof(params)/sizeof(HTTPHeaderParam_t),
|
||||||
|
params,
|
||||||
|
};
|
||||||
|
m_pANIClient = g_pHttpClientMgr->Connect("ani.sidestore.io", true, NULL);
|
||||||
|
CUtlString szPostData = CUtlString("{\"identifier\": \"" APPLE_LOCAL_USER "\", \"adi_pb\": \"%s\"}", szAdiPb.GetString());
|
||||||
|
V_printf("%s\n",szPostData.GetString());
|
||||||
|
m_pANIClient->Post("/v3/get_headers", &header, V_strlen(szPostData), szPostData);
|
||||||
|
HTTPResponse_t r = m_pANIClient->GetResponse();
|
||||||
|
V_printf("%i\n",r.m_uCode);
|
||||||
|
if ( r.m_uCode == 200 )
|
||||||
{
|
{
|
||||||
V_printf("%s\n",r.m_message.GetMemory());
|
V_printf("%s\n",r.m_message.GetMemory());
|
||||||
|
pHeader = JSONManager()->ReadString(r.m_message);
|
||||||
|
m_szAppleIMD = pHeader->GetValue("X-Apple-I-MD")->GetStringValue();
|
||||||
|
m_szAppleIMDM = pHeader->GetValue("X-Apple-I-MD-M")->GetStringValue();
|
||||||
|
m_szAppleIMDRINFO = pHeader->GetValue("X-Apple-I-MD-RINFO")->GetStringValue();
|
||||||
|
JSONManager()->FreeObject(pHeader);
|
||||||
}
|
}
|
||||||
}
|
g_pHttpClientMgr->Disconnect(m_pANIClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAppleAuth::Init()
|
||||||
|
{
|
||||||
|
CreateInterfaceFn fnHttpFactory = Sys_GetFactory("funnyhttp");
|
||||||
|
|
||||||
|
g_pHttpClientMgr = (IHTTPClientManager*)fnHttpFactory(HTTP_CLIENT_INTERFACE_VERSION, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
CUtlString szAdiPb = FetchADIPB();
|
||||||
|
FetchHeaders(szAdiPb);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAppleAuth::Shutdown()
|
void CAppleAuth::Shutdown()
|
||||||
@@ -62,7 +233,118 @@ void CAppleAuth::Shutdown()
|
|||||||
|
|
||||||
EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *szPassword )
|
EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *szPassword )
|
||||||
{
|
{
|
||||||
|
const char *pszUser = "your_username";
|
||||||
|
const char *pszPass = "";
|
||||||
|
|
||||||
|
SRP_gN *pstGN = SRP_get_default_gN("2048");
|
||||||
|
if (!pstGN) return APPLE_AUTH_FAILURE;
|
||||||
|
|
||||||
|
const BIGNUM *pN = pstGN->N;
|
||||||
|
const BIGNUM *pG = pstGN->g;
|
||||||
|
|
||||||
|
unsigned char aucSalt[16];
|
||||||
|
Plat_URandom(sizeof(aucSalt), aucSalt);
|
||||||
|
|
||||||
|
unsigned char aucHash[SHA256_DIGEST_LENGTH];
|
||||||
|
SHA256_CTX stCtx;
|
||||||
|
SHA256_Init(&stCtx);
|
||||||
|
SHA256_Update(&stCtx, aucSalt, sizeof(aucSalt));
|
||||||
|
SHA256_Update(&stCtx, pszUser, strlen(pszUser));
|
||||||
|
SHA256_Update(&stCtx, ":", 1);
|
||||||
|
SHA256_Update(&stCtx, pszPass, strlen(pszPass));
|
||||||
|
SHA256_Final(aucHash, &stCtx);
|
||||||
|
BIGNUM *pX = BN_bin2bn(aucHash, SHA256_DIGEST_LENGTH, NULL);
|
||||||
|
BIGNUM *pV = BN_new();
|
||||||
|
BN_CTX *pstCtx = BN_CTX_new();
|
||||||
|
if (!BN_mod_exp(pV, pG, pX, pN, pstCtx)) return APPLE_AUTH_FAILURE;
|
||||||
|
BN_free(pX);
|
||||||
|
|
||||||
|
BIGNUM *pA = BN_new();
|
||||||
|
BIGNUM *pApriv = BN_new();
|
||||||
|
if (!BN_rand(pApriv, 256, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY)) return APPLE_AUTH_FAILURE;
|
||||||
|
if (!BN_mod_exp(pA, pG, pApriv, pN, pstCtx)) return APPLE_AUTH_FAILURE;
|
||||||
|
|
||||||
|
char *pszA = BN_bn2hex(pA);
|
||||||
|
V_printf("A: %s\n",pszA);
|
||||||
|
CUtlString plist = CUtlString(
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "
|
||||||
|
"\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||||
|
"<plist version=\"1.0\">\n"
|
||||||
|
"<dict>\n"
|
||||||
|
"\t<key>Header</key>\n"
|
||||||
|
"\t<dict/>\n"
|
||||||
|
|
||||||
|
"\t<key>Request</key>\n"
|
||||||
|
"\t<dict>\n"
|
||||||
|
"\t<key>A2k</key>\n"
|
||||||
|
"\t<string>%s</string>\n"
|
||||||
|
"\t<key>ps</key>\n"
|
||||||
|
"\t<array><string>s2k</string><string>s2k_fo</string></array>\n"
|
||||||
|
"\t<string>%s</string>\n"
|
||||||
|
"\t<key>o</key>\n"
|
||||||
|
"\t<string>complete</string>\n"
|
||||||
|
|
||||||
|
"\t<key>cpd</key>\n"
|
||||||
|
"\t<dict>\n"
|
||||||
|
"\t<key>bootstrap</key>\n"
|
||||||
|
"\t<true/>\n"
|
||||||
|
"\t<key>capp</key>\n"
|
||||||
|
"\t<string>AppStore</string>\n"
|
||||||
|
"\t<key>ckgen</key>\n"
|
||||||
|
"\t<true/>\n"
|
||||||
|
"\t<key>dc</key>\n"
|
||||||
|
"\t<string>#d4c5b3</string>\n"
|
||||||
|
"\t<key>dec</key>\n"
|
||||||
|
"\t<string>#e1e4e3</string>\n"
|
||||||
|
"\t<key>loc</key>\n"
|
||||||
|
"\t<string>en_US</string>\n"
|
||||||
|
"\t<key>pbe</key>\n"
|
||||||
|
"\t<false/>\n"
|
||||||
|
"\t<key>prtn</key>\n"
|
||||||
|
"\t<string>ME349</string>\n"
|
||||||
|
"\t<key>svct</key>\n"
|
||||||
|
"\t<string>iTunes</string>\n"
|
||||||
|
|
||||||
|
"\t<key>X-Apple-I-MD</key>\n"
|
||||||
|
"\t<string>%s</string>\n"
|
||||||
|
|
||||||
|
"\t<key>X-Apple-I-MD-M</key>\n"
|
||||||
|
"\t<string>%s</string>\n"
|
||||||
|
|
||||||
|
"\t<key>X-Apple-I-MD-RINFO</key>\n"
|
||||||
|
"\t<string>%s</string>\n"
|
||||||
|
"\t</dict>\n"
|
||||||
|
|
||||||
|
"\t</dict>\n"
|
||||||
|
"</dict>\n"
|
||||||
|
"</plist>\n", pszA, szEmail, m_szAppleIMD.GetString(), m_szAppleIMDM.GetString(), m_szAppleIMDRINFO.GetString());
|
||||||
|
m_pGrandSlamClient = g_pHttpClientMgr->Connect("gsa.apple.com", true, NULL);
|
||||||
|
HTTPHeaderParam_t params[] = {
|
||||||
|
{"Content-Type", "text/x-xml-plist"},
|
||||||
|
{"Accept", "*/*"},
|
||||||
|
};
|
||||||
|
HTTPHeader_t header = {
|
||||||
|
sizeof(params)/sizeof(HTTPHeaderParam_t),
|
||||||
|
params,
|
||||||
|
};
|
||||||
|
V_printf("%s\n",plist.GetString());
|
||||||
|
m_pGrandSlamClient->Post("/grandslam/GsService2", &header, plist.GetLenght(), plist);
|
||||||
|
HTTPResponse_t stResponse = m_pGrandSlamClient->GetResponse();
|
||||||
|
V_printf("%i\n", stResponse.m_uCode);
|
||||||
|
if (stResponse.m_uCode == 200)
|
||||||
|
{
|
||||||
|
V_printf("%s\n",stResponse.m_message.GetMemory());
|
||||||
|
|
||||||
|
}
|
||||||
|
g_pHttpClientMgr->Disconnect(m_pGrandSlamClient);
|
||||||
|
|
||||||
|
OPENSSL_free(pszA);
|
||||||
|
BN_free(pApriv);
|
||||||
|
BN_free(pA);
|
||||||
|
BN_free(pV);
|
||||||
|
BN_CTX_free(pstCtx);
|
||||||
|
return APPLE_AUTH_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAppleAuthStatus CAppleAuth::Submit2FA( const char *szCode )
|
EAppleAuthStatus CAppleAuth::Submit2FA( const char *szCode )
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "ld.h"
|
#include "ld.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/commandline.h"
|
|
||||||
|
|
||||||
ADD_DEPENDENCY_BUILD_FILE(tier0, "../tier0/build.cpp")
|
ADD_DEPENDENCY_BUILD_FILE(tier0, "../tier0/build.cpp")
|
||||||
ADD_DEPENDENCY_BUILD_FILE(tier1, "../tier1/build.cpp")
|
ADD_DEPENDENCY_BUILD_FILE(tier1, "../tier1/build.cpp")
|
||||||
@@ -23,6 +22,9 @@ DECLARE_BUILD_STAGE(appleauth)
|
|||||||
ldProject = ccompiler->Compile(&compileProject);
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier1, "tier1")});
|
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier1, "tier1")});
|
||||||
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier2, "tier2")});
|
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier2, "tier2")});
|
||||||
|
ldProject.libraries = {
|
||||||
|
"crypto",
|
||||||
|
};
|
||||||
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||||
|
|
||||||
CUtlString szOutputProject = linker->Link(&ldProject);
|
CUtlString szOutputProject = linker->Link(&ldProject);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# We want to build just enough to use other stuff
|
# We want to build just enough to use other stuff
|
||||||
TIER0_FILES := ../tier0/lib.cpp ../tier0/mem.cpp ../tier0/platform.cpp ../tier0/commandline.cpp
|
TIER0_FILES := ../tier0/lib.cpp ../tier0/mem.cpp ../tier0/platform.cpp ../tier0/commandline.cpp ../tier0/rand.cpp
|
||||||
TIER1_FILES := ../tier1/utlbuffer.cpp ../tier1/interface.cpp ../tier1/utlstring.cpp ../tier1/utlvector.cpp ../tier1/utlmap.cpp
|
TIER1_FILES := ../tier1/utlbuffer.cpp ../tier1/interface.cpp ../tier1/utlstring.cpp ../tier1/utlvector.cpp ../tier1/utlmap.cpp
|
||||||
TIER2_FILES := ../tier2/filesystem.cpp ../tier2/fileformats/ini.cpp
|
TIER2_FILES := ../tier2/filesystem.cpp ../tier2/fileformats/ini.cpp
|
||||||
FILESYSTEM_FILES := ../stdfilesystems/filesystem_libc.cpp
|
FILESYSTEM_FILES := ../stdfilesystems/filesystem_libc.cpp
|
||||||
@@ -20,7 +20,7 @@ recompile: ../build/tools/fpc
|
|||||||
build/fpc build
|
build/fpc build
|
||||||
|
|
||||||
install: ../build/tools/fpc libfpcbuild.a libfpc.so libtier0.so libtier1.a libtier2.a libfilesystem_std.so install_temp builddir
|
install: ../build/tools/fpc libfpcbuild.a libfpc.so libtier0.so libtier1.a libtier2.a libfilesystem_std.so install_temp builddir
|
||||||
$(CC) -fPIC main.cpp library/helper.cpp library/target.cpp library/builder.cpp -lc -lstdc++ $(CCFLAGS) -o build/fpc libtier0.so build/libtier1.a build/libtier2.a -Wl,--disable-new-dtags -Wl,-rpath,'$$ORIGIN'
|
$(CC) -fPIC main.cpp library/helper.cpp library/target.cpp library/builder.cpp -lc -lstdc++ $(CCFLAGS) -o build/fpc -ltier0 -Lbuild build/libtier1.a build/libtier2.a -Wl,--disable-new-dtags -Wl,-rpath,'$$ORIGIN'
|
||||||
build/fpc build
|
build/fpc build
|
||||||
mv build/fpc_temp build/fpc
|
mv build/fpc_temp build/fpc
|
||||||
mv build/libfpc_temp.so build/libfpc.so
|
mv build/libfpc_temp.so build/libfpc.so
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ DECLARE_BUILD_STAGE(libfpc)
|
|||||||
ldProject = ccompiler->Compile(&compileProject);
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||||
ldProject.libraryObjects = {
|
ldProject.libraryObjects = {
|
||||||
"libtier0.so",
|
GET_PROJECT_LIBRARY(tier0, "tier0"),
|
||||||
GET_PROJECT_LIBRARY(tier1, "tier1"),
|
GET_PROJECT_LIBRARY(tier1, "tier1"),
|
||||||
GET_PROJECT_LIBRARY(tier2, "tier2"),
|
GET_PROJECT_LIBRARY(tier2, "tier2"),
|
||||||
};
|
};
|
||||||
@@ -114,7 +114,7 @@ DECLARE_BUILD_STAGE(fpc)
|
|||||||
compileProject.includeDirectories = g_IncludeDirectories;
|
compileProject.includeDirectories = g_IncludeDirectories;
|
||||||
ldProject = ccompiler->Compile(&compileProject);
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
ldProject.libraryObjects = {
|
ldProject.libraryObjects = {
|
||||||
"libtier0.so",
|
GET_PROJECT_LIBRARY(tier0, "tier0"),
|
||||||
GET_PROJECT_LIBRARY(tier1, "tier1"),
|
GET_PROJECT_LIBRARY(tier1, "tier1"),
|
||||||
GET_PROJECT_LIBRARY(tier2, "tier2"),
|
GET_PROJECT_LIBRARY(tier2, "tier2"),
|
||||||
};
|
};
|
||||||
|
|||||||
BIN
fpc/fpc_temp
BIN
fpc/fpc_temp
Binary file not shown.
BIN
fpc/libfpc.so
BIN
fpc/libfpc.so
Binary file not shown.
@@ -2,7 +2,7 @@
|
|||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier0/commandline.h"
|
||||||
#include "tier1/interface.h"
|
#include "tier1/interface.h"
|
||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ CUtlString CAppleTool::SignPackage( const char *szIpa, const char *szPassword )
|
|||||||
Plat_FatalErrorFunc("Couldn't get xtool\n");
|
Plat_FatalErrorFunc("Couldn't get xtool\n");
|
||||||
g_pAppleAuth = (IAppleAuth*)fnFactory(APPLE_AUTH_INTERFACE_VERSION, NULL);
|
g_pAppleAuth = (IAppleAuth*)fnFactory(APPLE_AUTH_INTERFACE_VERSION, NULL);
|
||||||
g_pAppleAuth->Init();
|
g_pAppleAuth->Init();
|
||||||
|
g_pAppleAuth->SubmitLoginData("bratelllo@icloud.com", "");
|
||||||
return szIpa;
|
return szIpa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier0/commandline.h"
|
||||||
#include "tier1/interface.h"
|
#include "tier1/interface.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
|
|||||||
@@ -161,7 +161,18 @@ void CClangLinker::LinkFile( CUtlVector<CUtlString> &cmd, const char *szName )
|
|||||||
|
|
||||||
void CClangLinker::LinkLibraryObject( CUtlVector<CUtlString> &cmd, const char *szName )
|
void CClangLinker::LinkLibraryObject( CUtlVector<CUtlString> &cmd, const char *szName )
|
||||||
{
|
{
|
||||||
cmd.AppendTail(szName);
|
CUtlString szDir = CUtlString(szName).GetDirectory();
|
||||||
|
CUtlString szFileName = CUtlString(szName).GetFileName();
|
||||||
|
if (!V_strncmp(szFileName, "lib",3))
|
||||||
|
szFileName.RemoveHead(3);
|
||||||
|
if (!V_strncmp(szFileName.GetFileExtension(), "so",2))
|
||||||
|
szFileName.RemoveTail(3);
|
||||||
|
if (!V_strncmp(szFileName.GetFileExtension(), "a",1))
|
||||||
|
szFileName.RemoveTail(2);
|
||||||
|
cmd.AppendTail("-L");
|
||||||
|
cmd.AppendTail(szDir);
|
||||||
|
cmd.AppendTail("-l");
|
||||||
|
cmd.AppendTail(szFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClangLinker::LinkLibrary( CUtlVector<CUtlString> &cmd, const char *szName )
|
void CClangLinker::LinkLibrary( CUtlVector<CUtlString> &cmd, const char *szName )
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#include "sys/wait.h"
|
#include "sys/wait.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier0/commandline.h"
|
||||||
|
|
||||||
#include "winerunner.h"
|
#include "winerunner.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier0/commandline.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
#include "tier0/mem.h"
|
#include "tier0/mem.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier0/commandline.h"
|
||||||
#include "tier1/interface.h"
|
#include "tier1/interface.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
|
#include "tier0/commandline.h"
|
||||||
#include "tier1/interface.h"
|
#include "tier1/interface.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "tier1/commandline.h"
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#include "sys/wait.h"
|
#include "sys/wait.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier0/commandline.h"
|
||||||
|
|
||||||
class CWineRunner: public IWineRunner
|
class CWineRunner: public IWineRunner
|
||||||
{
|
{
|
||||||
|
|||||||
BIN
fpc/libtier0.so
BIN
fpc/libtier0.so
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier0/rand.h"
|
||||||
|
#include "tier0/commandline.h"
|
||||||
#include "tier1/interface.h"
|
#include "tier1/interface.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "tier2/ifilesystem.h"
|
#include "tier2/ifilesystem.h"
|
||||||
@@ -153,12 +154,10 @@ findbuild:
|
|||||||
*ppConfig = g_pConfig;
|
*ppConfig = g_pConfig;
|
||||||
|
|
||||||
CommandLine()->CreateCommandLine(c, v);
|
CommandLine()->CreateCommandLine(c, v);
|
||||||
|
Plat_InitRandom();
|
||||||
if (CommandLine()->CheckParam("build"))
|
if (CommandLine()->CheckParam("build"))
|
||||||
return build();
|
return build();
|
||||||
const char *szDeployDevice = CommandLine()->ParamValue("deploy");
|
const char *szDeployDevice = CommandLine()->ParamValue("deploy");
|
||||||
if (szDeployDevice)
|
Plat_ShutdownRandom();
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,20 +5,21 @@
|
|||||||
#ifndef TARGET_T
|
#ifndef TARGET_T
|
||||||
#define TARGET_T
|
#define TARGET_T
|
||||||
|
|
||||||
|
#include "tier0/commandline.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/commandline.h"
|
|
||||||
|
|
||||||
enum ETargetKernel
|
enum ETargetKernel
|
||||||
{
|
{
|
||||||
TARGET_KERNEL_UNKNOWN = 0,
|
TARGET_KERNEL_UNKNOWN = 0,
|
||||||
TARGET_KERNEL_LINUX,
|
|
||||||
|
|
||||||
TARGET_KERNEL_WINDOWS_DEVICES = 0x100,
|
TARGET_KERNEL_WINDOWS_DEVICES = 0x100,
|
||||||
TARGET_KERNEL_WINDOWS_MSVC,
|
TARGET_KERNEL_WINDOWS_MSVC,
|
||||||
TARGET_KERNEL_WINDOWS_GNU,
|
TARGET_KERNEL_WINDOWS_GNU,
|
||||||
TARGET_KERNEL_WINDOWS = TARGET_KERNEL_WINDOWS_GNU,
|
TARGET_KERNEL_WINDOWS = TARGET_KERNEL_WINDOWS_GNU,
|
||||||
|
|
||||||
TARGET_KERNEL_APPLE_DEVICES = 0x200,
|
TARGET_KERNEL_POSIX = 0x10000,
|
||||||
|
TARGET_KERNEL_LINUX,
|
||||||
|
TARGET_KERNEL_APPLE_DEVICES = TARGET_KERNEL_POSIX | 0x200,
|
||||||
TARGET_KERNEL_DARWIN,
|
TARGET_KERNEL_DARWIN,
|
||||||
TARGET_KERNEL_IOS,
|
TARGET_KERNEL_IOS,
|
||||||
TARGET_KERNEL_ANDROID,
|
TARGET_KERNEL_ANDROID,
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ void CHTTPClient::Post( const char *szResource, HTTPHeader_t *pHeader, uint32_t
|
|||||||
szCombined = szMessage;
|
szCombined = szMessage;
|
||||||
szCombined.AppendTail(szHeader);
|
szCombined.AppendTail(szHeader);
|
||||||
szCombined.AppendTail("\r\n");
|
szCombined.AppendTail("\r\n");
|
||||||
|
V_printf("%s\n",szCombined.GetString());
|
||||||
|
|
||||||
Write(szCombined.GetString(), szCombined.GetLenght());
|
Write(szCombined.GetString(), szCombined.GetLenght());
|
||||||
Write((void*)data, uDataSize);
|
Write((void*)data, uDataSize);
|
||||||
@@ -209,7 +210,6 @@ HTTPResponse_t CHTTPClient::ParseResponse( const char *szMessage, uint32_t uData
|
|||||||
{
|
{
|
||||||
if ( !V_stricmp( headers[i].m_szParamName, "Content-Length" ) )
|
if ( !V_stricmp( headers[i].m_szParamName, "Content-Length" ) )
|
||||||
{
|
{
|
||||||
V_printf("%s\n",headers[i].m_szValue.GetString());
|
|
||||||
uBodySize = atoll(headers[i].m_szValue);
|
uBodySize = atoll(headers[i].m_szValue);
|
||||||
bParseInChunks = false;
|
bParseInChunks = false;
|
||||||
};
|
};
|
||||||
@@ -302,7 +302,6 @@ void CHTTPClient::ConnectToServer()
|
|||||||
{
|
{
|
||||||
struct hostent *pServerHostName = NULL;
|
struct hostent *pServerHostName = NULL;
|
||||||
struct sockaddr_in serverAddress;
|
struct sockaddr_in serverAddress;
|
||||||
int fd = 0;
|
|
||||||
int err;
|
int err;
|
||||||
SSL_CTX *ctx;
|
SSL_CTX *ctx;
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
@@ -314,9 +313,6 @@ void CHTTPClient::ConnectToServer()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
||||||
if ( fd < 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
V_memset(&serverAddress, 0, sizeof(serverAddress));
|
V_memset(&serverAddress, 0, sizeof(serverAddress));
|
||||||
serverAddress.sin_family = AF_INET;
|
serverAddress.sin_family = AF_INET;
|
||||||
@@ -328,7 +324,7 @@ void CHTTPClient::ConnectToServer()
|
|||||||
// https
|
// https
|
||||||
serverAddress.sin_port = htons(m_uPort);
|
serverAddress.sin_port = htons(m_uPort);
|
||||||
|
|
||||||
err = connect(fd, (struct sockaddr *)&serverAddress, sizeof(serverAddress));
|
err = connect(m_iFileDescriptor, (struct sockaddr *)&serverAddress, sizeof(serverAddress));
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -341,7 +337,7 @@ void CHTTPClient::ConnectToServer()
|
|||||||
if (!ssl)
|
if (!ssl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SSL_set_fd(ssl, fd);
|
SSL_set_fd(ssl, m_iFileDescriptor);
|
||||||
SSL_set_tlsext_host_name(ssl, m_szHostName);
|
SSL_set_tlsext_host_name(ssl, m_szHostName);
|
||||||
|
|
||||||
int r = SSL_connect(ssl);
|
int r = SSL_connect(ssl);
|
||||||
@@ -354,7 +350,6 @@ void CHTTPClient::ConnectToServer()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
m_iFileDescriptor = fd;
|
|
||||||
if (m_bIsSecure)
|
if (m_bIsSecure)
|
||||||
{
|
{
|
||||||
m_pSSL = ssl;
|
m_pSSL = ssl;
|
||||||
@@ -524,6 +519,8 @@ public:
|
|||||||
IHTTPClient *CHTTPClientManager::Connect( const char *szUrl, bool bSecure, uint16_t *pPort )
|
IHTTPClient *CHTTPClientManager::Connect( const char *szUrl, bool bSecure, uint16_t *pPort )
|
||||||
{
|
{
|
||||||
CHTTPClient *pClient;
|
CHTTPClient *pClient;
|
||||||
|
int fd = 0;
|
||||||
|
|
||||||
pClient = new CHTTPClient();
|
pClient = new CHTTPClient();
|
||||||
if (pPort)
|
if (pPort)
|
||||||
pClient->m_uPort = *pPort;
|
pClient->m_uPort = *pPort;
|
||||||
@@ -534,6 +531,13 @@ IHTTPClient *CHTTPClientManager::Connect( const char *szUrl, bool bSecure, uint1
|
|||||||
else
|
else
|
||||||
pClient->m_uPort = 80;
|
pClient->m_uPort = 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if ( fd < 0 )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pClient->m_iFileDescriptor = fd;
|
||||||
|
|
||||||
pClient->m_szHostName = szUrl;
|
pClient->m_szHostName = szUrl;
|
||||||
pClient->m_bIsSecure = bSecure;
|
pClient->m_bIsSecure = bSecure;
|
||||||
return pClient;
|
return pClient;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
enum EAppleAuthStatus
|
enum EAppleAuthStatus
|
||||||
{
|
{
|
||||||
|
APPLE_AUTH_FAILURE,
|
||||||
APPLE_AUTH_SUCCESS,
|
APPLE_AUTH_SUCCESS,
|
||||||
APPLE_AUTH_NEED_2FA,
|
APPLE_AUTH_NEED_2FA,
|
||||||
APPLE_AUTH_NEED_SMS_2FA,
|
APPLE_AUTH_NEED_SMS_2FA,
|
||||||
|
|||||||
30
public/tier0/commandline.h
Normal file
30
public/tier0/commandline.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
//================= Copyright kotofyt, All rights reserved ==================//
|
||||||
|
// Purpose: Command line handler for argc and argv. It also allows to find
|
||||||
|
// parameters and push your own.
|
||||||
|
//===========================================================================//
|
||||||
|
|
||||||
|
#ifndef TIER0_COMMANDLINE_H
|
||||||
|
#define TIER0_COMMANDLINE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
|
||||||
|
abstract_class ICommandLine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void CreateCommandLine( int argc, char **argv ) = 0;
|
||||||
|
|
||||||
|
virtual bool CheckParam( const char *psz ) = 0;
|
||||||
|
virtual char *ParamValue( const char* psz, const char *szDefaultValue = 0 ) = 0;
|
||||||
|
|
||||||
|
virtual void AddParam( char *psz ) = 0;
|
||||||
|
virtual void RemoveParam( char *psz ) = 0;
|
||||||
|
|
||||||
|
virtual int ParamCount() = 0;
|
||||||
|
virtual int FindParam( const char *psz ) = 0;
|
||||||
|
virtual const char *GetParam(int nIndex) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
ICommandLine *CommandLine();
|
||||||
|
|
||||||
|
#endif
|
||||||
10
public/tier0/rand.h
Normal file
10
public/tier0/rand.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef TIER0_RAND_H
|
||||||
|
#define TIER0_RAND_H
|
||||||
|
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
|
||||||
|
PLATFORM_INTERFACE void Plat_InitRandom();
|
||||||
|
PLATFORM_INTERFACE void Plat_ShutdownRandom();
|
||||||
|
PLATFORM_INTERFACE void Plat_URandom( size_t uBufferSize, uint8_t *szBuffer );
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
void RemoveAt( size_t nPosition, size_t nCount );
|
void RemoveAt( size_t nPosition, size_t nCount );
|
||||||
|
|
||||||
CUtlString GetFileName();
|
CUtlString GetFileName();
|
||||||
|
CUtlString GetFileExtension();
|
||||||
CUtlString GetDirectory();
|
CUtlString GetDirectory();
|
||||||
CUtlString RemoveHeadFile();
|
CUtlString RemoveHeadFile();
|
||||||
|
|
||||||
@@ -126,13 +127,35 @@ inline CUtlString CUtlString::GetFileName()
|
|||||||
while (pLast != m_data.GetData())
|
while (pLast != m_data.GetData())
|
||||||
{
|
{
|
||||||
if (*pLast=='/')
|
if (*pLast=='/')
|
||||||
|
{
|
||||||
|
pLast++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
pLast--;
|
pLast--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pLast;
|
return pLast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CUtlString CUtlString::GetFileExtension()
|
||||||
|
{
|
||||||
|
CUtlString szFileName = GetString();
|
||||||
|
|
||||||
|
char *pLast = &m_data[GetLenght()-1];
|
||||||
|
while (pLast != m_data.GetData())
|
||||||
|
{
|
||||||
|
if (*pLast=='.')
|
||||||
|
break;
|
||||||
|
if (*pLast=='/')
|
||||||
|
return NULL;
|
||||||
|
pLast--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pLast+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline CUtlString CUtlString::GetDirectory()
|
inline CUtlString CUtlString::GetDirectory()
|
||||||
{
|
{
|
||||||
if (GetLenght() == 0)
|
if (GetLenght() == 0)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
#include "tier0/mem.h"
|
#include "tier0/mem.h"
|
||||||
#include "tier1/utlbuffer.h"
|
#include "tier1/utlbuffer.h"
|
||||||
#include "tier1/commandline.h"
|
|
||||||
#include "tier2/fileformats/ini.h"
|
#include "tier2/fileformats/ini.h"
|
||||||
#include "tier2/ifilesystem.h"
|
#include "tier2/ifilesystem.h"
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "ld.h"
|
#include "ld.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/commandline.h"
|
|
||||||
|
|
||||||
CUtlVector<CUtlString> tier0_CompiledFiles = {
|
CUtlVector<CUtlString> tier0_CompiledFiles = {
|
||||||
"lib.cpp",
|
"lib.cpp",
|
||||||
"mem.cpp",
|
"mem.cpp",
|
||||||
"platform.cpp",
|
"platform.cpp",
|
||||||
"network.cpp",
|
"network.cpp",
|
||||||
"commandline.cpp"
|
"commandline.cpp",
|
||||||
|
"rand.cpp",
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_BUILD_STAGE(tier0)
|
DECLARE_BUILD_STAGE(tier0)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "tier1/commandline.h"
|
#include "tier0/commandline.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "tier0/network.h"
|
#include "tier0/network.h"
|
||||||
#include "tier1/commandline.h"
|
|
||||||
|
|
||||||
void Net_Init()
|
void Net_Init()
|
||||||
{
|
{
|
||||||
|
|||||||
29
tier0/rand.cpp
Normal file
29
tier0/rand.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#include "tier0/rand.h"
|
||||||
|
#include "tier0/lib.h"
|
||||||
|
|
||||||
|
static bool b_sIsRandInit = false;
|
||||||
|
static FILE *s_pURandom = NULL;
|
||||||
|
|
||||||
|
PLATFORM_INTERFACE void Plat_InitRandom()
|
||||||
|
{
|
||||||
|
if (b_sIsRandInit)
|
||||||
|
return;
|
||||||
|
s_pURandom = V_fopen("/dev/urandom","rb");
|
||||||
|
if (!s_pURandom)
|
||||||
|
Plat_FatalErrorFunc("/dev/urandom wasn't found somehow\n");
|
||||||
|
b_sIsRandInit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PLATFORM_INTERFACE void Plat_ShutdownRandom()
|
||||||
|
{
|
||||||
|
b_sIsRandInit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PLATFORM_INTERFACE void Plat_URandom( size_t uBufferSize, uint8_t *szBuffer )
|
||||||
|
{
|
||||||
|
if (!b_sIsRandInit)
|
||||||
|
Plat_InitRandom();
|
||||||
|
|
||||||
|
V_fread(szBuffer, 1, uBufferSize, s_pURandom);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "ld.h"
|
#include "ld.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/commandline.h"
|
|
||||||
|
|
||||||
CUtlVector<CUtlString> tier1_CompiledFiles = {
|
CUtlVector<CUtlString> tier1_CompiledFiles = {
|
||||||
"interface.cpp",
|
"interface.cpp",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "ld.h"
|
#include "ld.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "tier1/commandline.h"
|
|
||||||
|
|
||||||
CUtlVector<CUtlString> tier2_CompiledFiles = {
|
CUtlVector<CUtlString> tier2_CompiledFiles = {
|
||||||
"fileformats/ini.cpp",
|
"fileformats/ini.cpp",
|
||||||
|
|||||||
@@ -218,7 +218,10 @@ void CJSONObject::CopyTo( IJSONObject *pObject )
|
|||||||
|
|
||||||
void CJSONObject::Free()
|
void CJSONObject::Free()
|
||||||
{
|
{
|
||||||
|
for ( auto ¶m: m_params )
|
||||||
|
{
|
||||||
|
JSONManager()->FreeValue(param.m_pValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract_class CJSONManager: public IJSONManager
|
abstract_class CJSONManager: public IJSONManager
|
||||||
@@ -247,7 +250,8 @@ IJSONObject *CJSONManager::CreateObject( )
|
|||||||
|
|
||||||
void CJSONManager::FreeObject( IJSONObject *pObject )
|
void CJSONManager::FreeObject( IJSONObject *pObject )
|
||||||
{
|
{
|
||||||
|
pObject->Free();
|
||||||
|
delete (CJSONObject*)pObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
IJSONArray *CJSONManager::CreateArray( )
|
IJSONArray *CJSONManager::CreateArray( )
|
||||||
@@ -267,7 +271,8 @@ IJSONValue *CJSONManager::CreateValue( )
|
|||||||
|
|
||||||
void CJSONManager::FreeValue( IJSONValue *pValue )
|
void CJSONManager::FreeValue( IJSONValue *pValue )
|
||||||
{
|
{
|
||||||
|
pValue->Free();
|
||||||
|
delete (CJSONValue*)pValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NEXT_TOKEN() \
|
#define NEXT_TOKEN() \
|
||||||
|
|||||||
Reference in New Issue
Block a user