Subversion Repositories Kolibri OS

Rev

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

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