utils.h
Go to the documentation of this file.
/*********************************************************
* Copyright (C) 2008-2017 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation version 2.1 and no later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*********************************************************/
#ifndef _VMWARE_TOOLS_UTILS_H_
#define _VMWARE_TOOLS_UTILS_H_
#define VMTOOLS_GUEST_SERVICE "vmsvc"
#define VMTOOLS_USER_SERVICE "vmusr"
#if defined(__cplusplus)
# define VMTOOLS_EXTERN_C extern "C"
#else
# define VMTOOLS_EXTERN_C
#endif
#include <glib.h>
#if defined(G_PLATFORM_WIN32)
# include <windows.h>
#else
# include <signal.h>
# include <sys/time.h>
#endif
/* Work around a glib limitation: it doesn't set G_INLINE_FUNC on Win32. */
#if defined(G_PLATFORM_WIN32)
# if defined(G_INLINE_FUNC)
# undef G_INLINE_FUNC
# endif
# define G_INLINE_FUNC static __inline
#endif
#ifndef ABS
# define ABS(x) (((x) >= 0) ? (x) : -(x))
#endif
#if defined(G_PLATFORM_WIN32)
# define VMTOOLS_GET_FILENAME_LOCAL(path, err) (gchar *) (path)
#else
# define VMTOOLS_GET_FILENAME_LOCAL(path, err) g_filename_from_utf8((path), \
-1, \
NULL, \
NULL, \
(err))
#endif
#if defined(G_PLATFORM_WIN32)
# define VMTOOLS_RELEASE_FILENAME_LOCAL(path) (void) (path)
#else
# define VMTOOLS_RELEASE_FILENAME_LOCAL(path) g_free(path)
#endif
#define VMTOOLS_WRAP_ARRAY(a) VMTools_WrapArray((a), sizeof *(a), G_N_ELEMENTS(a))
G_BEGIN_DECLS
void
vm_free(void *ptr);
gboolean
VMTools_LoadConfig(const gchar *path,
GKeyFileFlags flags,
GKeyFile **config,
time_t *mtime);
gboolean
VMTools_WriteConfig(const gchar *path,
GKeyFile *config,
GError **err);
gboolean
VMTools_ChangeLogFilePath(const gchar *delimiter,
const gchar *appendString,
const gchar *domain,
GKeyFile *conf);
gboolean
VMTools_ConfigGetBoolean(GKeyFile *config,
const gchar *section,
const gchar *key,
const gboolean defValue);
gint
VMTools_ConfigGetInteger(GKeyFile *config,
const gchar *section,
const gchar *key,
const gint defValue);
gchar *
VMTools_ConfigGetString(GKeyFile *config,
const gchar *section,
const gchar *key,
const gchar *defValue);
#if defined(G_PLATFORM_WIN32)
gboolean
VMTools_AttachConsole(void);
GSource *
VMTools_NewHandleSource(HANDLE h);
#else
typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
GSource *
VMTools_NewSignalSource(int signum);
gchar *
VMTools_GetLibdir(void);
#endif
GSource *
VMTools_CreateTimer(gint timeout);
void
VMTools_SetGuestSDKMode(void);
void
VMTools_AcquireLogStateLock(void);
void
VMTools_ReleaseLogStateLock(void);
void
VMTools_StopLogging(void);
void
VMTools_RestartLogging(void);
void
VMTools_SuspendLogIO(void);
void
VMTools_ResumeLogIO(void);
GArray *
VMTools_WrapArray(gconstpointer data,
guint elemSize,
guint count);
G_END_DECLS
#endif /* _VMWARE_TOOLS_UTILS_H_ */
VMTools_StopLogging
void VMTools_StopLogging(void)
Definition: vmtoolsLog.c:1316
VMTools_WrapArray
GArray * VMTools_WrapArray(gconstpointer data, guint elemSize, guint count)
Definition: vmtools.c:60
VMTools_SetGuestSDKMode
void VMTools_SetGuestSDKMode(void)
Definition: vmtoolsLog.c:1385
VMTools_RestartLogging
void VMTools_RestartLogging(void)
Definition: vmtoolsLog.c:1328
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:1293
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_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:1304
VMTools_SuspendLogIO
void VMTools_SuspendLogIO(void)
Definition: vmtoolsLog.c:1339
VMTools_ResumeLogIO
void VMTools_ResumeLogIO(void)
Definition: vmtoolsLog.c:1350
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