From c4351c791052ad529a4e83c600b1aa6e6420ea86 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 22 Feb 2010 14:46:32 -0800 Subject: refactor applypatch and friends Change the applypatch function to take meaningful arguments instead of argc and argv. Move all the parsing of arguments into main.c (for the standalone binary) and into install.c (for the updater function). applypatch() takes patches as Value objects, so we can pass in blobs extracted from the package without ever writing them to temp files. The patching code is changed to read the patch from memory instead of a file. A bunch of compiler warnings (mostly about signed vs unsigned types) are fixed. Support for the IMGDIFF1 format is dropped. (We've been generating IMGDIFF2 packages for some time now.) Change-Id: I217563c500012750f27110db821928a06211323f --- applypatch/utils.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'applypatch/utils.c') diff --git a/applypatch/utils.c b/applypatch/utils.c index 912229b..41ff676 100644 --- a/applypatch/utils.c +++ b/applypatch/utils.c @@ -38,25 +38,28 @@ void Write8(long long value, FILE* f) { fputc((value >> 56) & 0xff, f); } -int Read2(unsigned char* p) { - return (int)(((unsigned int)p[1] << 8) | - (unsigned int)p[0]); +int Read2(void* pv) { + unsigned char* p = pv; + return (int)(((unsigned int)p[1] << 8) | + (unsigned int)p[0]); } -int Read4(unsigned char* p) { - return (int)(((unsigned int)p[3] << 24) | - ((unsigned int)p[2] << 16) | - ((unsigned int)p[1] << 8) | - (unsigned int)p[0]); +int Read4(void* pv) { + unsigned char* p = pv; + return (int)(((unsigned int)p[3] << 24) | + ((unsigned int)p[2] << 16) | + ((unsigned int)p[1] << 8) | + (unsigned int)p[0]); } -long long Read8(unsigned char* p) { - return (long long)(((unsigned long long)p[7] << 56) | - ((unsigned long long)p[6] << 48) | - ((unsigned long long)p[5] << 40) | - ((unsigned long long)p[4] << 32) | - ((unsigned long long)p[3] << 24) | - ((unsigned long long)p[2] << 16) | - ((unsigned long long)p[1] << 8) | - (unsigned long long)p[0]); +long long Read8(void* pv) { + unsigned char* p = pv; + return (long long)(((unsigned long long)p[7] << 56) | + ((unsigned long long)p[6] << 48) | + ((unsigned long long)p[5] << 40) | + ((unsigned long long)p[4] << 32) | + ((unsigned long long)p[3] << 24) | + ((unsigned long long)p[2] << 16) | + ((unsigned long long)p[1] << 8) | + (unsigned long long)p[0]); } -- cgit v1.1