authd: small cleanup

This commit is contained in:
Elizabeth Myers 2016-04-02 01:20:49 -05:00
parent 6a7bb6f1df
commit adfe7b8396

View file

@ -144,6 +144,17 @@ cid_to_client(uint32_t cid, bool delete)
return client_p; return client_p;
} }
static inline struct Client *
str_cid_to_client(const char *str, bool delete)
{
uint32_t cid = str_to_cid(str);
if(cid == 0)
return NULL;
return cid_to_client(cid, delete);
}
static void static void
parse_authd_reply(rb_helper * helper) parse_authd_reply(rb_helper * helper)
{ {
@ -151,7 +162,6 @@ parse_authd_reply(rb_helper * helper)
int parc; int parc;
char authdBuf[READBUF_SIZE]; char authdBuf[READBUF_SIZE];
char *parv[MAXPARA + 1]; char *parv[MAXPARA + 1];
uint32_t cid;
struct Client *client_p; struct Client *client_p;
while((len = rb_helper_read(helper, authdBuf, sizeof(authdBuf))) > 0) while((len = rb_helper_read(helper, authdBuf, sizeof(authdBuf))) > 0)
@ -168,11 +178,8 @@ parse_authd_reply(rb_helper * helper)
return; return;
} }
if((cid = str_to_cid(parv[1])) == 0)
return;
/* cid to uid (retrieve and delete) */ /* cid to uid (retrieve and delete) */
if((client_p = cid_to_client(cid, true)) == NULL) if((client_p = str_cid_to_client(parv[1], true)) == NULL)
return; return;
authd_accept_client(client_p, parv[2], parv[3]); authd_accept_client(client_p, parv[2], parv[3]);
@ -185,11 +192,8 @@ parse_authd_reply(rb_helper * helper)
return; return;
} }
if((cid = str_to_cid(parv[1])) == 0)
return;
/* cid to uid (retrieve and delete) */ /* cid to uid (retrieve and delete) */
if((client_p = cid_to_client(cid, true)) == NULL) if((client_p = str_cid_to_client(parv[1], true)) == NULL)
return; return;
authd_reject_client(client_p, parv[3], parv[4], toupper(*parv[2]), parv[5], parv[6]); authd_reject_client(client_p, parv[3], parv[4], toupper(*parv[2]), parv[5], parv[6]);
@ -202,11 +206,7 @@ parse_authd_reply(rb_helper * helper)
return; return;
} }
if((cid = str_to_cid(parv[1])) == 0) if((client_p = str_cid_to_client(parv[1], false)) == NULL)
return;
/* cid to uid */
if((client_p = cid_to_client(cid, false)) == NULL)
return; return;
sendto_one_notice(client_p, ":%s", parv[2]); sendto_one_notice(client_p, ":%s", parv[2]);
@ -218,6 +218,7 @@ parse_authd_reply(rb_helper * helper)
restart_authd(); restart_authd();
return; return;
} }
dns_results_callback(parv[1], parv[2], parv[3], parv[4]); dns_results_callback(parv[1], parv[2], parv[3], parv[4]);
break; break;
case 'W': /* Oper warning */ case 'W': /* Oper warning */