1 | /* $Id: ExtPackUtil.h 76487 2018-12-27 03:31:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - Extension Pack Utilities and definitions, VBoxC, VBoxSVC, ++.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_EXTPACKUTIL
|
---|
19 | #define ____H_EXTPACKUTIL
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #ifdef __cplusplus
|
---|
25 | # include <iprt/cpp/ministring.h>
|
---|
26 | #endif
|
---|
27 | #include <iprt/fs.h>
|
---|
28 | #include <iprt/vfs.h>
|
---|
29 |
|
---|
30 |
|
---|
31 | /** @name VBOX_EXTPACK_DESCRIPTION_NAME
|
---|
32 | * The name of the description file in an extension pack. */
|
---|
33 | #define VBOX_EXTPACK_DESCRIPTION_NAME "ExtPack.xml"
|
---|
34 | /** @name VBOX_EXTPACK_DESCRIPTION_NAME
|
---|
35 | * The name of the manifest file in an extension pack. */
|
---|
36 | #define VBOX_EXTPACK_MANIFEST_NAME "ExtPack.manifest"
|
---|
37 | /** @name VBOX_EXTPACK_SIGNATURE_NAME
|
---|
38 | * The name of the signature file in an extension pack. */
|
---|
39 | #define VBOX_EXTPACK_SIGNATURE_NAME "ExtPack.signature"
|
---|
40 | /** @name VBOX_EXTPACK_LICENSE_NAME_PREFIX
|
---|
41 | * The name prefix of a license file in an extension pack. There can be
|
---|
42 | * several license files in a pack, the variations being on locale, language
|
---|
43 | * and format (HTML, RTF, plain text). All extension packages shall include
|
---|
44 | * a */
|
---|
45 | #define VBOX_EXTPACK_LICENSE_NAME_PREFIX "ExtPack-license"
|
---|
46 | /** @name VBOX_EXTPACK_SUFFIX
|
---|
47 | * The suffix of a extension pack tarball. */
|
---|
48 | #define VBOX_EXTPACK_SUFFIX ".vbox-extpack"
|
---|
49 |
|
---|
50 | /** The minimum length (strlen) of a extension pack name. */
|
---|
51 | #define VBOX_EXTPACK_NAME_MIN_LEN 3
|
---|
52 | /** The max length (strlen) of a extension pack name. */
|
---|
53 | #define VBOX_EXTPACK_NAME_MAX_LEN 64
|
---|
54 |
|
---|
55 | /** The architecture-dependent application data subdirectory where the
|
---|
56 | * extension packs are installed. Relative to RTPathAppPrivateArch. */
|
---|
57 | #define VBOX_EXTPACK_INSTALL_DIR "ExtensionPacks"
|
---|
58 | /** The architecture-independent application data subdirectory where the
|
---|
59 | * certificates are installed. Relative to RTPathAppPrivateNoArch. */
|
---|
60 | #define VBOX_EXTPACK_CERT_DIR "ExtPackCertificates"
|
---|
61 |
|
---|
62 | /** The maximum entry name length.
|
---|
63 | * Play short and safe. */
|
---|
64 | #define VBOX_EXTPACK_MAX_MEMBER_NAME_LENGTH 128
|
---|
65 |
|
---|
66 |
|
---|
67 | #ifdef __cplusplus
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Plug-in descriptor.
|
---|
71 | */
|
---|
72 | typedef struct VBOXEXTPACKPLUGINDESC
|
---|
73 | {
|
---|
74 | /** The name. */
|
---|
75 | RTCString strName;
|
---|
76 | /** The module name. */
|
---|
77 | RTCString strModule;
|
---|
78 | /** The description. */
|
---|
79 | RTCString strDescription;
|
---|
80 | /** The frontend or component which it plugs into. */
|
---|
81 | RTCString strFrontend;
|
---|
82 | } VBOXEXTPACKPLUGINDESC;
|
---|
83 | /** Pointer to a plug-in descriptor. */
|
---|
84 | typedef VBOXEXTPACKPLUGINDESC *PVBOXEXTPACKPLUGINDESC;
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Extension pack descriptor
|
---|
88 | *
|
---|
89 | * This is the internal representation of the ExtPack.xml.
|
---|
90 | */
|
---|
91 | typedef struct VBOXEXTPACKDESC
|
---|
92 | {
|
---|
93 | /** The name. */
|
---|
94 | RTCString strName;
|
---|
95 | /** The description. */
|
---|
96 | RTCString strDescription;
|
---|
97 | /** The version string. */
|
---|
98 | RTCString strVersion;
|
---|
99 | /** The edition string. */
|
---|
100 | RTCString strEdition;
|
---|
101 | /** The internal revision number. */
|
---|
102 | uint32_t uRevision;
|
---|
103 | /** The name of the main module. */
|
---|
104 | RTCString strMainModule;
|
---|
105 | /** The name of the main VM module, empty if none. */
|
---|
106 | RTCString strMainVMModule;
|
---|
107 | /** The name of the VRDE module, empty if none. */
|
---|
108 | RTCString strVrdeModule;
|
---|
109 | /** The number of plug-in descriptors. */
|
---|
110 | uint32_t cPlugIns;
|
---|
111 | /** Pointer to an array of plug-in descriptors. */
|
---|
112 | PVBOXEXTPACKPLUGINDESC paPlugIns;
|
---|
113 | /** Whether to show the license prior to installation. */
|
---|
114 | bool fShowLicense;
|
---|
115 | } VBOXEXTPACKDESC;
|
---|
116 |
|
---|
117 | /** Pointer to a extension pack descriptor. */
|
---|
118 | typedef VBOXEXTPACKDESC *PVBOXEXTPACKDESC;
|
---|
119 | /** Pointer to a const extension pack descriptor. */
|
---|
120 | typedef VBOXEXTPACKDESC const *PCVBOXEXTPACKDESC;
|
---|
121 |
|
---|
122 |
|
---|
123 | void VBoxExtPackInitDesc(PVBOXEXTPACKDESC a_pExtPackDesc);
|
---|
124 | RTCString *VBoxExtPackLoadDesc(const char *a_pszDir, PVBOXEXTPACKDESC a_pExtPackDesc, PRTFSOBJINFO a_pObjInfo);
|
---|
125 | RTCString *VBoxExtPackLoadDescFromVfsFile(RTVFSFILE hVfsFile, PVBOXEXTPACKDESC a_pExtPackDesc, PRTFSOBJINFO a_pObjInfo);
|
---|
126 | RTCString *VBoxExtPackExtractNameFromTarballPath(const char *pszTarball);
|
---|
127 | void VBoxExtPackFreeDesc(PVBOXEXTPACKDESC a_pExtPackDesc);
|
---|
128 | bool VBoxExtPackIsValidName(const char *pszName);
|
---|
129 | bool VBoxExtPackIsValidMangledName(const char *pszMangledName, size_t cchMax = RTSTR_MAX);
|
---|
130 | RTCString *VBoxExtPackMangleName(const char *pszName);
|
---|
131 | RTCString *VBoxExtPackUnmangleName(const char *pszMangledName, size_t cbMax);
|
---|
132 | int VBoxExtPackCalcDir(char *pszExtPackDir, size_t cbExtPackDir, const char *pszParentDir, const char *pszName);
|
---|
133 | bool VBoxExtPackIsValidVersionString(const char *pszVersion);
|
---|
134 | bool VBoxExtPackIsValidEditionString(const char *pszEdition);
|
---|
135 | bool VBoxExtPackIsValidModuleString(const char *pszModule);
|
---|
136 |
|
---|
137 | int VBoxExtPackValidateMember(const char *pszName, RTVFSOBJTYPE enmType, RTVFSOBJ hVfsObj, char *pszError, size_t cbError);
|
---|
138 | int VBoxExtPackOpenTarFss(RTFILE hTarballFile, char *pszError, size_t cbError, PRTVFSFSSTREAM phTarFss, PRTMANIFEST phFileManifest);
|
---|
139 | int VBoxExtPackValidateTarball(RTFILE hTarballFile, const char *pszExtPackName,
|
---|
140 | const char *pszTarball, const char *pszTarballDigest,
|
---|
141 | char *pszError, size_t cbError,
|
---|
142 | PRTMANIFEST phValidManifest, PRTVFSFILE phXmlFile, RTCString *pStrDigest);
|
---|
143 | #endif /* __cplusplus */
|
---|
144 |
|
---|
145 | #endif
|
---|
146 |
|
---|