Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 153
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;                                                      ;
2
;                                                      ;
3
;    Tiny HTTP Server v 0.4 for MenuetOS               ;
3
;    Tiny HTTP Server v 0.5 for KolibriOS              ;
4
;                                                      ;
4
;                                                      ;
5
;    License GPL / See file COPYING for details.       ;
5
;    License GPL / See file COPYING for details.       ;
6
;    Copyright 2003 Ville Turjanmaa                    ;
6
;    Copyright 2003 Ville Turjanmaa                    ;
7
;                                                      ;
7
;                                                      ;
8
;    Compile with FASM for Menuet                      ;
8
;    Compile with FASM for Menuet/KolibriOS            ;
9
;                                                      ;
9
;                                                      ;
10
;    Request /TinyStat for server statistics           ;
10
;    Request /TinyStat for server statistics           ;
11
;    Request /TinyBoard for server message board       ;
11
;    Request /TinyBoard for server message board       ;
12
;                                                      ;
12
;                                                      ;
-
 
13
;    Special version for KoOS by Hex && Heavyiron      ;
-
 
14
;                                                      ;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line -... Line 16...
-
 
16
 
14
 
17
appname  equ  'Kolibri HTTP Server '
Line 15... Line 18...
15
version  equ  '0.4'
18
version  equ  '0.6'
Line 16... Line 19...
16
 
19
 
Line 17... Line 20...
17
use32
20
use32
18
 
21
 
19
                org     0x0
22
		org	0x0
20
 
23
 
21
                db      'MENUET01'              ; 8 byte id
24
		db	'MENUET01'		; 8 byte id
22
                dd      0x01                    ; required os
25
		dd	0x01			; required os
23
                dd      START                   ; program start
26
		dd	START			; program start
Line 24... Line -...
24
                dd      I_END                   ; program image size
-
 
25
                dd      0x400000                ; required amount of memory
27
		dd	I_END			; program image size
Line 26... Line 28...
26
                dd      0x20000
28
		dd	0x400000		; required amount of memory
27
                dd      0,0                     ; reserved=no extended header
29
		dd	0x20000
28
 
30
		dd	0,0			; reserved=no extended header
29
include 'lang.inc'
31
 
Line 30... Line 32...
30
include "macros.inc"
32
include "MACROS.INC"
-
 
33
 
-
 
34
; 0x0+       - program image
-
 
35
; 0x1ffff    - stack
-
 
36
; 0x20000+   - message board
31
 
37
; 0x100000+  - requested file
32
; 0x0+       - program image
38
 
Line 33... Line 39...
33
; 0x1ffff    - stack
39
filel:
-
 
40
   dd 0
-
 
41
   dd 0
-
 
42
   dd 0
-
 
43
   dd 50000
34
; 0x20000+   - message board
44
   dd 0x20000
35
; 0x100000+  - requested file
45
   db	'/rd/1/board.htm',0
36
 
-
 
Line 37... Line 46...
37
filel:
46
 
Line 38... Line 47...
38
   dd   0x0,0x0,50000/512,0x20000,0x70000
47
files:
39
   db   '/rd/1/board.htm',0
48
    dd 2
40
 
49
    dd 0
41
files:
50
    dd 0
42
   dd   0x1,0x0,0x0,0x20000,0x70000
51
    dd 0
43
   db   '/rd/1/board.htm',0
52
    dd 0x20000
Line 60... Line 69...
60
    cld
69
    cld
61
    rep  movsb
70
    rep  movsb
Line 62... Line 71...
62
 
71
 
Line 63... Line 72...
63
   board_found:
72
   board_found:
64
 
73
 
65
    mov  eax,58
74
    mov  eax,70
66
    mov  ebx,files
75
    mov  ebx,files
67
    mov  ecx,[board_size]
76
    mov  ecx,[board_size]
Line 68... Line 77...
68
    mov  [files+8],ecx
77
    mov  [files+12],ecx
69
    int  0x40
78
    int  0x40
70
 
79
 
-
 
80
    mov  [status],-1
71
    mov  [status],-1
81
    mov  [last_status],-2
72
    mov  [last_status],-2
-
 
73
    call clear_input
-
 
Line 74... Line 82...
74
    call draw_window            ; at first, draw the window
82
    call clear_input
Line 75... Line 83...
75
 
83
red:
76
;    call ops
84
    call draw_window		; at first, draw the window
Line 96... Line 104...
96
    int  0x40
104
    int  0x40
97
    call check_events
105
    call check_events
Line 98... Line 106...
98
 
106
 
Line 99... Line -...
99
    jmp  still
-
 
100
 
-
 
101
 
-
 
102
 reb:  ; boot
-
 
103
 
-
 
104
    mov  eax,18
-
 
105
    mov  ebx,1
-
 
106
    int  0x40
-
 
107
 
-
 
108
    jmp  $
-
 
109
 
107
    jmp  still
Line 110... Line 108...
110
 
108
 
Line 111... Line 109...
111
last_status   dd   0x0
109
last_status   dd   0x0
112
 
110
 
113
check_events:
111
check_events:
114
 
112
 
115
    cmp  eax,1                  ; redraw request ?
113
    cmp  eax,1			; redraw request ?
116
    jz   red
114
    jz   red
Line 117... Line 115...
117
    cmp  eax,2                  ; key in buffer ?
115
    cmp  eax,2			; key in buffer ?
Line 118... Line -...
118
    jz   key
-
 
119
    cmp  eax,3                  ; button in buffer ?
-
 
120
    jz   button
-
 
121
 
-
 
122
    ret
116
    jz   key
123
 
117
    cmp  eax,3			; button in buffer ?
124
red:                           ; redraw
118
    jz   button
