Subversion Repositories Kolibri OS

Rev

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

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