diff options
Diffstat (limited to 'agni.c')
-rw-r--r-- | agni.c | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -134,6 +134,33 @@ tble_cmd_resp* cllbk_wrapper( void *(*call)(void *), tble_cmd_param *param) } /* +convert irc ident to 3 newly alocated string +*/ +int irciedent_parse(char *ident, rpc_request *req) +{ + int count1, count2; + sds params1 = sdsnew(ident), params2; + sds *tokens1, *tokens2; + + tokens1 = sdssplitlen(params1, sdslen(params1), "!", 1, &count1); + + req->user = alloc_new_str(tokens1[0]); + + params2 = sdsnew(tokens1[1]); + tokens2 = sdssplitlen(params2, sdslen(params2), "@", 1, &count2); + + req->mask = alloc_new_str(tokens2[0]); + req->server = alloc_new_str(tokens2[1]); + + sdsfree(params1); + sdsfree(params2); + sdsfreesplitres(tokens1, count1); + sdsfreesplitres(tokens2, count2); + + return 0; +} + +/* return unique ID, with atomic counter should work in all cases */ _Atomic int _glbl_id=0; @@ -556,9 +583,7 @@ int th_start_client(void *data) } req = rpc_req_new(qcmd->cmd, qcmd->param, qcmd->cid); - req->user = alloc_new_str("U-ser"); - req->mask = alloc_new_str("M-ask"); - req->server = alloc_new_str("S-erver"); + irciedent_parse(qcmd->ircident, req); rpc_req_marsh(req, &nb_req); buf_nb = nb_create(nb_req); |