Subversion Repositories Kolibri OS

Rev

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

Rev 485 Rev 539
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                   ;;
2
;;                                                   ;;
3
;;    SMTP server for MenuetOS                       ;;
3
;;    SMTP server for MenuetOS                       ;;
4
;;                                                   ;;
4
;;                                                   ;;
5
;;    License: GPL / See file COPYING for details    ;;
5
;;    License: GPL / See file COPYING for details    ;;
6
;;    Copyright 2002 (c) Ville Turjanmaa             ;;
6
;;    Copyright 2002 (c) Ville Turjanmaa             ;;
7
;;                                                   ;;
7
;;                                                   ;;
8
;;    Compile with FASM for Menuet                   ;;
8
;;    Compile with FASM for Menuet                   ;;
9
;;                                                   ;;
9
;;                                                   ;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
 
11
 
12
version equ '0.1'
12
version equ '0.1'
13
 
13
 
14
use32
14
use32
15
 
15
 
16
                org     0x0
16
                org     0x0
17
 
17
 
18
                db      'MENUET01'              ; 8 byte id
18
                db      'MENUET01'              ; 8 byte id
19
                dd      0x01                    ; required os
19
                dd      0x01                    ; required os
20
                dd      START                   ; program start
20
                dd      START                   ; program start
21
                dd      I_END                   ; program image size
21
                dd      I_END                   ; program image size
22
                dd      0x200000                ; required amount of memory
22
                dd      0x200000                ; required amount of memory
23
                dd      0xffff0
23
                dd      0xffff0
24
                dd      0,0
24
                dd      0,0
25
 
25
 
26
include '..\..\..\macros.inc'
26
include '..\..\..\macros.inc'
27
 
27
 
28
save_file:
28
save_file:
29
 
29
 
30
;   cmp  [file_start],0x100000+10
30
;   cmp  [file_start],0x100000+10
31
;   jbe  nosub
31
;   jbe  nosub
32
;   sub  [file_start],8
32
;   sub  [file_start],8
33
;  nosub:
33
;  nosub:
34
 
34
 
35
   mov  eax,[file_start]
35
   mov  eax,[file_start]
36
   sub  eax,0x100000
36
   sub  eax,0x100000
37
   mov  ebx,files
37
   mov  ebx,files
38
   mov  [ebx+12],eax
38
   mov  [ebx+12],eax
39
 
39
 
40
   mov  eax,70
40
   mov  eax,70
41
   mcall
41
   mcall
42
 
42
 
43
   ret
43
   ret
44
 
44
 
45
 
45
 
46
START:                          ; start of execution
46
START:                          ; start of execution
47
 
47
 
48
    mov  [file_start],0x100000
48
    mov  [file_start],0x100000
49
 
49
 
50
    mov  eax,70
50
    mov  eax,70
51
    mov  ebx,filel
51
    mov  ebx,filel
52
    mcall
52
    mcall
53
 
53
 
54
    test eax,eax
54
    test eax,eax
55
    jz   @f
55
    jz   @f
56
    cmp  eax,6
56
    cmp  eax,6
57
    jnz  notfound
57
    jnz  notfound
58
@@:
58
@@:
59
    add  [file_start],ebx
59
    add  [file_start],ebx
60
  notfound:
60
  notfound:
61
 
61
 
62
 
62
 
63
    mov  edi,I_END
63
    mov  edi,I_END
64
    mov  ecx,60*120
64
    mov  ecx,60*120
65
    mov  al,32
65
    mov  al,32
66
    cld
66
    cld
67
    rep  stosb
67
    rep  stosb
68
 
68
 
69
    mov  eax,[rxs]
69
    mov  eax,[rxs]
70
    imul eax,11
70
    imul eax,11
71
    mov  [pos],eax
71
    mov  [pos],eax
72
 
72
 
73
    mov  ebp,0
73
    mov  ebp,0
74
    mov  edx,I_END
74
    mov  edx,I_END
75
 
75
 
76
redraw:
76
redraw:
77
    call draw_window            ; at first, draw the window
77
    call draw_window            ; at first, draw the window
78
 
78
 
79
still:
79
still:
80
 
80
 
81
    inc  [cursor_on_off]
81
    inc  [cursor_on_off]
82
 
82
 
83
    mov  eax,5
83
    mov  eax,5
84
    mov  ebx,1
84
    mov  ebx,1
85
    mcall
85
    mcall
86
 
86
 
87
    mov  eax,11                 ; wait here for event
87
    mov  eax,11                 ; wait here for event
88
    mcall
88
    mcall
89
 
89
 
90
    cmp  eax,1                  ; redraw
90
    cmp  eax,1                  ; redraw
91
    je   redraw
91
    je   redraw
92
    cmp  eax,2                  ; key
92
    cmp  eax,2                  ; key
93
    je   key
93
    je   key
94
    cmp  eax,3                  ; button
94
    cmp  eax,3                  ; button
95
    je   button
95
    je   button
96
 
96
 
97
    cmp  [I_END+120*60],byte 1
97
    cmp  [I_END+120*60],byte 1
98
    jne  no_main_update
98
    jne  no_main_update
