Subversion Repositories Kolibri OS

Rev

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

Rev 539 Rev 661
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                   ;;
2
;;                                                   ;;
3
;;    POP CLIENT for MenuetOS                        ;;
3
;;    POP CLIENT for MenuetOS                        ;;
4
;;    - Modified from IRC client                     ;;
4
;;    - Modified from IRC client                     ;;
5
;;                                                   ;;
5
;;                                                   ;;
6
;;    License: GPL / See file COPYING for details    ;;
6
;;    License: GPL / See file COPYING for details    ;;
7
;;    Copyright 2002 (c) Ville Turjanmaa             ;;
7
;;    Copyright 2002 (c) Ville Turjanmaa             ;;
8
;;                                                   ;;
8
;;                                                   ;;
9
;;    Compile with FASM for Menuet                   ;;
9
;;    Compile with FASM for Menuet                   ;;
10
;;                                                   ;;
10
;;                                                   ;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
include '..\..\..\macros.inc'
12
include 'macros.inc'
13
version equ '0.1'
13
version equ '0.1'
14
 
14
 
15
use32
15
use32
16
 
16
 
17
                org     0x0
17
                org     0x0
18
 
18
 
19
                db      'MENUET01'              ; 8 byte id
19
                db      'MENUET01'              ; 8 byte id
20
                dd      0x01                    ; required os
20
                dd      0x01                    ; required os
21
                dd      START                   ; program start
21
                dd      START                   ; program start
22
                dd      I_END                   ; program image size
22
                dd      I_END                   ; program image size
23
                dd      0x200000                ; required amount of memory
23
                dd      0x200000                ; required amount of memory
24
                dd      0xffff0
24
                dd      0xffff0
25
                dd      0,0
25
                dd      0,0
26
 
26
 
27
START:                          ; start of execution
27
START:                          ; start of execution
28
 
28
 
29
    mov  [file_start],0x100000
29
    mov  [file_start],0x100000
30
 
30
 
31
    mov  eax,70
31
    mov  eax,70
32
    mov  ebx,filel
32
    mov  ebx,filel
33
    mcall
33
    mcall
34
 
34
 
35
    test eax,eax
35
    test eax,eax
36
    jz   @f
36
    jz   @f
37
    cmp  eax,6
37
    cmp  eax,6
38
    jnz  notfound
38
    jnz  notfound
39
@@:
39
@@:
40
    add  [file_start],ebx
40
    add  [file_start],ebx
41
  notfound:
41
  notfound:
42
 
42
 
43
    mov  edi,I_END
43
    mov  edi,I_END
44
    mov  ecx,60*120
44
    mov  ecx,60*120
45
    mov  al,32
45
    mov  al,32
46
    cld
46
    cld
47
    rep  stosb
47
    rep  stosb
48
 
48
 
49
    mov  eax,[rxs]
49
    mov  eax,[rxs]
50
    imul eax,11
50
    imul eax,11
51
    mov  [pos],eax
51
    mov  [pos],eax
52
 
52
 
53
    mov  ebp,0
53
    mov  ebp,0
54
    mov  edx,I_END
54
    mov  edx,I_END
55
 
55
 
56
redraw:                         ; redraw
56
redraw:                         ; redraw
57
    call draw_window            ; at first, draw the window
57
    call draw_window            ; at first, draw the window
58
 
58
 
59
still:
59
still:
60
 
60
 
61
    mov  eax,5
61
    mov  eax,5
62
    mov  ebx,1
62
    mov  ebx,1
63
    mcall
63
    mcall
64
 
64
 
65
    mov  eax,11                 ; wait here for event
65
    mov  eax,11                 ; wait here for event
66
    mcall
66
    mcall
67
 
67
 
68
    cmp  eax,1                  ; redraw
68
    cmp  eax,1                  ; redraw
69
    je   redraw
69
    je   redraw
70
    cmp  eax,2                  ; key
70
    cmp  eax,2                  ; key
71
    je   key
71
    je   key
72
    cmp  eax,3                  ; button
72
    cmp  eax,3                  ; button
73
    je   button
73
    je   button
74
 
74
 
75
    cmp  [I_END+120*60],byte 1
75
    cmp  [I_END+120*60],byte 1
76
    jne  no_main_update
76
    jne  no_main_update
77
    mov  [I_END+120*60],byte 0
77
    mov  [I_END+120*60],byte 0
78
    mov  edx,I_END
78
    mov  edx,I_END
79
    call draw_server_data
79
    call draw_server_data
80
  no_main_update:
80
  no_main_update:
81
 
81
 
82
    cmp  [server_active],0
82
    cmp  [server_active],0
83
    je   noread
83
    je   noread
84
    call read_incoming_data
84
    call read_incoming_data
85
  noread:
85
  noread:
86
 
86
 
87
    call print_status
87
    call print_status
88
 
88
 
89
    cmp  [status],4
89
    cmp  [status],4
90
    je   send_request
90
    je   send_request
91
 
91
 
92
    jmp  still
92
    jmp  still
93
 
93
 
94
 
94
 
95
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
95
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
96
;;
96
;;
97
;;  Save the fetched mails
97
;;  Save the fetched mails
98
;;
98
;;
99
 
99
 
100
 
100
 
101
save_file:
101
save_file:
102
 
102
 
103
   pusha
103
   pusha
104
 
104
 
105
   mov  ebx,files
105
   mov  ebx,files
106
   mov  eax,[file_start]
106
   mov  eax,[file_start]
107
   sub  eax,0x100000
107
   sub  eax,0x100000
108
   mov  [ebx+12],eax
108
   mov  [ebx+12],eax
109
 
109
 
110
   mov  eax,70
110
   mov  eax,70
111
   mcall
111
   mcall
112
 
112
 
113
   popa
113
   popa
114
 
114
 
115
   ret
115
   ret
116
 
116
 
117
 
117
 
118
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
118
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
119
;;
119
;;
120
;;  Send user id/passwd/mailrq
120
;;  Send user id/passwd/mailrq
121
;;
121
;;
122
 
122
 
123
 
123
 
124
send_request:
124
send_request:
125
 
