Add delta.ua - a binary to apply an upgrade of DELTA_FS type.
[platform/core/system/upgrade.git] / src / delta-ua / engine / SS_UPI.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_UPI_H_
20 #define _SS_UPI_H_
21 #include <stdbool.h>
22 #include "fota_common.h"
23
24 #define DISPLAYRESOLUTION_SIZE 50
25
26 struct details {
27         int diffs;
28         int moves;
29         int news;
30         int deletes;
31         int symdiffs;
32         int symnews;
33         int harddiffs;
34         int hardnews;
35 };
36
37 enum DEL_TYPE { DELETES = 1, DIFFS, MOVES, DELETE_END, NEWFILES, SYMDIFFS, SYMNEWFILES, HARDDIFFS, HARDNEWFILES, DEL_TYPE_MAX };
38 struct fs_params {                        // Use Macros
39         char file_old_path[512];
40         char file_new_path[512];
41         char patch_name[256];
42         char sha1src[64];
43         char sha1trg[64];
44         int data_size;
45         int data_offset;
46         int type;                                  //0 is for diff and 1 is for verbatim
47         struct fs_params *nextnode;
48 };
49 typedef struct fs_params fs_params;
50
51 struct fs_list {
52         fs_params *dif_ref;
53         fs_params *move_ref;
54         fs_params *new_ref;
55         fs_params *del_ref;
56         fs_params *sym_difref;
57         fs_params *sym_newref;
58         fs_params *hard_difref;
59         fs_params *hard_newref;
60         int ulPatchCount;
61 };
62 typedef struct fs_list fs_list;
63
64 int SS_AppendNode(const char *ubDeltaPath, fs_params ** headparam, fs_params ** tailparam, const char *old_path,
65                                   const char *new_path, const char *patchname, const char *sha1src, const char *sha1trg, int type,
66                                   char *patchpath_name);
67 long SS_GetUPIVersion(unsigned char *ver_str);
68 extern int SS_FSUpdatemain(ua_dataSS_t * ua_dataSS);
69 extern int SS_FSVerifyPartition(ua_dataSS_t * ua_dataSS);
70
71 //extra functions
72 extern void *SS_Malloc(unsigned int size);
73 extern int tar_get_item_size_from_struct(tar_Data_t **, const char *, int *, int *);
74 extern void SS_Free(void *pMemBlock);
75 extern int tar_get_item_size(char *tar, char *item);
76 extern int tar_get_cfg_data(char *tar, char *item, char *buf, int buflen);
77 extern tar_Data_t *tar_build_cfg_table(char *tar);
78 extern int tar_open(char *tar);
79 extern int fast_tar_extract_file(char *tar, char *item, char *pathname, int size, int offset);
80 extern int tar_close();
81 extern int SS_UpdateDeltaFS(const char *source_filename, const char *target_filename,
82                                                         const char *source_sha1_str, const char *target_sha1_str, int patch_data_size, char *delta_folder);
83 extern int tar_extract_file(char *tar, char *item, char *pathname);
84 extern int _7zdecompress(char *path);
85 extern void tar_free_cfg_table(tar_Data_t ** delta_tar);
86 extern long SS_GetFileType(char *pLinkName, enumFileType * fileType);
87
88 extern int SS_Get_last_update_status(int* last_update_status, int* del_type, char *status_path);
89 extern void SS_Set_last_update_status(int last_update_status, int del_type, char *status_path);
90
91 #endif                                            //_SS_UPI_H_