open-vm-tools 11.3.5
guestStoreClientLib.h
1 /*********************************************************
2  * Copyright (C) 2019-2020 VMware, Inc. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published
6  * by the Free Software Foundation version 2.1 and no later version.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11  * License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16  *
17  *********************************************************/
18 
19 /*
20  * guestStoreClientLib.h --
21  * Definitions for VMware Tools guestStore client library.
22  */
23 
24 #ifndef __GUESTSTORECLIENTLIB_H__
25 #define __GUESTSTORECLIENTLIB_H__
26 
27 #include "vm_basic_types.h"
28 
29 #define GUESTSTORE_LIB_ERR_LIST \
30  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_SUCCESS = 0, \
31  gsliberr.success, \
32  "Success") \
33  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_GENERIC, \
34  gsliberr.generic, \
35  "Generic error") \
36  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_TLS, \
37  gsliberr.tls, \
38  "TLS error") \
39  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_NOT_INITIALIZED, \
40  gsliberr.not.initialized, \
41  "Not initialized") \
42  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_INVALID_PARAMETER, \
43  gsliberr.invalid.parameter, \
44  "Invalid parameter") \
45  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_NOT_ENOUGH_MEMORY, \
46  gsliberr.not.enough.memory, \
47  "Not enough memory") \
48  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CREATE_OUTPUT_FILE, \
49  gsliberr.create.output.file, \
50  "Create output file error") \
51  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_WRITE_OUTPUT_FILE, \
52  gsliberr.write.output.file, \
53  "Write output file error") \
54  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CONNECT_GENERIC, \
55  gsliberr.connect.generic, \
56  "Connect generic error") \
57  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CONNECT_SERVICE_NOT_RUNNING, \
58  gsliberr.connect.service.not.running, \
59  "Connect service not running") \
60  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CONNECT_PERMISSION_DENIED, \
61  gsliberr.connect.permission.denied, \
62  "Connect permission denied") \
63  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CONNECT_SECURITY_VIOLATION, \
64  gsliberr.connect.security.violation, \
65  "Connect security violation") \
66  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CONNECT_PEER_RESET, \
67  gsliberr.connect.peer.reset, \
68  "Connect peer reset") \
69  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_SEND, \
70  gsliberr.send, \
71  "Send error") \
72  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_RECV, \
73  gsliberr.recv, \
74  "Receive error") \
75  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CONTENT_FORBIDDEN, \
76  gsliberr.content.forbidden, \
77  "Content forbidden") \
78  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CONTENT_NOT_FOUND, \
79  gsliberr.content.not.found, \
80  "Content not found") \
81  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_SERVER, \
82  gsliberr.server, \
83  "Server error") \
84  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CANCELLED, \
85  gsliberr.cancelled, \
86  "Cancelled") \
87  GUESTSTORE_LIB_ERR_ITEM(GSLIBERR_CHECKSUM, \
88  gsliberr.checksum, \
89  "Checksum error")
90 
91 /*
92  * Error codes
93  */
94 #define GUESTSTORE_LIB_ERR_ITEM(a, b, c) a,
95 typedef enum {
96 GUESTSTORE_LIB_ERR_LIST
97 GUESTSTORE_LIB_ERR_MAX
98 } GuestStoreLibError;
99 #undef GUESTSTORE_LIB_ERR_ITEM
100 
101 /*
102  * Log levels
103  */
104 typedef enum {
105  GSLIBLOGLEVEL_ERROR = 1,
106  GSLIBLOGLEVEL_WARNING,
107  GSLIBLOGLEVEL_INFO,
108  GSLIBLOGLEVEL_DEBUG,
109 } GuestStoreLibLogLevel;
110 
111 
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115 
116 /*
117  * Caller provided function to receive log messages from GuestStore client
118  * library. Caller can log the messages to its own logging facilities.
119  */
120 typedef void (*GuestStore_Logger) (GuestStoreLibLogLevel level,
121  const char *message,
122  void *clientData);
123 
124 /*
125  * Caller provided Panic function in non-recoverable error situations.
126  * This function shall exit the library host process.
127  */
128 typedef void (*GuestStore_Panic) (const char *message,
129  void *clientData);
130 
131 /*
132  * Caller provided callback to get total content size in bytes and so far
133  * received bytes. Return FALSE to cancel content download.
134  */
135 typedef Bool (*GuestStore_GetContentCallback) (int64 contentSize,
136  int64 contentBytesReceived,
137  void *clientData);
138 
139 /*
140  * GuestStore client library Init entry point function.
141  */
142 GuestStoreLibError
143 GuestStore_Init(void);
144 
145 /*
146  * GuestStore client library GetContent entry point function.
147  */
148 GuestStoreLibError
149 GuestStore_GetContent(
150  const char *contentPath, // IN
151  const char *outputPath, // IN
152  GuestStore_Logger logger, // IN, OPTIONAL
153  GuestStore_Panic panic, // IN, OPTIONAL
154  GuestStore_GetContentCallback getContentCb, // IN, OPTIONAL
155  void *clientData); // IN, OPTIONAL
156 
157 /*
158  * GuestStore client library DeInit entry point function.
159  * Call of GuestStore_DeInit should match succeeded GuestStore_Init call.
160  */
161 GuestStoreLibError
162 GuestStore_DeInit(void);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* __GUESTSTORECLIENTLIB_H__ */