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.
 
 
 
 
 
 

77 lines
1016 B

#pragma once
class elt
{
public:
LPTSTR key;
LPTSTR val;
elt *next,
*prev;
elt()
{
next = NULL;
prev = NULL;
key = NULL;
val = NULL;
}
virtual ~elt()
{
if (key)
free (key);
if (val)
free (val);
}
};
class CStrList
{
protected:
elt *head;
int count;
HANDLE hmtxLock;
elt *FindElement ( LPCTSTR key );
void Lock ()
{
if ( hmtxLock )
WaitForSingleObject ( hmtxLock, INFINITE );
}
void Unlock ()
{
if ( hmtxLock )
ReleaseMutex ( hmtxLock );
}
public:
CStrList()
{
head = NULL;
count = 0;
hmtxLock = CreateMutex ( NULL, FALSE, NULL );
}
virtual ~CStrList()
{
RemoveAll();
CloseHandle ( hmtxLock );
}
bool AddValue ( LPCTSTR key, LPCTSTR val );
LPTSTR Lookup ( LPCTSTR key, LPTSTR outBuf );
void RemoveByKey ( LPCTSTR key );
void RemoveAll ();
LPTSTR ConcatKeyValues ( LPCTSTR separator, LPTSTR outBuf );
int GetCount ()
{
return count;
}
};