Subversion Repositories Kolibri OS

Rev

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

Rev 481 Rev 485
Line 18... Line 18...
18
    dd      I_END                   ; program image size
18
    dd      I_END                   ; program image size
19
    dd      0x170000                ; required amount of memory
19
    dd      0x170000                ; required amount of memory
20
    dd      0x7FFF0                 ; esp = 0x7FFF0
20
    dd      0x7FFF0                 ; esp = 0x7FFF0
21
    dd      0, 0                    ; no params, no path
21
    dd      0, 0                    ; no params, no path
Line 22... Line 22...
22
 
22
 
23
include 'macros.inc'
23
include '..\..\..\macros.inc'
24
; Various states of client connection
24
; Various states of client connection
25
USER_NONE       equ 0   ; Awaiting a connection
25
USER_NONE       equ 0   ; Awaiting a connection
26
USER_CONNECTED  equ 1   ; User just connected, prompt given
26
USER_CONNECTED  equ 1   ; User just connected, prompt given
27
USER_USERNAME   equ 2   ; User given username
27
USER_USERNAME   equ 2   ; User given username
Line 53... Line 53...
53
still:
53
still:
54
    ; check connection status
54
    ; check connection status
55
    mov     eax,53
55
    mov     eax,53
56
    mov     ebx,6               ; Get socket status
56
    mov     ebx,6               ; Get socket status
57
    mov     ecx,[CmdSocket]
57
    mov     ecx,[CmdSocket]
58
    int     0x40
58
    mcall
Line 59... Line 59...
59
 
59
 
60
    mov     ebx, [CmdSocketStatus]
60
    mov     ebx, [CmdSocketStatus]
Line 61... Line 61...
61
    mov     [CmdSocketStatus], eax
61
    mov     [CmdSocketStatus], eax
Line 95... Line 95...
95
    call    draw_window
95
    call    draw_window
Line 96... Line 96...
96
 
96
 
97
waitev:
97
waitev:
98
    mov     eax,23                 ; wait here for event
98
    mov     eax,23                 ; wait here for event
99
    mov     ebx,1                 ; Delay for up to 1s
99
    mov     ebx,1                 ; Delay for up to 1s
Line 100... Line 100...
100
    int     0x40
100
    mcall
101
 
101
 
102
    cmp     eax,1                  ; redraw request ?
102
    cmp     eax,1                  ; redraw request ?
103
    je      red
103
    je      red
Line 109... Line 109...
109
    ; any data from the socket?
109
    ; any data from the socket?
Line 110... Line 110...
110
 
110
 
111
    mov     eax, 53
111
    mov     eax, 53
112
    mov     ebx, 2                  ; Get # of bytes in input queue
112
    mov     ebx, 2                  ; Get # of bytes in input queue
113
    mov     ecx, [CmdSocket]
113
    mov     ecx, [CmdSocket]
114
    int     0x40
114
    mcall
115
    test    eax, eax
115
    test    eax, eax
Line 116... Line 116...
116
    jz      still
116
    jz      still
117
 
117
 
118
read_input:
118
read_input:
119
    mov     eax, 53
119
    mov     eax, 53
120
    mov     ebx, 3                  ; Get a byte from socket in bl
120
    mov     ebx, 3                  ; Get a byte from socket in bl
Line 121... Line 121...
121
    mov     ecx, [CmdSocket]
121
    mov     ecx, [CmdSocket]
Line 122... Line 122...
122
    int     0x40
122
    mcall
123
 
123
 
124
    call    ftpRxCmdData            ; process incoming ftp command
124
    call    ftpRxCmdData            ; process incoming ftp command
125
 
125
 
126
    ; Keep processing data until there is no more to process
126
    ; Keep processing data until there is no more to process
127
    mov     eax, 53
127
    mov     eax, 53
128
    mov     ebx, 2                  ; Get # of bytes in input queue
128
    mov     ebx, 2                  ; Get # of bytes in input queue
Line 129... Line 129...
129
    mov     ecx, [CmdSocket]
129
    mov     ecx, [CmdSocket]
130
    int     0x40
130
    mcall
Line 143... Line 143...
143
    call    draw_window
143
    call    draw_window
144
    jmp     still
144
    jmp     still
Line 145... Line 145...
145
 
145
 
146
key:                          ; KEY
146
key:                          ; KEY
147
    mov     eax,2                  ; get but ignore
147
    mov     eax,2                  ; get but ignore
148
    int     0x40
148
    mcall
Line 149... Line 149...
149
    jmp     still
149
    jmp     still
