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