summaryrefslogtreecommitdiff
path: root/sock_conn.h
diff options
context:
space:
mode:
Diffstat (limited to 'sock_conn.h')
-rw-r--r--sock_conn.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/sock_conn.h b/sock_conn.h
new file mode 100644
index 0000000..966a7f4
--- /dev/null
+++ b/sock_conn.h
@@ -0,0 +1,44 @@
+#ifndef __AGNI_SOCK_CONN_H
+#define __AGNI_SOCK_CONN_H
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <string.h>
+
+#include "util.h"
+
+#include "debug.h"
+
+#define IRC_BUF_IN_SIZE 1024*64
+#define IRC_BUF_OUT_SIZE 512
+
+/*
+Reads ins and spils out IRC lines ended with \r\n.
+*/
+//?what will happend if there is no string consumer?
+typedef struct irc_buf
+{
+ int out_size;
+ int max_out_size;
+ int in_size;
+ int max_in_size;
+ char *buf_in;
+ char *buf_out;
+ int ready;//if 1 there is one full line
+} irc_buf;
+
+irc_buf* irc_buf_create();
+//put string inside in reverse order =P
+int irc_buf_puts(irc_buf *ib, char *in_buf, int sz);
+int irc_buf_putc(irc_buf *ib, char c);
+int irc_buf_sz(irc_buf *ib);
+int irc_buf_ready(irc_buf *ib);
+char *irc_buf_line(irc_buf *ib);
+int irc_buf_destroy(irc_buf *ib);
+
+int irc_connect(char *hostname, char *port);
+
+
+#endif