---
 src/Makefile.am        |    2 ++
 src/libvirtSnmpError.c |   34 ++++++++++++++++++++++++++++++++++
 src/libvirtSnmpError.h |   31 +++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 0 deletions(-)
 create mode 100644 src/libvirtSnmpError.c
 create mode 100644 src/libvirtSnmpError.h

diff --git a/src/Makefile.am b/src/Makefile.am
index c781e23..57b74c8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,12 +15,14 @@ USER_SRCS =         \
                libvirtGuestTable_data_get.c \
                libvirtGuestTable_data_set.c \
                libvirtGuestTable_data_access.c \
+               libvirtSnmpError.c \
                libvirtSnmp.c
 
 USER_HDRS =    \
                libvirtGuestTable_data_get.h \
                libvirtGuestTable_data_set.h \
                libvirtGuestTable_data_access.h \
+               libvirtSnmpError.h \
                libvirtSnmp.h
 
 SRCS =                 \
diff --git a/src/libvirtSnmpError.c b/src/libvirtSnmpError.c
new file mode 100644
index 0000000..f5d546d
--- /dev/null
+++ b/src/libvirtSnmpError.c
@@ -0,0 +1,34 @@
+/*
+ * libvirtSnmpError.c: libvirt error handling function
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Michal Privoznik <mpriv...@redhat.com>
+ */
+
+#include "libvirtSnmpError.h"
+#include <stdio.h>
+
+/**
+ * Print libvirt error
+ * @msg Error message
+ */
+void printLibvirtError(const char *msg) {
+    virErrorPtr err = virGetLastError();
+
+    fprintf(stderr, "%s: %s", msg, err ? err->message : "Unknown error");
+}
diff --git a/src/libvirtSnmpError.h b/src/libvirtSnmpError.h
new file mode 100644
index 0000000..518cc03
--- /dev/null
+++ b/src/libvirtSnmpError.h
@@ -0,0 +1,31 @@
+/*
+ * libvirtSnmpError.h: libvirt error handling function
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Michal Privoznik <mpriv...@redhat.com>
+ */
+
+#ifndef __VIR_SNMP_ERROR_H__
+#define __VIR_SNMP_ERROR_H__
+
+#include <libvirt/libvirt.h>
+#include <libvirt/virterror.h>
+
+extern void printLibvirtError(const char *msg);
+
+#endif
-- 
1.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to