reduce message length fields for meshms to reflect 64KB message size

limit.
This commit is contained in:
gardners 2013-05-15 20:58:55 +09:30
parent 8223b1e8ff
commit a66f5eb701

View File

@ -78,7 +78,7 @@ int encode_length_forwards(unsigned char *buffer,int *offset,
if (length<0xff) { buffer[(*offset)++]=length; return 0; }
buffer[(*offset)++]=0xff;
int i;
for(i=0;i<32;i+=8) buffer[(*offset)++]=(length>>i)&0xff;
for(i=0;i<16;i+=8) buffer[(*offset)++]=(length>>i)&0xff;
return 0;
}
@ -87,7 +87,7 @@ int encode_length_backwards(unsigned char *buffer,int *offset,
{
if (length<0xff) { buffer[(*offset)++]=length; return 0; }
int i;
for(i=0;i<32;i+=8) buffer[(*offset)++]=(length>>i)&0xff;
for(i=0;i<16;i+=8) buffer[(*offset)++]=(length>>i)&0xff;
buffer[(*offset)++]=0xff;
return 0;
}
@ -103,7 +103,7 @@ int decode_length_forwards(unsigned char *buffer,int *offset,
(*offset)++;
if (*offset>=buffer_length) return -1;
int i;
for(i=0;i<32;i+=8) {
for(i=0;i<16;i+=8) {
(*length)|=buffer[(*offset)++]<<i;
if (*offset>=buffer_length) return -1;
}
@ -127,7 +127,7 @@ int decode_length_backwards(unsigned char *buffer,int offset,
case 0xff:
offset-=4;
int i;
for(i=0;i<32;i+=8) (*length)|=buffer[offset++]<<i;
for(i=0;i<16;i+=8) (*length)|=buffer[offset++]<<i;
return 0;
default:
*length=buffer[offset];