150
 
150
 
151
button:
151
button:
152
    mov     eax,17
152
    mov     eax,17
153
    int     0x40
153
    mcall
Line 154... Line 154...
154
    cmp     ah,1
154
    cmp     ah,1
155
    jne     still
155
    jne     still
156
 
156
 
157
    ; Exit button pressed, so close socket and quit
157
    ; Exit button pressed, so close socket and quit
158
    mov     eax,53
158
    mov     eax,53
Line 159... Line 159...
159
    mov     ebx,8
159
    mov     ebx,8
160
    mov     ecx,[CmdSocket]
160
    mov     ecx,[CmdSocket]
161
    int     0x40
161
    mcall
162
 
162
 
Line 163... Line 163...
163
    ; ... terminate program
163
    ; ... terminate program
Line 173... Line 173...
173
draw_window:
173
draw_window:
174
    pusha
174
    pusha
Line 175... Line 175...
175
 
175
 
176
    mov  eax,12
176
    mov  eax,12
177
    mov  ebx,1
177
    mov  ebx,1
Line 178... Line 178...
178
    int  0x40
178
    mcall
179
 
179
 
180
    xor  eax,eax                   ; DRAW WINDOW
180
    xor  eax,eax                   ; DRAW WINDOW
181
    mov  ebx,100*65536+491 + 8 +15
181
    mov  ebx,100*65536+491 + 8 +15
182
    mov  ecx,100*65536+270 + 20     ; 20 for status bar
182
    mov  ecx,100*65536+270 + 20     ; 20 for status bar
183
    mov  edx,0x13000000
183
    mov  edx,0x13000000
Line 184... Line 184...
184
    mov  edi,labelt
184
    mov  edi,labelt
185
    int  0x40
185
    mcall
186
 
186
 
187
    ; draw status bar
187
    ; draw status bar
188
    mov     eax, 13
188
    mov     eax, 13
189
    mov     ebx, 4*65536+484 + 8 +15
189
    mov     ebx, 4*65536+484 + 8 +15
Line 190... Line 190...
190
    mov     ecx, 270*65536 + 3
190
    mov     ecx, 270*65536 + 3
191
    mov     edx, 0x00557799
191
    mov     edx, 0x00557799
192
    int     0x40
192
    mcall
Line 201... Line 201...
201
pcon:
201
pcon:
Line 202... Line 202...
202
 
202
 
203
    mov  eax,4                      ; status text
203
    mov  eax,4                      ; status text
204
    mov  ebx,380*65536+276
204
    mov  ebx,380*65536+276
205
    mov  ecx,0x00ffffff
205
    mov  ecx,0x00ffffff
Line 206... Line 206...
206
    int  0x40
206
    mcall
207
 
207
 
208
    ; Draw the text on the screen, clearing it first
208
    ; Draw the text on the screen, clearing it first
209
    ; This can go when we loose debuggin info.
209
    ; This can go when we loose debuggin info.
Line 215... Line 215...
215
 
215
 
Line 216... Line 216...
216
    call draw_text
216
    call draw_text
217
 
217
 
218
    mov  eax,12
218
    mov  eax,12
Line 219... Line 219...
219
    mov  ebx,2
219
    mov  ebx,2
Line 220... Line 220...
220
    int  0x40
220
    mcall
Line 260... Line 260...
260
    mov     ebx, eax
260
    mov     ebx, eax
261
    add     ebx, 6
261
    add     ebx, 6
262
    shl     ebx, 16
262
    shl     ebx, 16
263
    mov     bx, 6
263
    mov     bx, 6
264
    mov     eax, 13
264
    mov     eax, 13
265
    int     0x40
265
    mcall
266
    popa
266
    popa
Line 267... Line 267...
267
 
267
 
Line 268... Line 268...
268
    ; draw character
268
    ; draw character
Line 276... Line 276...
276
    pop  bx
276
    pop  bx
277
    add  bx,26
277
    add  bx,26
278
    mov  eax,4
278
    mov  eax,4
279
    mov  edx,esi
279
    mov  edx,esi
280
    mov  esi,1
280
    mov  esi,1
281
    int  0x40
281
    mcall
282
    popa
282
    popa
Line 283... Line 283...
283
 
283
 
Line 284... Line 284...
284
  noletter:
284
  noletter:
Line 429... Line 429...
429
    push    esi
429
    push    esi
430
    push    edx
430
    push    edx
431
    mov     eax,53
431
    mov     eax,53
432
    mov     ebx,7
432
    mov     ebx,7