125
    call draw_window
119
 
Line 126... Line 120...
126
    ret
120
    ret
Line 127... Line 121...
127
 
121
 
128
key:                           ; Keys are not valid at this part of the
122
key:			       ; Keys are not valid at this part of the
Line 129... Line 123...
129
    mov  eax,2                 ; loop. Just read it and ignore
123
    mov  al,2		       ; loop. Just read it and ignore
130
    int  0x40
124
    int  0x40
131
    ret
125
    ret
132
 
126
 
133
button:                         ; button
127
button: 			; button
134
 
128
 
135
    mov  eax,17                 ; get id
129
    mov  al,17 		; get id
136
    int  0x40
130
    int  0x40
137
 
131
 
Line 138... Line 132...
138
    cmp  ah,1                   ; close
132
    cmp  ah,1		; close
139
    jnz  tst2
133
    jnz  tst2
140
    mov  eax,53
134
    mov  eax,53
141
    mov  ebx,8
135
    mov  ebx,8
142
    mov  ecx,[socket]
136
    mov  ecx,[socket]
143
    int  0x40
137
    int  0x40
144
    mov  eax,-1
138
    mov  eax,-1
145
    int  0x40
139
    int  0x40
146
  tst2:
140
  tst2:
147
 
141
 
148
    cmp  ah,2                   ; button id=2 ?
142
    cmp  ah,2            ; button id=2 ?
149
    jnz  tst3
143
    jnz  tst3
150
    ; open socket
144
    ; open socket
151
  ops:
145
  ops:
152
    mov  eax,53
146
    mov  eax,53
153
    mov  ebx,5
147
    mov  ebx,5
154
    mov  ecx,80     ; local port # - http
148
    mov  ecx,80       ; local port # - http
155
    mov  edx,0      ; no remote port specified
149
    mov  edx,0	    ; no remote port specified
156
    mov  esi,0      ; no remote ip specified
150
    mov  esi,0	    ; no remote ip specified
157
    mov  edi,0      ; PASSIVE open
-
 
158
    int  0x40
-
 
159
    mov  [socket], eax
151
    mov  edi,0	    ; PASSIVE open
160
    mov  [posy],1
152
    int  0x40
161
    mov  [posx],0
-
 
162
    call check_for_incoming_data
153
    mov  [socket], eax
163
    call clear_input
154
    mov  [posy],1
164
    call draw_data
155
    mov  [posx],0
165
    mov  [server_active],1
156
    call check_for_incoming_data
166
    call check_status
157
    call clear_input
167
;    cmp  [status],0
158
    call draw_data
Line 188... Line 179...
188
    cmp  [server_active],1
179
    cmp  [server_active],1
189
    jne  no_re_open
180
    jne  no_re_open
190
    mov  eax,53
181
    mov  eax,53
191
    mov  ebx,5
182
    mov  ebx,5
192
    mov  ecx,80     ; local port # - http
183
    mov  ecx,80     ; local port # - http
193
    mov  edx,0      ; no remote port specified
184
    mov  edx,0	    ; no remote port specified
194
    mov  esi,0      ; no remote ip specified
185
    mov  esi,0	    ; no remote ip specified
195
    mov  edi,0      ; PASSIVE open
186
    mov  edi,0	    ; PASSIVE open
196
    int  0x40
187
    int  0x40
197
    mov  [socket], eax
188
    mov  [socket], eax
198
  no_re_open:
189
  no_re_open:
Line 199... Line 190...
199
 
190
 
Line 218... Line 209...
218
 
209
 
219
    mov  esp,0x1ffff
210
    mov  esp,0x1ffff
220
    jmp  still
211
    jmp  still
Line 221... Line 212...
221
  no4:
212
  no4:
222
 
213
 
Line 223... Line 214...
223
    cmp  ah,6                   ; read directory
214
    cmp  ah,6			; read directory
Line 224... Line 215...
224
    je   read_string
215
    je	 read_string
Line 247... Line 238...
247
    mov  [retries],50
238
    mov  [retries],50
Line 248... Line 239...
248
 
239
 
249
  wait_for_data:
240
  wait_for_data:
250
    call check_for_incoming_data
241
    call check_for_incoming_data
251
    cmp  [input_text+256+1],dword 'GET '
242
    cmp  [input_text+256+1],dword 'GET '
252
    je   data_received
243
    je	 data_received
253
    cmp  [input_text+256+1],dword 'POST'
244
    cmp  [input_text+256+1],dword 'POST'
254
    je   data_received
245
    je	 data_received
255
    mov  eax,5
246
    mov  eax,5
256
    mov  ebx,1
247
    mov  ebx,1
257
    int  0x40
248
    int  0x40
258
    dec  [retries]
249
    dec  [retries]
Line 298... Line 289...
298
 
289
 
299
    mov  edx,[fileadd]
290
    mov  edx,[fileadd]
Line 300... Line 291...
300
    add  [filepos],edx
291
    add  [filepos],edx
301
 
292
 
Line 302... Line 293...
302
    cmp  [file_left],0
293
    cmp  [file_left],0
Line 303... Line 294...
303
    jg   newblock
294
    jg	 newblock
Line 317... Line 308...
317
 
308
 
Line 318... Line 309...
318
    pusha
309
    pusha
Line 319... Line -...
319
 
-
 
320
  wait_more:
-
 
321
 
-
 
322
;    rdtsc
-
 
323
;    mov  ecx,eax
-
 
324
;    add  ecx,1000000
-
 
325
;   wr:
-
 
326
;    rdtsc
-
 
327
;    cmp  eax,ecx
310
 
328
;    jb   wr
311
  wait_more:
329
 
312
 
