view libnnchat.h @ 77:e8c9d7d13866

Handle certain key sequences better.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 13 Dec 2008 11:19:19 +0200
parents 3a23c2adfb78
children 745f670068dc
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);


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