Inital commit.

FossilOrigin-Name: 7c7ad097c2960ff4fc53e7bd60815f046b3be71a30a6781ae171cba7c0dd7027
This commit is contained in:
7u83@mail.ru 2015-04-13 08:59:47 +00:00
parent 29cc65862b
commit 86c06c99b0
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,26 @@
#include "capwap.h"
int cw_put_image_data(uint8_t *dst,FILE *infile)
{
int bytes = fread(dst+1,1,1024,infile);
if (ferror(infile)){
cw_put_byte(dst+0,5);
return 1;
}
if ( feof(infile)){
/* Last image block */
cw_put_byte(dst,2);
}
else{
cw_put_byte(dst,1);
}
return bytes+1;
}

View File

@ -0,0 +1,25 @@
#include "lwapp.h"
int lw_put_image_data(uint8_t *dst,FILE *infile)
{
if ( feof(infile)){
lw_put_byte(dst+0,1);
return 1;
}
int bytes = fread(dst+3,1,LW_BLOCKSIZE_IMAGE_DATA,infile);
if ( ferror(infile)) {
lw_put_byte(dst+0,5);
return 1;
}
lw_put_byte(dst,3);
uint16_t checksum = lw_checksum(dst+3,bytes);
lw_put_word(dst+1,checksum);
return bytes+3;
}