Line 330... Line 313...
330
    mov  eax,5
313
    mov  eax,5
Line 378... Line 361...
378
 
361
 
Line 379... Line 362...
379
send_header:
362
send_header:
Line 380... Line 363...
380
 
363
 
381
    pusha
364
    pusha
382
 
365
 
383
    mov   eax,53                  ; send response and file length
366
    mov   eax,53		  ; send response and file length
384
    mov   ebx,7
367
    mov   ebx,7
385
    mov   ecx,[socket]
368
    mov   ecx,[socket]
Line 386... Line 369...
386
    mov   edx,h_len-html_header
369
    mov   edx,h_len-html_header
387
    mov   esi,html_header
370
    mov   esi,html_header
388
    int   0x40
371
    int   0x40
389
 
372
 
390
    mov   eax,53                  ; send file type
373
    mov   eax,53		  ; send file type
391
    mov   ebx,7
374
    mov   ebx,7
Line 392... Line 375...
392
    mov   ecx,[socket]
375
    mov   ecx,[socket]
393
    mov   edx,[type_len]
376
    mov   edx,[type_len]
Line -... Line 377...
-
 
377
    mov   esi,[file_type]
-
 
378
    int   0x40
394
    mov   esi,[file_type]
379
 
-
 
380
    popa
395
    int   0x40
381
    ret
396
 
382
 
397
    popa
383
fileinfo	dd 0
398
    ret
384
		dd 0
Line 399... Line 385...
399
 
385
		dd 0
Line 400... Line 386...
400
 
386
		dd 512
Line 401... Line 387...
401
fileinfo     dd  0,0,1,0x100000,0xf0000
387
		dd 0x100000
Line 402... Line 388...
402
getf         db  '/RD/1/'
388
getf		db '/rd/1/'
Line 403... Line 389...
403
             times 50 db 0
389
	     times 50 db 0
404
wanted_file: times 100 db 0
390
wanted_file: times 100 db 0
405
 
391
 
406
getflen      dd  6
392
getflen      dd  6
407
 
393
 
408
make_room:
394
make_room:
409
 
395
 
410
   pusha
396
   pusha
411
 
397
 
412
   mov  edx,ecx
398
   mov	edx,ecx
Line 413... Line 399...
413
 
399
 
414
   mov  esi,0x20000
400
   mov	esi,0x20000
Line 415... Line 401...
415
   add  esi,[board_size]
401
   add	esi,[board_size]
416
   mov  edi,esi
402
   mov	edi,esi
Line 417... Line 403...
417
   add  edi,edx
403
   add	edi,edx
418
   mov  ecx,[board_size]
404
   mov	ecx,[board_size]
Line 419... Line 405...
419
   sub  ecx,board1-board
405
   sub	ecx,board1-board
420
   inc  ecx
-
 
421
   std
-
 
422
   rep  movsb
-
 
Line -... Line 406...
-
 
406
   inc	ecx
-
 
407
   std
-
 
408
   rep	movsb
423
   cld
409
   cld
424
 
410
 
425
   popa
411
   popa
Line 426... Line 412...
426
   ret
412
   ret
427
 
413
 
Line 428... Line 414...
428
 
414
 
429
from_i  dd  0x0
415
from_i	dd  0x0
Line 430... Line 416...
430
from_len dd 0x0
416
from_len dd 0x0
Line 431... Line 417...
431
 
417
 
432
message dd 0x0
418
message dd 0x0
433
message_len dd 0x0
419
message_len dd 0x0
434
 
420
 
Line 435... Line 421...
435
read_file:                          ; start of execution
421
read_file:			    ; start of execution
Line 466... Line 452...
466
 
452
 
467
    mov  esi,input_text+256   ; from
453
    mov  esi,input_text+256   ; from
468
   newfroms:
454
   newfroms:
469
    inc  esi
455
    inc  esi
470
    cmp  esi,input_text+256*20
456
    cmp  esi,input_text+256*20
471
    je   no_server_message_2
457
    je	 no_server_message_2
472
    cmp  [esi],dword 'from'
458
    cmp  [esi],dword 'from'
Line 473... Line 459...
473
    jne  newfroms
459
    jne  newfroms
474
 
460
 
Line 475... Line 461...
475
    add  esi,5
461
    add  esi,5
476
    mov  [from_i],esi
462
    mov  [from_i],esi
477
 
463
 
478
    mov  edx,0
464
    mov  edx,0
479
   name_new_len:
465
   name_new_len:
480
    cmp  [esi+edx],byte 13
466
    cmp  [esi+edx],byte 13
481
    je   name_found_len
467
    je	 name_found_len
482
    cmp  [esi+edx],byte '&'
468
    cmp  [esi+edx],byte '&'
483
    je   name_found_len
469
    je	 name_found_len
484
    cmp  edx,1000
470
    cmp  edx,1000
-
 
471
    je	 name_found_len
485
    je   name_found_len
472
    inc  edx
Line 486... Line 473...
486
    inc  edx
473
    jmp  name_new_len
Line 487... Line 474...
487
    jmp  name_new_len
474
 
488
   name_found_len:
475
   name_found_len:
489
 
476
 
490
    mov  [from_len],edx
477
    mov  [from_len],edx
491
 
478
 
492
    mov  esi,input_text+256
479
    mov  esi,input_text+256
493
   newmessages:
480
   newmessages:
Line 494... Line 481...
494
    inc  esi
481
    inc  esi
495
    cmp  esi,input_text+256*20
482
    cmp  esi,input_text+256*20
Line 496... Line 483...
496
    je   no_server_message_2
483
    je	 no_server_message_2
497
    cmp  [esi],dword 'sage'
484
    cmp  [esi],dword 'sage'
