commit - 45e973a82e52804a0e13d4616581ae79c0048577
commit + 5565d021835b6c976da86e95f176b4cce5ba277c
blob - 6e182e45eeacdb0fa1564313cfcf5d4e780a871c
blob + 4abc64b5416fcca68dd9346ca94a312f4c6eb8df
--- kamiftp/ftp.c
+++ kamiftp/ftp.c
volatile sig_atomic_t resized;
int tty_p;
int tty_width;
+int xdump;
struct np_stat {
uint16_t type;
size_t nbytes;
ssize_t r;
+ if (xdump)
+ hexdump("outgoing message", EVBUFFER_DATA(evb),
+ EVBUFFER_LENGTH(evb));
+
while (EVBUFFER_LENGTH(evb) != 0) {
buf = EVBUFFER_DATA(evb);
nbytes = EVBUFFER_LENGTH(evb);
len -= l;
evbuffer_add(buf, tmp, l);
}
+
+ if (xdump)
+ hexdump("incoming packet", EVBUFFER_DATA(buf),
+ EVBUFFER_LENGTH(buf));
}
static uint64_t
struct winsize ws;
int i, l, w;
double perc;
+
+ if (xdump)
+ return;
perc = 100.0 * p->done / p->max;
if (!tty_p) {
fetch_fid(nfid, fd, l);
close(fd);
+}
+
+static void
+cmd_hexdump(int argc, const char **argv)
+{
+ if (argc == 0) {
+ xdump = !xdump;
+ if (xdump)
+ puts("hexdump mode enabled");
+ else
+ puts("hexdump mode disabled");
+ return;
+ }
+
+ if (argc > 1)
+ goto usage;
+
+ if (!strcmp(*argv, "on")) {
+ xdump = 1;
+ puts("hexdump mode enabled");
+ return;
+ }
+
+ if (!strcmp(*argv, "off")) {
+ xdump = 0;
+ puts("hexdump mode disabled");
+ return;
+ }
+
+usage:
+ puts("usage: hexdump [on | off]");
}
static void
{"cd", cmd_cd},
{"edit", cmd_edit},
{"get", cmd_get},
+ {"hexdump", cmd_hexdump},
{"lcd", cmd_lcd},
{"lpwd", cmd_lpwd},
{"ls", cmd_ls},
blob - 55516a7c5ba5124db19059ed6ffbbd7214174e90
blob + 179997c90b94a4a1ea64064b35c36facb4a9af7d
--- kamiftp/kamiftp.1
+++ kamiftp/kamiftp.1
.Ar local-file
is not given, use the file name from
.Ar remote-file .
+.It Ic hexdump Oo Cm on | off Oc
+Print the packets sent from/to the server.
+Without arguments, toggle the current state.
.It Ic lcd Op Ar local-directory
Change the local current working directory to
.Ar local-directory