open-vm-tools 12.1.5
utils.h
Go to the documentation of this file.
1/*********************************************************
2 * Copyright (C) 2008-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#ifndef _VMWARE_TOOLS_UTILS_H_
20#define _VMWARE_TOOLS_UTILS_H_
21
37#define VMTOOLS_GUEST_SERVICE "vmsvc"
38#define VMTOOLS_USER_SERVICE "vmusr"
39
40#if defined(__cplusplus)
41# define VMTOOLS_EXTERN_C extern "C"
42#else
43# define VMTOOLS_EXTERN_C
44#endif
45
46#include <glib.h>
47#if defined(G_PLATFORM_WIN32)
48# include <windows.h>
49#else
50# include <signal.h>
51# include <sys/time.h>
52#endif
53
54#ifndef ABS
55# define ABS(x) (((x) >= 0) ? (x) : -(x))
56#endif
57
58
71#if defined(G_PLATFORM_WIN32)
72# define VMTOOLS_GET_FILENAME_LOCAL(path, err) (gchar *) (path)
73#else
74# define VMTOOLS_GET_FILENAME_LOCAL(path, err) g_filename_from_utf8((path), \
75 -1, \
76 NULL, \
77 NULL, \
78 (err))
79#endif
80
87#if defined(G_PLATFORM_WIN32)
88# define VMTOOLS_RELEASE_FILENAME_LOCAL(path) (void) (path)
89#else
90# define VMTOOLS_RELEASE_FILENAME_LOCAL(path) g_free(path)
91#endif
92
94#define VMTOOLS_WRAP_ARRAY(a) VMTools_WrapArray((a), sizeof *(a), G_N_ELEMENTS(a))
95
96
97G_BEGIN_DECLS
98
99void
100vm_free(void *ptr);
101
102gboolean
103VMTools_LoadConfig(const gchar *path,
104 GKeyFileFlags flags,
105 GKeyFile **config,
106 time_t *mtime);
107
108gboolean
109VMTools_AddConfig(GKeyFile *srcConfig,
110 GKeyFile *dstConfig);
111
112gboolean
113VMTools_CompareConfig(GKeyFile *config1,
114 GKeyFile *config2);
115
116gboolean
117VMTools_WriteConfig(const gchar *path,
118 GKeyFile *config,
119 GError **err);
120
121gboolean
122VMTools_ChangeLogFilePath(const gchar *delimiter,
123 const gchar *appendString,
124 const gchar *domain,
125 GKeyFile *conf);
126
127gboolean
128VMTools_ConfigGetBoolean(GKeyFile *config,
129 const gchar *section,
130 const gchar *key,
131 const gboolean defValue);
132
133gint
134VMTools_ConfigGetInteger(GKeyFile *config,
135 const gchar *section,
136 const gchar *key,
137 const gint defValue);
138
139gchar *
140VMTools_ConfigGetString(GKeyFile *config,
141 const gchar *section,
142 const gchar *key,
143 const gchar *defValue);
144
145#if defined(G_PLATFORM_WIN32)
146
147gboolean
148VMTools_AttachConsole(void);
149
150GSource *
151VMTools_NewHandleSource(HANDLE h);
152
153#else
154
156typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
157
158GSource *
159VMTools_NewSignalSource(int signum);
160
161gchar *
162VMTools_GetLibdir(void);
163
164#endif
165
166GSource *
167VMTools_CreateTimer(gint timeout);
168
169void
171
172void
174
175gchar *
177
178void
180
181void
183
184GArray *
185VMTools_WrapArray(gconstpointer data,
186 guint elemSize,
187 guint count);
188
189G_END_DECLS
190
193#endif /* _VMWARE_TOOLS_UTILS_H_ */
194
void VMTools_AcquireLogStateLock(void)
Definition: vmtoolsLog.c:2127
gboolean VMTools_ConfigGetBoolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean defValue)
Definition: vmtoolsConfig.c:495
gboolean VMTools_LoadConfig(const gchar *path, GKeyFileFlags flags, GKeyFile **config, time_t *mtime)
Definition: vmtoolsConfig.c:87
gboolean(* SignalSourceCb)(const siginfo_t *, gpointer)
Definition: utils.h:156
GArray * VMTools_WrapArray(gconstpointer data, guint elemSize, guint count)
Definition: vmtools.c:60
void VMTools_ResumeLogIO(void)
Definition: vmtoolsLog.c:2160
GSource * VMTools_NewSignalSource(int signum)
Definition: signalSource.c:261
gboolean VMTools_AddConfig(GKeyFile *srcConfig, GKeyFile *dstConfig)
Definition: vmtoolsConfig.c:197
G_BEGIN_DECLS void vm_free(void *ptr)
Definition: vmtools.c:126
void VMTools_ReleaseLogStateLock(void)
Definition: vmtoolsLog.c:2138
gchar * VMTools_ConfigGetString(GKeyFile *config, const gchar *section, const gchar *key, const gchar *defValue)
Definition: vmtoolsConfig.c:582
gchar * VMTools_GetTimeAsString(void)
Definition: vmtoolsLog.c:358
void VMTools_SuspendLogIO(void)
Definition: vmtoolsLog.c:2149
gint VMTools_ConfigGetInteger(GKeyFile *config, const gchar *section, const gchar *key, const gint defValue)
Definition: vmtoolsConfig.c:540
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:420
gboolean VMTools_CompareConfig(GKeyFile *config1, GKeyFile *config2)
Definition: vmtoolsConfig.c:277
gboolean VMTools_ChangeLogFilePath(const gchar *delimiter, const gchar *appendString, const gchar *domain, GKeyFile *conf)
Definition: vmtoolsLog.c:2471