authd: clean up command handlers code a little

This commit is contained in:
William Pitcock 2016-01-06 03:11:20 -06:00
parent ed62c46ba1
commit f3e11b1d6f

View file

@ -18,15 +18,13 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <ratbox_lib.h> #include "authd.h"
#include <stdio.h> #include "dns.h"
#include "setup.h"
#include "common.h"
#define MAXPARA 10 #define MAXPARA 10
static rb_helper *authd_helper = NULL; rb_helper *authd_helper = NULL;
authd_cmd_handler authd_cmd_handlers[255] = {};
static void static void
parse_request(rb_helper *helper) parse_request(rb_helper *helper)
@ -35,6 +33,7 @@ parse_request(rb_helper *helper)
static char readbuf[READBUF_SIZE]; static char readbuf[READBUF_SIZE];
int parc; int parc;
int len; int len;
authd_cmd_handler handler;
while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0) while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0)
{ {
@ -43,11 +42,9 @@ parse_request(rb_helper *helper)
if(parc < 1) if(parc < 1)
continue; continue;
switch (parv[0][0]) handler = authd_cmd_handlers[parv[0][0]];
{ if (handler != NULL)
default: handler(parc, parv);
break;
}
} }
} }