498
    jne  newmessages
485
    jne  newmessages
499
 
486
 
500
    add  esi,5
487
    add  esi,5
501
    mov  [message],esi
488
    mov  [message],esi
502
 
489
 
503
    mov  edx,0
490
    mov  edx,0
504
   new_len:
491
   new_len:
505
    inc  edx
492
    inc  edx
506
    cmp  [esi+edx],byte ' '
493
    cmp  [esi+edx],byte ' '
507
    je   found_len
494
    je	 found_len
Line 544... Line 531...
544
    sub  ebx,7
531
    sub  ebx,7
545
   ebx_ok:
532
   ebx_ok:
546
    imul ebx,16
533
    imul ebx,16
547
    add  ebx,eax
534
    add  ebx,eax
548
    mov  [esi+edx],bl
535
    mov  [esi+edx],bl
549
    mov  [esi+edx+1],word '  '
536
    mov  [esi+edx+1],word ''
550
    add  edx,2
537
    add  edx,2
551
   no_ascii:
538
   no_ascii:
Line 552... Line 539...
552
 
539
 
553
    inc  edx
540
    inc  edx
Line 563... Line 550...
563
 
550
 
564
    mov  ecx,edx
551
    mov  ecx,edx
Line 565... Line 552...
565
    call make_room
552
    call make_room
566
 
553
 
567
 
554
 
568
    mov  esi,board1          ; first part
555
    mov  esi,board1	     ; first part
569
    mov  edi,0x20000
556
    mov  edi,0x20000
570
    add  edi,board1-board
557
    add  edi,board1-board
Line 571... Line 558...
571
    mov  ecx,edx
558
    mov  ecx,edx
572
    cld
559
    cld
-
 
560
    rep  movsb
573
    rep  movsb
561
 
574
 
562
    mov  esi,[from_i]	       ; name
575
    mov  esi,[from_i]          ; name
563
    mov  edi,0x20000
576
    mov  edi,0x20000
564
    add  edi,board1-board
Line 577... Line 565...
577
    add  edi,board1-board + board1e-board1
565
    add  edi,board1e-board1
578
    mov  ecx,[from_len]
566
    mov  ecx,[from_len]
579
    cld
567
    cld
580
    rep  movsb
568
    rep  movsb
581
 
569
 
582
    mov  esi,board2          ; middle part
570
    mov  esi,board2	     ; middle part
583
    mov  edi,0x20000
571
    mov  edi,0x20000
Line 584... Line 572...
584
    add  edi,board1-board + board1e-board1
572
    add  edi,board1-board + board1e-board1
585
    add  edi,[from_len]
573
    add  edi,[from_len]
586
    mov  ecx,board2e-board2
574
    mov  ecx,board2e-board2
587
    cld
575
    cld
588
    rep  movsb
576
    rep  movsb
589
 
577
 
590
    mov  esi,[message]       ; message
578
    mov  esi,[message]	     ; message
Line 591... Line 579...
591
    mov  edi,0x20000
579
    mov  edi,0x20000
592
    add  edi,board1-board + board1e-board1 +board2e-board2
580
    add  edi,board1-board + board1e-board1 + board2e-board2
593
    add  edi,[from_len]
581
    add  edi,[from_len]
594
    mov  ecx,[message_len]
582
    mov  ecx,[message_len]
595
    cld
583
    cld
596
    rep  movsb
584
    rep  movsb
597
 
585
 
598
    mov  esi,board3    ; end part
586
    mov  esi,board3    ; end part
Line 599... Line 587...
599
    mov  edi,0x20000
587
    mov  edi,0x20000
Line 600... Line 588...
600
    add  edi,board1-board + board1e-board1 +board2e-board2
588
    add  edi,board1-board + board1e-board1 + board2e-board2
601
    add  edi,[from_len]
589
    add  edi,[from_len]
Line 602... Line 590...
602
    add  edi,[message_len]
590
    add  edi,[message_len]
603
    mov  ecx,board3e-board3
591
    mov  ecx,board3e-board3
604
    cld
592
    cld
Line 605... Line 593...
605
    rep  movsb
593
    rep  movsb
606
 
594
 
Line 669... Line 657...
669
    jne  no_new_let
657
    jne  no_new_let
670
    mov  edi,wanted_file
658
    mov  edi,wanted_file
671
    cld
659
    cld
672
  new_let:
660
  new_let:
673
    cmp  [esi],byte ' '
661
    cmp  [esi],byte ' '
674
    je   no_new_let
662
    je	 no_new_let
675
    cmp  edi,wanted_file+30
663
    cmp  edi,wanted_file+30
676
    jge  no_new_let
664
    jge  no_new_let
677
    movsb
665
    movsb
678
    jmp  new_let
666
    jmp  new_let
679
  no_new_let:
667
  no_new_let:
Line 682... Line 670...
682
    mov  [edi+8],dword 0
670
    mov  [edi+8],dword 0
Line 683... Line 671...
683
 
671
 
684
    cmp  esi,input_text+256+6
672
    cmp  esi,input_text+256+6
685
    jne  no_index
673
    jne  no_index
686
    mov  edi,wanted_file
674
    mov  edi,wanted_file
687
    mov  [edi+0],dword  'inde'
675
    mov  [edi+0],dword	'inde'
688
    mov  [edi+4],dword  'x.ht'
676
    mov  [edi+4],dword	'x.ht'
689
    mov  [edi+8],byte   'm'
677
    mov  [edi+8],byte	'm'
690
    mov  [edi+9],byte   0
678
    mov  [edi+9],byte	0
Line 691... Line 679...
691
    add  edi,9
679
    add  edi,9
692
 
680
 
693
    mov  [file_type],htm
