[libvirt] [PATCH] esx: Gather some XML generation macros in esx_vi.h

--- src/esx/esx_vi.c | 27 ++------------------------- src/esx/esx_vi.h | 37 +++++++++++++++++++++++++++++++++++++ src/esx/esx_vi_methods.c | 17 ----------------- src/esx/esx_vi_types.c | 20 -------------------- 4 files changed, 39 insertions(+), 62 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index c6854f1..e405c80 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -38,38 +38,13 @@ #define VIR_FROM_THIS VIR_FROM_ESX -#define ESX_VI__SOAP__REQUEST_HEADER \ - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \ - "<soapenv:Envelope " \ - "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " \ - "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " \ - "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " \ - "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" \ - "<soapenv:Body>" - -#define ESX_VI__SOAP__REQUEST_FOOTER \ - "</soapenv:Body>" \ - "</soapenv:Envelope>" + #define ESX_VI__SOAP__RESPONSE_XPATH(_type) \ ((char *)"/soapenv:Envelope/soapenv:Body/" \ "vim:"_type"Response/vim:returnval") -#define ESV_VI__XML_TAG__OPEN(_buffer, _element, _type) \ - do { \ - virBufferAddLit(_buffer, "<"); \ - virBufferAdd(_buffer, _element, -1); \ - virBufferAddLit(_buffer, " xmlns=\"urn:vim25\" xsi:type=\""); \ - virBufferAdd(_buffer, _type, -1); \ - virBufferAddLit(_buffer, "\">"); \ - } while (0) - -#define ESV_VI__XML_TAG__CLOSE(_buffer, _element) \ - do { \ - virBufferAddLit(_buffer, "</"); \ - virBufferAdd(_buffer, _element, -1); \ - virBufferAddLit(_buffer, ">"); \ - } while (0) + #define ESX_VI__TEMPLATE__ALLOC(_type) \ int \ @@ -78,6 +53,8 @@ return esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##_type)); \ } + + #define ESX_VI__TEMPLATE__FREE(_type, _body) \ void \ esxVI_##_type##_Free(esxVI_##_type **ptrptr) \ diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h index a3d9363..e0d731e 100644 --- a/src/esx/esx_vi.h +++ b/src/esx/esx_vi.h @@ -40,6 +40,43 @@ +#define ESX_VI__SOAP__REQUEST_HEADER \ + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \ + "<soapenv:Envelope\n" \ + " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" \ + " xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\n" \ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" \ + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" \ + "<soapenv:Body>\n" + + + +#define ESX_VI__SOAP__REQUEST_FOOTER \ + "</soapenv:Body>\n" \ + "</soapenv:Envelope>" + + + +#define ESV_VI__XML_TAG__OPEN(_buffer, _element, _type) \ + do { \ + virBufferAddLit(_buffer, "<"); \ + virBufferAdd(_buffer, _element, -1); \ + virBufferAddLit(_buffer, " xmlns=\"urn:vim25\" xsi:type=\""); \ + virBufferAdd(_buffer, _type, -1); \ + virBufferAddLit(_buffer, "\">"); \ + } while (0) + + + +#define ESV_VI__XML_TAG__CLOSE(_buffer, _element) \ + do { \ + virBufferAddLit(_buffer, "</"); \ + virBufferAdd(_buffer, _element, -1); \ + virBufferAddLit(_buffer, ">"); \ + } while (0) + + + typedef enum _esxVI_APIVersion esxVI_APIVersion; typedef enum _esxVI_ProductVersion esxVI_ProductVersion; typedef enum _esxVI_Occurrence esxVI_Occurrence; diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c index 5c52167..8f841e3 100644 --- a/src/esx/esx_vi_methods.c +++ b/src/esx/esx_vi_methods.c @@ -34,23 +34,6 @@ -#define ESX_VI__SOAP__REQUEST_HEADER \ - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \ - "<soapenv:Envelope " \ - "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " \ - "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " \ - "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " \ - "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" \ - "<soapenv:Body>" - - - -#define ESX_VI__SOAP__REQUEST_FOOTER \ - "</soapenv:Body>" \ - "</soapenv:Envelope>" - - - #define ESX_VI__METHOD__CHECK_OUTPUT__None \ /* nothing */ diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index ed4674b..7d2c02c 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -39,26 +39,6 @@ -#define ESV_VI__XML_TAG__OPEN(_buffer, _element, _type) \ - do { \ - virBufferAddLit(_buffer, "<"); \ - virBufferAdd(_buffer, _element, -1); \ - virBufferAddLit(_buffer, " xmlns=\"urn:vim25\" xsi:type=\""); \ - virBufferAdd(_buffer, _type, -1); \ - virBufferAddLit(_buffer, "\">"); \ - } while (0) - - - -#define ESV_VI__XML_TAG__CLOSE(_buffer, _element) \ - do { \ - virBufferAddLit(_buffer, "</"); \ - virBufferAdd(_buffer, _element, -1); \ - virBufferAddLit(_buffer, ">"); \ - } while (0) - - - #define ESX_VI__TEMPLATE__ALLOC(__type) \ int \ esxVI_##__type##_Alloc(esxVI_##__type **ptrptr) \ -- 1.6.3.3

On 04/18/2010 02:33 PM, Matthias Bolte wrote:
--- src/esx/esx_vi.c | 27 ++------------------------- src/esx/esx_vi.h | 37 +++++++++++++++++++++++++++++++++++++ src/esx/esx_vi_methods.c | 17 ----------------- src/esx/esx_vi_types.c | 20 -------------------- 4 files changed, 39 insertions(+), 62 deletions(-)
Nice net change in lines of code. ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2010/4/20 Eric Blake <eblake@redhat.com>:
On 04/18/2010 02:33 PM, Matthias Bolte wrote:
--- src/esx/esx_vi.c | 27 ++------------------------- src/esx/esx_vi.h | 37 +++++++++++++++++++++++++++++++++++++ src/esx/esx_vi_methods.c | 17 ----------------- src/esx/esx_vi_types.c | 20 -------------------- 4 files changed, 39 insertions(+), 62 deletions(-)
Nice net change in lines of code.
ACK.
Thanks, pushed. Matthias

* src/esx/esx_vi.h: Placate cppi. --- Sorry for not noticing this earlier, but your patch fails 'make syntax-check'. Pushing this as obvious. src/esx/esx_vi.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h index e0d731e..d581a59 100644 --- a/src/esx/esx_vi.h +++ b/src/esx/esx_vi.h @@ -40,7 +40,7 @@ -#define ESX_VI__SOAP__REQUEST_HEADER \ +# define ESX_VI__SOAP__REQUEST_HEADER \ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \ "<soapenv:Envelope\n" \ " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" \ @@ -51,13 +51,13 @@ -#define ESX_VI__SOAP__REQUEST_FOOTER \ +# define ESX_VI__SOAP__REQUEST_FOOTER \ "</soapenv:Body>\n" \ "</soapenv:Envelope>" -#define ESV_VI__XML_TAG__OPEN(_buffer, _element, _type) \ +# define ESV_VI__XML_TAG__OPEN(_buffer, _element, _type) \ do { \ virBufferAddLit(_buffer, "<"); \ virBufferAdd(_buffer, _element, -1); \ @@ -68,7 +68,7 @@ -#define ESV_VI__XML_TAG__CLOSE(_buffer, _element) \ +# define ESV_VI__XML_TAG__CLOSE(_buffer, _element) \ do { \ virBufferAddLit(_buffer, "</"); \ virBufferAdd(_buffer, _element, -1); \ -- 1.6.6.1
participants (2)
-
Eric Blake
-
Matthias Bolte