Initial MSVC 2008 projects workspace
This commit is contained in:
36
l2ooghelper/BotConfigIDList.cpp
Normal file
36
l2ooghelper/BotConfigIDList.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
bool BotCfg_IsInList( const char *id, const char *list )
|
||||
{
|
||||
if( !id || !list ) return false;
|
||||
// olny one id in list, which is equal to what we need?
|
||||
if( _stricmp( id, list ) == 0 ) return true;
|
||||
// make copies
|
||||
char *idc = _strdup( id );
|
||||
char *listc = _strdup( list );
|
||||
// lowercase!
|
||||
_strlwr( idc );
|
||||
_strlwr( listc );
|
||||
//
|
||||
bool ret = false;
|
||||
char test_id[256];
|
||||
// id is in the beginning
|
||||
sprintf( test_id, "%s;", idc );
|
||||
if( strstr( listc, idc ) == listc ) ret = true;
|
||||
// id in the end
|
||||
if( !ret )
|
||||
{
|
||||
sprintf( test_id, "%;s", idc );
|
||||
if( strstr( listc, idc ) ) ret = true;
|
||||
}
|
||||
// in the middle?
|
||||
if( !ret )
|
||||
{
|
||||
sprintf( test_id, "%;s;", idc );
|
||||
if( strstr( listc, idc ) ) ret = true;
|
||||
}
|
||||
//
|
||||
free( idc );
|
||||
free( listc );
|
||||
return ret;
|
||||
}
|
Reference in New Issue
Block a user