125
 
126
    inc  [mcounter]
126
    inc  [mcounter]
127
 
127
 
128
    cmp  [mcounter],1000
128
    cmp  [mcounter],1000
129
    jbe  no_send
129
    jbe  no_send
130
 
130
 
131
    mov  eax,[ccounter]
131
    mov  eax,[ccounter]
132
    imul  eax,32
132
    imul  eax,32
133
    add  eax,getmail
133
    add  eax,getmail
134
    mov  esi,eax
134
    mov  esi,eax
135
 
135
 
136
    inc  [ccounter]
136
    inc  [ccounter]
137
 
137
 
138
    mov  edx,32
138
    mov  edx,32
139
 
139
 
140
    cmp  [ccounter],1
140
    cmp  [ccounter],1
141
    jne  no1
141
    jne  no1
142
    mov  edx,5+2
142
    mov  edx,5+2
143
    add  edx,[l2]
143
    add  edx,[l2]
144
  no1:
144
  no1:
145
 
145
 
146
    cmp  [ccounter],2
146
    cmp  [ccounter],2
147
    jne  no2
147
    jne  no2
148
    mov  edx,5+2
148
    mov  edx,5+2
149
    add  edx,[l3]
149
    add  edx,[l3]
150
  no2:
150
  no2:
151
 
151
 
152
    mov  eax,53
152
    mov  eax,53
153
    mov  ebx,7
153
    mov  ebx,7
154
    mov  ecx,[socket]
154
    mov  ecx,[socket]
155
    mcall
155
    mcall
156
    mov  [mcounter],0
156
    mov  [mcounter],0
157
 
157
 
158
    cmp  [esi],dword 'quit'
158
    cmp  [esi],dword 'quit'
159
    je   close_fetch
159
    je   close_fetch
160
 
160
 
161
 
161
 
162
  no_send:
162
  no_send:
163
 
163
 
164
    jmp  still
164
    jmp  still
165
 
165
 
166
 
166
 
167
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
167
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
168
;;
168
;;
169
;;  Close connection to server
169
;;  Close connection to server
170
;;
170
;;
171
 
171
 
172
 
172
 
173
close_fetch:
173
close_fetch:
174
 
174
 
175
    mov  eax,53
175
    mov  eax,53
176
    mov  ebx,7
176
    mov  ebx,7
177
    mov  ecx,[socket]
177
    mov  ecx,[socket]
178
    mov  edx,14
178
    mov  edx,14
179
    mov  esi,quitc
179
    mov  esi,quitc
180
    mcall
180
    mcall
181
    mov  [mcounter],0
181
    mov  [mcounter],0
182
 
182
 
183
    mov  eax,5
183
    mov  eax,5
184
    mov  ebx,150
184
    mov  ebx,150
185
    mcall
185
    mcall
186
 
186
 
187
    call read_incoming_data
187
    call read_incoming_data
188
 
188
 
189
    mov  eax,53
189
    mov  eax,53
190
    mov  ebx,8
190
    mov  ebx,8
191
    mov  ecx,[socket]
191
    mov  ecx,[socket]
192
    mcall
192
    mcall
193
 
193
 
194
    mov  eax,5
194
    mov  eax,5
195
    mov  ebx,2
195
    mov  ebx,2
196
    mcall
196
    mcall
197
 
197
 
198
    mov  eax,53
198
    mov  eax,53
199
    mov  ebx,8
199
    mov  ebx,8
200
    mov  ecx,[socket]
200
    mov  ecx,[socket]
201
    mcall
201
    mcall
202
 
202
 
203
    mov  [server_active],0
203
    mov  [server_active],0
204
 
204
 
205
    jmp  still
205
    jmp  still
206
 
206
 
207
 
207
 
208
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
208
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
209
;;
209
;;
210
;;  User input processing
210
;;  User input processing
211
;;
211
;;
212
 
212
 
213
 
213
 
214
key:
214
key:
215
 
215
 
216
    mov  eax,2
216
    mov  eax,2
217
    mcall
217
    mcall
218
 
218
 
219
    jmp  still
219
    jmp  still
220
 
220
 
221
 
221
 
222
button:                         ; button
222
button:                         ; button
223
 
223
 
224
    mov  eax,17                 ; get id
224
    mov  eax,17                 ; get id
225
    mcall
225
    mcall
226
 
226
 
227
    cmp  ah,60
227
    cmp  ah,60
228
    jne  no_open
228
    jne  no_open
229
        mov     eax, 70
229
        mov     eax, 70
230
        mov     ebx, tinypad_start
230
        mov     ebx, tinypad_start
231
        mcall
231
        mcall
232
    jmp  still
232
    jmp  still
233
  no_open:
233
  no_open:
234
 
234
 
235
    cmp  ah,1                   ; close program
235
    cmp  ah,1                   ; close program
236
    jne  noclose
236
    jne  noclose
237
    mov  eax,-1
237
    mov  eax,-1
238
    mcall
238
    mcall
239
  noclose:
239
  noclose:
240
 
240
 
241
    cmp  ah,51
241
    cmp  ah,51
242
    je   read_string
242
    je   read_string
243
    cmp  ah,52
243
    cmp  ah,52
244
    je   read_string
244
    je   read_string
245
    cmp  ah,53
245
    cmp  ah,53
246
    je   read_string
246
    je   read_string
247
 
247
 
248
    call socket_commands
248
    call socket_commands
249
 
249
 
250
    jmp  still
250
    jmp  still
251
 
251
 
252
 
252
 
253
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
253
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
254
;;
254
;;
255
;;  Socket open & close
255
;;  Socket open & close
256
;;
256
;;
257
 
257
 
258
socket_commands:
258
socket_commands:
259
 
259
 
260
    cmp  ah,22       ; open socket
260
    cmp  ah,22       ; open socket
261
    jnz  tst3
261
    jnz  tst3
262
 
262
 
263
    mov  [server_active],1
263
    mov  [server_active],1
264
 
264
 
265
    mov  [mcounter],900
265
    mov  [mcounter],900
266
    mov  [ccounter],0
266
    mov  [ccounter],0
