[tyndur-devel] [PATCH] FTP-Client
Paul Lange ·
*ftp: Befehl rm wurde hinzugefügt! Ist ja doof ohne löschen auf dem Server ;-) Signed-off-by: Paul Lange <matheeguru at gmx.de> --- Makefile | 5 ++--- src/modules/c/ftp/command.c | 12 ++++++++++++ src/modules/c/ftp/command.h | 6 +++++- src/modules/c/ftp/help.c | 1 + src/modules/c/ftp/main.c | 10 ++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9b63409..63c8c47 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PPC=fpc -n -Cn -CX -Ttyndur -Fu../lib/units -Fu../units ASM_ELF=nasm -felf -O99 ASM_BIN=nasm -fbin -O99 -BUILD_ROOT=/home/kevin/entwicklung/tyndur/build/output +BUILD_ROOT=/home/paul/Projekte/tyndur/build/output BUILD_DIR=$(BUILD_ROOT) AS=as -32 @@ -22,11 +22,10 @@ obj: subdirs: $(MAKE) --no-print-directory -sC doc - $(MAKE) --no-print-directory -sC patches $(MAKE) --no-print-directory -sC src clean: - rm -f *.o *.a *.mod + rm -f *.o *.a *.mod *.ppu link.res ppas.sh tyndur for file in *; do if [ -f "$$file/Makefile" -a \( ! -f "$$file/.nobuild" -o -f "$$file/.ignorenobuild" \) ]; then $(MAKE) -sC "$$file" clean; rm "$$file/Makefile"; fi done .SILENT: all makefiles subdirs obj clean clean_root updateroot image-floppy image-hd test-qemu test-qemu-hd diff --git a/src/modules/c/ftp/command.c b/src/modules/c/ftp/command.c index 7da54d7..bf326c5 100644 --- a/src/modules/c/ftp/command.c +++ b/src/modules/c/ftp/command.c @@ -180,6 +180,18 @@ void ftp_mkdir(const char* pathname) response(); } +void ftp_rm(const char* pathname) +{ + if (handle == NULL) { + puts("\033[1;37mes besteht keine Serververbindung...\033[0m"); + return; + } + + fprintf(handle, "DELE %s\r\n", pathname); + fflush(handle); + response(); +} + void ftp_rmdir(const char* pathname) { if (handle == NULL) { diff --git a/src/modules/c/ftp/command.h b/src/modules/c/ftp/command.h index a5a27e9..f81ae19 100644 --- a/src/modules/c/ftp/command.h +++ b/src/modules/c/ftp/command.h @@ -46,8 +46,12 @@ void ftp_account(void); // @param Pfadname+Dateiname void ftp_mkdir(const char*); -// loescht ein Verzeichniss auf dem FTP-Server +// loescht eine Datei auf dem FTP-Server // @param Pfadname+Dateiname +void ftp_rm(const char*); + +// loescht ein Verzeichniss auf dem FTP-Server +// @param Pfadname void ftp_rmdir(const char*); // wechselt das Verzeichniss auf dem FTP-Server diff --git a/src/modules/c/ftp/help.c b/src/modules/c/ftp/help.c index 4b8b8d5..79dae27 100644 --- a/src/modules/c/ftp/help.c +++ b/src/modules/c/ftp/help.c @@ -49,4 +49,5 @@ const char* help = "open - [ftp.name.net] öffnet eine Verbindung zu einem Server\n" "put - [Pfad+Dateiname] speichert eine Datei auf dem Server\n" "quit - schließt die Verbindung zum Server und beendet den FTP-Client\n" + "rm - [Pfad+Dateiname] löscht die Datei auf dem Server\n" "rmdir - [Pfad+Ordnername] löscht einen Ordner auf dem Server\n"; diff --git a/src/modules/c/ftp/main.c b/src/modules/c/ftp/main.c index 12e19cb..34acd62 100644 --- a/src/modules/c/ftp/main.c +++ b/src/modules/c/ftp/main.c @@ -95,6 +95,16 @@ int main(int argc, char* argv[]) ftp_mkdir(input); } + } else if (!strncmp(input, "rm", 2)) { + input += 2; + for (; isspace(*input); input++); + if (*input != '\0') { + for (buffer = input; !isspace(*buffer) && *buffer; + buffer++); + *buffer = '\0'; + + ftp_rm(input); + } } else if (!strncmp(input, "rmdir", 5)) { input += 5; for (; isspace(*input); input++); -- 1.6.0.4
Antworten
- [tyndur-devel] [PATCH] FTP-Client · Kevin Wolf