Add delta.ua - a binary to apply an upgrade of DELTA_FS type.
[platform/core/system/upgrade.git] / src / delta-ua / engine / SS_PatchDelta.h
1 /*
2  * delta-ua
3  *
4  * Copyright (c) 2017 - 2022 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef _SS_PATCHDELTA_H
20 #define _SS_PATCHDELTA_H
21
22 #include <stdint.h>
23 #include "sha1.h"
24 #include "unistd.h"
25 #include "fcntl.h"
26 #include "errno.h"
27 #include "ua_types.h"
28
29 #define SHA_DIGEST_SIZE 20
30
31 typedef struct _FileInfo {
32         unsigned char sha1[20];     //SHA_DIGEST_SIZE 20
33         unsigned char *data;
34         int size;
35         struct stat st;
36 } FileInfo;
37 typedef ssize_t(*SinkFn) (unsigned char *, ssize_t, void *);
38
39 int ParseSha1(const char *str, uint8_t * digest);
40
41 int SS_LoadFile(const char *filename, FileInfo * file);
42 extern void SS_SetUpgradeState(int Val);
43 extern long SS_GetAvailableFreeSpace(const char *partition_name, SS_UINT32 * available_flash_size);
44 extern int SS_BackupSource(const char *source_filename, char *backup_path);
45 extern int SS_ApplyBsdiff(char *oldfile, char *newfile, char *patch, SinkFn sink, void *token, SHA1_CTX * ctx1);
46 extern int SS_BackupSourceClear(char * backup_path);
47 extern int SS_PatchSourceClear(char *patch_path);
48 extern long SS_WriteFile(long wHandle, SS_UINT32 dwPosition, unsigned char *pbBuffer, SS_UINT32 dwSize);
49 extern void SS_Free(void * pMemBlock);
50 extern long SS_CopyFile(const char * strFromPath, const char * strToPath);
51 extern long SS_DeleteFolder(const char * strPath);
52 extern long SS_DeleteFile(const char * strPath);
53 extern int tar_get_item_size(char * tar, char * item);
54 extern int tar_extract_file(char * tar, char * item, char * pathname);
55 extern int _system_cmd_wait(const char * command);
56 #endif