The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _APPLYPATCH_H |
| 18 | #define _APPLYPATCH_H |
| 19 | |
Doug Zongker | 5a79087 | 2009-06-12 09:42:43 -0700 | [diff] [blame] | 20 | #include <sys/stat.h> |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 21 | #include "mincrypt/sha.h" |
| 22 | |
| 23 | typedef struct _Patch { |
| 24 | uint8_t sha1[SHA_DIGEST_SIZE]; |
| 25 | const char* patch_filename; |
| 26 | } Patch; |
| 27 | |
| 28 | typedef struct _FileContents { |
| 29 | uint8_t sha1[SHA_DIGEST_SIZE]; |
| 30 | unsigned char* data; |
| 31 | size_t size; |
| 32 | struct stat st; |
| 33 | } FileContents; |
| 34 | |
| 35 | // When there isn't enough room on the target filesystem to hold the |
| 36 | // patched version of the file, we copy the original here and delete |
| 37 | // it to free up space. If the expected source file doesn't exist, or |
| 38 | // is corrupted, we look to see if this file contains the bits we want |
| 39 | // and use it as the source instead. |
| 40 | #define CACHE_TEMP_SOURCE "/cache/saved.file" |
| 41 | |
Doug Zongker | 6c77046 | 2009-07-22 18:27:31 -0700 | [diff] [blame] | 42 | typedef size_t (*SinkFn)(unsigned char*, size_t, void*); |
Doug Zongker | 5da317e | 2009-06-02 13:38:17 -0700 | [diff] [blame] | 43 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 44 | // applypatch.c |
| 45 | size_t FreeSpaceForFile(const char* filename); |
Doug Zongker | 5a79087 | 2009-06-12 09:42:43 -0700 | [diff] [blame] | 46 | int applypatch(int argc, char** argv); |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 47 | |
| 48 | // bsdiff.c |
| 49 | void ShowBSDiffLicense(); |
| 50 | int ApplyBSDiffPatch(const unsigned char* old_data, ssize_t old_size, |
Doug Zongker | 02d444b | 2009-05-27 18:24:03 -0700 | [diff] [blame] | 51 | const char* patch_filename, ssize_t offset, |
Doug Zongker | 6c77046 | 2009-07-22 18:27:31 -0700 | [diff] [blame] | 52 | SinkFn sink, void* token, SHA_CTX* ctx); |
Doug Zongker | 02d444b | 2009-05-27 18:24:03 -0700 | [diff] [blame] | 53 | int ApplyBSDiffPatchMem(const unsigned char* old_data, ssize_t old_size, |
| 54 | const char* patch_filename, ssize_t patch_offset, |
| 55 | unsigned char** new_data, ssize_t* new_size); |
| 56 | |
| 57 | // imgpatch.c |
| 58 | int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size, |
Doug Zongker | 6c77046 | 2009-07-22 18:27:31 -0700 | [diff] [blame] | 59 | const char* patch_filename, |
| 60 | SinkFn sink, void* token, SHA_CTX* ctx); |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 61 | |
| 62 | // freecache.c |
| 63 | int MakeFreeSpaceOnCache(size_t bytes_needed); |
| 64 | |
| 65 | #endif |