From 57689e698230030803c872072a03329fdd4fecc6 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Thu, 26 Jan 2006 18:40:30 +0000 Subject: unsigned char tidy up, query mode --- Makefile | 4 +- vchat-client.c | 54 +++++------ vchat-commands.c | 106 ++++++++++----------- vchat-config.h | 6 +- vchat-protocol.c | 140 +++++++++++++-------------- vchat-ui.c | 284 +++++++++++++++++++++++-------------------------------- vchat-user.c | 82 ++++++++-------- vchat.h | 124 ++++++++++++------------ 8 files changed, 374 insertions(+), 426 deletions(-) diff --git a/Makefile b/Makefile index 216f161..9e19425 100755 --- a/Makefile +++ b/Makefile @@ -14,6 +14,8 @@ CFLAGS = -Wall -Os CFLAGS += $(OLDREADLINE) +CFLAGS += -I../readline-5.0 -I../ncurses-5.4/include/ + ## you might need one or more of these: #CFLAGS += -I/usr/local/ssl/include -L/usr/local/ssl/lib #CFLAGS += -I/usr/local/include -L/usr/local/lib @@ -29,7 +31,7 @@ CFLAGS += $(OLDREADLINE) ## the install prefix best is /usr/local PREFIX=/usr/local -LIBS = -lreadline -lncurses -lssl -lcrypto +LIBS = ../readline-5.0/libreadline.a ../ncurses-5.4/lib/libncurses.a -lssl -lcrypto OBJS = vchat-client.o vchat-ui.o vchat-protocol.o vchat-user.o vchat-commands.o diff --git a/vchat-client.c b/vchat-client.c index d7d1998..2d50932 100755 --- a/vchat-client.c +++ b/vchat-client.c @@ -32,7 +32,7 @@ #include "vchat.h" /* version of this module */ -unsigned char *vchat_cl_version = "$Id$"; +char *vchat_cl_version = "$Id$"; /* externally used variables */ /* we're logged in */ @@ -40,7 +40,7 @@ unsigned int loggedin = 0; /* we run as long as this is true */ unsigned int status = 1; /* error string to show after exit */ -unsigned char errstr[ERRSTRSIZE] = "\0"; +char errstr[ERRSTRSIZE] = "\0"; /* locally global variables */ /* our list of filedescriptors */ @@ -52,12 +52,12 @@ static fd_set masterfds; /* servers filedescriptor from vchat-protocol.c */ extern int serverfd; -void setnoption (unsigned char *, unsigned char *); +void setnoption (char *, char *); -static void parsecfg(unsigned char *line) { +static void parsecfg(char *line) { int bytes; - unsigned char *param=line; - unsigned char *value=NULL; + char *param=line; + char *value=NULL; /* handle quotes value is empty, so wecan use it */ value = strchr(line,'#'); @@ -101,9 +101,9 @@ static void parsecfg(unsigned char *line) { setnoption(param,value); } -static void parseformats(unsigned char *line) { +static void parseformats(char *line) { int i; - unsigned char *tmp = NULL; + char *tmp = NULL; /* read a format line from file, syntax is FS_XXX = "formatstring" @@ -117,7 +117,7 @@ static void parseformats(unsigned char *line) { for (i = 0; formatstrings[i].formatstr; i++) if (!strncasecmp(formatstrings[i].idstring, line, strlen( formatstrings[i].idstring) )) { - unsigned char *tail = line + strlen( formatstrings[i].idstring); + char *tail = line + strlen( formatstrings[i].idstring); while( *tail==' ' || *tail=='\t') tail++; /* and skip whitespaces */ if( *tail++ == '=' ) @@ -145,7 +145,7 @@ static void parseformats(unsigned char *line) { } } - if ( stringends && ( (tmp = (unsigned char *)malloc( 1 + j )) != NULL ) ) + if ( stringends && ( (tmp = (char *)malloc( 1 + j )) != NULL ) ) { memcpy( tmp, tmpstr, k); tmp[k-1]=0; @@ -158,21 +158,21 @@ static void parseformats(unsigned char *line) { } /* UNUSED uncomment if needed -static void parseknownhosts(unsigned char *line) { +static void parseknownhosts(char *line) { } */ /* load config file */ static void -loadcfg (unsigned char *file,void (*lineparser) (unsigned char *)) +loadcfg (char *file,void (*lineparser) (char *)) { int fd; int bytes,bufoff=0; - unsigned char *tmp = NULL; + char *tmp = NULL; #define BUFSIZE 4096 - unsigned char buf[BUFSIZE]; /* data buffer */ - unsigned char *ltmp = buf; - unsigned char *tildex = NULL; + char buf[BUFSIZE]; /* data buffer */ + char *ltmp = buf; + char *tildex = NULL; buf[BUFSIZE-1] = '\0'; /* sanity stop */ if (!file) return; @@ -226,19 +226,19 @@ loadcfg (unsigned char *file,void (*lineparser) (unsigned char *)) } void -loadconfig (unsigned char *file) +loadconfig (char *file) { loadcfg(file,parsecfg); } void -loadformats (unsigned char *file) +loadformats (char *file) { loadcfg(file,parseformats); } /* get-format-string */ -unsigned char * +char * getformatstr (formtstr id) { int i; @@ -248,7 +248,7 @@ getformatstr (formtstr id) } /* get-string-option, fetches *char-value of variable named by option */ -unsigned char * +char * getstroption (confopt option) { int i; @@ -267,7 +267,7 @@ getstroption (confopt option) /* set-string-option, puts *char-value to variable named by option */ void -setstroption (confopt option, unsigned char *string) +setstroption (confopt option, char *string) { int i; #ifdef DEBUG @@ -288,7 +288,7 @@ setstroption (confopt option, unsigned char *string) /* set-named-option, puts string to variable named by name */ void -setnoption (unsigned char *name, unsigned char *string) +setnoption (char *name, char *string) { int i; #ifdef DEBUG @@ -450,8 +450,8 @@ eventloop (void) } } -void usage(unsigned char *name) { - printf ("usage: %s [-C config-file] [-F formats] [-l] [-z] [-s host] [-p port] [-c channel] [-n nickname] [-k] [-K] [-L logfile]\n",name); +void usage( char *name) { + printf ("usage: %s [-C config-file] [-F formats] [-l] [-z] [-s host] [-p port] [-c channel] [-n nickname]\n",name); puts (" -C load a second config-file, overriding the first one"); puts (" -F load format strings (skins) from this file"); puts (" -l local connect (no SSL + connects localhost:2323)"); @@ -464,9 +464,6 @@ void usage(unsigned char *name) { else puts (" -n set nickname"); printf (" -f set from (default \"%s\")\n",getstroption(CF_FROM)); - puts (" -k keep autolog"); - puts (" -K don't keep autolog"); - printf (" -L use this file as logfile (default \"%s\")\n",getstroption(CF_LOGFILE)); puts (" -h gives this help"); } @@ -502,9 +499,6 @@ main (int argc, char **argv) case 'c': setintoption(CF_CHANNEL,strtol(optarg,NULL,10)); break; case 'n': setstroption(CF_NICK,optarg); break; case 'f': setstroption(CF_FROM,optarg); break; - case 'k': setintoption(CF_KEEPLOG,1); break; - case 'K': setintoption(CF_KEEPLOG,0); break; - case 'L': setstroption(CF_LOGFILE,optarg); break; case 'h': usage(argv[0]); exit(0); break; default : usage(argv[0]); exit(1); } diff --git a/vchat-commands.c b/vchat-commands.c index 5f54733..5dc7b4f 100755 --- a/vchat-commands.c +++ b/vchat-commands.c @@ -25,7 +25,7 @@ #include "vchat-help.h" /* version of this module */ -unsigned char *vchat_cm_version = "$Id$"; +char *vchat_cm_version = "$Id$"; /* our "/command " table */ enum { @@ -38,29 +38,30 @@ COMMAND_HELP, COMMAND_KEYS, COMMAND_QUIT, COMMAND_USER, -COMMAND_LOG, COMMAND_FLT, COMMAND_PM, COMMAND_ACTION, COMMAND_PMSHORT, +COMMAND_QUERY, +COMMAND_QUITSHORT, COMMAND_PLAIN, COMMAND_NONE }; -static void command_quit ( unsigned char *tail); -static void command_user ( unsigned char *tail); -static void command_pm ( unsigned char *tail); -static void command_action ( unsigned char *tail); -static void command_help ( unsigned char *tail); -static void command_flt ( unsigned char *tail); -static void command_lsflt ( unsigned char *tail); -static void command_clflt ( unsigned char *tail); -static void command_rmflt ( unsigned char *tail); - void command_version ( unsigned char *tail); -static void command_none ( unsigned char *line); -static void command_log ( unsigned char *tail); +static void command_quit ( char *tail); +static void command_user ( char *tail); +static void command_pm ( char *tail); +static void command_action ( char *tail); +static void command_help ( char *tail); +static void command_flt ( char *tail); +static void command_lsflt ( char *tail); +static void command_clflt ( char *tail); +static void command_rmflt ( char *tail); + void command_version ( char *tail); +static void command_none ( char *line); +static void command_query ( char *tail); -static void output_default ( unsigned char *tail); +static void output_default ( char *tail); /* commandentry defined in vchat.h */ @@ -73,20 +74,21 @@ commandtable[] = { { COMMAND_HELP, "HELP", 4, command_help, SHORT_HELPTEXT_HELP, LONG_HELPTEXT_HELP }, { COMMAND_FILTERS, "FILTERS", 7, command_help, SHORT_HELPTEXT_FILTERS, LONG_HELPTEXT_FILTERS }, { COMMAND_KEYS, "KEYS", 4, command_help, SHORT_HELPTEXT_KEYS, LONG_HELPTEXT_KEYS }, +{ COMMAND_QUERY, "QUERY", 5, command_query, NULL, NULL }, { COMMAND_QUIT, "QUIT", 4, command_quit, SHORT_HELPTEXT_QUIT, LONG_HELPTEXT_QUIT }, { COMMAND_USER, "USER", 4, command_user, SHORT_HELPTEXT_USER, LONG_HELPTEXT_USER }, { COMMAND_FLT, "FLT", 3, command_flt, NULL, LONG_HELPTEXT_FLT }, -{ COMMAND_LOG, "LOG", 3, command_log, NULL, NULL }, { COMMAND_PM, "MSG", 3, command_pm, SHORT_HELPTEXT_MSG, LONG_HELPTEXT_MSG }, { COMMAND_ACTION, "ME", 2, command_action, SHORT_HELPTEXT_ME, LONG_HELPTEXT_ME }, { COMMAND_PMSHORT, "M", 1, command_pm, NULL, SHORT_HELPTEXT_MSG }, +{ COMMAND_QUITSHORT,"Q", 1, command_quit, SHORT_HELPTEXT_QUIT, LONG_HELPTEXT_QUIT }, { COMMAND_PLAIN, "/", 1, output_default, NULL, NULL }, { COMMAND_NONE, "", 0, command_none, NULL, NULL } }; /* parse "/command" */ static int -translatecommand( unsigned char **cmd) +translatecommand( char **cmd) { int result; int cut = 0; @@ -120,7 +122,7 @@ translatecommand( unsigned char **cmd) /* handle thought */ static void -dothink( unsigned char *tail, char nice ) +dothink( char *tail, char nice ) { while( *tail == ' ' ) tail++; @@ -136,7 +138,7 @@ dothink( unsigned char *tail, char nice ) /* handle action */ static void -doaction( unsigned char *tail ) +doaction( char *tail ) { while( *tail == ' ' ) tail++; @@ -156,8 +158,8 @@ doaction( unsigned char *tail ) /* handle private message outgoing */ static void -privatemessagetx ( unsigned char *tail ) { - unsigned char *mesg; +privatemessagetx ( char *tail ) { + char *mesg; /* find nick */ while( *tail==' ') tail++; @@ -191,7 +193,7 @@ privatemessagetx ( unsigned char *tail ) { /* handle line entered by user */ void -handleline (unsigned char *line) +handleline (char *line) { #ifdef DEBUG /* debugging? log users input! */ @@ -245,7 +247,7 @@ handleline (unsigned char *line) } static void -output_default( unsigned char *line ) { +output_default(char *line ) { /* prepare for output on display */ snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_TXPUBMSG), nick, line); @@ -258,11 +260,11 @@ output_default( unsigned char *line ) { /* handle a "/user " request */ static void -command_user( unsigned char *tail) +command_user(char *tail) { while( *tail == ' ') tail++; if( *tail ) { - unsigned char * out = ul_matchuser( tail); + char * out = ul_matchuser( tail); if( *out ) { snprintf( tmpstr, TMPSTRSIZE, getformatstr(FS_USMATCH), tail, out); } else { @@ -276,14 +278,14 @@ command_user( unsigned char *tail) /* handle a "/msg " request */ static void -command_pm (unsigned char *tail) +command_pm (char *tail) { privatemessagetx( tail ); } /* handle a help request */ static void -command_help (unsigned char *line) { +command_help (char *line) { flushout( ); while( *line==' ') line++; if( *line ) { /* Get help on command */ @@ -297,7 +299,7 @@ command_help (unsigned char *line) { line = commandtable[i].help; if( line ) { while( *line ) { - unsigned char *tmp = tmpstr; + char *tmp = tmpstr; while( *line && (*line != '\n') ) *tmp++ = *line++; *tmp = '\0'; if( *line == '\n') line++; @@ -319,15 +321,15 @@ command_help (unsigned char *line) { /* handle an unknown command */ static void -command_none( unsigned char *line) { +command_none(char *line) { snprintf(tmpstr, TMPSTRSIZE, " Unknown client command: %s ", line); msgout(tmpstr); } /* handle a "/flt " request */ static void -command_flt( unsigned char *tail){ - unsigned char colour; +command_flt(char *tail){ + char colour; while(*tail==' ') tail++; colour = *tail++; while( colour && *tail == ' ') tail++; @@ -338,34 +340,34 @@ command_flt( unsigned char *tail){ /* handle a "/clflt " request */ static void -command_clflt ( unsigned char *tail) { +command_clflt (char *tail) { while( *tail == ' ') tail++; clearfilters( *tail ); } /* handle a "/rmflt " request */ static void -command_rmflt ( unsigned char *tail) { +command_rmflt (char *tail) { while( *tail == ' ') tail++; removefilter( tail ); } /* list filters */ static void -command_lsflt ( unsigned char *tail) { +command_lsflt (char *tail) { listfilters(); } /* handle a "/me " action */ static void -command_action( unsigned char *tail) +command_action(char *tail) { doaction( tail); } /* handle a "/quit " exit */ static void -command_quit ( unsigned char *tail) +command_quit(char *tail) { /* send users message to server */ snprintf (tmpstr, TMPSTRSIZE, ".x %s", tail); @@ -377,7 +379,7 @@ command_quit ( unsigned char *tail) /* print out version */ void -command_version( unsigned char *tail) +command_version(char *tail) { /* output internal versions of all modules */ flushout(); @@ -389,24 +391,20 @@ command_version( unsigned char *tail) showout(); } -/* Undocumented feature */ +/* start or end a query */ void -command_log ( unsigned char *tail) +command_query(char *tail) { - /* log to file */ - FILE *logfile = NULL; - while( *tail == ' ' ) - tail++; - if( (logfile = fopen( tail, "w")) ) { - if( *tail == '_' ) { - writelog_i(logfile); - } else { - writelog(logfile); - } - fclose( logfile ); - msgout(" Log written. "); - } else { - snprintf(tmpstr, TMPSTRSIZE, " Can't open file: %s ", tail); - msgout(tmpstr); + char *msg; + while( *tail == ' ') tail++; + + // Check, if a message is to be sent in first query + // Note: this is safe, since readline chops trailing spaces + if((msg = strchr(tail, ' '))) { + privatemessagetx( tail ); + *msg = 0; } + + // Do the ui stuff for query + handlequery( tail ); } diff --git a/vchat-config.h b/vchat-config.h index 008a940..ce9c72d 100755 --- a/vchat-config.h +++ b/vchat-config.h @@ -23,8 +23,8 @@ #endif /* configuration array with structure as defined in vchat.h */ -extern int usessl; -extern int usetime; +extern unsigned int usessl; +extern unsigned int usetime; extern unsigned int hscroll; static volatile configoption configoptions[] = { @@ -38,7 +38,6 @@ static volatile configoption configoptions[] = { {CF_CERTFILE, CO_STR, "certfile", "~/.vchat/cert", NULL, { NULL } }, {CF_KEYFILE, CO_STR, "keyfile", "~/.vchat/key", NULL, { NULL } }, {CF_FORMFILE, CO_STR, "formatfile", "~/.vchat/formats", NULL, { NULL } }, - {CF_LOGFILE, CO_STR, "logfile", "~/.vchat/log", NULL, { NULL } }, {CF_ENCODING, CO_STR, "encoding", NULL, NULL, { .pstr = &encoding }}, {CF_USESSL, CO_INT, "usessl", (char *) 1, (char *)-1, { .pint = &usessl } }, {CF_USECERT, CO_INT, "usecert", (char *) 1, (char *)-1, { NULL } }, @@ -51,7 +50,6 @@ static volatile configoption configoptions[] = { {CF_SCROLLBACK, CO_INT, "scrollback", (char *) 8192, (char *)-1, { NULL } }, {CF_SCROLLBPRIVT,CO_INT, "privscrollt",(char *) 0, (char *)-1, { NULL } }, {CF_SCROLLBACKT, CO_INT, "scrolltime", (char *) 86400, (char *)-1, { NULL } }, - {CF_KEEPLOG, CO_INT, "keeplog", (char *) 0, (char *)-1, { NULL } }, {CF_BELLPRIV, CO_INT, "bellonpm", (char *) 0, (char *)-1, { NULL } }, {CF_NIL, CO_NIL, NULL, NULL, NULL, { NULL } }, }; 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 @@ #include "vchat.h" /* version of this module */ -unsigned char *vchat_io_version = "$Id$"; +char *vchat_io_version = "$Id$"; /* externally used variables */ int serverfd = -1; @@ -49,28 +49,28 @@ static SSL *sslconn = NULL; * but by the library. we use it to set the accepted list of ciphers */ 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); -static unsigned char *sslpubkey = NULL; /* servers public key extracted from X.509 certificate */ +static char *sslpubkey = NULL; /* servers public key extracted from X.509 certificate */ static int sslpubkeybits = 0; /* length of server public key */ /* declaration of local helper functions */ -static void usersignon (unsigned char *); -static void usersignoff (unsigned char *); -static void usernickchange (unsigned char *); -static void userjoin (unsigned char *); -static void userleave (unsigned char *); -static void receivenicks (unsigned char *message); -static void justloggedin (unsigned char *message); -static void nickerr (unsigned char *message); -static void login (unsigned char *message); -static void anonlogin (unsigned char *message); -static void topicinfo (unsigned char *message); -static void pubaction (unsigned char *message); -static void pubthoughts (unsigned char *message); -static void serverlogin (unsigned char *message); -static void idleprompt (unsigned char *message); -static void topicchange (unsigned char *message); -static void pmnotsent (unsigned char *message); -static int getportnum(unsigned char *port); +static void usersignon (char *); +static void usersignoff (char *); +static void usernickchange (char *); +static void userjoin (char *); +static void userleave (char *); +static void receivenicks (char *message); +static void justloggedin (char *message); +static void nickerr (char *message); +static void login (char *message); +static void anonlogin (char *message); +static void topicinfo (char *message); +static void pubaction (char *message); +static void pubthoughts (char *message); +static void serverlogin (char *message); +static void idleprompt (char *message); +static void topicchange (char *message); +static void pmnotsent (char *message); +static int getportnum (char *port); /* declaration of server message array */ #include "vchat-messages.h" @@ -80,21 +80,21 @@ static int getportnum(unsigned char *port); extern int status; int usessl = 1; -unsigned char *encoding; +char *encoding; /* connects to server */ int -vcconnect (unsigned char *server, unsigned char *port) +vcconnect (char *server, char *port) { /* used for tilde expansion of cert & key filenames */ - unsigned char *tildex = NULL; + char *tildex = NULL; /* buffer for X.509 subject of server certificate */ - unsigned char subjbuf[256]; + char subjbuf[256]; /* variables used to split the subject */ - unsigned char *subjv = NULL; - unsigned char *subjn = NULL; - unsigned char *subjc = NULL; - unsigned char *subjh = NULL; + char *subjv = NULL; + char *subjn = NULL; + char *subjc = NULL; + char *subjh = NULL; /* pointer to key in certificate */ EVP_PKEY *certpubkey = NULL; /* temporary result */ @@ -109,7 +109,7 @@ vcconnect (unsigned char *server, unsigned char *port) SSL_METHOD *sslmeth = NULL; /* pointer to tilde-expanded certificate/keyfile-names */ - unsigned char *certfile = NULL, *keyfile = NULL; + char *certfile = NULL, *keyfile = NULL; /* variable for verify return */ long verify; @@ -154,7 +154,7 @@ vcconnect (unsigned char *server, unsigned char *port) SSL_CTX_set_default_passwd_cb (sslctx, passprompt); /* set our list of accepted ciphers */ - ssl_create_cipher_list (sslctx->method, &(sslctx->cipher_list), &(sslctx->cipher_list_by_id), getstroption (CF_CIPHERSUITE)); + ssl_create_cipher_list (sslctx->method, &(sslctx->cipher_list), &(sslctx->cipher_list_by_id), (unsigned char*)getstroption (CF_CIPHERSUITE)); /* get name of certificate file */ certfile = getstroption (CF_CERTFILE); @@ -366,7 +366,7 @@ vcdisconnect () } /* lookup a port number by service string */ -static int getportnum (unsigned char *port) +static int getportnum (char *port) { char *endpt = NULL; struct servent *service = getservbyname(port, "tcp"); @@ -382,7 +382,7 @@ static int getportnum (unsigned char *port) /* handle a pm not sent error * format: 412 %s */ static void -pmnotsent (unsigned char *message) +pmnotsent (char *message) { while(*message && *message!=' ') message++; snprintf(tmpstr,TMPSTRSIZE,getformatstr(FS_ERR),message+1); @@ -395,9 +395,9 @@ pmnotsent (unsigned char *message) * vars: %s nick * %s action */ static void -pubaction (unsigned char *message) +pubaction (char *message) { - unsigned char *nick = NULL, *action = NULL; + char *nick = NULL, *action = NULL; nick = strchr (message, ' '); nick[0] = '\0'; nick++; @@ -415,9 +415,9 @@ pubaction (unsigned char *message) * vars: %s nick * %s thought */ static void -pubthoughts (unsigned char *message) +pubthoughts (char *message) { - unsigned char *nick = NULL, *thoughts = NULL; + char *nick = NULL, *thoughts = NULL; nick = strchr (message, ' '); nick[0] = '\0'; nick++; @@ -432,7 +432,7 @@ pubthoughts (unsigned char *message) /* parse and handle server logon */ static void -serverlogin (unsigned char *message) +serverlogin (char *message) { #ifndef NO_LOCALE int utf8=!strcmp(nl_langinfo(CODESET), "UTF-8"); @@ -444,9 +444,9 @@ serverlogin (unsigned char *message) * format: 305 * vars: %s message */ static void -idleprompt (unsigned char *message) +idleprompt (char *message) { - unsigned char *msg = NULL; + char *msg = NULL; msg = strchr (message, ' '); msg[0] = '\0'; msg++; @@ -460,9 +460,9 @@ idleprompt (unsigned char *message) * vars: %d chan - channel number * %s topic - topic */ static void -topicinfo (unsigned char *message) +topicinfo (char *message) { - unsigned char *channel = NULL, *topic = NULL; + char *channel = NULL, *topic = NULL; int tmpchan = 0; /* search start of channel number */ @@ -499,9 +499,9 @@ topicinfo (unsigned char *message) * vars: %s nick * %s topic */ static void -topicchange (unsigned char *message) +topicchange (char *message) { - unsigned char *nick = NULL, *topic = NULL; + char *nick = NULL, *topic = NULL; int len; /* search start of nickname */ @@ -537,9 +537,9 @@ topicchange (unsigned char *message) * vars: %s str1 - nick used to login * %s str2 - servers message */ static void -justloggedin (unsigned char *message) +justloggedin (char *message) { - unsigned char *str1 = NULL, *str2 = NULL; + char *str1 = NULL, *str2 = NULL; /* search start of nickname */ str1 = strchr (message, ' '); str1++; @@ -590,7 +590,7 @@ ownleave (int channel) /* this user changes his nick */ void -ownnickchange (unsigned char *newnick) +ownnickchange (char *newnick) { /* free old nick, store copy of new nick */ setstroption(CF_NICK,newnick); @@ -606,9 +606,9 @@ ownnickchange (unsigned char *newnick) * 415 %s * vars: %s - server message */ static void -nickerr (unsigned char *message) +nickerr (char *message) { - unsigned char *helpkiller = NULL; + char *helpkiller = NULL; /* mutate message for output */ message[2] = '!'; /* help information found? remove it. */ @@ -639,9 +639,9 @@ nickerr (unsigned char *message) * vars: %s - this users registered nick * %s msg - server message */ static void -login (unsigned char *message) +login (char *message) { - unsigned char *msg = NULL; + char *msg = NULL; /* mutate message for output */ message[2] = '*'; @@ -675,7 +675,7 @@ login (unsigned char *message) * format: 121 %s * vars: %s - server message */ static void -anonlogin (unsigned char *message) +anonlogin (char *message) { /* mutate message for output */ message[2] = '*'; @@ -695,11 +695,11 @@ anonlogin (unsigned char *message) * format: 119 %s .. * vars: %s nick - a users nick */ static void -receivenicks (unsigned char *message) +receivenicks (char *message) { - unsigned char *str1 = NULL, *str2 = NULL; + char *str1 = NULL, *str2 = NULL; int mychan = 0; - void (*ul_myfunc)(unsigned char*,int); + void (*ul_myfunc)(char*,int); /* show message to user */ snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_USONLINE), &message[4]); @@ -745,9 +745,9 @@ receivenicks (unsigned char *message) * vars: %s nick - who logged on * %s msg - servers message */ static void -usersignon (unsigned char *message) +usersignon (char *message) { - unsigned char *nick = NULL, *msg = NULL; + char *nick = NULL, *msg = NULL; /* search start of nickname */ nick = strchr (message, ' '); nick++; @@ -770,9 +770,9 @@ usersignon (unsigned char *message) * vars: %s nick - who logged off * %s msg - servers message */ static void -usersignoff (unsigned char *message) +usersignoff (char *message) { - unsigned char *nick = NULL, *msg = NULL; + char *nick = NULL, *msg = NULL; /* search start of nickname */ nick = strchr (message, ' '); nick++; @@ -796,9 +796,9 @@ usersignoff (unsigned char *message) * %s msg - servers message * %d chan - channel joined */ static void -userjoin (unsigned char *message) +userjoin (char *message) { - unsigned char *nick = NULL, *msg = NULL, *channel = NULL; + char *nick = NULL, *msg = NULL, *channel = NULL; int chan = 0; /* search start of nickname */ @@ -832,9 +832,9 @@ userjoin (unsigned char *message) * %s msg - servers message * %d chan - channel joined */ static void -userleave (unsigned char *message) +userleave (char *message) { - unsigned char *nick = NULL, *msg = NULL, *channel = NULL; + char *nick = NULL, *msg = NULL, *channel = NULL; int chan = 0; /* search start of nickname */ @@ -868,9 +868,9 @@ userleave (unsigned char *message) * %s newnick - users new nick * %s msg - server message */ static void -usernickchange (unsigned char *message) +usernickchange (char *message) { - unsigned char *oldnick = NULL, *newnick = NULL, *msg = NULL; + char *oldnick = NULL, *newnick = NULL, *msg = NULL; /* search start of old nickname */ oldnick = strchr (message, ' '); @@ -896,9 +896,9 @@ usernickchange (unsigned char *message) /* handle received message from server */ static void -parsemsg (unsigned char *message) +parsemsg (char *message) { - unsigned char *str1, *str2; + char *str1, *str2; int i; /* message to short or starts with '<'? must be channel */ if (message[0] == '<') @@ -1014,10 +1014,10 @@ void networkinput (void) { int bytes; - unsigned char *tmp = NULL; + char *tmp = NULL; #define BUFSIZE 4096 - unsigned char buf[BUFSIZE]; /* data buffer */ - unsigned char *ltmp = buf; + char buf[BUFSIZE]; /* data buffer */ + char *ltmp = buf; buf[BUFSIZE-1] = '\0'; /* sanity stop */ /* check if we use ssl or if we don't and receive data at offset */ @@ -1085,7 +1085,7 @@ networkinput (void) } void -networkoutput (unsigned char *msg) +networkoutput (char *msg) { #ifdef DEBUG /* debugging? log network output! */ diff --git a/vchat-ui.c b/vchat-ui.c index 9378e0d..bd1cbe0 100755 --- a/vchat-ui.c +++ b/vchat-ui.c @@ -30,13 +30,13 @@ #include "vchat.h" /* version of this module */ -unsigned char *vchat_ui_version = "$Id$"; +char *vchat_ui_version = "$Id$"; /* externally used variables */ /* current string in topic window */ -unsigned char topicstr[TOPICSTRSIZE] = "[] VChat 0.16"; +char topicstr[TOPICSTRSIZE] = "[] VChat 0.16"; /* current string in console window */ -unsigned char consolestr[CONSOLESTRSIZE] = "[ Get help: .h for server /h for client commands"; +char consolestr[CONSOLESTRSIZE] = "[ Get help: .h for server /h for client commands"; static unsigned int ui_init = 0; @@ -48,8 +48,6 @@ static WINDOW *channel = NULL; static WINDOW *private = NULL; static WINDOW *output = NULL; -static FILE *vchat_logfile = NULL; - /* our screen dimensions */ static int screensx = 0; static int screensy = 0; @@ -68,12 +66,13 @@ static int privheight_desired = 0; static int privwinhidden = 0; int usetime = 1; int outputcountdown = 0; +char *querypartner = NULL; struct sb_entry { int id; time_t when; int stamp; - unsigned char *what; + char *what; struct sb_entry *link; }; @@ -93,9 +92,9 @@ static int sb_win = 0; /* 0 for pub, 1 for priv */ /* struct to keep filter list */ struct filt { - unsigned char colour; + char colour; unsigned int id; - unsigned char *text; + char *text; regex_t regex; struct filt *next; }; @@ -119,7 +118,7 @@ static void resize_output (void); static int getsbeheight (struct sb_entry *entry, const int xwidth, int needstime ); static int getsbdataheight (struct sb_data *data, const int xwidth, int needstime ); /* CURRENTLY UNUSED -static void writecolorized (WINDOW *win, unsigned char *string); +static void writecolorized (WINDOW *win, char *string); */ enum { @@ -129,10 +128,20 @@ enum { RMFILTER_KEEPANDSTOP }; +/* */ +static void +togglequery() { + if( querypartner && private ) { + { struct sb_data *tmp = sb_pub; sb_pub = sb_priv; sb_priv = tmp; } + { WINDOW *tmp= private; private = channel; channel = tmp; } + } +} + /* readlines callback when a line is completed */ static void -linecomplete (unsigned char *line) +linecomplete (char *line) { + char *c; int i; /* send linefeed, return pointer, reset cursors */ @@ -157,6 +166,10 @@ linecomplete (unsigned char *line) handleline (line); free (line); + /* If in query mode, feed query prefix */ + if (( c = querypartner )) + while( *c ) rl_stuff_char( *c++ ); + /* wipe input line and reset cursor */ wmove (input, 0, 0); for (i = 0; i < input->_maxx; i++) @@ -212,8 +225,8 @@ userinput (void) } static int -calcdrawcus (unsigned char * const str) { - unsigned char *tmp = str; +calcdrawcus (char * const str) { + char *tmp = str; int zero = 0; while( *tmp && (*tmp!=' ') && (*tmp!='\n')) { if(*tmp==1) zero+=2; tmp++; } return (tmp - str) - zero; @@ -240,7 +253,7 @@ sb_clear ( struct sb_data **sb ) { }*/ static struct sb_entry* -sb_add (struct sb_data *sb, unsigned char *line, time_t when) { +sb_add (struct sb_data *sb, char *line, time_t when) { struct sb_entry *newone = malloc (sizeof(struct sb_entry)); if( newone ) { if( sb->count == sb->scroll ) sb->scroll++; @@ -282,7 +295,7 @@ void showout (void) resize(0); } -void writeout (unsigned char *str) +void writeout (char *str) { int i; sb_add(sb_out,str,time(NULL)); @@ -290,43 +303,47 @@ void writeout (unsigned char *str) if( i > outputwidth_desired ) outputwidth_desired = i; } -int writechan (unsigned char *str) { +int writechan (char *str) { struct sb_entry *tmp; int i = 0; time_t now = time(NULL); tmp = sb_add(sb_pub,str,now); - if( getintoption( CF_KEEPLOG ) && vchat_logfile ) - fprintf( vchat_logfile, "%016llX0%s\n", (signed long long)now, str); - if ( (sb_pub->scroll == sb_pub->count) && ((filtertype == 0) || ( testfilter(tmp)))) { i = writescr(channel, tmp); wnoutrefresh(channel); } - consoleline(NULL); + + if( querypartner && private ) + topicline(NULL); + else + consoleline(NULL); + return i; } -int writecf (formtstr id,unsigned char *str) { +int writecf (formtstr id, char *str) { struct sb_entry *tmp; int i = 0; time_t now = time(NULL); snprintf(tmpstr,TMPSTRSIZE,getformatstr(id),str); tmp = sb_add(sb_pub,tmpstr,now); - if( getintoption( CF_KEEPLOG ) && vchat_logfile ) - fprintf( vchat_logfile, "%016llX0%s\n", (unsigned long long)now, tmpstr); - if ( (sb_pub->scroll == sb_pub->count) && ((filtertype == 0) || ( testfilter(tmp)))) { i = writescr(channel, tmp); wnoutrefresh(channel); } - consoleline(NULL); + + if( querypartner && private ) + topicline(NULL); + else + consoleline(NULL); + return i; } -int writepriv (unsigned char *str, int maybeep) { +int writepriv (char *str, int maybeep) { int i = 0; if (private) { @@ -334,10 +351,6 @@ int writepriv (unsigned char *str, int maybeep) { struct sb_entry *tmp; tmp = sb_add(sb_priv,str,now); - if( getintoption( CF_KEEPLOG ) && vchat_logfile ) { - fprintf( vchat_logfile, "%016llX1%s\n", (unsigned long long)now, str); - } - if ( !privwinhidden && (sb_priv->scroll == sb_priv->count) && ((filtertype == 0) || ( testfilter(tmp)))) { i = writescr(private, tmp); @@ -350,7 +363,12 @@ int writepriv (unsigned char *str, int maybeep) { resize(0); } wnoutrefresh(private); - topicline(NULL); + + if( querypartner && private ) + consoleline(NULL); + else + topicline(NULL); + } else i = writechan( str ); @@ -388,13 +406,13 @@ static int attributes[] = { A_ALTCHARSET, A_BOLD, 0, A_DIM, 0, 0, 0, 0, A_INVIS, 0, 0, 1, 0, 0 }; static void -docolorize (unsigned char colour, ncurs_attr *attr, ncurs_attr orgattr) { +docolorize (char colour, ncurs_attr *attr, ncurs_attr orgattr) { if( colour== '0') { *attr = orgattr; } else if( ( colour > '0') && ( colour <= '9')) { BCOLR_SET( attr, colour - '0' ); } else { - unsigned char upc = colour & ( 0x20 ^ 0xff ); /* colour AND NOT 0x20 */ + char upc = colour & ( 0x20 ^ 0xff ); /* colour AND NOT 0x20 */ attr_t newattr; if( ( upc >= 'A') && ( upc<='Z' ) && ( newattr = attributes[upc - 'A']) ) attr->attr = ( colour & 0x20 ) ? attr->attr | newattr : attr->attr & ~newattr; @@ -404,13 +422,13 @@ docolorize (unsigned char colour, ncurs_attr *attr, ncurs_attr orgattr) { /* draw arbitrary strings */ static int writescr ( WINDOW *win, struct sb_entry *entry ) { - unsigned char tmp [64]; + char tmp [64]; int charcount = 0; int i; int textlen = strlen( entry->what ); int timelen = ((win == channel)||(win == private)) && usetime ? (int)strftime(tmp,64,getformatstr(FS_TIME),localtime(&entry->when)) : 0; - unsigned char textbuffer[ textlen+timelen+1 ]; + char textbuffer[ textlen+timelen+1 ]; ncurs_attr attrbuffer[ textlen+timelen+1 ]; ncurs_attr orgattr; @@ -446,9 +464,9 @@ writescr ( WINDOW *win, struct sb_entry *entry ) { /* hilite */ if((win == channel)||(win == private)) { /* do not higlight bars */ - filt *flt = filterlist; - unsigned char *instr = textbuffer; - regmatch_t match; + filt *flt = filterlist; + char *instr = textbuffer; + regmatch_t match; int j; while( flt ) { @@ -493,87 +511,6 @@ writescr ( WINDOW *win, struct sb_entry *entry ) { return charcount; } -static void -writelog_processentry ( FILE *file, struct sb_entry* entry ) -{ - char *outtmp; - int outoff = 0; - if( usetime ) { - outtmp = tmpstr+64; - strftime(outtmp,64,getformatstr(FS_TIME),localtime(&entry->when)); - while(*outtmp) - if( *outtmp > 1 ) - tmpstr[outoff++] = *(outtmp++); - else - if( *(++outtmp)) - outtmp++; - } - - outtmp = entry->what; - while(*outtmp) - while(*outtmp && ( outoff < TMPSTRSIZE-1) ) { - if( *outtmp > 1 ) - tmpstr[outoff++] = *(outtmp++); - else - if( *(++outtmp)) - outtmp++; - tmpstr[outoff]=0; outoff = 0; - fputs( tmpstr, file ); - } - - fputc( '\n', file); -} - -void -writelog_i ( FILE *file) -{ - if( !private ) { - writelog( file); - } else { - struct sb_entry *now1= sb_pub->last, *prev1 = NULL, *tmp; - struct sb_entry *now2= sb_priv->last, *prev2 = NULL; - fputs( "Interleaved messages:\n\n", file); - while( now1 || now2 ) { - int process; - if( now1 && now2 ) { - process = ( now1->when < now2->when ) ? 1 : 2; - } else { - process = now1 ? 1 : 2; - } - - if( process == 1 ) { - writelog_processentry( file, now1 ); - tmp = now1; now1 = (struct sb_entry*)((unsigned long)now1->link ^ (unsigned long)prev1); prev1 = tmp; - } else { - writelog_processentry( file, now2 ); - tmp = now2; now2 = (struct sb_entry*)((unsigned long)now2->link ^ (unsigned long)prev2); prev2 = tmp; - } - } - } -} - -void -writelog ( FILE *file ) -{ - if( sb_pub->last ) { - struct sb_entry *now = sb_pub->last, *prev = NULL, *tmp; - fputs( "Public messages:\n\n", file); - while( now ) { - writelog_processentry( file, now ); - tmp = now; now = (struct sb_entry*)((unsigned long)now->link ^ (unsigned long)prev); prev = tmp; - } - putc( '\n', file ); - } - if( private && sb_priv->last ) { - struct sb_entry *now = sb_priv->last, *prev = NULL, *tmp; - fputs( "Private messages:\n\n", file); - while( now ) { - writelog_processentry( file, now ); - tmp = now; now = (struct sb_entry*)((unsigned long)now->link ^ (unsigned long)prev); prev = tmp; - } - } -} - static void resize_output ( ) { @@ -587,7 +524,9 @@ resize_output ( ) } static void -doscroll( int up ) { +doscroll ( int up ) { + togglequery(); + { WINDOW *destwin = (sb_win && private) ? private : channel; struct sb_data *sb = (sb_win && private) ? sb_priv : sb_pub; struct sb_entry *now = sb->entries, *prev = NULL, *tmp; @@ -617,7 +556,14 @@ doscroll( int up ) { drawwin(destwin, sb); wnoutrefresh(destwin); - if( sb_win && private ) topicline(NULL); else consoleline(NULL); + + togglequery(); + + if( private && (destwin == channel) ) + topicline( NULL); + else + consoleline( NULL); + } } @@ -634,7 +580,7 @@ scrolldown (void) } void -scrollwin (vod) +scrollwin (void) { if (!sb_win && private && !privwinhidden) sb_win = 1; else sb_win = 0; @@ -643,7 +589,7 @@ scrollwin (vod) } void -growprivwin (vod) { +growprivwin (void) { if( private ) { if( privwinhidden) privwinhidden = 0; @@ -653,7 +599,7 @@ growprivwin (vod) { } } -void toggleprivwin (vod) { +void toggleprivwin (void) { if( outputshown ) { outputshown = 0; resize(0); @@ -674,7 +620,7 @@ void toggleprivwin (vod) { } void -shrinkprivwin (vod) { +shrinkprivwin (void) { if( private && !privwinhidden ) { if( --privheight_desired < 1) privheight_desired = 1; if( privheight_desired > screensy - 5) privheight_desired = screensy - 5; @@ -778,7 +724,7 @@ forceredraw (void) if(console) wclear(console); if(topic) wclear(topic); if(private) wclear(private); - if(channel) wclear( channel ); + if(channel) wclear(channel ); if(output) wclear(output); if(input) wclear(input); resize(0); @@ -828,6 +774,8 @@ resize (int signal) * Arrange windows on screen *****/ + togglequery(); + /* console and input are always there and always 1 line tall */ wresize(console,1,screensx); wresize(input,1,screensx); @@ -882,6 +830,8 @@ resize (int signal) if(private && !privwinhidden ) wnoutrefresh(private); + togglequery(); + /* Resize and draw our message window, render topic and console line */ if(outputshown) resize_output(); @@ -1277,34 +1227,6 @@ initui (void) showout( ); */ - if( getintoption( CF_KEEPLOG ) ) { - unsigned char *logfile = getstroption( CF_LOGFILE ); - if( logfile && *logfile ) { - if( *logfile == '~' ) - logfile = tilde_expand( logfile ); - vchat_logfile = fopen( logfile, "r+" ); - if( vchat_logfile ) { - time_t now; - long long now_; - char dst; - int lenstr; - while( !feof( vchat_logfile)) { - if( (fscanf( vchat_logfile, "%016llX%c", (unsigned long long*)&now_, &dst)) && - ((dst == '0') || (dst == '1'))) - { - now = (time_t)now_; - if(fgets(tmpstr, TMPSTRSIZE, vchat_logfile)) { - lenstr = strlen( tmpstr ); - tmpstr[lenstr-1] = '\0'; - sb_add( dst == '0' ? sb_pub : sb_priv, tmpstr, now); - } - } else - while( !feof( vchat_logfile) && ( fgetc( vchat_logfile ) != '\n')); - } - } - } - } - resize(0); } @@ -1314,7 +1236,7 @@ initui (void) Enable, when needed static void -writecolorized( WINDOW *win, unsigned char *string) { +writecolorized( WINDOW *win, char *string) { ncurs_attr old_att, new_att; int i; @@ -1333,12 +1255,14 @@ writecolorized( WINDOW *win, unsigned char *string) { /* render consoleline to screen */ void -consoleline (unsigned char *message) +consoleline (char *message) { /* clear console, set string (or default), redraw display */ int i; ncurs_attr old_att, new_att; + togglequery(); + memset( &new_att, 0, sizeof(new_att)); BCOLR_SET( (&new_att), 8 ); wmove (console, 0, 0); @@ -1370,13 +1294,15 @@ consoleline (unsigned char *message) redrawwin(output); wnoutrefresh(output); } + + togglequery(); wnoutrefresh(input); doupdate(); } /* render topicline to screen */ void -topicline (unsigned char *message) +topicline (char *message) { int i; ncurs_attr old_att, new_att; @@ -1384,6 +1310,8 @@ topicline (unsigned char *message) if( !topic ) return; + togglequery(); + memset( &new_att, 0, sizeof(new_att)); BCOLR_SET( (&new_att), 8 ); @@ -1409,6 +1337,8 @@ topicline (unsigned char *message) redrawwin(output); wnoutrefresh(output); } + + togglequery(); wnoutrefresh(input); doupdate(); } @@ -1421,8 +1351,6 @@ exitui (void) rl_callback_handler_remove (); endwin (); ui_init = 0; - if( vchat_logfile ) - fclose( vchat_logfile ); } } @@ -1465,7 +1393,7 @@ static void vcnredraw (void) { int i; - unsigned char *passbof="-*-*-*-*-*-*-"; + char *passbof="-*-*-*-*-*-*-"; /* wipe input line and reset cursor */ wmove(input, 0, 0); @@ -1486,7 +1414,7 @@ int passprompt (char *buf, int size, int rwflag, void *userdata) { int i; - unsigned char *passphrase = NULL; + char *passphrase = NULL; /* use special non-revealing redraw function */ /* FIXME: passphrase isn't protected against e.g. swapping */ @@ -1619,7 +1547,7 @@ clearfilters( char colour ) { /* removes filter pattern */ void -removefilter( unsigned char *tail ) { +removefilter( char *tail ) { int rmv = 0, val; char* end; @@ -1627,8 +1555,8 @@ removefilter( unsigned char *tail ) { rmv = removefromfilterlist( test_simplerm, (void *)tail, 0 ); if(!rmv) { - val = strtol((char*)tail, &end, 10); - if( (tail != (unsigned char*)end) && (!*end) ) + val = strtol(tail, &end, 10); + if( (tail != end) && (!*end) ) rmv = removefromfilterlist( test_numericrm, (void *)val, 0); } @@ -1646,7 +1574,7 @@ static unsigned int uniqueidpool = 1; /* returns unique id for filter pattern or 0 for failure */ unsigned int -addfilter( char colour, unsigned char *regex ) { +addfilter( char colour, char *regex ) { filt *newflt = malloc( sizeof(filt)), **flt = &filterlist; if( !newflt ) return 0; @@ -1753,3 +1681,31 @@ listfilters( void ) { } showout(); } + +void +handlequery( char *tail ) { + if( *tail ) { + // ".m %s " -> string + 4 + if( querypartner && private ) { + WINDOW *tmp= private; private = channel; channel = tmp; + } + querypartner = (char *)realloc( querypartner, 5 + strlen( tail )); + if( querypartner ) { + snprintf( querypartner, 5 + strlen( tail ), ".m %s ", tail ); + if( private ) { + WINDOW *tmp= private; private = channel; channel = tmp; + } + } + resize( 0 ); + } else { + // QUERY ends + if( querypartner ) { + free( querypartner ); + querypartner = NULL; + if( private ) { + WINDOW *tmp= private; private = channel; channel = tmp; + } + resize( 0 ); + } + } +} diff --git a/vchat-user.c b/vchat-user.c index 1e14112..65b32b7 100755 --- a/vchat-user.c +++ b/vchat-user.c @@ -26,20 +26,20 @@ struct user { - unsigned char *nick; /* nick of user */ - int chan; /* channel user is on */ - int chan_valid; /* are we sure he is? */ - int client_pv; /* client protocol version */ - int messaged; /* did we message with this user? */ - struct user *next; /* next user in linked list */ + char *nick; /* nick of user */ + int chan; /* channel user is on */ + int chan_valid; /* are we sure he is? */ + int client_pv; /* client protocol version */ + int messaged; /* did we message with this user? */ + struct user *next;/* next user in linked list */ }; /* version of this module */ -unsigned char *vchat_us_version = "$Id$"; +char *vchat_us_version = "$Id$"; /* externally used variables */ /* current nick */ -unsigned char *nick = NULL; +char *nick = NULL; /* current channel */ int chan = 0; /* userlist */ @@ -47,7 +47,7 @@ user *nicks = NULL; /* add user to userlist */ void -ul_add (unsigned char *name, int ignored) +ul_add (char *name, int ignored) { user *tmp = NULL; @@ -100,7 +100,7 @@ ul_add (unsigned char *name, int ignored) /* delete user from userlist */ void -ul_del (unsigned char *name, int ignored) +ul_del (char *name, int ignored) { user *tmp = NULL, *ltmp = NULL; @@ -143,7 +143,7 @@ ul_del (unsigned char *name, int ignored) /* let user join a channel */ void -ul_join (unsigned char *name, int channel) +ul_join (char *name, int channel) { /* is it this client? handle and return */ if (nick && !strcmp (nick, name)) @@ -157,7 +157,7 @@ ul_join (unsigned char *name, int channel) } user * -ul_finduser (unsigned char *name) { +ul_finduser (char *name) { user *tmp = nicks; snprintf( tmpstr, TMPSTRSIZE, "%s:", name); @@ -175,11 +175,11 @@ ul_finduser (unsigned char *name) { return NULL; } -unsigned char * -ul_matchuser( unsigned char *regex) { - user *tmp = nicks; - unsigned char *dest = tmpstr; - regex_t preg; +char * +ul_matchuser( char *regex) { + user *tmp = nicks; + char *dest = tmpstr; + regex_t preg; *dest = 0; if( !regcomp( &preg, regex, REG_ICASE | REG_EXTENDED | REG_NEWLINE)) { @@ -212,7 +212,7 @@ ul_usertofront( user *who ) { } void -ul_msgto (unsigned char *name) { +ul_msgto (char *name) { user *tmp = ul_finduser(name); if (tmp) { @@ -222,7 +222,7 @@ ul_msgto (unsigned char *name) { } void -ul_msgfrom (unsigned char *name) { +ul_msgfrom (char *name) { user *tmp = ul_finduser(name); if (tmp) { @@ -233,7 +233,7 @@ ul_msgfrom (unsigned char *name) { /* set channel of user */ void -ul_moveuser (unsigned char *name, int channel) { +ul_moveuser (char *name, int channel) { user *tmp = ul_finduser(name); if (tmp) { @@ -248,7 +248,7 @@ ul_moveuser (unsigned char *name, int channel) { /* let user leave a channel */ void -ul_leave (unsigned char *name, int channel) +ul_leave (char *name, int channel) { user *tmp = ul_finduser(name); /* is it this client? handle and return */ @@ -271,7 +271,7 @@ ul_leave (unsigned char *name, int channel) /* let user change nick */ void -ul_nickchange (unsigned char *oldnick, unsigned char *newnick) +ul_nickchange (char *oldnick, char *newnick) { user *tmp = ul_finduser(oldnick); /* is it this client? handle and return */ @@ -314,19 +314,19 @@ ul_clear (void) #endif } -int ulnc_casenick(user *tmp, const unsigned char *text, int len, int value) { +int ulnc_casenick(user *tmp, const char *text, int len, int value) { return (!strncmp(tmp->nick, text, len)); } -int ulnc_ncasenick(user *tmp, const unsigned char *text, int len, int value) { +int ulnc_ncasenick(user *tmp, const char *text, int len, int value) { return (!strncasecmp(tmp->nick, text, len)); } -unsigned char * -ulnc_complete (const unsigned char *text, int state, int value, int (*checkfn)(user *,const unsigned char *,int,int)) { - static int len; +char * +ulnc_complete (const char *text, int state, int value, int (*checkfn)(user *,const char *,int,int)) { + static int len; static user *tmp; - unsigned char *name; + char *name; /* first round? reset pointers! */ if (!state) @@ -355,11 +355,11 @@ ulnc_complete (const unsigned char *text, int state, int value, int (*checkfn)(u } /* nick completion functions for readline in vchat-ui.c */ -unsigned char * -ul_nickcomp (const unsigned char *text, int state) +char * +ul_nickcomp (const char *text, int state) { int ncasemode = 1; - unsigned char *name = NULL; + char *name = NULL; if (!state) ncasemode = 0; if (!ncasemode) { name = ulnc_complete(text,state,0,ulnc_casenick); @@ -373,20 +373,20 @@ ul_nickcomp (const unsigned char *text, int state) return NULL; } -int ulnc_casenickc(user *tmp, const unsigned char *text, int len, int value) { +int ulnc_casenickc(user *tmp, const char *text, int len, int value) { return (!strncmp(tmp->nick, text, len) && (tmp->chan_valid) && (tmp->chan == value)); } -int ulnc_ncasenickc(user *tmp, const unsigned char *text, int len, int value) { +int ulnc_ncasenickc(user *tmp, const char *text, int len, int value) { return (!strncasecmp(tmp->nick, text, len) && (tmp->chan_valid) && (tmp->chan == value)); } /* nick completion for channel, used by vchat-ui.c */ -unsigned char * -ul_cnickcomp (const unsigned char *text, int state) +char * +ul_cnickcomp (const char *text, int state) { int ncasemode = 1; - static unsigned char *name = NULL; + static char *name = NULL; if (!state) ncasemode = 0; if (!ncasemode) { @@ -402,20 +402,20 @@ ul_cnickcomp (const unsigned char *text, int state) return NULL; } -int ulnc_casenickm(user *tmp, const unsigned char *text, int len, int value) { +int ulnc_casenickm(user *tmp, const char *text, int len, int value) { return (!strncmp(tmp->nick, text, len) && (tmp->messaged)); } -int ulnc_ncasenickm(user *tmp, const unsigned char *text, int len, int value) { +int ulnc_ncasenickm(user *tmp, const char *text, int len, int value) { return (!strncasecmp(tmp->nick, text, len) && (tmp->messaged)); } /* nick completion for channel, used by vchat-ui.c */ -unsigned char * -ul_mnickcomp (const unsigned char *text, int state) +char * +ul_mnickcomp (const char *text, int state) { int ncasemode = 1; - static unsigned char *name = NULL; + static char *name = NULL; if (!state) ncasemode = 0; if (!ncasemode) { diff --git a/vchat.h b/vchat.h index 33c378b..60d485d 100755 --- a/vchat.h +++ b/vchat.h @@ -26,20 +26,20 @@ typedef enum { SM_IGNORE, SM_INFO, SM_USERINFO, SM_CHANNEL, SM_ERROR } smtype; /* servermessage structure */ struct servermessage { - unsigned char id[4]; /* three-character message id */ - smtype type; /* message type */ - void (*funct) (unsigned char *); /* function used by client */ - void (*hook) (unsigned char *); /* function hook for scripting */ + char id[4]; /* three-character message id */ + smtype type; /* message type */ + void (*funct) (char *); /* function used by client */ + void (*hook) (char *); /* function hook for scripting */ }; typedef struct servermessage servermessage; /* configuration types and variable numbers */ typedef enum { CO_NIL, CO_STR, CO_INT } conftype; typedef enum { CF_NIL, CF_NICK, CF_FROM, CF_SERVERHOST, CF_SERVERPORT, -CF_CIPHERSUITE, CF_CONFIGFILE, CF_CERTFILE, CF_KEYFILE, CF_FORMFILE, CF_LOGFILE, +CF_CIPHERSUITE, CF_CONFIGFILE, CF_CERTFILE, CF_KEYFILE, CF_FORMFILE, CF_USESSL, CF_USECERT, CF_PRIVHEIGHT, CF_HSCROLL, CF_CHANNEL, CF_USETIME, CF_USETOPIC, CF_SCROLLBPRIV, CF_SCROLLBACK, CF_SCROLLBPRIVT, CF_SCROLLBACKT, -CF_KEEPLOG, CF_ENCODING, CF_BELLPRIV } confopt; +CF_ENCODING, CF_BELLPRIV } confopt; /* format strings */ typedef enum { FS_PLAIN, FS_CHAN, FS_PRIV, FS_SERV, FS_GLOB, FS_DBG, FS_ERR, @@ -54,14 +54,14 @@ FS_SBINF, FS_MISSTYPED, FS_UNKNCMD, FS_BADREGEX, FS_ERR_STRING } formtstr; /* configoption structure */ struct configoption { - confopt id; + confopt id; conftype type; - unsigned char *varname; - unsigned char *defaultvalue; - unsigned char *value; + char *varname; + char *defaultvalue; + char *value; union { - unsigned char **pstr; - int *pint; + char **pstr; + unsigned int *pint; } localvar; }; @@ -71,74 +71,74 @@ typedef struct configoption configoption; struct formatstring { formtstr id; - unsigned char *idstring; - unsigned char *formatstr; + char *idstring; + char *formatstr; }; typedef struct formatstring formatstring; /* static tmpstr in all modules */ #define TMPSTRSIZE 1024 -static unsigned char tmpstr[TMPSTRSIZE]; +static char tmpstr[TMPSTRSIZE]; -extern unsigned char *nick; -extern int chan; +extern char *nick; +extern int chan; extern unsigned int loggedin; /* vchat-client.c */ #define ERRSTRSIZE 1024 -extern unsigned char errstr[]; -extern unsigned char *vchat_cl_version; +extern char errstr[]; +extern char *vchat_cl_version; void cleanup(int signal); /* configuration helper funktions from vchat-client.c */ -unsigned char *getformatstr (formtstr id); -unsigned char *getstroption (confopt option); -void setstroption (confopt option, unsigned char *string); +char *getformatstr (formtstr id); +char *getstroption (confopt option); +void setstroption (confopt option, char *string); int getintoption (confopt option); void setintoption (confopt option, int value); /* vchat-user.c */ -extern unsigned char *vchat_us_version; +extern char *vchat_us_version; /* add / delete user */ -void ul_add (unsigned char *nick, int ignored); -void ul_del (unsigned char *nick, int ignored); +void ul_add (char *nick, int ignored); +void ul_del (char *nick, int ignored); /* clear userlist */ void ul_clear (); /* channel join / leave */ -void ul_join (unsigned char *nick, int channel); -void ul_leave (unsigned char *nick, int channel); +void ul_join (char *nick, int channel); +void ul_leave (char *nick, int channel); /* nickchange */ -void ul_nickchange (unsigned char *oldnick, unsigned char *newnick); +void ul_nickchange (char *oldnick, char *newnick); /* place user in channel */ -void ul_moveuser (unsigned char *nick, int channel); +void ul_moveuser (char *nick, int channel); /* message nick completion */ -void ul_msgto (unsigned char *nick); -void ul_msgfrom (unsigned char *nick); +void ul_msgto (char *nick); +void ul_msgfrom (char *nick); /* nick-completion for vchat-ui.c */ -unsigned char *ul_nickcomp (const unsigned char *text, int state); -unsigned char *ul_cnickcomp (const unsigned char *text, int state); -unsigned char *ul_mnickcomp (const unsigned char *text, int state); +char *ul_nickcomp (const char *text, int state); +char *ul_cnickcomp (const char *text, int state); +char *ul_mnickcomp (const char *text, int state); /* try to find user by substring */ -unsigned char *ul_matchuser ( unsigned char *substr); +char *ul_matchuser (char *substr); /* vchat-ui.c */ -extern unsigned char *vchat_ui_version; +extern char *vchat_ui_version; /* topic and console strings */ #define TOPICSTRSIZE 1024 #define CONSOLESTRSIZE 1024 -extern unsigned char topicstr[]; -extern unsigned char consolestr[]; -extern unsigned char *encoding; +extern char topicstr[]; +extern char consolestr[]; +extern char *encoding; /* init / exit functions */ void initui (void); @@ -148,22 +148,20 @@ void exitui (void); void userinput (void); /* display various messages */ -int writechan (unsigned char *str); -int writepriv (unsigned char *str, int maybeep ); -void writeout (unsigned char *str); +int writechan (char *str); +int writepriv (char *str, int maybeep ); +void writeout (char *str); void showout (void); void flushout (void); #define msgout(STR) {flushout();writeout(STR);showout();} void hideout (void); -int writecf (formtstr id, unsigned char *str); -void writelog (FILE *file); -void writelog_i(FILE *file); +int writecf (formtstr id, char *str); extern int outputcountdown; /* update console / topic window */ -void consoleline (unsigned char *); -void topicline (unsigned char *); +void consoleline (char *); +void topicline (char *); /* prompt for nick or password */ void nickprompt (void); @@ -172,40 +170,42 @@ int passprompt (char *buf, int size, int rwflag, void *userdata); /* filter functions */ void refilterscrollback( void); -unsigned int addfilter ( char colour, unsigned char *regex ); -void removefilter ( unsigned char *line ); +unsigned int addfilter ( char colour, char *regex ); +void removefilter ( char *line ); void listfilters ( void ); void clearfilters ( char colour ); +void handlequery ( char *line ); + /* vchat-protocol.c */ -extern unsigned char *vchat_io_version; +extern char *vchat_io_version; /* connect/disconnect */ -int vcconnect (unsigned char *server, unsigned char *port); +int vcconnect (char *server, char *port); void vcdisconnect (); /* network I/O */ void networkinput (void); -void networkoutput (unsigned char *); +void networkoutput (char *); /* helpers for vchat-user.c */ void ownjoin (int channel); void ownleave (int channel); -void ownnickchange (unsigned char *newnick); +void ownnickchange (char *newnick); /* vchat-commands.c */ -extern unsigned char *vchat_cm_version; -void command_version ( unsigned char *tail); +extern char *vchat_cm_version; +void command_version ( char *tail); /* user input */ -void handleline (unsigned char *); +void handleline (char *); /* struct for defining "/command" handlers */ typedef struct { - int number; - unsigned char name[8]; - int len; - void (*handler)(unsigned char *); - unsigned char *short_help; - unsigned char *help; + int number; + char name[8]; + int len; + void (*handler)(char *); + char *short_help; + char *help; } commandentry; -- cgit v1.2.3