1#ifndef DELTA_H 2#define DELTA_H 3 4/* handling of delta buffers */ 5externvoid*diff_delta(const void*from_buf,unsigned long from_size, 6const void*to_buf,unsigned long to_size, 7unsigned long*delta_size,unsigned long max_size); 8externvoid*patch_delta(void*src_buf,unsigned long src_size, 9const void*delta_buf,unsigned long delta_size, 10unsigned long*dst_size); 11 12/* the smallest possible delta size is 4 bytes */ 13#define DELTA_SIZE_MIN 4 14 15/* 16 * This must be called twice on the delta data buffer, first to get the 17 * expected reference buffer size, and again to get the result buffer size. 18 */ 19staticinlineunsigned longget_delta_hdr_size(const unsigned char**datap, 20const unsigned char*top) 21{ 22const unsigned char*data = *datap; 23unsigned char cmd; 24unsigned long size =0; 25int i =0; 26do{ 27 cmd = *data++; 28 size |= (cmd & ~0x80) << i; 29 i +=7; 30}while(cmd &0x80&& data < top); 31*datap = data; 32return size; 33} 34 35#endif