summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xvchat-client.c40
-rwxr-xr-xvchat-config.h48
-rwxr-xr-xvchat-messages.h7
-rwxr-xr-xvchat-protocol.c15
-rwxr-xr-xvchat-ui.c6
-rwxr-xr-xvchat.h5
6 files changed, 77 insertions, 44 deletions
diff --git a/vchat-client.c b/vchat-client.c
index 2fc1ea9..a3e7fd2 100755
--- a/vchat-client.c
+++ b/vchat-client.c
@@ -26,6 +26,10 @@
26#include <signal.h> 26#include <signal.h>
27#include <readline/readline.h> 27#include <readline/readline.h>
28#include <openssl/ssl.h> 28#include <openssl/ssl.h>
29#ifndef NO_LOCALE
30#include <locale.h>
31#include <langinfo.h>
32#endif
29#include "vchat.h" 33#include "vchat.h"
30 34
31/* version of this module */ 35/* version of this module */
@@ -278,8 +282,8 @@ setstroption (confopt option, unsigned char *string)
278 configoptions[i].value = strdup(string); 282 configoptions[i].value = strdup(string);
279 else 283 else
280 configoptions[i].value = NULL; 284 configoptions[i].value = NULL;
281 if (configoptions[i].localvar) 285 if (configoptions[i].localvar.pstr)
282 *configoptions[i].localvar = configoptions[i].value; 286 *configoptions[i].localvar.pstr = configoptions[i].value;
283 } 287 }
284} 288}
285 289
@@ -294,17 +298,19 @@ setnoption (unsigned char *name, unsigned char *string)
294 for (i = 0; configoptions[i].type != CO_NIL; i++) 298 for (i = 0; configoptions[i].type != CO_NIL; i++)
295 if (!strcmp(configoptions[i].varname,name)) { 299 if (!strcmp(configoptions[i].varname,name)) {
296 if (configoptions[i].type == CO_STR) { 300 if (configoptions[i].type == CO_STR) {
297 if (configoptions[i].value) 301 if (configoptions[i].value)
298 free(configoptions[i].value); 302 free(configoptions[i].value);
299 if (string) 303 if (string)
300 configoptions[i].value = strdup(string); 304 configoptions[i].value = strdup(string);
301 else 305 else
302 configoptions[i].value = NULL; 306 configoptions[i].value = NULL;
303 } else if (configoptions[i].type == CO_INT) { 307 if (configoptions[i].localvar.pstr)
304 configoptions[i].value = (char *) atoi(string); 308 *configoptions[i].localvar.pstr = configoptions[i].value;
305 } 309 } else if (configoptions[i].type == CO_INT) {
306 if (configoptions[i].localvar) 310 configoptions[i].value = (char *) atoi(string);
307 *configoptions[i].localvar = configoptions[i].value; 311 if (configoptions[i].localvar.pint)
312 *configoptions[i].localvar.pint = (int)configoptions[i].value;
313 }
308 } 314 }
309} 315}
310 316
@@ -337,8 +343,8 @@ setintoption (confopt option, int value)
337 for (i = 0; configoptions[i].type != CO_NIL; i++) 343 for (i = 0; configoptions[i].type != CO_NIL; i++)
338 if ((configoptions[i].id == option) && (configoptions[i].type == CO_INT)) { 344 if ((configoptions[i].id == option) && (configoptions[i].type == CO_INT)) {
339 configoptions[i].value = (char *) value; 345 configoptions[i].value = (char *) value;
340 if (configoptions[i].localvar) 346 if (configoptions[i].localvar.pint)
341 *configoptions[i].localvar = configoptions[i].value; 347 *configoptions[i].localvar.pint = (int)configoptions[i].value;
342 } 348 }
343} 349}
344 350
@@ -472,6 +478,10 @@ main (int argc, char **argv)
472 int pchar; 478 int pchar;
473 int cmdsunparsed = 1; 479 int cmdsunparsed = 1;
474 480
481#ifndef NO_LOCALE
482 setlocale(LC_ALL,"");
483#endif
484
475 loadconfig (GLOBAL_CONFIG_FILE); 485 loadconfig (GLOBAL_CONFIG_FILE);
476 loadconfig (getstroption (CF_CONFIGFILE)); 486 loadconfig (getstroption (CF_CONFIGFILE));
477 487
diff --git a/vchat-config.h b/vchat-config.h
index beb4579..856b00c 100755
--- a/vchat-config.h
+++ b/vchat-config.h
@@ -29,30 +29,30 @@ extern unsigned int hscroll;
29 29
30static volatile configoption configoptions[] = { 30static volatile configoption configoptions[] = {
31/* config-option type name in file default value value localvar */ 31/* config-option type name in file default value value localvar */
32 {CF_NICK, CO_STR, "nick", NULL, NULL, &nick }, 32 {CF_NICK, CO_STR, "nick", NULL, NULL, { .pstr = &nick } },
33 {CF_FROM, CO_STR, "from", "vc-alpha-0.16", NULL, NULL }, 33 {CF_FROM, CO_STR, "from", "vc-alpha-0.16", NULL, { NULL } },
34 {CF_SERVERHOST, CO_STR, "host", "pulse.flatline.de",NULL, NULL }, 34 {CF_SERVERHOST, CO_STR, "host", "pulse.flatline.de",NULL, { NULL } },
35 {CF_SERVERPORT, CO_INT, "port", (char *) 2325, (char *)-1, NULL }, 35 {CF_SERVERPORT, CO_INT, "port", (char *) 2325, (char *)-1, { NULL } },
36 {CF_CIPHERSUITE, CO_STR, "ciphers", "HIGH:MEDIUM", NULL, NULL }, 36 {CF_CIPHERSUITE, CO_STR, "ciphers", "HIGH:MEDIUM", NULL, { NULL } },
37 {CF_CONFIGFILE, CO_STR, "conffile", "~/.vchat/config", NULL, NULL }, 37 {CF_CONFIGFILE, CO_STR, "conffile", "~/.vchat/config", NULL, { NULL } },
38 {CF_CERTFILE, CO_STR, "certfile", "~/.vchat/cert", NULL, NULL }, 38 {CF_CERTFILE, CO_STR, "certfile", "~/.vchat/cert", NULL, { NULL } },
39 {CF_KEYFILE, CO_STR, "keyfile", "~/.vchat/key", NULL, NULL }, 39 {CF_KEYFILE, CO_STR, "keyfile", "~/.vchat/key", NULL, { NULL } },
40 {CF_FORMFILE, CO_STR, "formatfile", "~/.vchat/formats", NULL, NULL }, 40 {CF_FORMFILE, CO_STR, "formatfile", "~/.vchat/formats", NULL, { NULL } },
41 {CF_LOGFILE, CO_STR, "logfile", "~/.vchat/log", NULL, NULL, }, 41 {CF_LOGFILE, CO_STR, "logfile", "~/.vchat/log", NULL, { NULL } },
42 {CF_ENCODING, CO_STR, "encoding", NULL, NULL, &encoding }, 42 {CF_ENCODING, CO_STR, "encoding", NULL, NULL, { .pstr = &encoding }},
43 {CF_USESSL, CO_INT, "usessl", (char *) 1, (char *)-1, (unsigned char **)&usessl }, 43 {CF_USESSL, CO_INT, "usessl", (char *) 1, (char *)-1, { .pint = &usessl } },
44 {CF_USECERT, CO_INT, "usecert", (char *) 1, (char *)-1, NULL }, 44 {CF_USECERT, CO_INT, "usecert", (char *) 1, (char *)-1, { NULL } },
45 {CF_USETIME, CO_INT, "usetime", (char *) 1, (char *)-1, (unsigned char **)&usetime }, 45 {CF_USETIME, CO_INT, "usetime", (char *) 1, (char *)-1, { .pint = &usetime } },
46 {CF_USETOPIC, CO_INT, "usetopicbar",(char *) 1, (char *)-1, NULL }, 46 {CF_USETOPIC, CO_INT, "usetopicbar",(char *) 1, (char *)-1, { NULL } },
47 {CF_PRIVHEIGHT, CO_INT, "messages", (char *) 0, (char *)-1, NULL }, 47 {CF_PRIVHEIGHT, CO_INT, "messages", (char *) 0, (char *)-1, { NULL } },
48 {CF_HSCROLL, CO_INT, "hscroll", (char *) 5, (char *)-1, (unsigned char **)&hscroll }, 48 {CF_HSCROLL, CO_INT, "hscroll", (char *) 5, (char *)-1, { .pint = &hscroll } },
49 {CF_CHANNEL, CO_INT, "channel", (char *) 0, (char *)-1, NULL }, 49 {CF_CHANNEL, CO_INT, "channel", (char *) 0, (char *)-1, { NULL } },
50 {CF_SCROLLBPRIV, CO_INT, "privscrollb",(char *) 2048, (char *)-1, NULL }, 50 {CF_SCROLLBPRIV, CO_INT, "privscrollb",(char *) 2048, (char *)-1, { NULL } },
51 {CF_SCROLLBACK, CO_INT, "scrollback", (char *) 8192, (char *)-1, NULL }, 51 {CF_SCROLLBACK, CO_INT, "scrollback", (char *) 8192, (char *)-1, { NULL } },
52 {CF_SCROLLBPRIVT,CO_INT, "privscrollt",(char *) 0, (char *)-1, NULL }, 52 {CF_SCROLLBPRIVT,CO_INT, "privscrollt",(char *) 0, (char *)-1, { NULL } },
53 {CF_SCROLLBACKT, CO_INT, "scrolltime", (char *) 86400, (char *)-1, NULL }, 53 {CF_SCROLLBACKT, CO_INT, "scrolltime", (char *) 86400, (char *)-1, { NULL } },
54 {CF_KEEPLOG, CO_INT, "keeplog", (char *) 0, (char *)-1, NULL }, 54 {CF_KEEPLOG, CO_INT, "keeplog", (char *) 0, (char *)-1, { NULL } },
55 {CF_NIL, CO_NIL, NULL, NULL, NULL, NULL }, 55 {CF_NIL, CO_NIL, NULL, NULL, NULL, { NULL } },
56}; 56};
57 57
58/* 58/*
diff --git a/vchat-messages.h b/vchat-messages.h
index 477d791..0902e88 100755
--- a/vchat-messages.h
+++ b/vchat-messages.h
@@ -64,7 +64,7 @@ servermessage servermessages[] = {
64 {"169", SM_INFO, NULL, NULL}, 64 {"169", SM_INFO, NULL, NULL},
65/* 201 <protocol> <server-name> 65/* 201 <protocol> <server-name>
66 Server signon */ 66 Server signon */
67 {"201", SM_IGNORE, NULL, NULL}, 67 {"201", SM_IGNORE, serverlogin, NULL},
68/* 211 <nickname> 68/* 211 <nickname>
69 User signon */ 69 User signon */
70 {"211", SM_USERINFO, usersignon, NULL}, 70 {"211", SM_USERINFO, usersignon, NULL},
@@ -83,6 +83,9 @@ servermessage servermessages[] = {
83/* 241 <oldnick> <newnick> 83/* 241 <oldnick> <newnick>
84 Nickname change */ 84 Nickname change */
85 {"241", SM_USERINFO, usernickchange, NULL}, 85 {"241", SM_USERINFO, usernickchange, NULL},
86/* 269 Encoding set to <encoding>
87 answer to .e */
88 {"269", SM_INFO, NULL, NULL},
86/* 120 <registered nick> */ 89/* 120 <registered nick> */
87 {"120", SM_INFO, login, NULL}, 90 {"120", SM_INFO, login, NULL},
88/* 121 You're not logged in */ 91/* 121 You're not logged in */
@@ -117,6 +120,8 @@ servermessage servermessages[] = {
117 {"414", SM_ERROR, NULL, NULL}, 120 {"414", SM_ERROR, NULL, NULL},
118/* 415 Nickname reserved */ 121/* 415 Nickname reserved */
119 {"415", SM_ERROR, nickerr, NULL}, 122 {"415", SM_ERROR, nickerr, NULL},
123/* 469 I'm very sorry, FNORD is not know to this system, try .E for a * list */
124 {"469", SM_ERROR, NULL, NULL},
120/* 501 Disconnected by own request */ 125/* 501 Disconnected by own request */
121 {"501", SM_INFO, NULL, NULL}, 126 {"501", SM_INFO, NULL, NULL},
122/* 502 Disconnected by operator */ 127/* 502 Disconnected by operator */
diff --git a/vchat-protocol.c b/vchat-protocol.c
index 5113365..f1e8b5c 100755
--- a/vchat-protocol.c
+++ b/vchat-protocol.c
@@ -26,6 +26,10 @@
26#include <readline/readline.h> 26#include <readline/readline.h>
27#include <openssl/ssl.h> 27#include <openssl/ssl.h>
28#include <openssl/err.h> 28#include <openssl/err.h>
29#ifndef NO_LOCALE
30#include <locale.h>
31#include <langinfo.h>
32#endif
29 33
30/* local includes */ 34/* local includes */
31#include "vchat.h" 35#include "vchat.h"
@@ -62,6 +66,7 @@ static void anonlogin (unsigned char *message);
62static void topicinfo (unsigned char *message); 66static void topicinfo (unsigned char *message);
63static void pubaction (unsigned char *message); 67static void pubaction (unsigned char *message);
64static void pubthoughts (unsigned char *message); 68static void pubthoughts (unsigned char *message);
69static void serverlogin (unsigned char *message);
65static void idleprompt (unsigned char *message); 70static void idleprompt (unsigned char *message);
66static void topicchange (unsigned char *message); 71static void topicchange (unsigned char *message);
67static void pmnotsent (unsigned char *message); 72static void pmnotsent (unsigned char *message);
@@ -408,6 +413,16 @@ pubthoughts (unsigned char *message)
408 writechan (tmpstr); 413 writechan (tmpstr);
409} 414}
410 415
416/* parse and handle server logon */
417static void
418serverlogin (unsigned char *message)
419{
420#ifndef NO_LOCALE
421 int utf8=!strcmp(nl_langinfo(CODESET), "UTF-8");
422 if (utf8)
423 networkoutput(".e utf8");
424#endif
425}
411/* parse and handle an idle message 426/* parse and handle an idle message
412 * format: 305 427 * format: 305
413 * vars: %s message */ 428 * vars: %s message */
diff --git a/vchat-ui.c b/vchat-ui.c
index e2b68d1..ef6561e 100755
--- a/vchat-ui.c
+++ b/vchat-ui.c
@@ -1539,14 +1539,14 @@ clearfilters( char colour ) {
1539void 1539void
1540removefilter( unsigned char *tail ) { 1540removefilter( unsigned char *tail ) {
1541 int rmv = 0, val; 1541 int rmv = 0, val;
1542 unsigned char* end; 1542 char* end;
1543 1543
1544 flushout( ); 1544 flushout( );
1545 1545
1546 rmv = removefromfilterlist( test_simplerm, (void *)tail, 0 ); 1546 rmv = removefromfilterlist( test_simplerm, (void *)tail, 0 );
1547 if(!rmv) { 1547 if(!rmv) {
1548 val = strtol((char*)tail, (char **)&end, 10); 1548 val = strtol((char*)tail, &end, 10);
1549 if( (tail != end) && (!*end) ) 1549 if( (tail != (unsigned char*)end) && (!*end) )
1550 rmv = removefromfilterlist( test_numericrm, (void *)val, 0); 1550 rmv = removefromfilterlist( test_numericrm, (void *)val, 0);
1551 } 1551 }
1552 1552
diff --git a/vchat.h b/vchat.h
index 64788b9..ec5da02 100755
--- a/vchat.h
+++ b/vchat.h
@@ -59,7 +59,10 @@ struct configoption
59 unsigned char *varname; 59 unsigned char *varname;
60 unsigned char *defaultvalue; 60 unsigned char *defaultvalue;
61 unsigned char *value; 61 unsigned char *value;
62 unsigned char **localvar; 62 union {
63 unsigned char **pstr;
64 int *pint;
65 } localvar;
63}; 66};
64 67
65typedef struct configoption configoption; 68typedef struct configoption configoption;