681
    mov  [file_type],htm
Line 694... Line 682...
694
    mov  [type_len],html-htm
682
    mov  [type_len],html-htm
695
    mov  [filename+40*2+6],dword 'HTM '
683
    mov  [filename+40*2+6],dword 'HTM '
Line 696... Line 684...
696
 
684
 
697
    jmp  html_file
685
    jmp  html_file
698
  no_index:
686
  no_index:
699
 
687
 
700
    cmp  [edi-3],dword 'htm'+0
688
    cmp  [edi-3],dword 'htm'+0
701
    je   htm_header
689
    je	 htm_header
702
    cmp  [edi-3],dword 'HTM'+0
690
    cmp  [edi-3],dword 'HTM'+0
703
    je   htm_header
691
    je	 htm_header
704
    jmp  no_htm_header
692
    jmp  no_htm_header
705
  htm_header:
693
  htm_header:
706
    mov  [file_type],htm
694
    mov  [file_type],htm
Line 707... Line 695...
707
    mov  [type_len],html-htm
695
    mov  [type_len],html-htm
708
    mov  [filename+40*2+6],dword 'HTM '
696
    mov  [filename+40*2+6],dword 'HTM '
709
    jmp  found_file_type
697
    jmp  found_file_type
710
  no_htm_header:
698
  no_htm_header:
711
 
699
 
712
    cmp  [edi-3],dword 'png'+0
700
    cmp  [edi-3],dword 'png'+0
713
    je   png_header
701
    je	 png_header
714
    cmp  [edi-3],dword 'PNG'+0
702
    cmp  [edi-3],dword 'PNG'+0
715
    je   png_header
703
    je	 png_header
716
    jmp  no_png_header
704
    jmp  no_png_header
717
  png_header:
705
  png_header:
Line 718... Line 706...
718
    mov  [file_type],png
706
    mov  [file_type],png
719
    mov  [type_len],pngl-png
707
    mov  [type_len],pngl-png
720
    mov  [filename+40*2+6],dword 'PNG '
708
    mov  [filename+40*2+6],dword 'PNG '
721
    jmp  found_file_type
709
    jmp  found_file_type
722
  no_png_header:
710
  no_png_header:
723
 
711
 
724
    cmp  [edi-3],dword 'gif'+0
712
    cmp  [edi-3],dword 'gif'+0
725
    je   gif_header
713
    je	 gif_header
726
    cmp  [edi-3],dword 'GIF'+0
714
    cmp  [edi-3],dword 'GIF'+0
727
    je   gif_header
715
    je	 gif_header
728
    jmp  no_gif_header
716
    jmp  no_gif_header
Line 729... Line 717...
729
  gif_header:
717
  gif_header:
730
    mov  [file_type],gif
718
    mov  [file_type],gif
731
    mov  [type_len],gifl-gif
719
    mov  [type_len],gifl-gif
732
    mov  [filename+40*2+6],dword 'GIF '
720
    mov  [filename+40*2+6],dword 'GIF '
733
    jmp  found_file_type
721
    jmp  found_file_type
734
  no_gif_header:
722
  no_gif_header:
735
 
723
 
736
    cmp  [edi-3],dword 'jpg'+0
724
    cmp  [edi-3],dword 'jpg'+0
737
    je   jpg_header
725
    je	 jpg_header
738
    cmp  [edi-3],dword 'JPG'+0
726
    cmp  [edi-3],dword 'JPG'+0
739
    je   jpg_header
727
    je	 jpg_header
Line 740... Line 728...
740
    jmp  no_jpg_header
728
    jmp  no_jpg_header
741
  jpg_header:
729
  jpg_header:
742
    mov  [file_type],jpg
730
    mov  [file_type],jpg
743
    mov  [type_len],jpgl-jpg
731
    mov  [type_len],jpgl-jpg
744
    mov  [filename+40*2+6],dword 'JPG '
732
    mov  [filename+40*2+6],dword 'JPG '
745
    jmp  found_file_type
733
    jmp  found_file_type
746
  no_jpg_header:
734
  no_jpg_header:
747
 
735
 
748
    cmp  [edi-3],dword 'asm'+0
736
    cmp  [edi-3],dword 'asm'+0
749
    je   txt_header
737
    je	 txt_header
750
    cmp  [edi-3],dword 'ASM'+0
738
    cmp  [edi-3],dword 'ASM'+0
751
    je   txt_header
739
    je	 txt_header
752
    cmp  [edi-3],dword 'txt'+0
740
    cmp  [edi-3],dword 'txt'+0
Line 776... Line 764...
776
    mov  edi,filename
764
    mov  edi,filename
777
    mov  ecx,35
765
    mov  ecx,35
778
    cld
766
    cld
779
    rep  movsb
767
    rep  movsb
Line 780... Line 768...
780
 
768
 
781
    mov  [fileinfo+8],dword 1   ; file exists ?
769
    mov  [fileinfo+12],dword 1	 ; file exists ?
782
    mov  eax,58
770
    mov  eax,70
783
    mov  ebx,fileinfo
771
    mov  ebx,fileinfo
Line 784... Line 772...
784
    int  0x40
772
    int  0x40
785
 
773
 
786
    cmp  eax,0         ; file not found - message
774
    cmp  eax,0	       ; file not found - message
787
    je   file_found
775
    je	 file_found
788
    mov  edi,et
776
    mov  edi,et
789
    call set_time
777
    call set_time
790
    mov  edi,ed
778
    mov  edi,ed
Line 802... Line 790...
802
 
790
 
Line 803... Line 791...
803
    jmp  file_not_found
791
    jmp  file_not_found
Line 804... Line 792...
804
 
792
 
805
   file_found:
