Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
895 barsuk 1
; <--- description --->
2
; compiler:     FASM
3
; name:         Clipboard Client Demo
4
; version:      0.1
5
; author:       barsuk
6
 
7
 
8
; <--- include all MeOS stuff --->
9
include "lang.inc"
10
include "..\..\..\MACROS.INC"
11
 
12
TEST_SIZE = 100000	; должно делиться на 4
13
 
14
IPC_buffer_size = TEST_SIZE + 0x10
15
MAX_BUFFER = TEST_SIZE + 0x10
16
 
17
SEND_DELAY = 10
18
RECV_DELAY = 100
19
 
20
ATTEMPT = 5		; число попыток отправить сообщение демону, если
21
			; он занят
22
 
23
; <--- start of MenuetOS application --->
24
MEOS_APP_START
25
 
26
define DEBUG TRUE
27
include "bdebug.inc"
28
 
29
include "clip.inc"
30
 
31
; <--- start of code --->
32
CODE
33
 
34
 
35
;;;	This is the entry point of the program
36
 
37
begin:
38
 
39
print	"clipboard testing module loaded"
40
 
41
	mov	eax, 5
42
	mov	ebx, 100		; 5 sec
43
	int	0x40
44
 
45
	call	clipboard_init
46
	or	eax, eax
47
	jz	.err
48
 
49
	; put the data into clip_buffer
50
 
51
	mov	esi, test_line
52
	mov	edi, cb.data
53
	mov	ecx, cb.size
54
	rep	movsb
55
 
56
print	"init ok. @clip found."
57
 
58
	mov	esi, cb
59
	mov	eax, 2
60
	call	clipboard_write
61
	or	eax, eax
62
	jz	.err
63
 
64
print 	"write test ok."
65
 
66
; слегка очистим буфер, для надежности проверки
67
 
68
	mov	dword [cb.data], 0
69
 
70
;jmp .exit
71
	mov	eax, 3			; try to read bad data
72
	mov	esi, cb
73
	mov	edx, 7
74
	call	clipboard_read
75
	or	eax, eax
76
	jz	.bad2
77
	cmp	eax, -1
78
	jz	.err
79
 
80
.bad2:
81
print "unset data read ok 1."
82
	mov	eax, 88			; -"-
83
	mov	esi, cb
84
	mov	edx, 7
85
	call	clipboard_read
86
	or	eax, eax
87
	jz	.bad3
88
	cmp	eax, -1
89
	jz	.err
90
 
91
.bad3:
92
print "unset data read ok 2."
93
 
94
.read:
95
	mov	eax, 2
96
	mov	esi, cb
97
	mov	edx, 7
98
	call	clipboard_read		; read the string we've written
99
	or	eax, eax
100
	jz	.err
101
	cmp	eax, -1
102
	jz	.err
103
 
104
print	"read ok o_O, data:"
105
outs cb.data
106
print ""
107
 
108
	mov	eax, 5
109
	mov	ebx, 200
110
	int	0x40
111
 
112
 
113
; последняя проверка - на ресайз буфера. а именно, возьмем много данных
114
; и прокачаем их через буфер
115
 
116
	mov	eax, 68
117
	mov	ebx, 11
118
	int	0x40
119
 
120
	mov	eax, 68
121
	mov	ebx, 12
122
	mov	ecx, TEST_SIZE + 12
123
	int	0x40
124
	mov	[mega_buf], eax
125
 
126
	mov	dword [eax], TEST_SIZE
127
 
128
	lea	edx, [eax + 12]
129
	mov	eax, 12131415
130
	shr	ecx, 2
131
.loop:
132
	mov	[edx], eax
133
	add	edx, 4
134
	dec	ecx
135
	jnz	.loop
136
 
137
print "mega buffer allocated and filled"
138
 
139
	; now write it
140
 
141
	mov	esi, [mega_buf]
142
	mov	eax, 69
143
	call	clipboard_write
144
	or	eax, eax
145
	jz	.err
146
 
147
print "mega buffer written"
148
	mov	eax, 5
149
	mov	ebx, 100
150
	int	0x40
151
 
152
	; clear it.
153
 
154
	mov	edx, [mega_buf]
155
	add	edx, 12
156
	xor	eax, eax
157
	mov	ecx, TEST_SIZE/4
158
.loopc:
159
	mov	[edx], eax
160
	add	edx, 4
161
	dec	ecx
162
	jnz	.loopc
163
 
164
	; now read
165
 
166
	mov	eax, 69
167
	mov	esi, [mega_buf]
168
	mov	edx, 7
169
	call	clipboard_read		; read the string we've written
170
	or	eax, eax
171
	jz	.err
172
	cmp	eax, -1
173
	jz	.err
174
 
175
print "mega buf read"
176
 
177
	; now compare
178
 
179
	mov	edx, [mega_buf]
180
	add	edx, 12
181
	mov	eax, 12131415
182
	mov	ecx, TEST_SIZE/4
183
.loopm:
184
	cmp	eax, [edx]
185
	jnz	.err
186
	add	edx, 4
187
	dec	ecx
188
	jnz 	.loopm
189
 
190
print "deleting mega buf"
191
 
192
	mov	eax, 69
193
	call	clipboard_delete
194
	or	eax, eax
195
	jz	.err
196
 
197
	mov	eax, 5
198
	mov	ebx, 100
199
	int	0x40
200
 
201
print "if read error then all is ok"
202
 
203
	mov	eax, 69
204
	mov	esi, [mega_buf]
205
	mov	edx, 7
206
	call	clipboard_read		; read the string we've written
207
	or	eax, eax
208
	jz	.reading
209
	jmp	.err
210
 
211
.reading:
212
 
213
print "test complete!"
214
 
215
.exit:
216
	or	eax, -1
217
	int	0x40
218
 
219
.err:
220
print	"error!"
221
	jmp	.exit
222
 
223
 
224
; <--- initialised data --->
225
DATA
226
 
227
	CLIP_BUFFER	cb, 256
228
 
229
;	in_buf		db	256 dup(0)
230
;	out_buf		db 	'Cthulhu Fhtagn',0
231
 
232
	test_line 	db	'Cthulhu Fhtagn',0
233
	mega_buf	dd	0
234
 
235
; <--- uninitialised data --->
236
UDATA
237
 
238
 
239
MEOS_APP_END
240
; <--- end of MenuetOS application --->