diff libnnchat.h @ 89:c2d916b340bf

Change some typedef names; Add struct for user list handling.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 06 May 2009 05:05:02 +0300
parents 745f670068dc
children 1e0bf7b4fd41
line wrap: on
line diff
--- a/libnnchat.h	Mon Apr 27 07:31:10 2009 +0300
+++ b/libnnchat.h	Wed May 06 05:05:02 2009 +0300
@@ -17,7 +17,7 @@
 #include <netdb.h>
 #endif
 #include <sys/types.h>
-
+#include <time.h>
 #include <errno.h>
 #include "th_string.h"
 
@@ -27,12 +27,17 @@
 typedef struct {
     char **data;
     size_t n, size;
-} ringbuf_t;
+} nn_ringbuf_t;
 
 typedef struct {
     ssize_t pos, len, size;
     char *data;
-} editbuf_t;
+} nn_editbuf_t;
+
+typedef struct {
+    char *name, *encname;
+    time_t lastspoke, joined;
+} nn_user_t;
 
 
 int         openConnection(struct in_addr *addr, const int port);
@@ -40,28 +45,31 @@
 BOOL        sendToSocket(const int sock, char *buf, const size_t bufLen);
 BOOL        sendUserMsg(const int sock, const char *user, const char *fmt, ...);
 
+int         addUser(nn_user_t **list, char *encname);
+int         freeUser(nn_user_t *);
+int         freeUserList(nn_user_t *);
 
 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);
+
+nn_ringbuf_t * newRingBuf(const size_t size);
+void        freeRingBuf(nn_ringbuf_t *buf);
+void        addRingBuf(nn_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);
+int         writeBuf(nn_editbuf_t *buf, ssize_t pos, int ch);
+int         insertBuf(nn_editbuf_t *buf, ssize_t pos, int ch);
+int         deleteBuf(nn_editbuf_t *buf, ssize_t pos);
+void        clearBuf(nn_editbuf_t *buf);
+nn_editbuf_t * newBuf(ssize_t n);
+void        freeBuf(nn_editbuf_t *buf);
+nn_editbuf_t * copyBuf(nn_editbuf_t *src);
+void        setBufPos(nn_editbuf_t *buf, ssize_t pos);
 
 
 #endif