From 3574706f9733e25590ca251a5ceeae1d89ca0f7e Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Thu, 1 Jul 1999 20:46:27 +0000 Subject: moved dir display from rfsv to ftp. --- plpftp/ftp.cc | 29 +++++++++++++++++++++++++++-- plpftp/main.cc | 6 +++++- 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'plpftp') diff --git a/plpftp/ftp.cc b/plpftp/ftp.cc index 16a3bc2..70111e2 100644 --- a/plpftp/ftp.cc +++ b/plpftp/ftp.cc @@ -236,8 +236,33 @@ session(rfsv32 & a, int xargc, char **xargv) continue; } if ((!strcmp(argv[0], "ls")) || (!strcmp(argv[0], "dir"))) { - if ((res = a.dir(psionDir, NULL)) != 0) + bufferArray files; + if ((res = a.dir(psionDir, &files)) != 0) errprint(res, a); + else + while (!files.empty()) { + bufferStore s; + s = files.popBuffer(); + long date = s.getDWord(0); + long size = s.getDWord(4); + long attr = s.getDWord(8); + char dateBuff[100]; + struct tm *t; + t = localtime(&date); + strftime(dateBuff, 100, "%c", t); + cout << ((attr & rfsv32::PSI_ATTR_DIRECTORY) ? "d" : "-"); + cout << ((attr & rfsv32::PSI_ATTR_RONLY) ? "-" : "w"); + cout << ((attr & rfsv32::PSI_ATTR_HIDDEN) ? "h" : "-"); + cout << ((attr & rfsv32::PSI_ATTR_SYSTEM) ? "s" : "-"); + cout << ((attr & rfsv32::PSI_ATTR_ARCHIVE) ? "a" : "-"); + cout << ((attr & rfsv32::PSI_ATTR_VOLUME) ? "v" : "-"); + cout << ((attr & rfsv32::PSI_ATTR_NORMAL) ? "n" : "-"); + cout << ((attr & rfsv32::PSI_ATTR_TEMPORARY) ? "t" : "-"); + cout << ((attr & rfsv32::PSI_ATTR_COMPRESSED) ? "c" : "-"); + cout << " " << dec << setw(10) << setfill(' ') << size; + cout << " " << dateBuff; + cout << " " << s.getString(12) << endl; + } continue; } if (!strcmp(argv[0], "lcd")) { @@ -460,7 +485,7 @@ session(rfsv32 & a, int xargc, char **xargv) if (strcmp(argv[0], "bye") && strcmp(argv[0], "quit")) usage(); } while (strcmp(argv[0], "bye") && strcmp(argv[0], "quit") && - (a.getStatus() == 0) && (once == 0)); + ((a.getStatus() == 0) || (once == 0))); return a.getStatus(); } diff --git a/plpftp/main.cc b/plpftp/main.cc index e4e0875..2887e1c 100644 --- a/plpftp/main.cc +++ b/plpftp/main.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include "defs.h" #include "bool.h" @@ -56,9 +57,13 @@ main(int argc, char **argv) { ppsocket *skt; bool res; + sigset_t sigset; // Command line parameter processing int sockNum = DPORT; + sigemptyset(&sigset); + sigaddset(&sigset, SIGPIPE); + sigprocmask(SIG_BLOCK, &sigset, 0L); if ((argc > 2) && !strcmp(argv[1], "-s")) { sockNum = atoi(argv[2]); @@ -70,7 +75,6 @@ main(int argc, char **argv) if (argc < 2) ftpHeader(); skt = new ppsocket(); - skt->startup(); res = skt->connect(NULL, sockNum); if (!res) { delete skt; -- cgit v1.2.3