99
    mov  [I_END+120*60],byte 0
99
    mov  [I_END+120*60],byte 0
100
    mov  edx,I_END
100
    mov  edx,I_END
101
    call draw_channel_text
101
    call draw_channel_text
102
  no_main_update:
102
  no_main_update:
103
 
103
 
104
    cmp  [server_active],0
104
    cmp  [server_active],0
105
    je   noread
105
    je   noread
106
    cmp  [status],4
106
    cmp  [status],4
107
    jne  noread
107
    jne  noread
108
    call read_incoming_data
108
    call read_incoming_data
109
    inc  [close_connection]
109
    inc  [close_connection]
110
    cmp  [close_connection],15*100
110
    cmp  [close_connection],15*100
111
    jbe  noread
111
    jbe  noread
112
 
112
 
113
    call yq
113
    call yq
114
 
114
 
115
  noread:
115
  noread:
116
 
116
 
117
    call print_status
117
    call print_status
118
 
118
 
119
    cmp  [status],4
119
    cmp  [status],4
120
    je   check_header
120
    je   check_header
121
 
121
 
122
    jmp  still
122
    jmp  still
123
 
123
 
124
 
124
 
125
check_header:
125
check_header:
126
 
126
 
127
    cmp [header_sent],1
127
    cmp [header_sent],1
128
    je  still
128
    je  still
129
 
129
 
130
    mov  eax,53
130
    mov  eax,53
131
    mov  ebx,7
131
    mov  ebx,7
132
    mov  ecx,[socket]
132
    mov  ecx,[socket]
133
    mov  edx,6
133
    mov  edx,6
134
    mov  esi,r220
134
    mov  esi,r220
135
    mcall
135
    mcall
136
    mov  [header_sent],1
136
    mov  [header_sent],1
137
 
137
 
138
    jmp  still
138
    jmp  still
139
 
139
 
140
 
140
 
141
button:                         ; button
141
button:                         ; button
142
 
142
 
143
    mov  eax,17                 ; get id
143
    mov  eax,17                 ; get id
144
    mcall
144
    mcall
145
 
145
 
146
    cmp  ah,1                   ; close program
146
    cmp  ah,1                   ; close program
147
    jne  noclose
147
    jne  noclose
148
    or   eax,-1
148
    or   eax,-1
149
    mcall
149
    mcall
150
  noclose:
150
  noclose:
151
 
151
 
152
    call socket_commands
152
    call socket_commands
153
 
153
 
154
    jmp  still
154
    jmp  still
155
 
155
 
156
 
156
 
157
old_status dd 0x0
157
old_status dd 0x0
158
 
158
 
159
print_status:
159
print_status:
160
 
160
 
161
    pusha
161
    pusha
162
 
162
 
163
    mov  eax,53
163
    mov  eax,53
164
    mov  ebx,6
164
    mov  ebx,6
165
    mov  ecx,[socket]
165
    mov  ecx,[socket]
166
    mcall
166
    mcall
167
 
167
 
168
    mov  [status],eax
168
    mov  [status],eax
169
 
169
 
170
    cmp  eax,[old_status]
170
    cmp  eax,[old_status]
171
    je   no_print
171
    je   no_print
172
 
172
 
173
    mov  [old_status],eax
173
    mov  [old_status],eax
174
 
174
 
175
    push eax
175
    push eax
176
 
176
 
177
    mov  eax,13
177
    mov  eax,13
178
    mov  ebx,360*65536+30
178
    mov  ebx,360*65536+30
179
    mov  ecx,151*65536+10
179
    mov  ecx,151*65536+10
180
    mov  edx,0xffffff
180
    mov  edx,0xffffff
181
    mcall
181
    mcall
182
 
182
 
183
    pop  ecx
183
    pop  ecx
184
    mov  eax,47
184
    mov  eax,47
185
    mov  ebx,3*65536
185
    mov  ebx,3*65536
186
    mov  edx,360*65536+151
186
    mov  edx,360*65536+151
187
    mov  esi,0x000000
187
    mov  esi,0x000000
188
 
188
 
189
    cmp  [server_active],0
189
    cmp  [server_active],0
190
    je   no_print
190
    je   no_print
191
 
191
 
192
    mcall
192
    mcall
193
 
193
 
194
  no_print:
194
  no_print:
195
 
195
 
196
    popa
196
    popa
197
 
197
 
198
    ret
198
    ret
199
 
199
 
200
 
200
 
201
socket_commands:
201
socket_commands:
202
 
202
 
203
    cmp  ah,22       ; open socket
203
    cmp  ah,22       ; open socket
204
    jnz  tst3
204
    jnz  tst3
205
    mov  eax,3
205
    mov  eax,3
206
    mcall
206
    mcall
207
 
207
 
208
    mov  [server_active],1
208
    mov  [server_active],1
209
 
209
 
210
    mov  eax,53
210
    mov  eax,53
211
    mov  ebx,5
211
    mov  ebx,5
212
    mov  ecx,25     ; local port # - http
212
    mov  ecx,25     ; local port # - http
213
    mov  edx,0      ; no remote port specified
213
    mov  edx,0      ; no remote port specified
