Subversion Repositories Kolibri OS

Rev

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

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