Mercurial > hg > nnchat
view util.h @ 448:73ff0a592b2f
Remove some debug cruft from tab completion code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 26 May 2012 03:43:09 +0300 |
parents | 3396acd40147 |
children | 35d67bd0613b |
line wrap: on
line source
/* * NNChat - Custom chat client for NewbieNudes.com chatrooms * Written by Matti 'ccr' Hämäläinen * (C) Copyright 2008-2012 Tecnic Software productions (TNSP) */ #ifndef LIBNNUTIL_H #define LIBNNUTIL_H #include <stdio.h> #include <unistd.h> #include "th_types.h" #include "th_string.h" #define NN_TMPBUF_SIZE (4096) #define NN_ALLOC_SIZE (128) #define NN_NUM_BUCKETS (256) #define NN_BACKBUF_LEN (512) // Backbuffer size (in lines) typedef struct _nn_user_t { char *name; time_t lastspoke, joined; struct _nn_user_t *next; } nn_user_t; typedef struct { nn_user_t *buckets[NN_NUM_BUCKETS]; } nn_userhash_t; nn_userhash_t *nn_userhash_new(void); nn_user_t * nn_userhash_foreach(const nn_userhash_t *, int (*func)(const nn_user_t *)); nn_user_t * nn_userhash_match(const nn_userhash_t *list, const char *str, const char *current, BOOL again); int nn_userhash_insert(nn_userhash_t *, const char *name); int nn_userhash_delete(nn_userhash_t *, const char *name); void nn_userhash_free(nn_userhash_t *); nn_user_t * nn_userhash_find(const nn_userhash_t *list, const char *name); char * nn_encode_str1(const char *str); char * nn_decode_str1(const char *str); char * nn_encode_str2(const char *str); char * nn_decode_str2(const char *str); char * nn_strip_tags(const char *str); char * nn_dbldecode_str(const char *str); char * nn_dblencode_str(const char *str); char * nn_username_encode(char *str); char * nn_username_decode(char *str); typedef struct { size_t pos, len, size; char *data; } nn_editbuf_t; int nn_editbuf_write(nn_editbuf_t *buf, size_t pos, char ch); int nn_editbuf_insert(nn_editbuf_t *buf, size_t pos, char ch); int nn_editbuf_delete(nn_editbuf_t *buf, size_t pos); void nn_editbuf_clear(nn_editbuf_t *buf); nn_editbuf_t * nn_editbuf_new(size_t n); void nn_editbuf_free(nn_editbuf_t *buf); nn_editbuf_t * nn_editbuf_copy(nn_editbuf_t *src); void nn_editbuf_setpos(nn_editbuf_t *buf, size_t pos); char * nn_editbuf_get_string(nn_editbuf_t *buf, size_t start, size_t end); typedef struct { qringbuf_t *data; // "Backbuffer" data for this window int pos; // Current position in the window, 0 = real time BOOL dirty; char *id; // Chatter ID, NULL = main window int num; // Window number char *buf; size_t len, bufsize; size_t chlen; } nn_window_t; nn_window_t *nn_window_new(const char *); void nn_window_free(nn_window_t *); typedef struct { size_t len; char *str; } nn_strtuple_t; nn_strtuple_t *nn_strtuple_new(size_t, char *); void nn_strtuple_free(nn_strtuple_t *); #endif