Commit c754bb7e c754bb7ef1c0a668f8c672aaae9a5de16e68a355 by Sam Roberts

tcp_stream_create now has more informative errors for no host or port

1 parent 108f892c
......@@ -60,6 +60,9 @@ extern "C" {
#define MU_ERR_MAILER_NO_RCPT_TO (MU_ERR_BASE | 0x015)
#define MU_ERR_SMTP_RCPT_FAILED (MU_ERR_BASE | 0x016)
#define MU_ERR_TCP_NO_HOST (MU_ERR_BASE | 0x017)
#define MU_ERR_TCP_NO_PORT (MU_ERR_BASE | 0x018)
const char* mu_errname __P((int e));
const char* mu_errstring __P((int e));
......
......@@ -64,6 +64,7 @@ mu_errname (int e)
EN(MU_ERR_LOCK_EXT_FAIL)
EN(MU_ERR_LOCK_EXT_ERR)
EN(MU_ERR_LOCK_EXT_KILLED)
EN(MU_ERR_NO_SUCH_USER)
EN(MU_ERR_GETHOSTBYNAME)
EN(MU_ERR_BAD_RESUMPTION)
......@@ -71,6 +72,8 @@ mu_errname (int e)
EN(MU_ERR_MAILER_BAD_TO)
EN(MU_ERR_MAILER_NO_RCPT_TO)
EN(MU_ERR_SMTP_RCPT_FAILED)
EN(MU_ERR_TCP_NO_HOST)
EN(MU_ERR_TCP_NO_PORT)
}
return "SYSTEM ERROR";
......@@ -105,12 +108,14 @@ const char* mu_errstring (int e)
ES(MU_ERR_NO_SUCH_USER, "No such user name")
ES(MU_ERR_GETHOSTBYNAME, "gethostbyname() failed, check h_errno")
ES(MU_ERR_GETHOSTBYNAME, "DNS name resolution failed")
ES(MU_ERR_BAD_RESUMPTION, "State busy, must resume operation")
ES(MU_ERR_MAILER_BAD_FROM, "Not a valid mailer from address")
ES(MU_ERR_MAILER_BAD_TO, "Not a valid mailer to address")
ES(MU_ERR_MAILER_NO_RCPT_TO,"No receipt addresses found")
ES(MU_ERR_SMTP_RCPT_FAILED, "SMTP rcpt to command failed")
ES(MU_ERR_TCP_NO_HOST, "Tcp connections need a host")
ES(MU_ERR_TCP_NO_PORT, "Tcp connections need a postive port")
}
return strerror(e);
......
......@@ -232,8 +232,11 @@ tcp_stream_create (stream_t * stream, const char* host, int port, int flags)
struct _tcp_instance *tcp;
int ret;
if (host == NULL || port < 1)
return EINVAL;
if (host == NULL)
return MU_ERR_TCP_NO_HOST
if (port < 1)
return MU_ERR_TCP_NO_PORT;
if ((tcp = malloc (sizeof (*tcp))) == NULL)
return ENOMEM;
......