267
 
267
 
268
    mov  eax,3
268
    mov  eax,3
269
    mcall
269
    mcall
270
 
270
 
271
    mov  eax,3
271
    mov  eax,3
272
    mcall
272
    mcall
273
    mov  ecx,eax
273
    mov  ecx,eax
274
    and  ecx,0xffff
274
    and  ecx,0xffff
275
 
275
 
276
    mov  eax,53
276
    mov  eax,53
277
    mov  ebx,5
277
    mov  ebx,5
278
    mov  edx,110
278
    mov  edx,110
279
    mov  esi,dword [ip]
279
    mov  esi,dword [ip]
280
    mov  edi,1
280
    mov  edi,1
281
    mcall
281
    mcall
282
    mov  [socket], eax
282
    mov  [socket], eax
283
 
283
 
284
    ret
284
    ret
285
  tst3:
285
  tst3:
286
 
286
 
287
 
287
 
288
    cmp  ah,24     ; close socket
288
    cmp  ah,24     ; close socket
289
    jnz  no_24
289
    jnz  no_24
290
    mov  eax,53
290
    mov  eax,53
291
    mov  ebx,8
291
    mov  ebx,8
292
    mov  ecx,[socket]
292
    mov  ecx,[socket]
293
    mcall
293
    mcall
294
    mov  [header_sent],0
294
    mov  [header_sent],0
295
    mov  [mail_rp],0
295
    mov  [mail_rp],0
296
    mov  [server_active],0
296
    mov  [server_active],0
297
 
297
 
298
    ret
298
    ret
299
  no_24:
299
  no_24:
300
 
300
 
301
    ret
301
    ret
302
 
302
 
303
 
303
 
304
 
304
 
305
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
305
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
306
;;
306
;;
307
;;  Display connection status
307
;;  Display connection status
308
;;
308
;;
309
 
309
 
310
old_status dd 0x0
310
old_status dd 0x0
311
 
311
 
312
print_status:
312
print_status:
313
 
313
 
314
    pusha
314
    pusha
315
 
315
 
316
    mov  eax,53
316
    mov  eax,53
317
    mov  ebx,6
317
    mov  ebx,6
318
    mov  ecx,[socket]
318
    mov  ecx,[socket]
319
    mcall
319
    mcall
320
 
320
 
321
    mov  [status],eax
321
    mov  [status],eax
322
 
322
 
323
    cmp  eax,[old_status]
323
    cmp  eax,[old_status]
324
    je   nopr
324
    je   nopr
325
 
325
 
326
    mov  [old_status],eax
326
    mov  [old_status],eax
327
 
327
 
328
    push eax
328
    push eax
329
 
329
 
330
    mov  eax,13
330
    mov  eax,13
331
    mov  ebx,200*65536+30
331
    mov  ebx,200*65536+30
332
    mov  ecx,160*65536+10
332
    mov  ecx,160*65536+10
333
    mov  edx,0xffffff
333
    mov  edx,0xffffff
334
    mcall
334
    mcall
335
 
335
 
336
    pop  ecx
336
    pop  ecx
337
 
337
 
338
    cmp  [server_active],1
338
    cmp  [server_active],1
339
    jne  nopr
339
    jne  nopr
340
 
340
 
341
    mov  eax,47
341
    mov  eax,47
342
    mov  ebx,3*65536
342
    mov  ebx,3*65536
343
    mov  edx,200*65536+160
343
    mov  edx,200*65536+160
344
    mov  esi,0x000000
344
    mov  esi,0x000000
345
    mcall
345
    mcall
346
 
346
 
347
  nopr:
347
  nopr:
348
 
348
 
349
    popa
349
    popa
350
 
350
 
351
    ret
351
    ret
352
 
352
 
353
 
353
 
354
 
354
 
355
 
355
 
356
 
356
 
357
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
357
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
358
;;
358
;;
359
;;  Read data from server
359
;;  Read data from server
360
;;
360
;;
361
 
361
 
362
 
362
 
363
read_incoming_data:
363
read_incoming_data:
364
 
364
 
365
    pusha
365
    pusha
366
 
366
 
367
  read_new_byte:
367
  read_new_byte:
368
 
368
 
369
    call read_incoming_byte
369
    call read_incoming_byte
370
    cmp  ecx,-1
370
    cmp  ecx,-1
371
    je   no_data_in_buffer
371
    je   no_data_in_buffer
372
 
372
 
373
    mov  eax,[file_start]
373
    mov  eax,[file_start]
374
    mov  [eax],bl
374
    mov  [eax],bl
375
    inc  [file_start]
375
    inc  [file_start]
376
 
376
 
377
    cmp  bl,10
377
    cmp  bl,10
378
    jne  no_start_command
378
    jne  no_start_command
379
    mov  [cmd],1
379
    mov  [cmd],1
380
  no_start_command:
380
  no_start_command:
381
 
381
 
382
    cmp  bl,13
382
    cmp  bl,13
383
    jne  no_end_command
383
    jne  no_end_command
384
    mov  eax,[cmd]
384
    mov  eax,[cmd]
385
    mov  [eax+command-2],byte 0
385
    mov  [eax+command-2],byte 0
386
    call save_file
386
    call save_file
387
    call analyze_data
387
    call analyze_data
388
    mov  edi,command
388
    mov  edi,command
389
    mov  ecx,250
389
    mov  ecx,250
390
    mov  eax,0
390
    mov  eax,0
391
    cld
391
    cld
392
    rep  stosb
392
    rep  stosb
393
    mov  [cmd],0
393
    mov  [cmd],0
394
  no_end_command:
394
  no_end_command:
395
 
395
 
396
    mov  eax,[cmd]
396
    mov  eax,[cmd]
397
    cmp  eax,250
397
    cmp  eax,250
398
    jge  still
398
    jge  still
399
 
399
 
400
    mov  [eax+command-2],bl
400
    mov  [eax+command-2],bl
401
    inc  [cmd]
401
    inc  [cmd]
402
 
402
 
403
    jmp  read_new_byte
403
    jmp  read_new_byte
404
 
404
 
