ReactOS  0.4.14-dev-77-gd9e7c48
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 }
Definition: cache.c:46
#define TRUE
Definition: types.h:120
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
struct node node
unsigned int BOOL
Definition: ntddk_ex.h:94
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret
uint32_t entry
Definition: isohybrid.c:63
NBNameCacheEntry * entry
Definition: nbnamecache.c:27
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static NBNameCacheNode ** NBNameCacheWalk(struct NBNameCache *cache, const char name[NCBNAMSZ])
Definition: nbnamecache.c:66
#define HeapFree(x, y, z)
Definition: compat.h:394
struct _NBNameCacheNode * next
Definition: nbnamecache.c:28
Definition: dlist.c:348

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)
98  heap = GetProcessHeap();
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 }
Definition: cache.c:46
#define DWORD_PTR
Definition: treelist.c:76
HANDLE heap
Definition: nbnamecache.c:33
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static IOleCache * cache
Definition: ole2.c:75
DWORD entryExpireTimeMS
Definition: nbnamecache.c:35

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 }
Definition: cache.c:46
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
static void NBNameCacheUnlinkNode(struct NBNameCache *cache, NBNameCacheNode **prev)
Definition: nbnamecache.c:43
#define HeapFree(x, y, z)
Definition: compat.h:394

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 }
Definition: cache.c:46
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
struct node node
smooth NULL
Definition: ftsmooth.c:416
#define NCBNAMSZ
Definition: nb30.h:7
unsigned char UCHAR
Definition: xmlstorage.h:181
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: name.c:36
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static NBNameCacheNode ** NBNameCacheWalk(struct NBNameCache *cache, const char name[NCBNAMSZ])
Definition: nbnamecache.c:66
Definition: dlist.c:348

Referenced by NetBTInternalFindName().