aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plpftp/ftp.cc29
-rw-r--r--plpftp/main.cc6
2 files changed, 32 insertions, 3 deletions
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 <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <signal.h>
#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;