405
  no_data_in_buffer:
405
  no_data_in_buffer:
406
 
406
 
407
    popa
407
    popa
408
 
408
 
409
    ret
409
    ret
410
 
410
 
411
 
411
 
412
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
412
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
413
;;
413
;;
414
;;  Read user input for ip/user/passwd
414
;;  Read user input for ip/user/passwd
415
;;
415
;;
416
 
416
 
417
 
417
 
418
read_string:
418
read_string:
419
 
419
 
420
    shr  eax,8
420
    shr  eax,8
421
    sub  eax,51
421
    sub  eax,51
422
    mov  ebx,eax
422
    mov  ebx,eax
423
    imul eax,12
423
    imul eax,12
424
    add  eax,181
424
    add  eax,181
425
 
425
 
426
    mov  [len],ebx
426
    mov  [len],ebx
427
    shl  [len],2
427
    shl  [len],2
428
    add  [len],l1
428
    add  [len],l1
429
 
429
 
430
    imul ebx,50
430
    imul ebx,50
431
    add  ebx,input1
431
    add  ebx,input1
432
 
432
 
433
    mov  [addr],ebx
433
    mov  [addr],ebx
434
    mov  [ya],eax
434
    mov  [ya],eax
435
 
435
 
436
    mov  edi,[addr]
436
    mov  edi,[addr]
437
    mov  eax,0
437
    mov  eax,0
438
    mov  ecx,30
438
    mov  ecx,30
439
    cld
439
    cld
440
    rep  stosb
440
    rep  stosb
441
 
441
 
442
    call print_input_text
442
    call print_input_text
443
 
443
 
444
    mov  edi,[addr]
444
    mov  edi,[addr]
445
 
445
 
446
  f11:
446
  f11:
447
    mov  eax,10
447
    mov  eax,10
448
    mcall
448
    mcall
449
    cmp  eax,2
449
    cmp  eax,2
450
    jne  read_done
450
    jne  read_done
451
    mov  eax,2
451
    mov  eax,2
452
    mcall
452
    mcall
453
    shr  eax,8
453
    shr  eax,8
454
    cmp  eax,13
454
    cmp  eax,13
455
    je   read_done
455
    je   read_done
456
    cmp  eax,8
456
    cmp  eax,8
457
    jnz  nobsl
457
    jnz  nobsl
458
    cmp  edi,[addr]
458
    cmp  edi,[addr]
459
    jz   f11
459
    jz   f11
460
    sub  edi,1
460
    sub  edi,1
461
    mov  [edi],byte 32
461
    mov  [edi],byte 32
462
    call print_text
462
    call print_text
463
    jmp  f11
463
    jmp  f11
464
  nobsl:
464
  nobsl:
465
    mov  [edi],al
465
    mov  [edi],al
466
 
466
 
467
    call print_input_text
467
    call print_input_text
468
 
468
 
469
    add  edi,1
469
    add  edi,1
470
    mov  esi,[addr]
470
    mov  esi,[addr]
471
    add  esi,30
471
    add  esi,30
472
    cmp  esi,edi
472
    cmp  esi,edi
473
    jnz  f11
473
    jnz  f11
474
 
474
 
475
  read_done:
475
  read_done:
476
 
476
 
477
    push edi
477
    push edi
478
 
478
 
479
    mov  ecx,40
479
    mov  ecx,40
480
    mov  eax,32
480
    mov  eax,32
481
    cld
481
    cld
482
    rep  stosb
482
    rep  stosb
483
 
483
 
484
    call print_input_text
484
    call print_input_text
485
 
485
 
486
    pop  edi
486
    pop  edi
487
    sub  edi,[addr]
487
    sub  edi,[addr]
488
    mov  eax,[len]
488
    mov  eax,[len]
489
    mov  [eax],edi
489
    mov  [eax],edi
490
 
490
 
491
    cmp  [len],l1
491
    cmp  [len],l1
492
    jne  noip
492
    jne  noip
493
    mov  esi,input1
493
    mov  esi,input1
494
    mov  edi,ip_text+15
494
    mov  edi,ip_text+15
495
    mov  ecx,16
495
    mov  ecx,16
496
    cld
496
    cld
497
    rep  movsb
497
    rep  movsb
498
    call ip_set
498
    call ip_set
499
   noip:
499
   noip:
500
 
500
 
501
    cmp  [len],l2
501
    cmp  [len],l2
502
    jne  nol2
502
    jne  nol2
503
    mov  esi,input2
503
    mov  esi,input2
504
    mov  edi,l2_text+15
504
    mov  edi,l2_text+15
505
    mov  ecx,22
505
    mov  ecx,22
506
    cld
506
    cld
507
    rep  movsb
507
    rep  movsb
508
    mov  esi,input2
508
    mov  esi,input2
509
    mov  edi,getmail+5
509
    mov  edi,getmail+5
510
    mov  ecx,[l2]
510
    mov  ecx,[l2]
511
    cld
511
    cld
512
    rep  movsb
512
    rep  movsb
513
    mov  al,13
513
    mov  al,13
514
    stosb
514
    stosb
515
    mov  al,10
515
    mov  al,10
516
    stosb
516
    stosb
517
   nol2:
517
   nol2:
518
 
518
 
519
    cmp  [len],l3
519
    cmp  [len],l3
520
    jne  nol3
520
    jne  nol3
521
    mov  esi,input3
521
    mov  esi,input3
522
    mov  edi,getmail+32+5
522
    mov  edi,getmail+32+5
523
    mov  ecx,[l3]
523
    mov  ecx,[l3]
524
    cld
524
    cld
525
    rep  movsb
525
    rep  movsb
526
    mov  al,13
526
    mov  al,13
527
    stosb
527
    stosb
528
    mov  al,10
528
    mov  al,10
529
    stosb
529
    stosb
530
   nol3:
530
   nol3:
531
 
531
 
532
    call draw_window
532
    call draw_window
533
 
533
 
534
    jmp  still
534
    jmp  still
535
 
535
 
536
 
536
 
537
 
537
 
538
print_input_text:
538
print_input_text:
539
 
539
 
