mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-18 19:10:37 +00:00
public: add generic implementation for Q_memmem
This commit is contained in:
parent
aa3a0fa392
commit
07e622f224
@ -372,6 +372,23 @@ qboolean Q_stricmpext( const char *pattern, const char *text )
|
|||||||
return Q_strnicmpext( pattern, text, ~((size_t)0) );
|
return Q_strnicmpext( pattern, text, ~((size_t)0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const byte *Q_memmem( const byte *haystack, size_t haystacklen, const byte *needle, size_t needlelen )
|
||||||
|
{
|
||||||
|
const byte *i;
|
||||||
|
|
||||||
|
// quickly find first matching symbol
|
||||||
|
while( haystacklen && ( i = memchr( haystack, needle[0], haystacklen )))
|
||||||
|
{
|
||||||
|
if( !memcmp( i, needle, needlelen ))
|
||||||
|
return i;
|
||||||
|
|
||||||
|
haystacklen -= i - haystack;
|
||||||
|
haystack = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const char* Q_timestamp( int format )
|
const char* Q_timestamp( int format )
|
||||||
{
|
{
|
||||||
static string timestamp;
|
static string timestamp;
|
||||||
|
@ -78,6 +78,7 @@ void Q_atov( float *vec, const char *str, size_t siz );
|
|||||||
#define Q_strrchr strrchr
|
#define Q_strrchr strrchr
|
||||||
qboolean Q_stricmpext( const char *pattern, const char *text );
|
qboolean Q_stricmpext( const char *pattern, const char *text );
|
||||||
qboolean Q_strnicmpext( const char *pattern, const char *text, size_t minimumlen );
|
qboolean Q_strnicmpext( const char *pattern, const char *text, size_t minimumlen );
|
||||||
|
const byte *Q_memmem( const byte *haystack, size_t haystacklen, const byte *needle, size_t needlelen );
|
||||||
const char *Q_timestamp( int format );
|
const char *Q_timestamp( int format );
|
||||||
#define Q_vsprintf( buffer, format, args ) Q_vsnprintf( buffer, 99999, format, args )
|
#define Q_vsprintf( buffer, format, args ) Q_vsnprintf( buffer, 99999, format, args )
|
||||||
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args );
|
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user