diff options
Diffstat (limited to 'vchat-protocol.c')
-rwxr-xr-x | vchat-protocol.c | 140 |
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 */ |
38 | unsigned char *vchat_io_version = "$Id$"; | 38 | char *vchat_io_version = "$Id$"; |
39 | 39 | ||
40 | /* externally used variables */ | 40 | /* externally used variables */ |
41 | int serverfd = -1; | 41 | int 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 */ |
50 | STACK_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); | 50 | STACK_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 | ||
52 | static unsigned char *sslpubkey = NULL; /* servers public key extracted from X.509 certificate */ | 52 | static char *sslpubkey = NULL; /* servers public key extracted from X.509 certificate */ |
53 | static int sslpubkeybits = 0; /* length of server public key */ | 53 | static int sslpubkeybits = 0; /* length of server public key */ |
54 | 54 | ||
55 | /* declaration of local helper functions */ | 55 | /* declaration of local helper functions */ |
56 | static void usersignon (unsigned char *); | 56 | static void usersignon (char *); |
57 | static void usersignoff (unsigned char *); | 57 | static void usersignoff (char *); |
58 | static void usernickchange (unsigned char *); | 58 | static void usernickchange (char *); |
59 | static void userjoin (unsigned char *); | 59 | static void userjoin (char *); |
60 | static void userleave (unsigned char *); | 60 | static void userleave (char *); |
61 | static void receivenicks (unsigned char *message); | 61 | static void receivenicks (char *message); |
62 | static void justloggedin (unsigned char *message); | 62 | static void justloggedin (char *message); |
63 | static void nickerr (unsigned char *message); | 63 | static void nickerr (char *message); |
64 | static void login (unsigned char *message); | 64 | static void login (char *message); |
65 | static void anonlogin (unsigned char *message); | 65 | static void anonlogin (char *message); |
66 | static void topicinfo (unsigned char *message); | 66 | static void topicinfo (char *message); |
67 | static void pubaction (unsigned char *message); | 67 | static void pubaction (char *message); |
68 | static void pubthoughts (unsigned char *message); | 68 | static void pubthoughts (char *message); |
69 | static void serverlogin (unsigned char *message); | 69 | static void serverlogin (char *message); |
70 | static void idleprompt (unsigned char *message); | 70 | static void idleprompt (char *message); |
71 | static void topicchange (unsigned char *message); | 71 | static void topicchange (char *message); |
72 | static void pmnotsent (unsigned char *message); | 72 | static void pmnotsent (char *message); |
73 | static int getportnum(unsigned char *port); | 73 | static 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); | |||
80 | extern int status; | 80 | extern int status; |
81 | 81 | ||
82 | int usessl = 1; | 82 | int usessl = 1; |
83 | unsigned char *encoding; | 83 | char *encoding; |
84 | 84 | ||
85 | /* connects to server */ | 85 | /* connects to server */ |
86 | int | 86 | int |
87 | vcconnect (unsigned char *server, unsigned char *port) | 87 | vcconnect (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 */ |
369 | static int getportnum (unsigned char *port) | 369 | static 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 */ |
384 | static void | 384 | static void |
385 | pmnotsent (unsigned char *message) | 385 | pmnotsent (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 */ |
397 | static void | 397 | static void |
398 | pubaction (unsigned char *message) | 398 | pubaction (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 */ |
417 | static void | 417 | static void |
418 | pubthoughts (unsigned char *message) | 418 | pubthoughts (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 */ |
434 | static void | 434 | static void |
435 | serverlogin (unsigned char *message) | 435 | serverlogin (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 */ |
446 | static void | 446 | static void |
447 | idleprompt (unsigned char *message) | 447 | idleprompt (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 */ |
462 | static void | 462 | static void |
463 | topicinfo (unsigned char *message) | 463 | topicinfo (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 */ |
501 | static void | 501 | static void |
502 | topicchange (unsigned char *message) | 502 | topicchange (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 */ |
539 | static void | 539 | static void |
540 | justloggedin (unsigned char *message) | 540 | justloggedin (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 */ |
592 | void | 592 | void |
593 | ownnickchange (unsigned char *newnick) | 593 | ownnickchange (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 */ |
608 | static void | 608 | static void |
609 | nickerr (unsigned char *message) | 609 | nickerr (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 */ |
641 | static void | 641 | static void |
642 | login (unsigned char *message) | 642 | login (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 */ |
677 | static void | 677 | static void |
678 | anonlogin (unsigned char *message) | 678 | anonlogin (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 */ |
697 | static void | 697 | static void |
698 | receivenicks (unsigned char *message) | 698 | receivenicks (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 */ |
747 | static void | 747 | static void |
748 | usersignon (unsigned char *message) | 748 | usersignon (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 */ |
772 | static void | 772 | static void |
773 | usersignoff (unsigned char *message) | 773 | usersignoff (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 */ |
798 | static void | 798 | static void |
799 | userjoin (unsigned char *message) | 799 | userjoin (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 */ |
834 | static void | 834 | static void |
835 | userleave (unsigned char *message) | 835 | userleave (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 */ |
870 | static void | 870 | static void |
871 | usernickchange (unsigned char *message) | 871 | usernickchange (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 */ |
898 | static void | 898 | static void |
899 | parsemsg (unsigned char *message) | 899 | parsemsg (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 | |||
1014 | networkinput (void) | 1014 | networkinput (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 | ||
1087 | void | 1087 | void |
1088 | networkoutput (unsigned char *msg) | 1088 | networkoutput (char *msg) |
1089 | { | 1089 | { |
1090 | #ifdef DEBUG | 1090 | #ifdef DEBUG |
1091 | /* debugging? log network output! */ | 1091 | /* debugging? log network output! */ |