Mercurial > hg > nnchat
diff 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 |
line wrap: on
line diff
--- a/libnnchat.h Tue Nov 11 22:33:35 2008 +0200 +++ b/libnnchat.h Tue Nov 11 23:57:49 2008 +0200 @@ -24,17 +24,42 @@ #define SET_BUFSIZE (4096) #define SET_ALLOC_SIZE (128) +typedef struct { + char **data; + size_t n, size; +} ringbuf_t; + +typedef struct { + ssize_t pos, len, size; + char *data; +} editbuf_t; + + int openConnection(struct in_addr *addr, const int port); void closeConnection(const int sock); BOOL sendToSocket(const int sock, char *buf, const size_t bufLen); BOOL sendUserMsg(const int sock, const char *user, const char *fmt, ...); -char *encodeStr1(const char *str); -char *decodeStr1(const char *str); -char *encodeStr2(const char *str); -char *decodeStr2(const char *str); -char *stripXMLTags(const char *str); +char * encodeStr1(const char *str); +char * decodeStr1(const char *str); +char * encodeStr2(const char *str); +char * decodeStr2(const char *str); +char * stripXMLTags(const char *str); + + +ringbuf_t * newRingBuf(const size_t size); +void freeRingBuf(ringbuf_t *buf); +void addRingBuf(ringbuf_t *buf, const char *str); + +int writeBuf(editbuf_t *buf, ssize_t pos, int ch); +int insertBuf(editbuf_t *buf, ssize_t pos, int ch); +int deleteBuf(editbuf_t *buf, ssize_t pos); +void clearBuf(editbuf_t *buf); +editbuf_t * newBuf(ssize_t n); +void freeBuf(editbuf_t *buf); +editbuf_t * copyBuf(editbuf_t *src); +void setBufPos(editbuf_t *buf, ssize_t pos); #endif