test-socket-signal: add utils.h
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tue, 19 Oct 2010 11:13:09 +0000 (14:13 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tue, 19 Oct 2010 12:00:25 +0000 (15:00 +0300)
Add error handling macro (DIE).

Utils/test-socket-signal/utils.h [new file with mode: 0644]

diff --git a/Utils/test-socket-signal/utils.h b/Utils/test-socket-signal/utils.h
new file mode 100644 (file)
index 0000000..e402dda
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Useful macros
+ *
+ * SO lab team, 2010
+ */
+
+#ifndef UTILS_H_
+#define UTILS_H_       1
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* useful macro for handling error codes */
+#define DIE(is_error, call_description)                                        \
+       do {                                                            \
+               if (is_error) {                                         \
+                       fprintf(stderr, "%s (%s, %d): ",                \
+                                       __func__, __FILE__, __LINE__);  \
+                       perror(call_description);                       \
+                       exit(EXIT_FAILURE);                             \
+               }                                                       \
+       } while(0)
+
+#endif