Subversion Repositories Kolibri OS

Rev

Rev 7506 | Rev 7750 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7506 Rev 7742
1
#ifndef INCLUDE_STRING_H
1
#ifndef INCLUDE_STRING_H
2
#define INCLUDE_STRING_H
2
#define INCLUDE_STRING_H
3
 
3
 
4
#ifndef INCLUDE_MEM_H
4
#ifndef INCLUDE_MEM_H
5
#include "../lib/mem.h"
5
#include "../lib/mem.h"
6
#endif
6
#endif
7
 
7
 
8
//------------------------------------------------------------------------------
8
//------------------------------------------------------------------------------
9
// strspn(dword text1,text2) --- example: strspn("12 year","1234567890") -> return 2
9
// strspn(dword text1,text2) --- example: strspn("12 year","1234567890") -> return 2
10
// strpbrk(dword text1,text2) --- example: strpbrk("this test", " ckfi") -> return "is test"
10
// strpbrk(dword text1,text2) --- example: strpbrk("this test", " ckfi") -> return "is test"
11
// strcmp( ESI, EDI)
11
// strcmp( ESI, EDI)
12
// strlen( EDI)
12
// strlen( EDI)
13
// utf8_strlen( ESI)
13
// utf8_strlen( ESI)
14
// strcpy( EDI, ESI) --- 0 if ==
14
// strcpy( EDI, ESI) --- 0 if ==
15
// strlcpy(dword text1,text2,signed length)
15
// strlcpy(dword text1,text2,signed length)
16
// strcat( EDI, ESI)
16
// strcat( EDI, ESI)
17
// strncat(dword text1,text2,signed length) --- pasting the text of a certain length
17
// strncat(dword text1,text2,signed length) --- pasting the text of a certain length
18
// strchr( ESI,BL) --- find first BL
18
// strchr( ESI,BL) --- find first BL
19
// strrchr( ESI,BL) --- find last BL
19
// strrchr( ESI,BL) --- find last BL
20
// strstr( EBX, EDX)
20
// strstr( EBX, EDX)
21
// itoa(signed long number) --- convert the number as a string
21
// itoa(signed long number) --- convert the number as a string
22
// atoi(dword text) --- convert a string as a number
22
// atoi(dword text) --- convert a string as a number
23
// strupr( ESI)
23
// strupr( ESI)
24
// strlwr( ESI) --- Cyrillic symbols may not work
24
// strlwr( ESI) --- Cyrillic symbols may not work
25
// strttl( EDX)
25
// strttl( EDX)
26
// strtok( ESI)
26
// strtok( ESI)
27
// strltrim(dword text) --- removes "blank" characters on the left (\r, \n and space)
27
// strltrim(dword text) --- removes "blank" characters on the left (\r, \n and space)
28
// strrtrim(dword text) --- removes "blank" characters on the right (\r, \n and space)
28
// strrtrim(dword text) --- removes "blank" characters on the right (\r, \n and space)
29
// strtrim(dword text) --- delete "empty" characters (\ r \ n and space) on both sides
29
// strtrim(dword text) --- delete "empty" characters (\ r \ n and space) on both sides
30
// chrnum(dword searchin, char symbol)
30
// chrnum(dword searchin, char symbol)
31
// strcpyb(dword searchin, copyin, startstr, endstr) --- copy string between strings
31
// strcpyb(dword searchin, copyin, startstr, endstr) --- copy string between strings
32
// strnumb(dword searchin, startstr, endstr) --- get number between strings
32
// strnumb(dword searchin, startstr, endstr) --- get number between strings
33
// strdup(dword text) --- allocation under the text
33
// strdup(dword text) --- allocation under the text
34
//------------------------------------------------------------------------------
34
//------------------------------------------------------------------------------
35
 
35
 
36
/*
36
/*
37
inline fastcall signed int strcmp( ESI, EDI)
37
inline fastcall signed int strcmp( ESI, EDI)
38
{
38
{
39
    loop()
39
    loop()
40
    {
40
    {
41
        IF (DSBYTE[ESI]
41
        IF (DSBYTE[ESI]
42
        IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
42
        IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
43
        IF (DSBYTE[ESI]=='\0') RETURN 0;
43
        IF (DSBYTE[ESI]=='\0') RETURN 0;
44
        ESI++;
44
        ESI++;
45
        EDI++;
45
        EDI++;
46
    }
46
    }
47
}
47
}
48
*/
48
*/
49
 
49
 
50
 
50
 
51
 
51
 
52
inline int strspn(dword text1,text2)
52
inline int strspn(dword text1,text2)
53
{
53
{
54
	dword beg;
54
	dword beg;
55
	char s1,s2;
55
	char s1,s2;
56
	int ret;
56
	int ret;
57
	ret = 0;
57
	ret = 0;
58
	beg = text2;
58
	beg = text2;
59
	do {
59
	do {
60
		s1 = ESBYTE[text1];
60
		s1 = ESBYTE[text1];
61
		text2 = beg;
61
		text2 = beg;
62
		do {
62
		do {
63
			s2 = ESBYTE[text2];
63
			s2 = ESBYTE[text2];
64
			if(s1==s2)
64
			if(s1==s2)
65
			{
65
			{
66
				if(!s2)break;
66
				if(!s2)break;
67
				$inc ret
67
				$inc ret
68
				break;
68
				break;
69
			}
69
			}
70
			else $inc text2
70
			else $inc text2
71
		} while(s2);
71
		} while(s2);
72
		$inc text1
72
		$inc text1
73
	} while(s1);
73
	} while(s1);
74
	return ret;
74
	return ret;
75
}
75
}
76
 
76
 
77
inline dword strpbrk(dword text1,text2)
77
inline dword strpbrk(dword text1,text2)
78
{
78
{
79
	char s,ss;
79
	char s,ss;
80
	dword beg;
80
	dword beg;
81
	beg = text2;
81
	beg = text2;
82
	do {
82
	do {
83
		s = ESBYTE[text1];
83
		s = ESBYTE[text1];
84
		text2 = beg;
84
		text2 = beg;
85
		do {
85
		do {
86
			ss = ESBYTE[text2];
86
			ss = ESBYTE[text2];
87
			if(ss==s) return text1;
87
			if(ss==s) return text1;
88
			$inc text2
88
			$inc text2
89
		} while(ss);
89
		} while(ss);
90
		$inc text1
90
		$inc text1
91
	} while(s);
91
	} while(s);
92
	return text1;
92
	return text1;
93
}
93
}
94
 
94
 
