From: Razvan Deaconescu Date: Tue, 19 Oct 2010 11:13:09 +0000 (+0300) Subject: test-socket-signal: add utils.h X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=f8967831e3b1c50c3c5369a719bcd1f7d55b794d;p=p2p-testing-infrastructure.git test-socket-signal: add utils.h Add error handling macro (DIE). --- diff --git a/Utils/test-socket-signal/utils.h b/Utils/test-socket-signal/utils.h new file mode 100644 index 0000000..e402dda --- /dev/null +++ b/Utils/test-socket-signal/utils.h @@ -0,0 +1,24 @@ +/* + * Useful macros + * + * SO lab team, 2010 + */ + +#ifndef UTILS_H_ +#define UTILS_H_ 1 + +#include +#include + +/* 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