open-vm-tools 13.1.0
utils.h
Go to the documentation of this file.
1/*********************************************************
2 * Copyright (c) 2008-2025 Broadcom. All Rights Reserved.
3 * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation version 2.1 and no later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
12 * License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 *********************************************************/
19
20#ifndef _VMWARE_TOOLS_UTILS_H_
21#define _VMWARE_TOOLS_UTILS_H_
22
37
38#define VMTOOLS_GUEST_SERVICE "vmsvc"
39#define VMTOOLS_USER_SERVICE "vmusr"
40
41#if defined(__cplusplus)
42# define VMTOOLS_EXTERN_C extern "C"
43#else
44# define VMTOOLS_EXTERN_C
45#endif
46
47#include <glib.h>
48#if defined(G_PLATFORM_WIN32)
49# include <windows.h>
50#else
51# include <signal.h>
52# include <sys/time.h>
53#endif
54
55#ifndef ABS
56# define ABS(x) (((x) >= 0) ? (x) : -(x))
57#endif
58
59
71
72#if defined(G_PLATFORM_WIN32)
73# define VMTOOLS_GET_FILENAME_LOCAL(path, err) (gchar *) (path)
74#else
75# define VMTOOLS_GET_FILENAME_LOCAL(path, err) g_filename_from_utf8((path), \
76 -1, \
77 NULL, \
78 NULL, \
79 (err))
80#endif
81
87
88#if defined(G_PLATFORM_WIN32)
89# define VMTOOLS_RELEASE_FILENAME_LOCAL(path) (void) (path)
90#else
91# define VMTOOLS_RELEASE_FILENAME_LOCAL(path) g_free(path)
92#endif
93
95#define VMTOOLS_WRAP_ARRAY(a) VMTools_WrapArray((a), sizeof *(a), G_N_ELEMENTS(a))
96
97
98G_BEGIN_DECLS
99
100void
101vm_free(void *ptr);
102
103gboolean
104VMTools_LoadConfig(const gchar *path,
105 GKeyFileFlags flags,
106 GKeyFile **config,
107 time_t *mtime);
108
109gboolean
110VMTools_AddConfig(GKeyFile *srcConfig,
111 GKeyFile *dstConfig);
112
113gboolean
114VMTools_CompareConfig(GKeyFile *config1,
115 GKeyFile *config2);
116
117gboolean
118VMTools_WriteConfig(const gchar *path,
119 GKeyFile *config,
120 GError **err);
121
122gboolean
123VMTools_ChangeLogFilePath(const gchar *delimiter,
124 const gchar *appendString,
125 const gchar *domain,
126 GKeyFile *conf);
127
128gboolean
129VMTools_ConfigGetBoolean(GKeyFile *config,
130 const gchar *section,
131 const gchar *key,
132 const gboolean defValue);
133
134gint
135VMTools_ConfigGetInteger(GKeyFile *config,
136 const gchar *section,
137 const gchar *key,
138 const gint defValue);
139
140gchar *
141VMTools_ConfigGetString(GKeyFile *config,
142 const gchar *section,
143 const gchar *key,
144 const gchar *defValue);
145
146#if defined(G_PLATFORM_WIN32)
147
148#define VMTOOLS_WIN_EVENT_SOURCE_NAME L"VMware Tools"
149
150#define VMTOOLS_CERT_MSG "Verify that a valid VMware Tools signing "\
151 "certificate is present in the Trusted "\
152 "Publishers certificate store on the system. "\
153 "Refer to the VMware Tools Administration Guide "\
154 "for how to set up a VMware Tools signing "\
155 "certificate."
156gboolean
157VMTools_AttachConsole(void);
158
159GSource *
160VMTools_NewHandleSource(HANDLE h);
161
162gboolean
163VMTools_IsPSScriptSigningEnforced(void);
164
165gboolean
166VMTools_IsScriptSignerCertPresent(void);
167
168void
169VMTools_LogWinEvent(const gchar *certMsg);
170#else
171
173typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
174
175GSource *
176VMTools_NewSignalSource(int signum);
177
178gchar *
180
181#endif
182
183void
184VMTools_SetupEnv(const gchar *appName,
185 GKeyFile *config,
186 gboolean globalVars);
187
188GSource *
189VMTools_CreateTimer(gint timeout);
190
191void
193
194void
196
197gchar *
199
200void
202
203void
205
206GArray *
207VMTools_WrapArray(gconstpointer data,
208 guint elemSize,
209 guint count);
210
211G_END_DECLS
212
214
215#endif /* _VMWARE_TOOLS_UTILS_H_ */
216
gchar * VMTools_GetLibdir(void)
Definition vmtoolsMisc.c:56
void VMTools_AcquireLogStateLock(void)
Definition vmtoolsLog.c:2173
gboolean VMTools_ConfigGetBoolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean defValue)
Definition vmtoolsConfig.c:496
gboolean VMTools_LoadConfig(const gchar *path, GKeyFileFlags flags, GKeyFile **config, time_t *mtime)
Definition vmtoolsConfig.c:88
gboolean(* SignalSourceCb)(const siginfo_t *, gpointer)
Definition utils.h:173
GArray * VMTools_WrapArray(gconstpointer data, guint elemSize, guint count)
Definition vmtools.c:60
void VMTools_ResumeLogIO(void)
Definition vmtoolsLog.c:2206
GSource * VMTools_NewSignalSource(int signum)
Definition signalSource.c:271
gboolean VMTools_AddConfig(GKeyFile *srcConfig, GKeyFile *dstConfig)
Definition vmtoolsConfig.c:198
G_BEGIN_DECLS void vm_free(void *ptr)
Definition vmtools.c:126
void VMTools_ReleaseLogStateLock(void)
Definition vmtoolsLog.c:2184
gchar * VMTools_ConfigGetString(GKeyFile *config, const gchar *section, const gchar *key, const gchar *defValue)
Definition vmtoolsConfig.c:583
gchar * VMTools_GetTimeAsString(void)
Definition vmtoolsLog.c:360
void VMTools_SuspendLogIO(void)
Definition vmtoolsLog.c:2195
gint VMTools_ConfigGetInteger(GKeyFile *config, const gchar *section, const gchar *key, const gint defValue)
Definition vmtoolsConfig.c:541
GSource * VMTools_CreateTimer(gint timeout)
Create a timer based on a monotonic clock source.
Definition monotonicTimer.c:169
gboolean VMTools_WriteConfig(const gchar *path, GKeyFile *config, GError **err)
Definition vmtoolsConfig.c:421
gboolean VMTools_CompareConfig(GKeyFile *config1, GKeyFile *config2)
Definition vmtoolsConfig.c:278
void VMTools_SetupEnv(const gchar *appName, GKeyFile *config, gboolean globalVars)
Definition vmtoolsMisc.c:676
gboolean VMTools_ChangeLogFilePath(const gchar *delimiter, const gchar *appendString, const gchar *domain, GKeyFile *conf)
Definition vmtoolsLog.c:2517