summaryrefslogtreecommitdiff
path: root/vchat-protocol.c
diff options
context:
space:
mode:
authorerdgeist <>2006-01-26 18:40:30 +0000
committererdgeist <>2006-01-26 18:40:30 +0000
commit57689e698230030803c872072a03329fdd4fecc6 (patch)
treeb4f8671dbe04741be93091e99eb3c6aa81b9bebd /vchat-protocol.c
parent4413fb15bec35744c06ac3cfce2ae2bfa6953ae1 (diff)
unsigned char tidy up, query mode
Diffstat (limited to 'vchat-protocol.c')
-rwxr-xr-xvchat-protocol.c140
1 files changed, 70 insertions, 70 deletions
diff --git a/vchat-protocol.c b/vchat-protocol.c
index 7c91638..5554796 100755
--- a/vchat-protocol.c
+++ b/vchat-protocol.c
@@ -35,7 +35,7 @@
35#include "vchat.h" 35#include "vchat.h"
36 36
37/* version of this module */ 37/* version of this module */
38unsigned char *vchat_io_version = "$Id$"; 38char *vchat_io_version = "$Id$";
39 39
40/* externally used variables */ 40/* externally used variables */
41int serverfd = -1; 41int serverfd = -1;
@@ -49,28 +49,28 @@ static SSL *sslconn = NULL;
49 * but by the library. we use it to set the accepted list of ciphers */ 49 * but by the library. we use it to set the accepted list of ciphers */
50STACK_OF(SSL_CIPHER) * ssl_create_cipher_list (const SSL_METHOD * meth, STACK_OF (SSL_CIPHER) ** pref, STACK_OF (SSL_CIPHER) ** sorted, const unsigned char *rule_str); 50STACK_OF(SSL_CIPHER) * ssl_create_cipher_list (const SSL_METHOD * meth, STACK_OF (SSL_CIPHER) ** pref, STACK_OF (SSL_CIPHER) ** sorted, const unsigned char *rule_str);
51 51
52static unsigned char *sslpubkey = NULL; /* servers public key extracted from X.509 certificate */ 52static char *sslpubkey = NULL; /* servers public key extracted from X.509 certificate */
53static int sslpubkeybits = 0; /* length of server public key */ 53static int sslpubkeybits = 0; /* length of server public key */
54 54
55/* declaration of local helper functions */ 55/* declaration of local helper functions */
56static void usersignon (unsigned char *); 56static void usersignon (char *);
57static void usersignoff (unsigned char *); 57static void usersignoff (char *);
58static void usernickchange (unsigned char *); 58static void usernickchange (char *);
59static void userjoin (unsigned char *); 59static void userjoin (char *);
60static void userleave (unsigned char *); 60static void userleave (char *);
61static void receivenicks (unsigned char *message); 61static void receivenicks (char *message);
62static void justloggedin (unsigned char *message); 62static void justloggedin (char *message);
63static void nickerr (unsigned char *message); 63static void nickerr (char *message);
64static void login (unsigned char *message); 64static void login (char *message);
65static void anonlogin (unsigned char *message); 65static void anonlogin (char *message);
66static void topicinfo (unsigned char *message); 66static void topicinfo (char *message);
67static void pubaction (unsigned char *message); 67static void pubaction (char *message);
68static void pubthoughts (unsigned char *message); 68static void pubthoughts (char *message);
69static void serverlogin (unsigned char *message); 69static void serverlogin (char *message);
70static void idleprompt (unsigned char *message); 70static void idleprompt (char *message);
71static void topicchange (unsigned char *message); 71static void topicchange (char *message);
72static void pmnotsent (unsigned char *message); 72static void pmnotsent (char *message);
73static int getportnum(unsigned char *port); 73static int getportnum (char *port);
74 74
75/* declaration of server message array */ 75/* declaration of server message array */
76#include "vchat-messages.h" 76#include "vchat-messages.h"
@@ -80,21 +80,21 @@ static int getportnum(unsigned char *port);
80extern int status; 80extern int status;
81 81
82int usessl = 1; 82int usessl = 1;
83unsigned char *encoding; 83char *encoding;
84 84
85/* connects to server */ 85/* connects to server */
86int 86int
87vcconnect (unsigned char *server, unsigned char *port) 87vcconnect (char *server, char *port)
88{ 88{
89 /* used for tilde expansion of cert & key filenames */ 89 /* used for tilde expansion of cert & key filenames */
90 unsigned char *tildex = NULL; 90 char *tildex = NULL;
91 /* buffer for X.509 subject of server certificate */ 91 /* buffer for X.509 subject of server certificate */
92 unsigned char subjbuf[256]; 92 char subjbuf[256];
93 /* variables used to split the subject */ 93 /* variables used to split the subject */
94 unsigned char *subjv = NULL; 94 char *subjv = NULL;
95 unsigned char *subjn = NULL; 95 char *subjn = NULL;
96 unsigned char *subjc = NULL; 96 char *subjc = NULL;
97 unsigned char *subjh = NULL; 97 char *subjh = NULL;
98 /* pointer to key in certificate */ 98 /* pointer to key in certificate */
99 EVP_PKEY *certpubkey = NULL; 99 EVP_PKEY *certpubkey = NULL;
100 /* temporary result */ 100 /* temporary result */
@@ -109,7 +109,7 @@ vcconnect (unsigned char *server, unsigned char *port)
109 SSL_METHOD *sslmeth = NULL; 109 SSL_METHOD *sslmeth = NULL;
110 110
111 /* pointer to tilde-expanded certificate/keyfile-names */ 111 /* pointer to tilde-expanded certificate/keyfile-names */
112 unsigned char *certfile = NULL, *keyfile = NULL; 112 char *certfile = NULL, *keyfile = NULL;
113 113
114 /* variable for verify return */ 114 /* variable for verify return */
115 long verify; 115 long verify;
@@ -154,7 +154,7 @@ vcconnect (unsigned char *server, unsigned char *port)
154 SSL_CTX_set_default_passwd_cb (sslctx, passprompt); 154 SSL_CTX_set_default_passwd_cb (sslctx, passprompt);
155 155
156 /* set our list of accepted ciphers */ 156 /* set our list of accepted ciphers */
157 ssl_create_cipher_list (sslctx->method, &(sslctx->cipher_list), &(sslctx->cipher_list_by_id), getstroption (CF_CIPHERSUITE)); 157 ssl_create_cipher_list (sslctx->method, &(sslctx->cipher_list), &(sslctx->cipher_list_by_id), (unsigned char*)getstroption (CF_CIPHERSUITE));
158 158
159 /* get name of certificate file */ 159 /* get name of certificate file */
160 certfile = getstroption (CF_CERTFILE); 160 certfile = getstroption (CF_CERTFILE);
@@ -366,7 +366,7 @@ vcdisconnect ()
366} 366}
367 367
368/* lookup a port number by service string */ 368/* lookup a port number by service string */
369static int getportnum (unsigned char *port) 369static int getportnum (char *port)
370{ 370{
371 char *endpt = NULL; 371 char *endpt = NULL;
372 struct servent *service = getservbyname(port, "tcp"); 372 struct servent *service = getservbyname(port, "tcp");
@@ -382,7 +382,7 @@ static int getportnum (unsigned char *port)
382/* handle a pm not sent error 382/* handle a pm not sent error
383 * format: 412 %s */ 383 * format: 412 %s */
384static void 384static void
385pmnotsent (unsigned char *message) 385pmnotsent (char *message)
386{ 386{
387 while(*message && *message!=' ') message++; 387 while(*message && *message!=' ') message++;
388 snprintf(tmpstr,TMPSTRSIZE,getformatstr(FS_ERR),message+1); 388 snprintf(tmpstr,TMPSTRSIZE,getformatstr(FS_ERR),message+1);
@@ -395,9 +395,9 @@ pmnotsent (unsigned char *message)
395 * vars: %s nick 395 * vars: %s nick
396 * %s action */ 396 * %s action */
397static void 397static void
398pubaction (unsigned char *message) 398pubaction (char *message)
399{ 399{
400 unsigned char *nick = NULL, *action = NULL; 400 char *nick = NULL, *action = NULL;
401 nick = strchr (message, ' '); 401 nick = strchr (message, ' ');
402 nick[0] = '\0'; 402 nick[0] = '\0';
403 nick++; 403 nick++;
@@ -415,9 +415,9 @@ pubaction (unsigned char *message)
415 * vars: %s nick 415 * vars: %s nick
416 * %s thought */ 416 * %s thought */
417static void 417static void
418pubthoughts (unsigned char *message) 418pubthoughts (char *message)
419{ 419{
420 unsigned char *nick = NULL, *thoughts = NULL; 420 char *nick = NULL, *thoughts = NULL;
421 nick = strchr (message, ' '); 421 nick = strchr (message, ' ');
422 nick[0] = '\0'; 422 nick[0] = '\0';
423 nick++; 423 nick++;
@@ -432,7 +432,7 @@ pubthoughts (unsigned char *message)
432 432
433/* parse and handle server logon */ 433/* parse and handle server logon */
434static void 434static void
435serverlogin (unsigned char *message) 435serverlogin (char *message)
436{ 436{
437#ifndef NO_LOCALE 437#ifndef NO_LOCALE
438 int utf8=!strcmp(nl_langinfo(CODESET), "UTF-8"); 438 int utf8=!strcmp(nl_langinfo(CODESET), "UTF-8");
@@ -444,9 +444,9 @@ serverlogin (unsigned char *message)
444 * format: 305 444 * format: 305
445 * vars: %s message */ 445 * vars: %s message */
446static void 446static void
447idleprompt (unsigned char *message) 447idleprompt (char *message)
448{ 448{
449 unsigned char *msg = NULL; 449 char *msg = NULL;
450 msg = strchr (message, ' '); 450 msg = strchr (message, ' ');
451 msg[0] = '\0'; 451 msg[0] = '\0';
452 msg++; 452 msg++;
@@ -460,9 +460,9 @@ idleprompt (unsigned char *message)
460 * vars: %d chan - channel number 460 * vars: %d chan - channel number
461 * %s topic - topic */ 461 * %s topic - topic */
462static void 462static void
463topicinfo (unsigned char *message) 463topicinfo (char *message)
464{ 464{
465 unsigned char *channel = NULL, *topic = NULL; 465 char *channel = NULL, *topic = NULL;
466 int tmpchan = 0; 466 int tmpchan = 0;
467 467
468 /* search start of channel number */ 468 /* search start of channel number */
@@ -499,9 +499,9 @@ topicinfo (unsigned char *message)
499 * vars: %s nick 499 * vars: %s nick
500 * %s topic */ 500 * %s topic */
501static void 501static void
502topicchange (unsigned char *message) 502topicchange (char *message)
503{ 503{
504 unsigned char *nick = NULL, *topic = NULL; 504 char *nick = NULL, *topic = NULL;
505 int len; 505 int len;
506 506
507 /* search start of nickname */ 507 /* search start of nickname */
@@ -537,9 +537,9 @@ topicchange (unsigned char *message)
537 * vars: %s str1 - nick used to login 537 * vars: %s str1 - nick used to login
538 * %s str2 - servers message */ 538 * %s str2 - servers message */
539static void 539static void
540justloggedin (unsigned char *message) 540justloggedin (char *message)
541{ 541{
542 unsigned char *str1 = NULL, *str2 = NULL; 542 char *str1 = NULL, *str2 = NULL;
543 /* search start of nickname */ 543 /* search start of nickname */
544 str1 = strchr (message, ' '); 544 str1 = strchr (message, ' ');
545 str1++; 545 str1++;
@@ -590,7 +590,7 @@ ownleave (int channel)
590 590
591/* this user changes his nick */ 591/* this user changes his nick */
592void 592void
593ownnickchange (unsigned char *newnick) 593ownnickchange (char *newnick)
594{ 594{
595 /* free old nick, store copy of new nick */ 595 /* free old nick, store copy of new nick */
596 setstroption(CF_NICK,newnick); 596 setstroption(CF_NICK,newnick);
@@ -606,9 +606,9 @@ ownnickchange (unsigned char *newnick)
606 * 415 %s 606 * 415 %s
607 * vars: %s - server message */ 607 * vars: %s - server message */
608static void 608static void
609nickerr (unsigned char *message) 609nickerr (char *message)
610{ 610{
611 unsigned char *helpkiller = NULL; 611 char *helpkiller = NULL;
612 /* mutate message for output */ 612 /* mutate message for output */
613 message[2] = '!'; 613 message[2] = '!';
614 /* help information found? remove it. */ 614 /* help information found? remove it. */
@@ -639,9 +639,9 @@ nickerr (unsigned char *message)
639 * vars: %s - this users registered nick 639 * vars: %s - this users registered nick
640 * %s msg - server message */ 640 * %s msg - server message */
641static void 641static void
642login (unsigned char *message) 642login (char *message)
643{ 643{
644 unsigned char *msg = NULL; 644 char *msg = NULL;
645 645
646 /* mutate message for output */ 646 /* mutate message for output */
647 message[2] = '*'; 647 message[2] = '*';
@@ -675,7 +675,7 @@ login (unsigned char *message)
675 * format: 121 %s 675 * format: 121 %s
676 * vars: %s - server message */ 676 * vars: %s - server message */
677static void 677static void
678anonlogin (unsigned char *message) 678anonlogin (char *message)
679{ 679{
680 /* mutate message for output */ 680 /* mutate message for output */
681 message[2] = '*'; 681 message[2] = '*';
@@ -695,11 +695,11 @@ anonlogin (unsigned char *message)
695 * format: 119 %s .. 695 * format: 119 %s ..
696 * vars: %s nick - a users nick */ 696 * vars: %s nick - a users nick */
697static void 697static void
698receivenicks (unsigned char *message) 698receivenicks (char *message)
699{ 699{
700 unsigned char *str1 = NULL, *str2 = NULL; 700 char *str1 = NULL, *str2 = NULL;
701 int mychan = 0; 701 int mychan = 0;
702 void (*ul_myfunc)(unsigned char*,int); 702 void (*ul_myfunc)(char*,int);
703 703
704 /* show message to user */ 704 /* show message to user */
705 snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_USONLINE), &message[4]); 705 snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_USONLINE), &message[4]);
@@ -745,9 +745,9 @@ receivenicks (unsigned char *message)
745 * vars: %s nick - who logged on 745 * vars: %s nick - who logged on
746 * %s msg - servers message */ 746 * %s msg - servers message */
747static void 747static void
748usersignon (unsigned char *message) 748usersignon (char *message)
749{ 749{
750 unsigned char *nick = NULL, *msg = NULL; 750 char *nick = NULL, *msg = NULL;
751 /* search start of nickname */ 751 /* search start of nickname */
752 nick = strchr (message, ' '); 752 nick = strchr (message, ' ');
753 nick++; 753 nick++;
@@ -770,9 +770,9 @@ usersignon (unsigned char *message)
770 * vars: %s nick - who logged off 770 * vars: %s nick - who logged off
771 * %s msg - servers message */ 771 * %s msg - servers message */
772static void 772static void
773usersignoff (unsigned char *message) 773usersignoff (char *message)
774{ 774{
775 unsigned char *nick = NULL, *msg = NULL; 775 char *nick = NULL, *msg = NULL;
776 /* search start of nickname */ 776 /* search start of nickname */
777 nick = strchr (message, ' '); 777 nick = strchr (message, ' ');
778 nick++; 778 nick++;
@@ -796,9 +796,9 @@ usersignoff (unsigned char *message)
796 * %s msg - servers message 796 * %s msg - servers message
797 * %d chan - channel joined */ 797 * %d chan - channel joined */
798static void 798static void
799userjoin (unsigned char *message) 799userjoin (char *message)
800{ 800{
801 unsigned char *nick = NULL, *msg = NULL, *channel = NULL; 801 char *nick = NULL, *msg = NULL, *channel = NULL;
802 int chan = 0; 802 int chan = 0;
803 803
804 /* search start of nickname */ 804 /* search start of nickname */
@@ -832,9 +832,9 @@ userjoin (unsigned char *message)
832 * %s msg - servers message 832 * %s msg - servers message
833 * %d chan - channel joined */ 833 * %d chan - channel joined */
834static void 834static void
835userleave (unsigned char *message) 835userleave (char *message)
836{ 836{
837 unsigned char *nick = NULL, *msg = NULL, *channel = NULL; 837 char *nick = NULL, *msg = NULL, *channel = NULL;
838 int chan = 0; 838 int chan = 0;
839 839
840 /* search start of nickname */ 840 /* search start of nickname */
@@ -868,9 +868,9 @@ userleave (unsigned char *message)
868 * %s newnick - users new nick 868 * %s newnick - users new nick
869 * %s msg - server message */ 869 * %s msg - server message */
870static void 870static void
871usernickchange (unsigned char *message) 871usernickchange (char *message)
872{ 872{
873 unsigned char *oldnick = NULL, *newnick = NULL, *msg = NULL; 873 char *oldnick = NULL, *newnick = NULL, *msg = NULL;
874 874
875 /* search start of old nickname */ 875 /* search start of old nickname */
876 oldnick = strchr (message, ' '); 876 oldnick = strchr (message, ' ');
@@ -896,9 +896,9 @@ usernickchange (unsigned char *message)
896 896
897/* handle received message from server */ 897/* handle received message from server */
898static void 898static void
899parsemsg (unsigned char *message) 899parsemsg (char *message)
900{ 900{
901 unsigned char *str1, *str2; 901 char *str1, *str2;
902 int i; 902 int i;
903 /* message to short or starts with '<'? must be channel */ 903 /* message to short or starts with '<'? must be channel */
904 if (message[0] == '<') 904 if (message[0] == '<')
@@ -1014,10 +1014,10 @@ void
1014networkinput (void) 1014networkinput (void)
1015{ 1015{
1016 int bytes; 1016 int bytes;
1017 unsigned char *tmp = NULL; 1017 char *tmp = NULL;
1018#define BUFSIZE 4096 1018#define BUFSIZE 4096
1019 unsigned char buf[BUFSIZE]; /* data buffer */ 1019 char buf[BUFSIZE]; /* data buffer */
1020 unsigned char *ltmp = buf; 1020 char *ltmp = buf;
1021 buf[BUFSIZE-1] = '\0'; /* sanity stop */ 1021 buf[BUFSIZE-1] = '\0'; /* sanity stop */
1022 1022
1023 /* check if we use ssl or if we don't and receive data at offset */ 1023 /* check if we use ssl or if we don't and receive data at offset */
@@ -1085,7 +1085,7 @@ networkinput (void)
1085} 1085}
1086 1086
1087void 1087void
1088networkoutput (unsigned char *msg) 1088networkoutput (char *msg)
1089{ 1089{
1090#ifdef DEBUG 1090#ifdef DEBUG
1091 /* debugging? log network output! */ 1091 /* debugging? log network output! */