95
inline fastcall signed int strncmp( ESI, EDI, ECX)
95
inline fastcall signed int strncmp( ESI, EDI, ECX)
96
{
96
{
97
  asm {
97
  asm {
98
    MOV EBX, EDI
98
    MOV EBX, EDI
99
    XOR EAX, EAX
99
    XOR EAX, EAX
100
    MOV EDX, ECX
100
    MOV EDX, ECX
101
    OR ECX, ECX
101
    OR ECX, ECX
102
    JE L1
102
    JE L1
103
    REPNE SCASB
103
    REPNE SCASB
104
    SUB EDX, ECX
104
    SUB EDX, ECX
105
    MOV ECX, EDX
105
    MOV ECX, EDX
106
    MOV EDI, EBX
106
    MOV EDI, EBX
107
    XOR EBX, EBX
107
    XOR EBX, EBX
108
    REPE CMPSB
108
    REPE CMPSB
109
    MOV AL, DSBYTE[ ESI-1]
109
    MOV AL, DSBYTE[ ESI-1]
110
    MOV BL, DSBYTE[ EDI-1]
110
    MOV BL, DSBYTE[ EDI-1]
111
    SUB EAX, EBX
111
    SUB EAX, EBX
112
L1:
112
L1:
113
  }
113
  }
114
}
114
}
115
 
115
 
116
/*
116
/*
117
inline signed int strncmp(dword text1,text2,len)
117
inline signed int strncmp(dword text1,text2,len)
118
{
118
{
119
	
119
	
120
	loop()
120
	loop()
121
	{
121
	{
122
		if(DSBYTE[text1]!=DSBYTE[text2])return text1-text2;
122
		if(DSBYTE[text1]!=DSBYTE[text2])return text1-text2;
123
		$dec len 
123
		$dec len 
124
		if(!len)return 0;
124
		if(!len)return 0;
125
	}
125
	}
126
}
126
}
127
*/
127
*/
128
inline fastcall unsigned int strlen( EDI)
128
inline fastcall unsigned int strlen( EDI)
129
{
129
{
130
	$xor eax, eax
130
	$xor eax, eax
131
	$mov ecx, -1
131
	$mov ecx, -1
132
	$REPNE $SCASB
132
	$REPNE $SCASB
133
	EAX-=2+ECX;
133
	EAX-=2+ECX;
134
}
134
}
135
 
135
 
136
inline strnlen(dword str, dword maxlen)
136
inline strnlen(dword str, dword maxlen)
137
{
137
{
138
	dword cp;
138
	dword cp;
139
	for (cp = str; (maxlen != 0) && (DSBYTE[cp] != '\0'); cp++, maxlen--);
139
	for (cp = str; (maxlen != 0) && (DSBYTE[cp] != '\0'); cp++, maxlen--);
140
	return cp - str;
140
	return cp - str;
141
}
141
}
142
 
142
 
143
inline fastcall unsigned int utf8_strlen( ESI)
143
inline fastcall unsigned int utf8_strlen( ESI)
144
{
144
{
145
 $xor  ecx, ecx
145
 $xor  ecx, ecx
146
  _loop: 
146
  _loop: 
147
 $lodsb
147
 $lodsb
148
 $test  al, al
148
 $test  al, al
149
 $jz  _done
149
 $jz  _done
150
 $and al, 0xc0
150
 $and al, 0xc0
151
 $cmp al, 0x80
151
 $cmp al, 0x80
152
 $jz  _loop 
152
 $jz  _loop 
153
 $inc ecx
153
 $inc ecx
154
 $jmp _loop
154
 $jmp _loop
155
 
155
 
156
  _done:
156
  _done:
157
 return ECX;
157
 return ECX;
158
}
158
}
159
 
159
 
160
inline signed int strcmp(dword text1, text2)
160
inline signed int strcmp(dword text1, text2)
161
{
161
{
162
	char s1,s2;
162
	char s1,s2;
163
	dword p1,p2;
163
	dword p1,p2;
164
	p1 = text1;
164
	p1 = text1;
165
	p2 = text2;
165
	p2 = text2;
166
	loop()
166
	loop()
167
	{
167
	{
168
		s1 = DSBYTE[text1];
168
		s1 = DSBYTE[text1];
169
		s2 = DSBYTE[text2];
169
		s2 = DSBYTE[text2];
170
		if(s1==s2)
170
		if(s1==s2)
171
		{
171
		{
172
			if(s1==0) return 0;
172
			if(s1==0) return 0;
173
		}
173
		}
174
		else {
174
		else {
175
			return s1-s2;
175
			return s1-s2;
176
		}
176
		}
177
		$inc text1 
177
		$inc text1 
178
		$inc text2
178
		$inc text2
179
	}
179
	}
180
	return 0;
180
	return 0;
181
}
181
}
182
 
182
 
183
/*
183
/*
184
TODO: rewrite streq() using pure assembliy
184
TODO: rewrite streq() using pure assembliy
185
 
185
 
186
inline fastcall void strcpy( EDI, ESI)
186
inline fastcall void strcpy( EDI, ESI)
187
{
187
{
188
    $cld
188
    $cld
189
L2:
189
L2:
190
    $lodsb
190
    $lodsb
191
    $stosb
191
    $stosb
192
    $test al,al
192
    $test al,al
193
    $jnz L2
193
    $jnz L2
194
}
194
}
195
*/
195
*/
196
 
196
 
197
inline fastcall streq(ESI, EDI)
197
inline fastcall streq(ESI, EDI)
198
{
198
{
199
	loop()
199
	loop()
200
	{
200
	{
201
		if(DSBYTE[ESI]==DSBYTE[EDI])
201
		if(DSBYTE[ESI]==DSBYTE[EDI])
202
		{
202
		{
203
			if(DSBYTE[ESI]==0) return true;
203
			if(DSBYTE[ESI]==0) return true;
204
		}
204
		}
205
		else {
205
		else {
206
			return false;
206
			return false;
207
		}
207
		}
208
		ESI++;
208
		ESI++;
209
		EDI++;
209
		EDI++;
210
	}
210
	}
211
	return true;
211
	return true;
212
}
212
}
213
 
213
 
214
/*
214
/*
215
signed int strncmp(dword s1, s2, signed n)
215
signed int strncmp(dword s1, s2, signed n)
216
unsigned char _s1,_s2;
216
unsigned char _s1,_s2;
217
{
217
{
218
	if (n == 0)
218
	if (n == 0)
219
		return 0;
219
		return 0;
220
	do {
220
	do {
221
		_s1 = DSBYTE[s1];
221
		_s1 = DSBYTE[s1];
222
		_s2 = DSBYTE[s2];
222
		_s2 = DSBYTE[s2];
223
		if (_s1 != _s2)
223
		if (_s1 != _s2)
224
		{
224
		{
225
			$dec s2
225
			$dec s2
226
			return _s1 - _s2;
226
			return _s1 - _s2;
227
		}
227
		}
228
		$inc s2
228
		$inc s2
229
		if (_s1 == 0)
229
		if (_s1 == 0)
230
			break;
230
			break;
231
		$inc s1
231
		$inc s1
232
		$dec n
232
		$dec n
233
	} while (n);
233
	} while (n);
234
	return 0;
234
	return 0;
235
}
235
}
236
*/
236
*/
237
 