540
    pusha
540
    pusha
541
 
541
 
542
    mov  eax,13
542
    mov  eax,13
543
    mov  ebx,95*65536+23*6
543
    mov  ebx,95*65536+23*6
544
    mov  ecx,[ya]
544
    mov  ecx,[ya]
545
    shl  ecx,16
545
    shl  ecx,16
546
    mov  cx,9
546
    mov  cx,9
547
    mov  edx,0xffffff
547
    mov  edx,0xffffff
548
    mcall
548
    mcall
549
 
549
 
550
    cmp  [len],l3
550
    cmp  [len],l3
551
    je   noprt
551
    je   noprt
552
 
552
 
553
    mov  eax,4
553
    mov  eax,4
554
    mov  edx,[addr]
554
    mov  edx,[addr]
555
    mov  ebx,95*65536
555
    mov  ebx,95*65536
556
    add  ebx,[ya]
556
    add  ebx,[ya]
557
    mov  ecx,0x000000
557
    mov  ecx,0x000000
558
    mov  esi,23
558
    mov  esi,23
559
    mcall
559
    mcall
560
 
560
 
561
  noprt:
561
  noprt:
562
 
562
 
563
    popa
563
    popa
564
    ret
564
    ret
565
 
565
 
566
 
566
 
567
ip_set:
567
ip_set:
568
 
568
 
569
    mov   esi,input1-1
569
    mov   esi,input1-1
570
    mov   edi,ip
570
    mov   edi,ip
571
    xor   eax,eax
571
    xor   eax,eax
572
   ip1:
572
   ip1:
573
    inc   esi
573
    inc   esi
574
    cmp   [esi],byte '0'
574
    cmp   [esi],byte '0'
575
    jb    ip2
575
    jb    ip2
576
    cmp   [esi],byte '9'
576
    cmp   [esi],byte '9'
577
    jg    ip2
577
    jg    ip2
578
    imul  eax,10
578
    imul  eax,10
579
    movzx ebx,byte [esi]
579
    movzx ebx,byte [esi]
580
    sub   ebx,48
580
    sub   ebx,48
581
    add   eax,ebx
581
    add   eax,ebx
582
    jmp   ip1
582
    jmp   ip1
583
   ip2:
583
   ip2:
584
    mov   [edi],al
584
    mov   [edi],al
585
    xor   eax,eax
585
    xor   eax,eax
586
    inc   edi
586
    inc   edi
587
    cmp   edi,ip+3
587
    cmp   edi,ip+3
588
    jbe   ip1
588
    jbe   ip1
589
    ret
589
    ret
590
   no_read_ip:
590
   no_read_ip:
591
 
591
 
592
    ret
592
    ret
593
 
593
 
594
 
594
 
595
analyze_data:
595
analyze_data:
596
 
596
 
597
    pusha
597
    pusha
598
 
598
 
599
    mov  [text_start],I_END
599
    mov  [text_start],I_END
600
    mov  ecx,[rxs]
600
    mov  ecx,[rxs]
601
    imul ecx,11
601
    imul ecx,11
602
    mov  [pos],ecx
602
    mov  [pos],ecx
603
 
603
 
604
    mov  bl,13
604
    mov  bl,13
605
    call print_character
605
    call print_character
606
    mov  bl,10
606
    mov  bl,10
607
    call print_character
607
    call print_character
608
 
608
 
609
    cmp  [cmd],2
609
    cmp  [cmd],2
610
    jbe  nott
610
    jbe  nott
611
    mov  ecx,[cmd]
611
    mov  ecx,[cmd]
612
    sub  ecx,2
612
    sub  ecx,2
613
    mov  esi,command+0
613
    mov  esi,command+0
614
  newcmdc:
614
  newcmdc:
615
    mov  bl,[esi]
615
    mov  bl,[esi]
616
    call print_character
616
    call print_character
617
    inc  esi
617
    inc  esi
618
    loop newcmdc
618
    loop newcmdc
619
 
619
 
620
   nott:
620
   nott:
621
 
621
 
622
    mov   edx,I_END
622
    mov   edx,I_END
623
    call  draw_server_data
623
    call  draw_server_data
624
 
624
 
625
  cmd_len_ok:
625
  cmd_len_ok:
626
 
626
 
627
    cmp  [command],dword '-ERR'
627
    cmp  [command],dword '-ERR'
628
    je   close_fetch
628
    je   close_fetch
629
 
629
 
630
    cmp  [command],word '+O'
630
    cmp  [command],word '+O'
631
    jne  nook
631
    jne  nook
632
    mov  [mcounter],990
632
    mov  [mcounter],990
633
  nook:
633
  nook:
634
 
634
 
635
    popa
635
    popa
636
 
636
 
637
    ret
637
    ret
638
 
638
 
639
 
639
 
640
 
640
 
641
draw_data:
641
draw_data:
642
 
642
 
643
    push eax
643
    push eax
644
 
644
 
645
    add  eax,[text_start]
645
    add  eax,[text_start]
646
    mov  [eax],bl
646
    mov  [eax],bl
647
 
647
 
648
    pop  eax
648
    pop  eax
649
    ret
649
    ret
650
 
650
 
651
 
651
 
652
 
652
 
653
print_text:
653
print_text:
654
 
654
 
655
    pusha
655
    pusha
656
 
656
 
657
    mov  ecx,command-2
657
    mov  ecx,command-2
658
    add  ecx,[cmd]
658
    add  ecx,[cmd]
659
 
659
 
660
  ptr2:
660
  ptr2:
661
    mov  bl,[eax]
661
    mov  bl,[eax]
662
    cmp  bl,dl
662
    cmp  bl,dl
663
    je   ptr_ret
663
    je   ptr_ret
664
    cmp  bl,0
664
    cmp  bl,0
665
    je   ptr_ret
665
    je   ptr_ret
666
    call print_character
666
    call print_character
667
    inc  eax
667
    inc  eax
668
    cmp  eax,ecx
668
    cmp  eax,ecx
669
    jbe  ptr2
669
    jbe  ptr2
670
 
670
 
671
  ptr_ret:
