summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-02-25 00:52:06 +0000
committerFreeArtMan <dos21h@gmail.com>2017-02-25 00:52:06 +0000
commitfbf4aa43078f95d4ed3de0c9e897711bebf90eac (patch)
treef125fb51d27369eb9530809470ce0c7fe583eb2e
parent58493553ec4d0efaca1c1adddcdeb00e94e881bf (diff)
downloadagni-fbf4aa43078f95d4ed3de0c9e897711bebf90eac.tar.gz
agni-fbf4aa43078f95d4ed3de0c9e897711bebf90eac.zip
removed new string creation function to util file
-rw-r--r--Makefile6
-rw-r--r--agni.c21
-rw-r--r--tbl_qcmd.c32
3 files changed, 8 insertions, 51 deletions
diff --git a/Makefile b/Makefile
index 51cb80e..84e14c2 100644
--- a/Makefile
+++ b/Makefile
@@ -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:
diff --git a/agni.c b/agni.c
index c1ac68f..a2f14a4 100644
--- a/agni.c
+++ b/agni.c
@@ -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
diff --git a/tbl_qcmd.c b/tbl_qcmd.c
index 3d511b4..dea78e0 100644
--- a/tbl_qcmd.c
+++ b/tbl_qcmd.c
@@ -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