214
    mov  esi,0      ; no remote ip specified
214
    mov  esi,0      ; no remote ip specified
215
    mov  edi,0      ; PASSIVE open
215
    mov  edi,0      ; PASSIVE open
216
    mcall
216
    mcall
217
    mov  [socket], eax
217
    mov  [socket], eax
218
 
218
 
219
    ret
219
    ret
220
  tst3:
220
  tst3:
221
 
221
 
222
 
222
 
223
    cmp  ah,24     ; close socket
223
    cmp  ah,24     ; close socket
224
    jnz  no_24
224
    jnz  no_24
225
    mov  eax,53
225
    mov  eax,53
226
    mov  ebx,8
226
    mov  ebx,8
227
    mov  ecx,[socket]
227
    mov  ecx,[socket]
228
    mcall
228
    mcall
229
    mov  [header_sent],0
229
    mov  [header_sent],0
230
    mov  [mail_rp],0
230
    mov  [mail_rp],0
231
    mov  [server_active],0
231
    mov  [server_active],0
232
 
232
 
233
    ret
233
    ret
234
  no_24:
234
  no_24:
235
 
235
 
236
 
236
 
237
    ret
237
    ret
238
 
238
 
239
 
239
 
240
 
240
 
241
key:
241
key:
242
 
242
 
243
    mov  eax,2
243
    mov  eax,2
244
    mcall
244
    mcall
245
 
245
 
246
    jmp  still
246
    jmp  still
247
 
247
 
248
 
248
 
249
 
249
 
250
read_incoming_data:
250
read_incoming_data:
251
 
251
 
252
    pusha
252
    pusha
253
 
253
 
254
  read_new_byte:
254
  read_new_byte:
255
 
255
 
256
    call read_incoming_byte
256
    call read_incoming_byte
257
    cmp  ecx,-1
257
    cmp  ecx,-1
258
    je   no_data_in_buffer
258
    je   no_data_in_buffer
259
 
259
 
260
    mov  eax,[file_start]
260
    mov  eax,[file_start]
261
    mov  [eax],bl
261
    mov  [eax],bl
262
    inc  [file_start]
262
    inc  [file_start]
263
 
263
 
264
    cmp  bl,10
264
    cmp  bl,10
265
    jne  no_start_command
265
    jne  no_start_command
266
    mov  [cmd],1
266
    mov  [cmd],1
267
  no_start_command:
267
  no_start_command:
268
 
268
 
269
    cmp  bl,13
269
    cmp  bl,13
270
    jne  no_end_command
270
    jne  no_end_command
271
    mov  eax,[cmd]
271
    mov  eax,[cmd]
272
    mov  [eax+command-2],byte 0
272
    mov  [eax+command-2],byte 0
273
    call analyze_command
273
    call analyze_command
274
    mov  edi,command
274
    mov  edi,command
275
    mov  ecx,250
275
    mov  ecx,250
276
    mov  eax,0
276
    mov  eax,0
277
    cld
277
    cld
278
    rep  stosb
278
    rep  stosb
279
    mov  [cmd],0
279
    mov  [cmd],0
280
  no_end_command:
280
  no_end_command:
281
 
281
 
282
    mov  eax,[cmd]
282
    mov  eax,[cmd]
283
    cmp  eax,250
283
    cmp  eax,250
284
    jge  still
284
    jge  still
285
 
285
 
286
    mov  [eax+command-2],bl
286
    mov  [eax+command-2],bl
287
    inc  [cmd]
287
    inc  [cmd]
288
 
288
 
289
    jmp  read_new_byte
289
    jmp  read_new_byte
290
 
290
 
291
  no_data_in_buffer:
291
  no_data_in_buffer:
292
 
292
 
293
    popa
293
    popa
294
 
294
 
295
    ret
295
    ret
296
 
296
 
297
 
297
 
298
 
298
 
299
 
299
 
300
 
300
 
301
analyze_command:
301
analyze_command:
302
 
302
 
303
    pusha
303
    pusha
304
 
304
 
305
    mov  [text_start],I_END
305
    mov  [text_start],I_END
306
    mov  ecx,[rxs]
306
    mov  ecx,[rxs]
307
    imul ecx,11
307
    imul ecx,11
308
    mov  [pos],ecx
308
    mov  [pos],ecx
309
 
309
 
310
    mov  bl,13
310
    mov  bl,13
311
    call print_character
311
    call print_character
312
    mov  bl,10
312
    mov  bl,10
313
    call print_character
313
    call print_character
314
 
314
 
315
    cmp  [cmd],2
315
    cmp  [cmd],2
316
    jbe  nott
316
    jbe  nott
317
    mov  ecx,[cmd]
317
    mov  ecx,[cmd]
318
    sub  ecx,2
318
    sub  ecx,2
319
    mov  esi,command+0
319
    mov  esi,command+0
320
  newcmdc:
320
  newcmdc:
321
    mov  bl,[esi]
321
    mov  bl,[esi]
322
    call print_character
322
    call print_character
323
    inc  esi
323
    inc  esi
324
    loop newcmdc
324
    loop newcmdc
325
 
325
 
326
   nott:
326
   nott:
327
 
327
 
