tysend - i was only testing ascii files. binary doesnt trasnfer well...

so move to 4 bit nibbles encoded as ascii. inefficient but works
reliably.
This commit is contained in:
Carsten Haitzler 2017-12-18 00:51:52 +09:00
parent 125d475068
commit 15e3c87390
3 changed files with 15 additions and 31 deletions

10
README
View File

@ -310,10 +310,12 @@ fd[CHECKSUM DATA]
= block of data for the current file transfer with checksum as a
string decimal which is the sum of every byte when taken as an
unsigned char per byte. the checksum is a signed 32bit integer.
the checksum is the sum of the data after escaping. data will be
escaped using a 0xff byte as the escape header. the escape sequence
of 0xff 0x01 represents a 0x00 (nul) bytes, and 0xff 0x02 represents
a 0xff byte. all other bytes are transitted as-is.
the checksum is the sum of the data after escaping. 4 bits at a
time per data byte, encoded with high bits in one byte then low
bits, with the bits ecnoded as 4 bit value being 0x40 + 4 bit value
per byte. (@ == 0x0, A == 0x1, B == 0x2, ... N == 0xe, O == 0xf).
so to rebuild a byte will be (((bytes[0] - 0x40) & 0xf) << 4) |
((bytes[1] - 0x40) & 0xf) per byte pair in the data block.
fx
= exit file send mode (normally at the end of the file or when it's

View File

@ -6037,7 +6037,6 @@ _smart_pty_command(void *data)
{
Eina_Binbuf *bb = eina_binbuf_new();
unsigned char v;
int inp = 0;
if (bb)
{
@ -6047,17 +6046,12 @@ _smart_pty_command(void *data)
{
v = (unsigned char)(*p);
sum += v;
inp++;
if ((v == 0x1b) || (v == 0x07))
{
p++;
v = *p;
inp++;
sum += (unsigned char)(*p);
if (*p == 0x01) v = 0x00;
else if (*p == 0x02) v = 0xff;
else valid = EINA_FALSE;
}
v = ((v - '@') & 0xf) << 4;
p++;
sum += *p;
v |= ((*p - '@') & 0xf);
if (!*p) valid = EINA_FALSE;
eina_binbuf_append_char(bb, v);
}
if ((valid) && (sum == pksum) && (sd->sendfile.active))

View File

@ -87,27 +87,15 @@ main(int argc, char **argv)
{
if (buf[0] == 'k')
{
pksize = read(file_fd, rawbuf, 8192);
pksize = read(file_fd, rawbuf, 4096);
if (pksize > 0)
{
bout = 0;
for (bin = 0; bin < pksize; bin++)
{
if (rawbuf[bin] == 0x00)
{
rawbuf2[bout++] = 0xff;
rawbuf2[bout++] = 0x01;
}
else if (rawbuf[bin] == 0xff)
{
rawbuf2[bout++] = 0xff;
rawbuf2[bout++] = 0x02;
}
else
{
rawbuf2[bout++] = rawbuf[bin];
}
rawbuf2[bout++] = (rawbuf[bin] >> 4 ) + '@';
rawbuf2[bout++] = (rawbuf[bin] & 0xf) + '@';
}
rawbuf2[bout] = 0;
pksum = 0;