00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
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
00201