struct bsdiff_header
{
uint8_t signature[8];
- uint8_t ctrl_block_length[8];
- uint8_t diff_block_length[8];
- uint8_t new_file_length[8];
+ uint64_t ctrl_block_length;
+ uint64_t diff_block_length;
+ uint64_t new_file_length;
};
struct bsdiff_stream
?? ?? Bzip2ed diff block
?? ?? Bzip2ed extra block */
memcpy(req.header->signature,"BSDIFF40",sizeof(req.header->signature));
- offtout(req.newsize, req.header->new_file_length);
+ req.header->new_file_length = req.newsize;
/* Compute the differences, writing ctrl as we go */
scan=0;len=0;
filelen += compresslen;
/* Compute size of compressed ctrl data */
- offtout(filelen, req.header->ctrl_block_length);
+ req.header->ctrl_block_length = filelen;
/* Write compressed diff data */
filelen = 0;
filelen += compresslen;
/* Compute size of compressed diff data */
- offtout(filelen, req.header->diff_block_length);
+ req.header->diff_block_length = filelen;
/* Write compressed extra data */
compresslen = writecompressed(req.stream, eb, eblen);
uint8_t *old,*new;
off_t oldsize,newsize;
struct bsdiff_header header;
+ uint8_t buf[8];
FILE * pf;
struct bsdiff_stream stream;
bz_stream bz2;
err(1, "bsdiff");
if (fseek(pf, 0, SEEK_SET) ||
- fwrite(&header, sizeof(header), 1, pf) != 1)
+ fwrite(&header.signature, sizeof(header.signature), 1, pf) != 1)
+ err(1, "Failed to write header");
+ offtout(header.ctrl_block_length, buf);
+ if (fwrite(buf, sizeof(buf), 1, pf) != 1)
+ err(1, "Failed to write header");
+ offtout(header.diff_block_length, buf);
+ if (fwrite(buf, sizeof(buf), 1, pf) != 1)
+ err(1, "Failed to write header");
+ offtout(header.new_file_length, buf);
+ if (fwrite(buf, sizeof(buf), 1, pf) != 1)
err(1, "Failed to write header");
if (fclose(pf))