328
    mov   edx,I_END
328
    mov   edx,I_END
329
    call  draw_channel_text
329
    call  draw_channel_text
330
 
330
 
331
  cmd_len_ok:
331
  cmd_len_ok:
332
 
332
 
333
    cmp  [command],dword 'data'
333
    cmp  [command],dword 'data'
334
    je   datacom
334
    je   datacom
335
    cmp  [command],dword 'DATA'
335
    cmp  [command],dword 'DATA'
336
    je   datacom
336
    je   datacom
337
    cmp  [command],dword 'Data'
337
    cmp  [command],dword 'Data'
338
    je   datacom
338
    je   datacom
339
    jmp  nodatacom
339
    jmp  nodatacom
340
  datacom:
340
  datacom:
341
    inc  [mail_rp]
341
    inc  [mail_rp]
342
    mov  eax,53
342
    mov  eax,53
343
    mov  ebx,7
343
    mov  ebx,7
344
    mov  ecx,[socket]
344
    mov  ecx,[socket]
345
    mov  edx,6
345
    mov  edx,6
346
    mov  esi,r354
346
    mov  esi,r354
347
    mcall
347
    mcall
348
    mov  [cmd],0
348
    mov  [cmd],0
349
    popa
349
    popa
350
    ret
350
    ret
351
 
351
 
352
  nodatacom:
352
  nodatacom:
353
 
353
 
354
    cmp  [mail_rp],0
354
    cmp  [mail_rp],0
355
    jne  nomrp0
355
    jne  nomrp0
356
    mov  eax,53
356
    mov  eax,53
357
    mov  ebx,7
357
    mov  ebx,7
358
    mov  ecx,[socket]
358
    mov  ecx,[socket]
359
    mov  edx,6
359
    mov  edx,6
360
    mov  esi,r250
360
    mov  esi,r250
361
    mcall
361
    mcall
362
    mov  [cmd],0
362
    mov  [cmd],0
363
    popa
363
    popa
364
    ret
364
    ret
365
  nomrp0:
365
  nomrp0:
366
 
366
 
367
 
367
 
368
 
368
 
369
    cmp  [command],dword 'QUIT'
369
    cmp  [command],dword 'QUIT'
370
    je   yesquit
370
    je   yesquit
371
    cmp  [command],dword 'Quit'
371
    cmp  [command],dword 'Quit'
372
    je   yesquit
372
    je   yesquit
373
    cmp  [command],dword 'quit'
373
    cmp  [command],dword 'quit'
374
    je   yesquit
374
    je   yesquit
375
    jmp  noquit
375
    jmp  noquit
376
  yq:
376
  yq:
377
     pusha
377
     pusha
378
 
378
 
379
  yesquit:
379
  yesquit:
380
 
380
 
381
    mov  [close_connection],0
381
    mov  [close_connection],0
382
 
382
 
383
    mov  eax,53
383
    mov  eax,53
384
    mov  ebx,7
384
    mov  ebx,7
385
    mov  ecx,[socket]
385
    mov  ecx,[socket]
386
    mov  edx,6
386
    mov  edx,6
387
    mov  esi,r221
387
    mov  esi,r221
388
    mcall
388
    mcall
389
    mov  [cmd],0
389
    mov  [cmd],0
390
 
390
 
391
    mov  eax,5
391
    mov  eax,5
392
    mov  ebx,5
392
    mov  ebx,5
393
    mcall
393
    mcall
394
 
394
 
395
    mov  eax,53
395
    mov  eax,53
396
    mov  ebx,8
396
    mov  ebx,8
397
    mov  ecx,[socket]
397
    mov  ecx,[socket]
398
    mcall
398
    mcall
399
 
399
 
400
    mov  eax,5
400
    mov  eax,5
401
    mov  ebx,5
401
    mov  ebx,5
402
    mcall
402
    mcall
403
 
403
 
404
    mov  eax,53
404
    mov  eax,53
405
    mov  ebx,8
405
    mov  ebx,8
406
    mov  ecx,[socket]
406
    mov  ecx,[socket]
407
    mcall
407
    mcall
408
 
408
 
409
    mov  [header_sent],0
409
    mov  [header_sent],0
410
    mov  [mail_rp],0
410
    mov  [mail_rp],0
411
 
411
 
412
    call save_file
412
    call save_file
413
 
413
 
414
    mov  eax,5
414
    mov  eax,5
415
    mov  ebx,20
415
    mov  ebx,20
416
    mcall
416
    mcall
417
 
417
 
418
    mov  eax,53
418
    mov  eax,53
419
    mov  ebx,5
419
    mov  ebx,5
420
    mov  ecx,25     ; local port # - http
420
    mov  ecx,25     ; local port # - http
421
    mov  edx,0      ; no remote port specified
421
    mov  edx,0      ; no remote port specified
422
    mov  esi,0      ; no remote ip specified
422
    mov  esi,0      ; no remote ip specified
423
    mov  edi,0      ; PASSIVE open
423
    mov  edi,0      ; PASSIVE open
424
    mcall
424
    mcall
425
    mov  [socket], eax
425
    mov  [socket], eax
426
 
426
 