793
   file_found:
806
 
794
 
807
    mov  [fileinfo+8],dword 0x2f0000 / 512 ; read all of file
795
    mov  [fileinfo+12],dword 0x2f0000 ; read all of file
Line 808... Line 796...
808
    mov  eax,58
796
    mov  eax,70
809
    mov  ebx,fileinfo
797
    mov  ebx,fileinfo
Line 998... Line 986...
998
    mov  ebx,6
986
    mov  ebx,6
999
    mov  ecx,[socket]
987
    mov  ecx,[socket]
1000
    int  0x40
988
    int  0x40
Line 1001... Line 989...
1001
 
989
 
1002
    cmp  eax,[status]
990
    cmp  eax,[status]
1003
    je   c_ret
991
    je	 c_ret
1004
    mov  [status],eax
992
    mov  [status],eax
1005
    add  al,48
993
    add  al,48
1006
    mov  [text+12],al
994
    mov  [text+12],al
1007
    call draw_data
995
    call draw_data
Line 1008... Line 996...
1008
   c_ret:
996
   c_ret:
1009
 
997
 
Line 1010... Line 998...
1010
    popa
998
    popa
1011
    ret
999
    ret
Line 1012... Line 1000...
1012
 
1000
 
Line 1013... Line 1001...
1013
 
1001
 
Line 1038... Line 1026...
1038
    jne  read_done
1026
    jne  read_done
1039
    mov  eax,2
1027
    mov  eax,2
1040
    int  0x40
1028
    int  0x40
1041
    shr  eax,8
1029
    shr  eax,8
1042
    cmp  eax,13
1030
    cmp  eax,13
1043
    je   read_done
1031
    je	 read_done
1044
    cmp  eax,8
1032
    cmp  eax,8
1045
    jnz  nobsl
1033
    jnz  nobsl
1046
    cmp  edi,[addr]
1034
    cmp  edi,[addr]
1047
    jz   f11
1035
    jz	 f11
1048
    sub  edi,1
1036
    sub  edi,1
1049
    mov  [edi],byte 32
1037
    mov  [edi],byte 32
1050
    call print_text
1038
    call print_text
1051
    jmp  f11
1039
    jmp  f11
1052
  nobsl:
1040
  nobsl:
Line 1086... Line 1074...
1086
 
1074
 
Line 1087... Line 1075...
1087
print_text:
1075
print_text:
Line 1088... Line -...
1088
 
-
 
1089
    pusha
-
 
1090
 
-
 
1091
    mov  eax,13
-
 
1092
    mov  ebx,97*65536+23*6
-
 
1093
    mov  ecx,[ya]
-
 
1094
    shl  ecx,16
-
 
1095
    mov  cx,9
-
 
1096
    mov  edx,0xffffff
1076
 
1097
    int  0x40
1077
    pusha
1098
 
1078
 
1099
    mov  eax,4
1079
    mov  eax,4
1100
    mov  edx,[addr]
1080
    mov  edx,[addr]
1101
    mov  ebx,97*65536
1081
    mov  ebx,97*65536
-
 
1082
    add  ebx,[ya]
1102
    add  ebx,[ya]
1083
    mov  ecx,0x40000000
Line 1103... Line 1084...
1103
    mov  ecx,0x000000
1084
    mov  esi,23
1104
    mov  esi,23
1085
    mov  edi,0xffffff
Line 1105... Line -...
1105
    int  0x40
-
 
1106
 
-
 
1107
    popa
-
 
1108
    ret
-
 
1109
 
1086
    int  0x40
1110
 
1087
 
1111
 
1088
    popa
Line 1112... Line 1089...
1112
 
1089
    ret
Line 1113... Line 1090...
1113
 
1090
 
1114
 
1091
 
1115
;   *********************************************
1092
;   *********************************************
Line 1116... Line 1093...
1116
;   *******  WINDOW DEFINITIONS AND DRAW ********
1093
;   *******  WINDOW DEFINITIONS AND DRAW ********
1117
;   *********************************************
1094
;   *********************************************
1118
 
1095
 
1119
 
1096
 
1120
draw_window:
1097
draw_window:
1121
 
-
 
1122
    mov  eax,12                    ; function 12:tell os about windowdraw
1098
 
1123
    mov  ebx,1                     ; 1, start of draw
1099
    mov  eax,12 		   ; function 12:tell os about windowdraw
Line 1124... Line -...
1124
    int  0x40
-
 
1125
 
1100
    mov  ebx,1			   ; 1, start of draw
1126
                                   ; DRAW WINDOW
1101
    int  0x40
1127
    mov  eax,0                     ; function 0 : define and draw window
1102
 
1128
    mov  ebx,100*65536+480         ; [x start] *65536 + [x size]
1103
				   ; DRAW WINDOW
1129
    mov  ecx,100*65536+215         ; [y start] *65536 + [y size]
1104
    mov  eax,0			   ; function 0 : define and draw window
1130
    mov  edx,0x03ffffff            ; color of work area RRGGBB
1105
    mov  ebx,100*65536+480	   ; [x start] *65536 + [x size]
Line 1131... Line 1106...
1131
    mov  esi,0x8050a0b0            ; color of grab bar  RRGGBB,8->color gl
1106
    mov  ecx,100*65536+215	   ; [y start] *65536 + [y size]
1132
    mov  edi,0x0050a0b0            ; color of frames    RRGGBB
1107
    mov  edx,0x13ffffff 	   ; color of work area RRGGBB
1133
    int  0x40
1108
    mov  edi,header		   ; WINDOW LABEL
1134
 
1109
    int  0x40
1135
                                   ; WINDOW LABEL
1110
 
1136
    mov  eax,4                     ; function 4 : write text to window
