Commit 569b4432 authored by Thomas Haller's avatar Thomas Haller

shared: add nm-glib.h compat implementation for g_variant_new_printf()

parent 3be79105
......@@ -452,4 +452,33 @@ _nm_g_variant_new_take_string (gchar *string)
}
#define g_variant_new_take_string _nm_g_variant_new_take_string
#if !GLIB_CHECK_VERSION(2, 38, 0)
_nm_printf (1, 2)
static inline GVariant *
_nm_g_variant_new_printf (const char *format_string, ...)
{
char *string;
va_list ap;
g_return_val_if_fail (format_string, NULL);
va_start (ap, format_string);
string = g_strdup_vprintf (format_string, ap);
va_end (ap);
return g_variant_new_take_string (string);
}
#define g_variant_new_printf(...) _nm_g_variant_new_printf(__VA_ARGS__)
#else
#define g_variant_new_printf(...) \
({ \
GVariant *_v; \
\
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
_v = g_variant_new_printf (__VA_ARGS__); \
G_GNUC_END_IGNORE_DEPRECATIONS \
_v; \
})
#endif
#endif /* __NM_GLIB_H__ */
......@@ -26,16 +26,16 @@
#include <stdlib.h>
#include <errno.h>
#include "nm-glib.h"
/*****************************************************************************/
#define _nm_packed __attribute__ ((packed))
#define _nm_unused __attribute__ ((unused))
#define _nm_pure __attribute__ ((pure))
#define _nm_const __attribute__ ((const))
#define _nm_printf(a,b) __attribute__ ((__format__ (__printf__, a, b)))
#include "nm-glib.h"
/*****************************************************************************/
#define nm_offsetofend(t,m) (G_STRUCT_OFFSET (t,m) + sizeof (((t *) NULL)->m))
#define nm_auto(fcn) __attribute__ ((cleanup(fcn)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment