open-vm-tools 10.1.15

lib/include/vmware/tools/utils.h

Go to the documentation of this file.
00001 /*********************************************************
00002  * Copyright (C) 2008-2017 VMware, Inc. All rights reserved.
00003  *
00004  * This program is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License as published
00006  * by the Free Software Foundation version 2.1 and no later version.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00010  * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
00011  * License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this program; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
00016  *
00017  *********************************************************/
00018 
00019 #ifndef _VMWARE_TOOLS_UTILS_H_
00020 #define _VMWARE_TOOLS_UTILS_H_
00021 
00037 #define  VMTOOLS_GUEST_SERVICE   "vmsvc"
00038 #define  VMTOOLS_USER_SERVICE    "vmusr"
00039 
00040 #if defined(__cplusplus)
00041 #  define VMTOOLS_EXTERN_C extern "C"
00042 #else
00043 #  define VMTOOLS_EXTERN_C
00044 #endif
00045 
00046 #include <glib.h>
00047 #if defined(G_PLATFORM_WIN32)
00048 #  include <windows.h>
00049 #else
00050 #  include <signal.h>
00051 #  include <sys/time.h>
00052 #endif
00053 
00054 
00055 /* Work around a glib limitation: it doesn't set G_INLINE_FUNC on Win32. */
00056 #if defined(G_PLATFORM_WIN32)
00057 #  if defined(G_INLINE_FUNC)
00058 #     undef G_INLINE_FUNC
00059 #  endif
00060 #  define G_INLINE_FUNC static __inline
00061 #endif
00062 
00063 #ifndef ABS
00064 #  define ABS(x) (((x) >= 0) ? (x) : -(x))
00065 #endif
00066 
00067 
00080 #if defined(G_PLATFORM_WIN32)
00081 #  define VMTOOLS_GET_FILENAME_LOCAL(path, err) (gchar *) (path)
00082 #else
00083 #  define VMTOOLS_GET_FILENAME_LOCAL(path, err) g_filename_from_utf8((path),  \
00084                                                                      -1,      \
00085                                                                      NULL,    \
00086                                                                      NULL,    \
00087                                                                      (err))
00088 #endif
00089 
00096 #if defined(G_PLATFORM_WIN32)
00097 #  define VMTOOLS_RELEASE_FILENAME_LOCAL(path)   (void) (path)
00098 #else
00099 #  define VMTOOLS_RELEASE_FILENAME_LOCAL(path)   g_free(path)
00100 #endif
00101 
00103 #define VMTOOLS_WRAP_ARRAY(a) VMTools_WrapArray((a), sizeof *(a), G_N_ELEMENTS(a))
00104 
00105 
00106 G_BEGIN_DECLS
00107 
00108 void
00109 vm_free(void *ptr);
00110 
00111 gboolean
00112 VMTools_LoadConfig(const gchar *path,
00113                    GKeyFileFlags flags,
00114                    GKeyFile **config,
00115                    time_t *mtime);
00116 
00117 gboolean
00118 VMTools_WriteConfig(const gchar *path,
00119                     GKeyFile *config,
00120                     GError **err);
00121 
00122 gboolean
00123 VMTools_ChangeLogFilePath(const gchar *delimiter,
00124                           const gchar *appendString,
00125                           const gchar *domain,
00126                           GKeyFile *conf);
00127 
00128 gboolean
00129 VMTools_ConfigGetBoolean(GKeyFile *config,
00130                          const gchar *section,
00131                          const gchar *key,
00132                          gboolean defValue);
00133 
00134 gint
00135 VMTools_ConfigGetInteger(GKeyFile *config,
00136                          const gchar *section,
00137                          const gchar *key,
00138                          gint defValue);
00139 
00140 gchar *
00141 VMTools_ConfigGetString(GKeyFile *config,
00142                         const gchar *section,
00143                         const gchar *key,
00144                         gchar *defValue);
00145 
00146 #if defined(G_PLATFORM_WIN32)
00147 
00148 gboolean
00149 VMTools_AttachConsole(void);
00150 
00151 GSource *
00152 VMTools_NewHandleSource(HANDLE h);
00153 
00154 #else
00155 
00157 typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
00158 
00159 GSource *
00160 VMTools_NewSignalSource(int signum);
00161 
00162 gchar *
00163 VMTools_GetLibdir(void);
00164 
00165 #endif
00166 
00167 GSource *
00168 VMTools_CreateTimer(gint timeout);
00169 
00170 void
00171 VMTools_SetGuestSDKMode(void);
00172 
00173 void
00174 VMTools_AcquireLogStateLock(void);
00175 
00176 void
00177 VMTools_ReleaseLogStateLock(void);
00178 
00179 void
00180 VMTools_StopLogging(void);
00181 
00182 void
00183 VMTools_RestartLogging(void);
00184 
00185 void
00186 VMTools_SuspendLogIO(void);
00187 
00188 void
00189 VMTools_ResumeLogIO(void);
00190 
00191 GArray *
00192 VMTools_WrapArray(gconstpointer data,
00193                   guint elemSize,
00194                   guint count);
00195 
00196 G_END_DECLS
00197 
00200 #endif /* _VMWARE_TOOLS_UTILS_H_ */
00201