427
    popa
427
    popa
428
    ret
428
    ret
429
  noquit:
429
  noquit:
430
 
430
 
431
 
431
 
432
 
432
 
433
    cmp  [command],byte '.'
433
    cmp  [command],byte '.'
434
    jne  nodot
434
    jne  nodot
435
    mov  eax,53
435
    mov  eax,53
436
    mov  ebx,7
436
    mov  ebx,7
437
    mov  ecx,[socket]
437
    mov  ecx,[socket]
438
    mov  edx,6
438
    mov  edx,6
439
    mov  esi,r250
439
    mov  esi,r250
440
    mcall
440
    mcall
441
    mov  [cmd],0
441
    mov  [cmd],0
442
    popa
442
    popa
443
    ret
443
    ret
444
  nodot:
444
  nodot:
445
 
445
 
446
    popa
446
    popa
447
    ret
447
    ret
448
 
448
 
449
 
449
 
450
r250  db  '250 ',13,10
450
r250  db  '250 ',13,10
451
r221  db  '221 ',13,10
451
r221  db  '221 ',13,10
452
r220  db  '220 ',13,10
452
r220  db  '220 ',13,10
453
r354  db  '354 ',13,10
453
r354  db  '354 ',13,10
454
 
454
 
455
 
455
 
456
 
456
 
457
draw_data:
457
draw_data:
458
 
458
 
459
    pusha
459
    pusha
460
 
460
 
461
    add  eax,[text_start]
461
    add  eax,[text_start]
462
    mov  [eax],bl
462
    mov  [eax],bl
463
 
463
 
464
    popa
464
    popa
465
    ret
465
    ret
466
 
466
 
467
 
467
 
468
 
468
 
469
 
469
 
470
print_text:
470
print_text:
471
 
471
 
472
    pusha
472
    pusha
473
 
473
 
474
    mov  ecx,command-2
474
    mov  ecx,command-2
475
    add  ecx,[cmd]
475
    add  ecx,[cmd]
476
 
476
 
477
  ptr2:
477
  ptr2:
478
    mov  bl,[eax]
478
    mov  bl,[eax]
479
    cmp  bl,dl
479
    cmp  bl,dl
480
    je   ptr_ret
480
    je   ptr_ret
481
    cmp  bl,0
481
    cmp  bl,0
482
    je   ptr_ret
482
    je   ptr_ret
483
    call print_character
483
    call print_character
484
    inc  eax
484
    inc  eax
485
    cmp  eax,ecx
485
    cmp  eax,ecx
486
    jbe  ptr2
486
    jbe  ptr2
487
 
487
 
488
  ptr_ret:
488
  ptr_ret:
489
 
489
 
490
    mov  eax,[text_start]
490
    mov  eax,[text_start]
491
    mov  [eax+120*60],byte 1
491
    mov  [eax+120*60],byte 1
492
 
492
 
493
    popa
493
    popa
494
    ret
494
    ret
495
 
495
 
496
 
496
 
497
 
497
 
498
print_character:
498
print_character:
499
 
499
 
500
    pusha
500
    pusha
501
 
501
 
502
    cmp  bl,13     ; line beginning
502
    cmp  bl,13     ; line beginning
503
    jne  nobol
503
    jne  nobol
504
    mov  ecx,[pos]
504
    mov  ecx,[pos]
505
    add  ecx,1
505
    add  ecx,1
506
  boll1:
506
  boll1:
507
    sub  ecx,1
507
    sub  ecx,1
508
    mov  eax,ecx
508
    mov  eax,ecx
509
    xor  edx,edx
509
    xor  edx,edx
510
    mov  ebx,[rxs]
510
    mov  ebx,[rxs]
511
    div  ebx
511
    div  ebx
512
    cmp  edx,0
512
    cmp  edx,0
513
    jne  boll1
513
    jne  boll1
514
    mov  [pos],ecx
514
    mov  [pos],ecx
515
    jmp  newdata
515
    jmp  newdata
516
  nobol:
516
  nobol:
517
 
517
 
518
    cmp  bl,10     ; line down
518
    cmp  bl,10     ; line down
519
    jne  nolf
519
    jne  nolf
520
   addx1:
520
   addx1:
521
    add  [pos],dword 1
521
    add  [pos],dword 1
522
    mov  eax,[pos]
522
    mov  eax,[pos]
523
    xor  edx,edx
523
    xor  edx,edx
524
    mov  ecx,[rxs]
524
    mov  ecx,[rxs]
525
    div  ecx
525
    div  ecx
526
    cmp  edx,0
526
    cmp  edx,0
527
    jnz  addx1
527
    jnz  addx1
528
    mov  eax,[pos]
528
    mov  eax,[pos]
529
    jmp  cm1
529
    jmp  cm1
530
  nolf:
530
  nolf:
531
  no_lf_ret:
531
  no_lf_ret:
532
 
532
 
533
 
533
 
534
    cmp  bl,15    ; character
534
    cmp  bl,15    ; character
535
    jbe  newdata
535
    jbe  newdata
536
 
536
 
537
    mov  eax,[irc_data]
537
    mov  eax,[irc_data]
538
    shl  eax,8
