Subversion Repositories Kolibri OS

Rev

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

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