671
  ptr_ret:
672
 
672
 
673
    mov  eax,[text_start]
673
    mov  eax,[text_start]
674
    mov  [eax+120*60],byte 1
674
    mov  [eax+120*60],byte 1
675
 
675
 
676
    popa
676
    popa
677
    ret
677
    ret
678
 
678
 
679
 
679
 
680
 
680
 
681
print_character:
681
print_character:
682
 
682
 
683
    pusha
683
    pusha
684
 
684
 
685
    cmp  bl,13     ; line beginning
685
    cmp  bl,13     ; line beginning
686
    jne  nobol
686
    jne  nobol
687
    mov  ecx,[pos]
687
    mov  ecx,[pos]
688
    add  ecx,1
688
    add  ecx,1
689
  boll1:
689
  boll1:
690
    sub  ecx,1
690
    sub  ecx,1
691
    mov  eax,ecx
691
    mov  eax,ecx
692
    xor  edx,edx
692
    xor  edx,edx
693
    mov  ebx,[rxs]
693
    mov  ebx,[rxs]
694
    div  ebx
694
    div  ebx
695
    cmp  edx,0
695
    cmp  edx,0
696
    jne  boll1
696
    jne  boll1
697
    mov  [pos],ecx
697
    mov  [pos],ecx
698
    jmp  newdata
698
    jmp  newdata
699
  nobol:
699
  nobol:
700
 
700
 
701
    cmp  bl,10     ; line down
701
    cmp  bl,10     ; line down
702
    jne  nolf
702
    jne  nolf
703
   addx1:
703
   addx1:
704
    add  [pos],dword 1
704
    add  [pos],dword 1
705
    mov  eax,[pos]
705
    mov  eax,[pos]
706
    xor  edx,edx
706
    xor  edx,edx
707
    mov  ecx,[rxs]
707
    mov  ecx,[rxs]
708
    div  ecx
708
    div  ecx
709
    cmp  edx,0
709
    cmp  edx,0
710
    jnz  addx1
710
    jnz  addx1
711
    mov  eax,[pos]
711
    mov  eax,[pos]
712
    jmp  cm1
712
    jmp  cm1
713
  nolf:
713
  nolf:
714
  no_lf_ret:
714
  no_lf_ret:
715
 
715
 
716
 
716
 
717
    cmp  bl,15    ; character
717
    cmp  bl,15    ; character
718
    jbe  newdata
718
    jbe  newdata
719
 
719
 
720
    mov  eax,[irc_data]
720
    mov  eax,[irc_data]
721
    shl  eax,8
721
    shl  eax,8
722
    mov  al,bl
722
    mov  al,bl
723
    mov  [irc_data],eax
723
    mov  [irc_data],eax
724
 
724
 
725
    mov  eax,[pos]
725
    mov  eax,[pos]
726
    call draw_data
726
    call draw_data
727
 
727
 
728
    mov  eax,[pos]
728
    mov  eax,[pos]
729
    add  eax,1
729
    add  eax,1
730
  cm1:
730
  cm1:
731
    mov  ebx,[scroll+4]
731
    mov  ebx,[scroll+4]
732
    imul ebx,[rxs]
732
    imul ebx,[rxs]
733
    cmp  eax,ebx
733
    cmp  eax,ebx
734
    jb   noeaxz
734
    jb   noeaxz
735
 
735
 
736
    mov  esi,[text_start]
736
    mov  esi,[text_start]
737
    add  esi,[rxs]
737
    add  esi,[rxs]
738
 
738
 
739
    mov  edi,[text_start]
739
    mov  edi,[text_start]
740
    mov  ecx,ebx
740
    mov  ecx,ebx
741
    cld
741
    cld
742
    rep  movsb
742
    rep  movsb
743
 
743
 
744
    mov  esi,[text_start]
744
    mov  esi,[text_start]
745
    mov  ecx,[rxs]
745
    mov  ecx,[rxs]
746
    imul ecx,61
746
    imul ecx,61
747
    add  esi,ecx
747
    add  esi,ecx
748
 
748
 
749
    mov  edi,[text_start]
749
    mov  edi,[text_start]
750
    mov  ecx,[rxs]
750
    mov  ecx,[rxs]
751
    imul ecx,60
751
    imul ecx,60
752
    add  edi,ecx
752
    add  edi,ecx
753
    mov  ecx,ebx
753
    mov  ecx,ebx
754
    cld
754
    cld
755
    rep  movsb
755
    rep  movsb
756
 
756
 
757
    mov  eax,ebx
757
    mov  eax,ebx
758
    sub  eax,[rxs]
758
    sub  eax,[rxs]
759
  noeaxz:
759
  noeaxz:
760
    mov  [pos],eax
760
    mov  [pos],eax
761
 
761
 
762
  newdata:
762
  newdata:
763
 
763
 
764
    mov  eax,[text_start]
764
    mov  eax,[text_start]
765
    mov  [eax+120*60],byte 1
765
    mov  [eax+120*60],byte 1
766
 
766
 
767
    popa
767
    popa
768
    ret
768
    ret
769
 
769
 
770
 
770
 
771
 
771
 
772
read_incoming_byte:
772
read_incoming_byte:
773
 
773
 
774
    mov  eax, 53
774
    mov  eax, 53
775
    mov  ebx, 2
775
    mov  ebx, 2
776
    mov  ecx, [socket]
776
    mov  ecx, [socket]
777
    mcall
777
    mcall
778
 
778
 
779
    mov  ecx,-1
779
    mov  ecx,-1
780
 
780
 
781
    cmp  eax,0
781
    cmp  eax,0
782
    je   no_more_data
782
    je   no_more_data
783
 
783
 
784
    mov  eax, 53
784
    mov  eax, 53
785
    mov  ebx, 3
785
    mov  ebx, 3
786
    mov  ecx, [socket]
786
    mov  ecx, [socket]
787
    mcall
787
    mcall
788
 
788
 
789
    mov  ecx,0
789
    mov  ecx,0
790
 
790
 
791
  no_more_data:
791
  no_more_data:
792
 
792
 
793
    ret
793
    ret
794
 
