Mercurial > hg > nnchat
view libnnchat.h @ 78:745f670068dc
Add functions to simplify code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 18 Dec 2008 14:34:44 +0200 |
parents | 3a23c2adfb78 |
children | c2d916b340bf |
line wrap: on
line source
/* * NNChat - Custom chat client for NewbieNudes.com chatrooms * Written by Matti 'ccr' Hämäläinen * (C) Copyright 2008 Tecnic Software productions (TNSP) */ #ifndef LIBNNCHAT_H #define LIBNNCHAT_H #include <stdio.h> #include <unistd.h> #ifdef __WIN32 #include <windows.h> #include <winsock.h> #else #include <sys/socket.h> #include <arpa/inet.h> #include <netdb.h> #endif #include <sys/types.h> #include <errno.h> #include "th_string.h" #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 * doubleDecodeStr(const char *str); char * doubleEncodeStr(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