diff options
author | Haru <haru@dotalux.com> | 2016-01-07 03:41:22 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-02-24 20:57:34 +0100 |
commit | 9aa8a3b09ee2c491b55259ee433af7f39308ca37 (patch) | |
tree | f23571319dc25bdcb7efd56df9fc1eab6be32588 /src/map/irc-bot.c | |
parent | 931d716e1000b50a66b012815a412619d16fc957 (diff) | |
download | hercules-9aa8a3b09ee2c491b55259ee433af7f39308ca37.tar.gz hercules-9aa8a3b09ee2c491b55259ee433af7f39308ca37.tar.bz2 hercules-9aa8a3b09ee2c491b55259ee433af7f39308ca37.tar.xz hercules-9aa8a3b09ee2c491b55259ee433af7f39308ca37.zip |
Added const qualifier to several variable/argument pointers
- This is necessary for compatibility with a const RFIFOP.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/irc-bot.c')
-rw-r--r-- | src/map/irc-bot.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 3d8ec8b5d..fa4216f18 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -134,7 +134,7 @@ struct irc_func* irc_func_search(char* function_name) { * @see do_sockets */ int irc_parse(int fd) { - char *parse_string = NULL, *str_safe = NULL; + char *parse_string = NULL, *p = NULL, *str_safe = NULL; if (sockt->session[fd]->flag.eof) { sockt->close(fd); @@ -150,18 +150,19 @@ int irc_parse(int fd) { if( !RFIFOREST(fd) ) return 0; - parse_string = (char*)RFIFOP(fd,0); - parse_string[ RFIFOREST(fd) - 1 ] = '\0'; + parse_string = aMalloc(RFIFOREST(fd)); + safestrncpy(parse_string, (char*)RFIFOP(fd,0), RFIFOREST(fd)); + RFIFOSKIP(fd, RFIFOREST(fd)); + RFIFOFLUSH(fd); - parse_string = strtok_r(parse_string,"\r\n",&str_safe); + p = strtok_r(parse_string,"\r\n",&str_safe); - while (parse_string != NULL) { + while (p != NULL) { ircbot->parse_sub(fd,parse_string); - parse_string = strtok_r(NULL,"\r\n",&str_safe); + p = strtok_r(NULL,"\r\n",&str_safe); } + aFree(parse_string); - RFIFOSKIP(fd, RFIFOREST(fd)); - RFIFOFLUSH(fd); return 0; } |