Subversion Repositories Kolibri OS

Rev

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

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