open-vm-tools 10.3.10

utils.h
Go to the documentation of this file.
1 /*********************************************************
2 * Copyright (C) 2008-2018 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
55 /* Work around a glib limitation: it doesn't set G_INLINE_FUNC on Win32. */
56 #if defined(G_PLATFORM_WIN32)
57 # if defined(G_INLINE_FUNC)
58 # undef G_INLINE_FUNC
59 # endif
60 # define G_INLINE_FUNC static __inline
61 #endif
62
63 #ifndef ABS
64 # define ABS(x) (((x) >= 0) ? (x) : -(x))
65 #endif
66
67
80 #if defined(G_PLATFORM_WIN32)
81 # define VMTOOLS_GET_FILENAME_LOCAL(path, err) (gchar *) (path)
82 #else
83 # define VMTOOLS_GET_FILENAME_LOCAL(path, err) g_filename_from_utf8((path), \
84 -1, \
85 NULL, \
86 NULL, \
87 (err))
88 #endif
89
96 #if defined(G_PLATFORM_WIN32)
97 # define VMTOOLS_RELEASE_FILENAME_LOCAL(path) (void) (path)
98 #else
99 # define VMTOOLS_RELEASE_FILENAME_LOCAL(path) g_free(path)
100 #endif
101
103 #define VMTOOLS_WRAP_ARRAY(a) VMTools_WrapArray((a), sizeof *(a), G_N_ELEMENTS(a))
104
105
106 G_BEGIN_DECLS
107
108 void
109 vm_free(void *ptr);
110
111 gboolean
112 VMTools_LoadConfig(const gchar *path,
113 GKeyFileFlags flags,
114 GKeyFile **config,
115 time_t *mtime);
116
117 gboolean
118 VMTools_WriteConfig(const gchar *path,
119 GKeyFile *config,
120 GError **err);
121
122 gboolean
123 VMTools_ChangeLogFilePath(const gchar *delimiter,
124 const gchar *appendString,
125 const gchar *domain,
126 GKeyFile *conf);
127
128 gboolean
129 VMTools_ConfigGetBoolean(GKeyFile *config,
130 const gchar *section,
131 const gchar *key,
132 const gboolean defValue);
133
134 gint
135 VMTools_ConfigGetInteger(GKeyFile *config,
136 const gchar *section,
137 const gchar *key,
138 const gint defValue);
139
140 gchar *
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 gboolean
149 VMTools_AttachConsole(void);
150
151 GSource *
152 VMTools_NewHandleSource(HANDLE h);
153
154 #else
155
157 typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
158
159 GSource *
160 VMTools_NewSignalSource(int signum);
161
162 gchar *
163 VMTools_GetLibdir(void);
164
165 #endif
166
167 GSource *
168 VMTools_CreateTimer(gint timeout);
169
170 void
171 VMTools_SetGuestSDKMode(void);
172
173 void
174 VMTools_AcquireLogStateLock(void);
175
176 void
177 VMTools_ReleaseLogStateLock(void);
178
179 void
180 VMTools_StopLogging(void);
181
182 void
183 VMTools_RestartLogging(void);
184
185 gchar *
186 VMTools_GetTimeAsString(void);
187
188 void
189 VMTools_SuspendLogIO(void);
190
191 void
192 VMTools_ResumeLogIO(void);
193
194 GArray *
195 VMTools_WrapArray(gconstpointer data,
196 guint elemSize,
197 guint count);
198
199 G_END_DECLS
200
203 #endif /* _VMWARE_TOOLS_UTILS_H_ */
204
VMTools_StopLogging
void VMTools_StopLogging(void)
Definition: vmtoolsLog.c:1347
VMTools_WrapArray
GArray * VMTools_WrapArray(gconstpointer data, guint elemSize, guint count)
Definition: vmtools.c:60
VMTools_SetGuestSDKMode
void VMTools_SetGuestSDKMode(void)
Definition: vmtoolsLog.c:1416
VMTools_RestartLogging
void VMTools_RestartLogging(void)
Definition: vmtoolsLog.c:1359
VMTools_ConfigGetBoolean
gboolean VMTools_ConfigGetBoolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean defValue)
Definition: vmtoolsConfig.c:548
VMTools_AcquireLogStateLock
void VMTools_AcquireLogStateLock(void)
Definition: vmtoolsLog.c:1324
VMTools_ConfigGetInteger
gint VMTools_ConfigGetInteger(GKeyFile *config, const gchar *section, const gchar *key, const gint defValue)
Definition: vmtoolsConfig.c:591
VMTools_ConfigGetString
gchar * VMTools_ConfigGetString(GKeyFile *config, const gchar *section, const gchar *key, const gchar *defValue)
Definition: vmtoolsConfig.c:633
VMTools_GetTimeAsString
gchar * VMTools_GetTimeAsString(void)
Definition: vmtoolsLog.c:248
VMTools_LoadConfig
gboolean VMTools_LoadConfig(const gchar *path, GKeyFileFlags flags, GKeyFile **config, time_t *mtime)
Definition: vmtoolsConfig.c:324
VMTools_WriteConfig
gboolean VMTools_WriteConfig(const gchar *path, GKeyFile *config, GError **err)
Definition: vmtoolsConfig.c:473
VMTools_ReleaseLogStateLock
void VMTools_ReleaseLogStateLock(void)
Definition: vmtoolsLog.c:1335
VMTools_SuspendLogIO
void VMTools_SuspendLogIO(void)
Definition: vmtoolsLog.c:1370
VMTools_ResumeLogIO
void VMTools_ResumeLogIO(void)
Definition: vmtoolsLog.c:1381
VMTools_CreateTimer
GSource * VMTools_CreateTimer(gint timeout)
Create a timer based on a monotonic clock source.
Definition: monotonicTimer.c:169
VMTools_NewSignalSource
GSource * VMTools_NewSignalSource(int signum)
Definition: signalSource.c:257
vm_free
G_BEGIN_DECLS void vm_free(void *ptr)
Definition: vmtools.c:126
SignalSourceCb
gboolean(* SignalSourceCb)(const siginfo_t *, gpointer)
Definition: utils.h:157