Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 485 → Rev 481

/programs/network/ftps/trunk/FTPS.ASM
20,7 → 20,7
dd 0x7FFF0 ; esp = 0x7FFF0
dd 0, 0 ; no params, no path
 
include '..\..\..\macros.inc'
include 'macros.inc'
; Various states of client connection
USER_NONE equ 0 ; Awaiting a connection
USER_CONNECTED equ 1 ; User just connected, prompt given
55,7 → 55,7
mov eax,53
mov ebx,6 ; Get socket status
mov ecx,[CmdSocket]
mcall
int 0x40
 
mov ebx, [CmdSocketStatus]
mov [CmdSocketStatus], eax
97,7 → 97,7
waitev:
mov eax,23 ; wait here for event
mov ebx,1 ; Delay for up to 1s
mcall
int 0x40
 
cmp eax,1 ; redraw request ?
je red
111,7 → 111,7
mov eax, 53
mov ebx, 2 ; Get # of bytes in input queue
mov ecx, [CmdSocket]
mcall
int 0x40
test eax, eax
jz still
 
119,7 → 119,7
mov eax, 53
mov ebx, 3 ; Get a byte from socket in bl
mov ecx, [CmdSocket]
mcall
int 0x40
 
call ftpRxCmdData ; process incoming ftp command
 
127,7 → 127,7
mov eax, 53
mov ebx, 2 ; Get # of bytes in input queue
mov ecx, [CmdSocket]
mcall
int 0x40
cmp eax, 0
jne read_input
 
145,12 → 145,12
 
key: ; KEY
mov eax,2 ; get but ignore
mcall
int 0x40
jmp still
 
button:
mov eax,17
mcall
int 0x40
cmp ah,1
jne still
 
158,11 → 158,11
mov eax,53
mov ebx,8
mov ecx,[CmdSocket]
mcall
int 0x40
 
; ... terminate program
or eax,-1
mcall
mov eax,-1
int 0x40
jmp still
 
 
175,7 → 175,7
 
mov eax,12
mov ebx,1
mcall
int 0x40
 
xor eax,eax ; DRAW WINDOW
mov ebx,100*65536+491 + 8 +15
182,7 → 182,7
mov ecx,100*65536+270 + 20 ; 20 for status bar
mov edx,0x13000000
mov edi,labelt
mcall
int 0x40
 
; draw status bar
mov eax, 13
189,7 → 189,7
mov ebx, 4*65536+484 + 8 +15
mov ecx, 270*65536 + 3
mov edx, 0x00557799
mcall
int 0x40
 
 
mov esi,contlen-contt ; display connected status
203,7 → 203,7
mov eax,4 ; status text
mov ebx,380*65536+276
mov ecx,0x00ffffff
mcall
int 0x40
 
; Draw the text on the screen, clearing it first
; This can go when we loose debuggin info.
217,7 → 217,7
 
mov eax,12
mov ebx,2
mcall
int 0x40
 
popa
 
262,7 → 262,7
shl ebx, 16
mov bx, 6
mov eax, 13
mcall
int 0x40
popa
 
; draw character
278,7 → 278,7
mov eax,4
mov edx,esi
mov esi,1
mcall
int 0x40
popa
 
noletter:
431,7 → 431,7
mov eax,53
mov ebx,7
mov ecx,[CmdSocket]
mcall
int 0x40
pop edx
pop esi
442,7 → 442,7
pusha
mov eax,5
mov ebx,1 ; Delay for up 100ms
mcall
int 0x40
popa
jmp outputStr
os_exit:
468,7 → 468,7
mov eax,53
mov ebx,7
mov ecx,[DataSocket]
mcall
int 0x40
pop edx
pop esi
 
479,7 → 479,7
pusha
mov eax,5
mov ebx,20 ; Delay for upto 200ms
mcall
int 0x40
popa
jmp outputDataStr
ods_exit:
580,7 → 580,7
mov eax, 53 ; Stack Interface
mov ebx,8 ; Close TCP socket
mov ecx,[CmdSocket]
mcall
int 0x40
ret
 
