The Android Open Source Project | 66339ad | 2009-01-15 16:12:07 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 17 | * 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef _APPLYPATCH_H |
| 21 | #define _APPLYPATCH_H |
| 22 | |
| 23 | #include "mincrypt/sha.h" |
| 24 | |
| 25 | typedef struct _Patch { |
| 26 | uint8_t sha1[SHA_DIGEST_SIZE]; |
| 27 | const char* patch_filename; |
| 28 | } Patch; |
| 29 | |
| 30 | typedef struct _FileContents { |
| 31 | uint8_t sha1[SHA_DIGEST_SIZE]; |
| 32 | unsigned char* data; |
| 33 | size_t size; |
| 34 | struct stat st; |
| 35 | } FileContents; |
| 36 | |
| 37 | // When there isn't enough room on the target filesystem to hold the |
| 38 | // patched version of the file, we copy the original here and delete |
| 39 | // it to free up space. If the expected source file doesn't exist, or |
| 40 | // is corrupted, we look to see if this file contains the bits we want |
| 41 | // and use it as the source instead. |
| 42 | #define CACHE_TEMP_SOURCE "/cache/saved.file" |
| 43 | |
| 44 | // applypatch.c |
| 45 | size_t FreeSpaceForFile(const char* filename); |
| 46 | |
| 47 | // xdelta3.c |
| 48 | int ApplyXDelta3Patch(const unsigned char* old_data, ssize_t old_size, |
| 49 | const char* patch_filename, |
| 50 | FILE* output, SHA_CTX* ctx); |
| 51 | |
| 52 | // bsdiff.c |
| 53 | void ShowBSDiffLicense(); |
| 54 | int ApplyBSDiffPatch(const unsigned char* old_data, ssize_t old_size, |
| 55 | const char* patch_filename, |
| 56 | FILE* output, SHA_CTX* ctx); |
| 57 | |
| 58 | // freecache.c |
| 59 | int MakeFreeSpaceOnCache(size_t bytes_needed); |
| 60 | |
| 61 | #endif |