open-vm-tools 11.0.0

utils.h
Go to the documentation of this file.
1 /*********************************************************
2 * Copyright (C) 2008-2019 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
97 G_BEGIN_DECLS
98
99 void
100 vm_free(void *ptr);
101
102 gboolean
103 VMTools_LoadConfig(const gchar *path,
104 GKeyFileFlags flags,
105 GKeyFile **config,
106 time_t *mtime);
107
108 gboolean
109 VMTools_WriteConfig(const gchar *path,
110 GKeyFile *config,
111 GError **err);
112
113 gboolean
114 VMTools_ChangeLogFilePath(const gchar *delimiter,
115 const gchar *appendString,
116 const gchar *domain,
117 GKeyFile *conf);
118
119 gboolean
120 VMTools_ConfigGetBoolean(GKeyFile *config,
121 const gchar *section,
122 const gchar *key,
123 const gboolean defValue);
124
125 gint
126 VMTools_ConfigGetInteger(GKeyFile *config,
127 const gchar *section,
128 const gchar *key,
129 const gint defValue);
130
131 gchar *
132 VMTools_ConfigGetString(GKeyFile *config,
133 const gchar *section,
134 const gchar *key,
135 const gchar *defValue);
136
137 #if defined(G_PLATFORM_WIN32)
138
139 gboolean
140 VMTools_AttachConsole(void);
141
142 GSource *
143 VMTools_NewHandleSource(HANDLE h);
144
145 #else
146
148 typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
149
150 GSource *
151 VMTools_NewSignalSource(int signum);
152
153 gchar *
154 VMTools_GetLibdir(void);
155
156 #endif
157
158 GSource *
159 VMTools_CreateTimer(gint timeout);
160
161 void
162 VMTools_SetGuestSDKMode(void);
163
164 void
165 VMTools_AcquireLogStateLock(void);
166
167 void
168 VMTools_ReleaseLogStateLock(void);
169
170 gchar *
171 VMTools_GetTimeAsString(void);
172
173 void
174 VMTools_SuspendLogIO(void);
175
176 void
177 VMTools_ResumeLogIO(void);
178
179 GArray *
180 VMTools_WrapArray(gconstpointer data,
181 guint elemSize,
182 guint count);
183
184 G_END_DECLS
185
188 #endif /* _VMWARE_TOOLS_UTILS_H_ */
189
VMTools_CreateTimer
GSource * VMTools_CreateTimer(gint timeout)
Create a timer based on a monotonic clock source.
Definition: monotonicTimer.c:169
VMTools_SetGuestSDKMode
void VMTools_SetGuestSDKMode(void)
Definition: vmtoolsLog.c:2090
VMTools_WrapArray
GArray * VMTools_WrapArray(gconstpointer data, guint elemSize, guint count)
Definition: vmtools.c:60
VMTools_ChangeLogFilePath
gboolean VMTools_ChangeLogFilePath(const gchar *delimiter, const gchar *appendString, const gchar *domain, GKeyFile *conf)
Definition: vmtoolsLog.c:2401
SignalSourceCb
gboolean(* SignalSourceCb)(const siginfo_t *, gpointer)
Definition: utils.h:147
VMTools_ConfigGetBoolean
gboolean VMTools_ConfigGetBoolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean defValue)
Definition: vmtoolsConfig.c:264
VMTools_GetTimeAsString
gchar * VMTools_GetTimeAsString(void)
Definition: vmtoolsLog.c:344
VMTools_AcquireLogStateLock
void VMTools_AcquireLogStateLock(void)
Definition: vmtoolsLog.c:2022
VMTools_ConfigGetInteger
gint VMTools_ConfigGetInteger(GKeyFile *config, const gchar *section, const gchar *key, const gint defValue)
Definition: vmtoolsConfig.c:309
VMTools_LoadConfig
gboolean VMTools_LoadConfig(const gchar *path, GKeyFileFlags flags, GKeyFile **config, time_t *mtime)
Definition: vmtoolsConfig.c:87
VMTools_ConfigGetString
gchar * VMTools_ConfigGetString(GKeyFile *config, const gchar *section, const gchar *key, const gchar *defValue)
Definition: vmtoolsConfig.c:351
VMTools_WriteConfig
gboolean VMTools_WriteConfig(const gchar *path, GKeyFile *config, GError **err)
Definition: vmtoolsConfig.c:189
vm_free
G_BEGIN_DECLS void vm_free(void *ptr)
Definition: vmtools.c:126
VMTools_ReleaseLogStateLock
void VMTools_ReleaseLogStateLock(void)
Definition: vmtoolsLog.c:2033
VMTools_ResumeLogIO
void VMTools_ResumeLogIO(void)
Definition: vmtoolsLog.c:2055
VMTools_SuspendLogIO
void VMTools_SuspendLogIO(void)
Definition: vmtoolsLog.c:2044
VMTools_NewSignalSource
GSource * VMTools_NewSignalSource(int signum)
Definition: signalSource.c:256