538
    shl  eax,8
539
    mov  al,bl
539
    mov  al,bl
540
    mov  [irc_data],eax
540
    mov  [irc_data],eax
541
 
541
 
542
    mov  eax,[pos]
542
    mov  eax,[pos]
543
    call draw_data
543
    call draw_data
544
 
544
 
545
    mov  eax,[pos]
545
    mov  eax,[pos]
546
    add  eax,1
546
    add  eax,1
547
  cm1:
547
  cm1:
548
    mov  ebx,[scroll+4]
548
    mov  ebx,[scroll+4]
549
    imul ebx,[rxs]
549
    imul ebx,[rxs]
550
    cmp  eax,ebx
550
    cmp  eax,ebx
551
    jb   noeaxz
551
    jb   noeaxz
552
 
552
 
553
    mov  esi,[text_start]
553
    mov  esi,[text_start]
554
    add  esi,[rxs]
554
    add  esi,[rxs]
555
 
555
 
556
    mov  edi,[text_start]
556
    mov  edi,[text_start]
557
    mov  ecx,ebx
557
    mov  ecx,ebx
558
    cld
558
    cld
559
    rep  movsb
559
    rep  movsb
560
 
560
 
561
    mov  esi,[text_start]
561
    mov  esi,[text_start]
562
    mov  ecx,[rxs]
562
    mov  ecx,[rxs]
563
    imul ecx,61
563
    imul ecx,61
564
    add  esi,ecx
564
    add  esi,ecx
565
 
565
 
566
    mov  edi,[text_start]
566
    mov  edi,[text_start]
567
    mov  ecx,[rxs]
567
    mov  ecx,[rxs]
568
    imul ecx,60
568
    imul ecx,60
569
    add  edi,ecx
569
    add  edi,ecx
570
    mov  ecx,ebx
570
    mov  ecx,ebx
571
    cld
571
    cld
572
    rep  movsb
572
    rep  movsb
573
 
573
 
574
    mov  eax,ebx
574
    mov  eax,ebx
575
    sub  eax,[rxs]
575
    sub  eax,[rxs]
576
  noeaxz:
576
  noeaxz:
577
    mov  [pos],eax
577
    mov  [pos],eax
578
 
578
 
579
  newdata:
579
  newdata:
580
 
580
 
581
    mov  eax,[text_start]
581
    mov  eax,[text_start]
582
    mov  [eax+120*60],byte 1
582
    mov  [eax+120*60],byte 1
583
 
583
 
584
    popa
584
    popa
585
    ret
585
    ret
586
 
586
 
587
 
587
 
588
 
588
 
589
read_incoming_byte:
589
read_incoming_byte:
590
 
590
 
591
    mov  eax, 53
591
    mov  eax, 53
592
    mov  ebx, 2
592
    mov  ebx, 2
593
    mov  ecx, [socket]
593
    mov  ecx, [socket]
594
    mcall
594
    mcall
595
 
595
 
596
    mov  ecx,-1
596
    mov  ecx,-1
597
 
597
 
598
    cmp  eax,0
598
    cmp  eax,0
599
    je   no_more_data
599
    je   no_more_data
600
 
600
 
601
    mov  eax, 53
601
    mov  eax, 53
602
    mov  ebx, 3
602
    mov  ebx, 3
603
    mov  ecx, [socket]
603
    mov  ecx, [socket]
604
    mcall
604
    mcall
605
 
605
 
606
    mov  ecx,0
606
    mov  ecx,0
607
 
607
 
608
  no_more_data:
608
  no_more_data:
609
 
609
 
610
    ret
610
    ret
611
 
611
 
612
 
612
 
613
 
613
 
614
draw_window:
614
draw_window:
615
 
615
 
616
    pusha
616
    pusha
617
 
617
 
618
    mov  eax,12
618
    mov  eax,12
619
    mov  ebx,1
619
    mov  ebx,1
620
    mcall
620
    mcall
621
 
621
 
622
    mov  [old_status],300
622
    mov  [old_status],300
623
 
623
 
624
    mov  eax,0                     ; draw window
624
    mov  eax,0                     ; draw window
625
    mov  ebx,5*65536+400
625
    mov  ebx,5*65536+400
626
    mov  ecx,5*65536+200
626
    mov  ecx,5*65536+200
627
    mov  edx,0x13ffffff
627
    mov  edx,0x13ffffff
628
    mov  edi,title
628
    mov  edi,title
629
    mcall
629
    mcall
630
 
630
 
631
    mov  eax,8                     ; button: open socket
631
    mov  eax,8                     ; button: open socket
632
    mov  ebx,23*65536+22
632
    mov  ebx,23*65536+22
633
    mov  ecx,169*65536+10
633
    mov  ecx,169*65536+10
634
    mov  edx,22
634
    mov  edx,22
635
    mov  esi,0x55aa55
635
    mov  esi,0x55aa55
636
    mcall
636
    mcall
637
 
637
 
638
 ;   mov  eax,8                     ; button: close socket
638
 ;   mov  eax,8                     ; button: close socket
639
    mov  ebx,265*65536+22
639
    mov  ebx,265*65536+22
640
    mov  edx,24
