2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
/*
|
2010-03-02 21:19:24 +00:00
|
|
|
* esx_util.h: utility functions for the VMware ESX driver
|
2009-07-23 20:21:08 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
|
|
|
|
*
|
|
|
|
* This library 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; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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 GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ESX_UTIL_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __ESX_UTIL_H__
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-06-03 18:04:15 +00:00
|
|
|
# include <stdbool.h>
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <libxml/uri.h>
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
|
|
|
# include "conf.h"
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-07-30 20:08:35 +00:00
|
|
|
typedef struct _esxUtil_ParsedUri esxUtil_ParsedUri;
|
2010-06-03 18:04:15 +00:00
|
|
|
|
2010-07-30 20:08:35 +00:00
|
|
|
struct _esxUtil_ParsedUri {
|
2010-06-03 18:04:15 +00:00
|
|
|
char *transport;
|
|
|
|
char *vCenter;
|
|
|
|
bool noVerify;
|
|
|
|
bool autoAnswer;
|
2010-06-03 21:09:12 +00:00
|
|
|
bool proxy;
|
|
|
|
int proxy_type;
|
|
|
|
char *proxy_hostname;
|
|
|
|
int proxy_port;
|
2010-07-30 20:08:35 +00:00
|
|
|
char *path_datacenter;
|
|
|
|
char *path_computeResource;
|
|
|
|
char *path_hostSystem;
|
2010-06-03 18:04:15 +00:00
|
|
|
};
|
|
|
|
|
2010-07-30 20:08:35 +00:00
|
|
|
int esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, xmlURIPtr uri);
|
2010-06-03 18:04:15 +00:00
|
|
|
|
2010-07-30 20:08:35 +00:00
|
|
|
void esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
|
|
|
int esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id);
|
|
|
|
|
2010-08-01 17:53:00 +00:00
|
|
|
int esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
|
2010-08-25 09:44:57 +00:00
|
|
|
char **directoryName, char **directoryAndFileName);
|
2009-09-23 12:52:36 +00:00
|
|
|
|
2010-01-15 22:05:26 +00:00
|
|
|
int esxUtil_ResolveHostname(const char *hostname,
|
2009-08-06 13:15:45 +00:00
|
|
|
char *ipAddress, size_t ipAddress_length);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-01-15 22:05:26 +00:00
|
|
|
int esxUtil_GetConfigString(virConfPtr conf, const char *name, char **string,
|
2010-06-18 16:16:22 +00:00
|
|
|
bool optional);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-01-15 22:05:26 +00:00
|
|
|
int esxUtil_GetConfigUUID(virConfPtr conf, const char *name,
|
2010-06-18 16:16:22 +00:00
|
|
|
unsigned char *uuid, bool optional);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-01-15 22:05:26 +00:00
|
|
|
int esxUtil_GetConfigLong(virConfPtr conf, const char *name, long long *number,
|
2010-06-18 16:16:22 +00:00
|
|
|
long long default_, bool optional);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-06-18 16:16:22 +00:00
|
|
|
int esxUtil_GetConfigBoolean(virConfPtr conf, const char *name, bool *boolean_,
|
|
|
|
bool default_, bool optional);
|
2009-07-23 20:21:08 +00:00
|
|
|
|
2010-08-29 17:33:49 +00:00
|
|
|
int esxUtil_ReformatUuid(const char *input, char *output);
|
|
|
|
|
2010-10-12 17:37:39 +00:00
|
|
|
char *esxUtil_EscapeHex(const char *string, char escape, const char *special);
|
|
|
|
|
|
|
|
# define esxUtil_EscapeHexPipe(_string) esxUtil_EscapeHex(_string, '|', "\"")
|
|
|
|
|
|
|
|
# define esxUtil_EscapeHexPercent(_string) esxUtil_EscapeHex(_string, '%', "/\\")
|
|
|
|
|
|
|
|
int esxUtil_UnescapeHex(char *string, char escape);
|
|
|
|
|
|
|
|
# define esxUtil_UnescapeHexPipe(_string) esxUtil_UnescapeHex(_string, '|')
|
|
|
|
|
|
|
|
# define esxUtil_UnescapeHexPercent(_string) esxUtil_UnescapeHex(_string, '%')
|
|
|
|
|
|
|
|
char *esxUtil_EscapeBase64(const char *string);
|
|
|
|
|
|
|
|
void esxUtil_ReplaceSpecialWindowsPathChars(char *string);
|
|
|
|
|
|
|
|
char *esxUtil_EscapeDatastoreItem(const char *string);
|
|
|
|
|
2010-10-15 15:50:23 +00:00
|
|
|
char *esxUtil_ConvertToUTF8(const char *encoding, const char *string);
|
|
|
|
|
2009-07-23 20:21:08 +00:00
|
|
|
#endif /* __ESX_UTIL_H__ */
|