237
 
238
 
238
 
239
inline fastcall void strcpy( EDI, ESI)
239
inline fastcall void strcpy( EDI, ESI)
240
{
240
{
241
    $cld
241
    $cld
242
L2:
242
L2:
243
    $lodsb
243
    $lodsb
244
    $stosb
244
    $stosb
245
    $test al,al
245
    $test al,al
246
    $jnz L2
246
    $jnz L2
247
}
247
}
248
 
248
 
249
inline fastcall int strlcpy(dword ESI, EDI, EBX)
249
inline fastcall int strlcpy(dword ESI, EDI, EBX)
250
{
250
{
251
    if (EBX<0) return -1;
251
    if (EBX<0) return -1;
252
    EDX=0;
252
    EDX=0;
253
    do {
253
    do {
254
        DSBYTE[ESI]=DSBYTE[EDI];
254
        DSBYTE[ESI]=DSBYTE[EDI];
255
        ESI++;
255
        ESI++;
256
        EDI++;
256
        EDI++;
257
        EDX++;
257
        EDX++;
258
        if (EDX==EBX) { DSBYTE[ESI]='\0'; return -1;}
258
        if (EDX==EBX) { DSBYTE[ESI]='\0'; return -1;}
259
    } while(DSBYTE[EDI-1]!='\0');
259
    } while(DSBYTE[EDI-1]!='\0');
260
    return 0;
260
    return 0;
261
}
261
}
262
 
262
 
263
:void strncpy(dword dst, src, len)
263
:void strncpy(dword dst, src, len)
264
{
264
{
265
	while (len)
265
	while (len)
266
	{
266
	{
267
		ESBYTE[dst] = ESBYTE[src];
267
		ESBYTE[dst] = ESBYTE[src];
268
		dst++;
268
		dst++;
269
		src++;
269
		src++;
270
		len--;
270
		len--;
271
	}
271
	}
272
	ESBYTE[dst]=0;
272
	ESBYTE[dst]=0;
273
}
273
}
274
 
274
 
275
/*
275
/*
276
inline fastcall void strtrim( ESI)
276
inline fastcall void strtrim( ESI)
277
{
277
{
278
    EDI = ESI;
278
    EDI = ESI;
279
    do{
279
    do{
280
        AL=DSBYTE[EDI];
280
        AL=DSBYTE[EDI];
281
        if (AL != '\32') && (AL != '\13') && (AL != '\10')
281
        if (AL != '\32') && (AL != '\13') && (AL != '\10')
282
        {
282
        {
283
            DSBYTE[ESI]=AL;
283
            DSBYTE[ESI]=AL;
284
            $inc ESI
284
            $inc ESI
285
        }
285
        }
286
         $inc EDI
286
         $inc EDI
287
    }while(AL!=0);
287
    }while(AL!=0);
288
    DSBYTE[ESI] = '\0';
288
    DSBYTE[ESI] = '\0';
289
}
289
}
290
*/
290
*/
291
 
291
 
292
inline byte __isWhite(int s){ if (s==13)||(s==32)||(s==10)||(s==9) return true; return false; }
292
inline byte __isWhite(int s){ if (s==13)||(s==32)||(s==10)||(s==9) return true; return false; }
293
inline void strltrim(dword text){
293
inline void strltrim(dword text){
294
	int s;
294
	int s;
295
	dword back_text;
295
	dword back_text;
296
	back_text = text;
296
	back_text = text;
297
	s = ESBYTE[text];
297
	s = ESBYTE[text];
298
	while(__isWhite(s))
298
	while(__isWhite(s))
299
	{
299
	{
300
		$inc text
300
		$inc text
301
		s = ESBYTE[text];
301
		s = ESBYTE[text];
302
	}
302
	}
303
	loop()
303
	loop()
304
	{
304
	{
305
		ESBYTE[back_text] = s;
305
		ESBYTE[back_text] = s;
306
		$inc back_text
306
		$inc back_text
307
		if(!s) break;
307
		if(!s) break;
308
		$inc text
308
		$inc text
309
		s = ESBYTE[text];
309
		s = ESBYTE[text];
310
	};
310
	};
311
}
311
}
312
 
312
 
313
inline void strrtrim(dword text)
313
inline void strrtrim(dword text)
314
{
314
{
315
	int s;
315
	int s;
316
	dword p;
316
	dword p;
317
	do {
317
	do {
318
		s = ESBYTE[text];
318
		s = ESBYTE[text];
319
		if(__isWhite(s))
319
		if(__isWhite(s))
320
		{
320
		{
321
			p = text;
321
			p = text;
322
			while(__isWhite(s))
322
			while(__isWhite(s))
323
			{
323
			{
324
				$inc text;
324
				$inc text;
325
				s = ESBYTE[text];
325
				s = ESBYTE[text];
326
			}
326
			}
327
		}
327
		}
328
		else $inc text
328
		else $inc text
329
	} while(s);
329
	} while(s);
330
	$dec text
330
	$dec text
331
	s = ESBYTE[text];
331
	s = ESBYTE[text];
332
	if(__isWhite(s)) ESBYTE[p] = 0;
332
	if(__isWhite(s)) ESBYTE[p] = 0;
333
}
333
}
334
 
334
 
335
inline void strtrim(dword text){
335
inline void strtrim(dword text){
336
	int s;
336
	int s;
337
	dword p,back_text;
337
	dword p,back_text;
338
	back_text = text;
338
	back_text = text;
339
	s = ESBYTE[text];
339
	s = ESBYTE[text];
340
	while(__isWhite(s))
340
	while(__isWhite(s))
341
	{
341
	{
342
		$inc text
342
		$inc text
343
		s = ESBYTE[text];
343
		s = ESBYTE[text];
344
	} 
344
	} 
345
	do {
345
	do {
346
		s = ESBYTE[text];
346
		s = ESBYTE[text];
347
		if(__isWhite(s))
347
		if(__isWhite(s))
348
		{
348
		{
349
			p = back_text;
349
			p = back_text;
350
			while(__isWhite(s))
350
			while(__isWhite(s))
351
			{
351
			{
352
				ESBYTE[back_text] = s;
352
				ESBYTE[back_text] = s;
353
				$inc back_text
353
				$inc back_text
354
				$inc text;
354
				$inc text;
355
				s = ESBYTE[text];
355
				s = ESBYTE[text];
356
			}
356
			}
357
		}
357
		}
358
		else {
358
		else {
359
			ESBYTE[back_text] = s;
359
			ESBYTE[back_text] = s;
360
			$inc back_text
360
			$inc back_text
361
			$inc text
361
			$inc text
362
		}
362
		}
363
	} while(s);
363
	} while(s);
364
	$dec text
364
	$dec text
365
	s = ESBYTE[text];
365
	s = ESBYTE[text];
366
	if(__isWhite(s)) ESBYTE[p] = 0;
366
	if(__isWhite(s)) ESBYTE[p] = 0;
367
}
367
}
368
 