1111
    mov  eax,8			   ; function 8 : define and draw button
Line 1137... Line -...
1137
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
-
 
1138
    mov  ecx,0x10ffffff            ; color of text RRGGBB
-
 
1139
    mov  edx,labelt                ; pointer to text beginning
-
 
1140
    mov  esi,labellen-labelt       ; text length
-
 
1141
    int  0x40
-
 
1142
 
1112
    mov  ebx,(40)*65536+20	   ; [x start] *65536 + [x size]
1143
    mov  eax,8                     ; function 8 : define and draw button
-
 
1144
    mov  ebx,(40)*65536+20         ; [x start] *65536 + [x size]
-
 
1145
    mov  ecx,59*65536+9           ; [y start] *65536 + [y size]
1113
    mov  ecx,59*65536+9 	   ; [y start] *65536 + [y size]
1146
    mov  edx,2                     ; button id
1114
    mov  edx,2			   ; button id
1147
    mov  esi,0x66aa66              ; button color RRGGBB
1115
    mov  esi,0x66aa66		   ; button color RRGGBB
1148
    int  0x40
1116
    int  0x40
1149
 
1117
 
Line 1165... Line 1133...
1165
    mov  ebx,240*65536+240
1133
    mov  ebx,240*65536+240
1166
    mov  ecx,22*65536+210
1134
    mov  ecx,22*65536+210
1167
    mov  edx,0x6699cc ; 002288
1135
    mov  edx,0x6699cc ; 002288
1168
    int  0x40
1136
    int  0x40
Line 1169... Line 1137...
1169
 
1137
 
1170
    mov  eax,38
1138
 
1171
    mov  ebx,241*65536+241
1139
    mov  ebx,241*65536+241
1172
    mov  ecx,22*65536+210
1140
    mov  ecx,22*65536+210
1173
    mov  edx,0x336699 ; 002288
1141
    mov  edx,0x336699 ; 002288
Line 1174... Line 1142...
1174
    int  0x40
1142
    int  0x40
Line 1175... Line 1143...
1175
 
1143
 
1176
    call draw_data
1144
    call draw_data
1177
 
1145
 
Line 1178... Line 1146...
1178
    mov  eax,12                    ; function 12:tell os about windowdraw
1146
    mov  eax,12 		   ; function 12:tell os about windowdraw
Line 1179... Line 1147...
1179
    mov  ebx,2                     ; 2, end of draw
1147
    mov  ebx,2			   ; 2, end of draw
Line 1180... Line 1148...
1180
    int  0x40
1148
    int  0x40
Line 1181... Line 1149...
1181
 
1149
 
1182
    ret
1150
    ret
1183
 
1151
 
1184
 
1152
 
1185
draw_data:
1153
draw_data:
1186
 
1154
 
Line 1216... Line 1184...
1216
 
1184
 
1217
    mov  [input_text+0],dword 'RECE'
1185
    mov  [input_text+0],dword 'RECE'
1218
    mov  [input_text+4],dword 'IVED'
1186
    mov  [input_text+4],dword 'IVED'
Line 1219... Line 1187...
1219
    mov  [input_text+8],dword ':   '
1187
    mov  [input_text+8],dword ':   '
1220
 
1188
 
1221
    mov  ebx,255*65536+35           ; draw info text with function 4
1189
    mov  ebx,255*65536+35	    ; draw info text with function 4
1222
    mov  ecx,0x000000
1190
    mov  ecx,0x000000
1223
    mov  edx,input_text
1191
    mov  edx,input_text
1224
    mov  esi,35
1192
    mov  esi,35
Line 1245... Line 1213...
1245
    ret
1213
    ret
Line 1246... Line 1214...
1246
 
1214
 
Line 1247... Line 1215...
1247
 
1215
 
Line 1248... Line 1216...
1248
; DATA AREA
1216
; DATA AREA
1249
 
1217
 
1250
status  dd  0x0
1218
status	dd  0x0
1251
 
1219
 
Line 1257... Line 1225...
1257
    db '                                        '
1225
    db '                                        '
1258
    db 'Requests: /TinyStat  -statistics        '
1226
    db 'Requests: /TinyStat  -statistics        '
1259
    db '          /TinyBoard -message board     '
1227
    db '          /TinyBoard -message board     '
1260
    db '                                        '
1228
    db '                                        '
1261
dirp:
1229
dirp:
1262
    db '   Files:   /RD/1/                      '
1230
    db '   Files:   /rd/1/                      '
1263
    db '                                        '
1231
    db '                                        '
1264
filename:
1232
filename:
1265
    db '                                        '
1233
    db '                                        '
1266
    db 'Size: -------                           '
1234
    db 'Size: -------                           '
1267
    db 'Type: ---                               '
1235
    db 'Type: ---                               '
Line 1269... Line 1237...
1269
 
1237
 
Line 1270... Line 1238...
1270
 
1238
 
1271
html_header:
1239
html_header:
1272
 
1240
 
1273
     db  'HTTP/1.0 200 OK',13,10
1241
     db  'HTTP/1.0 200 OK',13,10
Line 1274... Line 1242...
1274
     db  'Server: MenuetOS HTTP Server',13,10
1242
     db  'Server: KolibriOS HTTP Server',13,10
Line 1275... Line 1243...
1275
     db  'Content-Length: '
1243
     db  'Content-Length: '
1276
c_l: db  '000000',13,10
1244
c_l: db  '000000',13,10
1277
 
1245
 
1278
h_len:
1246
h_len:
1279
 
1247
 
1280
fnf:
1248
fnf:
1281
     db  ''
1249
     db  ''
1282
     db  '
'
1250
     db  '
