diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-03-18 20:30:06 +0000 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-03-18 20:30:06 +0000 |
commit | 0ae9dc3dfe4b1bd24a0d0385480d9ad7d07d0976 (patch) | |
tree | f51cbf81033fd9f87373c27c0c81d6b6c59396e9 /mq_cmd.c | |
parent | 39c0045fbb2f511484d5effb69c987906d0b52d8 (diff) | |
download | agni-0ae9dc3dfe4b1bd24a0d0385480d9ad7d07d0976.tar.gz agni-0ae9dc3dfe4b1bd24a0d0385480d9ad7d07d0976.zip |
Basic response from 2 command, works for privatemessages
Diffstat (limited to 'mq_cmd.c')
-rw-r--r-- | mq_cmd.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -23,7 +23,7 @@ mq_cmd* mq_cmd_create(int id, char *cmd, size_t cmd_sz, char *param, size_t para ENL(); return NULL; } - //memset(ret, 0, sizeof(mq_cmd)); + memset(ret, 0, sizeof(mq_cmd)); ret->id = id; ret->sz = MQ_CMD_MSG_SIZE; @@ -37,8 +37,17 @@ mq_cmd* mq_cmd_create(int id, char *cmd, size_t cmd_sz, char *param, size_t para } //if not null string that everything will blow up pal //cmd[cmd_sz-1] = 0x0; - //param[param_sz-1] = 0x0; - snprintf(ret->buf,ret->sz-1,":%d:%s: %s", id, cmd, param); + //param[param_sz-1] = 0x0; + char *t_cmd = malloc(cmd_sz+1); + memcpy(t_cmd, cmd, cmd_sz); + t_cmd[cmd_sz]=0; + char *t_param = malloc(param_sz+1); + memcpy(t_param, param, param_sz); + t_param[param_sz]=0; + snprintf(ret->buf,ret->sz-1,":%d:%s: %s", id, t_cmd, t_param); + + free(t_cmd); + free(t_param); return ret; } |