open-vm-tools 13.1.0: lib/include/vmware/tools/utils.h Source File

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
101 vm_free(void *ptr);
102
103gboolean
104 VMTools_LoadConfig(const gchar *path,
105 GKeyFileFlags flags,
106 GKeyFile **config,
107 time_t *mtime);
108
109gboolean
110 VMTools_AddConfig(GKeyFile *srcConfig,
111 GKeyFile *dstConfig);
112
113gboolean
114 VMTools_CompareConfig(GKeyFile *config1,
115 GKeyFile *config2);
116
117gboolean
118 VMTools_WriteConfig(const gchar *path,
119 GKeyFile *config,
120 GError **err);
121
122gboolean
123 VMTools_ChangeLogFilePath(const gchar *delimiter,
124 const gchar *appendString,
125 const gchar *domain,
126 GKeyFile *conf);
127
128gboolean
129 VMTools_ConfigGetBoolean(GKeyFile *config,
130 const gchar *section,
131 const gchar *key,
132 const gboolean defValue);
133
134gint
135 VMTools_ConfigGetInteger(GKeyFile *config,
136 const gchar *section,
137 const gchar *key,
138 const gint defValue);
139
140gchar *
141 VMTools_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
173 typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
174
175GSource *
176 VMTools_NewSignalSource(int signum);
177
178gchar *
179 VMTools_GetLibdir(void);
180
181#endif
182
183void
184 VMTools_SetupEnv(const gchar *appName,
185 GKeyFile *config,
186 gboolean globalVars);
187
188GSource *
189 VMTools_CreateTimer(gint timeout);
190
191void
192 VMTools_AcquireLogStateLock(void);
193
194void
195 VMTools_ReleaseLogStateLock(void);
196
197gchar *
198 VMTools_GetTimeAsString(void);
199
200void
201 VMTools_SuspendLogIO(void);
202
203void
204 VMTools_ResumeLogIO(void);
205
206GArray *
207 VMTools_WrapArray(gconstpointer data,
208 guint elemSize,
209 guint count);
210
211G_END_DECLS
212
214
215#endif /* _VMWARE_TOOLS_UTILS_H_ */
216
VMTools_GetLibdir
gchar * VMTools_GetLibdir(void)
Definition vmtoolsMisc.c:56
VMTools_AcquireLogStateLock
void VMTools_AcquireLogStateLock(void)
Definition vmtoolsLog.c:2173
VMTools_ConfigGetBoolean
gboolean VMTools_ConfigGetBoolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean defValue)
Definition vmtoolsConfig.c:496
VMTools_LoadConfig
gboolean VMTools_LoadConfig(const gchar *path, GKeyFileFlags flags, GKeyFile **config, time_t *mtime)
Definition vmtoolsConfig.c:88
SignalSourceCb
gboolean(* SignalSourceCb)(const siginfo_t *, gpointer)
Definition utils.h:173
VMTools_WrapArray
GArray * VMTools_WrapArray(gconstpointer data, guint elemSize, guint count)
Definition vmtools.c:60
VMTools_ResumeLogIO
void VMTools_ResumeLogIO(void)
Definition vmtoolsLog.c:2206
VMTools_NewSignalSource
GSource * VMTools_NewSignalSource(int signum)
Definition signalSource.c:271
VMTools_AddConfig
gboolean VMTools_AddConfig(GKeyFile *srcConfig, GKeyFile *dstConfig)
Definition vmtoolsConfig.c:198
vm_free
G_BEGIN_DECLS void vm_free(void *ptr)
Definition vmtools.c:126
VMTools_ReleaseLogStateLock
void VMTools_ReleaseLogStateLock(void)
Definition vmtoolsLog.c:2184
VMTools_ConfigGetString
gchar * VMTools_ConfigGetString(GKeyFile *config, const gchar *section, const gchar *key, const gchar *defValue)
Definition vmtoolsConfig.c:583
VMTools_GetTimeAsString
gchar * VMTools_GetTimeAsString(void)
Definition vmtoolsLog.c:360
VMTools_SuspendLogIO
void VMTools_SuspendLogIO(void)
Definition vmtoolsLog.c:2195
VMTools_ConfigGetInteger
gint VMTools_ConfigGetInteger(GKeyFile *config, const gchar *section, const gchar *key, const gint defValue)
Definition vmtoolsConfig.c:541
VMTools_CreateTimer
GSource * VMTools_CreateTimer(gint timeout)
Create a timer based on a monotonic clock source.
Definition monotonicTimer.c:169
VMTools_WriteConfig
gboolean VMTools_WriteConfig(const gchar *path, GKeyFile *config, GError **err)
Definition vmtoolsConfig.c:421
VMTools_CompareConfig
gboolean VMTools_CompareConfig(GKeyFile *config1, GKeyFile *config2)
Definition vmtoolsConfig.c:278
VMTools_SetupEnv
void VMTools_SetupEnv(const gchar *appName, GKeyFile *config, gboolean globalVars)
Definition vmtoolsMisc.c:676
VMTools_ChangeLogFilePath
gboolean VMTools_ChangeLogFilePath(const gchar *delimiter, const gchar *appendString, const gchar *domain, GKeyFile *conf)
Definition vmtoolsLog.c:2517