diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-01-10 22:35:08 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2006-01-10 22:35:08 +0100 |
commit | 8e419cb4f86679636b2d96618e1bec4853636c11 (patch) | |
tree | b7514f0bd06ce2a1f5290c53552c692698091d2b | |
parent | 3e91c3ec7d6426c4c2819e78275f935e1a7fce2c (diff) | |
parent | dd8d4c5243eea91dd3b0709ae76abdd3743e99bc (diff) |
Merge Wilmer
42 files changed, 1346 insertions, 949 deletions
@@ -9,7 +9,7 @@ -include Makefile.settings # Program variables -objects = account.o bitlbee.o commands.o crypting.o help.o ini.o irc.o nick.o query.o set.o url.o user.o storage_text.o storage.o +objects = account.o bitlbee.o commands.o crypting.o help.o ini.o irc.o nick.o query.o set.o storage.o storage_text.o url.o user.o util.o subdirs = protocols ifeq ($(ARCH),Windows) @@ -36,12 +36,34 @@ gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpoi { size_t size = sizeof( struct sockaddr_in ); struct sockaddr_in conn_info; - int new_socket = accept( global.listen_socket, (struct sockaddr *) &conn_info, - &size ); + int new_socket = accept( global.listen_socket, (struct sockaddr *) &conn_info, &size ); + pid_t client_pid = 0; + + if( global.conf->runmode == RUNMODE_FORKDAEMON ) + client_pid = fork(); + + if( client_pid == 0 ) + { + log_message( LOGLVL_INFO, "Creating new connection with fd %d.", new_socket ); + irc_new( new_socket ); + + if( global.conf->runmode == RUNMODE_FORKDAEMON ) + { + /* Close the listening socket, we're a client. */ + close( global.listen_socket ); + g_source_remove( global.listen_watch_source_id ); + } + } + else + { + /* We don't need this one, only the client does. */ + close( new_socket ); + + /* Or maybe we didn't even get a child process... */ + if( client_pid == -1 ) + log_message( LOGLVL_ERROR, "Failed to fork() subprocess for client: %s", strerror( errno ) ); + } - log_message( LOGLVL_INFO, "Creating new connection with fd %d.", new_socket ); - irc_new( new_socket ); - return TRUE; } @@ -49,37 +71,57 @@ gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpoi int bitlbee_daemon_init() { +#ifdef IPV6 + struct sockaddr_in6 listen_addr; +#else struct sockaddr_in listen_addr; +#endif int i; GIOChannel *ch; - global.listen_socket = socket( AF_INET, SOCK_STREAM, 0 ); + log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG ); + log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG ); + + global.listen_socket = socket( AF_INETx, SOCK_STREAM, 0 ); if( global.listen_socket == -1 ) { log_error( "socket" ); return( -1 ); } - listen_addr.sin_family = AF_INET; + +#ifdef IPV6 + listen_addr.sin6_family = AF_INETx; + listen_addr.sin6_port = htons( global.conf->port ); + i = inet_pton( AF_INETx, ipv6_wrap( global.conf->iface ), &listen_addr.sin6_addr ); +#else + listen_addr.sin_family = AF_INETx; listen_addr.sin_port = htons( global.conf->port ); - listen_addr.sin_addr.s_addr = inet_addr( global.conf->iface ); - - i = bind( global.listen_socket, (struct sockaddr *) &listen_addr, sizeof( struct sockaddr ) ); + i = inet_pton( AF_INETx, global.conf->iface, &listen_addr.sin_addr ); +#endif + + if( i != 1 ) + { + log_message( LOGLVL_ERROR, "Couldn't parse address `%s'", global.conf->iface ); + return( -1 ); + } + + i = bind( global.listen_socket, (struct sockaddr *) &listen_addr, sizeof( listen_addr ) ); if( i == -1 ) { log_error( "bind" ); return( -1 ); } - + i = listen( global.listen_socket, 10 ); if( i == -1 ) { log_error( "listen" ); return( -1 ); } - + ch = g_io_channel_unix_new( global.listen_socket ); - g_io_add_watch( ch, G_IO_IN, bitlbee_io_new_client, NULL ); - + global.listen_watch_source_id = g_io_add_watch( ch, G_IO_IN, bitlbee_io_new_client, NULL ); + #ifndef _WIN32 if( !global.conf->nofork ) { @@ -174,32 +216,12 @@ gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condi irc_t *irc = data; int st, size; char *temp; -#ifdef FLOOD_SEND - time_t newtime; -#endif -#ifdef FLOOD_SEND - newtime = time( NULL ); - if( ( newtime - irc->oldtime ) > FLOOD_SEND_INTERVAL ) - { - irc->sentbytes = 0; - irc->oldtime = newtime; - } -#endif - if( irc->sendbuffer == NULL ) return( FALSE ); size = strlen( irc->sendbuffer ); - -#ifdef FLOOD_SEND - if( ( FLOOD_SEND_BYTES - irc->sentbytes ) > size ) - st = write( irc->fd, irc->sendbuffer, size ); - else - st = write( irc->fd, irc->sendbuffer, ( FLOOD_SEND_BYTES - irc->sentbytes ) ); -#else st = write( irc->fd, irc->sendbuffer, size ); -#endif if( st <= 0 ) { @@ -214,10 +236,6 @@ gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condi } } -#ifdef FLOOD_SEND - irc->sentbytes += st; -#endif - if( st == size ) { g_free( irc->sendbuffer ); @@ -245,134 +263,3 @@ void bitlbee_shutdown( gpointer data ) /* We'll only reach this point when not running in inetd mode: */ g_main_quit( global.loop ); } - -int root_command_string( irc_t *irc, user_t *u, char *command, int flags ) -{ - char *cmd[IRC_MAX_ARGS]; - char *s; - int k; - char q = 0; - - memset( cmd, 0, sizeof( cmd ) ); - cmd[0] = command; - k = 1; - for( s = command; *s && k < ( IRC_MAX_ARGS - 1 ); s ++ ) - if( *s == ' ' && !q ) - { - *s = 0; - while( *++s == ' ' ); - if( *s == '"' || *s == '\'' ) - { - q = *s; - s ++; - } - if( *s ) - { - cmd[k++] = s; - s --; - } - } - else if( *s == q ) - { - q = *s = 0; - } - cmd[k] = NULL; - - return( root_command( irc, cmd ) ); -} - -int root_command( irc_t *irc, char *cmd[] ) -{ - int i; - - if( !cmd[0] ) - return( 0 ); - - for( i = 0; commands[i].command; i++ ) - if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) - { - if( !cmd[commands[i].required_parameters] ) - { - irc_usermsg( irc, "Not enough parameters given (need %d)", commands[i].required_parameters ); - return( 0 ); - } - commands[i].execute( irc, cmd ); - return( 1 ); - } - - irc_usermsg( irc, "Unknown command: %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[0] ); - - return( 1 ); -} - -/* Decode%20a%20file%20name */ -void http_decode( char *s ) -{ - char *t; - int i, j, k; - - t = g_new( char, strlen( s ) + 1 ); - - for( i = j = 0; s[i]; i ++, j ++ ) - { - if( s[i] == '%' ) - { - if( sscanf( s + i + 1, "%2x", &k ) ) - { - t[j] = k; - i += 2; - } - else - { - *t = 0; - break; - } - } - else - { - t[j] = s[i]; - } - } - t[j] = 0; - - strcpy( s, t ); - g_free( t ); -} - -/* Warning: This one explodes the string. Worst-cases can make the string 3x its original size! */ -/* This fuction is safe, but make sure you call it safely as well! */ -void http_encode( char *s ) -{ - char *t; - int i, j; - - t = g_strdup( s ); - - for( i = j = 0; t[i]; i ++, j ++ ) - { - if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' ) - { - sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] ); - j += 2; - } - else - { - s[j] = t[i]; - } - } - s[j] = 0; - - g_free( t ); -} - -/* Strip newlines from a string. Modifies the string passed to it. */ -char *strip_newlines( char *source ) -{ - int i; - - for( i = 0; source[i] != '\0'; i ++ ) - if( source[i] == '\n' || source[i] == '\r' ) - source[i] = 32; - - return source; -} diff --git a/bitlbee.conf b/bitlbee.conf index b0de328d..e5e0f7de 100644 --- a/bitlbee.conf +++ b/bitlbee.conf @@ -13,13 +13,16 @@ ## stable enough to serve lots of users from one process. Because of this ## and other reasons, the use of daemon-mode is *STRONGLY* discouraged, ## don't even *think* of reporting bugs when you use this. +## ForkDaemon -- Run as a stand-alone daemon, but keep all clients in separate +## child processes. This should be pretty safe and reliable to use instead +## of inetd mode. ## # RunMode = Inetd ## DaemonPort/DaemonInterface: ## -## For RunMode=Daemon, here you can specify on what interface and port the -## daemon should be listening for connections. +## For daemon mode, you can specify on what interface and port the daemon +## should be listening for connections. ## # DaemonInterface = 0.0.0.0 # DaemonPort = 6667 @@ -41,12 +44,17 @@ ## # AuthPassword = ItllBeBitlBee ## Heh.. Our slogan. ;-) +## OperPassword +## +## Password that unlocks access to special operator commands. +## +# OperPassword = ChangeMe! + ## HostName ## ## Normally, BitlBee gets a hostname using getsockname(). If you have a nicer ## alias for your BitlBee daemon, you can set it here and BitlBee will identify -## itself with that name instead. Leave it commented out if you want BitlBee to -## use getsockname() to get a hostname. +## itself with that name instead. ## # HostName = localhost @@ -110,6 +110,7 @@ extern char *CONF_FILE; typedef struct global_t { int listen_socket; + gint listen_watch_source_id; help_t *help; conf_t *conf; GList *storage; /* The first backend in the list will be used for saving */ @@ -31,7 +31,7 @@ #include <string.h> -command_t commands[] = { +const command_t commands[] = { { "help", 0, cmd_help }, { "identify", 1, cmd_identify }, { "register", 1, cmd_register }, @@ -54,6 +54,65 @@ command_t commands[] = { { NULL } }; +int root_command_string( irc_t *irc, user_t *u, char *command, int flags ) +{ + char *cmd[IRC_MAX_ARGS]; + char *s; + int k; + char q = 0; + + memset( cmd, 0, sizeof( cmd ) ); + cmd[0] = command; + k = 1; + for( s = command; *s && k < ( IRC_MAX_ARGS - 1 ); s ++ ) + if( *s == ' ' && !q ) + { + *s = 0; + while( *++s == ' ' ); + if( *s == '"' || *s == '\'' ) + { + q = *s; + s ++; + } + if( *s ) + { + cmd[k++] = s; + s --; + } + } + else if( *s == q ) + { + q = *s = 0; + } + cmd[k] = NULL; + + return( root_command( irc, cmd ) ); +} + +int root_command( irc_t *irc, char *cmd[] ) +{ + int i; + + if( !cmd[0] ) + return( 0 ); + + for( i = 0; commands[i].command; i++ ) + if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) + { + if( !cmd[commands[i].required_parameters] ) + { + irc_usermsg( irc, "Not enough parameters given (need %d)", commands[i].required_parameters ); + return( 0 ); + } + commands[i].execute( irc, cmd ); + return( 1 ); + } + + irc_usermsg( irc, "Unknown command: %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[0] ); + + return( 1 ); +} + int cmd_help( irc_t *irc, char **cmd ) { char param[80]; @@ -96,6 +155,7 @@ int cmd_identify( irc_t *irc, char **cmd ) break; case STORAGE_OK: irc_usermsg( irc, "Password accepted" ); + irc_umode_set( irc, "+R", 1 ); break; default: irc_usermsg( irc, "Something very weird happened" ); @@ -121,6 +181,7 @@ int cmd_register( irc_t *irc, char **cmd ) case STORAGE_OK: irc->status = USTATUS_IDENTIFIED; + irc_umode_set( irc, "+R", 1 ); break; default: @@ -145,6 +206,8 @@ int cmd_drop( irc_t *irc, char **cmd ) return( 0 ); case STORAGE_OK: irc_setpass( irc, NULL ); + irc->status = USTATUS_LOGGED_IN; + irc_umode_set( irc, "-R", 1 ); irc_usermsg( irc, "Account `%s' removed", irc->nick ); return( 0 ); default: @@ -28,8 +28,6 @@ #include "bitlbee.h" -/* Hmm... Linked list? Plleeeeaaase?? ;-) */ - typedef struct command_t { char *command; @@ -57,8 +55,6 @@ int cmd_qlist( irc_t *irc, char **cmd ); int cmd_import_buddies( irc_t *irc, char **cmd ); int cmd_dump( irc_t *irc, char **cmd ); - - -extern command_t commands[]; +extern const command_t commands[]; #endif @@ -45,14 +45,19 @@ conf_t *conf_load( int argc, char *argv[] ) conf = g_new0( conf_t, 1 ); +#ifdef IPV6 + conf->iface = "::"; +#else conf->iface = "0.0.0.0"; +#endif conf->port = 6667; conf->nofork = 0; conf->verbose = 0; conf->primary_storage = "text"; conf->runmode = RUNMODE_INETD; conf->authmode = AUTHMODE_OPEN; - conf->password = NULL; + conf->auth_pass = NULL; + conf->oper_pass = NULL; conf->configdir = g_strdup( CONFIG ); conf->plugindir = g_strdup( PLUGINDIR ); conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); @@ -70,7 +75,7 @@ conf_t *conf_load( int argc, char *argv[] ) fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE ); } - while( ( opt = getopt( argc, argv, "i:p:nvIDc:d:h" ) ) >= 0 ) + while( ( opt = getopt( argc, argv, "i:p:nvIDFc:d:h" ) ) >= 0 ) { if( opt == 'i' ) { @@ -93,6 +98,8 @@ conf_t *conf_load( int argc, char *argv[] ) conf->runmode=RUNMODE_INETD; else if( opt == 'D' ) conf->runmode=RUNMODE_DAEMON; + else if( opt == 'F' ) + conf->runmode=RUNMODE_FORKDAEMON; else if( opt == 'c' ) { if( strcmp( CONF_FILE, optarg ) != 0 ) @@ -117,6 +124,7 @@ conf_t *conf_load( int argc, char *argv[] ) "\n" " -I Classic/InetD mode. (Default)\n" " -D Daemon mode. (Still EXPERIMENTAL!)\n" + " -F Forking daemon. (one process per client)\n" " -i Specify the interface (by IP address) to listen on.\n" " (Default: 0.0.0.0 (any interface))\n" " -p Port number to listen on. (Default: 6667)\n" @@ -156,6 +164,8 @@ static int conf_loadini( conf_t *conf, char *file ) { if( g_strcasecmp( ini->value, "daemon" ) == 0 ) conf->runmode = RUNMODE_DAEMON; + else if( g_strcasecmp( ini->value, "forkdaemon" ) == 0 ) + conf->runmode = RUNMODE_FORKDAEMON; else conf->runmode = RUNMODE_INETD; } @@ -183,7 +193,11 @@ static int conf_loadini( conf_t *conf, char *file ) } else if( g_strcasecmp( ini->key, "authpassword" ) == 0 ) { - conf->password = g_strdup( ini->value ); + conf->auth_pass = g_strdup( ini->value ); + } + else if( g_strcasecmp( ini->key, "operpassword" ) == 0 ) + { + conf->oper_pass = g_strdup( ini->value ); } else if( g_strcasecmp( ini->key, "hostname" ) == 0 ) { @@ -26,7 +26,7 @@ #ifndef __CONF_H #define __CONF_H -typedef enum runmode { RUNMODE_DAEMON, RUNMODE_INETD } runmode_t; +typedef enum runmode { RUNMODE_DAEMON, RUNMODE_FORKDAEMON, RUNMODE_INETD } runmode_t; typedef enum authmode { AUTHMODE_OPEN, AUTHMODE_CLOSED, AUTHMODE_REGISTERED } authmode_t; typedef struct conf @@ -37,7 +37,8 @@ typedef struct conf int verbose; runmode_t runmode; authmode_t authmode; - char *password; + char *auth_pass; + char *oper_pass; char *hostname; char *configdir; char *plugindir; @@ -22,7 +22,6 @@ yahoo=1 debug=0 strip=1 -flood=0 ipv6=1 ssl=auto @@ -257,10 +256,10 @@ if [ "$msn" = 1 -o "$jabber" = 1 ]; then if [ "$ret" = "0" ]; then echo - echo 'WARNING: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' - echo ' This is necessary for MSN and full Jabber support. To continue,' - echo ' install a suitable SSL library or disable MSN support (--msn=0).' - echo ' If you want Jabber without SSL support you can try --ssl=bogus.' + echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' + echo ' This is necessary for MSN and full Jabber support. To continue,' + echo ' install a suitable SSL library or disable MSN support (--msn=0).' + echo ' If you want Jabber without SSL support you can try --ssl=bogus.' exit 1; fi; @@ -290,19 +289,18 @@ else fi; fi -if [ "$flood" = 1 ]; then - # echo '#define FLOOD_SEND' >> config.h - echo 'Flood protection is disabled in this release because of too many bugs.' 2> /dev/stderr - rm config.h - rm Makefile.settings - exit 1 +echo +if [ -z "$BITLBEE_VERSION" -a -d .bzr -a -x "`which bzr`" ]; then + rev=`bzr revno` + echo 'Using bzr revision #'$rev' as version number' + BITLBEE_VERSION=\"bzr-$rev\" fi if [ -n "$BITLBEE_VERSION" ]; then - echo echo 'Spoofing version number: '$BITLBEE_VERSION echo '#undef BITLBEE_VERSION' >> config.h - echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h; + echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h + echo fi protocols='' @@ -313,7 +311,7 @@ if [ "$msn" = 0 ]; then else echo '#define WITH_MSN' >> config.h protocols=$protocols'msn ' - protoobjs=$protoobjs'msnn.o ' + protoobjs=$protoobjs'msn_mod.o ' fi if [ "$jabber" = 0 ]; then @@ -321,7 +319,7 @@ if [ "$jabber" = 0 ]; then else echo '#define WITH_JABBER' >> config.h protocols=$protocols'jabber ' - protoobjs=$protoobjs'jabberr.o ' + protoobjs=$protoobjs'jabber_mod.o ' fi if [ "$oscar" = 0 ]; then @@ -329,7 +327,7 @@ if [ "$oscar" = 0 ]; then else echo '#define WITH_OSCAR' >> config.h protocols=$protocols'oscar ' - protoobjs=$protoobjs'oscarr.o ' + protoobjs=$protoobjs'oscar_mod.o ' fi if [ "$yahoo" = 0 ]; then @@ -337,11 +335,10 @@ if [ "$yahoo" = 0 ]; then else echo '#define WITH_YAHOO' >> config.h protocols=$protocols'yahoo ' - protoobjs=$protoobjs'yahooo.o ' + protoobjs=$protoobjs'yahoo_mod.o ' fi if [ "$protocols" = "PROTOCOLS = " ]; then - echo echo "WARNING: You haven't selected any communication protocol to compile!" echo " Bitlbee will run, but you will be unable to connect to IM servers!" fi @@ -349,7 +346,6 @@ fi echo "PROTOCOLS = $protocols" >> Makefile.settings echo "PROTOOBJS = $protoobjs" >> Makefile.settings -echo echo Architecture: $arch case "$arch" in Linux ) @@ -39,14 +39,17 @@ static char *passchange (irc_t *irc, void *set, char *value) irc_t *irc_new( int fd ) { - irc_t *irc = g_new0( irc_t, 1 ); - - struct sockaddr_in sock[1]; + irc_t *irc; + struct hostent *peer; + unsigned int i; + char buf[128]; #ifdef IPV6 - struct sockaddr_in6 sock6[1]; + struct sockaddr_in6 sock[1]; +#else + struct sockaddr_in sock[1]; #endif - struct hostent *peer; - unsigned int i, j; + + irc = g_new0( irc_t, 1 ); irc->fd = fd; irc->io_channel = g_io_channel_unix_new( fd ); @@ -70,41 +73,47 @@ irc_t *irc_new( int fd ) irc->channel = g_strdup( ROOT_CHAN ); i = sizeof( *sock ); -#ifdef IPV6 - j = sizeof( *sock6 ); -#endif + if( global.conf->hostname ) irc->myhost = g_strdup( global.conf->hostname ); - else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET ) +#ifdef IPV6 + else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) { - if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) ) + if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) irc->myhost = g_strdup( peer->h_name ); + else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) + irc->myhost = g_strdup( ipv6_unwrap( buf ) ); } -#ifdef IPV6 - else if( getsockname( irc->fd, (struct sockaddr*) sock6, &j ) == 0 && sock6->sin6_family == AF_INET6 ) +#else + else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) { - if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) ) + if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) irc->myhost = g_strdup( peer->h_name ); + else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) + irc->myhost = g_strdup( buf ); } #endif i = sizeof( *sock ); #ifdef IPV6 - j = sizeof( *sock6 ); -#endif - if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET ) + if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) { - if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) ) + if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) irc->host = g_strdup( peer->h_name ); + else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) + irc->host = g_strdup( ipv6_unwrap( buf ) ); } -#ifdef IPV6 - else if( getpeername( irc->fd, (struct sockaddr*) sock6, &j ) == 0 && sock6->sin6_family == AF_INET6 ) +#else + if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) { - if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) ) + if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) irc->host = g_strdup( peer->h_name ); + else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) + irc->host = g_strdup( buf ); } #endif + /* Rare, but possible. */ if( !irc->host ) irc->host = g_strdup( "localhost." ); if( !irc->myhost ) irc->myhost = g_strdup( "localhost." ); @@ -263,7 +272,7 @@ void irc_free(irc_t * irc) } g_free(irc); - if( global.conf->runmode == RUNMODE_INETD ) + if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON ) g_main_quit( global.loop ); } @@ -421,7 +430,7 @@ int irc_exec( irc_t *irc, char **cmd ) { irc_reply( irc, 461, "%s :Need more parameters", cmd[0] ); } - else if( strcmp( cmd[1], (global.conf)->password ) == 0 ) + else if( strcmp( cmd[1], (global.conf)->auth_pass ) == 0 ) { irc->status = USTATUS_AUTHORIZED; } @@ -500,6 +509,15 @@ int irc_exec( irc_t *irc, char **cmd ) { irc_write( irc, ":%s PONG %s :%s", irc->myhost, irc->myhost, cmd[1]?cmd[1]:irc->myhost ); } + else if( g_strcasecmp( cmd[0], "OPER" ) == 0 ) + { + if( !cmd[2] ) + irc_reply( irc, 461, "%s :Need more parameters", cmd[0] ); + else if( strcmp( cmd[2], global.conf->oper_pass ) == 0 ) + irc_umode_set( irc, "+o", 1 ); + // else + /* FIXME/TODO: Find out which reply to send now. */ + } else if( g_strcasecmp( cmd[0], "MODE" ) == 0 ) { if( !cmd[1] ) @@ -523,7 +541,7 @@ int irc_exec( irc_t *irc, char **cmd ) if( nick_cmp( cmd[1], irc->nick ) == 0 ) { if( cmd[2] ) - irc_umode_set( irc, irc->nick, cmd[2] ); + irc_umode_set( irc, cmd[2], 0 ); } else irc_reply( irc, 502, ":Don't touch their modes" ); @@ -922,21 +940,6 @@ void irc_vawrite( irc_t *irc, char *format, va_list params ) if( irc->sendbuffer != NULL ) { size = strlen( irc->sendbuffer ) + strlen( line ); -#ifdef FLOOD_SEND - if( size > FLOOD_SEND_MAXBUFFER ) { - /* Die flooder, die! >:) */ - - g_free(irc->sendbuffer); - - /* We need the \r\n at the start because else we might append our string to a half - * sent line. A bit hackish, but it works. - */ - irc->sendbuffer = g_strdup( "\r\nERROR :Sendq Exceeded\r\n" ); - irc->quit = 1; - - return; - } -#endif irc->sendbuffer = g_renew ( char, irc->sendbuffer, size + 1 ); strcpy( ( irc->sendbuffer + strlen( irc->sendbuffer ) ), line ); } @@ -1074,9 +1077,10 @@ void irc_login( irc_t *irc ) irc_reply( irc, 1, ":Welcome to the BitlBee gateway, %s", irc->nick ); irc_reply( irc, 2, ":Host %s is running BitlBee " BITLBEE_VERSION " " ARCH "/" CPU ".", irc->myhost ); irc_reply( irc, 3, ":%s", IRCD_INFO ); - irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES, CMODES ); + irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES ); + irc_reply( irc, 5, "PREFIX=(ov)@+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 ); irc_motd( irc ); - irc_umode_set( irc, irc->myhost, "+" UMODE ); + irc_umode_set( irc, "+" UMODE, 1 ); u = user_add( irc, irc->mynick ); u->host = g_strdup( irc->myhost ); @@ -1203,8 +1207,10 @@ void irc_whois( irc_t *irc, char *nick ) } -void irc_umode_set( irc_t *irc, char *who, char *s ) +void irc_umode_set( irc_t *irc, char *s, int allow_priv ) { + /* allow_priv: Set to 0 if s contains user input, 1 if you want + to set a "privileged" mode (+o, +R, etc). */ char m[256], st = 1, *t; int i; @@ -1217,14 +1223,14 @@ void irc_umode_set( irc_t *irc, char *who, char *s ) { if( *t == '+' || *t == '-' ) st = *t == '+'; - else + else if( st == 0 || ( strchr( UMODES, *t ) || ( allow_priv && strchr( UMODES_PRIV, *t ) ) ) ) m[(int)*t] = st; } memset( irc->umode, 0, sizeof( irc->umode ) ); for( i = 0; i < 256 && strlen( irc->umode ) < ( sizeof( irc->umode ) - 1 ); i ++ ) - if( m[i] && strchr( UMODES, i ) ) + if( m[i] ) irc->umode[strlen(irc->umode)] = i; irc_reply( irc, 221, "+%s", irc->umode ); @@ -32,14 +32,8 @@ #define IRC_LOGIN_TIMEOUT 60 #define IRC_PING_STRING "PinglBee" -/* #define FLOOD_SEND - * Not yet enabled by default due to some problems. - */ -#define FLOOD_SEND_INTERVAL 30 -#define FLOOD_SEND_BYTES (1024*10) -#define FLOOD_SEND_MAXBUFFER (1024*20) - -#define UMODES "ais" +#define UMODES "ias" +#define UMODES_PRIV "Ro" #define CMODES "nt" #define CMODE "t" #define UMODE "s" @@ -126,7 +120,7 @@ void irc_login( irc_t *irc ); void irc_motd( irc_t *irc ); void irc_names( irc_t *irc, char *channel ); void irc_topic( irc_t *irc, char *channel ); -void irc_umode_set( irc_t *irc, char *who, char *s ); +void irc_umode_set( irc_t *irc, char *s, int allow_priv ); void irc_who( irc_t *irc, char *channel ); void irc_spawn( irc_t *irc, user_t *u ); void irc_join( irc_t *irc, user_t *u, char *channel ); diff --git a/protocols/Makefile b/protocols/Makefile index c5f938fd..4016e7fd 100644 --- a/protocols/Makefile +++ b/protocols/Makefile @@ -9,7 +9,7 @@ -include ../Makefile.settings # [SH] Program variables -objects = md5.o nogaim.o proxy.o sha.o util.o $(SSL_CLIENT) +objects = http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT) # [SH] The next two lines should contain the directory name (in $(subdirs)) # and the name of the object file, which should be linked into diff --git a/protocols/http_client.c b/protocols/http_client.c new file mode 100644 index 00000000..9417e200 --- /dev/null +++ b/protocols/http_client.c @@ -0,0 +1,382 @@ + /********************************************************************\ + * BitlBee -- An IRC to other IM-networks gateway * + * * + * Copyright 2002-2005 Wilmer van der Gaast and others * + \********************************************************************/ + +/* HTTP(S) module */ + +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License with + the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; + if not, write to the Free Software Foundation, Inc., 59 Temple Place, + Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <string.h> +#include <stdio.h> + +#include "http_client.h" +#include "url.h" +#include "sock.h" + + +static void http_connected( gpointer data, int source, GaimInputCondition cond ); +static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond ); +static void http_incoming_data( gpointer data, int source, GaimInputCondition cond ); + + +void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ) +{ + struct http_request *req; + int error = 0; + + req = g_new0( struct http_request, 1 ); + + if( ssl ) + { + req->ssl = ssl_connect( host, port, http_ssl_connected, req ); + if( req->ssl == NULL ) + error = 1; + } + else + { + req->fd = proxy_connect( host, port, http_connected, req ); + if( req->fd < 0 ) + error = 1; + } + + if( error ) + { + g_free( req ); + return( NULL ); + } + + req->func = func; + req->data = data; + req->request = g_strdup( request ); + req->request_length = strlen( request ); + + return( req ); +} + +/* This one is actually pretty simple... Might get more calls if we can't write + the whole request at once. */ +static void http_connected( gpointer data, int source, GaimInputCondition cond ) +{ + struct http_request *req = data; + int st; + + if( source < 0 ) + goto error; + + if( req->inpa > 0 ) + gaim_input_remove( req->inpa ); + + sock_make_nonblocking( req->fd ); + + if( req->ssl ) + { + st = ssl_write( req->ssl, req->request + req->bytes_written, + req->request_length - req->bytes_written ); + if( st < 0 ) + { + if( ssl_errno != SSL_AGAIN ) + { + ssl_disconnect( req->ssl ); + goto error; + } + } + } + else + { + st = write( source, req->request + req->bytes_written, + req->request_length - req->bytes_written ); + if( st < 0 ) + { + if( !sockerr_again() ) + { + closesocket( req->fd ); + goto error; + } + } + } + + if( st > 0 ) + req->bytes_written += st; + + if( req->bytes_written < req->request_length ) + req->inpa = gaim_input_add( source, + req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE, + http_connected, req ); + else + req->inpa = gaim_input_add( source, GAIM_INPUT_READ, http_incoming_data, req ); + + return; + +error: + req->func( req ); + + g_free( req->request ); + g_free( req ); + + return; +} + +static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond ) +{ + struct http_request *req = data; + + if( source == NULL ) + return http_connected( data, -1, cond ); + + req->fd = ssl_getfd( source ); + + return http_connected( data, req->fd, cond ); +} + +static void http_incoming_data( gpointer data, int source, GaimInputCondition cond ) +{ + struct http_request *req = data; + int evil_server = 0; + char buffer[2048]; + char *end1, *end2; + int st; + + if( req->inpa > 0 ) + gaim_input_remove( req->inpa ); + + if( req->ssl ) + { + st = ssl_read( req->ssl, buffer, sizeof( buffer ) ); + if( st < 0 ) + { + if( ssl_errno != SSL_AGAIN ) + { + /* goto cleanup; */ + + /* YAY! We have to deal with crappy Microsoft + servers that LOVE to send invalid TLS + packets that abort connections! \o/ */ + + goto got_reply; + } + } + else if( st == 0 ) + { + goto got_reply; + } + } + else + { + st = read( req->fd, buffer, sizeof( buffer ) ); + if( st < 0 ) + { + if( !sockerr_again() ) + { + goto cleanup; + } + } + else if( st == 0 ) + { + goto got_reply; + } + } + + if( st > 0 ) + { + req->reply_headers = g_realloc( req->reply_headers, req->bytes_read + st + 1 ); + memcpy( req->reply_headers + req->bytes_read, buffer, st ); + req->bytes_read += st; + } + + /* There will be more! */ + req->inpa = gaim_input_add( req->fd, + req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ, + http_incoming_data, req ); + + return; + +got_reply: + /* Zero termination is very convenient. */ + req->reply_headers[req->bytes_read] = 0; + + /* Find the separation between headers and body, and keep stupid + webservers in mind. */ + end1 = strstr( req->reply_headers, "\r\n\r\n" ); + end2 = strstr( req->reply_headers, "\n\n" ); + + if( end2 && end2 < end1 ) + { + end1 = end2 + 1; + evil_server = 1; + } + else + { + end1 += 2; + } + + if( end1 ) + { + *end1 = 0; + + if( evil_server ) + req->reply_body = end1 + 1; + else + req->reply_body = end1 + 2; + } + + if( ( end1 = strchr( req->reply_headers, ' ' ) ) != NULL ) + { + if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 ) + req->status_code = -1; + } + else + { + req->status_code = -1; + } + + if( req->status_code == 301 || req->status_code == 302 ) + { + char *loc, *new_request, *new_host; + int error = 0, new_port, new_proto; + + loc = strstr( req->reply_headers, "\nLocation: " ); + if( loc == NULL ) /* We can't handle this redirect... */ + goto cleanup; + + loc += 11; + while( *loc == ' ' ) + loc ++; + + /* TODO/FIXME: Possibly have to handle relative redirections, + and rewrite Host: headers. Not necessary for now, it's + enough for passport authentication like this. */ + + if( *loc == '/' ) + { + /* Just a different pathname... */ + + /* Since we don't cache the servername, and since we + don't need this yet anyway, I won't implement it. */ + + goto cleanup; + } + else + { + /* A whole URL */ + url_t *url; + char *s; + + s = strstr( loc, "\r\n" ); + if( s == NULL ) + goto cleanup; + + url = g_new0( url_t, 1 ); + *s = 0; + + if( !url_set( url, loc ) ) + { + g_free( url ); + goto cleanup; + } + + /* Okay, this isn't fun! We have to rebuild the request... :-( */ + new_request = g_malloc( req->request_length + strlen( url->file ) ); + + /* So, now I just allocated enough memory, so I'm + going to use strcat(), whether you like it or not. :-) */ + + /* First, find the GET/POST/whatever from the original request. */ + s = strchr( req->request, ' ' ); + if( s == NULL ) + { + g_free( new_request ); + g_free( url ); + goto cleanup; + } + + *s = 0; + sprintf( new_request, "%s %s HTTP/1.0\r\n", req->request, url->file ); + *s = ' '; + + s = strstr( req->request, "\r\n" ); + if( s == NULL ) + { + g_free( new_request ); + g_free( url ); + goto cleanup; + } + + strcat( new_request, s + 2 ); + new_host = g_strdup( url->host ); + new_port = url->port; + new_proto = url->proto; + + g_free( url ); + } + + if( req->ssl ) + ssl_disconnect( req->ssl ); + else + closesocket( req->fd ); + + req->fd = -1; + req->ssl = 0; + + if( new_proto == PROTO_HTTPS ) + { + req->ssl = ssl_connect( new_host, new_port, http_ssl_connected, req ); + if( req->ssl == NULL ) + error = 1; + } + else + { + req->fd = proxy_connect( new_host, new_port, http_connected, req ); + if( req->fd < 0 ) + error = 1; + } + g_free( new_host ); + + if( error ) + { + g_free( new_request ); + goto cleanup; + } + + g_free( req->request ); + g_free( req->reply_headers ); + req->request = new_request; + req->request_length = strlen( new_request ); + req->bytes_read = req->bytes_written = req->inpa = 0; + req->reply_headers = req->reply_body = NULL; + + return; + } + + /* Assume that a closed connection means we're finished, this indeed + breaks with keep-alive connections and faulty connections. */ + req->finished = 1; + +cleanup: + if( req->ssl ) + ssl_disconnect( req->ssl ); + else + closesocket( req->fd ); + + req->func( req ); + + g_free( req->request ); + g_free( req->reply_headers ); + g_free( req ); +} diff --git a/protocols/http_client.h b/protocols/http_client.h new file mode 100644 index 00000000..53c6fcd6 --- /dev/null +++ b/protocols/http_client.h @@ -0,0 +1,54 @@ + /********************************************************************\ + * BitlBee -- An IRC to other IM-networks gateway * + * * + * Copyright 2002-2005 Wilmer van der Gaast and others * + \********************************************************************/ + +/* HTTP(S) module */ + +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License with + the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; + if not, write to the Free Software Foundation, Inc., 59 Temple Place, + Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <glib.h> + +#include "ssl_client.h" + +struct http_request; + +typedef void (*http_input_function)( struct http_request * ); + +struct http_request +{ + char *request; + int request_length; + int status_code; + char *reply_headers; + char *reply_body; + int finished; + + void *ssl; + int fd; + + int inpa; + int bytes_written; + int bytes_read; + + http_input_function func; + gpointer data; +}; + +void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ); diff --git a/protocols/jabber/Makefile b/protocols/jabber/Makefile index df326fe6..9b414dc8 100644 --- a/protocols/jabber/Makefile +++ b/protocols/jabber/Makefile @@ -15,7 +15,7 @@ CFLAGS += -Wall LFLAGS += -r # [SH] Phony targets -all: jabberr.o +all: jabber_mod.o .PHONY: all clean distclean @@ -32,6 +32,6 @@ $(objects): %.o: %.c @echo '*' Compiling $< @$(CC) -c $(CFLAGS) $< -o $@ -jabberr.o: $(objects) - @echo '*' Linking jabberr.o - @$(LD) $(LFLAGS) $(objects) -o jabberr.o +jabber_mod.o: $(objects) + @echo '*' Linking jabber_mod.o + @$(LD) $(LFLAGS) $(objects) -o jabber_mod.o diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index fc419124..d4b5bde5 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -1248,14 +1248,10 @@ static void jabber_handleauthresp(gjconn gjc, jpacket p) } gjab_auth(gjc); } else { + gjab_reqroster(gjc); account_online(GJ_GC(gjc)); - - if (bud_list_cache_exists(GJ_GC(gjc))) - do_import(GJ_GC(gjc), NULL); - + ((struct jabber_data *)GJ_GC(gjc)->proto_data)->did_import = TRUE; - - gjab_reqroster(gjc); } } else { xmlnode xerr; @@ -1859,11 +1855,7 @@ static void jabber_set_away(struct gaim_connection *gc, char *state, char *messa y = xmlnode_insert_tag(x, "show"); xmlnode_insert_cdata(y, "away", -1); y = xmlnode_insert_tag(x, "status"); - { - char *utf8 = str_to_utf8(message); - xmlnode_insert_cdata(y, utf8, -1); - g_free(utf8); - } + xmlnode_insert_cdata(y, message, -1); gc->away = ""; } else { /* Gaim wants us to not be away */ diff --git a/protocols/msn/Makefile b/protocols/msn/Makefile index e6620323..873c831c 100644 --- a/protocols/msn/Makefile +++ b/protocols/msn/Makefile @@ -15,7 +15,7 @@ CFLAGS += -Wall LFLAGS += -r # [SH] Phony targets -all: msnn.o +all: msn_mod.o .PHONY: all clean distclean @@ -32,8 +32,8 @@ $(objects): %.o: %.c @echo '*' Compiling $< @$(CC) -c $(CFLAGS) $< -o $@ -msnn.o: $(objects) - @echo '*' Linking msnn.o - @$(LD) $(LFLAGS) $(objects) -o msnn.o +msn_mod.o: $(objects) + @echo '*' Linking msn_mod.o + @$(LD) $(LFLAGS) $(objects) -o msn_mod.o diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index b828d31c..b03c898e 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -169,17 +169,17 @@ static GList *msn_away_states( struct gaim_connection *gc ) int i; for( i = 0; msn_away_state_list[i].number > -1; i ++ ) - l = g_list_append( l, msn_away_state_list[i].name ); + l = g_list_append( l, (void*) msn_away_state_list[i].name ); return( l ); } static char *msn_get_status_string( struct gaim_connection *gc, int number ) { - struct msn_away_state *st = msn_away_state_by_number( number ); + const struct msn_away_state *st = msn_away_state_by_number( number ); if( st ) - return( st->name ); + return( (char*) st->name ); else return( "" ); } @@ -188,7 +188,7 @@ static void msn_set_away( struct gaim_connection *gc, char *state, char *message { char buf[1024]; struct msn_data *md = gc->proto_data; - struct msn_away_state *st; + const struct msn_away_state *st; if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 ) st = msn_away_state_by_name( "Away" ); diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 61231d8a..9727c537 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -66,7 +66,7 @@ struct msn_data GSList *msgq; GSList *switchboards; int buddycount; - struct msn_away_state *away_state; + const struct msn_away_state *away_state; }; struct msn_switchboard @@ -126,10 +126,12 @@ struct msn_handler_data /* Bitfield values for msn_status_code.flags */ #define STATUS_FATAL 1 #define STATUS_SB_FATAL 2 +#define STATUS_SB_IM_SPARE 4 /* Make one-to-one conversation switchboard available again, invite failed. */ +#define STATUS_SB_CHAT_SPARE 8 /* Same, but also for groupchats (not used yet). */ int msn_chat_id; -extern struct msn_away_state msn_away_state_list[]; -extern struct msn_status_code msn_status_code_list[]; +extern const struct msn_away_state msn_away_state_list[]; +extern const struct msn_status_code msn_status_code_list[]; /* Keep a list of all the active connections. We need these lists because "connected" callbacks might be called when the connection they belong too @@ -153,10 +155,10 @@ char **msn_linesplit( char *line ); int msn_handler( struct msn_handler_data *h ); /* tables.c */ -struct msn_away_state *msn_away_state_by_number( int number ); -struct msn_away_state *msn_away_state_by_code( char *code ); -struct msn_away_state *msn_away_state_by_name( char *name ); -struct msn_status_code *msn_status_by_number( int number ); +const struct msn_away_state *msn_away_state_by_number( int number ); +const struct msn_away_state *msn_away_state_by_code( char *code ); +const struct msn_away_state *msn_away_state_by_name( char *name ); +const struct msn_status_code *msn_status_by_number( int number ); /* sb.c */ int msn_sb_write( struct msn_switchboard *sb, char *s, int len ); diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index f1bda1a4..4ced58a0 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -207,7 +207,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts == 5 && strcmp( cmd[2], "TWN" ) == 0 && strcmp( cmd[3], "S" ) == 0 ) { /* Time for some Passport black magic... */ - if( !passport_get_id( gc, gc->username, gc->password, cmd[4], msn_auth_got_passport_id ) ) + if( !passport_get_id( msn_auth_got_passport_id, gc, gc->username, gc->password, cmd[4] ) ) { hide_login_progress_error( gc, "Error while contacting Passport server" ); signoff( gc ); @@ -364,7 +364,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "ILN" ) == 0 ) { - struct msn_away_state *st; + const struct msn_away_state *st; if( num_parts != 6 ) { @@ -392,7 +392,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "NLN" ) == 0 ) { - struct msn_away_state *st; + const struct msn_away_state *st; if( num_parts != 5 ) { @@ -538,7 +538,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) else if( isdigit( cmd[0][0] ) ) { int num = atoi( cmd[0] ); - struct msn_status_code *err = msn_status_by_number( num ); + const struct msn_status_code *err = msn_status_by_number( num ); g_snprintf( buf, sizeof( buf ), "Error reported by MSN server: %s", err->text ); do_error_dialog( gc, buf, "MSN" ); diff --git a/protocols/msn/passport.c b/protocols/msn/passport.c index 640126a0..34703432 100644 --- a/protocols/msn/passport.c +++ b/protocols/msn/passport.c @@ -19,7 +19,7 @@ * */ -#include "ssl_client.h" +#include "http_client.h" #include "passport.h" #include "msn.h" #include "bitlbee.h" @@ -30,34 +30,91 @@ static char *prd_cached = NULL; -static char *passport_create_header( char *reply, char *email, char *pwd ); +static int passport_get_id_real( gpointer func, gpointer data, char *header ); +static void passport_get_id_ready( struct http_request *req ); + static int passport_retrieve_dalogin( gpointer data, gpointer func, char *header ); -static void passport_retrieve_dalogin_connected( gpointer data, void *ssl, GaimInputCondition cond ); -static int passport_get_id_from( gpointer data, gpointer func, char *header_i, char *url ); -static void passport_get_id_connected( gpointer data, void *ssl, GaimInputCondition cond ); -static void destroy_reply( struct passport_reply *rep ); +static void passport_retrieve_dalogin_ready( struct http_request *req ); +static char *passport_create_header( char *cookie, char *email, char *pwd ); +static void destroy_reply( struct passport_reply *rep ); -int passport_get_id( gpointer data, char *username, char *password, char *cookie, gpointer func ) +int passport_get_id( gpointer func, gpointer data, char *username, char *password, char *cookie ) { char *header = passport_create_header( cookie, username, password ); - if( prd_cached ) - { - int st; - - st = passport_get_id_from( data, func, header, prd_cached ); - g_free( header ); - return( st ); - } + if( prd_cached == NULL ) + return passport_retrieve_dalogin( func, data, header ); else + return passport_get_id_real( func, data, header ); +} + +static int passport_get_id_real( gpointer func, gpointer data, char *header ) +{ + struct passport_reply *rep; + char *server, *dummy, *reqs; + struct http_request *req; + + rep = g_new0( struct passport_reply, 1 ); + rep->data = data; + rep->func = func; + + server = g_strdup( prd_cached ); + dummy = strchr( server, '/' ); + + if( dummy == NULL ) { - return( passport_retrieve_dalogin( data, func, header ) ); + destroy_reply( rep ); + return( 0 ); } + + reqs = g_malloc( strlen( header ) + strlen( dummy ) + 128 ); + sprintf( reqs, "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header ); + + *dummy = 0; + req = http_dorequest( server, 443, 1, reqs, passport_get_id_ready, rep ); + + g_free( server ); + g_free( reqs ); + + if( req == NULL ) + destroy_reply( rep ); + + return( req != NULL ); } +static void passport_get_id_ready( struct http_request *req ) +{ + struct passport_reply *rep = req->data; + + if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers ) + { + destroy_reply( rep ); + return; + } + + if( req->status_code == 200 ) + { + char *dummy; + + if( ( dummy = strstr( req->reply_headers, "from-PP='" ) ) ) + { + char *responseend; + + dummy += strlen( "from-PP='" ); + responseend = strchr( dummy, '\'' ); + if( responseend ) + *responseend = 0; + + rep->result = g_strdup( dummy ); + } + } + + rep->func( rep ); + destroy_reply( rep ); +} -static char *passport_create_header( char *reply, char *email, char *pwd ) +static char *passport_create_header( char *cookie, char *email, char *pwd ) { char *buffer = g_new0( char, 2048 ); char *currenttoken; @@ -71,7 +128,7 @@ static char *passport_create_header( char *reply, char *email, char *pwd ) strcpy( pwd_enc, pwd ); http_encode( pwd_enc ); - currenttoken = strstr( reply, "lc=" ); + currenttoken = strstr( cookie, "lc=" ); if( currenttoken == NULL ) return( NULL ); @@ -87,227 +144,68 @@ static char *passport_create_header( char *reply, char *email, char *pwd ) return( buffer ); } - -static int passport_retrieve_dalogin( gpointer data, gpointer func, char *header ) +#define PPR_REQUEST "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n" +static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header ) { struct passport_reply *rep = g_new0( struct passport_reply, 1 ); - void *ssl; + struct http_request *req; rep->data = data; rep->func = func; rep->header = header; - ssl = ssl_connect( "nexus.passport.com", 443, passport_retrieve_dalogin_connected, rep ); + req = http_dorequest( "nexus.passport.com", 443, 1, PPR_REQUEST, passport_retrieve_dalogin_ready, rep ); - if( !ssl ) + if( !req ) destroy_reply( rep ); - return( ssl != NULL ); + return( req != NULL ); } -#define PPR_BUFFERSIZE 2048 -#define PPR_REQUEST "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n" -static void passport_retrieve_dalogin_connected( gpointer data, void *ssl, GaimInputCondition cond ) +static void passport_retrieve_dalogin_ready( struct http_request *req ) { - int ret; - char buffer[PPR_BUFFERSIZE+1]; - struct passport_reply *rep = data; + struct passport_reply *rep = req->data; + char *dalogin; + char *urlend; - if( !g_slist_find( msn_connections, rep->data ) ) + if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers ) { - if( ssl ) ssl_disconnect( ssl ); destroy_reply( rep ); return; } - if( !ssl ) - { - rep->func( rep ); - destroy_reply( rep ); - return; - } - - ssl_write( ssl, PPR_REQUEST, strlen( PPR_REQUEST ) ); + dalogin = strstr( req->reply_headers, "DALogin=" ); - if( ( ret = ssl_read( ssl, buffer, PPR_BUFFERSIZE ) ) <= 0 ) - { + if( !dalogin ) goto failure; - } - - { - char *dalogin = strstr( buffer, "DALogin=" ); - char *urlend; - - if( !dalogin ) - goto failure; - - dalogin += strlen( "DALogin=" ); - urlend = strchr( dalogin, ',' ); - if( urlend ) - *urlend = 0; - - /* strip the http(s):// part from the url */ - urlend = strstr( urlend, "://" ); - if( urlend ) - dalogin = urlend + strlen( "://" ); - - if( prd_cached == NULL ) - prd_cached = g_strdup( dalogin ); - } - - if( passport_get_id_from( rep->data, rep->func, rep->header, prd_cached ) ) - { - ssl_disconnect( ssl ); - destroy_reply( rep ); - return; - } -failure: - ssl_disconnect( ssl ); - rep->func( rep ); - destroy_reply( rep ); -} - - -static int passport_get_id_from( gpointer data, gpointer func, char *header_i, char *url ) -{ - struct passport_reply *rep = g_new0( struct passport_reply, 1 ); - char server[512], *dummy; - void *ssl; - - rep->data = data; - rep->func = func; - rep->redirects = 4; - - strncpy( server, url, 512 ); - dummy = strchr( server, '/' ); - if( dummy ) - *dummy = 0; - - ssl = ssl_connect( server, 443, passport_get_id_connected, rep ); - - if( ssl ) - { - rep->header = g_strdup( header_i ); - rep->url = g_strdup( url ); - } - else - { - destroy_reply( rep ); - } + dalogin += strlen( "DALogin=" ); + urlend = strchr( dalogin, ',' ); + if( urlend ) + *urlend = 0; - return( ssl != NULL ); -} - -#define PPG_BUFFERSIZE 4096 -static void passport_get_id_connected( gpointer data, void *ssl, GaimInputCondition cond ) -{ - struct passport_reply *rep = data; - char server[512], buffer[PPG_BUFFERSIZE+1], *dummy; - int ret; + /* strip the http(s):// part from the url */ + urlend = strstr( urlend, "://" ); + if( urlend ) + dalogin = urlend + strlen( "://" ); - if( !g_slist_find( msn_connections, rep->data ) ) - { - if( ssl ) ssl_disconnect( ssl ); - destroy_reply( rep ); - return; - } + if( prd_cached == NULL ) + prd_cached = g_strdup( dalogin ); - if( !ssl ) + if( passport_get_id_real( rep->func, rep->data, rep->header ) ) { - rep->func( rep ); destroy_reply( rep ); return; } - memset( buffer, 0, PPG_BUFFERSIZE + 1 ); - - strncpy( server, rep->url, 512 ); - dummy = strchr( server, '/' ); - if( dummy == NULL ) - goto end; - - g_snprintf( buffer, PPG_BUFFERSIZE - 1, "GET %s HTTP/1.0\r\n" - "%s\r\n\r\n", dummy, rep->header ); - - ssl_write( ssl, buffer, strlen( buffer ) ); - memset( buffer, 0, PPG_BUFFERSIZE + 1 ); - - { - char *buffer2 = buffer; - - while( ( ( ret = ssl_read( ssl, buffer2, 512 ) ) > 0 ) && - ( buffer + PPG_BUFFERSIZE - buffer2 - ret - 512 >= 0 ) ) - { - buffer2 += ret; - } - } - - if( *buffer == 0 ) - goto end; - - if( ( dummy = strstr( buffer, "Location:" ) ) ) - { - char *urlend; - - rep->redirects --; - if( rep->redirects == 0 ) - goto end; - - dummy += strlen( "Location:" ); - while( isspace( *dummy ) ) dummy ++; - urlend = dummy; - while( !isspace( *urlend ) ) urlend ++; - *urlend = 0; - if( ( urlend = strstr( dummy, "://" ) ) ) - dummy = urlend + strlen( "://" ); - - g_free( rep->url ); - rep->url = g_strdup( dummy ); - - strncpy( server, dummy, sizeof( server ) - 1 ); - dummy = strchr( server, '/' ); - if( dummy ) *dummy = 0; - - ssl_disconnect( ssl ); - - if( ssl_connect( server, 443, passport_get_id_connected, rep ) ) - { - return; - } - else - { - rep->func( rep ); - destroy_reply( rep ); - return; - } - } - else if( strstr( buffer, "200 OK" ) ) - { - if( ( dummy = strstr( buffer, "from-PP='" ) ) ) - { - char *responseend; - - dummy += strlen( "from-PP='" ); - responseend = strchr( dummy, '\'' ); - if( responseend ) - *responseend = 0; - - rep->result = g_strdup( dummy ); - } - } - -end: - ssl_disconnect( ssl ); +failure: rep->func( rep ); destroy_reply( rep ); } - static void destroy_reply( struct passport_reply *rep ) { - if( rep->result ) g_free( rep->result ); - if( rep->url ) g_free( rep->url ); - if( rep->header ) g_free( rep->header ); - if( rep ) g_free( rep ); + g_free( rep->result ); + g_free( rep->header ); + g_free( rep ); } diff --git a/protocols/msn/passport.h b/protocols/msn/passport.h index 63fef2e9..f7e6ebb6 100644 --- a/protocols/msn/passport.h +++ b/protocols/msn/passport.h @@ -34,14 +34,12 @@ struct passport_reply { + void (*func)( struct passport_reply * ); void *data; char *result; - void (*func)( struct passport_reply * ); - char *url; char *header; - int redirects; }; -int passport_get_id( gpointer data, char *username, char *password, char *cookie, gpointer func ); +int passport_get_id( gpointer func, gpointer data, char *username, char *password, char *cookie ); #endif /* __PASSPORT_H__ */ diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index 2f4d05d5..9e7ef841 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -511,7 +511,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) else if( isdigit( cmd[0][0] ) ) { int num = atoi( cmd[0] ); - struct msn_status_code *err = msn_status_by_number( num ); + const struct msn_status_code *err = msn_status_by_number( num ); g_snprintf( buf, sizeof( buf ), "Error reported by switchboard server: %s", err->text ); do_error_dialog( gc, buf, "MSN" ); @@ -521,11 +521,35 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) msn_sb_destroy( sb ); return( 0 ); } - else if( err->flags & STATUS_FATAL ) + if( err->flags & STATUS_FATAL ) { signoff( gc ); return( 0 ); } + if( err->flags & STATUS_SB_IM_SPARE ) + { + if( sb->who ) + { + struct msn_message *m; + GSList *l; + + /* Apparently some invitation failed. We might want to use this + board later, so keep it as a spare. */ + g_free( sb->who ); + sb->who = NULL; + + /* Also clear the msgq, otherwise someone else might get them. */ + for( l = sb->msgq; l; l = l->next ) + { + m = l->data; + g_free( m->who ); + g_free( m->text ); + g_free( m ); + } + g_slist_free( sb->msgq ); + sb->msgq = NULL; + } + } } else { diff --git a/protocols/msn/tables.c b/protocols/msn/tables.c index 0cd80c01..f8e98350 100644 --- a/protocols/msn/tables.c +++ b/protocols/msn/tables.c @@ -26,7 +26,7 @@ #include "nogaim.h" #include "msn.h" -struct msn_away_state msn_away_state_list[] = +const struct msn_away_state msn_away_state_list[] = { { 0, "NLN", "Available" }, { 1, "BSY", "Busy" }, @@ -39,7 +39,7 @@ struct msn_away_state msn_away_state_list[] = { -1, "", "" } }; -struct msn_away_state *msn_away_state_by_number( int number ) +const struct msn_away_state *msn_away_state_by_number( int number ) { int i; @@ -50,7 +50,7 @@ struct msn_away_state *msn_away_state_by_number( int number ) return( NULL ); } -struct msn_away_state *msn_away_state_by_code( char *code ) +const struct msn_away_state *msn_away_state_by_code( char *code ) { int i; @@ -61,7 +61,7 @@ struct msn_away_state *msn_away_state_by_code( char *code ) return( NULL ); } -struct msn_away_state *msn_away_state_by_name( char *name ) +const struct msn_away_state *msn_away_state_by_name( char *name ) { int i; @@ -72,19 +72,19 @@ struct msn_away_state *msn_away_state_by_name( char *name ) return( NULL ); } -struct msn_status_code msn_status_code_list[] = +const struct msn_status_code msn_status_code_list[] = { { 200, "Invalid syntax", 0 }, { 201, "Invalid parameter", 0 }, { 205, "Invalid (non-existent) handle", 0 }, { 206, "Domain name missing", 0 }, { 207, "Already logged in", 0 }, - { 208, "Invalid handle", 0 }, + { 208, "Invalid handle", STATUS_SB_IM_SPARE }, { 209, "Forbidden nickname", 0 }, { 210, "Buddy list too long", 0 }, { 215, "Handle is already in list", 0 }, - { 216, "Handle is not in list", 0 }, - { 217, "Person is off-line or non-existent", 0 }, + { 216, "Handle is not in list", STATUS_SB_IM_SPARE }, + { 217, "Person is off-line or non-existent", STATUS_SB_IM_SPARE }, { 218, "Already in that mode", 0 }, { 219, "Handle is already in opposite list", 0 }, { 223, "Too many groups", 0 }, @@ -117,7 +117,7 @@ struct msn_status_code msn_status_code_list[] = { 710, "Invalid CVR parameters", STATUS_FATAL }, { 711, "Write is blocking", STATUS_FATAL }, { 712, "Session is overloaded", STATUS_FATAL }, - { 713, "Calling too rapidly", 0 }, + { 713, "Calling too rapidly", STATUS_SB_IM_SPARE }, { 714, "Too many sessions", STATUS_FATAL }, { 715, "Not expected/Invalid argument/action", 0 }, { 717, "Bad friend file", STATUS_FATAL }, @@ -143,7 +143,7 @@ struct msn_status_code msn_status_code_list[] = { -1, NULL, 0 } }; -struct msn_status_code *msn_status_by_number( int number ) +const struct msn_status_code *msn_status_by_number( int number ) { static struct msn_status_code *unknown = NULL; int i; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 8ec65347..afc39a80 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -311,19 +311,18 @@ G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *han G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle ); G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime ); G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id ); -/* void serv_finish_login( struct gaim_connection *gc ); */ /* util.c */ -G_MODULE_EXPORT char *utf8_to_str( const char *in ); -G_MODULE_EXPORT char *str_to_utf8( const char *in ); G_MODULE_EXPORT void strip_linefeed( gchar *text ); G_MODULE_EXPORT char *add_cr( char *text ); G_MODULE_EXPORT char *tobase64( const char *text ); G_MODULE_EXPORT char *normalize( const char *s ); G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec ); G_MODULE_EXPORT void strip_html( char *msg ); -G_MODULE_EXPORT char * escape_html(const char *html); +G_MODULE_EXPORT char *escape_html( const char *html ); G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value); +G_MODULE_EXPORT char *ipv6_wrap( char *src ); +G_MODULE_EXPORT char *ipv6_unwrap( char *src ); /* prefs.c */ G_MODULE_EXPORT void build_block_list(); diff --git a/protocols/oscar/Makefile b/protocols/oscar/Makefile index 5ef996a1..97a27299 100644 --- a/protocols/oscar/Makefile +++ b/protocols/oscar/Makefile @@ -15,7 +15,7 @@ CFLAGS += -Wall LFLAGS += -r # [SH] Phony targets -all: oscarr.o +all: oscar_mod.o .PHONY: all clean distclean @@ -32,6 +32,6 @@ $(objects): %.o: %.c @echo '*' Compiling $< @$(CC) -c $(CFLAGS) $< -o $@ -oscarr.o: $(objects) - @echo '*' Linking oscarr.o - @$(LD) $(LFLAGS) $(objects) -o oscarr.o +oscar_mod.o: $(objects) + @echo '*' Linking oscar_mod.o + @$(LD) $(LFLAGS) $(objects) -o oscar_mod.o diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 5f19f12b..b4bfb220 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -20,7 +20,6 @@ * */ -#include "sock.h" #include <errno.h> #include <ctype.h> #include <string.h> @@ -32,6 +31,7 @@ #include "nogaim.h" #include "bitlbee.h" #include "proxy.h" +#include "sock.h" #include "aim.h" #include "icq.h" diff --git a/protocols/proxy.c b/protocols/proxy.c index c658a163..1ca35dfe 100644 --- a/protocols/proxy.c +++ b/protocols/proxy.c @@ -105,8 +105,6 @@ static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpoin gaim_cond |= GAIM_INPUT_READ; if (condition & GAIM_WRITE_COND) gaim_cond |= GAIM_INPUT_WRITE; -// if (condition & GAIM_ERR_COND) -// fprintf( stderr, "ERROR! fd=%d\n", g_io_channel_unix_get_fd( source ) ); closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond); diff --git a/protocols/ssl_bogus.c b/protocols/ssl_bogus.c index 1ee0df4c..52406b75 100644 --- a/protocols/ssl_bogus.c +++ b/protocols/ssl_bogus.c @@ -27,7 +27,7 @@ int ssl_errno; -void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) +void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) { return( NULL ); } @@ -50,3 +50,8 @@ int ssl_getfd( void *conn ) { return( -1 ); } + +GaimInputCondition ssl_getdirection( void *conn ) +{ + return GAIM_INPUT_READ; +} diff --git a/protocols/ssl_client.h b/protocols/ssl_client.h index 719cd0c4..89189db9 100644 --- a/protocols/ssl_client.h +++ b/protocols/ssl_client.h @@ -32,10 +32,11 @@ extern int ssl_errno; -typedef void (*SslInputFunction)(gpointer, void*, GaimInputCondition); +typedef void (*ssl_input_function)(gpointer, void*, GaimInputCondition); -G_MODULE_EXPORT void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ); +G_MODULE_EXPORT void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ); G_MODULE_EXPORT int ssl_read( void *conn, char *buf, int len ); G_MODULE_EXPORT int ssl_write( void *conn, const char *buf, int len ); G_MODULE_EXPORT void ssl_disconnect( void *conn_ ); G_MODULE_EXPORT int ssl_getfd( void *conn ); +G_MODULE_EXPORT GaimInputCondition ssl_getdirection( void *conn ); diff --git a/protocols/ssl_gnutls.c b/protocols/ssl_gnutls.c index c2eb6906..f2cb3e08 100644 --- a/protocols/ssl_gnutls.c +++ b/protocols/ssl_gnutls.c @@ -37,7 +37,7 @@ static gboolean initialized = FALSE; struct scd { - SslInputFunction func; + ssl_input_function func; gpointer data; int fd; gboolean established; @@ -50,7 +50,7 @@ struct scd static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ); -void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) +void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) { struct scd *conn = g_new0( struct scd, 1 ); @@ -110,15 +110,16 @@ static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ) int st; if( conn->inpa != -1 ) + { gaim_input_remove( conn->inpa ); + conn->inpa = -1; + } if( ( st = gnutls_handshake( conn->session ) ) < 0 ) { if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED ) { - conn->inpa = gaim_input_add( conn->fd, - gnutls_record_get_direction( conn->session ) ? - GAIM_INPUT_WRITE : GAIM_INPUT_READ, + conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data ); } else @@ -144,31 +145,49 @@ static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ) int ssl_read( void *conn, char *buf, int len ) { + int st; + if( !((struct scd*)conn)->established ) { ssl_errno = SSL_NOHANDSHAKE; return( -1 ); } - return( gnutls_record_recv( ((struct scd*)conn)->session, buf, len ) ); + st = gnutls_record_recv( ((struct scd*)conn)->session, buf, len ); + ssl_errno = SSL_OK; + if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED ) + ssl_errno = SSL_AGAIN; + + return st; } int ssl_write( void *conn, const char *buf, int len ) { + int st; + if( !((struct scd*)conn)->established ) { ssl_errno = SSL_NOHANDSHAKE; return( -1 ); } - return( gnutls_record_send( ((struct scd*)conn)->session, buf, len ) ); + st = gnutls_record_send( ((struct scd*)conn)->session, buf, len ); + + ssl_errno = SSL_OK; + if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED ) + ssl_errno = SSL_AGAIN; + + return st; } void ssl_disconnect( void *conn_ ) { struct scd *conn = conn_; + if( conn->inpa != -1 ) + gaim_input_remove( conn->inpa ); + if( conn->established ) gnutls_bye( conn->session, GNUTLS_SHUT_WR ); @@ -183,3 +202,9 @@ int ssl_getfd( void *conn ) { return( ((struct scd*)conn)->fd ); } + +GaimInputCondition ssl_getdirection( void *conn ) +{ + return( gnutls_record_get_direction( ((struct scd*)conn)->session ) ? + GAIM_INPUT_WRITE : GAIM_INPUT_READ ); +} diff --git a/protocols/ssl_nss.c b/protocols/ssl_nss.c index d28983fc..dfd32622 100644 --- a/protocols/ssl_nss.c +++ b/protocols/ssl_nss.c @@ -44,7 +44,7 @@ static gboolean initialized = FALSE; struct scd { - SslInputFunction func; + ssl_input_function func; gpointer data; int fd; PRFileDesc *prfd; @@ -90,7 +90,7 @@ static SECStatus nss_bad_cert (void *arg, PRFileDesc *socket) } -void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) +void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) { struct scd *conn = g_new0( struct scd, 1 ); diff --git a/protocols/ssl_openssl.c b/protocols/ssl_openssl.c index bf87ab73..ae55f3f9 100644 --- a/protocols/ssl_openssl.c +++ b/protocols/ssl_openssl.c @@ -40,11 +40,13 @@ static gboolean initialized = FALSE; struct scd { - SslInputFunction func; + ssl_input_function func; gpointer data; int fd; gboolean established; + int inpa; + int lasterr; /* Necessary for SSL_get_error */ SSL *ssl; SSL_CTX *ssl_ctx; }; @@ -53,7 +55,7 @@ static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) -void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) +void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) { struct scd *conn = g_new0( struct scd, 1 ); SSL_METHOD *meth; @@ -92,19 +94,45 @@ void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) return( conn ); } +static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ); + static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) { struct scd *conn = data; if( source == -1 ) - goto ssl_connected_failure; + return ssl_handshake( data, -1, cond ); + /* Make it non-blocking at least during the handshake... */ + sock_make_nonblocking( conn->fd ); SSL_set_fd( conn->ssl, conn->fd ); - if( SSL_connect( conn->ssl ) < 0 ) - goto ssl_connected_failure; + return ssl_handshake( data, source, cond ); +} + +static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ) +{ + struct scd *conn = data; + int st; + + if( conn->inpa != -1 ) + { + gaim_input_remove( conn->inpa ); + conn->inpa = -1; + } + + if( ( st = SSL_connect( conn->ssl ) ) < 0 ) + { + conn->lasterr = SSL_get_error( conn->ssl, st ); + if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE ) + goto ssl_connected_failure; + + conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data ); + return; + } conn->established = TRUE; + sock_make_blocking( conn->fd ); /* For now... */ conn->func( conn->data, conn, cond ); return; @@ -126,24 +154,57 @@ ssl_connected_failure: int ssl_read( void *conn, char *buf, int len ) { + int st; + if( !((struct scd*)conn)->established ) - return( 0 ); + { + ssl_errno = SSL_NOHANDSHAKE; + return -1; + } + + st = SSL_read( ((struct scd*)conn)->ssl, buf, len ); - return( SSL_read( ((struct scd*)conn)->ssl, buf, len ) ); + ssl_errno = SSL_OK; + if( st <= 0 ) + { + ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); + if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) + ssl_errno = SSL_AGAIN; + } + + return st; } int ssl_write( void *conn, const char *buf, int len ) { + int st; + if( !((struct scd*)conn)->established ) - return( 0 ); + { + ssl_errno = SSL_NOHANDSHAKE; + return -1; + } + + st = SSL_write( ((struct scd*)conn)->ssl, buf, len ); - return( SSL_write( ((struct scd*)conn)->ssl, buf, len ) ); + ssl_errno = SSL_OK; + if( st <= 0 ) + { + ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); + if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) + ssl_errno = SSL_AGAIN; + } + + return st; } void ssl_disconnect( void *conn_ ) { struct scd *conn = conn_; + if( conn->inpa != -1 ) + gaim_input_remove( conn->inpa ); + if( conn->established ) SSL_shutdown( conn->ssl ); @@ -158,3 +219,8 @@ int ssl_getfd( void *conn ) { return( ((struct scd*)conn)->fd ); } + +GaimInputCondition ssl_getdirection( void *conn ) +{ + return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ ); +} diff --git a/protocols/yahoo/Makefile b/protocols/yahoo/Makefile index 39a655a3..e594cc1f 100644 --- a/protocols/yahoo/Makefile +++ b/protocols/yahoo/Makefile @@ -15,7 +15,7 @@ CFLAGS += -Wall -DSTDC_HEADERS -DHAVE_STRING_H -DHAVE_STRCHR -DHAVE_MEMCPY -DHAV LFLAGS += -r # [SH] Phony targets -all: yahooo.o +all: yahoo_mod.o .PHONY: all clean distclean @@ -32,6 +32,6 @@ $(objects): %.o: %.c @echo '*' Compiling $< @$(CC) -c $(CFLAGS) $< -o $@ -yahooo.o: $(objects) - @echo '*' Linking yahooo.o - @$(LD) $(LFLAGS) $(objects) -o yahooo.o +yahoo_mod.o: $(objects) + @echo '*' Linking yahoo_mod.o + @$(LD) $(LFLAGS) $(objects) -o yahoo_mod.o diff --git a/protocols/yahoo/yahoo_fn.c b/protocols/yahoo/yahoo_fn.c index 6f14c263..9544999d 100644 --- a/protocols/yahoo/yahoo_fn.c +++ b/protocols/yahoo/yahoo_fn.c @@ -24,7 +24,7 @@ #include "yahoo_fn.h" -unsigned char table_0[256] = { +static const unsigned char table_0[256] = { 0x5A, 0x41, 0x11, 0x77, 0x29, 0x9C, 0x31, 0xAD, 0x4A, 0x32, 0x1A, 0x6D, 0x56, 0x9F, 0x39, 0xA6, 0x0C, 0xE8, 0x49, 0x40, 0xA4, 0x21, 0xE9, 0x01, @@ -58,7 +58,7 @@ unsigned char table_0[256] = { 0x0E, 0x8B, 0xAA, 0x3A, 0xB4, 0xFC, 0xA9, 0x94, 0x7B, 0xBE, 0xF9, 0xAF, 0x82, 0x63, 0x47, 0x23 }; -unsigned char table_1[256] = { +static const unsigned char table_1[256] = { 0x08, 0xCB, 0x54, 0xCF, 0x97, 0x53, 0x59, 0xF1, 0x66, 0xEC, 0xDB, 0x1B, 0xB1, 0xE2, 0x36, 0xEB, 0xB3, 0x8F, 0x71, 0xA8, 0x90, 0x7D, 0xDA, 0xDC, @@ -92,13 +92,13 @@ unsigned char table_1[256] = { 0x39, 0x80, 0x98, 0xFA, 0x25, 0x92, 0x30, 0x5B, 0x05, 0x95, 0xBB, 0x79, 0x61, 0x3E, 0x81, 0xF7 }; -unsigned char table_2[32] = { +static const unsigned char table_2[32] = { 0x19, 0x05, 0x09, 0x1C, 0x0B, 0x1A, 0x12, 0x03, 0x06, 0x04, 0x0D, 0x1D, 0x15, 0x0E, 0x1B, 0x18, 0x00, 0x07, 0x08, 0x02, 0x13, 0x1F, 0x0C, 0x1E, 0x16, 0x0A, 0x10, 0x0F, 0x01, 0x14, 0x11, 0x17 }; -unsigned char table_3[256] = { +static const unsigned char table_3[256] = { 0xBC, 0x1B, 0xCC, 0x1E, 0x5B, 0x59, 0x4F, 0xA8, 0x62, 0xC6, 0xC1, 0xBB, 0x83, 0x2D, 0xA3, 0xA6, 0x5A, 0xDC, 0xE5, 0x93, 0xFB, 0x5C, 0xD6, 0x2A, @@ -132,13 +132,13 @@ unsigned char table_3[256] = { 0xEA, 0x49, 0x23, 0x4D, 0xB3, 0x8E, 0xC3, 0x1F, 0x7C, 0xEF, 0xE0, 0x99, 0x09, 0xA0, 0x01, 0x7E }; -unsigned char table_4[32] = { +static const unsigned char table_4[32] = { 0x1F, 0x0B, 0x00, 0x1E, 0x03, 0x0E, 0x15, 0x01, 0x1A, 0x17, 0x1D, 0x1B, 0x11, 0x0F, 0x0A, 0x12, 0x13, 0x18, 0x02, 0x04, 0x09, 0x06, 0x0D, 0x07, 0x08, 0x05, 0x10, 0x19, 0x0C, 0x14, 0x16, 0x1C }; -unsigned char table_5[256] = { +static const unsigned char table_5[256] = { 0x9A, 0xAB, 0x61, 0x28, 0x0A, 0x23, 0xFC, 0xBA, 0x90, 0x22, 0xB7, 0x62, 0xD9, 0x09, 0x91, 0xF4, 0x7B, 0x5D, 0x6B, 0x80, 0xAC, 0x9E, 0x21, 0x72, @@ -172,13 +172,13 @@ unsigned char table_5[256] = { 0xDC, 0x0B, 0xCF, 0x31, 0xEA, 0xB2, 0x70, 0x4B, 0x46, 0x73, 0x69, 0xD5, 0x10, 0xEE, 0x02, 0xEF }; -unsigned char table_6[32] = { +static const unsigned char table_6[32] = { 0x1A, 0x1C, 0x0F, 0x0C, 0x00, 0x02, 0x13, 0x09, 0x11, 0x05, 0x0D, 0x12, 0x18, 0x0B, 0x04, 0x10, 0x14, 0x1B, 0x1E, 0x16, 0x07, 0x08, 0x03, 0x17, 0x19, 0x1F, 0x01, 0x0E, 0x15, 0x06, 0x0A, 0x1D }; -unsigned char table_7[256] = { +static const unsigned char table_7[256] = { 0x52, 0x11, 0x72, 0xD0, 0x76, 0xD7, 0xAE, 0x03, 0x7F, 0x19, 0xF4, 0xB8, 0xB3, 0x5D, 0xCA, 0x2D, 0x5C, 0x30, 0x53, 0x1A, 0x57, 0xF6, 0xAD, 0x83, @@ -212,13 +212,13 @@ unsigned char table_7[256] = { 0x36, 0xE6, 0x78, 0x4F, 0xC9, 0xE9, 0x2C, 0x43, 0x88, 0x9E, 0x9C, 0x5B, 0x4D, 0x3A, 0x39, 0xEF }; -unsigned char table_8[32] = { +static const unsigned char table_8[32] = { 0x13, 0x08, 0x1E, 0x1D, 0x17, 0x16, 0x07, 0x1F, 0x0E, 0x03, 0x1A, 0x19, 0x01, 0x12, 0x11, 0x10, 0x09, 0x0C, 0x0F, 0x14, 0x0B, 0x05, 0x00, 0x04, 0x1C, 0x18, 0x0A, 0x15, 0x02, 0x1B, 0x06, 0x0D }; -unsigned char table_9[256] = { +static const unsigned char table_9[256] = { 0x20, 0x2A, 0xDA, 0xFE, 0x76, 0x0D, 0xED, 0x39, 0x51, 0x4C, 0x46, 0x9A, 0xF1, 0xB0, 0x10, 0xC7, 0xD1, 0x6F, 0x18, 0x24, 0xB9, 0x7A, 0x4F, 0x47, @@ -252,13 +252,13 @@ unsigned char table_9[256] = { 0xEF, 0xB7, 0x31, 0xD0, 0xBF, 0x3A, 0x79, 0xE5, 0xF9, 0xF0, 0x2C, 0x74, 0xE9, 0x71, 0xC0, 0x2D }; -unsigned char table_10[32] = { +static const unsigned char table_10[32] = { 0x1D, 0x12, 0x11, 0x0D, 0x1E, 0x19, 0x16, 0x1B, 0x18, 0x13, 0x07, 0x17, 0x0C, 0x02, 0x00, 0x15, 0x0E, 0x08, 0x05, 0x01, 0x10, 0x06, 0x04, 0x0F, 0x1F, 0x1A, 0x0B, 0x09, 0x0A, 0x14, 0x1C, 0x03 }; -unsigned char table_11[256] = { +static const unsigned char table_11[256] = { 0x6B, 0x1D, 0xC6, 0x0A, 0xB7, 0xAC, 0xB2, 0x11, 0x29, 0xD3, 0xA2, 0x4D, 0xCB, 0x03, 0xEF, 0xA6, 0xC1, 0x5D, 0x75, 0x48, 0x35, 0x6C, 0xE2, 0x84, @@ -292,13 +292,13 @@ unsigned char table_11[256] = { 0xBF, 0xC7, 0x20, 0x7E, 0x6A, 0xC5, 0x88, 0xFC, 0x64, 0x76, 0xFF, 0x9F, 0x2E, 0x02, 0xCC, 0x57 }; -unsigned char table_12[32] = { +static const unsigned char table_12[32] = { 0x14, 0x1B, 0x18, 0x00, 0x1F, 0x15, 0x17, 0x07, 0x11, 0x1A, 0x0E, 0x13, 0x12, 0x06, 0x01, 0x03, 0x1C, 0x0C, 0x0B, 0x1D, 0x10, 0x0F, 0x09, 0x19, 0x0D, 0x1E, 0x04, 0x05, 0x08, 0x16, 0x0A, 0x02 }; -unsigned char table_13[256] = { +static const unsigned char table_13[256] = { 0x37, 0x8A, 0x1B, 0x91, 0xA5, 0x2B, 0x2D, 0x88, 0x8E, 0xFE, 0x0E, 0xD3, 0xF3, 0xE9, 0x7D, 0xD1, 0x24, 0xEA, 0xB1, 0x8B, 0x5C, 0xA4, 0x44, 0x7E, @@ -332,13 +332,13 @@ unsigned char table_13[256] = { 0x75, 0x93, 0x9F, 0x3A, 0x07, 0xE5, 0x89, 0xDF, 0x97, 0x4A, 0xB8, 0x7A, 0xF4, 0xFB, 0x04, 0xA8 }; -unsigned char table_14[32] = { +static const unsigned char table_14[32] = { 0x04, 0x14, 0x13, 0x15, 0x1A, 0x1B, 0x0F, 0x16, 0x02, 0x0D, 0x0C, 0x06, 0x10, 0x17, 0x01, 0x0B, 0x1E, 0x08, 0x1C, 0x18, 0x19, 0x0A, 0x1F, 0x05, 0x11, 0x09, 0x1D, 0x07, 0x0E, 0x12, 0x03, 0x00 }; -unsigned char table_15[256] = { +static const unsigned char table_15[256] = { 0x61, 0x48, 0x58, 0x41, 0x7F, 0x88, 0x43, 0x42, 0xD9, 0x80, 0x81, 0xFE, 0xC6, 0x49, 0xD7, 0x2C, 0xE6, 0x5B, 0xEE, 0xFF, 0x2A, 0x6F, 0xBF, 0x98, @@ -372,7 +372,7 @@ unsigned char table_15[256] = { 0xA1, 0x35, 0xAE, 0xB6, 0x10, 0x5C, 0x17, 0xBC, 0xAB, 0x8D, 0x02, 0x74, 0xBD, 0x3D, 0x8E, 0xDD }; -unsigned char table_16[256] = { +static const unsigned char table_16[256] = { 0x3F, 0x9C, 0x17, 0xC1, 0x59, 0xC6, 0x23, 0x93, 0x4B, 0xDF, 0xCB, 0x55, 0x2B, 0xDE, 0xCD, 0xAD, 0xB3, 0xE7, 0x42, 0x2F, 0x02, 0x5A, 0x7B, 0x5C, @@ -406,7 +406,7 @@ unsigned char table_16[256] = { 0x70, 0xDA, 0x7E, 0x47, 0x94, 0x61, 0xB0, 0x78, 0xF4, 0xBE, 0xEA, 0x19, 0x43, 0x01, 0xB1, 0x96 }; -unsigned char table_17[256] = { +static const unsigned char table_17[256] = { 0x7E, 0xF1, 0xD3, 0x75, 0x87, 0xA6, 0xED, 0x9E, 0xA9, 0xD5, 0xC6, 0xBF, 0xE6, 0x6A, 0xEE, 0x4B, 0x34, 0xDF, 0x4C, 0x7D, 0xDD, 0xFE, 0x3F, 0xAF, @@ -440,7 +440,7 @@ unsigned char table_17[256] = { 0xCA, 0x83, 0x26, 0x5C, 0xA5, 0x44, 0x64, 0x6D, 0x9F, 0x99, 0x62, 0xAA, 0xFA, 0x11, 0x0C, 0x52 }; -unsigned char table_18[256] = { +static const unsigned char table_18[256] = { 0x0F, 0x42, 0x3D, 0x86, 0x3E, 0x66, 0xFE, 0x5C, 0x52, 0xE2, 0xA3, 0xB3, 0xCE, 0x16, 0xCC, 0x95, 0xB0, 0x8B, 0x82, 0x3B, 0x93, 0x7D, 0x62, 0x08, @@ -474,7 +474,7 @@ unsigned char table_18[256] = { 0xF4, 0xBD, 0xA4, 0x29, 0x60, 0x03, 0xB9, 0x50, 0xFA, 0x4E, 0xEF, 0x54, 0xE6, 0x7F, 0xC0, 0x67 }; -unsigned char table_19[256] = { +static const unsigned char table_19[256] = { 0xEA, 0xE7, 0x13, 0x14, 0xB9, 0xC0, 0xC4, 0x42, 0x49, 0x6E, 0x2A, 0xA6, 0x65, 0x3C, 0x6A, 0x40, 0x07, 0xCD, 0x4F, 0xFE, 0xF2, 0x2D, 0xC8, 0x30, @@ -508,13 +508,13 @@ unsigned char table_19[256] = { 0xFD, 0x1F, 0xDE, 0x53, 0xA3, 0x2C, 0x20, 0xF6, 0x1E, 0x0D, 0xAE, 0x7B, 0x5E, 0x61, 0xE9, 0x63 }; -unsigned char table_20[32] = { +static const unsigned char table_20[32] = { 0x0D, 0x0B, 0x11, 0x02, 0x05, 0x1B, 0x08, 0x1D, 0x04, 0x14, 0x01, 0x09, 0x00, 0x19, 0x1E, 0x15, 0x1F, 0x0A, 0x0F, 0x1C, 0x10, 0x16, 0x0C, 0x07, 0x13, 0x1A, 0x06, 0x17, 0x0E, 0x12, 0x18, 0x03 }; -unsigned char table_21[256] = { +static const unsigned char table_21[256] = { 0x4C, 0x94, 0xAD, 0x66, 0x9E, 0x69, 0x04, 0xA8, 0x61, 0xE0, 0xE1, 0x3D, 0xFD, 0x9C, 0xFB, 0x19, 0x1E, 0x80, 0x8C, 0xA0, 0xFC, 0x27, 0x26, 0x3B, @@ -548,13 +548,13 @@ unsigned char table_21[256] = { 0x56, 0xBA, 0x86, 0x28, 0x6A, 0x20, 0x51, 0xF7, 0xFF, 0xD8, 0xE7, 0xDD, 0xBB, 0x78, 0xD5, 0x81 }; -unsigned char table_22[32] = { +static const unsigned char table_22[32] = { 0x0B, 0x15, 0x1C, 0x0C, 0x06, 0x0A, 0x1D, 0x16, 0x12, 0x0E, 0x04, 0x11, 0x1F, 0x0F, 0x07, 0x02, 0x17, 0x13, 0x19, 0x18, 0x0D, 0x10, 0x1A, 0x05, 0x03, 0x00, 0x01, 0x08, 0x09, 0x14, 0x1B, 0x1E }; -unsigned char table_23[256] = { +static const unsigned char table_23[256] = { 0x36, 0x53, 0x2D, 0xD0, 0x7A, 0xF0, 0xD5, 0x1C, 0x50, 0x61, 0x9A, 0x90, 0x0B, 0x29, 0x20, 0x77, 0xF1, 0x82, 0xFE, 0xC1, 0xA7, 0xB6, 0x78, 0x87, @@ -588,7 +588,7 @@ unsigned char table_23[256] = { 0xA4, 0xBE, 0x96, 0x5E, 0x97, 0xD3, 0xA5, 0x55, 0x1D, 0x15, 0xC6, 0xBF, 0xA9, 0x43, 0xC0, 0x49 }; -unsigned char table_24[256] = { +static const unsigned char table_24[256] = { 0xDC, 0x5A, 0xE6, 0x59, 0x64, 0xDA, 0x58, 0x40, 0x95, 0xF8, 0x2A, 0xE0, 0x39, 0x7E, 0x32, 0x89, 0x09, 0x93, 0xED, 0x55, 0xC3, 0x5B, 0x1A, 0xD1, @@ -622,19 +622,19 @@ unsigned char table_24[256] = { 0xCD, 0x20, 0x74, 0x08, 0x1D, 0xC4, 0xF9, 0x4D, 0xEA, 0x8D, 0x2D, 0x5F, 0xF6, 0xA7, 0x80, 0x3A }; -unsigned char table_25[32] = { +static const unsigned char table_25[32] = { 0x0A, 0x11, 0x17, 0x03, 0x05, 0x0B, 0x18, 0x13, 0x09, 0x02, 0x00, 0x1C, 0x0C, 0x08, 0x1B, 0x14, 0x06, 0x0E, 0x01, 0x0D, 0x16, 0x1E, 0x1D, 0x19, 0x0F, 0x1A, 0x10, 0x04, 0x12, 0x15, 0x07, 0x1F }; -unsigned char table_26[32] = { +static const unsigned char table_26[32] = { 0x19, 0x13, 0x1B, 0x01, 0x1C, 0x0D, 0x0C, 0x15, 0x0B, 0x00, 0x1A, 0x0F, 0x12, 0x16, 0x08, 0x0A, 0x03, 0x06, 0x14, 0x10, 0x18, 0x04, 0x11, 0x1D, 0x1F, 0x07, 0x17, 0x05, 0x02, 0x0E, 0x1E, 0x09 }; -unsigned char table_27[256] = { +static const unsigned char table_27[256] = { 0x72, 0xF0, 0x14, 0xCB, 0x61, 0xA5, 0xB2, 0x02, 0x75, 0x22, 0xC3, 0x9D, 0x5A, 0x63, 0xFA, 0x5F, 0xD9, 0x55, 0x58, 0x43, 0x24, 0x7D, 0x77, 0x93, @@ -668,13 +668,13 @@ unsigned char table_27[256] = { 0x4E, 0xB9, 0x66, 0xF2, 0x62, 0x36, 0x4C, 0x83, 0x5E, 0x6F, 0x47, 0x64, 0xBC, 0x9A, 0x60, 0x7E }; -unsigned char table_28[32] = { +static const unsigned char table_28[32] = { 0x15, 0x05, 0x08, 0x19, 0x02, 0x18, 0x1E, 0x07, 0x0D, 0x0C, 0x1A, 0x06, 0x17, 0x03, 0x10, 0x09, 0x01, 0x11, 0x1C, 0x04, 0x0F, 0x1F, 0x12, 0x0B, 0x1B, 0x13, 0x0A, 0x16, 0x0E, 0x00, 0x1D, 0x14 }; -unsigned char table_29[256] = { +static const unsigned char table_29[256] = { 0x34, 0x59, 0x05, 0x13, 0x09, 0x1D, 0xDF, 0x77, 0x11, 0xA5, 0x92, 0x27, 0xCD, 0x7B, 0x5E, 0x80, 0xF9, 0x50, 0x18, 0x24, 0xD4, 0x70, 0x4A, 0x39, @@ -708,13 +708,13 @@ unsigned char table_29[256] = { 0xD6, 0x60, 0x76, 0x55, 0x0B, 0x4E, 0xFF, 0x1A, 0x46, 0x62, 0xB6, 0xB0, 0x15, 0x04, 0x95, 0x4D }; -unsigned char table_30[32] = { +static const unsigned char table_30[32] = { 0x00, 0x1C, 0x0E, 0x0C, 0x06, 0x16, 0x09, 0x12, 0x01, 0x13, 0x0B, 0x14, 0x11, 0x08, 0x04, 0x18, 0x10, 0x1B, 0x15, 0x03, 0x02, 0x19, 0x1A, 0x17, 0x1E, 0x1F, 0x0F, 0x07, 0x0D, 0x05, 0x1D, 0x0A }; -unsigned char table_31[256] = { +static const unsigned char table_31[256] = { 0xDF, 0xD8, 0x3F, 0xBC, 0x5F, 0xC9, 0x8E, 0x4C, 0x0B, 0x3C, 0xE5, 0xBF, 0x39, 0xD5, 0x30, 0xDD, 0x23, 0xC7, 0x72, 0x63, 0x1F, 0xF8, 0x96, 0x31, @@ -748,7 +748,7 @@ unsigned char table_31[256] = { 0x6F, 0x07, 0xE9, 0xEE, 0x21, 0x98, 0x5A, 0xC5, 0x92, 0x48, 0xF7, 0x0A, 0xF6, 0xE2, 0x4B, 0x56 }; -unsigned char table_32[256] = { +static const unsigned char table_32[256] = { 0x7B, 0x0F, 0x56, 0x2F, 0x1E, 0x2A, 0x7A, 0xD1, 0x02, 0x91, 0x4E, 0x37, 0x6C, 0x10, 0xA7, 0xF2, 0x38, 0xAC, 0x9E, 0x2B, 0x5E, 0x23, 0xE3, 0x19, @@ -782,7 +782,7 @@ unsigned char table_32[256] = { 0x81, 0x4C, 0x0B, 0x3F, 0xB7, 0x0E, 0x39, 0xAE, 0x47, 0x6B, 0x8A, 0xA2, 0x9A, 0xA3, 0x45, 0x41 }; -unsigned char table_33[256] = { +static const unsigned char table_33[256] = { 0xDE, 0xD3, 0x79, 0x67, 0x13, 0x5C, 0x04, 0xF2, 0xD9, 0x9F, 0x65, 0x56, 0xCC, 0x3B, 0xA4, 0x9A, 0x08, 0xBF, 0x26, 0xB2, 0xA7, 0x5E, 0xAA, 0xCA, @@ -816,7 +816,7 @@ unsigned char table_33[256] = { 0xF3, 0xE9, 0x91, 0x63, 0xA5, 0xB9, 0xE8, 0x14, 0x80, 0x3C, 0xEE, 0x47, 0xC6, 0x3A, 0x53, 0xF6 }; -unsigned char table_34[256] = { +static const unsigned char table_34[256] = { 0xF0, 0xE9, 0x3E, 0xD6, 0x89, 0xC8, 0xC7, 0x23, 0x75, 0x26, 0x5F, 0x9C, 0x57, 0xB8, 0x2A, 0x29, 0xE5, 0xB5, 0x68, 0xA4, 0x92, 0x46, 0x40, 0x7F, @@ -850,7 +850,7 @@ unsigned char table_34[256] = { 0xF3, 0x7D, 0xC6, 0xCE, 0x8A, 0xB2, 0x33, 0x4C, 0x03, 0x05, 0xBF, 0x06, 0x1B, 0xC0, 0x1A, 0x60 }; -unsigned char table_35[256] = { +static const unsigned char table_35[256] = { 0xCC, 0x40, 0xEF, 0x1F, 0xDB, 0xE5, 0x71, 0x51, 0x3B, 0x0F, 0x7D, 0x9C, 0x83, 0x17, 0x6F, 0x8F, 0x13, 0xDC, 0x7F, 0xA9, 0xA5, 0xA2, 0x9D, 0xDF, @@ -884,7 +884,7 @@ unsigned char table_35[256] = { 0x7C, 0x8D, 0x72, 0x0B, 0x52, 0xE8, 0xA7, 0x3A, 0x59, 0xC4, 0x9F, 0xD0, 0x66, 0x7B, 0x33, 0xB5 }; -unsigned char table_36[256] = { +static const unsigned char table_36[256] = { 0xDB, 0x6F, 0xFE, 0xB3, 0x5C, 0x1F, 0xB8, 0xBF, 0xA3, 0x71, 0x11, 0x56, 0x90, 0xE2, 0x63, 0x18, 0x83, 0x51, 0x21, 0xEB, 0x66, 0x08, 0xA6, 0xA5, @@ -918,7 +918,7 @@ unsigned char table_36[256] = { 0x74, 0xA0, 0x73, 0x5A, 0x2A, 0x98, 0x75, 0x47, 0x4B, 0xB6, 0x7B, 0x4D, 0xCF, 0x7E, 0x48, 0xE3 }; -unsigned char table_37[256] = { +static const unsigned char table_37[256] = { 0x1F, 0xD6, 0xB1, 0xB3, 0x40, 0xAD, 0xDE, 0xB7, 0x19, 0xB4, 0xE7, 0x0B, 0x9C, 0x2D, 0xE0, 0xF5, 0xCF, 0x2C, 0x30, 0x65, 0x2F, 0xCD, 0x02, 0x91, @@ -952,7 +952,7 @@ unsigned char table_37[256] = { 0x98, 0x9F, 0x23, 0xD1, 0x6B, 0x59, 0x3E, 0xCA, 0x73, 0xC8, 0x86, 0x47, 0xDB, 0xAB, 0x6F, 0x8C }; -unsigned char table_38[256] = { +static const unsigned char table_38[256] = { 0xAA, 0x8D, 0x37, 0x94, 0x99, 0xDD, 0x70, 0x77, 0x78, 0xC9, 0x0F, 0xFA, 0xE2, 0x05, 0xC2, 0x16, 0x02, 0x4D, 0x44, 0x65, 0xAC, 0xB0, 0x39, 0xF8, @@ -986,31 +986,31 @@ unsigned char table_38[256] = { 0x89, 0x58, 0x79, 0xFB, 0x6E, 0xA5, 0x42, 0x25, 0x09, 0x76, 0x00, 0x46, 0x4E, 0x53, 0xCE, 0x4A }; -unsigned char table_39[32] = { +static const unsigned char table_39[32] = { 0x12, 0x18, 0x0E, 0x08, 0x16, 0x05, 0x06, 0x00, 0x11, 0x17, 0x15, 0x1B, 0x14, 0x01, 0x1F, 0x19, 0x04, 0x0D, 0x0A, 0x0F, 0x10, 0x07, 0x1D, 0x03, 0x0B, 0x13, 0x0C, 0x09, 0x1E, 0x02, 0x1A, 0x1C }; -unsigned char table_40[32] = { +static const unsigned char table_40[32] = { 0x16, 0x02, 0x06, 0x0E, 0x0D, 0x1C, 0x08, 0x0A, 0x0F, 0x13, 0x0B, 0x18, 0x07, 0x04, 0x14, 0x01, 0x1B, 0x05, 0x17, 0x1E, 0x11, 0x1A, 0x10, 0x1F, 0x12, 0x19, 0x1D, 0x03, 0x0C, 0x00, 0x09, 0x15 }; -unsigned char table_41[32] = { +static const unsigned char table_41[32] = { 0x13, 0x18, 0x04, 0x1F, 0x1D, 0x11, 0x03, 0x00, 0x10, 0x12, 0x06, 0x0A, 0x1C, 0x07, 0x15, 0x0E, 0x08, 0x05, 0x0C, 0x09, 0x01, 0x02, 0x16, 0x0B, 0x1A, 0x17, 0x14, 0x1E, 0x0D, 0x0F, 0x19, 0x1B }; -unsigned char table_42[32] = { +static const unsigned char table_42[32] = { 0x00, 0x08, 0x15, 0x1D, 0x05, 0x18, 0x06, 0x07, 0x1F, 0x01, 0x0B, 0x03, 0x19, 0x13, 0x02, 0x1C, 0x17, 0x11, 0x0E, 0x1E, 0x0C, 0x0F, 0x09, 0x1A, 0x1B, 0x16, 0x10, 0x0D, 0x0A, 0x14, 0x12, 0x04 }; -unsigned char table_43[256] = { +static const unsigned char table_43[256] = { 0x34, 0xB7, 0x36, 0x85, 0x5F, 0x93, 0x98, 0x70, 0x1E, 0x59, 0x83, 0x60, 0x6F, 0xBF, 0xF9, 0xD0, 0xB3, 0x22, 0x12, 0x38, 0xF5, 0x01, 0xC9, 0x5B, @@ -1044,13 +1044,13 @@ unsigned char table_43[256] = { 0x0A, 0x69, 0xC5, 0xA5, 0xC1, 0x8A, 0x2A, 0xEE, 0x73, 0x76, 0x3A, 0x21, 0x53, 0xA4, 0x50, 0x6A }; -unsigned char table_44[32] = { +static const unsigned char table_44[32] = { 0x1A, 0x0E, 0x0A, 0x17, 0x1F, 0x08, 0x10, 0x14, 0x0C, 0x0F, 0x09, 0x1C, 0x06, 0x18, 0x1E, 0x12, 0x15, 0x00, 0x11, 0x13, 0x0D, 0x01, 0x0B, 0x03, 0x16, 0x19, 0x05, 0x1D, 0x02, 0x07, 0x04, 0x1B }; -unsigned char table_45[256] = { +static const unsigned char table_45[256] = { 0x5E, 0xD6, 0xE2, 0x54, 0x35, 0xC2, 0xAC, 0x9D, 0x92, 0x64, 0x57, 0x65, 0xC8, 0xAE, 0x21, 0xA9, 0x89, 0x48, 0x12, 0x59, 0xEC, 0xEF, 0x9F, 0xF7, @@ -1084,7 +1084,7 @@ unsigned char table_45[256] = { 0xD8, 0xE4, 0xC4, 0xA8, 0x4B, 0x61, 0x2E, 0x3D, 0xF9, 0x2B, 0x32, 0x8F, 0xFB, 0xC7, 0x07, 0x82 }; -unsigned char table_46[256] = { +static const unsigned char table_46[256] = { 0x85, 0x78, 0xFE, 0x6C, 0x61, 0xA0, 0x71, 0xCC, 0x45, 0x54, 0x7A, 0xE6, 0x82, 0x1D, 0xA6, 0x02, 0x47, 0xD0, 0x23, 0x55, 0x62, 0xFA, 0x76, 0x3E, @@ -1118,37 +1118,37 @@ unsigned char table_46[256] = { 0x8B, 0x42, 0x29, 0x8C, 0x33, 0x59, 0xE8, 0xF8, 0xC7, 0xE4, 0x37, 0xE5, 0xFC, 0xBD, 0x99, 0x41 }; -unsigned char table_47[32] = { +static const unsigned char table_47[32] = { 0x18, 0x1D, 0x16, 0x10, 0x11, 0x04, 0x1E, 0x08, 0x19, 0x0E, 0x0F, 0x02, 0x14, 0x1C, 0x07, 0x17, 0x0D, 0x09, 0x12, 0x1A, 0x05, 0x01, 0x0B, 0x0A, 0x13, 0x15, 0x0C, 0x00, 0x06, 0x1F, 0x03, 0x1B }; -unsigned char table_48[32] = { +static const unsigned char table_48[32] = { 0x13, 0x08, 0x15, 0x01, 0x17, 0x10, 0x0F, 0x1F, 0x1D, 0x0D, 0x12, 0x03, 0x06, 0x0A, 0x1C, 0x19, 0x1A, 0x04, 0x1B, 0x02, 0x16, 0x1E, 0x11, 0x00, 0x14, 0x09, 0x0C, 0x18, 0x05, 0x07, 0x0E, 0x0B }; -unsigned char table_49[32] = { +static const unsigned char table_49[32] = { 0x1F, 0x0F, 0x19, 0x07, 0x18, 0x05, 0x1E, 0x1D, 0x15, 0x08, 0x17, 0x10, 0x0A, 0x0E, 0x0C, 0x1B, 0x02, 0x13, 0x03, 0x0D, 0x04, 0x1A, 0x06, 0x09, 0x12, 0x1C, 0x0B, 0x16, 0x14, 0x01, 0x11, 0x00 }; -unsigned char table_50[32] = { +static const unsigned char table_50[32] = { 0x16, 0x18, 0x1C, 0x0E, 0x12, 0x00, 0x04, 0x1B, 0x1F, 0x13, 0x17, 0x0A, 0x1E, 0x03, 0x0C, 0x01, 0x0F, 0x10, 0x02, 0x08, 0x14, 0x09, 0x19, 0x15, 0x06, 0x0D, 0x0B, 0x1D, 0x05, 0x07, 0x11, 0x1A }; -unsigned char table_51[32] = { +static const unsigned char table_51[32] = { 0x1C, 0x0D, 0x1B, 0x07, 0x17, 0x0E, 0x06, 0x01, 0x12, 0x19, 0x03, 0x0B, 0x10, 0x08, 0x00, 0x1E, 0x0A, 0x04, 0x1A, 0x1D, 0x0C, 0x18, 0x02, 0x13, 0x0F, 0x11, 0x05, 0x09, 0x15, 0x16, 0x1F, 0x14 }; -unsigned char table_52[256] = { +static const unsigned char table_52[256] = { 0x34, 0x0B, 0x47, 0xA3, 0x56, 0x30, 0x73, 0xD4, 0x4B, 0xF6, 0xA6, 0x80, 0x22, 0x95, 0xA5, 0xBB, 0xFE, 0xCD, 0x27, 0x88, 0x87, 0x18, 0x86, 0x6E, @@ -1182,7 +1182,7 @@ unsigned char table_52[256] = { 0x9B, 0xC2, 0x38, 0xD0, 0xEE, 0x81, 0x46, 0xE2, 0x01, 0x0C, 0x5D, 0x7D, 0xB8, 0xBE, 0x6A, 0x16 }; -unsigned char table_53[256] = { +static const unsigned char table_53[256] = { 0xE3, 0xF4, 0x8D, 0x72, 0x45, 0x32, 0x9D, 0xCE, 0x1F, 0x6B, 0xBC, 0xDC, 0xF1, 0xEC, 0x5A, 0x3B, 0xA5, 0xA2, 0x2B, 0xDD, 0x8A, 0xA3, 0x76, 0xE4, @@ -1216,19 +1216,19 @@ unsigned char table_53[256] = { 0x39, 0x6A, 0xC8, 0xA0, 0xB2, 0xC1, 0x84, 0xFC, 0xAB, 0x64, 0xE0, 0xBE, 0xDA, 0xBD, 0x96, 0x94 }; -unsigned char table_54[32] = { +static const unsigned char table_54[32] = { 0x01, 0x02, 0x1D, 0x10, 0x0E, 0x11, 0x08, 0x14, 0x12, 0x09, 0x15, 0x17, 0x16, 0x04, 0x06, 0x1B, 0x07, 0x1A, 0x18, 0x13, 0x0A, 0x1E, 0x1C, 0x1F, 0x0C, 0x0B, 0x0D, 0x05, 0x0F, 0x00, 0x19, 0x03 }; -unsigned char table_55[32] = { +static const unsigned char table_55[32] = { 0x01, 0x12, 0x13, 0x09, 0x0B, 0x19, 0x03, 0x0E, 0x02, 0x1F, 0x1D, 0x1B, 0x1E, 0x11, 0x06, 0x05, 0x00, 0x16, 0x07, 0x0C, 0x15, 0x0D, 0x1A, 0x08, 0x18, 0x10, 0x0F, 0x17, 0x1C, 0x0A, 0x04, 0x14 }; -unsigned char table_56[256] = { +static const unsigned char table_56[256] = { 0xEF, 0x06, 0x5F, 0x11, 0x4B, 0x60, 0x13, 0xBB, 0x79, 0xD7, 0xE4, 0x6D, 0x22, 0xB4, 0x15, 0x50, 0x29, 0x17, 0xD2, 0xE3, 0x37, 0x8C, 0x46, 0x7C, @@ -1262,7 +1262,7 @@ unsigned char table_56[256] = { 0x67, 0xA4, 0x55, 0x10, 0x0F, 0xD9, 0x52, 0x32, 0x96, 0xD5, 0xEB, 0x64, 0x8A, 0xC8, 0x7A, 0xBE }; -unsigned char table_57[256] = { +static const unsigned char table_57[256] = { 0xD1, 0x9B, 0x15, 0x06, 0xB4, 0xF6, 0x97, 0xF0, 0xC6, 0x5B, 0x88, 0x12, 0x25, 0xFA, 0x7B, 0x79, 0xD6, 0xAB, 0xDC, 0x47, 0x85, 0x61, 0x67, 0x0B, @@ -1296,7 +1296,7 @@ unsigned char table_57[256] = { 0x75, 0x02, 0x2B, 0x92, 0x21, 0x7D, 0xF5, 0x5E, 0x4E, 0x3C, 0x84, 0x14, 0x28, 0x3A, 0xE9, 0xC0 }; -unsigned char table_58[256] = { +static const unsigned char table_58[256] = { 0xE9, 0x81, 0x60, 0xA7, 0x18, 0xA0, 0x0F, 0x55, 0x2B, 0x52, 0xE0, 0x8B, 0x9D, 0x85, 0xD2, 0xA3, 0x3F, 0x6E, 0xB1, 0xAF, 0xE3, 0x36, 0xE2, 0x19, @@ -1330,7 +1330,7 @@ unsigned char table_58[256] = { 0xF1, 0xC8, 0x9F, 0xED, 0x50, 0x20, 0x15, 0x11, 0x68, 0x1E, 0xF6, 0xA6, 0x6C, 0xB2, 0xD1, 0x58 }; -unsigned char table_59[256] = { +static const unsigned char table_59[256] = { 0x4C, 0x85, 0x2B, 0x14, 0xCC, 0x4D, 0x5F, 0xD7, 0xCE, 0x28, 0xC5, 0x0B, 0xA1, 0x99, 0x08, 0xDE, 0x42, 0xD1, 0x82, 0x5C, 0xC9, 0x8F, 0x72, 0x12, @@ -1364,13 +1364,13 @@ unsigned char table_59[256] = { 0x0C, 0x46, 0xBD, 0xE9, 0x68, 0x18, 0xAB, 0x2E, 0x5D, 0x1A, 0x8D, 0xC1, 0x58, 0x48, 0xAD, 0x0F }; -unsigned char table_60[32] = { +static const unsigned char table_60[32] = { 0x1C, 0x06, 0x1E, 0x10, 0x1D, 0x05, 0x00, 0x0E, 0x0C, 0x02, 0x11, 0x19, 0x15, 0x18, 0x16, 0x07, 0x1F, 0x0B, 0x14, 0x01, 0x0F, 0x09, 0x0D, 0x13, 0x03, 0x08, 0x12, 0x04, 0x1B, 0x0A, 0x17, 0x1A }; -unsigned char table_61[256] = { +static const unsigned char table_61[256] = { 0xC5, 0xA6, 0xF2, 0x6B, 0x4B, 0x58, 0xE0, 0x41, 0xC6, 0x2F, 0x13, 0xFE, 0xC1, 0x34, 0x3F, 0x24, 0x10, 0xBF, 0x8B, 0xC9, 0x26, 0x2E, 0x68, 0xBE, @@ -1404,7 +1404,7 @@ unsigned char table_61[256] = { 0xA9, 0x1F, 0x06, 0x27, 0xC7, 0x04, 0xE2, 0xBA, 0xCF, 0x60, 0xAA, 0xA4, 0xEB, 0xC4, 0x4E, 0xC2 }; -unsigned char table_62[256] = { +static const unsigned char table_62[256] = { 0x01, 0x59, 0xEC, 0xFC, 0x51, 0xD2, 0xE4, 0x9D, 0xAA, 0x61, 0xD5, 0xCA, 0x63, 0x5D, 0xCE, 0x36, 0xB9, 0x49, 0x76, 0xA9, 0x14, 0x4C, 0x90, 0x28, @@ -1438,7 +1438,7 @@ unsigned char table_62[256] = { 0x35, 0xDF, 0xEF, 0xA7, 0x7F, 0x24, 0xF8, 0xE3, 0xCF, 0xE9, 0xDB, 0xD3, 0x02, 0x9A, 0x0E, 0x5F }; -unsigned char table_63[256] = { +static const unsigned char table_63[256] = { 0x0C, 0x02, 0xEE, 0x94, 0x2D, 0x76, 0x96, 0x75, 0x21, 0xDC, 0x37, 0x03, 0xC0, 0xF7, 0xDF, 0xEF, 0xB1, 0x1D, 0xCF, 0x15, 0x5A, 0xB4, 0xCC, 0x81, @@ -1472,25 +1472,25 @@ unsigned char table_63[256] = { 0x1C, 0x55, 0x6F, 0x9C, 0x56, 0x38, 0xC6, 0x5B, 0x8C, 0xE2, 0x83, 0xA7, 0xD6, 0x0E, 0xB3, 0xDD }; -unsigned char table_64[32] = { +static const unsigned char table_64[32] = { 0x03, 0x05, 0x0D, 0x09, 0x1A, 0x16, 0x08, 0x10, 0x06, 0x1E, 0x1C, 0x15, 0x02, 0x04, 0x17, 0x0C, 0x18, 0x0B, 0x19, 0x11, 0x1B, 0x14, 0x13, 0x0A, 0x0E, 0x00, 0x1D, 0x1F, 0x01, 0x0F, 0x07, 0x12 }; -unsigned char table_65[32] = { +static const unsigned char table_65[32] = { 0x01, 0x0A, 0x1E, 0x14, 0x10, 0x1D, 0x0D, 0x17, 0x0E, 0x0C, 0x0F, 0x12, 0x04, 0x1A, 0x05, 0x02, 0x08, 0x1C, 0x09, 0x1F, 0x0B, 0x13, 0x19, 0x1B, 0x11, 0x00, 0x16, 0x06, 0x03, 0x18, 0x15, 0x07 }; -unsigned char table_66[32] = { +static const unsigned char table_66[32] = { 0x1C, 0x18, 0x0C, 0x09, 0x05, 0x03, 0x15, 0x12, 0x0D, 0x02, 0x08, 0x0E, 0x19, 0x07, 0x13, 0x17, 0x1E, 0x1D, 0x1F, 0x11, 0x06, 0x0A, 0x0B, 0x14, 0x0F, 0x10, 0x01, 0x1B, 0x00, 0x04, 0x1A, 0x16 }; -unsigned char table_67[256] = { +static const unsigned char table_67[256] = { 0x6B, 0x49, 0xC8, 0x86, 0xFF, 0xC0, 0x5D, 0xEF, 0xF7, 0x06, 0xE0, 0x98, 0xA9, 0x72, 0x71, 0xD5, 0xBA, 0x7F, 0x10, 0xD1, 0xBE, 0x41, 0x9C, 0x40, @@ -1524,7 +1524,7 @@ unsigned char table_67[256] = { 0x9D, 0xD2, 0xC3, 0x0A, 0x7D, 0x70, 0xF6, 0x63, 0x24, 0x43, 0x21, 0x83, 0xFB, 0xFD, 0x8B, 0x96 }; -unsigned char table_68[256] = { +static const unsigned char table_68[256] = { 0x93, 0xFF, 0x83, 0x70, 0x12, 0x2D, 0x1C, 0xD6, 0xF9, 0xEE, 0xCF, 0x94, 0x7B, 0xB5, 0xA4, 0x84, 0x99, 0xF7, 0x67, 0x32, 0xFC, 0x8A, 0xE3, 0xE4, @@ -1558,7 +1558,7 @@ unsigned char table_68[256] = { 0x33, 0x86, 0x76, 0x80, 0xE5, 0xC8, 0xD8, 0xA9, 0x8C, 0x6D, 0x91, 0x63, 0x3A, 0x4D, 0xC1, 0x01 }; -unsigned char table_69[256] = { +static const unsigned char table_69[256] = { 0x21, 0x6B, 0x9B, 0xAE, 0x11, 0x5A, 0x91, 0xC2, 0x47, 0x8E, 0x87, 0x86, 0x4F, 0xFC, 0x8F, 0x66, 0x97, 0x2F, 0x61, 0x9C, 0x5B, 0x4C, 0xB3, 0x14, @@ -1592,7 +1592,7 @@ unsigned char table_69[256] = { 0xD0, 0x0F, 0x6D, 0xD7, 0x92, 0x7B, 0x0C, 0xA3, 0x73, 0xDB, 0xB6, 0x83, 0xCE, 0x1E, 0xC1, 0x3C }; -unsigned char table_70[256] = { +static const unsigned char table_70[256] = { 0x54, 0x23, 0xF1, 0x09, 0x9D, 0xEB, 0x26, 0xD9, 0x6C, 0xC1, 0xBC, 0x3D, 0x6E, 0xB0, 0x5F, 0xE2, 0x59, 0x4D, 0x95, 0xFA, 0xD8, 0x29, 0xAA, 0x8E, @@ -1626,13 +1626,13 @@ unsigned char table_70[256] = { 0x74, 0xCE, 0xDC, 0x90, 0x3E, 0xF3, 0x7F, 0xC4, 0x49, 0x84, 0x38, 0xC7, 0xE3, 0xD4, 0x1A, 0xBF }; -unsigned char table_71[32] = { +static const unsigned char table_71[32] = { 0x17, 0x13, 0x0E, 0x1A, 0x0D, 0x18, 0x19, 0x10, 0x14, 0x11, 0x16, 0x05, 0x04, 0x00, 0x12, 0x0A, 0x02, 0x07, 0x03, 0x0B, 0x09, 0x1F, 0x1C, 0x0F, 0x0C, 0x06, 0x1B, 0x08, 0x1D, 0x01, 0x15, 0x1E }; -unsigned char table_72[256] = { +static const unsigned char table_72[256] = { 0xC9, 0xA7, 0x1B, 0xEC, 0x2B, 0x8B, 0xB0, 0xEB, 0x7F, 0x39, 0x25, 0xD9, 0x1D, 0xD5, 0x67, 0xA0, 0xB3, 0xAC, 0x3B, 0xC8, 0x82, 0xC0, 0xE3, 0x9E, @@ -1666,7 +1666,7 @@ unsigned char table_72[256] = { 0xB5, 0xC5, 0xD4, 0x47, 0x8E, 0xE7, 0x58, 0x8F, 0x08, 0x53, 0xF2, 0xB9, 0x5A, 0x3E, 0xE9, 0xD2 }; -unsigned char table_73[256] = { +static const unsigned char table_73[256] = { 0x36, 0x37, 0xED, 0xD8, 0xBF, 0xD7, 0x12, 0xB7, 0x40, 0x32, 0x19, 0x4A, 0x44, 0x2A, 0xCE, 0xA5, 0x29, 0x13, 0x43, 0x51, 0x5C, 0xD0, 0x76, 0x6E, @@ -1700,7 +1700,7 @@ unsigned char table_73[256] = { 0x26, 0x38, 0x71, 0x0E, 0x45, 0xDF, 0xB4, 0x99, 0xFF, 0x90, 0x6B, 0xBC, 0x54, 0x95, 0xBD, 0x07 }; -unsigned char table_74[256] = { +static const unsigned char table_74[256] = { 0xA7, 0xCF, 0x99, 0x1A, 0x13, 0xC7, 0xE9, 0xC4, 0xB6, 0x0E, 0x15, 0x09, 0xFF, 0xDF, 0xBE, 0x03, 0xAD, 0xF1, 0xB0, 0x3C, 0x4A, 0x9B, 0xF5, 0x12, @@ -1734,7 +1734,7 @@ unsigned char table_74[256] = { 0x6E, 0xF3, 0x23, 0x3D, 0x85, 0x82, 0x78, 0xF6, 0x2F, 0xD8, 0xC3, 0x7C, 0x9C, 0x98, 0xEA, 0x71 }; -unsigned char table_75[256] = { +static const unsigned char table_75[256] = { 0xE7, 0xA5, 0x30, 0xE1, 0x9D, 0x81, 0xBE, 0x83, 0xB2, 0x1E, 0xE4, 0x69, 0x2F, 0x2B, 0x0D, 0xEB, 0x7C, 0x59, 0x2D, 0xAA, 0x01, 0x0C, 0xDB, 0xED, @@ -1768,7 +1768,7 @@ unsigned char table_75[256] = { 0xA9, 0x34, 0x94, 0x3B, 0xB9, 0x9C, 0xA2, 0x13, 0x89, 0x46, 0x78, 0xDC, 0x32, 0x8B, 0x67, 0x36 }; -unsigned char table_76[256] = { +static const unsigned char table_76[256] = { 0x3D, 0x66, 0x40, 0xC5, 0x1D, 0xF5, 0xE7, 0xB7, 0x2C, 0x23, 0x09, 0xC2, 0x68, 0xE6, 0xD3, 0x8D, 0x35, 0x94, 0x93, 0xF0, 0x43, 0x97, 0x2B, 0x4B, @@ -1802,25 +1802,25 @@ unsigned char table_76[256] = { 0x13, 0x56, 0x6C, 0x89, 0x33, 0x6E, 0x2A, 0xA5, 0xD1, 0x95, 0xC3, 0xA0, 0x0F, 0xCA, 0xAC, 0xFC }; -unsigned char table_77[32] = { +static const unsigned char table_77[32] = { 0x1C, 0x0D, 0x1E, 0x01, 0x06, 0x16, 0x18, 0x17, 0x0B, 0x1F, 0x04, 0x0F, 0x00, 0x19, 0x08, 0x0A, 0x11, 0x03, 0x05, 0x07, 0x09, 0x0C, 0x15, 0x14, 0x1A, 0x12, 0x13, 0x0E, 0x1D, 0x10, 0x02, 0x1B }; -unsigned char table_78[32] = { +static const unsigned char table_78[32] = { 0x0E, 0x02, 0x17, 0x12, 0x1E, 0x09, 0x15, 0x03, 0x01, 0x0B, 0x0F, 0x11, 0x10, 0x0A, 0x16, 0x06, 0x07, 0x00, 0x1C, 0x1D, 0x1F, 0x0C, 0x18, 0x04, 0x13, 0x0D, 0x1B, 0x08, 0x19, 0x14, 0x05, 0x1A }; -unsigned char table_79[32] = { +static const unsigned char table_79[32] = { 0x12, 0x0B, 0x11, 0x01, 0x07, 0x0E, 0x1A, 0x0D, 0x1E, 0x18, 0x14, 0x1F, 0x0A, 0x17, 0x19, 0x1B, 0x00, 0x10, 0x0C, 0x08, 0x13, 0x02, 0x0F, 0x1D, 0x09, 0x06, 0x04, 0x16, 0x15, 0x1C, 0x05, 0x03 }; -unsigned char table_80[256] = { +static const unsigned char table_80[256] = { 0x14, 0xE7, 0x31, 0x0F, 0xD1, 0x5F, 0xED, 0x1E, 0xA6, 0x77, 0x20, 0x57, 0x34, 0x64, 0x33, 0x0B, 0x5A, 0xB4, 0x83, 0x62, 0xFD, 0x8E, 0xE4, 0xF3, @@ -1854,13 +1854,13 @@ unsigned char table_80[256] = { 0x2F, 0x50, 0x2E, 0x95, 0xAE, 0x1B, 0x56, 0x7B, 0x39, 0xB9, 0xC0, 0x22, 0xF1, 0x4D, 0x90, 0xFC }; -unsigned char table_81[32] = { +static const unsigned char table_81[32] = { 0x03, 0x02, 0x1D, 0x0E, 0x09, 0x1A, 0x0C, 0x11, 0x1C, 0x0D, 0x08, 0x12, 0x19, 0x10, 0x04, 0x17, 0x15, 0x05, 0x0A, 0x00, 0x13, 0x16, 0x1B, 0x18, 0x1E, 0x0B, 0x0F, 0x01, 0x07, 0x14, 0x1F, 0x06 }; -unsigned char table_82[256] = { +static const unsigned char table_82[256] = { 0x53, 0xD3, 0x64, 0x89, 0x7D, 0xA5, 0x66, 0xA4, 0x09, 0x46, 0x17, 0x2C, 0xAF, 0x8C, 0x21, 0x5F, 0x3B, 0x22, 0xE3, 0x05, 0x07, 0x28, 0x2F, 0xAB, @@ -1894,19 +1894,19 @@ unsigned char table_82[256] = { 0x5E, 0x33, 0x5B, 0xA6, 0xC2, 0xB0, 0xBA, 0x30, 0x6A, 0x78, 0xB5, 0x71, 0x56, 0x87, 0x7F, 0x86 }; -unsigned char table_83[32] = { +static const unsigned char table_83[32] = { 0x1B, 0x0A, 0x1F, 0x01, 0x10, 0x08, 0x0E, 0x18, 0x06, 0x04, 0x00, 0x1C, 0x0C, 0x19, 0x0D, 0x16, 0x02, 0x03, 0x09, 0x07, 0x13, 0x0F, 0x05, 0x12, 0x17, 0x1E, 0x1A, 0x1D, 0x0B, 0x11, 0x14, 0x15 }; -unsigned char table_84[32] = { +static const unsigned char table_84[32] = { 0x02, 0x1A, 0x0D, 0x15, 0x01, 0x16, 0x1E, 0x00, 0x08, 0x1B, 0x04, 0x10, 0x1C, 0x18, 0x19, 0x14, 0x0C, 0x11, 0x0B, 0x0E, 0x03, 0x0A, 0x07, 0x12, 0x1D, 0x17, 0x13, 0x06, 0x0F, 0x05, 0x09, 0x1F }; -unsigned char table_85[256] = { +static const unsigned char table_85[256] = { 0xC6, 0x7C, 0xCE, 0xBD, 0x84, 0x3E, 0x0B, 0xD8, 0xFE, 0xCC, 0x46, 0x50, 0xD1, 0xFB, 0xA0, 0x6D, 0xEA, 0xE2, 0x40, 0x51, 0x13, 0xB0, 0xD6, 0xB1, @@ -1940,31 +1940,31 @@ unsigned char table_85[256] = { 0x8E, 0x1B, 0xEF, 0xBF, 0x94, 0xC4, 0x0D, 0xB8, 0x2D, 0x57, 0xE7, 0x82, 0x1E, 0x37, 0x63, 0x43 }; -unsigned char table_86[32] = { +static const unsigned char table_86[32] = { 0x11, 0x07, 0x0F, 0x0A, 0x19, 0x1D, 0x0B, 0x09, 0x1C, 0x1E, 0x14, 0x06, 0x0C, 0x16, 0x13, 0x04, 0x15, 0x18, 0x00, 0x0D, 0x12, 0x05, 0x08, 0x02, 0x10, 0x1A, 0x1F, 0x01, 0x17, 0x0E, 0x03, 0x1B }; -unsigned char table_87[32] = { +static const unsigned char table_87[32] = { 0x17, 0x0E, 0x1D, 0x13, 0x0B, 0x19, 0x03, 0x06, 0x09, 0x01, 0x0D, 0x15, 0x1C, 0x16, 0x18, 0x1B, 0x11, 0x10, 0x00, 0x1E, 0x1F, 0x08, 0x12, 0x0F, 0x02, 0x04, 0x07, 0x1A, 0x14, 0x0A, 0x0C, 0x05 }; -unsigned char table_88[32] = { +static const unsigned char table_88[32] = { 0x09, 0x08, 0x17, 0x10, 0x0A, 0x07, 0x1C, 0x1F, 0x04, 0x0E, 0x01, 0x0C, 0x0D, 0x1B, 0x03, 0x15, 0x02, 0x1E, 0x18, 0x19, 0x0F, 0x06, 0x1A, 0x0B, 0x05, 0x11, 0x14, 0x00, 0x16, 0x1D, 0x12, 0x13 }; -unsigned char table_89[32] = { +static const unsigned char table_89[32] = { 0x15, 0x1C, 0x1D, 0x14, 0x0F, 0x1A, 0x05, 0x02, 0x07, 0x09, 0x06, 0x08, 0x1F, 0x00, 0x10, 0x13, 0x0D, 0x03, 0x0C, 0x18, 0x0E, 0x16, 0x1B, 0x1E, 0x12, 0x04, 0x11, 0x0A, 0x01, 0x0B, 0x17, 0x19 }; -unsigned char table_90[256] = { +static const unsigned char table_90[256] = { 0x62, 0x36, 0x64, 0x0E, 0x4C, 0x6C, 0xBE, 0xCF, 0x25, 0x5A, 0x3D, 0x12, 0x54, 0x9F, 0xE7, 0xA5, 0xDE, 0xD7, 0xB2, 0x60, 0x18, 0x8D, 0x89, 0x70, @@ -1998,19 +1998,19 @@ unsigned char table_90[256] = { 0x29, 0x0A, 0x08, 0xE4, 0x27, 0x19, 0x31, 0xC9, 0x20, 0x94, 0x45, 0xED, 0xDC, 0xBD, 0x7E, 0x50 }; -unsigned char table_91[32] = { +static const unsigned char table_91[32] = { 0x03, 0x04, 0x0C, 0x18, 0x10, 0x0D, 0x13, 0x1B, 0x1F, 0x07, 0x11, 0x17, 0x1C, 0x1D, 0x05, 0x06, 0x0A, 0x12, 0x02, 0x1A, 0x0B, 0x01, 0x0E, 0x08, 0x14, 0x16, 0x00, 0x15, 0x19, 0x09, 0x0F, 0x1E }; -unsigned char table_92[32] = { +static const unsigned char table_92[32] = { 0x1E, 0x10, 0x01, 0x07, 0x11, 0x16, 0x15, 0x17, 0x1F, 0x14, 0x0C, 0x1C, 0x06, 0x03, 0x00, 0x18, 0x08, 0x0E, 0x02, 0x1B, 0x09, 0x0D, 0x19, 0x05, 0x0F, 0x12, 0x0B, 0x13, 0x0A, 0x04, 0x1D, 0x1A }; -unsigned char table_93[256] = { +static const unsigned char table_93[256] = { 0x76, 0x78, 0xA2, 0x94, 0x0E, 0x7F, 0xDF, 0xC1, 0xB9, 0xE1, 0x3D, 0x59, 0x6F, 0x1E, 0x53, 0x99, 0x80, 0xE3, 0x21, 0xF8, 0x65, 0xB8, 0x08, 0xBC, @@ -2044,19 +2044,19 @@ unsigned char table_93[256] = { 0x6E, 0x3B, 0x7D, 0x77, 0x36, 0xAA, 0x39, 0xDE, 0x24, 0x34, 0xE2, 0xEC, 0x85, 0x47, 0xF4, 0xB2 }; -unsigned char table_94[32] = { +static const unsigned char table_94[32] = { 0x1C, 0x07, 0x05, 0x1A, 0x10, 0x1D, 0x14, 0x12, 0x08, 0x0F, 0x0C, 0x01, 0x04, 0x1B, 0x16, 0x0A, 0x11, 0x02, 0x1F, 0x13, 0x0D, 0x1E, 0x17, 0x06, 0x0E, 0x09, 0x15, 0x19, 0x03, 0x18, 0x00, 0x0B }; -unsigned char table_95[32] = { +static const unsigned char table_95[32] = { 0x12, 0x10, 0x11, 0x15, 0x03, 0x0A, 0x14, 0x05, 0x1D, 0x07, 0x17, 0x0D, 0x09, 0x08, 0x1B, 0x1F, 0x0B, 0x06, 0x19, 0x0E, 0x18, 0x04, 0x00, 0x02, 0x1E, 0x1C, 0x01, 0x0C, 0x1A, 0x0F, 0x13, 0x16 }; -unsigned char table_96[256] = { +static const unsigned char table_96[256] = { 0x1C, 0x6E, 0xCD, 0xB4, 0xB3, 0x93, 0xA8, 0x2E, 0x4F, 0x09, 0xE3, 0x72, 0x64, 0x13, 0x21, 0xF5, 0x89, 0xB2, 0xD2, 0x22, 0x5D, 0x63, 0x90, 0xC4, @@ -2090,7 +2090,7 @@ unsigned char table_96[256] = { 0x7E, 0x7C, 0x06, 0x3B, 0xEB, 0x60, 0x7A, 0x8C, 0x59, 0xCE, 0xE1, 0x57, 0x20, 0x58, 0x51, 0xD8 }; -unsigned char table_97[256] = { +static const unsigned char table_97[256] = { 0x15, 0x2D, 0xAF, 0x36, 0xCF, 0xD3, 0xD0, 0xED, 0xB2, 0x1B, 0xFE, 0x92, 0xBD, 0xAD, 0x58, 0x0F, 0x76, 0x3C, 0x47, 0x03, 0x2E, 0x4C, 0x40, 0xF7, @@ -2124,7 +2124,7 @@ unsigned char table_97[256] = { 0x80, 0x88, 0xE8, 0x5F, 0x04, 0xDA, 0xE4, 0xBC, 0x83, 0x25, 0x9F, 0xD9, 0x99, 0xC1, 0xFD, 0xB3 }; -unsigned char table_98[256] = { +static const unsigned char table_98[256] = { 0xC8, 0xE6, 0x38, 0x93, 0xE5, 0x03, 0x18, 0x1F, 0xE9, 0x5A, 0xB6, 0xAF, 0xC3, 0x95, 0x00, 0x51, 0xC0, 0xFD, 0x32, 0xE8, 0x96, 0x57, 0xF0, 0xAA, @@ -2158,13 +2158,13 @@ unsigned char table_98[256] = { 0x88, 0xFE, 0x24, 0x2F, 0x76, 0x3F, 0x59, 0x21, 0x54, 0x3A, 0x13, 0x09, 0x2C, 0xB5, 0xC7, 0x63 }; -unsigned char table_99[32] = { +static const unsigned char table_99[32] = { 0x19, 0x00, 0x10, 0x18, 0x09, 0x11, 0x13, 0x1D, 0x08, 0x1A, 0x02, 0x05, 0x03, 0x17, 0x12, 0x01, 0x1F, 0x14, 0x06, 0x07, 0x15, 0x0D, 0x0F, 0x0B, 0x0E, 0x16, 0x1E, 0x04, 0x1B, 0x0A, 0x0C, 0x1C }; -unsigned char table_100[256] = { +static const unsigned char table_100[256] = { 0x9B, 0x3A, 0xAE, 0x60, 0x27, 0x67, 0x1E, 0x4E, 0x91, 0xDA, 0x85, 0x43, 0x5C, 0xCC, 0x89, 0x55, 0x75, 0x56, 0xF2, 0x86, 0xEB, 0xC4, 0x0D, 0xE6, @@ -2198,25 +2198,25 @@ unsigned char table_100[256] = { 0x87, 0xB3, 0x7E, 0xDE, 0xD7, 0x71, 0x65, 0xF1, 0x30, 0x0C, 0xB2, 0x7B, 0xBE, 0xFB, 0x23, 0x2C }; -unsigned char table_101[32] = { +static const unsigned char table_101[32] = { 0x18, 0x08, 0x14, 0x17, 0x03, 0x10, 0x19, 0x04, 0x0D, 0x1C, 0x06, 0x1D, 0x1E, 0x12, 0x11, 0x0B, 0x0F, 0x02, 0x0E, 0x1B, 0x13, 0x05, 0x07, 0x16, 0x15, 0x0A, 0x0C, 0x1A, 0x00, 0x01, 0x1F, 0x09 }; -unsigned char table_102[32] = { +static const unsigned char table_102[32] = { 0x17, 0x1F, 0x0E, 0x05, 0x13, 0x0C, 0x14, 0x1A, 0x0F, 0x01, 0x12, 0x1C, 0x00, 0x07, 0x0D, 0x02, 0x10, 0x16, 0x04, 0x11, 0x1D, 0x03, 0x1E, 0x18, 0x06, 0x15, 0x0A, 0x19, 0x09, 0x08, 0x1B, 0x0B }; -unsigned char table_103[32] = { +static const unsigned char table_103[32] = { 0x0F, 0x09, 0x1E, 0x11, 0x0D, 0x08, 0x10, 0x00, 0x01, 0x1F, 0x1D, 0x1C, 0x12, 0x04, 0x07, 0x05, 0x19, 0x14, 0x1B, 0x02, 0x1A, 0x15, 0x17, 0x16, 0x18, 0x0B, 0x0A, 0x13, 0x0C, 0x0E, 0x03, 0x06 }; -unsigned char table_104[256] = { +static const unsigned char table_104[256] = { 0xA4, 0x9F, 0x78, 0x39, 0x3D, 0x81, 0x51, 0x24, 0x46, 0x2A, 0x56, 0xE8, 0xDF, 0x73, 0xA8, 0xA2, 0x0D, 0xDC, 0xA5, 0x4F, 0xF0, 0x93, 0xC0, 0x76, @@ -2250,7 +2250,7 @@ unsigned char table_104[256] = { 0x69, 0x9B, 0x84, 0xA0, 0xB3, 0x6F, 0xFE, 0x52, 0x97, 0xBB, 0x37, 0x8C, 0x54, 0x53, 0x9E, 0x8F }; -unsigned char table_105[256] = { +static const unsigned char table_105[256] = { 0x7B, 0x35, 0x11, 0x79, 0x07, 0x2F, 0xF6, 0x82, 0x8E, 0xB4, 0x6E, 0xD2, 0x6D, 0xC5, 0x8C, 0x1C, 0xE0, 0xD6, 0x34, 0xF0, 0x4F, 0x25, 0x59, 0xE8, @@ -2284,19 +2284,19 @@ unsigned char table_105[256] = { 0x90, 0x0A, 0x2A, 0x5D, 0x96, 0x08, 0x6B, 0x83, 0xBA, 0x1E, 0x44, 0x87, 0x45, 0x9F, 0xC9, 0x94 }; -unsigned char table_106[32] = { +static const unsigned char table_106[32] = { 0x03, 0x11, 0x07, 0x1B, 0x0F, 0x14, 0x0C, 0x01, 0x04, 0x02, 0x09, 0x0A, 0x05, 0x12, 0x06, 0x1F, 0x1C, 0x0E, 0x0D, 0x15, 0x18, 0x08, 0x00, 0x10, 0x1E, 0x1D, 0x17, 0x19, 0x13, 0x16, 0x0B, 0x1A }; -unsigned char table_107[32] = { +static const unsigned char table_107[32] = { 0x13, 0x1B, 0x06, 0x11, 0x1C, 0x07, 0x08, 0x0E, 0x10, 0x05, 0x09, 0x18, 0x04, 0x15, 0x1E, 0x0F, 0x1F, 0x12, 0x02, 0x00, 0x17, 0x19, 0x1A, 0x0D, 0x03, 0x0C, 0x0A, 0x1D, 0x14, 0x01, 0x16, 0x0B }; -unsigned char table_108[256] = { +static const unsigned char table_108[256] = { 0x99, 0xA3, 0x48, 0xE8, 0x5A, 0x7D, 0x97, 0xCA, 0x7F, 0x06, 0x9B, 0x04, 0xE0, 0xF3, 0x18, 0xAE, 0x59, 0xA0, 0x2B, 0x15, 0x85, 0x3E, 0x12, 0x93, @@ -2330,7 +2330,7 @@ unsigned char table_108[256] = { 0x4B, 0x9C, 0x70, 0x65, 0x4A, 0xE4, 0x42, 0xDD, 0xCC, 0xE2, 0x44, 0x73, 0xBE, 0x26, 0x8C, 0x5B }; -unsigned char table_109[256] = { +static const unsigned char table_109[256] = { 0xE3, 0x95, 0xDB, 0x09, 0x82, 0x0A, 0x8F, 0x9E, 0xC9, 0xDC, 0x28, 0x35, 0x0F, 0x8B, 0xA8, 0xA5, 0x7F, 0x3D, 0x8C, 0xD1, 0x93, 0x57, 0x04, 0xAA, @@ -2364,7 +2364,7 @@ unsigned char table_109[256] = { 0x9A, 0xCD, 0x24, 0xEC, 0x7C, 0x97, 0x61, 0xCB, 0x1E, 0xF4, 0xD5, 0xB1, 0x5C, 0x25, 0xE8, 0x1C }; -unsigned char table_110[256] = { +static const unsigned char table_110[256] = { 0xC3, 0x06, 0x3C, 0xCB, 0xD2, 0x44, 0x9D, 0x48, 0x28, 0xAA, 0xA9, 0xD0, 0x64, 0x25, 0x56, 0xCA, 0xC2, 0xF8, 0x5C, 0xAE, 0x4E, 0x63, 0xB2, 0xE9, @@ -2398,13 +2398,13 @@ unsigned char table_110[256] = { 0x67, 0xDC, 0x0B, 0xF4, 0x20, 0xAB, 0x6B, 0x9E, 0x4B, 0xCF, 0xB4, 0x2F, 0xBB, 0xEF, 0xDB, 0x33 }; -unsigned char table_111[32] = { +static const unsigned char table_111[32] = { 0x09, 0x0F, 0x00, 0x15, 0x12, 0x17, 0x1A, 0x0D, 0x1C, 0x0B, 0x01, 0x0A, 0x05, 0x1E, 0x1D, 0x0C, 0x1B, 0x08, 0x19, 0x18, 0x14, 0x07, 0x0E, 0x03, 0x10, 0x16, 0x11, 0x1F, 0x04, 0x06, 0x02, 0x13 }; -unsigned char table_112[256] = { +static const unsigned char table_112[256] = { 0xF9, 0x7D, 0xBE, 0xD5, 0x9F, 0xB8, 0x95, 0x43, 0xDB, 0xAE, 0x7E, 0xEC, 0x5B, 0x58, 0x18, 0x49, 0x4B, 0x9D, 0x1C, 0x3E, 0x61, 0xD1, 0xF6, 0x2F, @@ -2438,7 +2438,7 @@ unsigned char table_112[256] = { 0xA9, 0x8B, 0x75, 0x01, 0xA0, 0xE4, 0x35, 0x8D, 0xA1, 0xCC, 0xDF, 0x60, 0xD8, 0x5A, 0xE6, 0xD4 }; -unsigned char table_113[256] = { +static const unsigned char table_113[256] = { 0x46, 0x9D, 0x39, 0xB2, 0x8D, 0x3B, 0x59, 0x5A, 0xD0, 0x9C, 0xE4, 0x04, 0x01, 0xE2, 0xB3, 0xD2, 0xD7, 0x18, 0x40, 0xD8, 0xF1, 0xEF, 0x3A, 0x1D, @@ -2472,13 +2472,13 @@ unsigned char table_113[256] = { 0x6A, 0x19, 0xCE, 0xAB, 0x51, 0xD5, 0x6B, 0xBB, 0xFE, 0x7B, 0x67, 0xFF, 0x10, 0xEC, 0xC6, 0x86 }; -unsigned char table_114[32] = { +static const unsigned char table_114[32] = { 0x11, 0x10, 0x04, 0x1D, 0x08, 0x15, 0x1A, 0x1B, 0x14, 0x18, 0x0F, 0x17, 0x16, 0x07, 0x1E, 0x0E, 0x12, 0x0A, 0x13, 0x0B, 0x0C, 0x00, 0x06, 0x02, 0x1F, 0x19, 0x09, 0x1C, 0x01, 0x0D, 0x03, 0x05 }; -unsigned char table_115[256] = { +static const unsigned char table_115[256] = { 0xB7, 0xBB, 0x63, 0x0D, 0xF0, 0x33, 0x5A, 0x05, 0xF2, 0x7F, 0x64, 0xDB, 0x51, 0xC9, 0x2C, 0x85, 0x4F, 0x41, 0xA4, 0x42, 0xCF, 0xA6, 0x52, 0x2F, @@ -2512,13 +2512,13 @@ unsigned char table_115[256] = { 0x5E, 0xFC, 0xC7, 0x0F, 0x2E, 0x81, 0x7E, 0xA1, 0x8C, 0x17, 0xB5, 0xEB, 0xD5, 0xF3, 0x0B, 0x3C }; -unsigned char table_116[32] = { +static const unsigned char table_116[32] = { 0x00, 0x05, 0x10, 0x1C, 0x0C, 0x1A, 0x04, 0x1B, 0x0A, 0x0D, 0x14, 0x0B, 0x07, 0x03, 0x12, 0x1E, 0x06, 0x11, 0x01, 0x08, 0x15, 0x09, 0x1F, 0x0F, 0x19, 0x18, 0x16, 0x02, 0x13, 0x0E, 0x17, 0x1D }; -unsigned char table_117[256] = { +static const unsigned char table_117[256] = { 0xD0, 0x9A, 0xAB, 0xA8, 0xA7, 0xDF, 0x28, 0xCE, 0x3E, 0x51, 0xBF, 0x76, 0x03, 0xA0, 0x53, 0x3F, 0x90, 0x93, 0x87, 0x67, 0x98, 0x3D, 0xEA, 0x8B, @@ -2552,7 +2552,7 @@ unsigned char table_117[256] = { 0x7E, 0x08, 0x15, 0xB9, 0x7C, 0xAD, 0x84, 0xDD, 0xC1, 0xFD, 0x92, 0xA1, 0xF7, 0xAE, 0xDC, 0x58 }; -unsigned char table_118[256] = { +static const unsigned char table_118[256] = { 0x38, 0xA0, 0xA6, 0xFC, 0x7C, 0x5A, 0x97, 0x1D, 0xFD, 0x00, 0x20, 0xA2, 0x72, 0x10, 0x1F, 0x48, 0x98, 0x7E, 0xDF, 0x2D, 0x80, 0x0A, 0x27, 0xDC, @@ -2586,13 +2586,13 @@ unsigned char table_118[256] = { 0xE8, 0x06, 0x7A, 0x78, 0x0D, 0x81, 0xF7, 0xEA, 0xD9, 0x2F, 0x02, 0xAC, 0x30, 0x6A, 0xD6, 0x95 }; -unsigned char table_119[32] = { +static const unsigned char table_119[32] = { 0x14, 0x0A, 0x1C, 0x00, 0x0C, 0x1F, 0x1E, 0x0B, 0x12, 0x1D, 0x17, 0x08, 0x07, 0x04, 0x09, 0x10, 0x03, 0x1B, 0x0E, 0x1A, 0x05, 0x0D, 0x11, 0x15, 0x18, 0x02, 0x06, 0x01, 0x19, 0x16, 0x13, 0x0F }; -unsigned char table_120[256] = { +static const unsigned char table_120[256] = { 0xCE, 0x89, 0xB2, 0x72, 0x04, 0x77, 0x64, 0xAE, 0x80, 0x99, 0xB5, 0x00, 0x7B, 0x50, 0x9D, 0xE3, 0x87, 0x37, 0x6D, 0x3D, 0x32, 0xBA, 0x20, 0xF0, @@ -2626,13 +2626,13 @@ unsigned char table_120[256] = { 0xD9, 0x29, 0x3C, 0x0C, 0xF1, 0x0B, 0x28, 0x84, 0x5E, 0xCA, 0xFD, 0x11, 0xA3, 0xC7, 0xC0, 0x91 }; -unsigned char table_121[32] = { +static const unsigned char table_121[32] = { 0x1E, 0x12, 0x06, 0x1D, 0x15, 0x1F, 0x13, 0x0B, 0x10, 0x0D, 0x1C, 0x01, 0x0A, 0x0E, 0x02, 0x19, 0x04, 0x1A, 0x03, 0x11, 0x00, 0x16, 0x0C, 0x17, 0x14, 0x08, 0x18, 0x05, 0x09, 0x0F, 0x1B, 0x07 }; -unsigned char table_122[256] = { +static const unsigned char table_122[256] = { 0x85, 0xDF, 0x7F, 0x7C, 0x56, 0xF0, 0x0C, 0x7D, 0x76, 0xA8, 0x58, 0x31, 0x25, 0x8A, 0x0D, 0x23, 0x05, 0x0F, 0x12, 0x64, 0x8E, 0x5D, 0xF4, 0x2C, @@ -2666,7 +2666,7 @@ unsigned char table_122[256] = { 0x89, 0xC7, 0xC1, 0xCF, 0xBE, 0xAA, 0xEC, 0xBA, 0xCE, 0x2D, 0x4E, 0x83, 0xC3, 0x69, 0xEE, 0xB2 }; -unsigned char table_123[256] = { +static const unsigned char table_123[256] = { 0x9D, 0xFB, 0x3C, 0x81, 0xAA, 0x05, 0xB2, 0xBE, 0xD1, 0x5F, 0x4C, 0xE0, 0xA3, 0xF4, 0xDE, 0x35, 0xFE, 0x1B, 0x37, 0x99, 0x94, 0x7A, 0x10, 0xAB, @@ -2700,7 +2700,7 @@ unsigned char table_123[256] = { 0xE5, 0xE4, 0x74, 0x66, 0x1C, 0x68, 0xEC, 0x40, 0x48, 0x77, 0xD0, 0x0A, 0x8A, 0x3A, 0x43, 0x79 }; -unsigned char table_124[256] = { +static const unsigned char table_124[256] = { 0x6C, 0xC3, 0x28, 0x2F, 0x42, 0x4B, 0x7C, 0x3C, 0xCE, 0x24, 0xC8, 0x51, 0x25, 0x3F, 0x49, 0x8D, 0x1E, 0x5C, 0x89, 0x3A, 0x98, 0x47, 0x0B, 0x12, @@ -2734,19 +2734,19 @@ unsigned char table_124[256] = { 0xA2, 0xAD, 0xF2, 0x23, 0xBB, 0x72, 0xF3, 0x94, 0x62, 0x1B, 0xDE, 0x91, 0x87, 0x97, 0x05, 0x2E }; -unsigned char table_125[32] = { +static const unsigned char table_125[32] = { 0x1A, 0x18, 0x12, 0x15, 0x00, 0x1C, 0x01, 0x0B, 0x19, 0x1B, 0x1F, 0x11, 0x07, 0x10, 0x1E, 0x06, 0x17, 0x04, 0x0A, 0x0E, 0x0D, 0x0C, 0x16, 0x08, 0x02, 0x03, 0x13, 0x14, 0x09, 0x1D, 0x05, 0x0F }; -unsigned char table_126[32] = { +static const unsigned char table_126[32] = { 0x1C, 0x1D, 0x07, 0x12, 0x18, 0x1A, 0x19, 0x09, 0x0F, 0x14, 0x1F, 0x0B, 0x13, 0x04, 0x0E, 0x1E, 0x0C, 0x0D, 0x01, 0x17, 0x1B, 0x16, 0x0A, 0x05, 0x15, 0x10, 0x11, 0x08, 0x00, 0x03, 0x06, 0x02 }; -unsigned char table_127[256] = { +static const unsigned char table_127[256] = { 0xA0, 0x66, 0xD8, 0x08, 0xEA, 0x39, 0x78, 0xAB, 0x61, 0x4E, 0xC7, 0xD1, 0xA3, 0x1C, 0x9F, 0xCB, 0x19, 0x51, 0x15, 0x92, 0x23, 0xFD, 0x7D, 0x1D, @@ -2780,13 +2780,13 @@ unsigned char table_127[256] = { 0xD2, 0xD0, 0xD6, 0x3B, 0xC2, 0x2F, 0xE1, 0x2B, 0x70, 0xF8, 0x17, 0xCD, 0xB0, 0xCC, 0x82, 0x2D }; -unsigned char table_128[32] = { +static const unsigned char table_128[32] = { 0x1A, 0x1C, 0x09, 0x17, 0x1B, 0x0B, 0x16, 0x1E, 0x14, 0x0C, 0x12, 0x0E, 0x05, 0x03, 0x1F, 0x15, 0x19, 0x0D, 0x10, 0x13, 0x0A, 0x01, 0x00, 0x11, 0x02, 0x08, 0x0F, 0x18, 0x07, 0x04, 0x1D, 0x06 }; -unsigned char table_129[256] = { +static const unsigned char table_129[256] = { 0x9D, 0x5F, 0xE8, 0x99, 0x57, 0x07, 0x16, 0xA6, 0x9F, 0xB6, 0xDE, 0xED, 0x2D, 0xB3, 0xC0, 0x8E, 0xCC, 0x49, 0xCE, 0xB0, 0x1B, 0xB1, 0x7A, 0xE0, @@ -2820,19 +2820,19 @@ unsigned char table_129[256] = { 0x23, 0x73, 0x92, 0xB5, 0x01, 0x83, 0x82, 0xAA, 0x09, 0x45, 0x6B, 0xD7, 0x0B, 0x89, 0x4F, 0x2A }; -unsigned char table_130[32] = { +static const unsigned char table_130[32] = { 0x07, 0x03, 0x15, 0x0B, 0x02, 0x11, 0x17, 0x14, 0x05, 0x10, 0x0A, 0x0F, 0x01, 0x1C, 0x1D, 0x0E, 0x12, 0x06, 0x18, 0x16, 0x1A, 0x09, 0x13, 0x19, 0x1B, 0x00, 0x08, 0x0D, 0x0C, 0x1E, 0x04, 0x1F }; -unsigned char table_131[32] = { +static const unsigned char table_131[32] = { 0x1D, 0x13, 0x1B, 0x10, 0x07, 0x03, 0x0A, 0x02, 0x00, 0x0C, 0x0E, 0x0B, 0x0D, 0x18, 0x12, 0x1F, 0x1A, 0x04, 0x15, 0x11, 0x1E, 0x08, 0x1C, 0x14, 0x19, 0x05, 0x0F, 0x17, 0x06, 0x01, 0x09, 0x16 }; -unsigned char table_132[256] = { +static const unsigned char table_132[256] = { 0x33, 0x8D, 0x45, 0x6F, 0xFF, 0xF5, 0xB6, 0x53, 0x3B, 0xF3, 0x07, 0xA4, 0x97, 0xEB, 0x6B, 0xA5, 0xD3, 0xDC, 0x7B, 0x79, 0x93, 0xE7, 0xF7, 0x67, @@ -2866,7 +2866,7 @@ unsigned char table_132[256] = { 0x25, 0x96, 0x6C, 0x39, 0x82, 0xE6, 0x2C, 0x9B, 0xC4, 0x7F, 0xA0, 0xD8, 0xEF, 0x03, 0x70, 0xF6 }; -unsigned char table_133[256] = { +static const unsigned char table_133[256] = { 0x02, 0xF0, 0xED, 0xC4, 0xE4, 0x67, 0x60, 0x8B, 0xF3, 0x77, 0x92, 0xE0, 0x85, 0x93, 0x1E, 0x8E, 0x9A, 0x38, 0x61, 0x20, 0xB7, 0x68, 0xE1, 0x5E, @@ -2900,13 +2900,13 @@ unsigned char table_133[256] = { 0x4A, 0x2D, 0x8F, 0x4C, 0x97, 0x28, 0x3E, 0xE5, 0x5A, 0x35, 0xB0, 0xAE, 0x82, 0x79, 0x1D, 0x52 }; -unsigned char table_134[32] = { +static const unsigned char table_134[32] = { 0x09, 0x0F, 0x10, 0x0C, 0x03, 0x15, 0x07, 0x17, 0x0E, 0x0B, 0x1D, 0x08, 0x19, 0x11, 0x00, 0x0A, 0x01, 0x06, 0x18, 0x16, 0x0D, 0x13, 0x14, 0x12, 0x02, 0x1B, 0x1A, 0x04, 0x05, 0x1F, 0x1C, 0x1E }; -unsigned char table_135[256] = { +static const unsigned char table_135[256] = { 0x14, 0x34, 0xEA, 0x02, 0x2B, 0x5A, 0x10, 0x51, 0xF3, 0x8F, 0x28, 0xB2, 0x50, 0x8B, 0x01, 0xCC, 0x80, 0x15, 0x29, 0x42, 0xF4, 0x1D, 0xFB, 0xBB, @@ -2940,7 +2940,7 @@ unsigned char table_135[256] = { 0x96, 0x4E, 0x08, 0xC6, 0x0B, 0xDF, 0x3A, 0xB0, 0x00, 0x63, 0xD9, 0xBE, 0xF2, 0x60, 0x25, 0x62 }; -unsigned char table_136[256] = { +static const unsigned char table_136[256] = { 0xD3, 0x1A, 0x00, 0xED, 0x59, 0x24, 0xA3, 0xF2, 0xBA, 0x58, 0x4C, 0x5C, 0x75, 0x48, 0x98, 0xB0, 0xCF, 0xC3, 0xF7, 0x88, 0x70, 0xB3, 0x3D, 0x3E, @@ -2974,31 +2974,31 @@ unsigned char table_136[256] = { 0x60, 0xD7, 0xE9, 0x17, 0xEB, 0x9C, 0x84, 0x0C, 0x93, 0x1D, 0x9B, 0x5B, 0x40, 0xEE, 0x42, 0x19 }; -unsigned char table_137[32] = { +static const unsigned char table_137[32] = { 0x0F, 0x09, 0x02, 0x06, 0x18, 0x0B, 0x1E, 0x05, 0x11, 0x1D, 0x16, 0x01, 0x13, 0x10, 0x0E, 0x1A, 0x1B, 0x00, 0x0D, 0x08, 0x15, 0x14, 0x19, 0x17, 0x03, 0x1F, 0x0A, 0x12, 0x0C, 0x07, 0x04, 0x1C }; -unsigned char table_138[32] = { +static const unsigned char table_138[32] = { 0x0D, 0x1C, 0x1F, 0x15, 0x0F, 0x14, 0x1B, 0x12, 0x09, 0x0B, 0x19, 0x07, 0x11, 0x16, 0x0C, 0x04, 0x13, 0x05, 0x1D, 0x03, 0x0E, 0x0A, 0x08, 0x1E, 0x01, 0x06, 0x18, 0x17, 0x10, 0x1A, 0x02, 0x00 }; -unsigned char table_139[32] = { +static const unsigned char table_139[32] = { 0x05, 0x15, 0x1D, 0x02, 0x0F, 0x03, 0x17, 0x1A, 0x0A, 0x00, 0x1F, 0x12, 0x0E, 0x11, 0x1B, 0x13, 0x0B, 0x0D, 0x09, 0x18, 0x1E, 0x08, 0x14, 0x07, 0x0C, 0x04, 0x16, 0x19, 0x1C, 0x06, 0x10, 0x01 }; -unsigned char table_140[32] = { +static const unsigned char table_140[32] = { 0x06, 0x1E, 0x0C, 0x11, 0x13, 0x08, 0x15, 0x01, 0x1D, 0x03, 0x0F, 0x19, 0x18, 0x04, 0x00, 0x14, 0x12, 0x1A, 0x0B, 0x0E, 0x02, 0x1B, 0x07, 0x05, 0x1F, 0x17, 0x09, 0x0A, 0x0D, 0x16, 0x10, 0x1C }; -unsigned char table_141[256] = { +static const unsigned char table_141[256] = { 0xE1, 0x0A, 0x28, 0xCD, 0x8A, 0x1E, 0x26, 0x10, 0xC0, 0x6F, 0x06, 0x2C, 0xF8, 0x51, 0x6C, 0x8F, 0xA8, 0x8C, 0x41, 0xF4, 0xED, 0x36, 0xAC, 0x89, @@ -3032,7 +3032,7 @@ unsigned char table_141[256] = { 0xD1, 0x48, 0x92, 0x1D, 0x52, 0x5E, 0x45, 0x70, 0x98, 0x54, 0xB8, 0xDC, 0x46, 0xDF, 0x87, 0xE5 }; -unsigned char table_142[256] = { +static const unsigned char table_142[256] = { 0x90, 0x94, 0xBE, 0x14, 0x99, 0xEB, 0x45, 0x0F, 0x34, 0x4A, 0xE3, 0x79, 0xD2, 0x64, 0x4D, 0x69, 0x91, 0xDE, 0xB9, 0x1C, 0x59, 0x20, 0x6C, 0x0B, @@ -3066,19 +3066,19 @@ unsigned char table_142[256] = { 0xBA, 0x7A, 0x76, 0x41, 0x50, 0x66, 0x05, 0x8E, 0xCC, 0x1E, 0x87, 0xD7, 0x01, 0x1F, 0x51, 0x95 }; -unsigned char table_143[32] = { +static const unsigned char table_143[32] = { 0x0E, 0x16, 0x18, 0x11, 0x0C, 0x01, 0x12, 0x1F, 0x08, 0x15, 0x0A, 0x06, 0x1C, 0x1E, 0x02, 0x1A, 0x17, 0x03, 0x07, 0x13, 0x05, 0x19, 0x10, 0x0F, 0x0D, 0x14, 0x09, 0x0B, 0x1B, 0x00, 0x1D, 0x04 }; -unsigned char table_144[32] = { +static const unsigned char table_144[32] = { 0x00, 0x1B, 0x17, 0x19, 0x1D, 0x11, 0x0D, 0x1A, 0x13, 0x03, 0x1E, 0x09, 0x10, 0x0E, 0x15, 0x05, 0x0B, 0x1C, 0x1F, 0x08, 0x0A, 0x06, 0x01, 0x0F, 0x16, 0x14, 0x02, 0x04, 0x07, 0x18, 0x12, 0x0C }; -unsigned char table_145[256] = { +static const unsigned char table_145[256] = { 0xF9, 0x2C, 0x38, 0x74, 0xDA, 0x65, 0x85, 0x0E, 0xBA, 0x64, 0xDB, 0xE3, 0xB6, 0x8B, 0x0B, 0x5E, 0x01, 0x0F, 0x12, 0x8C, 0xD4, 0xCC, 0xB1, 0x7B, @@ -3112,7 +3112,7 @@ unsigned char table_145[256] = { 0xED, 0x1A, 0x9E, 0x99, 0xEA, 0x40, 0x94, 0x4D, 0x69, 0xF6, 0xEF, 0xC2, 0xAD, 0x03, 0xB3, 0x1E }; -unsigned char table_146[256] = { +static const unsigned char table_146[256] = { 0x1C, 0xF5, 0x16, 0xD2, 0xCC, 0xDC, 0x1E, 0x29, 0xE3, 0x17, 0x3B, 0x66, 0x6A, 0xF7, 0x03, 0xB2, 0x92, 0x45, 0x4D, 0xD6, 0x0C, 0x5E, 0xE6, 0x01, @@ -3146,13 +3146,13 @@ unsigned char table_146[256] = { 0x4A, 0x9F, 0x3D, 0x31, 0x36, 0x5D, 0xA0, 0x2C, 0x7D, 0x96, 0x76, 0x99, 0xB5, 0x48, 0x98, 0x10 }; -unsigned char table_147[32] = { +static const unsigned char table_147[32] = { 0x17, 0x07, 0x0D, 0x16, 0x00, 0x1B, 0x1F, 0x09, 0x10, 0x11, 0x14, 0x0A, 0x02, 0x06, 0x13, 0x0C, 0x08, 0x1E, 0x0F, 0x12, 0x05, 0x15, 0x19, 0x01, 0x1C, 0x1A, 0x03, 0x18, 0x04, 0x0B, 0x1D, 0x0E }; -unsigned char table_148[256] = { +static const unsigned char table_148[256] = { 0xFB, 0x23, 0xBC, 0x5A, 0x8C, 0x02, 0x42, 0x3B, 0x95, 0x0C, 0x21, 0x0E, 0x14, 0xDF, 0x11, 0xC0, 0xDB, 0x5E, 0xD3, 0xEA, 0xCE, 0xB4, 0x32, 0x12, @@ -3186,13 +3186,13 @@ unsigned char table_148[256] = { 0x40, 0x45, 0x9F, 0x44, 0x63, 0x35, 0x77, 0xFF, 0x09, 0x43, 0xBF, 0xD0, 0x55, 0xDD, 0x3F, 0x24 }; -unsigned char table_149[32] = { +static const unsigned char table_149[32] = { 0x1B, 0x0B, 0x0C, 0x06, 0x1F, 0x17, 0x04, 0x1A, 0x1E, 0x02, 0x0F, 0x16, 0x0E, 0x09, 0x10, 0x01, 0x13, 0x19, 0x11, 0x00, 0x0A, 0x05, 0x03, 0x1C, 0x18, 0x1D, 0x14, 0x0D, 0x07, 0x08, 0x15, 0x12 }; -unsigned char table_150[256] = { +static const unsigned char table_150[256] = { 0x57, 0xBC, 0x9D, 0x46, 0x14, 0xD0, 0x94, 0x95, 0x1B, 0x12, 0xB8, 0xD4, 0x53, 0x73, 0x83, 0xE6, 0x75, 0xE1, 0xD1, 0x0D, 0xDF, 0x23, 0x13, 0x40, @@ -3226,7 +3226,7 @@ unsigned char table_150[256] = { 0xAA, 0x8A, 0xF2, 0x69, 0x39, 0x6F, 0x77, 0xDD, 0x97, 0xC9, 0xF3, 0x04, 0xD8, 0xF4, 0x80, 0x44 }; -unsigned char table_151[256] = { +static const unsigned char table_151[256] = { 0x78, 0x6C, 0xC5, 0x0C, 0x2D, 0xA7, 0x97, 0x9C, 0x22, 0x76, 0x3E, 0x81, 0x51, 0x47, 0x59, 0x71, 0xB1, 0xA2, 0x4A, 0x3C, 0xB5, 0x16, 0x06, 0x95, @@ -3260,19 +3260,19 @@ unsigned char table_151[256] = { 0x8B, 0x5D, 0xB0, 0xB7, 0xD9, 0x58, 0x2F, 0x08, 0x43, 0x3A, 0x53, 0x9E, 0x80, 0x88, 0x07, 0x9D }; -unsigned char table_152[32] = { +static const unsigned char table_152[32] = { 0x02, 0x1A, 0x17, 0x1D, 0x01, 0x03, 0x13, 0x1E, 0x05, 0x18, 0x06, 0x0A, 0x0C, 0x04, 0x1B, 0x00, 0x1C, 0x09, 0x1F, 0x16, 0x07, 0x0F, 0x0B, 0x0E, 0x14, 0x12, 0x0D, 0x10, 0x19, 0x11, 0x08, 0x15 }; -unsigned char table_153[32] = { +static const unsigned char table_153[32] = { 0x0E, 0x14, 0x12, 0x1E, 0x1C, 0x02, 0x06, 0x16, 0x18, 0x0D, 0x17, 0x0C, 0x1D, 0x11, 0x08, 0x19, 0x07, 0x0F, 0x13, 0x04, 0x03, 0x1B, 0x0B, 0x1F, 0x1A, 0x0A, 0x05, 0x10, 0x00, 0x01, 0x15, 0x09 }; -unsigned char table_154[256] = { +static const unsigned char table_154[256] = { 0x27, 0x5A, 0x08, 0x5B, 0xF4, 0x39, 0x13, 0x6F, 0x67, 0xEA, 0x22, 0xCA, 0x5C, 0xCF, 0x18, 0x7C, 0x05, 0x87, 0x60, 0xCC, 0x40, 0xC6, 0xE8, 0x6D, @@ -3306,7 +3306,7 @@ unsigned char table_154[256] = { 0xCB, 0xAA, 0xBF, 0x89, 0x1F, 0xA7, 0xBC, 0x9F, 0x53, 0xE1, 0xDD, 0x72, 0x95, 0x52, 0x34, 0xB5 }; -unsigned char table_155[256] = { +static const unsigned char table_155[256] = { 0x75, 0x58, 0xC5, 0xA5, 0x83, 0x16, 0xF3, 0x7F, 0x94, 0xDE, 0xA0, 0xF6, 0xFD, 0x89, 0xA8, 0x06, 0x98, 0x01, 0xD9, 0x69, 0xB7, 0x0F, 0xEA, 0x73, @@ -3340,7 +3340,7 @@ unsigned char table_155[256] = { 0xD0, 0xC4, 0xF7, 0x7B, 0x9E, 0xCB, 0xED, 0x0E, 0x8B, 0x33, 0xFC, 0xBB, 0x00, 0xA2, 0xDF, 0xDA }; -unsigned char table_156[256] = { +static const unsigned char table_156[256] = { 0x31, 0x25, 0xB1, 0xD3, 0xAF, 0xAE, 0x84, 0x2C, 0x71, 0x5E, 0xD8, 0x80, 0x6F, 0x3E, 0x48, 0x86, 0xED, 0x54, 0x6A, 0xC3, 0xBC, 0xBF, 0x0E, 0xEA, @@ -3374,13 +3374,13 @@ unsigned char table_156[256] = { 0x11, 0xC7, 0xB8, 0x4A, 0x33, 0xB0, 0x99, 0xE7, 0xF1, 0x68, 0xBE, 0x35, 0x40, 0x8C, 0xD4, 0x47 }; -unsigned char table_157[32] = { +static const unsigned char table_157[32] = { 0x00, 0x0D, 0x03, 0x02, 0x11, 0x04, 0x18, 0x0B, 0x14, 0x1D, 0x1C, 0x13, 0x1B, 0x17, 0x10, 0x15, 0x01, 0x19, 0x07, 0x09, 0x1A, 0x16, 0x12, 0x1E, 0x08, 0x06, 0x0C, 0x0E, 0x1F, 0x0F, 0x0A, 0x05 }; -unsigned char table_158[256] = { +static const unsigned char table_158[256] = { 0x68, 0x26, 0x80, 0x0B, 0xB8, 0xD5, 0x8C, 0xB7, 0x65, 0xEF, 0xBC, 0x94, 0x28, 0xB9, 0xB2, 0xD2, 0x92, 0xA4, 0x55, 0x27, 0xE0, 0x40, 0x6C, 0x41, @@ -3414,7 +3414,7 @@ unsigned char table_158[256] = { 0xD1, 0x1F, 0x0A, 0x21, 0xA9, 0x6E, 0xC4, 0xBA, 0x9A, 0x57, 0xA2, 0x74, 0xC6, 0xFE, 0x9B, 0x58 }; -unsigned char table_159[256] = { +static const unsigned char table_159[256] = { 0xE5, 0xBF, 0x84, 0x56, 0xD6, 0x43, 0x3E, 0xA5, 0x64, 0x87, 0x44, 0x63, 0x4A, 0x4C, 0x8D, 0x24, 0x1C, 0xDA, 0x89, 0x52, 0x80, 0x4F, 0xE4, 0xBC, @@ -3448,7 +3448,7 @@ unsigned char table_159[256] = { 0xAA, 0x0E, 0x61, 0x5D, 0x95, 0x4E, 0xD7, 0x74, 0xCB, 0x9B, 0x13, 0x8F, 0xA4, 0x28, 0x23, 0x85 }; -unsigned char table_160[256] = { +static const unsigned char table_160[256] = { 0x35, 0x44, 0x0E, 0x92, 0x75, 0x83, 0x9D, 0x53, 0xA5, 0x90, 0xF8, 0xF7, 0x54, 0x74, 0xDF, 0x3D, 0x5A, 0xAA, 0xC6, 0x26, 0x7A, 0xFC, 0x79, 0x6C, @@ -3482,7 +3482,7 @@ unsigned char table_160[256] = { 0x57, 0x61, 0x81, 0xEF, 0x06, 0xDE, 0x48, 0x31, 0xBB, 0x2C, 0xE5, 0xC3, 0x67, 0xA1, 0x10, 0xB9 }; -unsigned char table_161[256] = { +static const unsigned char table_161[256] = { 0x8F, 0x1A, 0x81, 0xA2, 0x2C, 0x56, 0x6D, 0xCD, 0x4A, 0x33, 0x50, 0xE9, 0xE0, 0x12, 0x5A, 0x43, 0x2D, 0x4F, 0xEA, 0x95, 0xFD, 0x49, 0xAB, 0xA3, @@ -3516,7 +3516,7 @@ unsigned char table_161[256] = { 0x52, 0x2E, 0xA8, 0x60, 0x5E, 0x29, 0x21, 0x7E, 0xBE, 0x0A, 0x36, 0x41, 0xC0, 0x8C, 0xE4, 0xAA }; -unsigned char table_162[256] = { +static const unsigned char table_162[256] = { 0xF7, 0x1B, 0xC0, 0x31, 0x5A, 0x23, 0xEA, 0xE9, 0xFB, 0x14, 0x6A, 0xE8, 0x04, 0x65, 0x5B, 0x2C, 0x41, 0xD9, 0xEB, 0xE4, 0x8D, 0x1D, 0xCA, 0x8F, @@ -3550,19 +3550,19 @@ unsigned char table_162[256] = { 0xD4, 0x02, 0x8E, 0x37, 0xF4, 0xB3, 0xA2, 0x53, 0x38, 0xCC, 0x58, 0x44, 0xBF, 0x93, 0x5D, 0xC7 }; -unsigned char table_163[32] = { +static const unsigned char table_163[32] = { 0x1B, 0x14, 0x12, 0x15, 0x11, 0x1D, 0x17, 0x19, 0x10, 0x09, 0x08, 0x06, 0x1A, 0x16, 0x07, 0x13, 0x1F, 0x0B, 0x1C, 0x05, 0x0E, 0x00, 0x18, 0x0A, 0x04, 0x01, 0x03, 0x0C, 0x0D, 0x1E, 0x02, 0x0F }; -unsigned char table_164[32] = { +static const unsigned char table_164[32] = { 0x15, 0x00, 0x10, 0x0B, 0x1D, 0x0A, 0x06, 0x1C, 0x0D, 0x1F, 0x17, 0x0F, 0x03, 0x14, 0x13, 0x12, 0x1B, 0x18, 0x08, 0x1E, 0x16, 0x09, 0x1A, 0x04, 0x02, 0x0C, 0x0E, 0x01, 0x07, 0x19, 0x11, 0x05 }; -unsigned char table_165[256] = { +static const unsigned char table_165[256] = { 0x98, 0xF5, 0x1D, 0xFB, 0x13, 0x20, 0x41, 0xA3, 0xE3, 0x76, 0x49, 0x7E, 0x60, 0xD8, 0x68, 0x30, 0x88, 0x45, 0xD5, 0x77, 0x00, 0xC3, 0x09, 0x31, @@ -3596,7 +3596,7 @@ unsigned char table_165[256] = { 0x0B, 0x78, 0xF1, 0xE6, 0x59, 0x27, 0xC2, 0xE0, 0x1A, 0x26, 0xCC, 0xB1, 0xF9, 0xFA, 0x97, 0xE9 }; -unsigned char table_166[256] = { +static const unsigned char table_166[256] = { 0xCB, 0xEA, 0x2A, 0x36, 0x6D, 0x93, 0x4E, 0xD5, 0xBC, 0x6A, 0xD4, 0x68, 0xF7, 0x18, 0xAB, 0x8B, 0x66, 0x95, 0x94, 0x64, 0xB7, 0x00, 0x4D, 0x97, @@ -3630,7 +3630,7 @@ unsigned char table_166[256] = { 0x20, 0x31, 0x9B, 0xEC, 0xB4, 0xCF, 0x54, 0x22, 0x1C, 0xE0, 0x51, 0x16, 0x43, 0x07, 0x0A, 0x3F }; -unsigned char table_167[256] = { +static const unsigned char table_167[256] = { 0x91, 0xEA, 0x4F, 0x6A, 0x6E, 0x2D, 0x27, 0x22, 0x44, 0xA5, 0x6D, 0xE3, 0x45, 0x06, 0xE2, 0x87, 0x9A, 0xC9, 0x2C, 0x4A, 0x93, 0x6F, 0x00, 0xEB, @@ -3664,7 +3664,7 @@ unsigned char table_167[256] = { 0xB6, 0xAB, 0x89, 0xBD, 0x8F, 0xEF, 0x7D, 0xB2, 0x14, 0x15, 0x25, 0x32, 0x6C, 0x69, 0x1A, 0xCF }; -unsigned char table_168[256] = { +static const unsigned char table_168[256] = { 0x28, 0xEE, 0xB1, 0xFD, 0xB3, 0xEF, 0x36, 0x8E, 0x85, 0x5D, 0x1C, 0x53, 0x1E, 0xDA, 0xBA, 0x3C, 0xA8, 0x90, 0x99, 0x49, 0x45, 0xE0, 0x27, 0x8D, @@ -3698,7 +3698,7 @@ unsigned char table_168[256] = { 0xEB, 0xF7, 0x71, 0x39, 0x30, 0xA5, 0x87, 0xD2, 0x66, 0x2E, 0x08, 0x32, 0x4C, 0x33, 0x7E, 0xE1 }; -unsigned char table_169[256] = { +static const unsigned char table_169[256] = { 0xA4, 0x31, 0xA9, 0x3F, 0x13, 0x4D, 0x1B, 0x29, 0x73, 0x43, 0xF1, 0xE7, 0x9C, 0xC2, 0xF6, 0xCD, 0xA1, 0x94, 0x0D, 0x27, 0xFE, 0x7B, 0x9B, 0x0B, @@ -3732,7 +3732,7 @@ unsigned char table_169[256] = { 0x6F, 0x9A, 0x65, 0xB9, 0x41, 0xBE, 0x8A, 0xA2, 0x6B, 0x0A, 0x59, 0x9E, 0x5E, 0x38, 0x45, 0x80 }; -unsigned char table_170[256] = { +static const unsigned char table_170[256] = { 0xE3, 0x00, 0x99, 0x03, 0xF6, 0xDD, 0xD1, 0x41, 0x58, 0x7E, 0xD9, 0x46, 0x04, 0xAF, 0x5C, 0x43, 0xDE, 0x5E, 0xFC, 0x97, 0x3D, 0x68, 0xC8, 0x37, @@ -3766,43 +3766,43 @@ unsigned char table_170[256] = { 0x8C, 0x3E, 0x61, 0x6E, 0xE9, 0x63, 0xF9, 0xEC, 0x48, 0x30, 0x87, 0x83, 0x12, 0x4D, 0x65, 0xDF }; -unsigned char table_171[32] = { +static const unsigned char table_171[32] = { 0x07, 0x06, 0x11, 0x08, 0x0C, 0x1F, 0x19, 0x02, 0x14, 0x04, 0x0D, 0x18, 0x1A, 0x05, 0x17, 0x13, 0x1C, 0x1B, 0x15, 0x03, 0x01, 0x0F, 0x16, 0x1E, 0x1D, 0x10, 0x00, 0x12, 0x0B, 0x0E, 0x09, 0x0A }; -unsigned char table_172[32] = { +static const unsigned char table_172[32] = { 0x11, 0x01, 0x1F, 0x06, 0x1A, 0x04, 0x02, 0x09, 0x05, 0x0D, 0x0B, 0x18, 0x0E, 0x12, 0x1B, 0x17, 0x07, 0x08, 0x1D, 0x1E, 0x14, 0x19, 0x16, 0x15, 0x03, 0x0C, 0x00, 0x10, 0x0A, 0x1C, 0x0F, 0x13 }; -unsigned char table_173[32] = { +static const unsigned char table_173[32] = { 0x1F, 0x0B, 0x13, 0x00, 0x16, 0x15, 0x14, 0x0A, 0x1D, 0x05, 0x1E, 0x1A, 0x0F, 0x04, 0x0E, 0x01, 0x19, 0x07, 0x02, 0x12, 0x0C, 0x17, 0x08, 0x09, 0x03, 0x11, 0x18, 0x10, 0x1C, 0x1B, 0x06, 0x0D }; -unsigned char table_174[32] = { +static const unsigned char table_174[32] = { 0x02, 0x1B, 0x0C, 0x17, 0x1F, 0x05, 0x15, 0x1E, 0x16, 0x09, 0x1A, 0x12, 0x0F, 0x1C, 0x18, 0x0A, 0x19, 0x10, 0x0D, 0x13, 0x04, 0x11, 0x08, 0x14, 0x1D, 0x0E, 0x06, 0x00, 0x01, 0x07, 0x0B, 0x03 }; -unsigned char table_175[32] = { +static const unsigned char table_175[32] = { 0x00, 0x06, 0x0B, 0x08, 0x0C, 0x04, 0x1A, 0x1C, 0x05, 0x1E, 0x14, 0x03, 0x0A, 0x18, 0x12, 0x1D, 0x16, 0x1F, 0x07, 0x09, 0x0F, 0x0E, 0x17, 0x13, 0x11, 0x19, 0x10, 0x0D, 0x1B, 0x02, 0x01, 0x15 }; -unsigned char table_176[32] = { +static const unsigned char table_176[32] = { 0x12, 0x03, 0x1A, 0x15, 0x04, 0x19, 0x0B, 0x1B, 0x17, 0x1E, 0x0D, 0x05, 0x11, 0x14, 0x1C, 0x00, 0x18, 0x10, 0x0A, 0x06, 0x0E, 0x08, 0x02, 0x07, 0x13, 0x09, 0x16, 0x1D, 0x0F, 0x0C, 0x01, 0x1F }; -unsigned char table_177[256] = { +static const unsigned char table_177[256] = { 0x5E, 0x4D, 0x76, 0xFE, 0xB5, 0x50, 0x83, 0x23, 0x72, 0xDD, 0x93, 0x08, 0x69, 0xAD, 0xEC, 0x3B, 0x0B, 0x9A, 0x36, 0xC9, 0xCA, 0xBE, 0xF7, 0x30, @@ -3836,7 +3836,7 @@ unsigned char table_177[256] = { 0xB4, 0x67, 0xA9, 0x81, 0xB1, 0x12, 0xD3, 0x85, 0x5A, 0xC5, 0xE0, 0x58, 0x41, 0x4E, 0x4A, 0xAF }; -unsigned char table_178[256] = { +static const unsigned char table_178[256] = { 0x33, 0xBA, 0x98, 0xDA, 0x07, 0x2C, 0x22, 0x9B, 0xE0, 0xED, 0xB7, 0xA1, 0x93, 0xEB, 0xDC, 0x49, 0xDF, 0xE1, 0x6C, 0xC2, 0x64, 0x52, 0xD0, 0x8F, @@ -3870,7 +3870,7 @@ unsigned char table_178[256] = { 0x10, 0x23, 0xB6, 0xF3, 0x19, 0x30, 0x20, 0x4D, 0x95, 0x9E, 0xBF, 0xEF, 0xF8, 0x45, 0x00, 0xB4 }; -unsigned char table_179[256] = { +static const unsigned char table_179[256] = { 0x50, 0x3D, 0x41, 0x42, 0x06, 0x5B, 0xD6, 0x34, 0x9D, 0x3C, 0x7B, 0x14, 0xE2, 0x9B, 0x80, 0x15, 0x51, 0x01, 0x6A, 0x30, 0xD7, 0xFC, 0x61, 0x4B, @@ -3904,7 +3904,7 @@ unsigned char table_179[256] = { 0x5D, 0xAC, 0x1A, 0x36, 0x63, 0x99, 0x31, 0xF3, 0x2A, 0x04, 0x18, 0xA5, 0xA2, 0x6E, 0x07, 0xE3 }; -unsigned char table_180[256] = { +static const unsigned char table_180[256] = { 0xDA, 0xCC, 0x72, 0xA6, 0xE7, 0x07, 0xFD, 0x25, 0x92, 0x39, 0x49, 0x02, 0xD6, 0x09, 0xA8, 0x65, 0x2E, 0x6C, 0xA1, 0x19, 0xBF, 0x21, 0x11, 0xC7, @@ -3938,7 +3938,7 @@ unsigned char table_180[256] = { 0x6F, 0x20, 0x54, 0xFB, 0x93, 0xFC, 0x6B, 0x38, 0x62, 0x4F, 0xCF, 0xB2, 0xC2, 0x59, 0xDB, 0x67 }; -unsigned char table_181[256] = { +static const unsigned char table_181[256] = { 0x2B, 0xED, 0x14, 0x05, 0x80, 0xCC, 0x5A, 0xF8, 0x43, 0xB7, 0x86, 0xC6, 0xEE, 0xA6, 0xD7, 0xD6, 0xA0, 0xC4, 0x21, 0x34, 0xB1, 0x8C, 0xF9, 0xF4, @@ -3972,7 +3972,7 @@ unsigned char table_181[256] = { 0x85, 0xA8, 0x95, 0x6D, 0x16, 0x78, 0xB5, 0xF6, 0x32, 0x24, 0x7D, 0x9B, 0xD2, 0x83, 0x35, 0xCD }; -unsigned char table_182[256] = { +static const unsigned char table_182[256] = { 0x06, 0x7F, 0x66, 0xB5, 0xBA, 0x1E, 0xFD, 0x51, 0x81, 0x8D, 0x28, 0xA3, 0x15, 0x37, 0xDC, 0x58, 0xE6, 0x3D, 0xB4, 0xB9, 0x2E, 0xA0, 0x2F, 0xC4, @@ -4006,19 +4006,19 @@ unsigned char table_182[256] = { 0xA4, 0xE2, 0x45, 0x8F, 0x21, 0xE0, 0x49, 0x22, 0x7B, 0x17, 0x0B, 0x0A, 0x41, 0x03, 0xD4, 0x4B }; -unsigned char table_183[32] = { +static const unsigned char table_183[32] = { 0x1E, 0x1B, 0x11, 0x07, 0x08, 0x06, 0x18, 0x17, 0x0D, 0x0F, 0x12, 0x03, 0x1D, 0x04, 0x0A, 0x1A, 0x0C, 0x13, 0x14, 0x1F, 0x0B, 0x19, 0x10, 0x01, 0x16, 0x05, 0x1C, 0x0E, 0x02, 0x00, 0x09, 0x15 }; -unsigned char table_184[32] = { +static const unsigned char table_184[32] = { 0x0F, 0x1D, 0x17, 0x16, 0x0D, 0x05, 0x13, 0x1F, 0x1B, 0x09, 0x1C, 0x1E, 0x15, 0x01, 0x06, 0x08, 0x0C, 0x10, 0x0B, 0x02, 0x04, 0x0A, 0x07, 0x1A, 0x18, 0x0E, 0x03, 0x11, 0x12, 0x14, 0x19, 0x00 }; -unsigned char table_185[256] = { +static const unsigned char table_185[256] = { 0xA5, 0xEE, 0x2E, 0x28, 0xA7, 0xAC, 0xD9, 0xB2, 0x6E, 0x04, 0xB4, 0x03, 0xE8, 0x92, 0x5F, 0x4D, 0x73, 0x20, 0x71, 0xE0, 0x43, 0x53, 0x3F, 0xF8, @@ -4052,7 +4052,7 @@ unsigned char table_185[256] = { 0x60, 0xCA, 0x26, 0xFD, 0x33, 0x46, 0x21, 0xBB, 0x2B, 0xC5, 0x98, 0x18, 0x66, 0x15, 0x9C, 0xBC }; -unsigned char table_186[256] = { +static const unsigned char table_186[256] = { 0xB7, 0xFA, 0x03, 0x7C, 0x76, 0x43, 0xA7, 0x15, 0x4B, 0x4F, 0x04, 0xAA, 0x4E, 0xD2, 0x52, 0xC8, 0x79, 0x16, 0xF6, 0x61, 0x01, 0x5D, 0xD6, 0x47, @@ -4086,13 +4086,13 @@ unsigned char table_186[256] = { 0x64, 0x82, 0xC6, 0x05, 0xD8, 0xAC, 0x99, 0x9F, 0x11, 0x3B, 0x94, 0xE8, 0x7D, 0x7B, 0xD9, 0x5A }; -unsigned char table_187[32] = { +static const unsigned char table_187[32] = { 0x0F, 0x04, 0x1D, 0x1B, 0x15, 0x10, 0x01, 0x0B, 0x00, 0x17, 0x13, 0x07, 0x1E, 0x1F, 0x08, 0x0A, 0x19, 0x09, 0x05, 0x06, 0x0C, 0x1A, 0x14, 0x16, 0x0E, 0x18, 0x03, 0x1C, 0x12, 0x11, 0x0D, 0x02 }; -struct yahoo_fn yahoo_fntable[5][96] = +static const struct yahoo_fn yahoo_fntable[5][96] = {{{ IDENT, 0, 0 }, { IDENT, 0, 0 }, { IDENT, 0, 0 }, @@ -4581,7 +4581,7 @@ struct yahoo_fn yahoo_fntable[5][96] = int yahoo_xfrm( int table, int depth, int seed ) { - struct yahoo_fn *xfrm; + const struct yahoo_fn *xfrm; int i, j, z; unsigned int n = seed; unsigned char *arg; diff --git a/protocols/yahoo/yahoo_util.c b/protocols/yahoo/yahoo_util.c index 3c99cf44..7babfa49 100644 --- a/protocols/yahoo/yahoo_util.c +++ b/protocols/yahoo/yahoo_util.c @@ -51,56 +51,6 @@ char * y_string_append(char * string, char * append) return new_string; } -char * y_str_to_utf8(const char *in) -{ - unsigned int n, i = 0; - char *result = NULL; - - if(in == NULL || *in == '\0') - return ""; - - result = y_new(char, strlen(in) * 2 + 1); - - /* convert a string to UTF-8 Format */ - for (n = 0; n < strlen(in); n++) { - unsigned char c = (unsigned char)in[n]; - - if (c < 128) { - result[i++] = (char) c; - } else { - result[i++] = (char) ((c >> 6) | 192); - result[i++] = (char) ((c & 63) | 128); - } - } - result[i] = '\0'; - return result; -} - -char * y_utf8_to_str(const char *in) -{ - int i = 0; - unsigned int n; - char *result = NULL; - - if(in == NULL || *in == '\0') - return ""; - - result = y_new(char, strlen(in) + 1); - - /* convert a string from UTF-8 Format */ - for (n = 0; n < strlen(in); n++) { - unsigned char c = in[n]; - - if (c < 128) { - result[i++] = (char) c; - } else { - result[i++] = (c << 6) | (in[++n] & 63); - } - } - result[i] = '\0'; - return result; -} - #if !HAVE_GLIB void y_strfreev(char ** vector) @@ -1,3 +1,13 @@ +#include <errno.h> +#include <fcntl.h> + +/* To cut down on the ifdef stuff a little bit in other places */ +#ifdef IPV6 +#define AF_INETx AF_INET6 +#else +#define AF_INETx AF_INET +#endif + #ifndef _WIN32 #include <unistd.h> #include <sys/socket.h> diff --git a/storage_text.c b/storage_text.c index 54905440..d6920c64 100644 --- a/storage_text.c +++ b/storage_text.c @@ -78,7 +78,7 @@ static storage_status_t text_load ( const char *my_nick, const char* password, i FILE *fp; user_t *ru = user_find( irc, ROOT_NICK ); - if( irc->status == USTATUS_IDENTIFIED ) + if( irc->status >= USTATUS_IDENTIFIED ) return( 1 ); g_snprintf( s, 511, "%s%s%s", global.conf->configdir, my_nick, ".accounts" ); @@ -31,6 +31,7 @@ #include <signal.h> #include <unistd.h> #include <sys/time.h> +#include <sys/wait.h> global_t global; /* Against global namespace pollution */ @@ -45,7 +46,7 @@ int main( int argc, char *argv[] ) global.loop = g_main_new( FALSE ); - log_init( ); + log_init(); nogaim_init(); @@ -75,11 +76,15 @@ int main( int argc, char *argv[] ) i = bitlbee_daemon_init(); log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION ); } + else if( global.conf->runmode == RUNMODE_FORKDAEMON ) + { + i = bitlbee_daemon_init(); + log_message( LOGLVL_INFO, "Bitlbee %s starting in forking daemon mode.", BITLBEE_VERSION ); + } if( i != 0 ) return( i ); - global.storage = storage_init( global.conf->primary_storage, - global.conf->migrate_storage ); + global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); if ( global.storage == NULL) { log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage ); return( 1 ); @@ -89,6 +94,7 @@ int main( int argc, char *argv[] ) /* Catch some signals to tell the user what's happening before quitting */ memset( &sig, 0, sizeof( sig ) ); sig.sa_handler = sighandler; + sigaction( SIGCHLD, &sig, &old ); sigaction( SIGPIPE, &sig, &old ); sig.sa_flags = SA_RESETHAND; sigaction( SIGINT, &sig, &old ); @@ -112,7 +118,7 @@ int main( int argc, char *argv[] ) static void sighandler( int signal ) { - /* FIXME: In fact, calling log_message() here can be dangerous. But well, let's take the risk for now. */ + /* FIXME: Calling log_message() here is not a very good idea! */ if( signal == SIGTERM ) { @@ -138,6 +144,19 @@ static void sighandler( int signal ) raise( signal ); } } + else if( signal == SIGCHLD ) + { + pid_t pid; + int st; + + while( ( pid = waitpid( 0, &st, WNOHANG ) ) > 0 ) + { + if( WIFSIGNALED( st ) ) + log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", pid, WEXITSTATUS( st ) ); + else if( WIFEXITED( st ) ) + log_message( LOGLVL_INFO, "Client %d killed by signal %d.", pid, WTERMSIG( st ) ); + } + } else if( signal != SIGPIPE ) { log_message( LOGLVL_ERROR, "Fatal signal received: %d. That's probably a bug.", signal ); @@ -1,7 +1,7 @@ /********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * - * Copyright 2001-2004 Wilmer van der Gaast and others * + * Copyright 2001-2005 Wilmer van der Gaast and others * \********************************************************************/ /* URL/mirror stuff - Stolen from Axel */ @@ -29,7 +29,7 @@ int url_set( url_t *url, char *set_url ) { char s[MAX_STRING]; - char *i, *j; + char *i; /* protocol:// */ if( ( i = strstr( set_url, "://" ) ) == NULL ) @@ -39,7 +39,9 @@ int url_set( url_t *url, char *set_url ) } else { - if( g_strncasecmp( set_url, "http", i - set_url ) == 0 ) + if( g_strncasecmp( set_url, "https", i - set_url ) == 0 ) + url->proto = PROTO_HTTPS; + else if( g_strncasecmp( set_url, "http", i - set_url ) == 0 ) url->proto = PROTO_HTTP; else if( g_strncasecmp( set_url, "socks4", i - set_url ) == 0 ) url->proto = PROTO_SOCKS4; @@ -55,33 +57,14 @@ int url_set( url_t *url, char *set_url ) /* Split */ if( ( i = strchr( s, '/' ) ) == NULL ) { - strcpy( url->dir, "/" ); + strcpy( url->file, "/" ); } else { + strncpy( url->file, i, MAX_STRING ); *i = 0; - g_snprintf( url->dir, MAX_STRING, "/%s", i + 1 ); - if( url->proto == PROTO_HTTP ) - http_encode( url->dir ); } strncpy( url->host, s, MAX_STRING ); - j = strchr( url->dir, '?' ); - if( j != NULL ) - *j = 0; - i = strrchr( url->dir, '/' ); - *i = 0; - if( j != NULL ) - *j = '?'; - if( i == NULL ) - { - strcpy( url->file, url->dir ); - strcpy( url->dir, "/" ); - } - else - { - strcpy( url->file, i + 1 ); - strcat( url->dir, "/" ); - } /* Check for username in host field */ if( strrchr( url->host, '@' ) != NULL ) @@ -95,15 +78,7 @@ int url_set( url_t *url, char *set_url ) /* If not: Fill in defaults */ else { - if( url->proto == PROTO_FTP ) - { - strcpy( url->user, "anonymous" ); - strcpy( url->pass, "-p.artmaps@lintux.cx" ); - } - else - { - *url->user = *url->pass = 0; - } + *url->user = *url->pass = 0; } /* Password? */ @@ -116,13 +91,14 @@ int url_set( url_t *url, char *set_url ) if( ( i = strchr( url->host, ':' ) ) != NULL ) { *i = 0; - sscanf( i + 1, "%i", &url->port ); + sscanf( i + 1, "%d", &url->port ); } - /* Take default port numbers from /etc/services */ else { if( url->proto == PROTO_HTTP ) - url->port = 8080; + url->port = 80; + else if( url->proto == PROTO_HTTPS ) + url->port = 443; else if( url->proto == PROTO_SOCKS4 || url->proto == PROTO_SOCKS4 ) url->port = 1080; } @@ -25,8 +25,8 @@ #include "bitlbee.h" -#define PROTO_FTP 1 #define PROTO_HTTP 2 +#define PROTO_HTTPS 5 #define PROTO_SOCKS4 3 #define PROTO_SOCKS5 4 #define PROTO_DEFAULT PROTO_HTTP @@ -36,7 +36,6 @@ typedef struct url int proto; int port; char host[MAX_STRING]; - char dir[MAX_STRING]; char file[MAX_STRING]; char user[MAX_STRING]; char pass[MAX_STRING]; diff --git a/protocols/util.c b/util.c index 6a2f2e46..db783fe0 100644 --- a/protocols/util.c +++ b/util.c @@ -5,13 +5,12 @@ \********************************************************************/ /* - * nogaim - * - * Gaim without gaim - for BitlBee + * Various utility functions. Some are copied from Gaim to support the + * IM-modules, most are from BitlBee. * * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> * (and possibly other members of the Gaim team) - * Copyright 2002-2004 Wilmer van der Gaast <lintux@lintux.cx> + * Copyright 2002-2005 Wilmer van der Gaast <wilmer@gaast.net> */ /* @@ -31,103 +30,15 @@ Suite 330, Boston, MA 02111-1307 USA */ -/* Parts from util.c from gaim needed by nogaim */ #define BITLBEE_CORE #include "nogaim.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> #include <glib.h> #include <time.h> -char *utf8_to_str(const char *in) -{ - int n = 0, i = 0; - int inlen; - char *result; - - if (!in) - return NULL; - - inlen = strlen(in); - - result = g_malloc(inlen + 1); - - while (n <= inlen - 1) { - long c = (long)in[n]; - if (c < 0x80) - result[i++] = (char)c; - else { - if ((c & 0xC0) == 0xC0) - result[i++] = - (char)(((c & 0x03) << 6) | (((unsigned char)in[++n]) & 0x3F)); - else if ((c & 0xE0) == 0xE0) { - if (n + 2 <= inlen) { - result[i] = - (char)(((c & 0xF) << 4) | (((unsigned char)in[++n]) & 0x3F)); - result[i] = - (char)(((unsigned char)result[i]) | - (((unsigned char)in[++n]) & 0x3F)); - i++; - } else - n += 2; - } else if ((c & 0xF0) == 0xF0) - n += 3; - else if ((c & 0xF8) == 0xF8) - n += 4; - else if ((c & 0xFC) == 0xFC) - n += 5; - } - n++; - } - result[i] = '\0'; - - return result; -} - -char *str_to_utf8(const char *in) -{ - int n = 0, i = 0; - int inlen; - char *result = NULL; - - if (!in) - return NULL; - - inlen = strlen(in); - - result = g_malloc(inlen * 2 + 1); - - while (n < inlen) { - long c = (long)in[n]; - if (c == 27) { - n += 2; - if (in[n] == 'x') - n++; - if (in[n] == '3') - n++; - n += 2; - continue; - } - /* why are we removing newlines and carriage returns? - if ((c == 0x0D) || (c == 0x0A)) { - n++; - continue; - } - */ - if (c < 128) - result[i++] = (char)c; - else { - result[i++] = (char)((c >> 6) | 192); - result[i++] = (char)((c & 63) | 128); - } - n++; - } - result[i] = '\0'; - - return result; -} - void strip_linefeed(gchar *text) { int i, j; @@ -270,34 +181,39 @@ time_t get_time(int year, int month, int day, int hour, int min, int sec) typedef struct htmlentity { char code[8]; - char is; + char is[4]; } htmlentity_t; /* FIXME: This is ISO8859-1(5) centric, so might cause problems with other charsets. */ -static htmlentity_t ent[] = +static const htmlentity_t ent[] = { - { "lt", '<' }, - { "gt", '>' }, - { "amp", '&' }, - { "quot", '"' }, - { "aacute", 'á' }, - { "eacute", 'é' }, - { "iacute", 'é' }, - { "oacute", 'ó' }, - { "uacute", 'ú' }, - { "agrave", 'à' }, - { "egrave", 'è' }, - { "igrave", 'ì' }, - { "ograve", 'ò' }, - { "ugrave", 'ù' }, - { "acirc", 'â' }, - { "ecirc", 'ê' }, - { "icirc", 'î' }, - { "ocirc", 'ô' }, - { "ucirc", 'û' }, - { "nbsp", ' ' }, - { "", 0 } + { "lt", "<" }, + { "gt", ">" }, + { "amp", "&" }, + { "quot", "\"" }, + { "aacute", "á" }, + { "eacute", "é" }, + { "iacute", "é" }, + { "oacute", "ó" }, + { "uacute", "ú" }, + { "agrave", "à " }, + { "egrave", "è" }, + { "igrave", "ì" }, + { "ograve", "ò" }, + { "ugrave", "ù" }, + { "acirc", "â" }, + { "ecirc", "ê" }, + { "icirc", "î" }, + { "ocirc", "ô" }, + { "ucirc", "û" }, + { "auml", "ä" }, + { "euml", "ë" }, + { "iuml", "ï" }, + { "ouml", "ö" }, + { "uuml", "ü" }, + { "nbsp", " " }, + { "", "" } }; void strip_html( char *in ) @@ -346,7 +262,11 @@ void strip_html( char *in ) for( i = 0; *ent[i].code; i ++ ) if( g_strncasecmp( ent[i].code, cs, strlen( ent[i].code ) ) == 0 ) { - *(s++) = ent[i].is; + int j; + + for( j = 0; ent[i].is[j]; j ++ ) + *(s++) = ent[i].is[j]; + matched = 1; break; } @@ -411,3 +331,116 @@ void info_string_append(GString *str, char *newline, char *name, char *value) if( value && value[0] ) g_string_sprintfa( str, "%s%s: %s", newline, name, value ); } + +/* Decode%20a%20file%20name */ +void http_decode( char *s ) +{ + char *t; + int i, j, k; + + t = g_new( char, strlen( s ) + 1 ); + + for( i = j = 0; s[i]; i ++, j ++ ) + { + if( s[i] == '%' ) + { + if( sscanf( s + i + 1, "%2x", &k ) ) + { + t[j] = k; + i += 2; + } + else + { + *t = 0; + break; + } + } + else + { + t[j] = s[i]; + } + } + t[j] = 0; + + strcpy( s, t ); + g_free( t ); +} + +/* Warning: This one explodes the string. Worst-cases can make the string 3x its original size! */ +/* This fuction is safe, but make sure you call it safely as well! */ +void http_encode( char *s ) +{ + char *t; + int i, j; + + t = g_strdup( s ); + + for( i = j = 0; t[i]; i ++, j ++ ) + { + /* if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' ) */ + if( !isalnum( t[i] ) ) + { + sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] ); + j += 2; + } + else + { + s[j] = t[i]; + } + } + s[j] = 0; + + g_free( t ); +} + +/* Strip newlines from a string. Modifies the string passed to it. */ +char *strip_newlines( char *source ) +{ + int i; + + for( i = 0; source[i] != '\0'; i ++ ) + if( source[i] == '\n' || source[i] == '\r' ) + source[i] = ' '; + + return source; +} + +#ifdef IPV6 +/* Wrap an IPv4 address into IPv6 space. Not thread-safe... */ +char *ipv6_wrap( char *src ) +{ + static char dst[64]; + int i; + + for( i = 0; src[i]; i ++ ) + if( ( src[i] < '0' || src[i] > '9' ) && src[i] != '.' ) + break; + + /* Hmm, it's not even an IP... */ + if( src[i] ) + return src; + + g_snprintf( dst, sizeof( dst ), "::ffff:%s", src ); + + return dst; +} + +/* Unwrap an IPv4 address into IPv6 space. Thread-safe, because it's very simple. :-) */ +char *ipv6_unwrap( char *src ) +{ + int i; + + if( g_strncasecmp( src, "::ffff:", 7 ) != 0 ) + return src; + + for( i = 7; src[i]; i ++ ) + if( ( src[i] < '0' || src[i] > '9' ) && src[i] != '.' ) + break; + + /* Hmm, it's not even an IP... */ + if( src[i] ) + return src; + + return ( src + 7 ); +} +#endif |