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.
 
 
 
 
 
 

134 lines
2.7 KiB

#ifndef _REQUEST_HEADERHASH_HXX_
#define _REQUEST_HEADERHASH_HXX_
//
// Helper class for String->Index hash
//
struct HEADER_RECORD
{
ULONG _ulHeaderIndex;
CHAR * _pszName;
USHORT _cchName;
};
#define HEADER(x) x, sizeof(x) - sizeof(CHAR)
//
// *_HEADER_HASH maps strings to UlHeader* values
//
#define UNKNOWN_INDEX (0xFFFFFFFF)
class REQUEST_HEADER_HASH
: public CTypedHashTable< REQUEST_HEADER_HASH,
HEADER_RECORD,
CHAR * >
{
public:
REQUEST_HEADER_HASH()
: CTypedHashTable< REQUEST_HEADER_HASH,
HEADER_RECORD,
CHAR * >
("REQUEST_HEADER_HASH")
{
}
static
CHAR *
ExtractKey(
const HEADER_RECORD * pRecord
)
{
DBG_ASSERT( pRecord != NULL );
return pRecord->_pszName;
}
static
DWORD
CalcKeyHash(
CHAR * pszKey
)
{
return HashStringNoCase( pszKey );
}
static
bool
EqualKeys(
CHAR * pszKey1,
CHAR * pszKey2
)
{
return _stricmp( pszKey1, pszKey2 ) == 0;
}
static
void
AddRefRecord(
HEADER_RECORD *,
int
)
{
}
static
HRESULT
Initialize(
VOID
);
static
VOID
Terminate(
VOID
);
static
ULONG
GetIndex(
CHAR * pszName
)
{
HEADER_RECORD * pRecord = NULL;
LK_RETCODE retCode;
retCode = sm_pRequestHash->FindKey( pszName,
&pRecord );
if ( retCode == LK_SUCCESS )
{
DBG_ASSERT( pRecord != NULL );
return pRecord->_ulHeaderIndex;
}
else
{
return UNKNOWN_INDEX;
}
}
static
CHAR *
GetString(
ULONG ulIndex,
DWORD * pcchLength
)
{
if ( ulIndex < HttpHeaderRequestMaximum )
{
*pcchLength = sm_rgHeaders[ ulIndex ]._cchName;
return sm_rgHeaders[ ulIndex ]._pszName;
}
return NULL;
}
private:
static REQUEST_HEADER_HASH *sm_pRequestHash;
static HEADER_RECORD sm_rgHeaders[];
REQUEST_HEADER_HASH(const REQUEST_HEADER_HASH &);
void operator=(const REQUEST_HEADER_HASH &);
};
#endif