utils.h
Go to the documentation of this file.
/*********************************************************
* Copyright (C) 2008-2020 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
#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_AddConfig(GKeyFile *srcConfig,
GKeyFile *dstConfig);
gboolean
VMTools_CompareConfig(GKeyFile *config1,
GKeyFile *config2);
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_AcquireLogStateLock(void);
void
VMTools_ReleaseLogStateLock(void);
gchar *
VMTools_GetTimeAsString(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_AcquireLogStateLock
void VMTools_AcquireLogStateLock(void)
Definition vmtoolsLog.c:2128
VMTools_ConfigGetBoolean
gboolean VMTools_ConfigGetBoolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean defValue)
Definition vmtoolsConfig.c:495
VMTools_LoadConfig
gboolean VMTools_LoadConfig(const gchar *path, GKeyFileFlags flags, GKeyFile **config, time_t *mtime)
Definition vmtoolsConfig.c:87
SignalSourceCb
gboolean(* SignalSourceCb)(const siginfo_t *, gpointer)
Definition utils.h:156
VMTools_WrapArray
GArray * VMTools_WrapArray(gconstpointer data, guint elemSize, guint count)
Definition vmtools.c:60
VMTools_ResumeLogIO
void VMTools_ResumeLogIO(void)
Definition vmtoolsLog.c:2161
VMTools_NewSignalSource
GSource * VMTools_NewSignalSource(int signum)
Definition signalSource.c:261
VMTools_AddConfig
gboolean VMTools_AddConfig(GKeyFile *srcConfig, GKeyFile *dstConfig)
Definition vmtoolsConfig.c:197
vm_free
G_BEGIN_DECLS void vm_free(void *ptr)
Definition vmtools.c:126
VMTools_ReleaseLogStateLock
void VMTools_ReleaseLogStateLock(void)
Definition vmtoolsLog.c:2139
VMTools_ConfigGetString
gchar * VMTools_ConfigGetString(GKeyFile *config, const gchar *section, const gchar *key, const gchar *defValue)
Definition vmtoolsConfig.c:582
VMTools_GetTimeAsString
gchar * VMTools_GetTimeAsString(void)
Definition vmtoolsLog.c:359
VMTools_SuspendLogIO
void VMTools_SuspendLogIO(void)
Definition vmtoolsLog.c:2150
VMTools_ConfigGetInteger
gint VMTools_ConfigGetInteger(GKeyFile *config, const gchar *section, const gchar *key, const gint defValue)
Definition vmtoolsConfig.c:540
VMTools_CreateTimer
GSource * VMTools_CreateTimer(gint timeout)
Create a timer based on a monotonic clock source.
Definition monotonicTimer.c:169
VMTools_WriteConfig
gboolean VMTools_WriteConfig(const gchar *path, GKeyFile *config, GError **err)
Definition vmtoolsConfig.c:420
VMTools_CompareConfig
gboolean VMTools_CompareConfig(GKeyFile *config1, GKeyFile *config2)
Definition vmtoolsConfig.c:277
VMTools_ChangeLogFilePath
gboolean VMTools_ChangeLogFilePath(const gchar *delimiter, const gchar *appendString, const gchar *domain, GKeyFile *conf)
Definition vmtoolsLog.c:2472