summaryrefslogtreecommitdiff
path: root/include/glibtop/error.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/glibtop/error.h')
-rw-r--r--include/glibtop/error.h114
1 files changed, 102 insertions, 12 deletions
diff --git a/include/glibtop/error.h b/include/glibtop/error.h
index a3c077c2..1434e495 100644
--- a/include/glibtop/error.h
+++ b/include/glibtop/error.h
@@ -1,5 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -28,19 +26,111 @@
#include <glibtop.h>
-G_BEGIN_DECLS
+BEGIN_LIBGTOP_DECLS
+
+#ifndef G_GNUC_UNUSED
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define G_GNUC_UNUSED \
+ __attribute__((unused))
+#else /* !__GNUC__ */
+#define G_GNUC_UNUSED
+#endif /* !__GNUC__ */
+#endif /* defined G_GNUC_UNUSED */
+
+void glibtop_error_vr (glibtop *server, char *format, va_list args);
+void glibtop_warn_vr (glibtop *server, char *format, va_list args);
+
+void glibtop_error_io_vr (glibtop *server, char *format, int, va_list args);
+void glibtop_warn_io_vr (glibtop *server, char *format, int, va_list args);
+
+static void G_GNUC_UNUSED
+glibtop_error_r (glibtop *server, char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ glibtop_error_vr (server, format, args);
+ va_end (args);
+}
+
+static void G_GNUC_UNUSED
+glibtop_warn_r (glibtop *server, char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ glibtop_warn_vr (server, format, args);
+ va_end (args);
+}
+
+static void G_GNUC_UNUSED
+glibtop_error_io_r (glibtop *server, char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ glibtop_error_io_vr (server, format, errno, args);
+ va_end (args);
+}
+
+static void G_GNUC_UNUSED
+glibtop_warn_io_r (glibtop *server, char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ glibtop_warn_io_vr (server, format, errno, args);
+ va_end (args);
+}
+
+#ifdef __GNUC__
+
+#define glibtop_error(p1, args...) glibtop_error_r(glibtop_global_server , p1 , ## args)
+#define glibtop_warn(p1, args...) glibtop_warn_r(glibtop_global_server , p1 , ## args)
+
+#define glibtop_error_io(p1, args...) glibtop_error_io_r(glibtop_global_server , p1 , ## args)
+#define glibtop_warn_io(p1, args...) glibtop_warn_io_r(glibtop_global_server , p1 , ## args)
+
+#else /* no __GNUC__ */
+
+static void
+glibtop_error (char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ glibtop_error_vr (glibtop_global_server, format, args);
+ va_end (args);
+}
+
+static void
+glibtop_warn (char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ glibtop_warn_vr (glibtop_global_server, format, args);
+ va_end (args);
+}
-void glibtop_error_vr (glibtop_server *server, char *format, va_list args);
-void glibtop_warn_vr (glibtop_server *server, char *format, va_list args);
+static void
+glibtop_error_io (char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ glibtop_error_io_vr (glibtop_global_server, format, errno, args);
+ va_end (args);
+}
-void glibtop_error_io_vr (glibtop_server *server, char *format, int, va_list args);
-void glibtop_warn_io_vr (glibtop_server *server, char *format, int, va_list args);
+static void
+glibtop_warn_io (char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ glibtop_warn_io_vr (glibtop_global_server, format, errno, args);
+ va_end (args);
+}
-void glibtop_error_r (glibtop_server *server, char *format, ...);
-void glibtop_warn_r (glibtop_server *server, char *format, ...);
-void glibtop_error_io_r (glibtop_server *server, char *format, ...);
-void glibtop_warn_io_r (glibtop_server *server, char *format, ...);
+#endif /* no __GNUC__ */
-G_END_DECLS
+END_LIBGTOP_DECLS
#endif