433
    mov     ecx,[CmdSocket]
433
    mov     ecx,[CmdSocket]
434
    int     0x40
434
    mcall
435
    pop     edx
435
    pop     edx
436
    pop     esi
436
    pop     esi
Line 437... Line 437...
437
    
437
    
438
    cmp     eax, 0
438
    cmp     eax, 0
Line 439... Line 439...
439
    je      os_exit
439
    je      os_exit
440
    
440
    
441
    ; The TCP/IP transmit queue is full; Wait a bit, then retry 
441
    ; The TCP/IP transmit queue is full; Wait a bit, then retry 
442
    pusha
442
    pusha
443
    mov     eax,5
443
    mov     eax,5
444
    mov     ebx,1                 ; Delay for up 100ms
444
    mov     ebx,1                 ; Delay for up 100ms
445
    int     0x40
445
    mcall
446
    popa
446
    popa
447
    jmp     outputStr        
447
    jmp     outputStr        
Line 466... Line 466...
466
    push    esi
466
    push    esi
467
    push    edx
467
    push    edx
468
    mov     eax,53
468
    mov     eax,53
469
    mov     ebx,7
469
    mov     ebx,7
470
    mov     ecx,[DataSocket]
470
    mov     ecx,[DataSocket]
471
    int     0x40
471
    mcall
472
    pop     edx
472
    pop     edx
473
    pop     esi
473
    pop     esi
Line 474... Line 474...
474
 
474
 
475
    cmp     eax, 0
475
    cmp     eax, 0
Line 476... Line 476...
476
    je      ods_exit
476
    je      ods_exit
477
 
477
 
478
    ; The TCP/IP transmit queue is full; Wait a bit, then retry 
478
    ; The TCP/IP transmit queue is full; Wait a bit, then retry 
479
    pusha
479
    pusha
480
    mov     eax,5
480
    mov     eax,5
481
    mov     ebx,20           ; Delay for upto 200ms
481
    mov     ebx,20           ; Delay for upto 200ms
482
    int     0x40
482
    mcall
483
    popa
483
    popa
484
    jmp     outputDataStr        
484
    jmp     outputDataStr        
Line 578... Line 578...
578
;***************************************************************************
578
;***************************************************************************
579
disconnect:
579
disconnect:
580
    mov     eax, 53         ; Stack Interface
580
    mov     eax, 53         ; Stack Interface
581
    mov     ebx,8           ; Close TCP socket
581
    mov     ebx,8           ; Close TCP socket
582
    mov     ecx,[CmdSocket]
582
    mov     ecx,[CmdSocket]
583
    int     0x40
583
    mcall
584
    ret
584
    ret
Line 585... Line 585...
585
    
585
    
Line 600... Line 600...
600
    ; This delay would be better done by allowing the socket code
600
    ; This delay would be better done by allowing the socket code
601
    ; to wait for all data to pass through the stack before closing
601
    ; to wait for all data to pass through the stack before closing
602
    pusha
602
    pusha
603
    mov     eax,5
603
    mov     eax,5
604
    mov     ebx,200                 ; Delay for 2s
604
    mov     ebx,200                 ; Delay for 2s
605
    int     0x40
605
    mcall
606
    popa
606
    popa
Line 607... Line 607...
607
 
607
 
608
    mov     eax, 53         ; Stack Interface
608
    mov     eax, 53         ; Stack Interface
609
    mov     ebx,8           ; Close TCP socket
609
    mov     ebx,8           ; Close TCP socket
610
    mov     ecx,[DataSocket]
610
    mov     ecx,[DataSocket]
611
    int     0x40
611
    mcall
Line 632... Line 632...
632
    mov     ebx, 5      ; Open TCP socket
632
    mov     ebx, 5      ; Open TCP socket
633
    mov     esi, 0      ; No remote IP address
633
    mov     esi, 0      ; No remote IP address
634
    mov     edx, 0      ; No remote port
634
    mov     edx, 0      ; No remote port
635
    mov     ecx, 21     ; ftp command port id
635
    mov     ecx, 21     ; ftp command port id
636
    mov     edi, 0      ; passive open
636
    mov     edi, 0      ; passive open
637
    int     0x40
637
    mcall
638
    mov     [CmdSocket], eax
638
    mov     [CmdSocket], eax
Line 639... Line 639...
639
 
639
 
Line 640... Line 640...
640
    popa
640
    popa
Line 661... Line 661...
661
    mov     ebx, 5      ; Open TCP socket
661
    mov     ebx, 5      ; Open TCP socket
