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 = 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 string decimal which is the sum of every byte when taken as an
unsigned char per byte. the checksum is a signed 32bit integer. unsigned char per byte. the checksum is a signed 32bit integer.
the checksum is the sum of the data after escaping. data will be the checksum is the sum of the data after escaping. 4 bits at a
escaped using a 0xff byte as the escape header. the escape sequence time per data byte, encoded with high bits in one byte then low
of 0xff 0x01 represents a 0x00 (nul) bytes, and 0xff 0x02 represents bits, with the bits ecnoded as 4 bit value being 0x40 + 4 bit value
a 0xff byte. all other bytes are transitted as-is. 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 fx
= exit file send mode (normally at the end of the file or when it's = 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(); Eina_Binbuf *bb = eina_binbuf_new();
unsigned char v; unsigned char v;
int inp = 0;
if (bb) if (bb)
{ {
@ -6047,17 +6046,12 @@ _smart_pty_command(void *data)
{ {
v = (unsigned char)(*p); v = (unsigned char)(*p);
sum += v; sum += v;
inp++;
if ((v == 0x1b) || (v == 0x07)) v = ((v - '@') & 0xf) << 4;
{ p++;
p++; sum += *p;
v = *p; v |= ((*p - '@') & 0xf);
inp++; if (!*p) valid = EINA_FALSE;
sum += (unsigned char)(*p);
if (*p == 0x01) v = 0x00;
else if (*p == 0x02) v = 0xff;
else valid = EINA_FALSE;
}
eina_binbuf_append_char(bb, v); eina_binbuf_append_char(bb, v);
} }
if ((valid) && (sum == pksum) && (sd->sendfile.active)) if ((valid) && (sum == pksum) && (sd->sendfile.active))

View File

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