Utility Functions

A collection of useful functions for when writing applications. More...


Defines

#define VMTOOLS_GUEST_SERVICE   "vmsvc"
#define VMTOOLS_USER_SERVICE   "vmusr"
#define VMTOOLS_GET_FILENAME_LOCAL(path, err)
#define VMTOOLS_RELEASE_FILENAME_LOCAL(path)   g_free(path)

Typedefs

typedef gboolean(* SignalSourceCb )(const siginfo_t *, gpointer)

Functions

const char * VMTools_GetDefaultLogDomain (void)
void vm_free (void *ptr)
void VMTools_SetDefaultLogDomain (const gchar *domain)
void VMTools_ConfigLogging (GKeyFile *cfg)
void VMTools_EnableLogging (gboolean enable)
gchar * VMTools_GetToolsConfFile (void)
GKeyFile * VMTools_LoadConfig (const gchar *path, GKeyFileFlags flags, gboolean autoUpgrade)
gboolean VMTools_ReloadConfig (const gchar *path, GKeyFileFlags flags, GKeyFile **config, time_t *mtime)
void VMTools_ResetLogging (gboolean cleanDefault)
gboolean VMTools_WriteConfig (const gchar *path, GKeyFile *config, GError **err)
GSource * VMTools_NewSignalSource (int signum)
GArray * VMTools_WrapArray (gconstpointer data, guint elemSize, guint count)


Detailed Description

A collection of useful functions for when writing applications.

This module contains functions for loading configuration data, logging, and extensions to the glib API that are useful when writing applications.

Configuring Logging

Logging is configurable on a per-domain basis. The configuration options for each domain are:

Logging configuration should be under the "[logging]" group in the application's configuration file.

Each application can specify a default log domain (which defaults to "vmtools"). If no handler is specified for a particular domain when logging, the default handler will be used. The default logging level for the default domain is "warning" in non-debug builds, and "message" in debug builds.

Example of logging configuration in the config file:

[logging]
# Turns on logging globally. It can still be disabled for each domain.
log = true

# Disables core dumps on fatal errors; they're enabled by default.
enableCoreDump = false

# Defines the "vmsvc" domain, logging to stdout/stderr.
vmsvc.level = info
vmsvc.handler = std

# Defines the "unity" domain, logging to a file.
unity.level = warning
unity.handler = file
unity.data = /tmp/unity.log

# Defines the "vmtoolsd" domain, and disable logging for it.
vmtoolsd.level = none

Log file names can contain variable references. Currently, only two variables are expanded: ${USER} expands to the current user's login name, and ${PID} expands to the current process's ID. So, for example, log.${USER}.${PID}.txt would expand to "log.jdoe.1234.txt" for user "jdoe" if the process ID were 1234.


Define Documentation

#define VMTOOLS_GET_FILENAME_LOCAL ( path,
err   ) 

Value:

g_filename_from_utf8((path),  \
                                                                     -1,      \
                                                                     NULL,    \
                                                                     NULL,    \
                                                                     (err))
Converts an UTF-8 path to the local (i.e., glib) file name encoding. This is a no-op on Windows, since the local encoding is always UTF-8 in glib. The returned value should not be freed directly; instead, use VMTOOLS_FREE_FILENAME.

Parameters:
[in] path Path in UTF-8 (should not be NULL).
[out] err Where to store errors (type: GError **; may be NULL).
Returns:
The path in glib's filename encoding, or NULL on error.

#define VMTOOLS_RELEASE_FILENAME_LOCAL ( path   )     g_free(path)

Frees a path allocated with VMTOOLS_GET_FILENAME_LOCAL. No-op on Windows.

Parameters:
[in] path Path in UTF-8.


Typedef Documentation

typedef gboolean(* SignalSourceCb)(const siginfo_t *, gpointer)

Type of callback used by the signal event source.


Generated on Tue Oct 27 00:40:31 2009 for open-vm-tools 2009.10.15 by  doxygen 1.5.8