Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "util.h"
  8. #include <string.h>
  9. #define NUM_BUFFERS 4
  10. #define MAX_INFO_TOKEN_LENGTH 512
  11. const char *CUtil::InfoGetValue( const char *s, const char *key )
  12. {
  13. char pkey[MAX_INFO_TOKEN_LENGTH];
  14. // Use multiple buffers so compares
  15. // work without stomping on each other
  16. static char value[NUM_BUFFERS][MAX_INFO_TOKEN_LENGTH];
  17. static int valueindex;
  18. char *o;
  19. valueindex = (valueindex + 1) % NUM_BUFFERS;
  20. if (*s == '\\')
  21. s++;
  22. while (1)
  23. {
  24. o = pkey;
  25. while (*s != '\\')
  26. {
  27. if (!*s)
  28. return "";
  29. *o++ = *s++;
  30. }
  31. *o = 0;
  32. s++;
  33. o = value[valueindex];
  34. while (*s != '\\' && *s)
  35. {
  36. if (!*s)
  37. return "";
  38. *o++ = *s++;
  39. }
  40. *o = 0;
  41. if (!strcmp (key, pkey) )
  42. return value[valueindex];
  43. if (!*s)
  44. return "";
  45. s++;
  46. }
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Purpose: This function is supposed to localise the strings, but for now just return internal value
  50. // Input : *stringName -
  51. // Output : const char
  52. //-----------------------------------------------------------------------------
  53. const char *CUtil::GetString(const char *stringName)
  54. {
  55. return stringName;
  56. }
  57. static CUtil g_Util;
  58. CUtil *util = &g_Util;