794
 
795
 
795
 
796
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
796
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
797
;;
797
;;
798
;;  Window definitions
798
;;  Window definitions
799
;;
799
;;
800
 
800
 
801
 
801
 
802
 
802
 
803
draw_window:
803
draw_window:
804
 
804
 
805
    pusha
805
    pusha
806
 
806
 
807
    mov  eax,12
807
    mov  eax,12
808
    mov  ebx,1
808
    mov  ebx,1
809
    mcall
809
    mcall
810
 
810
 
811
    mov  eax,0                     ; draw window
811
    mov  eax,0                     ; draw window
812
    mov  ebx,5*65536+435
812
    mov  ebx,5*65536+435
813
    mov  ecx,5*65536+232
813
    mov  ecx,5*65536+232
814
    mov  edx,0x13ffffff
814
    mov  edx,0x14ffffff
815
    mov  edi,labelt
815
    mov  edi,labelt
816
    mcall
816
    mcall
817
 
817
 
818
    mov  [old_status],300
818
    mov  [old_status],300
819
 
819
 
820
    mov  eax,8                     ; button: open socket
820
    mov  eax,8                     ; button: open socket
821
    mov  ebx,23*65536+22
821
    mov  ebx,23*65536+22
822
    mov  ecx,155*65536+10
822
    mov  ecx,155*65536+10
823
    mov  edx,22
823
    mov  edx,22
824
    mov  esi,0x44cc44
824
    mov  esi,0x44cc44
825
    mcall
825
    mcall
826
 
826
 
827
;    mov  eax,8                     ; button: close socket
827
;    mov  eax,8                     ; button: close socket
828
    mov  ebx,295*65536+22
828
    mov  ebx,295*65536+22
829
    mov  ecx,155*65536+10
829
    mov  ecx,155*65536+10
830
    mov  edx,24
830
    mov  edx,24
831
    mov  esi,0xcc4444
831
    mov  esi,0xcc4444
832
    mcall
832
    mcall
833
 
833
 
834
;    mov  eax,8                     ; button: text entries
834
;    mov  eax,8                     ; button: text entries
835
    mov  ebx,243*65536+8
835
    mov  ebx,243*65536+8
836
    mov  ecx,180*65536+8
836
    mov  ecx,180*65536+8
837
    mov  edx,51
837
    mov  edx,51
838
    mov  esi,0x4488dd
838
    mov  esi,0x4488dd
839
  newi:
839
  newi:
840
    mcall
840
    mcall
841
    inc  edx
841
    inc  edx
842
    add  ecx,12*65536
842
    add  ecx,12*65536
843
    cmp  edx,53
843
    cmp  edx,53
844
    jbe  newi
844
    jbe  newi
845
 
845
 
846
;    mov  eax,8                     ; open inbox
846
;    mov  eax,8                     ; open inbox
847
    mov  ebx,295*65536+102
847
    mov  ebx,295*65536+102
848
    mov  ecx,190*65536+14
848
    mov  ecx,190*65536+14
849
    mov  edx,60
849
    mov  edx,60
850
    mov  esi,0x5577dd
850
    mov  esi,0x5577dd
851
    mcall
851
    mcall
852
 
852
 
853
    mov  eax,38                    ; line
853
    mov  eax,38                    ; line
854
    mov  ebx,5*65536+430
854
    mov  ebx,5*65536+430
855
    mov  ecx,114*65536+114
855
    mov  ecx,114*65536+114
856
    mov  edx,0x000000
856
    mov  edx,0x000000
857
    mcall
857
    mcall
858
 
858
 
859
    mov  ebx,5*65536+133          ; info text
859
    mov  ebx,5*65536+133          ; info text
860
    mov  ecx,0x000000
860
    mov  ecx,0x000000
861
    mov  edx,text
861
    mov  edx,text
862
    mov  esi,70
862
    mov  esi,70
863
  newline:
863
  newline:
864
    mov  eax,4
864
    mov  eax,4
865
    mcall
865
    mcall
866
    add  ebx,12
866
    add  ebx,12
867
    add  edx,70
867
    add  edx,70
868
    cmp  [edx],byte 'x'
868
    cmp  [edx],byte 'x'
869
    jne  newline
869
    jne  newline
870
 
870
 
871
    mov  edx,I_END                ; text from server
871
    mov  edx,I_END                ; text from server
872
    call draw_server_data
872
    call draw_server_data
873
 
873
 
874
    mov  eax,12
874
    mov  eax,12
875
    mov  ebx,2
875
    mov  ebx,2
876
    mcall
876
    mcall
877
 
877
 
878
    popa
878
    popa
879
 
879
 
880
    ret
880
    ret
881
 
881
 
882
 
882
 
883
draw_server_data:
883
draw_server_data:
884
 
884
 
885
    pusha
885
    pusha
886
 
886
 
887
    mov   eax,4
887
    mov   eax,4
888
    mov   ebx,10*65536+26
888
    mov   ebx,10*65536+26
889
    mov   ecx,8
889
    mov   ecx,8
890
    mov   esi,[rxs]
890
    mov   esi,[rxs]
891
  dct:
891
  dct:
892
    pusha
892
    pusha
893
    mov   ecx,ebx
893
    mov   ecx,ebx
894
    shl   ecx,16
894
    shl   ecx,16
895
    mov   cl,9
895
    mov   cl,9
896
    mov   eax,13
896
    mov   eax,13
897
    mov   ebx,10*65536
897
    mov   ebx,10*65536
898
    mov   bx,word [rxs]
898
    mov   bx,word [rxs]
899
    imul  bx,6
899
    imul  bx,6
900
    mov   edx,0xffffff
900
    mov   edx,0xffffff
901
    mcall
901
    mcall
902
    popa
902
    popa
903
    push  ecx
903
    push  ecx
904
    mov   eax,4
904
    mov   eax,4
905
    mov   ecx,0
905
    mov   ecx,0
906
    mcall
906
    mcall
907
    add   edx,[rxs]
907
    add   edx,[rxs]
908
    add   ebx,10
908
    add   ebx,10
909
    pop   ecx
