1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
/*********************************************************
* Copyright (C) 2006 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation version 2.1 and no later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*********************************************************/
#ifndef _MSPACKWRAPPER_H_
#define _MSPACKWRAPPER_H_
/*
* This include takes care of configuring the header files to suite the library
* compilation.
*/
#include "mspackConfig.h"
#include "imgcust-common/log.h"
/*
* The objective of this header file is to abstract the c99 standard
* of mspack.h which does not compile with C++ due to usage of keywords
* like 'this' and 'class' in the code. "extern C" is more of a linker
* provision and does not handle this scenario.
*
* This header file abstracts away the mspack.h and exposes the same
* functionalities.
*
*/
/*
* Constant Declaration
*/
/*
* Error codes
*/
#define LINUXCAB_SUCCESS 0 // Success
#define LINUXCAB_ERROR 1 // General error
#define LINUXCAB_ERR_EXTRACT 2 // Extraction error
#define LINUXCAB_ERR_DECOMPRESSOR 3 // Decompression error
#define LINUXCAB_ERR_OPEN 4 // Open error
#define LINUXCAB_ERR_SEEK 5 // Seek error
// .....................................................................................
/**
*
* Set the logging function.
*
* @param [in] log Logging function to be used.
* @returns None
*
**/
void
MspackWrapper_SetLogger(LogFunction log);
//......................................................................................
/**
*
* Expands all files in the cabinet into the specified directory. Also returns
* the command that is specified in the VMware defined header.
*
* @param cabFileName IN: Cabinet file name
* @param destDirectory IN: Destination directory to uncab
*
* @return
* On success LINUXCAB_SUCCESS
* On Error LINUXCAB_ERROR, LINUXCAB_ERR_OPEN, LINUXCAB_ERR_DECOMPRESS,
* LINUXCAB_EXTRACT
**/
unsigned int
ExpandAllFilesInCab(const char* cabFileName,
const char* destDirectory);
//......................................................................................
/**
* Does a self check on the library parameters to make sure that the library
* compilation is compatible with the client compilation. This is funny scenario
* and is put in to support different flavours of UNIX operating systems.
* Essentially the library checks of off_t size.
*
* @param None
* @return
* On Success LINUXCAB_SUCCESS
* On Error LINUXCAB_ERR_SEEK, LINUXCAB_ERROR
*
**/
unsigned int
SelfTestMspack(void);
//......................................................................................
/**
*
* Get a string error message for the given error code.
*
* @param error IN: Error number
* @return error as a string message
*
**/
const char*
GetLinuxCabErrorMsg (const unsigned int error);
// .....................................................................................
/**
*
* Sets up the path for exracting file. For e.g. if the file is /a/b/c/d.abc
* then it creates /a/b/c (skips if any of the directories along the path
* exists)
*
* @param path IN: Complete path of the file
* @return
* On Success LINUXCAB_SUCCESS
* On Error LINUXCAB_ERROR
*
**/
unsigned int
SetupPath (char* path);
#endif
|