[Libguestfs] [PATCH v2 2/4] common/utils: Move libxml2 writer macros to a common header file.
Pino Toscano
ptoscano at redhat.com
Fri Nov 2 14:15:23 UTC 2018
On Thursday, 4 October 2018 14:03:48 CET Richard W.M. Jones wrote:
> In some places when generating XML output in C code we use some clever
> macros:
>
> start_element ("memory") {
> attribute ("unit", "MiB");
> string ("%d", g->memsize);
> } end_element ();
>
> This commit which is mostly refactoring moves the repeated definitions
> of these macros into a common header file.
>
> I also took this opportunity to change / clean up the macros:
>
> - The macros are now documented properly.
>
> - comment() and empty_element() macros are now available everywhere.
>
> - Error handling has been made generic.
>
> - Added do..while(0) around some of the macros to make them safe to
> use in all contexts.
>
> - Both string() and attribute() take a format string (previously
> there were string_format() and attribute_format() variants).
I'd still keep these variants, as there is no need for a format string
in case there is already the final string to be used.
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20181102/0027f08a/attachment.sig>
More information about the Libguestfs
mailing list