640
    mov  edx,24
641
    mov  esi,0xaa5555
641
    mov  esi,0xaa5555
642
    mcall
642
    mcall
643
 
643
 
644
    mov  eax,38                    ; line
644
    mov  eax,38                    ; line
645
    mov  ebx,5*65536+395
645
    mov  ebx,5*65536+395
646
    mov  ecx,108*65536+108
646
    mov  ecx,108*65536+108
647
    mov  edx,0x000000
647
    mov  edx,0x000000
648
    mcall
648
    mcall
649
 
649
 
650
    mov  eax,4
650
    mov  eax,4
651
    mov  ebx,5*65536+123          ; info text
651
    mov  ebx,5*65536+123          ; info text
652
    mov  ecx,0x000000
652
    mov  ecx,0x000000
653
    mov  edx,text
653
    mov  edx,text
654
    mov  esi,70
654
    mov  esi,70
655
  newline:
655
  newline:
656
    mcall
656
    mcall
657
    add  ebx,12
657
    add  ebx,12
658
    add  edx,70
658
    add  edx,70
659
    cmp  [edx],byte 'x'
659
    cmp  [edx],byte 'x'
660
    jne  newline
660
    jne  newline
661
 
661
 
662
    mov  edx,I_END                ; text from server
662
    mov  edx,I_END                ; text from server
663
    call draw_channel_text
663
    call draw_channel_text
664
 
664
 
665
    mov  eax,12
665
    mov  eax,12
666
    mov  ebx,2
666
    mov  ebx,2
667
    mcall
667
    mcall
668
 
668
 
669
    popa
669
    popa
670
 
670
 
671
    ret
671
    ret
672
 
672
 
673
 
673
 
674
 
674
 
675
 
675
 
676
 
676
 
677
draw_channel_text:
677
draw_channel_text:
678
 
678
 
679
    pusha
679
    pusha
680
 
680
 
681
    mov   eax,4
681
    mov   eax,4
682
    mov   ebx,10*65536+26
682
    mov   ebx,10*65536+26
683
    mov   ecx,[scroll+4]
683
    mov   ecx,[scroll+4]
684
    mov   esi,[rxs]
684
    mov   esi,[rxs]
685
  dct:
685
  dct:
686
    pusha
686
    pusha
687
    mov   cx,bx
687
    mov   cx,bx
688
    shl   ecx,16
688
    shl   ecx,16
689
    mov   cx,9
689
    mov   cx,9
690
    mov   eax,13
690
    mov   eax,13
691
    mov   ebx,10*65536
691
    mov   ebx,10*65536
692
    mov   bx,word [rxs]
692
    mov   bx,word [rxs]
693
    imul  bx,6
693
    imul  bx,6
694
    mov   edx,0xffffff
694
    mov   edx,0xffffff
695
    mcall
695
    mcall
696
    popa
696
    popa
697
    push  ecx
697
    push  ecx
698
    mov   eax,4
698
    mov   eax,4
699
    mov   ecx,0
699
    mov   ecx,0
700
    cmp   [edx],word '* '
700
    cmp   [edx],word '* '
701
    jne   no_red
701
    jne   no_red
702
    mov   ecx,0xff0000
702
    mov   ecx,0xff0000
703
   no_red:
703
   no_red:
704
    cmp   [edx],word '**'
704
    cmp   [edx],word '**'
705
    jne   no_light_blue
705
    jne   no_light_blue
706
    cmp   [edx+2],byte '*'
706
    cmp   [edx+2],byte '*'
707
    jne   no_light_blue
707
    jne   no_light_blue
708
    mov   ecx,0x0000ff
708
    mov   ecx,0x0000ff
709
  no_light_blue:
709
  no_light_blue:
710
    cmp   [edx],byte '#'
710
    cmp   [edx],byte '#'
711
    jne   no_blue
711
    jne   no_blue
712
    mov   ecx,0x00ff00
712
    mov   ecx,0x00ff00
713
  no_blue:
713
  no_blue:
714
    mcall
714
    mcall
715
    add   edx,[rxs]
715
    add   edx,[rxs]
716
    add   ebx,10
716
    add   ebx,10
717
    pop   ecx
717
    pop   ecx
718
    loop  dct
718
    loop  dct
719
 
719
 
720
    popa
720
    popa
721
    ret
721
    ret
722
 
722
 
723
 
723
 
724
 
724
 
725
text:
725
text:
726
 
726
 
727
db '   Incoming mails are written to /rd/1/smtps.txt                      '
727
db '   Incoming mails are written to /sys/smtps.txt                       '
728
db '   The file can be fetched with TinyServer and a Html-browser.        '
728
db '   The file can be fetched with TinyServer and a Html-browser.        '
729
db '   Timeout is set to 15 seconds.                                      '
729
db '   Timeout is set to 15 seconds.                                      '
730
db '                                                                      '
730
db '                                                                      '
731
db '        Open SMTP server port 25                Close SMTP            '
731
db '        Open SMTP server port 25                Close SMTP            '
732
db 'x' ; <- END MARKER, DONT DELETE
732
db 'x' ; <- END MARKER, DONT DELETE
733
 
