diff options
author | Brian Cully <bjc@kublai.com> | 2008-03-01 15:33:11 -0500 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2008-03-01 15:33:11 -0500 |
commit | a15b24e54c3149fbd2ece053ce4c3cbd069514e8 (patch) | |
tree | 6a1e981198b39278196db994fc90cb266d3dd5c5 | |
parent | dd72c7682b9f0ca5defa345a570c291f7693cd40 (diff) | |
download | mysqlerl-a15b24e54c3149fbd2ece053ce4c3cbd069514e8.tar.gz mysqlerl-a15b24e54c3149fbd2ece053ce4c3cbd069514e8.zip |
Use tagged message types.
-rw-r--r-- | src/mysqlerl.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mysqlerl.c b/src/mysqlerl.c index dc1e868..7a3a68e 100644 --- a/src/mysqlerl.c +++ b/src/mysqlerl.c @@ -18,9 +18,12 @@ const char *LOGPATH = "/tmp/mysqlerl.log"; static FILE *logfile = NULL; typedef u_int32_t msglen_t; -typedef enum { QUERY = 0 } msgtype_t; +typedef enum { QUERY_MSG = 0, EXTENDED_MSG = 255 } msgtype_t; + struct msg { msgtype_t type; + char *msg; + size_t msglen; char *buf; }; typedef struct msg msg_t; @@ -146,6 +149,10 @@ read_msg() exit(2); } + msg->type = msg->buf[0]; + msg->msg = msg->buf + 1; + msg->msglen = len - 1; + return msg; } @@ -169,7 +176,8 @@ void dispatch_db_cmd(MYSQL *dbh, msg_t *msg) { logmsg("DEBUG: dispatch_cmd(\"%s\")", msg->buf); - write_cmd(msg->buf, strlen(msg->buf)); + logmsg("DEBUG: type: %d, msg: %s.\n", msg->type, msg->msg); + write_cmd(msg->msg, msg->msglen); } void |