Subversion Repositories Kolibri OS

Rev

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

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