diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-02-25 00:52:06 +0000 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-02-25 00:52:06 +0000 |
commit | fbf4aa43078f95d4ed3de0c9e897711bebf90eac (patch) | |
tree | f125fb51d27369eb9530809470ce0c7fe583eb2e | |
parent | 58493553ec4d0efaca1c1adddcdeb00e94e881bf (diff) | |
download | agni-fbf4aa43078f95d4ed3de0c9e897711bebf90eac.tar.gz agni-fbf4aa43078f95d4ed3de0c9e897711bebf90eac.zip |
removed new string creation function to util file
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | agni.c | 21 | ||||
-rw-r--r-- | tbl_qcmd.c | 32 |
3 files changed, 8 insertions, 51 deletions
@@ -4,7 +4,11 @@ make: gcc darray.c -c gcc mq_cmd.c -c gcc tbl_qcmd.c -c - gcc tbl_qcmd.o mq_cmd.o buf.o mmm.o darray.o agni.c \ + gcc util.c -c + gcc sock_conn.c -c + gcc irc_parse.c -c + gcc tbl_qcmd.o mq_cmd.o buf.o mmm.o darray.o util.o sock_conn.o \ + irc_parse.o agni.c \ -o agni -std=c11 -lrt clean: @@ -23,6 +23,9 @@ #include "buf.h" #include "mq_cmd.h" #include "tbl_qcmd.h" +#include "util.h" +#include "sock_conn.h" +#include "irc_parse.h" /* no defence programming, no error checking, no argument checking just PoC @@ -31,24 +34,6 @@ nothing else #define MQ_MSG_SIZE 8192 -/* -return fd!=ifconnection there -*/ -int irc_connect( char *hostname, char *port ) -{ - int fd=0; - - struct addrinfo serv, *res; - - memset(&serv, 0, sizeof(serv)); - serv.ai_family = AF_INET; - serv.ai_socktype = SOCK_STREAM; - getaddrinfo(hostname, port, &serv, &res); - fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - connect(fd, res->ai_addr, res->ai_addrlen); - - return fd; -} /* return unique ID, with atomic counter should work in all cases @@ -273,35 +273,3 @@ int tbl_cmd_param_set(tble_cmd_param *cmd_param, tble_qcmd *cmd) return 0; } - - -char *alloc_new_str_s(char *str, size_t size) -{ - char *ret = NULL; - - if (str == NULL) - { - return NULL; - } - - //1MB is enought - if (size > (1024*1024)) - { - return NULL; - } - - ret = malloc(size); - if (ret == NULL) - { - return NULL; - } - - memcpy(ret, str, size); - - return ret; -} - -char *alloc_new_str(char *str) -{ - return alloc_new_str_s(str, strlen(str)); -}
\ No newline at end of file |