909
    pop   ecx
910
    loop  dct
910
    loop  dct
911
 
911
 
912
    popa
912
    popa
913
    ret
913
    ret
914
 
914
 
915
 
915
 
916
 
916
 
917
text:
917
text:
918
 
918
 
919
db '   Incoming mails are written to /rd/1/popc.txt                       '
919
db '   Incoming mails are written to /rd/1/popc.txt                       '
920
db '                                                                      '
920
db '                                                                      '
921
db '        Check for mail.                               Force close     '
921
db '        Check for mail.                               Force close     '
922
db '                                                                      '
922
db '                                                                      '
923
ip_text:
923
ip_text:
924
db '   Server IP : 192.168.1.200            <                             '
924
db '   Server IP : 192.168.1.200            <                             '
925
l2_text:
925
l2_text:
926
db '   User      :                          <         Open popc.txt       '
926
db '   User      :                          <         Open popc.txt       '
927
 l3_text:
927
 l3_text:
928
db '   Password  : (not shown)              <                             '
928
db '   Password  : (not shown)              <                             '
929
 
929
 
930
db 'x' ; <- END MARKER, DONT DELETE
930
db 'x' ; <- END MARKER, DONT DELETE
931
 
931
 
932
file_start      dd      0x100000
932
file_start      dd      0x100000
933
 
933
 
934
; max size is 0x100000 bytes, read to/write from 0x100000
934
; max size is 0x100000 bytes, read to/write from 0x100000
935
files:
935
files:
936
       dd  2,0,0,?,0x100000
936
       dd  2,0,0,?,0x100000
937
       db  0
937
       db  0
938
       dd  pr
938
       dd  pr
939
filel:
939
filel:
940
       dd  0,0,0,0x100000,0x100000
940
       dd  0,0,0,0x100000,0x100000
941
pr db  '/sys/popc.txt',0
941
pr db  '/sys/popc.txt',0
942
 
942
 
943
ip     db 192,168,1,200
943
ip     db 192,168,1,200
944
 
944
 
945
socket  dd  0x0
945
socket  dd  0x0
946
 
946
 
947
posx             dd  0x0
947
posx             dd  0x0
948
incoming_pos     dd  0x0
948
incoming_pos     dd  0x0
949
incoming_string: times 128 db 0
949
incoming_string: times 128 db 0
950
pos          dd  0x0
950
pos          dd  0x0
951
 
951
 
952
text_start   dd  I_END
952
text_start   dd  I_END
953
print        db  0x0
953
print        db  0x0
954
cmd          dd  0x0
954
cmd          dd  0x0
955
rxs          dd  66
955
rxs          dd  66
956
 
956
 
957
res:         db  0,0
957
res:         db  0,0
958
command:     times  256  db 0x0
958
command:     times  256  db 0x0
959
 
959
 
960
command_position  dd 0
960
command_position  dd 0
961
counter           dd 0
961
counter           dd 0
962
 
962
 
963
numtext      db  '                     '
963
numtext      db  '                     '
964
labelt       db  'POP client v ',version,0
964
labelt       db  'POP client v ',version,0
965
scroll:      dd 1,8
965
scroll:      dd 1,8
966
 
966
 
967
tinypad_start:
967
tinypad_start:
968
        dd      7
968
        dd      7
969
        dd      0
969
        dd      0
970
        dd      pr
970
        dd      pr
971
        dd      0
971
        dd      0
972
        dd      0
972
        dd      0
973
        db      '/sys/TINYPAD',0
973
        db      '/sys/TINYPAD',0
974
 
974
 
975
getmail:
975
getmail:
976
       db  'user xyz                      ',13,10
976
       db  'user xyz                      ',13,10
977
       db  'pass xyz                      ',13,10
977
       db  'pass xyz                      ',13,10
978
       db  'retr 1                        ',13,10
978
       db  'retr 1                        ',13,10
979
       db  'retr 2                        ',13,10
979
       db  'retr 2                        ',13,10
980
       db  'retr 3                        ',13,10
980
       db  'retr 3                        ',13,10
981
       db  'retr 4                        ',13,10
981
       db  'retr 4                        ',13,10
982
       db  'retr 5                        ',13,10
982
       db  'retr 5                        ',13,10
983
       db  'retr 6                        ',13,10
983
       db  'retr 6                        ',13,10
984
       db  'retr 7                        ',13,10
984
       db  'retr 7                        ',13,10
985
       db  'retr 8                        ',13,10
985
       db  'retr 8                        ',13,10
986
       db  'retr 9                        ',13,10
986
       db  'retr 9                        ',13,10
987
 
987
 
988
quitc:
988
quitc:
989
       db  'quit        ',13,10
989
       db  'quit        ',13,10
990
 
990
 
991
mcounter dd 900
991
mcounter dd 900
992
ccounter dd 0
992
ccounter dd 0
993
 
993
 
994
ld   db 13,10
994
ld   db 13,10
995
 
995
 
996
server_active db 0
996
server_active db 0
997
 
997
 
998
header_sent db 0
998
header_sent db 0
999
 
999
 
1000
close_connection   dd 0x0
1000
close_connection   dd 0x0
1001
 
1001
 
1002
mail_rp      dd  0
1002
mail_rp      dd  0
1003
 
1003
 
1004
irc_data   dd  0x0
1004
irc_data   dd  0x0
1005
addr       dd  0x0
1005
addr       dd  0x0
1006
ya         dd  0x0
1006
ya         dd  0x0
1007
len        dd  0x0
1007
len        dd  0x0
1008
 
1008
 
1009
input1:  times 50 db 32
1009
input1:  times 50 db 32
1010
input2:  times 50 db 32
1010
input2:  times 50 db 32
1011
input3:  times 50 db 32
1011
input3:  times 50 db 32
1012
 
1012
 
1013
l1 dd 0
1013
l1 dd 0
1014
l2 dd 3
1014
l2 dd 3
1015
l3 dd 3
1015
l3 dd 3
1016
 
1016
 
1017
status  dd  0x0
1017
status  dd  0x0
1018
 
1018
 
1019
I_END:
1019
I_END: