Inital ...
FossilOrigin-Name: 6a4d9c2728a7eaff7122cf7ef069b90fe4c75ad863d2b38b6eaffc91bef55a92
This commit is contained in:
49
src/capwap/cw_out_image_data.c
Normal file
49
src/capwap/cw_out_image_data.c
Normal file
@ -0,0 +1,49 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "capwap.h"
|
||||
#include "capwap_items.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
|
||||
#define BLOCK_SIZE 1024
|
||||
|
||||
|
||||
int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst) // ,struct cw_item * item)
|
||||
{
|
||||
cw_item_t * item = cw_itemstore_get(conn->outgoing,CW_ITEM_IMAGE_FILEHANDLE);
|
||||
if (!item) {
|
||||
cw_log(LOG_ERR,"Can't put element Image Data, no image filehandle found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE *infile = item->data;
|
||||
|
||||
|
||||
int bytes = fread(dst+5,1,BLOCK_SIZE,infile);
|
||||
|
||||
if (feof(infile)){
|
||||
if (ferror(infile)){
|
||||
cw_log(LOG_ERROR,"Aborting image data transfer: %s",strerror(errno));
|
||||
bytes=1;
|
||||
cw_put_byte(dst+4,5);
|
||||
bytes=0;
|
||||
|
||||
}
|
||||
else{
|
||||
/* Last image block */
|
||||
cw_put_byte(dst+4,2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
cw_put_byte(dst+4,1);
|
||||
}
|
||||
|
||||
|
||||
return bytes+1 + cw_put_elem_hdr(dst,a->elem_id,bytes+1);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user