602,13 → 602,13
pusha
mov eax,5
mov ebx,200 ; Delay for 2s
mcall
int 0x40
popa
 
mov eax, 53 ; Stack Interface
mov ebx,8 ; Close TCP socket
mov ecx,[DataSocket]
mcall
int 0x40
ret
 
 
634,7 → 634,7
mov edx, 0 ; No remote port
mov ecx, 21 ; ftp command port id
mov edi, 0 ; passive open
mcall
int 0x40
mov [CmdSocket], eax
 
popa
663,7 → 663,7
mov edx, [DataPort] ; remote port
mov ecx, 20 ; ftp data port id
mov edi, 1 ; active open
mcall
int 0x40
mov [DataSocket], eax
 
popa
853,7 → 853,7
sd001:
; Read the next DirBlocksPerCall (=16) blocks
mov eax, 70
mcall
int 0x40
; Did we read anything?
test eax, eax
jz @f
1067,7 → 1067,7
sf002a:
; now read the file..
mov eax,70
mcall
int 0x40
test eax, eax
jz @f
cmp eax, 6
1083,7 → 1083,7
; wait a bit
mov eax, 5
mov ebx, 10
mcall
int 0x40
mov ebx, fileinfoblock
add dword [ebx+4], edx
jmp sf002a
1132,7 → 1132,7
mov eax, 53
mov ebx, 2 ; Get # of bytes in input queue
mov ecx, [DataSocket]
mcall
int 0x40
test eax, eax
je gf_sleep
1139,7 → 1139,7
mov eax, 53
mov ebx, 3 ; Get a byte from socket in bl
mov ecx, [DataSocket]
mcall ; returned data in bl
int 0x40 ; returned data in bl
mov esi, text + 0x1300
add esi, dword [fsize]
1156,7 → 1156,7
mov eax,53
mov ebx,6 ; Get socket status
mov ecx,[DataSocket]
mcall
int 0x40
 
cmp eax, 7
jne gf001 ; still open, so just sleep a bit
1166,7 → 1166,7
mov [fileinfoblock+12], eax
mov eax,70
mov ebx,fileinfoblock
mcall
int 0x40
 
ret ; Finished
 
1174,7 → 1174,7
; wait a bit
mov eax,5
mov ebx,10 ; Delay for up 100ms
mcall
int 0x40
jmp gf000 ; try for more data
1289,7 → 1289,7
and dword [ebx+12], 0
and dword [ebx+16], 0
mov eax, 70
mcall
int 0x40
pop dword [ebx+16]
pop dword [ebx+12]
1327,13 → 1327,13
; wait a bit
mov eax,5
mov ebx,10 ; Delay for up 100ms
mcall
int 0x40
 
; check connection status
mov eax,53
mov ebx,6 ; Get socket status
mov ecx,[DataSocket]
mcall
int 0x40
 
cmp eax, 4
jne cl001
1363,13 → 1363,13
; wait a bit
mov eax,5
mov ebx,10 ; Delay for up 100ms
mcall
int 0x40
 
; check connection status
mov eax,53
mov ebx,6 ; Get socket status
mov ecx,[DataSocket]
mcall
int 0x40
 
cmp eax, 4
jne cr001
1402,13 → 1402,13
; wait a bit
mov eax,5
mov ebx,10 ; Delay for up 100ms
mcall
int 0x40
 
; check connection status
mov eax,53
mov ebx,6 ; Get socket status
mov ecx,[DataSocket]
mcall
int 0x40
 
cmp eax, 4
je @f
/programs/network/ftps/trunk/macros.inc
0,0 → 1,269
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
dw ? ; +52 - reserved
.client_left dd ? ; +54
.client_top dd ? ; +58
.client_width dd ? ; +62
.client_height dd ? ; +66
.wnd_state db ? ; +70
rb (1024-71)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b