2015-07-22 20:32:54 +02:00
|
|
|
|
#ifndef INCLUDE_STRING_H
|
|
|
|
|
#define INCLUDE_STRING_H
|
|
|
|
|
|
|
|
|
|
#ifndef INCLUDE_MEM_H
|
|
|
|
|
#include "../lib/mem.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
//------------------------------------------------------------------------------
|
2015-07-11 18:44:18 +02:00
|
|
|
|
// strspn(dword text1,text2) --- example: strspn("12 year","1234567890") -> return 2
|
|
|
|
|
// strpbrk(dword text1,text2) --- example: strpbrk("this test", " ckfi") -> return "is test"
|
2012-11-26 16:26:15 +01:00
|
|
|
|
// strcmp( ESI, EDI)
|
|
|
|
|
// strlen( EDI)
|
2015-08-10 17:59:20 +02:00
|
|
|
|
// utf8_strlen( ESI)
|
2012-12-15 01:16:06 +01:00
|
|
|
|
// strcpy( EDI, ESI) --- 0 if ==
|
2015-09-05 16:04:04 +02:00
|
|
|
|
// strlcpy(dword text1,text2,signed length)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
// strcat( EDI, ESI)
|
2020-03-23 16:53:56 +01:00
|
|
|
|
// chrcat(ESI, BL)
|
2015-07-11 18:01:28 +02:00
|
|
|
|
// strncat(dword text1,text2,signed length) --- pasting the text of a certain length
|
2013-03-11 19:16:24 +01:00
|
|
|
|
// strchr( ESI,BL) --- find first BL
|
|
|
|
|
// strrchr( ESI,BL) --- find last BL
|
2012-11-26 16:26:15 +01:00
|
|
|
|
// strstr( EBX, EDX)
|
2015-07-11 18:01:28 +02:00
|
|
|
|
// itoa(signed long number) --- convert the number as a string
|
|
|
|
|
// atoi(dword text) --- convert a string as a number
|
2012-11-26 16:26:15 +01:00
|
|
|
|
// strupr( ESI)
|
2015-08-07 00:37:34 +02:00
|
|
|
|
// strlwr( ESI) --- Cyrillic symbols may not work
|
2012-11-26 16:26:15 +01:00
|
|
|
|
// strttl( EDX)
|
|
|
|
|
// strtok( ESI)
|
2015-07-11 18:01:28 +02:00
|
|
|
|
// strltrim(dword text) --- removes "blank" characters on the left (\r, \n and space)
|
|
|
|
|
// strrtrim(dword text) --- removes "blank" characters on the right (\r, \n and space)
|
|
|
|
|
// strtrim(dword text) --- delete "empty" characters (\ r \ n and space) on both sides
|
2013-04-04 19:07:38 +02:00
|
|
|
|
// chrnum(dword searchin, char symbol)
|
2012-12-15 01:16:06 +01:00
|
|
|
|
// strcpyb(dword searchin, copyin, startstr, endstr) --- copy string between strings
|
2012-12-19 18:37:24 +01:00
|
|
|
|
// strnumb(dword searchin, startstr, endstr) --- get number between strings
|
2015-07-11 18:01:28 +02:00
|
|
|
|
// strdup(dword text) --- allocation under the text
|
2012-11-26 16:26:15 +01:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
2015-07-11 18:01:28 +02:00
|
|
|
|
/*
|
2012-11-26 16:26:15 +01:00
|
|
|
|
inline fastcall signed int strcmp( ESI, EDI)
|
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
IF (DSBYTE[ESI]<DSBYTE[EDI]) RETURN -1;
|
|
|
|
|
IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
|
|
|
|
|
IF (DSBYTE[ESI]=='\0') RETURN 0;
|
|
|
|
|
ESI++;
|
|
|
|
|
EDI++;
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
2015-07-11 18:01:28 +02:00
|
|
|
|
*/
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2015-07-22 20:32:54 +02:00
|
|
|
|
|
|
|
|
|
|
2015-07-12 01:45:19 +02:00
|
|
|
|
inline int strspn(dword text1,text2)
|
2015-07-11 18:44:18 +02:00
|
|
|
|
{
|
|
|
|
|
dword beg;
|
|
|
|
|
char s1,s2;
|
|
|
|
|
int ret;
|
|
|
|
|
ret = 0;
|
|
|
|
|
beg = text2;
|
|
|
|
|
do {
|
|
|
|
|
s1 = ESBYTE[text1];
|
|
|
|
|
text2 = beg;
|
|
|
|
|
do {
|
|
|
|
|
s2 = ESBYTE[text2];
|
|
|
|
|
if(s1==s2)
|
|
|
|
|
{
|
|
|
|
|
if(!s2)break;
|
|
|
|
|
$inc ret
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else $inc text2
|
|
|
|
|
} while(s2);
|
|
|
|
|
$inc text1
|
|
|
|
|
} while(s1);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-12 01:45:19 +02:00
|
|
|
|
inline dword strpbrk(dword text1,text2)
|
2015-07-11 18:44:18 +02:00
|
|
|
|
{
|
|
|
|
|
char s,ss;
|
|
|
|
|
dword beg;
|
|
|
|
|
beg = text2;
|
|
|
|
|
do {
|
|
|
|
|
s = ESBYTE[text1];
|
|
|
|
|
text2 = beg;
|
|
|
|
|
do {
|
|
|
|
|
ss = ESBYTE[text2];
|
|
|
|
|
if(ss==s) return text1;
|
|
|
|
|
$inc text2
|
|
|
|
|
} while(ss);
|
|
|
|
|
$inc text1
|
|
|
|
|
} while(s);
|
|
|
|
|
return text1;
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
inline fastcall signed int strncmp( ESI, EDI, ECX)
|
|
|
|
|
{
|
|
|
|
|
asm {
|
|
|
|
|
MOV EBX, EDI
|
|
|
|
|
XOR EAX, EAX
|
|
|
|
|
MOV EDX, ECX
|
|
|
|
|
OR ECX, ECX
|
|
|
|
|
JE L1
|
|
|
|
|
REPNE SCASB
|
|
|
|
|
SUB EDX, ECX
|
|
|
|
|
MOV ECX, EDX
|
|
|
|
|
MOV EDI, EBX
|
|
|
|
|
XOR EBX, EBX
|
|
|
|
|
REPE CMPSB
|
|
|
|
|
MOV AL, DSBYTE[ ESI-1]
|
|
|
|
|
MOV BL, DSBYTE[ EDI-1]
|
|
|
|
|
SUB EAX, EBX
|
|
|
|
|
L1:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-29 12:57:14 +02:00
|
|
|
|
/*
|
|
|
|
|
signed int strncmp(dword s1, s2, signed n)
|
|
|
|
|
unsigned char _s1,_s2;
|
|
|
|
|
{
|
|
|
|
|
if (n == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
do {
|
|
|
|
|
_s1 = DSBYTE[s1];
|
|
|
|
|
_s2 = DSBYTE[s2];
|
|
|
|
|
if (_s1 != _s2)
|
|
|
|
|
{
|
|
|
|
|
$dec s2
|
|
|
|
|
return _s1 - _s2;
|
|
|
|
|
}
|
|
|
|
|
$inc s2
|
|
|
|
|
if (_s1 == 0)
|
|
|
|
|
break;
|
|
|
|
|
$inc s1
|
|
|
|
|
$dec n
|
|
|
|
|
} while (n);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2015-07-23 13:54:26 +02:00
|
|
|
|
/*
|
|
|
|
|
inline signed int strncmp(dword text1,text2,len)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
if(DSBYTE[text1]!=DSBYTE[text2])return text1-text2;
|
|
|
|
|
$dec len
|
|
|
|
|
if(!len)return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
2012-11-26 16:26:15 +01:00
|
|
|
|
inline fastcall unsigned int strlen( EDI)
|
|
|
|
|
{
|
2018-10-29 12:39:31 +01:00
|
|
|
|
$xor eax, eax
|
|
|
|
|
$mov ecx, -1
|
|
|
|
|
$REPNE $SCASB
|
|
|
|
|
EAX-=2+ECX;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-29 12:57:14 +02:00
|
|
|
|
inline dword strnlen(dword str, dword maxlen)
|
2015-07-12 01:45:19 +02:00
|
|
|
|
{
|
|
|
|
|
dword cp;
|
|
|
|
|
for (cp = str; (maxlen != 0) && (DSBYTE[cp] != '\0'); cp++, maxlen--);
|
|
|
|
|
return cp - str;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-10 17:59:20 +02:00
|
|
|
|
inline fastcall unsigned int utf8_strlen( ESI)
|
|
|
|
|
{
|
|
|
|
|
$xor ecx, ecx
|
|
|
|
|
_loop:
|
|
|
|
|
$lodsb
|
|
|
|
|
$test al, al
|
|
|
|
|
$jz _done
|
|
|
|
|
$and al, 0xc0
|
|
|
|
|
$cmp al, 0x80
|
|
|
|
|
$jz _loop
|
|
|
|
|
$inc ecx
|
|
|
|
|
$jmp _loop
|
|
|
|
|
|
|
|
|
|
_done:
|
|
|
|
|
return ECX;
|
|
|
|
|
}
|
2015-07-11 18:01:28 +02:00
|
|
|
|
|
2015-07-12 01:45:19 +02:00
|
|
|
|
inline signed int strcmp(dword text1, text2)
|
2015-07-11 18:01:28 +02:00
|
|
|
|
{
|
|
|
|
|
char s1,s2;
|
|
|
|
|
dword p1,p2;
|
|
|
|
|
p1 = text1;
|
|
|
|
|
p2 = text2;
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
s1 = DSBYTE[text1];
|
|
|
|
|
s2 = DSBYTE[text2];
|
|
|
|
|
if(s1==s2)
|
|
|
|
|
{
|
|
|
|
|
if(s1==0) return 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-07-11 18:44:18 +02:00
|
|
|
|
return s1-s2;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
}
|
|
|
|
|
$inc text1
|
|
|
|
|
$inc text2
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 14:04:44 +02:00
|
|
|
|
|
|
|
|
|
inline fastcall streq(ESI, EDI)
|
|
|
|
|
{
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
if(DSBYTE[ESI]==DSBYTE[EDI])
|
|
|
|
|
{
|
|
|
|
|
if(DSBYTE[ESI]==0) return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
ESI++;
|
|
|
|
|
EDI++;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2016-01-15 00:05:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-11 19:16:24 +01:00
|
|
|
|
inline fastcall void strcpy( EDI, ESI)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$cld
|
2012-12-15 01:16:06 +01:00
|
|
|
|
L2:
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$lodsb
|
|
|
|
|
$stosb
|
|
|
|
|
$test al,al
|
|
|
|
|
$jnz L2
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-19 18:37:24 +01:00
|
|
|
|
inline fastcall int strlcpy(dword ESI, EDI, EBX)
|
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
if (EBX<0) return -1;
|
|
|
|
|
EDX=0;
|
|
|
|
|
do {
|
|
|
|
|
DSBYTE[ESI]=DSBYTE[EDI];
|
|
|
|
|
ESI++;
|
|
|
|
|
EDI++;
|
|
|
|
|
EDX++;
|
|
|
|
|
if (EDX==EBX) { DSBYTE[ESI]='\0'; return -1;}
|
|
|
|
|
} while(DSBYTE[EDI-1]!='\0');
|
|
|
|
|
return 0;
|
2012-12-19 18:37:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
|
:void strncpy(dword dst, src, len)
|
|
|
|
|
{
|
2020-03-30 23:29:52 +02:00
|
|
|
|
while (len) && (ESBYTE[src])
|
2017-10-05 00:59:57 +02:00
|
|
|
|
{
|
|
|
|
|
ESBYTE[dst] = ESBYTE[src];
|
|
|
|
|
dst++;
|
|
|
|
|
src++;
|
|
|
|
|
len--;
|
|
|
|
|
}
|
|
|
|
|
ESBYTE[dst]=0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-11 18:01:28 +02:00
|
|
|
|
/*
|
|
|
|
|
inline fastcall void strtrim( ESI)
|
2013-04-05 07:35:28 +02:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
EDI = ESI;
|
|
|
|
|
do{
|
|
|
|
|
AL=DSBYTE[EDI];
|
|
|
|
|
if (AL != '\32') && (AL != '\13') && (AL != '\10')
|
|
|
|
|
{
|
|
|
|
|
DSBYTE[ESI]=AL;
|
|
|
|
|
$inc ESI
|
|
|
|
|
}
|
|
|
|
|
$inc EDI
|
|
|
|
|
}while(AL!=0);
|
|
|
|
|
DSBYTE[ESI] = '\0';
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2015-07-20 01:09:56 +02:00
|
|
|
|
inline byte __isWhite(int s){ if (s==13)||(s==32)||(s==10)||(s==9) return true; return false; }
|
2015-07-12 01:45:19 +02:00
|
|
|
|
inline void strltrim(dword text){
|
2015-07-11 18:01:28 +02:00
|
|
|
|
int s;
|
|
|
|
|
dword back_text;
|
|
|
|
|
back_text = text;
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
while(__isWhite(s))
|
|
|
|
|
{
|
|
|
|
|
$inc text
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
}
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
ESBYTE[back_text] = s;
|
|
|
|
|
$inc back_text
|
|
|
|
|
if(!s) break;
|
|
|
|
|
$inc text
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-12 01:45:19 +02:00
|
|
|
|
inline void strrtrim(dword text)
|
2015-07-11 18:01:28 +02:00
|
|
|
|
{
|
|
|
|
|
int s;
|
|
|
|
|
dword p;
|
|
|
|
|
do {
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
if(__isWhite(s))
|
2013-04-05 07:35:28 +02:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
p = text;
|
|
|
|
|
while(__isWhite(s))
|
|
|
|
|
{
|
|
|
|
|
$inc text;
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
}
|
2013-04-05 07:35:28 +02:00
|
|
|
|
}
|
2015-07-11 18:01:28 +02:00
|
|
|
|
else $inc text
|
|
|
|
|
} while(s);
|
|
|
|
|
$dec text
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
if(__isWhite(s)) ESBYTE[p] = 0;
|
2013-04-05 07:35:28 +02:00
|
|
|
|
}
|
2012-12-19 18:37:24 +01:00
|
|
|
|
|
2015-07-12 01:45:19 +02:00
|
|
|
|
inline void strtrim(dword text){
|
2015-07-11 18:01:28 +02:00
|
|
|
|
int s;
|
|
|
|
|
dword p,back_text;
|
|
|
|
|
back_text = text;
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
while(__isWhite(s))
|
|
|
|
|
{
|
|
|
|
|
$inc text
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
}
|
|
|
|
|
do {
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
if(__isWhite(s))
|
|
|
|
|
{
|
|
|
|
|
p = back_text;
|
|
|
|
|
while(__isWhite(s))
|
|
|
|
|
{
|
|
|
|
|
ESBYTE[back_text] = s;
|
|
|
|
|
$inc back_text
|
|
|
|
|
$inc text;
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ESBYTE[back_text] = s;
|
|
|
|
|
$inc back_text
|
|
|
|
|
$inc text
|
|
|
|
|
}
|
|
|
|
|
} while(s);
|
|
|
|
|
$dec text
|
|
|
|
|
s = ESBYTE[text];
|
|
|
|
|
if(__isWhite(s)) ESBYTE[p] = 0;
|
|
|
|
|
}
|
2012-12-19 18:37:24 +01:00
|
|
|
|
|
2013-03-11 19:16:24 +01:00
|
|
|
|
inline fastcall void strcat( EDI, ESI)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
|
|
|
|
asm {
|
|
|
|
|
mov ebx, edi
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ecx
|
|
|
|
|
repne scasb
|
|
|
|
|
dec edi
|
|
|
|
|
mov edx, edi
|
|
|
|
|
mov edi, esi
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ecx
|
|
|
|
|
repne scasb
|
|
|
|
|
xor ecx, 0ffffffffh
|
|
|
|
|
mov edi, edx
|
|
|
|
|
mov edx, ecx
|
|
|
|
|
mov eax, edi
|
|
|
|
|
shr ecx, 2
|
|
|
|
|
rep movsd
|
|
|
|
|
mov ecx, edx
|
|
|
|
|
and ecx, 3
|
|
|
|
|
rep movsb
|
|
|
|
|
mov eax, ebx
|
2015-07-11 18:01:28 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-29 12:57:14 +02:00
|
|
|
|
:void strncat(dword dst, src, len)
|
2015-07-11 18:01:28 +02:00
|
|
|
|
{
|
2020-03-26 01:12:32 +01:00
|
|
|
|
while (ESBYTE[dst]) && (len) {
|
|
|
|
|
dst++;
|
|
|
|
|
len--;
|
|
|
|
|
}
|
2020-03-29 12:57:14 +02:00
|
|
|
|
while (ESBYTE[src]) && (len>1) {
|
2020-03-25 01:18:19 +01:00
|
|
|
|
ESBYTE[dst] = ESBYTE[src];
|
|
|
|
|
dst++;
|
|
|
|
|
src++;
|
|
|
|
|
len--;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
2020-03-26 01:12:32 +01:00
|
|
|
|
ESBYTE[dst] = 0;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-29 12:57:14 +02:00
|
|
|
|
:void chrncat(dword dst, unsigned char s, dword len)
|
|
|
|
|
{
|
|
|
|
|
while (ESBYTE[dst]) && (len) {
|
|
|
|
|
dst++;
|
|
|
|
|
len--;
|
|
|
|
|
}
|
|
|
|
|
if (len>1) {
|
|
|
|
|
ESBYTE[dst] = s;
|
|
|
|
|
ESBYTE[dst+1] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-25 01:18:19 +01:00
|
|
|
|
inline fastcall void chrcat(ESI, DI)
|
2013-03-11 19:16:24 +01:00
|
|
|
|
{
|
2020-03-25 01:18:19 +01:00
|
|
|
|
while (ESBYTE[ESI]) ESI++;
|
|
|
|
|
ESBYTE[ESI] = DI;
|
|
|
|
|
ESI++;
|
|
|
|
|
ESBYTE[ESI] = 0;
|
2013-03-11 19:16:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-22 20:32:54 +02:00
|
|
|
|
inline dword strchr(dword shb;char s)
|
|
|
|
|
{
|
|
|
|
|
char ss;
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
ss = DSBYTE[shb];
|
|
|
|
|
if(!ss)return 0;
|
|
|
|
|
if(ss==s)return shb;
|
|
|
|
|
shb++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-12-19 18:37:24 +01:00
|
|
|
|
|
|
|
|
|
inline fastcall signed int strrchr( ESI,BL)
|
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
int jj=0, last=0;
|
|
|
|
|
do{
|
|
|
|
|
jj++;
|
|
|
|
|
$lodsb
|
|
|
|
|
IF(AL==BL) last=jj;
|
|
|
|
|
} while(AL!=0);
|
|
|
|
|
return last;
|
2012-12-19 18:37:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-11-23 11:04:07 +01:00
|
|
|
|
inline fastcall unsigned int chrnum( ESI, BL)
|
2012-12-19 18:37:24 +01:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
int num = 0;
|
2016-11-23 11:04:07 +01:00
|
|
|
|
while(DSBYTE[ESI])
|
2015-07-11 18:01:28 +02:00
|
|
|
|
{
|
2016-11-23 11:04:07 +01:00
|
|
|
|
if (DSBYTE[ESI] == BL) num++;
|
|
|
|
|
ESI++;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
}
|
|
|
|
|
return num;
|
2012-12-19 18:37:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-03-11 19:16:24 +01:00
|
|
|
|
inline fastcall signed int strstr( EBX, EDX)
|
2012-12-19 18:37:24 +01:00
|
|
|
|
{
|
|
|
|
|
asm {
|
|
|
|
|
MOV EDI, EDX
|
|
|
|
|
XOR ECX, ECX
|
|
|
|
|
XOR EAX, EAX
|
|
|
|
|
DEC ECX
|
|
|
|
|
REPNE SCASB
|
|
|
|
|
NOT ECX
|
|
|
|
|
DEC ECX
|
|
|
|
|
JE LS2
|
|
|
|
|
MOV ESI, ECX
|
|
|
|
|
XOR ECX, ECX
|
|
|
|
|
MOV EDI, EBX
|
|
|
|
|
DEC ECX
|
|
|
|
|
REPNE SCASB
|
|
|
|
|
NOT ECX
|
|
|
|
|
SUB ECX, ESI
|
|
|
|
|
JBE LS2
|
|
|
|
|
MOV EDI, EBX
|
|
|
|
|
LEA EBX, DSDWORD[ ESI-1]
|
|
|
|
|
LS1: MOV ESI, EDX
|
|
|
|
|
LODSB
|
|
|
|
|
REPNE SCASB
|
|
|
|
|
JNE LS2
|
|
|
|
|
MOV EAX, ECX
|
|
|
|
|
PUSH EDI
|
|
|
|
|
MOV ECX, EBX
|
|
|
|
|
REPE CMPSB
|
|
|
|
|
POP EDI
|
|
|
|
|
MOV ECX, EAX
|
|
|
|
|
JNE LS1
|
|
|
|
|
LEA EAX, DSDWORD[ EDI-1]
|
|
|
|
|
JMP SHORT LS3
|
|
|
|
|
LS2: XOR EAX, EAX
|
|
|
|
|
LS3:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 22:10:07 +02:00
|
|
|
|
inline int strnum(dword haystack, needle)
|
|
|
|
|
{
|
|
|
|
|
int count = 0;
|
|
|
|
|
int needle_len = strlen(needle);
|
|
|
|
|
loop() {
|
|
|
|
|
if (! haystack = strstr(haystack, needle)) break;
|
|
|
|
|
haystack+=needle_len;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 12:03:45 +02:00
|
|
|
|
inline int strinum(dword haystack, needle)
|
|
|
|
|
{
|
|
|
|
|
int count = 0;
|
|
|
|
|
int needle_len = strlen(needle);
|
|
|
|
|
loop() {
|
|
|
|
|
if (! haystack = strstri(haystack, needle)) break;
|
|
|
|
|
haystack+=needle_len;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-06 17:53:34 +02:00
|
|
|
|
inline signed int strcmpi(dword cmp1, cmp2)
|
2013-11-14 01:39:19 +01:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
char si, ue;
|
|
|
|
|
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
si = DSBYTE[cmp1];
|
|
|
|
|
ue = DSBYTE[cmp2];
|
|
|
|
|
if (si>='A') && (si<='Z') si +=32;
|
|
|
|
|
if (ue>='A') && (ue<='Z') ue +=32;
|
2020-05-06 17:53:34 +02:00
|
|
|
|
if (si != ue) return si-ue;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
cmp1++;
|
|
|
|
|
cmp2++;
|
|
|
|
|
if ((DSBYTE[cmp1]=='\0') && (DSBYTE[cmp2]=='\0')) return 0;
|
|
|
|
|
if (DSBYTE[cmp1]=='\0') return -1;
|
|
|
|
|
if (DSBYTE[cmp2]=='\0') return 1;
|
|
|
|
|
}
|
2013-11-14 01:39:19 +01:00
|
|
|
|
}
|
2012-12-19 18:37:24 +01:00
|
|
|
|
|
2015-07-20 01:09:56 +02:00
|
|
|
|
inline dword strstri(dword searchin, usestr_s)
|
2012-12-19 18:37:24 +01:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
dword usestr_e = usestr_s;
|
|
|
|
|
char si, ue;
|
|
|
|
|
|
|
|
|
|
while(DSBYTE[searchin])
|
|
|
|
|
{
|
|
|
|
|
si = DSBYTE[searchin];
|
|
|
|
|
ue = DSBYTE[usestr_e];
|
|
|
|
|
if (si>='A') && (si<='Z') si +=32;
|
|
|
|
|
if (ue>='A') && (ue<='Z') ue +=32;
|
|
|
|
|
if (si == ue) usestr_e++; else usestr_e = usestr_s;
|
|
|
|
|
searchin++;
|
|
|
|
|
if (DSBYTE[usestr_e]=='\0') return searchin;
|
|
|
|
|
}
|
2020-05-18 12:03:45 +02:00
|
|
|
|
return 0;
|
2012-12-19 18:37:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-07-20 01:09:56 +02:00
|
|
|
|
inline unsigned int strcpyb(dword search_in, copyin, startstr, endstr)
|
2012-12-19 18:37:24 +01:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
dword startp, endp;
|
|
|
|
|
dword copyin_start_off = copyin;
|
|
|
|
|
if (startstr==0) startp = search_in; else startp = strstr(search_in, startstr) + strlen(startstr);
|
2020-05-18 12:03:45 +02:00
|
|
|
|
if (! endp = strstri(startp, endstr)) endp = startp+strlen(search_in);
|
2015-07-11 18:01:28 +02:00
|
|
|
|
//if (startp==endp) return 0;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
DSBYTE[copyin] = DSBYTE[startp];
|
|
|
|
|
copyin++;
|
|
|
|
|
startp++;
|
|
|
|
|
}
|
|
|
|
|
while (startp<endp);
|
|
|
|
|
DSBYTE[copyin] = '\0';
|
|
|
|
|
return copyin_start_off;
|
2012-12-19 18:37:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-02-18 21:49:48 +01:00
|
|
|
|
/*void strcat(char *to, char *from)
|
2012-12-06 08:49:06 +01:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
while(*to) to++;
|
|
|
|
|
while(*from)
|
|
|
|
|
{
|
|
|
|
|
*to = *from;
|
|
|
|
|
to++;
|
|
|
|
|
from++;
|
|
|
|
|
}
|
|
|
|
|
*to = '\0';
|
2012-12-06 08:49:06 +01:00
|
|
|
|
}*/
|
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
inline fastcall dword atoi( EDI)
|
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$push ebx
|
|
|
|
|
$push esi
|
|
|
|
|
ESI=EDI;
|
|
|
|
|
while (DSBYTE[ESI]==' ') ESI++;
|
|
|
|
|
if (DSBYTE[ESI]=='-') ESI++;
|
|
|
|
|
EAX=0;
|
|
|
|
|
while (DSBYTE[ESI]>='0') && (DSBYTE[ESI]<='9')
|
|
|
|
|
{
|
|
|
|
|
$xor ebx, ebx
|
|
|
|
|
EBX = DSBYTE[ESI]-'0';
|
|
|
|
|
EAX *= 10;
|
|
|
|
|
EAX += EBX;
|
|
|
|
|
ESI++;
|
|
|
|
|
}
|
|
|
|
|
IF (DSBYTE[EDI]=='-') -EAX;
|
|
|
|
|
$pop esi
|
|
|
|
|
$pop ebx
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall strupr( ESI)
|
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
do{
|
|
|
|
|
AL=DSBYTE[ESI];
|
|
|
|
|
IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f;
|
|
|
|
|
IF (AL>=160) && (AL<=175) DSBYTE[ESI] = AL - 32; //<2F>-<2D>
|
|
|
|
|
IF (AL>=224) && (AL<=239) DSBYTE[ESI] = AL - 80; //<2F>-<2D>
|
|
|
|
|
ESI++;
|
|
|
|
|
}while(AL!=0);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline fastcall strlwr( ESI)
|
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
do{
|
|
|
|
|
$LODSB
|
|
|
|
|
IF(AL>='A')&&(AL<='Z'){
|
|
|
|
|
AL+=0x20;
|
|
|
|
|
DSBYTE[ESI-1]=AL;
|
|
|
|
|
CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
}while(AL!=0);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline fastcall strttl( EDX)
|
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
AL=DSBYTE[EDX];
|
|
|
|
|
IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
|
|
|
|
|
IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32; //<2F>-<2D>
|
|
|
|
|
IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80; //<2F>-<2D>
|
|
|
|
|
do{
|
|
|
|
|
EDX++;
|
|
|
|
|
AL=DSBYTE[EDX];
|
|
|
|
|
IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
|
|
|
|
|
IF(AL>='<EFBFBD>')&&(AL<='<EFBFBD>')DSBYTE[EDX]=AL|0x20; //<2F>-<2D>
|
|
|
|
|
IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80; //<2F>-<2D>
|
|
|
|
|
}while(AL!=0);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-11 18:01:28 +02:00
|
|
|
|
/*
|
2013-11-05 00:27:39 +01:00
|
|
|
|
dword itoa( ESI)
|
|
|
|
|
{
|
2014-03-13 01:31:31 +01:00
|
|
|
|
unsigned char buffer[11];
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$pusha
|
|
|
|
|
EDI = #buffer;
|
|
|
|
|
ECX = 10;
|
|
|
|
|
if (ESI < 0)
|
|
|
|
|
{
|
|
|
|
|
$mov al, '-'
|
|
|
|
|
$stosb
|
|
|
|
|
$neg esi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mov eax, esi
|
|
|
|
|
$push -'0'
|
2013-11-05 00:27:39 +01:00
|
|
|
|
F2:
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$xor edx, edx
|
|
|
|
|
$div ecx
|
|
|
|
|
$push edx
|
|
|
|
|
$test eax, eax
|
|
|
|
|
$jnz F2
|
2013-11-05 00:27:39 +01:00
|
|
|
|
F3:
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$pop eax
|
|
|
|
|
$add al, '0'
|
|
|
|
|
$stosb
|
|
|
|
|
$jnz F3
|
|
|
|
|
|
|
|
|
|
$mov al, '\0'
|
|
|
|
|
$stosb
|
|
|
|
|
|
|
|
|
|
$popa
|
2013-11-05 00:27:39 +01:00
|
|
|
|
return #buffer;
|
|
|
|
|
}
|
2015-07-11 18:01:28 +02:00
|
|
|
|
*/
|
2015-07-21 03:10:37 +02:00
|
|
|
|
:unsigned char BUF_ITOA[11];
|
2015-07-12 01:45:19 +02:00
|
|
|
|
inline dword itoa(signed long number)
|
2013-11-05 00:27:39 +01:00
|
|
|
|
{
|
2015-07-16 03:44:30 +02:00
|
|
|
|
dword ret,p;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
byte cmd;
|
|
|
|
|
long mask,tmp;
|
|
|
|
|
mask = 1000000000;
|
|
|
|
|
cmd = true;
|
2015-07-21 03:10:37 +02:00
|
|
|
|
p = #BUF_ITOA;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
if(!number){
|
2015-07-16 03:44:30 +02:00
|
|
|
|
ESBYTE[p] = '0';
|
|
|
|
|
ESBYTE[p+1] = 0;
|
|
|
|
|
return p;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
}
|
2015-07-16 03:44:30 +02:00
|
|
|
|
ret = p;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
if(number<0)
|
2013-11-05 00:27:39 +01:00
|
|
|
|
{
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$neg number
|
2015-07-16 03:44:30 +02:00
|
|
|
|
ESBYTE[p] = '-';
|
|
|
|
|
$inc p
|
2013-11-05 00:27:39 +01:00
|
|
|
|
}
|
2015-07-11 18:01:28 +02:00
|
|
|
|
while(mask)
|
|
|
|
|
{
|
|
|
|
|
tmp = number / mask;
|
|
|
|
|
tmp = tmp%10;
|
|
|
|
|
|
|
|
|
|
if(cmd){
|
|
|
|
|
if(tmp){
|
2015-07-16 03:44:30 +02:00
|
|
|
|
ESBYTE[p] = tmp + '0';
|
|
|
|
|
$inc p
|
2015-07-11 18:01:28 +02:00
|
|
|
|
cmd = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-07-16 03:44:30 +02:00
|
|
|
|
ESBYTE[p] = tmp + '0';
|
|
|
|
|
$inc p
|
2015-07-11 18:01:28 +02:00
|
|
|
|
}
|
|
|
|
|
mask /= 10;
|
|
|
|
|
}
|
2015-07-16 03:44:30 +02:00
|
|
|
|
ESBYTE[p] = 0;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
2015-07-16 03:44:30 +02:00
|
|
|
|
|
2015-07-20 01:09:56 +02:00
|
|
|
|
inline fastcall itoa_(signed int EDI, ESI)
|
2015-07-11 18:01:28 +02:00
|
|
|
|
{
|
|
|
|
|
$pusha
|
|
|
|
|
EBX = EDI;
|
|
|
|
|
ECX = 10;
|
|
|
|
|
if (ESI > 90073741824)
|
|
|
|
|
{
|
|
|
|
|
$mov al, '-'
|
|
|
|
|
$stosb
|
|
|
|
|
$neg esi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mov eax, esi
|
|
|
|
|
$push -'0'
|
2013-11-05 00:27:39 +01:00
|
|
|
|
F2:
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$xor edx, edx
|
|
|
|
|
$div ecx
|
|
|
|
|
$push edx
|
|
|
|
|
$test eax, eax
|
|
|
|
|
$jnz F2
|
2013-11-05 00:27:39 +01:00
|
|
|
|
F3:
|
2015-07-11 18:01:28 +02:00
|
|
|
|
$pop eax
|
|
|
|
|
$add al, '0'
|
|
|
|
|
$stosb
|
|
|
|
|
$jnz F3
|
|
|
|
|
|
|
|
|
|
$mov al, '\0'
|
|
|
|
|
$stosb
|
|
|
|
|
|
|
|
|
|
$popa
|
2013-11-05 00:27:39 +01:00
|
|
|
|
return EBX;
|
2015-07-11 18:01:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 01:09:56 +02:00
|
|
|
|
inline dword memchr(dword s,int c,signed len)
|
2015-07-16 03:44:30 +02:00
|
|
|
|
{
|
|
|
|
|
if(!len) return NULL;
|
|
|
|
|
do {
|
|
|
|
|
if(DSBYTE[s] == c) return s;
|
|
|
|
|
$inc s
|
|
|
|
|
$dec len
|
|
|
|
|
} while(len);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 01:09:56 +02:00
|
|
|
|
inline dword strdup(dword text)
|
2015-07-11 18:01:28 +02:00
|
|
|
|
{
|
|
|
|
|
dword l = strlen(text);
|
|
|
|
|
dword ret = malloc(l+1);
|
2015-07-16 03:44:30 +02:00
|
|
|
|
if(!ret) return NULL;
|
2015-09-05 16:04:04 +02:00
|
|
|
|
strlcpy(ret,text,l);
|
2015-07-11 18:01:28 +02:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
2013-11-05 00:27:39 +01:00
|
|
|
|
|
2015-07-20 01:09:56 +02:00
|
|
|
|
inline dword strndup(dword str, signed maxlen)
|
2015-07-12 01:45:19 +02:00
|
|
|
|
{
|
|
|
|
|
dword copy,len;
|
|
|
|
|
|
|
|
|
|
len = strnlen(str, maxlen);
|
|
|
|
|
copy = malloc(len + 1);
|
|
|
|
|
if (copy != NULL)
|
|
|
|
|
{
|
2015-09-05 16:04:04 +02:00
|
|
|
|
strlcpy(copy, str, len);
|
2015-07-12 01:45:19 +02:00
|
|
|
|
DSBYTE[len+copy] = '\0';
|
|
|
|
|
}
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 01:09:56 +02:00
|
|
|
|
inline dword hexdec(dword text)
|
|
|
|
|
{
|
|
|
|
|
char s;
|
|
|
|
|
dword ret,l;
|
|
|
|
|
ret = 0;
|
|
|
|
|
s = DSBYTE[text];
|
|
|
|
|
while(s)
|
|
|
|
|
{
|
|
|
|
|
ret <<= 4;
|
|
|
|
|
if(s>='A')&&(s<='F')ret |= s-'A'+10;
|
|
|
|
|
else if(s>='a')&&(s<='f')ret |= s-'a'+10;
|
2015-07-22 20:32:54 +02:00
|
|
|
|
else if(s>='0')&&(s<='9')ret |= s-'0';
|
2015-07-20 01:09:56 +02:00
|
|
|
|
text++;
|
|
|
|
|
s = DSBYTE[text];
|
|
|
|
|
}
|
2015-07-22 20:32:54 +02:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline signed csshexdec(dword text)
|
|
|
|
|
{
|
|
|
|
|
char s;
|
|
|
|
|
dword ret,l;
|
|
|
|
|
byte tmp;
|
|
|
|
|
l = strlen(text);
|
|
|
|
|
ret = 0;
|
|
|
|
|
s = DSBYTE[text];
|
|
|
|
|
tmp = 0;
|
|
|
|
|
if(l==6) while(s)
|
2015-07-20 01:09:56 +02:00
|
|
|
|
{
|
|
|
|
|
ret <<= 4;
|
|
|
|
|
if(s>='A')&&(s<='F')ret |= s-'A'+10;
|
|
|
|
|
else if(s>='a')&&(s<='f')ret |= s-'a'+10;
|
2015-07-22 20:32:54 +02:00
|
|
|
|
else if(s>='0')&&(s<='9')ret |= s-'0';
|
2015-07-20 01:09:56 +02:00
|
|
|
|
text++;
|
|
|
|
|
s = DSBYTE[text];
|
2015-07-22 20:32:54 +02:00
|
|
|
|
}
|
|
|
|
|
else if(l==3) while(s)
|
|
|
|
|
{
|
|
|
|
|
ret |= tmp;
|
|
|
|
|
ret <<= 4;
|
|
|
|
|
ret |= tmp;
|
|
|
|
|
ret <<= 4;
|
|
|
|
|
if(s>='A')&&(s<='F')tmp = s-'A'+10;
|
|
|
|
|
else if(s>='a')&&(s<='f')tmp = s-'a'+10;
|
|
|
|
|
else if(s>='0')&&(s<='9')tmp = s-'0';
|
|
|
|
|
text++;
|
|
|
|
|
s = DSBYTE[text];
|
|
|
|
|
}
|
2015-07-20 01:09:56 +02:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-06 11:33:56 +02:00
|
|
|
|
inline cdecl int sprintf(dword buf, format,...)
|
2015-07-16 03:44:30 +02:00
|
|
|
|
{
|
2018-10-06 11:33:56 +02:00
|
|
|
|
#define END_ARGS 0xFF00FF //ARGS FUNCTION
|
2015-07-16 03:44:30 +02:00
|
|
|
|
byte s;
|
2018-10-06 11:33:56 +02:00
|
|
|
|
char X[10];
|
2015-07-16 03:44:30 +02:00
|
|
|
|
dword ret, tmp, l;
|
|
|
|
|
dword arg = #format;
|
|
|
|
|
ret = buf;
|
|
|
|
|
s = DSBYTE[format];
|
2018-10-06 11:33:56 +02:00
|
|
|
|
while(s){
|
|
|
|
|
if(s=='%'){
|
|
|
|
|
arg+=4;
|
2015-07-16 03:44:30 +02:00
|
|
|
|
tmp = DSDWORD[arg];
|
2018-10-06 11:33:56 +02:00
|
|
|
|
if(tmp==END_ARGS)goto END_FUNC_SPRINTF;
|
|
|
|
|
$inc format
|
2015-07-16 03:44:30 +02:00
|
|
|
|
s = DSBYTE[format];
|
2018-10-06 11:33:56 +02:00
|
|
|
|
if(!s)goto END_FUNC_SPRINTF;
|
2015-07-16 03:44:30 +02:00
|
|
|
|
switch(s)
|
|
|
|
|
{
|
|
|
|
|
case 's':
|
|
|
|
|
l = tmp;
|
2018-10-06 11:33:56 +02:00
|
|
|
|
s = DSBYTE[tmp];
|
|
|
|
|
while(s)
|
2015-07-16 03:44:30 +02:00
|
|
|
|
{
|
2018-10-06 11:33:56 +02:00
|
|
|
|
DSBYTE[buf] = s;
|
|
|
|
|
$inc tmp
|
|
|
|
|
$inc buf
|
|
|
|
|
s = DSBYTE[tmp];
|
2015-07-16 03:44:30 +02:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'c':
|
|
|
|
|
DSBYTE[buf] = tmp;
|
2018-10-06 11:33:56 +02:00
|
|
|
|
$inc buf
|
2015-07-16 03:44:30 +02:00
|
|
|
|
break;
|
|
|
|
|
case 'u': //if(tmp<0)return ret;
|
|
|
|
|
case 'd':
|
|
|
|
|
case 'i':
|
|
|
|
|
tmp = itoa(tmp);
|
2018-10-06 11:33:56 +02:00
|
|
|
|
if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
|
2015-07-16 03:44:30 +02:00
|
|
|
|
l = strlen(tmp);
|
2015-08-02 13:41:41 +02:00
|
|
|
|
strlcpy(buf,tmp,l);
|
2015-07-16 03:44:30 +02:00
|
|
|
|
buf += l;
|
|
|
|
|
break;
|
|
|
|
|
case 'a':
|
|
|
|
|
case 'A':
|
2018-10-06 11:33:56 +02:00
|
|
|
|
strlcpy(buf,"0x00000000",10);
|
|
|
|
|
buf+=10;
|
|
|
|
|
l=buf;
|
|
|
|
|
while(tmp)
|
2015-07-16 03:44:30 +02:00
|
|
|
|
{
|
2018-10-06 11:33:56 +02:00
|
|
|
|
$dec buf
|
|
|
|
|
s=tmp&0xF;
|
|
|
|
|
if(s>9)DSBYTE[buf]='A'+s-10;
|
|
|
|
|
else DSBYTE[buf]='0'+s;
|
|
|
|
|
tmp>>=4;
|
2015-07-16 03:44:30 +02:00
|
|
|
|
}
|
2018-10-06 11:33:56 +02:00
|
|
|
|
buf=l;
|
2015-07-16 03:44:30 +02:00
|
|
|
|
break;
|
|
|
|
|
case 'p':
|
|
|
|
|
tmp = itoa(#tmp);
|
2018-10-06 11:33:56 +02:00
|
|
|
|
if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
|
2015-07-16 03:44:30 +02:00
|
|
|
|
l = strlen(tmp);
|
2015-08-02 13:41:41 +02:00
|
|
|
|
strlcpy(buf,tmp,l);
|
2015-07-16 03:44:30 +02:00
|
|
|
|
buf += l;
|
|
|
|
|
break;
|
|
|
|
|
case '%':
|
|
|
|
|
DSBYTE[buf] = '%';
|
2018-10-06 11:33:56 +02:00
|
|
|
|
$inc buf
|
2015-07-16 03:44:30 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-10-06 11:33:56 +02:00
|
|
|
|
goto END_FUNC_SPRINTF;
|
2015-07-16 03:44:30 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-06 11:33:56 +02:00
|
|
|
|
else {
|
2015-07-16 03:44:30 +02:00
|
|
|
|
DSBYTE[buf] = s;
|
2018-10-06 11:33:56 +02:00
|
|
|
|
$inc buf
|
2015-07-16 03:44:30 +02:00
|
|
|
|
}
|
2018-10-06 11:33:56 +02:00
|
|
|
|
$inc format
|
2015-07-16 03:44:30 +02:00
|
|
|
|
s = DSBYTE[format];
|
|
|
|
|
}
|
2018-10-06 11:33:56 +02:00
|
|
|
|
END_FUNC_SPRINTF:
|
2015-07-16 03:44:30 +02:00
|
|
|
|
DSBYTE[buf] = 0;
|
2016-11-30 17:41:21 +01:00
|
|
|
|
return ret;
|
2015-07-16 03:44:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-22 20:32:54 +02:00
|
|
|
|
inline signed strcoll(dword text1,text2)
|
|
|
|
|
{
|
|
|
|
|
char s,ss;
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
s = DSBYTE[text2];
|
|
|
|
|
ss=strchr(text1,s);
|
|
|
|
|
if(ss)return ss;
|
|
|
|
|
text2++;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-05 09:33:55 +02:00
|
|
|
|
// void * memset( ptr, value, num );
|
|
|
|
|
// fills the memory with a dword
|
|
|
|
|
// example: memset(str,'-', sizeof(str));
|
|
|
|
|
inline void MEMSETD(EDI,ECX,EAX)
|
|
|
|
|
{
|
|
|
|
|
$REP
|
|
|
|
|
$STOSD
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-18 16:32:11 +01:00
|
|
|
|
:replace_char(dword in_str, char from_char, to_char, int length) {
|
2020-05-05 01:50:41 +02:00
|
|
|
|
dword max = in_str + length;
|
|
|
|
|
while (in_str < max) {
|
|
|
|
|
if (ESBYTE[in_str] == from_char) ESBYTE[in_str] = to_char;
|
|
|
|
|
in_str++;
|
2017-10-05 00:59:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-22 20:32:54 +02:00
|
|
|
|
#endif
|