662
    mov     esi, [DataIP]      ; remote IP address
662
    mov     esi, [DataIP]      ; remote IP address
663
    mov     edx, [DataPort]    ; remote port
663
    mov     edx, [DataPort]    ; remote port
664
    mov     ecx, 20     ; ftp data port id
664
    mov     ecx, 20     ; ftp data port id
665
    mov     edi, 1      ; active open
665
    mov     edi, 1      ; active open
666
    int     0x40
666
    mcall
667
    mov     [DataSocket], eax
667
    mov     [DataSocket], eax
Line 668... Line 668...
668
 
668
 
Line 669... Line 669...
669
    popa
669
    popa
Line 851... Line 851...
851
        mov     ebx, dirinfoblock
851
        mov     ebx, dirinfoblock
852
        and     dword [ebx+4], 0        ; start from zero block
852
        and     dword [ebx+4], 0        ; start from zero block
853
sd001:
853
sd001:
854
; Read the next DirBlocksPerCall (=16) blocks
854
; Read the next DirBlocksPerCall (=16) blocks
855
        mov     eax, 70
855
        mov     eax, 70
856
        int     0x40
856
        mcall
857
; Did we read anything?
857
; Did we read anything?
858
        test    eax, eax
858
        test    eax, eax
859
        jz      @f
859
        jz      @f
860
        cmp     eax, 6
860
        cmp     eax, 6
861
        jnz     sd_exit
861
        jnz     sd_exit
Line 1065... Line 1065...
1065
    and     dword [ebx+4], 0 ; first block
1065
    and     dword [ebx+4], 0 ; first block
Line 1066... Line 1066...
1066
 
1066
 
1067
sf002a:
1067
sf002a:
1068
    ; now read the file..    
1068
    ; now read the file..    
1069
    mov     eax,70
1069
    mov     eax,70
1070
    int     0x40
1070
    mcall
1071
    test    eax, eax
1071
    test    eax, eax
1072
    jz      @f
1072
    jz      @f
1073
    cmp     eax, 6
1073
    cmp     eax, 6
1074
    jnz     sf_exit
1074
    jnz     sf_exit
Line 1081... Line 1081...
1081
    test    eax, eax
1081
    test    eax, eax
1082
    jnz     sf_exit
1082
    jnz     sf_exit
1083
; wait a bit
1083
; wait a bit
1084
    mov     eax, 5
1084
    mov     eax, 5
1085
    mov     ebx, 10
1085
    mov     ebx, 10
1086
    int     0x40
1086
    mcall
1087
    mov     ebx, fileinfoblock
1087
    mov     ebx, fileinfoblock
1088
    add     dword [ebx+4], edx
1088
    add     dword [ebx+4], edx
1089
    jmp     sf002a
1089
    jmp     sf002a
Line 1090... Line 1090...
1090
 
1090
 
Line 1130... Line 1130...
1130
    
1130
    
1131
gf000:
1131
gf000:
1132
    mov     eax, 53
1132
    mov     eax, 53
1133
    mov     ebx, 2                  ; Get # of bytes in input queue
1133
    mov     ebx, 2                  ; Get # of bytes in input queue
1134
    mov     ecx, [DataSocket]
1134
    mov     ecx, [DataSocket]
1135
    int     0x40
1135
    mcall
1136
    test    eax, eax
1136
    test    eax, eax
Line 1137... Line 1137...
1137
    je      gf_sleep
1137
    je      gf_sleep
1138
        
1138
        
1139
    mov     eax, 53
1139
    mov     eax, 53
1140
    mov     ebx, 3                  ; Get a byte from socket in bl
1140
    mov     ebx, 3                  ; Get a byte from socket in bl
Line 1141... Line 1141...
1141
    mov     ecx, [DataSocket]
1141
    mov     ecx, [DataSocket]
1142
    int     0x40                    ; returned data in bl
1142
    mcall                    ; returned data in bl
1143
    
1143
    
1144
    mov     esi, text + 0x1300
1144
    mov     esi, text + 0x1300
Line 1154... Line 1154...
1154
gf_sleep:
1154
gf_sleep:
1155
    ; Check to see if socket closed...
1155
    ; Check to see if socket closed...
1156
    mov     eax,53
1156
    mov     eax,53
1157
    mov     ebx,6               ; Get socket status
1157
    mov     ebx,6               ; Get socket status
1158
    mov     ecx,[DataSocket]
1158
    mov     ecx,[DataSocket]
1159
    int     0x40
1159
    mcall
Line 1160... Line 1160...
1160
 