733
 
734
 
734
 
735
irc_server_ip   db      192,168,1,1
735
irc_server_ip   db      192,168,1,1
736
 
736
 
737
file_start      dd      0x100000
737
file_start      dd      0x100000
738
 
738
 
739
files:
739
files:
740
       dd  2,0,0,?,0x100000
740
       dd  2,0,0,?,0x100000
741
       db  '/rd/1/smtps.txt',0
741
       db  '/sys/smtps.txt',0
742
filel:
742
filel:
743
       dd  0,0,0,0x100000,0x100000
743
       dd  0,0,0,0x100000,0x100000
744
       db  '/rd/1/smtps.txt',0
744
       db  '/sys/smtps.txt',0
745
 
745
 
746
 
746
 
747
server_active dd 0
747
server_active dd 0
748
 
748
 
749
status  dd  0x0
749
status  dd  0x0
750
header_sent db 0
750
header_sent db 0
751
 
751
 
752
channel_temp:         times   100   db   0
752
channel_temp:         times   100   db   0
753
channel_temp_length   dd      0x0
753
channel_temp_length   dd      0x0
754
 
754
 
755
close_connection   dd 0x0
755
close_connection   dd 0x0
756
 
756
 
757
mail_rp      dd  0
757
mail_rp      dd  0
758
 
758
 
759
socket  dd  0x0
759
socket  dd  0x0
760
 
760
 
761
bgc  dd  0x000000
761
bgc  dd  0x000000
762
     dd  0x000000
762
     dd  0x000000
763
     dd  0x00ff00
763
     dd  0x00ff00
764
     dd  0x0000ff
764
     dd  0x0000ff
765
     dd  0x005500
765
     dd  0x005500
766
     dd  0xff00ff
766
     dd  0xff00ff
767
     dd  0x00ffff
767
     dd  0x00ffff
768
     dd  0x770077
768
     dd  0x770077
769
 
769
 
770
tc   dd  0xffffff
770
tc   dd  0xffffff
771
     dd  0xff00ff
771
     dd  0xff00ff
772
     dd  0xffffff
772
     dd  0xffffff
773
     dd  0xffffff
773
     dd  0xffffff
774
     dd  0xffffff
774
     dd  0xffffff
775
     dd  0xffffff
775
     dd  0xffffff
776
     dd  0xffffff
776
     dd  0xffffff
777
     dd  0xffffff
777
     dd  0xffffff
778
 
778
 
779
cursor_on_off  dd  0x0
779
cursor_on_off  dd  0x0
780
 
780
 
781
max_windows    dd  20
781
max_windows    dd  20
782
 
782
 
783
thread_stack   dd  0x9fff0
783
thread_stack   dd  0x9fff0
784
thread_nro     dd 1
784
thread_nro     dd 1
785
thread_screen  dd I_END+120*80*1
785
thread_screen  dd I_END+120*80*1
786
 
786
 
787
action_header_blue  db  10,'*** ',0
787
action_header_blue  db  10,'*** ',0
788
action_header_red   db  10,'*** ',0
788
action_header_red   db  10,'*** ',0
789
 
789
 
790
action_header_short db  10,'* ',0
790
action_header_short db  10,'* ',0
791
 
791
 
792
posx             dd  0x0
792
posx             dd  0x0
793
incoming_pos     dd  0x0
793
incoming_pos     dd  0x0
794
incoming_string: times 128 db 0
794
incoming_string: times 128 db 0
795
 
795
 
796
pos          dd  0x0
796
pos          dd  0x0
797
 
797
 
798
text_start   dd  I_END
798
text_start   dd  I_END
799
irc_data     dd  0x0
799
irc_data     dd  0x0
800
print        db  0x0
800
print        db  0x0
801
cmd          dd  0x0
801
cmd          dd  0x0
802
rxs          dd  56
802
rxs          dd  56
803
 
803
 
804
res:         db  0,0
804
res:         db  0,0
805
command:     times  256  db 0x0
805
command:     times  256  db 0x0
806
 
806
 
807
nick         dd  0,0,0
807
nick         dd  0,0,0
808
irc_command  dd  0,0
808
irc_command  dd  0,0
809
 
809
 
810
command_position  dd 0x0
810
command_position  dd 0x0
811
counter           dd  0
811
counter           dd  0
812
send_to_server    db 0
812
send_to_server    db 0
813
 
813
 
814
channel_list:     times 32*20 db 32
814
channel_list:     times 32*20 db 32
815
send_to_channel   dd 0x0
815
send_to_channel   dd 0x0
816
 
816
 
817
send_string:         times  100  db  0x0
817
send_string:         times  100  db  0x0
818
 
818
 
819
xpos        dd  0
819
xpos        dd  0
820
attribute   dd  0
820
attribute   dd  0
821
scroll      dd  1
821
scroll      dd  1
822
            dd  8
822
            dd  8
823
 
823
 
824
numtext     db  '                     '
824
numtext     db  '                     '
825
 
825
 
826
title       db  'Tiny SMTP email server v ',version,0
826
title       db  'Tiny SMTP email server v ',version,0
827
 
827
 
828
I_END:
828
I_END: