ReactOS 0.4.15-dev-8109-gd7be748
nbnamecache.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _NBNameCacheEntry
 

Typedefs

typedef struct _NBNameCacheEntry NBNameCacheEntry
 

Functions

struct NBNameCacheNBNameCacheCreate (HANDLE heap, DWORD entryExpireTimeMS) DECLSPEC_HIDDEN
 
BOOL NBNameCacheAddEntry (struct NBNameCache *cache, NBNameCacheEntry *entry) DECLSPEC_HIDDEN
 
const NBNameCacheEntryNBNameCacheFindEntry (struct NBNameCache *cache, const UCHAR name[NCBNAMSZ]) DECLSPEC_HIDDEN
 
void NBNameCacheDestroy (struct NBNameCache *cache) DECLSPEC_HIDDEN
 

Typedef Documentation

◆ NBNameCacheEntry

Function Documentation

◆ NBNameCacheAddEntry()

BOOL NBNameCacheAddEntry ( struct NBNameCache cache,
NBNameCacheEntry entry 
)

Definition at line 111 of file nbnamecache.c.

112{
113 BOOL ret;
114
115 if (cache && entry)
116 {
118
120 node = NBNameCacheWalk(cache, (char*)entry->name);
121 if (node)
122 {
123 (*node)->expireTime = GetTickCount() +
124 cache->entryExpireTimeMS;
125 HeapFree(cache->heap, 0, (*node)->entry);
126 (*node)->entry = entry;
127 ret = TRUE;
128 }
129 else
130 {
131 NBNameCacheNode *newNode = HeapAlloc(cache->heap, 0, sizeof(NBNameCacheNode));
132 if (newNode)
133 {
134 newNode->expireTime = GetTickCount() +
135 cache->entryExpireTimeMS;
136 newNode->entry = entry;
137 newNode->next = cache->head;
138 cache->head = newNode;
139 ret = TRUE;
140 }
141 else
142 ret = FALSE;
143 }
145 }
146 else
147 ret = FALSE;
148 return ret;
149}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned int BOOL
Definition: ntddk_ex.h:94
uint32_t entry
Definition: isohybrid.c:63
static NBNameCacheNode ** NBNameCacheWalk(struct NBNameCache *cache, const char name[NCBNAMSZ])
Definition: nbnamecache.c:66
struct _NBNameCacheNode * next
Definition: nbnamecache.c:28
NBNameCacheEntry * entry
Definition: nbnamecache.c:27
Definition: cache.c:49
Definition: dlist.c:348
int ret
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by NetBTStoreCacheEntry().

◆ NBNameCacheCreate()

struct NBNameCache * NBNameCacheCreate ( HANDLE  heap,
DWORD  entryExpireTimeMS 
)

Definition at line 92 of file nbnamecache.c.

93{
94 struct NBNameCache *cache;
95
96
97 if (!heap)
99 cache = HeapAlloc(heap, 0, sizeof(struct NBNameCache));
100 if (cache)
101 {
102 cache->heap = heap;
104 cache->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": NBNameCache.cs");
105 cache->entryExpireTimeMS = entryExpireTimeMS;
106 cache->head = NULL;
107 }
108 return cache;
109}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
static HANDLE heap
Definition: heap.c:65
DWORD entryExpireTimeMS
Definition: nbnamecache.c:35
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define DWORD_PTR
Definition: treelist.c:76

Referenced by NetBTStoreCacheEntry().

◆ NBNameCacheDestroy()

void NBNameCacheDestroy ( struct NBNameCache cache)

Definition at line 176 of file nbnamecache.c.

177{
178 if (cache)
179 {
180 cache->cs.DebugInfo->Spare[0] = 0;
182 while (cache->head)
184 HeapFree(cache->heap, 0, cache);
185 }
186}
static void NBNameCacheUnlinkNode(struct NBNameCache *cache, NBNameCacheNode **prev)
Definition: nbnamecache.c:43
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by NetBTCleanup(), and NetBTCleanupAdapter().

◆ NBNameCacheFindEntry()

const NBNameCacheEntry * NBNameCacheFindEntry ( struct NBNameCache cache,
const UCHAR  name[NCBNAMSZ] 
)

Definition at line 151 of file nbnamecache.c.

153{
154 const NBNameCacheEntry *ret;
155 UCHAR printName[NCBNAMSZ];
156
157 memcpy(printName, name, NCBNAMSZ - 1);
158 printName[NCBNAMSZ - 1] = '\0';
159 if (cache)
160 {
162
164 node = NBNameCacheWalk(cache, (const char *)name);
165 if (node)
166 ret = (*node)->entry;
167 else
168 ret = NULL;
170 }
171 else
172 ret = NULL;
173 return ret;
174}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define NCBNAMSZ
Definition: nb30.h:7
Definition: name.c:39
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by NetBTInternalFindName().