1160
 
1161
    cmp     eax, 7
1161
    cmp     eax, 7
Line 1162... Line 1162...
1162
    jne     gf001               ; still open, so just sleep a bit
1162
    jne     gf001               ; still open, so just sleep a bit
1163
 
1163
 
1164
    ; Finished, so write the file
1164
    ; Finished, so write the file
1165
    mov     eax, [fsize]
1165
    mov     eax, [fsize]
1166
    mov     [fileinfoblock+12], eax
1166
    mov     [fileinfoblock+12], eax
1167
    mov     eax,70
1167
    mov     eax,70
Line 1168... Line 1168...
1168
    mov     ebx,fileinfoblock
1168
    mov     ebx,fileinfoblock
Line 1169... Line 1169...
1169
    int     0x40
1169
    mcall
1170
 
1170
 
1171
    ret                         ; Finished
1171
    ret                         ; Finished
1172
 
1172
 
1173
gf001:
1173
gf001:
1174
    ; wait a bit
1174
    ; wait a bit
Line 1287... Line 1287...
1287
    push    dword [ebx+12]
1287
    push    dword [ebx+12]
1288
    push    dword [ebx+16]
1288
    push    dword [ebx+16]
1289
    and     dword [ebx+12], 0
1289
    and     dword [ebx+12], 0
1290
    and     dword [ebx+16], 0
1290
    and     dword [ebx+16], 0
1291
    mov     eax, 70
1291
    mov     eax, 70
1292
    int     0x40
1292
    mcall
1293
    pop     dword [ebx+16]
1293
    pop     dword [ebx+16]
1294
    pop     dword [ebx+12]
1294
    pop     dword [ebx+12]
Line 1295... Line 1295...
1295
    
1295
    
1296
    test    eax, eax
1296
    test    eax, eax
Line 1325... Line 1325...
1325
 
1325
 
1326
cl001:
1326
cl001:
1327
    ; wait a bit
1327
    ; wait a bit
1328
    mov     eax,5
1328
    mov     eax,5
1329
    mov     ebx,10                ; Delay for up 100ms
1329
    mov     ebx,10                ; Delay for up 100ms
Line 1330... Line 1330...
1330
    int     0x40
1330
    mcall
1331
 
1331
 
1332
    ; check connection status
1332
    ; check connection status
1333
    mov     eax,53
1333
    mov     eax,53
1334
    mov     ebx,6               ; Get socket status
1334
    mov     ebx,6               ; Get socket status
Line 1335... Line 1335...
1335
    mov     ecx,[DataSocket]
1335
    mov     ecx,[DataSocket]
1336
    int     0x40
1336
    mcall
Line 1337... Line 1337...
1337
 
1337
 
Line 1361... Line 1361...
1361
 
1361
 
1362
cr001:
1362
cr001:
1363
    ; wait a bit
1363
    ; wait a bit
1364
    mov     eax,5
1364
    mov     eax,5
1365
    mov     ebx,10                ; Delay for up 100ms
1365
    mov     ebx,10                ; Delay for up 100ms
Line 1366... Line 1366...
1366
    int     0x40
1366
    mcall
1367
 
1367
 
1368
    ; check connection status
1368
    ; check connection status
1369
    mov     eax,53
1369
    mov     eax,53
1370
    mov     ebx,6               ; Get socket status
1370
    mov     ebx,6               ; Get socket status
Line 1371... Line 1371...
1371
    mov     ecx,[DataSocket]
1371
    mov     ecx,[DataSocket]
1372
    int     0x40
1372
    mcall
Line 1373... Line 1373...
1373
 
1373
 
Line 1400... Line 1400...
1400
 
1400
 
1401
cs001:
1401
cs001:
1402
    ; wait a bit
1402
    ; wait a bit
1403
    mov     eax,5
1403
    mov     eax,5
1404
    mov     ebx,10                ; Delay for up 100ms
1404
    mov     ebx,10                ; Delay for up 100ms
Line 1405... Line 1405...
1405
    int     0x40
1405
    mcall
1406
 
1406
 
1407
    ; check connection status
1407
    ; check connection status
1408
    mov     eax,53
1408
    mov     eax,53
1409
    mov     ebx,6               ; Get socket status
1409
    mov     ebx,6               ; Get socket status
Line 1410... Line 1410...
1410
    mov     ecx,[DataSocket]
1410
    mov     ecx,[DataSocket]
1411
    int     0x40
1411
    mcall
1412
 
1412
 
1413
    cmp     eax, 4
1413
    cmp     eax, 4