diff options
Diffstat (limited to 'lib/x1000-installer/include/xf_package.h')
-rw-r--r-- | lib/x1000-installer/include/xf_package.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/x1000-installer/include/xf_package.h b/lib/x1000-installer/include/xf_package.h new file mode 100644 index 0000000000..6633766bd7 --- /dev/null +++ b/lib/x1000-installer/include/xf_package.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2021 Aidan MacDonald | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef _XF_PACKAGE_H_ | ||
23 | #define _XF_PACKAGE_H_ | ||
24 | |||
25 | /* package format | ||
26 | * | ||
27 | * - bootloader-info.txt (contains a version label and optional metadata) | ||
28 | * - flashmap.txt (describes the flash update map) | ||
29 | * - [package must contain any other files referenced by the flash map] | ||
30 | * - [other files may be present, but are ignored] | ||
31 | */ | ||
32 | |||
33 | #include "xf_flashmap.h" | ||
34 | #include "xf_stream.h" | ||
35 | #include "microtar.h" | ||
36 | |||
37 | struct xf_package { | ||
38 | int alloc_handle; | ||
39 | mtar_t* tar; | ||
40 | struct xf_map* map; | ||
41 | int map_size; | ||
42 | char* metadata; | ||
43 | size_t metadata_len; | ||
44 | }; | ||
45 | |||
46 | /** Open an update package | ||
47 | * | ||
48 | * \param pkg Uninitialized package structure | ||
49 | * \param file Name of the package file | ||
50 | * \param dflt_map Default flash map for loading old format packages | ||
51 | * \param dflt_map_size Size of the default flash map | ||
52 | * \returns XF_E_SUCCESS or a negative error code | ||
53 | */ | ||
54 | int xf_package_open_ex(struct xf_package* pkg, const char* file, | ||
55 | const struct xf_map* dflt_map, int dflt_map_size); | ||
56 | |||
57 | /** Close a package which was previously opened successfully */ | ||
58 | void xf_package_close(struct xf_package* pkg); | ||
59 | |||
60 | static inline int xf_package_open(struct xf_package* pkg, const char* file) | ||
61 | { | ||
62 | return xf_package_open_ex(pkg, file, NULL, 0); | ||
63 | } | ||
64 | |||
65 | #endif /* _XF_PACKAGE_H_ */ | ||