368
 
369
inline fastcall void strcat( EDI, ESI)
369
inline fastcall void strcat( EDI, ESI)
370
{
370
{
371
  asm {
371
  asm {
372
    mov ebx, edi
372
    mov ebx, edi
373
    xor ecx, ecx
373
    xor ecx, ecx
374
    xor eax, eax
374
    xor eax, eax
375
    dec ecx
375
    dec ecx
376
    repne scasb
376
    repne scasb
377
    dec edi
377
    dec edi
378
    mov edx, edi
378
    mov edx, edi
379
    mov edi, esi
379
    mov edi, esi
380
    xor ecx, ecx
380
    xor ecx, ecx
381
    xor eax, eax
381
    xor eax, eax
382
    dec ecx
382
    dec ecx
383
    repne scasb
383
    repne scasb
384
    xor ecx, 0ffffffffh
384
    xor ecx, 0ffffffffh
385
    mov edi, edx
385
    mov edi, edx
386
    mov edx, ecx
386
    mov edx, ecx
387
    mov eax, edi
387
    mov eax, edi
388
    shr ecx, 2
388
    shr ecx, 2
389
    rep movsd
389
    rep movsd
390
    mov ecx, edx
390
    mov ecx, edx
391
    and ecx, 3
391
    and ecx, 3
392
    rep movsb
392
    rep movsb
393
    mov eax, ebx
393
    mov eax, ebx
394
    }
394
    }
395
}
395
}
396
 
396
 
397
:void strncat(dword text1, text2, signed len)
397
:void strncat(dword text1, text2, signed len)
398
signed o1,o2;
398
signed o1,o2;
399
char s;
399
char s;
400
{
400
{
401
	s = DSBYTE[text1];
401
	s = DSBYTE[text1];
402
	while(s){
402
	while(s){
403
		$inc text1
403
		$inc text1
404
		s = DSBYTE[text1];
404
		s = DSBYTE[text1];
405
	}
405
	}
406
	o1 = len/4;
406
	o1 = len/4;
407
	o2 = len-4*o1;
407
	o2 = len-4*o1;
408
	while(o1){
408
	while(o1){
409
		DSDWORD[text1] = DSDWORD[text2];
409
		DSDWORD[text1] = DSDWORD[text2];
410
		text1 += 4;
410
		text1 += 4;
411
		text2 += 4;
411
		text2 += 4;
412
		$dec o1
412
		$dec o1
413
	}
413
	}
414
	while(o2){
414
	while(o2){
415
		DSBYTE[text1] = DSBYTE[text2];
415
		DSBYTE[text1] = DSBYTE[text2];
416
		$inc text1 
416
		$inc text1 
417
		$inc text2 
417
		$inc text2 
418
		$dec o2
418
		$dec o2
419
	}
419
	}
420
	DSBYTE[text1] = 0;
420
	DSBYTE[text1] = 0;
421
}
421
}
422
 
422
 
423
inline fastcall void chrcat(ESI, BL)
423
inline fastcall void chrcat(ESI, BL)
424
{
424
{
425
    EDI = strlen(ESI);
425
    EDI = strlen(ESI);
426
    ESBYTE[ESI+EDI] = BL;
426
    ESBYTE[ESI+EDI] = BL;
427
    ESBYTE[ESI+EDI+1] = 0;
427
    ESBYTE[ESI+EDI+1] = 0;
428
}
428
}
429
 
429
 
430
inline dword strchr(dword shb;char s)
430
inline dword strchr(dword shb;char s)
431
{
431
{
432
	char ss;
432
	char ss;
433
	loop()
433
	loop()
434
	{
434
	{
435
		ss = DSBYTE[shb];
435
		ss = DSBYTE[shb];
436
		if(!ss)return 0;
436
		if(!ss)return 0;
437
		if(ss==s)return shb;
437
		if(ss==s)return shb;
438
		shb++;
438
		shb++;
439
	}
439
	}
440
}
440
}
441
 
441
 
442
inline fastcall signed int strrchr( ESI,BL)
442
inline fastcall signed int strrchr( ESI,BL)
443
{
443
{
444
    int jj=0, last=0;
444
    int jj=0, last=0;
445
    do{
445
    do{
446
        jj++;
446
        jj++;
447
        $lodsb
447
        $lodsb
448
        IF(AL==BL) last=jj;
448
        IF(AL==BL) last=jj;
449
    } while(AL!=0);
449
    } while(AL!=0);
450
    return last;
450
    return last;
451
}
451
}
452
 
452
 
453
 
453
 
454
inline fastcall unsigned int chrnum( ESI, BL)
454
inline fastcall unsigned int chrnum( ESI, BL)
455
{
455
{
456
    int num = 0;
456
    int num = 0;
457
    while(DSBYTE[ESI])
457
    while(DSBYTE[ESI])
458
    { 
458
    { 
459
        if (DSBYTE[ESI] == BL) num++;
459
        if (DSBYTE[ESI] == BL) num++;
460
        ESI++;
460
        ESI++;
461
    }
461
    }
462
    return num;
462
    return num;
463
}
463
}
464
 
464
 
465
 
465
 
