Mercurial > hg > nnchat
annotate libnnchat.h @ 395:74d97581dc46
Rename variable and function, internal use only.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 24 May 2012 04:58:10 +0300 |
parents | cabf2233ea39 |
children | 07a46ca075ab |
rev | line source |
---|---|
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * NNChat - Custom chat client for NewbieNudes.com chatrooms |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Written by Matti 'ccr' Hämäläinen |
394 | 4 * (C) Copyright 2008-2012 Tecnic Software productions (TNSP) |
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 */ |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 #ifndef LIBNNCHAT_H |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 #define LIBNNCHAT_H |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 #include <unistd.h> |
365
88ac689d11bc
Win32/MinGW specific fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
360
diff
changeset
|
11 #include "th_types.h" |
64
6a3a917303e4
Some random cleanups, bring back WinSock support.
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
12 #ifdef __WIN32 |
68
3ab7751fdad1
MingW compatibility, with one ugly kludge.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
13 #include <windows.h> |
64
6a3a917303e4
Some random cleanups, bring back WinSock support.
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
14 #include <winsock.h> |
365
88ac689d11bc
Win32/MinGW specific fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
360
diff
changeset
|
15 typedef uint16_t in_port_t; |
88ac689d11bc
Win32/MinGW specific fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
360
diff
changeset
|
16 typedef uint32_t in_addr_t; |
64
6a3a917303e4
Some random cleanups, bring back WinSock support.
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
17 #else |
266 | 18 #include <sys/select.h> |
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 #include <sys/socket.h> |
217
7ba4e371e9a6
Add Makefile for OpenBSD, and specific #ifdef'd includes for the platform.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
20 #ifdef HAVE_NETINET_IN_H |
7ba4e371e9a6
Add Makefile for OpenBSD, and specific #ifdef'd includes for the platform.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
21 #include <netinet/in.h> |
7ba4e371e9a6
Add Makefile for OpenBSD, and specific #ifdef'd includes for the platform.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
22 #endif |
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 #include <arpa/inet.h> |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 #include <netdb.h> |
64
6a3a917303e4
Some random cleanups, bring back WinSock support.
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
25 #endif |
6a3a917303e4
Some random cleanups, bring back WinSock support.
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
26 #include <sys/types.h> |
89
c2d916b340bf
Change some typedef names; Add struct for user list handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
27 #include <time.h> |
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 #include <errno.h> |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 #include "th_string.h" |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
31 #define NN_TMPBUF_SIZE (4096) |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
32 #define NN_ALLOC_SIZE (128) |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
33 #define NN_CONNBUF_SIZE (64 * 1024) |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
34 #define NN_NUM_BUCKETS (256) |
224 | 35 #define NN_DELAY_USEC (15 * 1000) |
325
c086345d176b
Move some functions to libnnchat and rename nn_find_window to findWindow()
Matti Hamalainen <ccr@tnsp.org>
parents:
285
diff
changeset
|
36 #define NN_BACKBUF_LEN (512) /* Backbuffer size (in lines) */ |
102 | 37 |
390 | 38 enum |
39 { | |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
40 NN_CONN_UNINIT = 0, |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
41 NN_CONN_PROXY_NEG, |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
42 NN_CONN_OPEN, |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
43 NN_CONN_CLOSED |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
44 }; |
65
e763ef5cfd53
Move more functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
45 |
390 | 46 enum |
47 { | |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
48 NN_PROXY_NONE = 0, |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
49 NN_PROXY_SOCKS4, |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
50 NN_PROXY_SOCKS4A, |
390 | 51 |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
52 NN_PROXY_LAST |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
53 }; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
54 |
390 | 55 enum |
56 { | |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
57 SOCKS_CMD_CONNECT = 1, |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
58 SOCKS_CMD_BIND = 2 |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
59 }; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
60 |
390 | 61 struct nn_socks_t |
62 { | |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
63 uint8_t version; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
64 uint8_t command; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
65 in_port_t port; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
66 in_addr_t addr; |
373
ebbe97f2a2a5
Remove useless semicolons, fixes some pedantic warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
67 } __attribute__((__packed__)); |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
68 |
390 | 69 struct nn_socks_res_t |
70 { | |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
71 uint8_t nb; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
72 uint8_t result; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
73 in_port_t port; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
74 in_addr_t addr; |
373
ebbe97f2a2a5
Remove useless semicolons, fixes some pedantic warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
75 } __attribute__((__packed__)); |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
76 |
390 | 77 typedef struct _nn_conn_t |
78 { | |
79 struct | |
80 { | |
354
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
81 char *host; |
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
82 struct hostent *hst; |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
83 int type; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
84 int port; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
85 struct in_addr addr; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
86 } proxy; |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
87 |
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
88 char *host; |
354
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
89 struct hostent *hst; |
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
90 int port; |
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
91 |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
92 int socket; |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
93 struct in_addr addr; |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
94 fd_set sockfds; |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
95 |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
96 void (*errfunc)(struct _nn_conn_t *conn, const char *fmt, va_list ap); |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
97 void (*msgfunc)(struct _nn_conn_t *conn, const char *fmt, va_list ap); |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
98 |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
99 int err; |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
100 int status; |
390 | 101 |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
102 char buf[NN_CONNBUF_SIZE + 16]; |
395
74d97581dc46
Rename variable and function, internal use only.
Matti Hamalainen <ccr@tnsp.org>
parents:
394
diff
changeset
|
103 char *ptr, *in_ptr; |
393
318a71f4f57f
Rename some internal variables and add new buffer pointer one.
Matti Hamalainen <ccr@tnsp.org>
parents:
390
diff
changeset
|
104 ssize_t got_bytes, total_bytes; |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
105 } nn_conn_t; |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
106 |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
107 |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
108 const char *nn_get_errstr(int err); |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
109 BOOL nn_network_init(); |
97
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
110 void nn_network_close(void); |
90
1e0bf7b4fd41
Move socket error handling functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
89
diff
changeset
|
111 |
354
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
112 struct hostent *nn_resolve_host(nn_conn_t *conn, const char *name); |
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
113 nn_conn_t * nn_conn_new( |
390 | 114 void (*errfunc)(nn_conn_t *conn, const char *fmt, va_list ap), |
115 void (*msgfunc)(nn_conn_t *conn, const char *fmt, va_list ap)); | |
354
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
116 |
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
117 int nn_conn_set_proxy(nn_conn_t *conn, int type, int port, const char *host); |
c01e42fc9adb
More work on SOCKS proxy support, should work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
118 int nn_conn_open(nn_conn_t *conn, const int port, const char *host); |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
119 void nn_conn_close(nn_conn_t *); |
360
b465a17ffa47
Finally fix handling of long packets.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
120 void nn_conn_reset(nn_conn_t *); |
352
b54c8545dcb0
Overhaul network code a bit, add initial implementation of SOCKS4/4A proxy support -- which may not work yet, it is untested.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
121 int nn_conn_pull(nn_conn_t *); |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
122 BOOL nn_conn_send_buf(nn_conn_t *, const char *buf, const size_t len); |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
123 BOOL nn_conn_send_msg(nn_conn_t *, const char *user, const char *fmt, ...); |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
124 BOOL nn_conn_check(nn_conn_t *); |
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
125 |
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 |
390 | 127 typedef struct _nn_user_t |
128 { | |
330
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
129 char *name; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
130 time_t lastspoke, joined; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
131 struct _nn_user_t *next; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
132 } nn_user_t; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
133 |
390 | 134 typedef struct |
135 { | |
330
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
136 nn_user_t *buckets[NN_NUM_BUCKETS]; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
137 } nn_userhash_t; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
138 |
103
eaa524e153f9
Initial implementation of functions for implementing tab-completion for user names.
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
139 nn_userhash_t *nn_userhash_new(void); |
eaa524e153f9
Initial implementation of functions for implementing tab-completion for user names.
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
140 nn_user_t * nn_userhash_foreach(const nn_userhash_t *, int (*func)(const nn_user_t *)); |
116
741e45592522
Add simple "prediction" into tab-completion based on previously gotten last
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
141 nn_user_t * nn_user_match(const nn_userhash_t *list, const char *str, const char *current, BOOL again); |
106
c587a99e2096
Drop internal use and storage of encoded usernames.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
142 int nn_userhash_insert(nn_userhash_t *, const char *name); |
c587a99e2096
Drop internal use and storage of encoded usernames.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
143 int nn_userhash_delete(nn_userhash_t *, const char *name); |
103
eaa524e153f9
Initial implementation of functions for implementing tab-completion for user names.
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
144 void nn_userhash_free(nn_userhash_t *); |
eaa524e153f9
Initial implementation of functions for implementing tab-completion for user names.
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
145 void nn_user_free(nn_user_t *); |
102 | 146 void nn_user_free_list(nn_user_t *); |
147 nn_user_t * nn_user_copy(const nn_user_t *src); | |
106
c587a99e2096
Drop internal use and storage of encoded usernames.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
148 nn_user_t * nn_user_find(const nn_userhash_t *list, const char *name); |
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 |
168
2e4850ece456
Partially re-factor connection handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
150 |
97
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
151 char * nn_encode_str1(const char *str); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
152 char * nn_decode_str1(const char *str); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
153 char * nn_encode_str2(const char *str); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
154 char * nn_decode_str2(const char *str); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
155 char * nn_strip_tags(const char *str); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
156 char * nn_dbldecode_str(const char *str); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
157 char * nn_dblencode_str(const char *str); |
65
e763ef5cfd53
Move more functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
158 |
285
b765f15f9895
Move nn_username_{de,en}code() to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
159 char * nn_username_encode(char *str); |
b765f15f9895
Move nn_username_{de,en}code() to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
160 char * nn_username_decode(char *str); |
b765f15f9895
Move nn_username_{de,en}code() to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
161 |
89
c2d916b340bf
Change some typedef names; Add struct for user list handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
162 |
390 | 163 typedef struct |
164 { | |
330
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
165 ssize_t pos, len, size; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
166 char *data; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
167 } nn_editbuf_t; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
168 |
97
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
169 int nn_editbuf_write(nn_editbuf_t *buf, ssize_t pos, int ch); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
170 int nn_editbuf_insert(nn_editbuf_t *buf, ssize_t pos, int ch); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
171 int nn_editbuf_delete(nn_editbuf_t *buf, ssize_t pos); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
172 void nn_editbuf_clear(nn_editbuf_t *buf); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
173 nn_editbuf_t * nn_editbuf_new(ssize_t n); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
174 void nn_editbuf_free(nn_editbuf_t *buf); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
175 nn_editbuf_t * nn_editbuf_copy(nn_editbuf_t *src); |
218efd2f0641
Rename functions for clarity.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
176 void nn_editbuf_setpos(nn_editbuf_t *buf, ssize_t pos); |
103
eaa524e153f9
Initial implementation of functions for implementing tab-completion for user names.
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
177 char * nn_editbuf_get_string(nn_editbuf_t *buf, ssize_t start, ssize_t end); |
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 |
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
179 |
390 | 180 typedef struct |
181 { | |
330
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
182 qringbuf_t *data; /* "Backbuffer" data for this window */ |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
183 int pos; /* Current position in the window, 0 = real time */ |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
184 BOOL dirty; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
185 |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
186 char *id; /* Chatter ID, NULL = main window */ |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
187 int num; /* Window number */ |
390 | 188 |
330
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
189 char *buf; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
190 size_t len, bufsize; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
191 size_t chlen; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
192 } nn_window_t; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
193 |
325
c086345d176b
Move some functions to libnnchat and rename nn_find_window to findWindow()
Matti Hamalainen <ccr@tnsp.org>
parents:
285
diff
changeset
|
194 nn_window_t *nn_window_new(const char *); |
c086345d176b
Move some functions to libnnchat and rename nn_find_window to findWindow()
Matti Hamalainen <ccr@tnsp.org>
parents:
285
diff
changeset
|
195 void nn_window_free(nn_window_t *); |
c086345d176b
Move some functions to libnnchat and rename nn_find_window to findWindow()
Matti Hamalainen <ccr@tnsp.org>
parents:
285
diff
changeset
|
196 |
330
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
197 |
390 | 198 typedef struct |
199 { | |
330
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
200 size_t len; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
201 char *str; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
202 } nn_strtuple_t; |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
203 |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
204 |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
205 nn_strtuple_t *nn_strtuple_new(size_t, char *); |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
206 void nn_strtuple_free(nn_strtuple_t *); |
8e509d6546d3
Move nn_strtuple_* functions to libnnchat.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
207 |
62
ff5d74f0d428
Moved some functions to "libnnchat".
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
208 #endif |