summaryrefslogtreecommitdiff
path: root/sock_conn.h
blob: 55ef8e047613a3a18c79bc79365d51c77afe841e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 1024

/*
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