--- a/common.h Thu Jun 05 23:04:28 2008 +0300
+++ b/common.h Fri Jun 06 03:24:22 2008 +0300
@@ -1,7 +1,38 @@
+
+/*
+ * error handling
+ */
+
+// perror + exit
void die (const char *msg);
+
+// fprintf + newline
void error (const char *fmt, ...);
+
+// fprintf + strerror + newline
void perr (const char *fmt, ...);
+
+// fprintf + strerror + newline + exit
void perr_exit (const char *fmt, ...);
+
+// fprintf + newline + exit
void err_exit (const char *fmt, ...);
+/*
+ * Parse a host:port string.
+ *
+ * Valid formats:
+ * host
+ * host:port
+ * [host]
+ * [host]:port
+ *
+ * The contents of the given hostport string *will* be modified.
+ *
+ * The value of *port will be set to NULL if no port was given.
+ *
+ * Returns 0 and sets *host if succesfull, nonzero otherwise.
+ *
+ */
+int parse_hostport (char *hostport, char **host, char **port);