Leaked source code of windows server 2003
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.

89 lines
2.0 KiB

  1. // ========================================================================
  2. // LANGID.H
  3. //
  4. // Cache to map between language ids (LCIDs) and MIME language specifiers
  5. // ("en-us" etc.)
  6. //
  7. // Copyright 1997-1998 Microsoft Corporation, All Rights Reserved
  8. //
  9. // ========================================================================
  10. #ifndef _LANGID_H_
  11. #define _LANGID_H_
  12. #include <ex\gencache.h>
  13. #include <singlton.h>
  14. // We need to lookup LCID-s from strings on (IIS-side).
  15. //
  16. class CLangIDCache : private Singleton<CLangIDCache>
  17. {
  18. //
  19. // Friend declarations required by Singleton template
  20. //
  21. friend class Singleton<CLangIDCache>;
  22. // Cache of mime mappings
  23. //
  24. typedef CCache<CRCSzi, LONG> CSzLCache;
  25. CSzLCache m_cache;
  26. // String data storage area.
  27. //
  28. ChainedStringBuffer<CHAR> m_sb;
  29. // CREATORS
  30. //
  31. // Declared private to ensure that arbitrary instances
  32. // of this class cannot be created. The Singleton
  33. // template (declared as a friend above) controls
  34. // the sole instance of this class.
  35. //
  36. CLangIDCache() {};
  37. // Function to fill cache with data.
  38. //
  39. static BOOL FFillCacheData();
  40. // NOT IMPLEMENTED
  41. //
  42. CLangIDCache& operator=(const CLangIDCache&);
  43. CLangIDCache(const CLangIDCache&);
  44. public:
  45. // STATICS
  46. //
  47. //
  48. // Instance creating/destroying routines provided
  49. // by the Singleton template.
  50. //
  51. using Singleton<CLangIDCache>::CreateInstance;
  52. using Singleton<CLangIDCache>::DestroyInstance;
  53. static BOOL FInitialize()
  54. {
  55. BOOL fSuccess = FALSE;
  56. // Init all our failing members.
  57. //
  58. if (!Instance().m_cache.FInit())
  59. goto ret;
  60. // Call the function to fill the cache.
  61. // If we do not succeed let us not block,
  62. // We will proceed with whatever we have got.
  63. //
  64. (void)Instance().FFillCacheData();
  65. fSuccess = TRUE;
  66. ret:
  67. return fSuccess;
  68. }
  69. // Find LangID from MIME language string
  70. //
  71. static LONG LcidFind (LPCSTR psz);
  72. };
  73. #endif // !_LANGID_H_