Tom Marshall | c575fc4 | 2015-11-16 13:48:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 The LineageOS 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 | #include <utils/String8.h> |
| 18 | |
| 19 | #include <lib/libtar.h> |
| 20 | #include <zlib.h> |
| 21 | |
| 22 | extern "C" { |
| 23 | #include <openssl/md5.h> |
| 24 | #include <openssl/sha.h> |
| 25 | #ifndef MD5_DIGEST_STRING_LENGTH |
| 26 | #define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1) |
| 27 | #endif |
| 28 | #ifndef SHA_DIGEST_STRING_LENGTH |
| 29 | #define SHA_DIGEST_STRING_LENGTH (SHA_DIGEST_LENGTH * 2 + 1) |
| 30 | #endif |
| 31 | } |
| 32 | |
| 33 | #define HASH_MAX_LENGTH SHA_DIGEST_LENGTH |
| 34 | #define HASH_MAX_STRING_LENGTH SHA_DIGEST_STRING_LENGTH |
| 35 | |
| 36 | #define PROP_LINE_LEN (PROPERTY_KEY_MAX + 1 + PROPERTY_VALUE_MAX + 1 + 1) |
| 37 | |
| 38 | extern int adb_ifd; |
| 39 | extern int adb_ofd; |
| 40 | extern TAR* tar; |
| 41 | extern gzFile gzf; |
| 42 | |
| 43 | extern char* hash_name; |
| 44 | extern size_t hash_datalen; |
| 45 | extern SHA_CTX sha_ctx; |
| 46 | extern MD5_CTX md5_ctx; |
| 47 | |
| 48 | struct partspec { |
| 49 | char* name; |
| 50 | char* path; |
| 51 | Volume* vol; |
| 52 | uint64_t size; |
| 53 | uint64_t used; |
| 54 | uint64_t off; |
| 55 | }; |
| 56 | #define MAX_PART 8 |
| 57 | |
| 58 | extern void logmsg(const char* fmt, ...); |
| 59 | |
| 60 | extern int part_add(const char* name); |
| 61 | extern partspec* part_get(int i); |
| 62 | extern partspec* part_find(const char* name); |
| 63 | extern void part_set(partspec* part); |
| 64 | |
| 65 | extern int update_progress(uint64_t off); |
| 66 | |
| 67 | extern int create_tar(int fd, const char* compress, const char* mode); |
| 68 | |
| 69 | extern int do_backup(int argc, char** argv); |
| 70 | extern int do_restore(int argc, char** argv); |