common.h
changeset 11 082bfaf38cf0
parent 8 4d38ccbeb93e
child 12 43297144f196
--- a/common.h	Fri Jun 06 16:05:26 2008 +0300
+++ b/common.h	Fri Jun 06 18:35:46 2008 +0300
@@ -18,6 +18,18 @@
 // fprintf + newline + exit
 void err_exit (const char *fmt, ...);
 
+// fprintf (__func__ + msg, ...)
+void err_func (const char *func, const char *fmt, ...);
+
+// fprintf (__func__ + msg + strerror, ...)
+void perr_func (const char *func, const char *fmt, ...);
+
+// error(func + colon + msg, ...) + goto error
+#define ERROR(msg) do { err_func(__func__, "%s", msg); goto error; } while (0)
+#define ERROR_FMT(fmt, ...) do { err_func(__func__, fmt, __VA_ARGS__); goto error; } while (0)
+#define PERROR(msg) do { perr_func(__func__, "%s", msg); goto error; } while (0)
+#define PERROR_FMT(fmt, ...) do { perr_func(__func__, fmt, __VA_ARGS__); goto error; } while (0)
+
 /*
  * Parse a host:port string.
  *