466
inline fastcall signed int strstr( EBX, EDX)
466
inline fastcall signed int strstr( EBX, EDX)
467
{
467
{
468
  asm {
468
  asm {
469
    MOV EDI, EDX
469
    MOV EDI, EDX
470
    XOR ECX, ECX
470
    XOR ECX, ECX
471
    XOR EAX, EAX
471
    XOR EAX, EAX
472
    DEC ECX
472
    DEC ECX
473
    REPNE SCASB
473
    REPNE SCASB
474
    NOT ECX
474
    NOT ECX
475
    DEC ECX
475
    DEC ECX
476
    JE LS2
476
    JE LS2
477
    MOV ESI, ECX
477
    MOV ESI, ECX
478
    XOR ECX, ECX
478
    XOR ECX, ECX
479
    MOV EDI, EBX
479
    MOV EDI, EBX
480
    DEC ECX
480
    DEC ECX
481
    REPNE SCASB
481
    REPNE SCASB
482
    NOT ECX
482
    NOT ECX
483
    SUB ECX, ESI
483
    SUB ECX, ESI
484
    JBE LS2
484
    JBE LS2
485
    MOV EDI, EBX
485
    MOV EDI, EBX
486
    LEA EBX, DSDWORD[ ESI-1]
486
    LEA EBX, DSDWORD[ ESI-1]
487
LS1: MOV ESI, EDX
487
LS1: MOV ESI, EDX
488
    LODSB
488
    LODSB
489
    REPNE SCASB
489
    REPNE SCASB
490
    JNE LS2
490
    JNE LS2
491
    MOV EAX, ECX
491
    MOV EAX, ECX
492
    PUSH EDI
492
    PUSH EDI
493
    MOV ECX, EBX
493
    MOV ECX, EBX
494
    REPE CMPSB
494
    REPE CMPSB
495
    POP EDI
495
    POP EDI
496
    MOV ECX, EAX
496
    MOV ECX, EAX
497
    JNE LS1
497
    JNE LS1
498
    LEA EAX, DSDWORD[ EDI-1]
498
    LEA EAX, DSDWORD[ EDI-1]
499
    JMP SHORT LS3
499
    JMP SHORT LS3
500
LS2: XOR EAX, EAX
500
LS2: XOR EAX, EAX
501
LS3:
501
LS3:
502
  }
502
  }
503
}
503
}
504
 
504
 
505
inline dword strcmpi(dword cmp1, cmp2)
505
inline dword strcmpi(dword cmp1, cmp2)
506
{
506
{
507
    char si, ue;
507
    char si, ue;
508
 
508
 
509
    loop()
509
    loop()
510
    { 
510
    { 
511
        si = DSBYTE[cmp1];
511
        si = DSBYTE[cmp1];
512
        ue = DSBYTE[cmp2];
512
        ue = DSBYTE[cmp2];
513
        if (si>='A') && (si<='Z') si +=32;
513
        if (si>='A') && (si<='Z') si +=32;
514
        if (ue>='A') && (ue<='Z') ue +=32;
514
        if (ue>='A') && (ue<='Z') ue +=32;
515
        if (si != ue) return -1;
515
        if (si != ue) return -1;
516
        cmp1++;
516
        cmp1++;
517
        cmp2++;
517
        cmp2++;
518
        if ((DSBYTE[cmp1]=='\0') && (DSBYTE[cmp2]=='\0')) return 0;
518
        if ((DSBYTE[cmp1]=='\0') && (DSBYTE[cmp2]=='\0')) return 0;
519
        if (DSBYTE[cmp1]=='\0') return -1;
519
        if (DSBYTE[cmp1]=='\0') return -1;
520
        if (DSBYTE[cmp2]=='\0') return 1;
520
        if (DSBYTE[cmp2]=='\0') return 1;
521
    }
521
    }
522
}
522
}
523
 
523
 
524
inline dword strstri(dword searchin, usestr_s)
524
inline dword strstri(dword searchin, usestr_s)
525
{
525
{
526
    dword usestr_e = usestr_s;
526
    dword usestr_e = usestr_s;
527
    char si, ue;
527
    char si, ue;
528
 
528
 
529
    while(DSBYTE[searchin])
529
    while(DSBYTE[searchin])
530
    { 
530
    { 
531
        si = DSBYTE[searchin];
531
        si = DSBYTE[searchin];
532
        ue = DSBYTE[usestr_e];
532
        ue = DSBYTE[usestr_e];
533
        if (si>='A') && (si<='Z') si +=32;
533
        if (si>='A') && (si<='Z') si +=32;
534
        if (ue>='A') && (ue<='Z') ue +=32;
534
        if (ue>='A') && (ue<='Z') ue +=32;
535
        if (si == ue) usestr_e++; else usestr_e = usestr_s;
535
        if (si == ue) usestr_e++; else usestr_e = usestr_s;
536
        searchin++;
536
        searchin++;
537
        if (DSBYTE[usestr_e]=='\0') return searchin;
537
        if (DSBYTE[usestr_e]=='\0') return searchin;
538
    }
538
    }
539
    return -1;
539
    return -1;
540
}
540
}
541
 
541
 
542
 
542
 
