From 172b5f0aef9e49e3c4af4f6c8a4077aef833b7f3 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sat, 1 Mar 2008 15:54:16 -0500 Subject: Use a switch dispatch and crash on unknown types. --- src/mysqlerl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mysqlerl.c b/src/mysqlerl.c index 0f88a49..dfd7ef0 100644 --- a/src/mysqlerl.c +++ b/src/mysqlerl.c @@ -175,8 +175,16 @@ write_cmd(const char *cmd, msglen_t len) void dispatch_db_cmd(MYSQL *dbh, msg_t *msg) { - logmsg("DEBUG: type: %d, msg: %s.", msg->type, msg->msg); - write_cmd(msg->msg, msg->msglen); + switch (msg->type) { + case QUERY_MSG: + logmsg("DEBUG: got query msg: %s.", msg->msg); + write_cmd(msg->msg, msg->msglen); + break; + + default: + logmsg("WARNING: message type %d unknown.", msg->type); + exit(3); + } } void -- cgit v1.2.3