comparison libnnchat.h @ 65:e763ef5cfd53

Move more functions to libnnchat.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 11 Nov 2008 23:57:49 +0200
parents 6a3a917303e4
children 3ab7751fdad1
comparison
equal deleted inserted replaced
64:6a3a917303e4 65:e763ef5cfd53
22 #include "th_string.h" 22 #include "th_string.h"
23 23
24 #define SET_BUFSIZE (4096) 24 #define SET_BUFSIZE (4096)
25 #define SET_ALLOC_SIZE (128) 25 #define SET_ALLOC_SIZE (128)
26 26
27 typedef struct {
28 char **data;
29 size_t n, size;
30 } ringbuf_t;
31
32 typedef struct {
33 ssize_t pos, len, size;
34 char *data;
35 } editbuf_t;
36
37
27 int openConnection(struct in_addr *addr, const int port); 38 int openConnection(struct in_addr *addr, const int port);
28 void closeConnection(const int sock); 39 void closeConnection(const int sock);
29 BOOL sendToSocket(const int sock, char *buf, const size_t bufLen); 40 BOOL sendToSocket(const int sock, char *buf, const size_t bufLen);
30 BOOL sendUserMsg(const int sock, const char *user, const char *fmt, ...); 41 BOOL sendUserMsg(const int sock, const char *user, const char *fmt, ...);
31 42
32 43
33 char *encodeStr1(const char *str); 44 char * encodeStr1(const char *str);
34 char *decodeStr1(const char *str); 45 char * decodeStr1(const char *str);
35 char *encodeStr2(const char *str); 46 char * encodeStr2(const char *str);
36 char *decodeStr2(const char *str); 47 char * decodeStr2(const char *str);
37 char *stripXMLTags(const char *str); 48 char * stripXMLTags(const char *str);
49
50
51 ringbuf_t * newRingBuf(const size_t size);
52 void freeRingBuf(ringbuf_t *buf);
53 void addRingBuf(ringbuf_t *buf, const char *str);
54
55 int writeBuf(editbuf_t *buf, ssize_t pos, int ch);
56 int insertBuf(editbuf_t *buf, ssize_t pos, int ch);
57 int deleteBuf(editbuf_t *buf, ssize_t pos);
58 void clearBuf(editbuf_t *buf);
59 editbuf_t * newBuf(ssize_t n);
60 void freeBuf(editbuf_t *buf);
61 editbuf_t * copyBuf(editbuf_t *src);
62 void setBufPos(editbuf_t *buf, ssize_t pos);
38 63
39 64
40 #endif 65 #endif