543
inline unsigned int strcpyb(dword search_in, copyin, startstr, endstr)
543
inline unsigned int strcpyb(dword search_in, copyin, startstr, endstr)
544
{
544
{
545
    dword startp, endp;
545
    dword startp, endp;
546
    dword copyin_start_off = copyin;
546
    dword copyin_start_off = copyin;
547
    if (startstr==0) startp = search_in; else startp = strstr(search_in, startstr) + strlen(startstr);
547
    if (startstr==0) startp = search_in; else startp = strstr(search_in, startstr) + strlen(startstr);
548
    endp = strstri(startp, endstr);
548
    endp = strstri(startp, endstr);
549
    if (endp==0) endp = startp+strlen(search_in);
549
    if (endp==0) endp = startp+strlen(search_in);
550
    //if (startp==endp) return 0;
550
    //if (startp==endp) return 0;
551
    do
551
    do
552
    { 
552
    { 
553
        DSBYTE[copyin] = DSBYTE[startp];
553
        DSBYTE[copyin] = DSBYTE[startp];
554
        copyin++;
554
        copyin++;
555
        startp++;
555
        startp++;
556
    }
556
    }
557
    while (startp
557
    while (startp
558
    DSBYTE[copyin] = '\0';
558
    DSBYTE[copyin] = '\0';
559
    return copyin_start_off;
559
    return copyin_start_off;
560
}
560
}
561
 
561
 
562
 
562
 
563
/*void strcat(char *to, char *from) 
563
/*void strcat(char *to, char *from) 
564
{
564
{
565
    while(*to) to++;
565
    while(*to) to++;
566
    while(*from)
566
    while(*from)
567
    {
567
    {
568
        *to = *from;
568
        *to = *from;
569
        to++;
569
        to++;
570
        from++;
570
        from++;
571
    }
571
    }
572
    *to = '\0';
572
    *to = '\0';
573
}*/
573
}*/
574
 
574
 
575
 
575
 
576
inline fastcall dword atoi( EDI)
576
inline fastcall dword atoi( EDI)
577
{
577
{
578
    $push ebx
578
    $push ebx
579
    $push esi
579
    $push esi
580
    ESI=EDI;
580
    ESI=EDI;
581
    while (DSBYTE[ESI]==' ') ESI++;
581
    while (DSBYTE[ESI]==' ') ESI++;
582
    if (DSBYTE[ESI]=='-') ESI++;
582
    if (DSBYTE[ESI]=='-') ESI++;
583
    EAX=0;
583
    EAX=0;
584
    while (DSBYTE[ESI]>='0') && (DSBYTE[ESI]<='9')
584
    while (DSBYTE[ESI]>='0') && (DSBYTE[ESI]<='9')
585
    {
585
    {
586
        $xor ebx, ebx
586
        $xor ebx, ebx
587
        EBX = DSBYTE[ESI]-'0';
587
        EBX = DSBYTE[ESI]-'0';
588
        EAX *= 10;
588
        EAX *= 10;
589
        EAX += EBX;
589
        EAX += EBX;
590
        ESI++;
590
        ESI++;
591
    } 
591
    } 
592
    IF (DSBYTE[EDI]=='-') -EAX;
592
    IF (DSBYTE[EDI]=='-') -EAX;
593
    $pop esi
593
    $pop esi
594
    $pop ebx
594
    $pop ebx
595
}
595
}
596
 
596
 
597
 
597
 
598
 
598
 
599
inline fastcall strupr( ESI)
599
inline fastcall strupr( ESI)
600
{
600
{
601
    do{
601
    do{
602
        AL=DSBYTE[ESI];
602
        AL=DSBYTE[ESI];
603
        IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f;
603
        IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f;
604
        IF (AL>=160) && (AL<=175) DSBYTE[ESI] = AL - 32;    //à-ï
604
        IF (AL>=160) && (AL<=175) DSBYTE[ESI] = AL - 32;    //à-ï
605
        IF (AL>=224) && (AL<=239) DSBYTE[ESI] = AL - 80;    //à-ï
605
        IF (AL>=224) && (AL<=239) DSBYTE[ESI] = AL - 80;    //à-ï
606
         ESI++;
606
         ESI++;
607
    }while(AL!=0);
607
    }while(AL!=0);
608
}
608
}
609
 
609
 
610
inline fastcall strlwr( ESI)
610
inline fastcall strlwr( ESI)
611
{
611
{
612
    do{
612
    do{
613
        $LODSB
613
        $LODSB
614
        IF(AL>='A')&&(AL<='Z'){
614
        IF(AL>='A')&&(AL<='Z'){
615
            AL+=0x20;
615
            AL+=0x20;
616
            DSBYTE[ESI-1]=AL;
616
            DSBYTE[ESI-1]=AL;
617
            CONTINUE;
617
            CONTINUE;
618
        }
618
        }
619
    }while(AL!=0);
619
    }while(AL!=0);
620
}
620
}
621
 
621
 
622
inline fastcall strttl( EDX)
622
inline fastcall strttl( EDX)
623
{
623
{
624
    AL=DSBYTE[EDX];
624
    AL=DSBYTE[EDX];
625
    IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
625
    IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
626
    IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32;    //à-ï
626
    IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32;    //à-ï
627
    IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80;    //à-ï
627
    IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80;    //à-ï
628
    do{
628
    do{
629
        EDX++;
629
        EDX++;
630
        AL=DSBYTE[EDX];
630
        AL=DSBYTE[EDX];
631
        IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
631
        IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
632
        IF(AL>='€')&&(AL<='')DSBYTE[EDX]=AL|0x20; // -¯
632
        IF(AL>='€')&&(AL<='')DSBYTE[EDX]=AL|0x20; // -¯
633
        IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80;    //à-ï
633
        IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80;    //à-ï
634
    }while(AL!=0);
634
    }while(AL!=0);
635
}
635
}
636
 
636
 
637
/*
637
/*
638
dword itoa( ESI)
638
dword itoa( ESI)
639
{
639
{
640
    unsigned char buffer[11];
640
    unsigned char buffer[11];
641
    $pusha
641
    $pusha
642
    EDI = #buffer;
642
    EDI = #buffer;
643
    ECX = 10;
643
    ECX = 10;
644
    if (ESI < 0)
644
    if (ESI < 0)
645
    {
645
    {
646
         $mov     al, '-'
646
         $mov     al, '-'
647
         $stosb
647
         $stosb
648
         $neg     esi
648
         $neg     esi
649
    }
649
    }
650
 
650
 
651
    $mov     eax, esi
651
    $mov     eax, esi
652
    $push    -'0'
652
    $push    -'0'
653
F2:
653
F2:
654
    $xor     edx, edx
654
    $xor     edx, edx
655
    $div     ecx
655
    $div     ecx
656
    $push    edx
656
    $push    edx
657
    $test    eax, eax
657
    $test    eax, eax
658
    $jnz     F2
658
    $jnz     F2
659
F3:
659
F3:
660
    $pop     eax
660
    $pop     eax
661
    $add     al, '0'
661
    $add     al, '0'
662
    $stosb
662
    $stosb
663
    $jnz     F3
663
    $jnz     F3
664
    
664
    
665
    $mov     al, '\0'
665
    $mov     al, '\0'
666
    $stosb
666
    $stosb
667
 
667
 
668
    $popa
668
    $popa
669
    return #buffer;
669
    return #buffer;
670
}
670
}
671
*/
671
*/
672
:unsigned char BUF_ITOA[11];
672
:unsigned char BUF_ITOA[11];
673
inline dword itoa(signed long number)
673
inline dword itoa(signed long number)
674
{
674
{
675
	dword ret,p;
675
	dword ret,p;
676
	byte cmd;
676
	byte cmd;
677
	long mask,tmp;
677
	long mask,tmp;
678
	mask = 1000000000;
678
	mask = 1000000000;
679
	cmd = true;
679
	cmd = true;
680
	p = #BUF_ITOA;
680
	p = #BUF_ITOA;
681
	if(!number){
681
	if(!number){
682
		ESBYTE[p] = '0';
682
		ESBYTE[p] = '0';
683
		ESBYTE[p+1] = 0;
683
		ESBYTE[p+1] = 0;
684
		return p;
684
		return p;
685
	}
685
	}
686
	ret = p;
686
	ret = p;
687
	if(number<0)
687
	if(number<0)
688
	{
688
	{
689
		$neg number
689
		$neg number
690
		ESBYTE[p] = '-';
690
		ESBYTE[p] = '-';
691
		$inc p
691
		$inc p
692
	}
692
	}
693
	while(mask)
693
	while(mask)
694
	{
694
	{
695
		tmp = number / mask;
695
		tmp = number / mask;
696
		tmp = tmp%10;
696
		tmp = tmp%10;
697
		
697
		
698
		if(cmd){
698
		if(cmd){
699
			if(tmp){
699
			if(tmp){
700
				ESBYTE[p] = tmp + '0';
700
				ESBYTE[p] = tmp + '0';
701
				$inc p
701
				$inc p
702
				cmd = false;
702
				cmd = false;
703
			}
703
			}
704
		}
704
		}
705
		else {
705
		else {
706
			ESBYTE[p] = tmp + '0';
706
			ESBYTE[p] = tmp + '0';
707
			$inc p
707
			$inc p
708
		}
708
		}
709
		mask /= 10;
709
		mask /= 10;
710
	}
710
	}
711
	ESBYTE[p] = 0;
711
	ESBYTE[p] = 0;
712
	return ret;
712
	return ret;
713
}
713
}
714
 
714
 
715
inline fastcall itoa_(signed int EDI, ESI)
715
inline fastcall itoa_(signed int EDI, ESI)
716
{
716
{
717
    $pusha
717
    $pusha
718
    EBX = EDI;
718
    EBX = EDI;
719
    ECX = 10;
719
    ECX = 10;
720
    if (ESI > 90073741824)
720
    if (ESI > 90073741824)
721
    {
721
    {
722
         $mov     al, '-'
722
         $mov     al, '-'
723
         $stosb
723
         $stosb
724
         $neg     esi
724
         $neg     esi
725
    }
725
    }
726
 
726
 
727
    $mov     eax, esi
727
    $mov     eax, esi
728
    $push    -'0'
728
    $push    -'0'
729
F2:
729
F2:
730
    $xor     edx, edx
730
    $xor     edx, edx
731
    $div     ecx
731
    $div     ecx
732
    $push    edx
732
    $push    edx
733
    $test    eax, eax
733
    $test    eax, eax
734
    $jnz     F2
734
    $jnz     F2
735
F3:
735
F3:
736
    $pop     eax
736
    $pop     eax
737
    $add     al, '0'
737
    $add     al, '0'
738
    $stosb
738
    $stosb
739
    $jnz     F3
739
    $jnz     F3
740
    
740
    
741
    $mov     al, '\0'
741
    $mov     al, '\0'
742
    $stosb
742
    $stosb
743
 
743
 
744
    $popa
744
    $popa
745
    return EBX;
745
    return EBX;
746
} 
746
} 
747
 
747
 
748
inline dword memchr(dword s,int c,signed len)
748
inline dword memchr(dword s,int c,signed len)
749
{
749
{
750
	if(!len) return NULL;
750
	if(!len) return NULL;
751
	do {
751
	do {
752
		if(DSBYTE[s] == c) return s;
752
		if(DSBYTE[s] == c) return s;
753
		$inc s
753
		$inc s
754
		$dec len
754
		$dec len
755
	} while(len);
755
	} while(len);
756
	return NULL;
756
	return NULL;
757
}
757
}
758
 
758
 
759
inline dword strdup(dword text)
759
inline dword strdup(dword text)
760
{
760
{
761
    dword l = strlen(text);
761
    dword l = strlen(text);
762
    dword ret = malloc(l+1);
762
    dword ret = malloc(l+1);
763
	if(!ret) return NULL;
763
	if(!ret) return NULL;
764
    strlcpy(ret,text,l);
764
    strlcpy(ret,text,l);
765
    return ret;
765
    return ret;
766
}
766
}
767
 
767
 
768
inline dword strndup(dword str, signed maxlen)
768
inline dword strndup(dword str, signed maxlen)
769
{
769
{
770
	dword copy,len;
770
	dword copy,len;
771
 
771
 
772
	len = strnlen(str, maxlen);
772
	len = strnlen(str, maxlen);
773
	copy = malloc(len + 1);
773
	copy = malloc(len + 1);
774
	if (copy != NULL)
774
	if (copy != NULL)
775
	{
775
	{
776
		strlcpy(copy, str, len);
776
		strlcpy(copy, str, len);
777
		DSBYTE[len+copy] = '\0';
777
		DSBYTE[len+copy] = '\0';
778
	}
778
	}
779
	return copy;
779
	return copy;
780
}
780
}
781
 
781
 
782
inline dword hexdec(dword text)
782
inline dword hexdec(dword text)
783
{
783
{
784
	char s;
784
	char s;
785
	dword ret,l;
785
	dword ret,l;
786
	ret = 0;
786
	ret = 0;
787
	s = DSBYTE[text];
787
	s = DSBYTE[text];
788
	while(s)
788
	while(s)
789
	{	
789
	{	
790
		ret <<= 4;
790
		ret <<= 4;
791
		if(s>='A')&&(s<='F')ret |= s-'A'+10;
791
		if(s>='A')&&(s<='F')ret |= s-'A'+10;
792
		else if(s>='a')&&(s<='f')ret |= s-'a'+10;
792
		else if(s>='a')&&(s<='f')ret |= s-'a'+10;
793
		else if(s>='0')&&(s<='9')ret |= s-'0';
793
		else if(s>='0')&&(s<='9')ret |= s-'0';
794
		text++;
794
		text++;
795
		s = DSBYTE[text];
795
		s = DSBYTE[text];
796
	}
796
	}
797
	return ret;
797
	return ret;
798
}
798
}
799
 
799
 
800
inline signed csshexdec(dword text)
800
inline signed csshexdec(dword text)
801
{
801
{
802
	char s;
802
	char s;
803
	dword ret,l;
803
	dword ret,l;
804
	byte tmp;
804
	byte tmp;
805
	l = strlen(text);
805
	l = strlen(text);
806
	ret = 0;
806
	ret = 0;
807
	s = DSBYTE[text];
807
	s = DSBYTE[text];
808
	tmp = 0;
808
	tmp = 0;
809
	if(l==6) while(s)
809
	if(l==6) while(s)
810
	{	
810
	{	
811
		ret <<= 4;
811
		ret <<= 4;
812
		if(s>='A')&&(s<='F')ret |= s-'A'+10;
812
		if(s>='A')&&(s<='F')ret |= s-'A'+10;
813
		else if(s>='a')&&(s<='f')ret |= s-'a'+10;
813
		else if(s>='a')&&(s<='f')ret |= s-'a'+10;
814
		else if(s>='0')&&(s<='9')ret |= s-'0';
814
		else if(s>='0')&&(s<='9')ret |= s-'0';
815
		text++;
815
		text++;
816
		s = DSBYTE[text];
816
		s = DSBYTE[text];
817
	}
817
	}
818
	else if(l==3) while(s)
818
	else if(l==3) while(s)
819
	{	
819
	{	
820
		ret |= tmp;
820
		ret |= tmp;
821
		ret <<= 4;
821
		ret <<= 4;
822
		ret |= tmp;
822
		ret |= tmp;
823
		ret <<= 4;
823
		ret <<= 4;
824
		if(s>='A')&&(s<='F')tmp = s-'A'+10;
824
		if(s>='A')&&(s<='F')tmp = s-'A'+10;
825
		else if(s>='a')&&(s<='f')tmp = s-'a'+10;
825
		else if(s>='a')&&(s<='f')tmp = s-'a'+10;
826
		else if(s>='0')&&(s<='9')tmp = s-'0';
826
		else if(s>='0')&&(s<='9')tmp = s-'0';
827
		text++;
827
		text++;
828
		s = DSBYTE[text];
828
		s = DSBYTE[text];
829
	}
829
	}
830
	return ret;
830
	return ret;
831
}
831
}
832
 
832
 
833
inline cdecl int sprintf(dword buf, format,...)
833
inline cdecl int sprintf(dword buf, format,...)
834
{
834
{
835
	#define END_ARGS 0xFF00FF //ARGS FUNCTION
835
	#define END_ARGS 0xFF00FF //ARGS FUNCTION
836
	byte s;
836
	byte s;
837
	char X[10];
837
	char X[10];
838
	dword ret, tmp, l;
838
	dword ret, tmp, l;
839
	dword arg = #format;
839
	dword arg = #format;
840
	ret = buf;
840
	ret = buf;
841
	s = DSBYTE[format];
841
	s = DSBYTE[format];
842
	while(s){
842
	while(s){
843
		if(s=='%'){
843
		if(s=='%'){
844
			arg+=4;
844
			arg+=4;
845
			tmp = DSDWORD[arg];
845
			tmp = DSDWORD[arg];
846
			if(tmp==END_ARGS)goto END_FUNC_SPRINTF;
846
			if(tmp==END_ARGS)goto END_FUNC_SPRINTF;
847
			$inc format
847
			$inc format
848
			s = DSBYTE[format];
848
			s = DSBYTE[format];
849
			if(!s)goto END_FUNC_SPRINTF;
849
			if(!s)goto END_FUNC_SPRINTF;
850
			switch(s)
850
			switch(s)
851
			{
851
			{
852
				case 's':
852
				case 's':
853
					l = tmp;
853
					l = tmp;
854
					s = DSBYTE[tmp];
854
					s = DSBYTE[tmp];
855
					while(s)
855
					while(s)
856
					{
856
					{
857
						DSBYTE[buf] = s;
857
						DSBYTE[buf] = s;
858
						$inc tmp
858
						$inc tmp
859
						$inc buf
859
						$inc buf
860
						s = DSBYTE[tmp];
860
						s = DSBYTE[tmp];
861
					}
861
					}
862
				break;
862
				break;
863
				case 'c':
863
				case 'c':
864
					DSBYTE[buf] = tmp;
864
					DSBYTE[buf] = tmp;
865
					$inc buf
865
					$inc buf
866
				break;
866
				break;
867
				case 'u': //if(tmp<0)return ret;
867
				case 'u': //if(tmp<0)return ret;
868
				case 'd':
868
				case 'd':
869
				case 'i':
869
				case 'i':
870
					tmp = itoa(tmp);
870
					tmp = itoa(tmp);
871
					if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
871
					if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
872
					l = strlen(tmp);
872
					l = strlen(tmp);
873
					strlcpy(buf,tmp,l);
873
					strlcpy(buf,tmp,l);
874
					buf += l;
874
					buf += l;
875
				break;
875
				break;
876
				case 'a':
876
				case 'a':
877
				case 'A':
877
				case 'A':
878
					strlcpy(buf,"0x00000000",10);
878
					strlcpy(buf,"0x00000000",10);
879
					buf+=10;
879
					buf+=10;
880
					l=buf;
880
					l=buf;
881
					while(tmp)
881
					while(tmp)
882
					{
882
					{
883
						$dec buf
883
						$dec buf
884
						s=tmp&0xF;
884
						s=tmp&0xF;
885
						if(s>9)DSBYTE[buf]='A'+s-10;
885
						if(s>9)DSBYTE[buf]='A'+s-10;
886
						else DSBYTE[buf]='0'+s;
886
						else DSBYTE[buf]='0'+s;
887
						tmp>>=4;
887
						tmp>>=4;
888
					}
888
					}
889
					buf=l;
889
					buf=l;
890
				break;
890
				break;
891
				case 'p':
891
				case 'p':
892
					tmp = itoa(#tmp);
892
					tmp = itoa(#tmp);
893
					if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
893
					if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
894
					l = strlen(tmp);
894
					l = strlen(tmp);
895
					strlcpy(buf,tmp,l);
895
					strlcpy(buf,tmp,l);
896
					buf += l;
896
					buf += l;
897
				break;
897
				break;
898
				case '%':
898
				case '%':
899
					DSBYTE[buf] = '%';
899
					DSBYTE[buf] = '%';
900
					$inc buf
900
					$inc buf
901
				break;
901
				break;
902
				default:
902
				default:
903
				goto END_FUNC_SPRINTF;
903
				goto END_FUNC_SPRINTF;
904
			}
904
			}
905
		}
905
		}
906
		else {
906
		else {
907
			DSBYTE[buf] = s;
907
			DSBYTE[buf] = s;
908
			$inc buf
908
			$inc buf
909
		}
909
		}
910
		$inc format
910
		$inc format
911
		s = DSBYTE[format];
911
		s = DSBYTE[format];
912
	}
912
	}
913
	END_FUNC_SPRINTF:
913
	END_FUNC_SPRINTF:
914
	DSBYTE[buf] = 0;
914
	DSBYTE[buf] = 0;
915
	return ret;
915
	return ret;
916
}
916
}
917
 
917
 
918
inline signed strcoll(dword text1,text2)
918
inline signed strcoll(dword text1,text2)
919
{
919
{
920
	char s,ss;
920
	char s,ss;
921
	loop()
921
	loop()
922
	{
922
	{
923
		s = DSBYTE[text2];
923
		s = DSBYTE[text2];
924
		ss=strchr(text1,s);
924
		ss=strchr(text1,s);
925
		if(ss)return ss;
925
		if(ss)return ss;
926
		text2++;
926
		text2++;
927
	}
927
	}
928
	return 0;
928
	return 0;
929
}
929
}
930
 
930
 
931
:replace_char(dword in_str, char from_char, to_char, int length) {
931
:replace_char(dword in_str, char from_char, to_char, int length) {
932
	int i;
932
	int i;
933
	for (i=0; i
933
	for (i=0; i
934
		if (ESBYTE[in_str+i] == from_char) ESBYTE[in_str+i] = to_char;
934
		if (ESBYTE[in_str+i] == from_char) ESBYTE[in_str+i] = to_char;
935
	}
935
	}
936
	ESBYTE[in_str+length]=0;
936
	ESBYTE[in_str+length]=0;
937
}
937
}
938
 
-
 
939
 
-
 
940
#define strnmov strmovn
-
 
941
#define stricmp strcmpi
-
 
942
#define strcmpn strncmp
-
 
943
 
938
 
944
#endif
939
#endif
945
>
940
>
946
>
941
>
947
>
942
>
948
>
943
>
949
>
944
>
950
>
945
>