From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- tracker/common/util.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tracker/common/util.cpp (limited to 'tracker/common/util.cpp') diff --git a/tracker/common/util.cpp b/tracker/common/util.cpp new file mode 100644 index 0000000..d28b1c7 --- /dev/null +++ b/tracker/common/util.cpp @@ -0,0 +1,70 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include "util.h" +#include + +#define NUM_BUFFERS 4 +#define MAX_INFO_TOKEN_LENGTH 512 +const char *CUtil::InfoGetValue( const char *s, const char *key ) +{ + char pkey[MAX_INFO_TOKEN_LENGTH]; + // Use multiple buffers so compares + // work without stomping on each other + static char value[NUM_BUFFERS][MAX_INFO_TOKEN_LENGTH]; + static int valueindex; + char *o; + + valueindex = (valueindex + 1) % NUM_BUFFERS; + + if (*s == '\\') + s++; + while (1) + { + o = pkey; + while (*s != '\\') + { + if (!*s) + return ""; + *o++ = *s++; + } + *o = 0; + s++; + + o = value[valueindex]; + + while (*s != '\\' && *s) + { + if (!*s) + return ""; + *o++ = *s++; + } + *o = 0; + + if (!strcmp (key, pkey) ) + return value[valueindex]; + + if (!*s) + return ""; + s++; + } +} + +//----------------------------------------------------------------------------- +// Purpose: This function is supposed to localise the strings, but for now just return internal value +// Input : *stringName - +// Output : const char +//----------------------------------------------------------------------------- +const char *CUtil::GetString(const char *stringName) +{ + return stringName; +} + +static CUtil g_Util; +CUtil *util = &g_Util; + + -- cgit v1.2.3