From f3e11b1d6f1fc2f58b0e059b0f94ed3911ed7aed Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 6 Jan 2016 03:11:20 -0600 Subject: [PATCH] authd: clean up command handlers code a little --- authd/authd.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/authd/authd.c b/authd/authd.c index f9f81edf..f8007a28 100644 --- a/authd/authd.c +++ b/authd/authd.c @@ -18,15 +18,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include - -#include "setup.h" -#include "common.h" +#include "authd.h" +#include "dns.h" #define MAXPARA 10 -static rb_helper *authd_helper = NULL; +rb_helper *authd_helper = NULL; +authd_cmd_handler authd_cmd_handlers[255] = {}; static void parse_request(rb_helper *helper) @@ -35,6 +33,7 @@ parse_request(rb_helper *helper) static char readbuf[READBUF_SIZE]; int parc; int len; + authd_cmd_handler handler; while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0) { @@ -43,11 +42,9 @@ parse_request(rb_helper *helper) if(parc < 1) continue; - switch (parv[0][0]) - { - default: - break; - } + handler = authd_cmd_handlers[parv[0][0]]; + if (handler != NULL) + handler(parc, parv); } }