Source code of Windows XP (NT5)
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.

86 lines
2.0 KiB

  1. #ifndef _CSPCACHE_H_
  2. #define _CSPCACHE_H_
  3. #include <windows.h>
  4. #define MAX_KEY_SIZE (50 * sizeof(CHAR))
  5. /*
  6. typedef enum
  7. {
  8. CardGeneralFile,
  9. CardContainer,
  10. CardFreeSpace,
  11. CardCapabilities
  12. } CACHE_TYPES;
  13. */
  14. typedef struct _CACHE_ITEM
  15. {
  16. //CACHE_TYPES CacheType;
  17. struct _CACHE_ITEM *pNext;
  18. LPSTR pszKey;
  19. PVOID pvData;
  20. } CACHE_ITEM, *PCACHE_ITEM;
  21. typedef struct _CACHE_HEAD
  22. {
  23. PCACHE_ITEM pCacheList;
  24. DWORD dwItemListCacheStamp;
  25. BOOL fAllItemsPresent;
  26. } CACHE_HEAD, *PCACHE_HEAD;
  27. typedef PCACHE_HEAD CACHE_HANDLE;
  28. //
  29. // Function: CacheGetItem
  30. //
  31. // Purpose: Search the provided cache list for the item
  32. // specified in pszKey. The search is conducted first by
  33. // CacheType, then by pszKey if pszKey is not NULL.
  34. // If the item is found, move it to
  35. // the front of the list and return its pvData member, and return
  36. // TRUE.
  37. // If the item is not found, return FALSE.
  38. //
  39. BOOL CacheGetItem(
  40. IN CACHE_HANDLE *phCache,
  41. IN CACHE_TYPES CacheType,
  42. IN OPTIONAL LPSTR pszKey,
  43. OUT PVOID *ppvData);
  44. //
  45. // Function: CacheDeleteCache
  46. //
  47. // Purpose: Free the provided cache list.
  48. //
  49. void CacheDeleteCache(
  50. IN OUT CACHE_HANDLE hCache);
  51. //
  52. // Function: CacheAddItem
  53. //
  54. // Purpose: If the key pszKey does not already exist in the provided cache
  55. // list, add the key and associate pvData with it. In this case *ppvOldData
  56. // will be set to NULL. If pszKey already exists, update the key with the
  57. // provided pvData, and set *ppvOldData to the previous pvData of the
  58. // specified key.
  59. //
  60. DWORD CacheAddItem(
  61. IN OUT CACHE_HANDLE *phCache,
  62. IN CACHE_TYPES CacheType,
  63. IN OPTIONAL LPSTR pszKey,
  64. IN PVOID pvData,
  65. OUT PVOID *ppvOldData);
  66. //
  67. // Function: CacheDeleteItem
  68. //
  69. // Purpose: Search the provided cache list for pszKey. If the node is found,
  70. // remove it from the list and return its pvData member. If the node is not
  71. // found, return NULL.
  72. //
  73. PVOID CacheDeleteItem(
  74. IN CACHE_HANDLE *phCache,
  75. LPSTR pszKey);
  76. #endif