'
1283
     db  "TinyServer v ",version," for MenuetOS",13,10,13,10
1251
     db  "HTTP-Ñåðâåð v ",version," äëÿ KolibriOS",13,10,13,10
1284
     db  "Error 404 - File not found.",13,10,13,10
1252
     db  "

Error 404 - File not found

",13,10,13,10
Line 1285... Line 1253...
1285
     db  "For more info about server: request /TinyStat",13,10,13,10
1253
     db  "Äëÿ ïîëó÷åíèÿ ñòàòèñòèêè âûïîëíèòå çàïðîñ /TinyStat",13,10,13,10
1286
et:  db  "xx:xx:xx",13,10
1254
et:  db  "xx:xx:xx",13,10
1287
ed:  db  "xx.xx.xx",13,10
1255
ed:  db  "xx.xx.xx",13,10
1288
     db  "
"
1256
     db  "
"
1289
fnfe:
1257
fnfe:
1290
 
1258
 
1291
 
1259
 
1292
sm:
1260
sm:
1293
     db  ''
1261
     db  ''
1294
     db  '
'
1262
     db  '
'
1295
     db  "TinyServer v ",version," for MenuetOS",13,10,13,10
1263
     db  "HTTP-Ñåðâåð v ",version," äëÿ KolibriOS",13,10,13,10
1296
     db  "Statistics: (before current request)",13,10,13,10
1264
     db  "Ñòàòèñòèêà: (ïîñëå äàííîãî çàïðîñà)",13,10,13,10
1297
sms: db  "- Documents served  : xxxxxxxxx",13,10
1265
sms: db  "- Äîêóìåíòîâ ïðèíÿòî: xxxxxxxxx",13,10
1298
smb: db  "- Bytes transferred : xxxxxxxxx",13,10
1266
smb: db  "- Áàéò ïåðåäàííî    : xxxxxxxxx",13,10
1299
     db  "- Location          : /TinyStat",13,10,13,10
1267
     db  "- Ìåñòîíàõîæäåíèå   : Ñòàòèñòèêà",13,10,13,10
1300
     db  "TinyBoard:",13,10,13,10
1268
     db  "Ãîñòåâàÿ:",13,10,13,10
Line 1324... Line 1292...
1324
jpgl:
1292
jpgl:
1325
unk:   db  'Content-Type: unknown/unknown',13,10,13,10
1293
unk:   db  'Content-Type: unknown/unknown',13,10,13,10
1326
unkl:
1294
unkl:
Line 1327... Line 1295...
1327
 
1295
 
1328
 
-
 
Line 1329... Line 1296...
1329
 labelt:  db   'Tiny http server ',version
1296
 
1330
 labellen:
1297
header db   appname,version,0
Line 1331... Line 1298...
1331
 
1298
 
Line -... Line 1299...
-
 
1299
socket		dd  0x0
1332
socket          dd  0x0
1300
server_active	db  0x0
1333
server_active   db  0x0
1301
 
1334
 
1302
board:
1335
board:
1303
 
1336
 
1304
db "INTKolibriOS - /Ãîñòåâàÿ/",13,10
1337
db "
",13,10
1305
db "
",13,10
1338
db "
",13,10
1306
db "
",13,10
1339
db ""
1307
db ""
Line 1340... Line 1308...
1340
db 13,10
1308
db 13,10
Line 1341... Line 1309...
1341
db "
",13,10 1309
db "
",13,10
1342
db "Tinyserver Messageboard

",13,10
1310
db "Ãîñòåâàÿ ñåðâåðà INTKolibriOS

",13,10
1343
db ""
1311
db """,13,10",13,10",13,10",13,10
1344
db 13,10,13,10
1312
db 13,10,13,10
1345
 
1313
 
1346
board1:
1314
board1:
1347
 
1315
 
1348
db "
1316
db "
1349
db "

",13,10

1317
db "

",13,10

1350
db "",13,10
1318
db "",13,10
1351
board1e:
1319
board1e:
1352
db "WebMaster",13,10
1320
db "Hex",13,10
1353
board2:
1321
board2:
1354
db "",13,10
1322
db "",13,10
1355
db "


",13,10
1323
db "


",13,10
1356
db "



",13,10
1324
db "



",13,10
1357
bsmt:
1325
bsmt:
1358
db "12.23.45
",13,10
1326
db "15.23.45
",13,10
1359
bsmd:
1327
bsmd:
1360
db "02.05.03",13,10
1328
db "22.03.06",13,10
1361
db "

1329
db "

Line 1372... Line 1340...
1372
db "
",13,10
1340
db "
",13,10
1373
db "
",13,10
1341
db "
",13,10
1374
db ""
1342
db """,13,10",13,10",13,10",13,10
1375
db 13,10
1343
db 13,10
1376
db "
1344
db "
1377
db "

",13,10

1345
db "

",13,10

1378
db "
",13,10
1346
db "",13,10
1379
db "Name: 

",13,10
1347
db "Èìÿ: 

",13,10
1380
db "Message: 

",13,10
1348
db "Ñîîáùåíèå: 

",13,10
1381
db "",13,10
1349
db "",13,10
1382
db "
1350
db "
1383
db "
",13,10
1351
db "
",13,10
1384
db "",13,10
1352
db "",13,10
1385
db "",13,10
1353
db "",13,10
Line 1386... Line 1354...
1386
 
1354
 
Line 1387... Line 1355...
1387
board_end:
1355
board_end:
1388
 
1356
 
Line 1389... Line 1357...
1389
board_size      dd  0x0
1357
board_size	dd  0x0
Line 1390... Line 1358...
1390
board_messages  dd  0x0
1358
board_messages	dd  0x0
1391
 
1359