open-vm-tools 9.10.2
utils.h
Go to the documentation of this file.
1 /*********************************************************
2  * Copyright (C) 2008-2016 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 
76 #if defined(G_PLATFORM_WIN32)
77 # define VMTOOLS_GET_FILENAME_LOCAL(path, err) (gchar *) (path)
78 #else
79 # define VMTOOLS_GET_FILENAME_LOCAL(path, err) g_filename_from_utf8((path), \
80  -1, \
81  NULL, \
82  NULL, \
83  (err))
84 #endif
85 
92 #if defined(G_PLATFORM_WIN32)
93 # define VMTOOLS_RELEASE_FILENAME_LOCAL(path) (void) (path)
94 #else
95 # define VMTOOLS_RELEASE_FILENAME_LOCAL(path) g_free(path)
96 #endif
97 
99 #define VMTOOLS_WRAP_ARRAY(a) VMTools_WrapArray((a), sizeof *(a), G_N_ELEMENTS(a))
100 
101 
102 G_BEGIN_DECLS
103 
104 void
105 vm_free(void *ptr);
106 
107 gboolean
108 VMTools_LoadConfig(const gchar *path,
109  GKeyFileFlags flags,
110  GKeyFile **config,
111  time_t *mtime);
112 
113 gboolean
114 VMTools_WriteConfig(const gchar *path,
115  GKeyFile *config,
116  GError **err);
117 
118 gboolean
119 VMTools_ChangeLogFilePath(const gchar *delimiter,
120  const gchar *appendString,
121  const gchar *domain,
122  GKeyFile *conf);
123 
124 gboolean
125 VMTools_ConfigGetBoolean(GKeyFile *config,
126  const gchar *section,
127  const gchar *key,
128  gboolean defValue);
129 
130 gint
131 VMTools_ConfigGetInteger(GKeyFile *config,
132  const gchar *section,
133  const gchar *key,
134  gint defValue);
135 
136 gchar *
137 VMTools_ConfigGetString(GKeyFile *config,
138  const gchar *section,
139  const gchar *key,
140  gchar *defValue);
141 
142 #if defined(G_PLATFORM_WIN32)
143 
144 gboolean
145 VMTools_AttachConsole(void);
146 
147 GSource *
148 VMTools_NewHandleSource(HANDLE h);
149 
150 #else
151 
153 typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
154 
155 GSource *
156 VMTools_NewSignalSource(int signum);
157 
158 gchar *
159 VMTools_GetLibdir(void);
160 
161 #endif
162 
163 GSource *
164 VMTools_CreateTimer(gint timeout);
165 
166 void
168 
169 void
171 
172 void
174 
175 void
176 VMTools_StopLogging(void);
177 
178 void
180 
181 void
182 VMTools_SuspendLogIO(void);
183 
184 void
185 VMTools_ResumeLogIO(void);
186 
187 GArray *
188 VMTools_WrapArray(gconstpointer data,
189  guint elemSize,
190  guint count);
191 
192 G_END_DECLS
193 
196 #endif /* _VMWARE_TOOLS_UTILS_H_ */
197 
void VMTools_StopLogging(void)
Definition: vmtoolsLog.c:983
GArray * VMTools_WrapArray(gconstpointer data, guint elemSize, guint count)
Definition: vmtools.c:61
void VMTools_SetGuestSDKMode(void)
Definition: vmtoolsLog.c:1006
gint VMTools_ConfigGetInteger(GKeyFile *config, const gchar *section, const gchar *key, gint defValue)
Definition: vmtoolsConfig.c:589
void VMTools_RestartLogging(void)
Definition: vmtoolsLog.c:995
void VMTools_AcquireLogStateLock(void)
Definition: vmtoolsLog.c:960
gboolean(* SignalSourceCb)(const siginfo_t *, gpointer)
Definition: utils.h:153
gchar * VMTools_ConfigGetString(GKeyFile *config, const gchar *section, const gchar *key, gchar *defValue)
Definition: vmtoolsConfig.c:628
gboolean VMTools_LoadConfig(const gchar *path, GKeyFileFlags flags, GKeyFile **config, time_t *mtime)
Definition: vmtoolsConfig.c:324
gboolean VMTools_WriteConfig(const gchar *path, GKeyFile *config, GError **err)
Definition: vmtoolsConfig.c:473
void VMTools_ReleaseLogStateLock(void)
Definition: vmtoolsLog.c:971
gboolean VMTools_ConfigGetBoolean(GKeyFile *config, const gchar *section, const gchar *key, gboolean defValue)
Definition: vmtoolsConfig.c:547
GSource * VMTools_CreateTimer(gint timeout)
Create a timer based on a monotonic clock source.
Definition: monotonicTimer.c:169
GSource * VMTools_NewSignalSource(int signum)
Definition: signalSource.c:256
G_BEGIN_DECLS void vm_free(void *ptr)
Definition: vmtools.c:128