From 7cc4d5555ef3fc7d39d3d0e2b3a041aa3fc89aa6 Mon Sep 17 00:00:00 2001
From: hidnplayr <hidnplayr@kolibrios.org>
Date: Tue, 9 Jul 2013 21:59:02 +0000
Subject: [PATCH] FTPc: added pwd command, bugfixes

git-svn-id: svn://kolibrios.org@3794 a494cfbc-eb01-0410-851d-a64ba20cac60
---
 programs/network/ftpc/ftpc.asm         | 21 +++++++++++++++------
 programs/network/ftpc/usercommands.inc |  9 ++++++++-
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/programs/network/ftpc/ftpc.asm b/programs/network/ftpc/ftpc.asm
index 5aee1a7cf0..c747024b68 100644
--- a/programs/network/ftpc/ftpc.asm
+++ b/programs/network/ftpc/ftpc.asm
@@ -194,6 +194,8 @@ wait_for_usercommand:
 ; read string
         mov     esi, s
         invoke  con_gets, esi, 256
+
+        invoke  con_write_asciiz, str4          ; newline
         invoke  con_set_flags, 0x07
 
         cmp     dword[s], "list"
@@ -208,6 +210,9 @@ wait_for_usercommand:
         cmp     dword[s], "retr"
         je      cmd_retr
 
+        cmp     dword[s], "pwd" + 10 shl 24
+        je      cmd_pwd
+
 ;        cmp     dword[s], "stor"
 ;        je      cmd_stor
 
@@ -284,7 +289,7 @@ exit:
 
 ; data
 title   db 'FTP client',0
-str1    db 'FTP client for KolibriOS v0.03',10,10,'Please enter ftp server address.',10,0
+str1    db 'FTP client for KolibriOS v0.04',10,10,'Please enter ftp server address.',10,0
 str2    db '> ',0
 str3    db 'Resolving ',0
 str4    db 10,0
@@ -298,8 +303,8 @@ str12   db 'Waiting for welcome message.',10,0
 str_user db "username: ",0
 str_pass db "password: ",0
 str_unknown db "unknown command",10,0
-str_help db "available commands:",10,10
-         db "help       list",10,0
+str_help db "available commands:",10
+         db "help    list    cwd     retr    pwd",10,10,0
 
 str_open db "opening data socket",10,0
 
@@ -343,15 +348,19 @@ import  console,        \
 
 i_end:
 
+align 4
+status          db ?
 active_passive  db ?
+
+align 4
 socketnum       dd ?
 datasocket      dd ?
-buffer_ptr      rb BUFFERSIZE
-buffer_ptr2     rb BUFFERSIZE
-status          db ?
 offset          dd ?
 size            dd ?
 
+buffer_ptr      rb BUFFERSIZE+1
+buffer_ptr2     rb BUFFERSIZE+1
+
 s               rb 1024
 
 mem:
diff --git a/programs/network/ftpc/usercommands.inc b/programs/network/ftpc/usercommands.inc
index b1ca064635..887ae497cb 100644
--- a/programs/network/ftpc/usercommands.inc
+++ b/programs/network/ftpc/usercommands.inc
@@ -4,7 +4,7 @@ cmd_list:
 
         mov     dword[s], "LIST"
         mov     byte[s+4], 0x0a
-        mcall   send, [socketnum], s, 5
+        mcall   send, [socketnum], s, 5, 0
 
         jmp     wait_for_servercommand
 
@@ -16,6 +16,13 @@ cmd_help:
 
         jmp     wait_for_usercommand
 
+cmd_pwd:
+
+        mov     dword[s], "PWD" + 10 shl 24
+        mcall   send, [socketnum], s, 4, 0
+
+        jmp     wait_for_servercommand
+
 cmd_cwd:
 
         mov     dword[s], "CWD "