Inital commit.
FossilOrigin-Name: 7c7ad097c2960ff4fc53e7bd60815f046b3be71a30a6781ae171cba7c0dd7027
This commit is contained in:
parent
29cc65862b
commit
86c06c99b0
26
src/capwap/cw_put_image_data.c
Normal file
26
src/capwap/cw_put_image_data.c
Normal 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;
|
||||
}
|
||||
|
||||
|
25
src/capwap/lw_put_image_data.c
Normal file
25
src/capwap/lw_put_image_data.c
Normal 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user