[cvslog] (2002-10-23 04:03:14 UTC) Module eggdrop1.6: Change committed

cvslog cvs at tsss.org
Tue Oct 22 23:04:00 CST 2002


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2002-10-23 04:03:14 UTC
Commited by: Will Buckner <wcc at techmonkeys.org>

Modified files:
     eggdrop.conf doc/UPDATES1.6 src/net.c src/tcl.c

Log message:

Fixed a UTF problem with scandinavian characters. Patch by Pauli Borodulin.

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/UPDATES1.6
diff -u eggdrop1.6/doc/UPDATES1.6:1.420 eggdrop1.6/doc/UPDATES1.6:1.421
--- eggdrop1.6/doc/UPDATES1.6:1.420	Mon Oct  7 23:25:37 2002
+++ eggdrop1.6/doc/UPDATES1.6	Tue Oct 22 23:03:04 2002
@@ -1,10 +1,11 @@
-$Id: UPDATES1.6,v 1.420 2002/10/08 04:25:37 wcc Exp $
+$Id: UPDATES1.6,v 1.421 2002/10/23 04:03:04 wcc Exp $
 
 Changes in Eggdrop: (since v1.6.0)
 ----------------------------------
 
 1.6.13
 Found by  Fixed by  What...
+          Borodulin fixed a UTF problem with scandinavian characters
           Eule      made the modes-per-line limit definable in src/chan.h
           BarkerJr  [ban/exempt/invite]-time were not being saved to the channel file
 Eule      Wcc       halfops were not honored in flush_modes()
Index: eggdrop1.6/eggdrop.conf
diff -u eggdrop1.6/eggdrop.conf:1.2 eggdrop1.6/eggdrop.conf:1.3
--- eggdrop1.6/eggdrop.conf:1.2	Mon Oct  7 23:25:36 2002
+++ eggdrop1.6/eggdrop.conf	Tue Oct 22 23:03:04 2002
@@ -1,7 +1,7 @@
 #! /path/to/executable/eggdrop
 # ^- This should contain a fully qualified path to your Eggdrop executable.
 #
-# $Id: eggdrop.conf,v 1.2 2002/10/08 04:25:36 wcc Exp $
+# $Id: eggdrop.conf,v 1.3 2002/10/23 04:03:04 wcc Exp $
 #
 # This is a sample Eggdrop configuration file which includes all possible
 # settings that can be used to configure your bot.
@@ -41,6 +41,11 @@
 # If you don't want to use the timezone setting for scripting purposes only,
 # but instead everywhere possible, un-comment the following line.
 #set env(TZ) "$timezone $offset"
+
+# This setting defines the encoding used when sending data from Eggdrop
+# to irc-server. Any encoding your TCL knows is fine. Iso8859-1 should
+# be suitable almost for everybody.
+#set encoding "iso8859-1"
 
 # If you're using virtual hosting (your machine has more than 1 IP), you
 # may want to specify the particular IP to bind to. You can specify either
Index: eggdrop1.6/src/net.c
diff -u eggdrop1.6/src/net.c:1.45 eggdrop1.6/src/net.c:1.46
--- eggdrop1.6/src/net.c:1.45	Sat Sep 21 23:11:08 2002
+++ eggdrop1.6/src/net.c	Tue Oct 22 23:03:04 2002
@@ -2,7 +2,7 @@
  * net.c -- handles:
  *   all raw network i/o
  * 
- * $Id: net.c,v 1.45 2002/09/22 04:11:08 wcc Exp $
+ * $Id: net.c,v 1.46 2002/10/23 04:03:04 wcc Exp $
  */
 /* 
  * This is hereby released into the public domain.
@@ -21,6 +21,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>		/* is this really necessary? */
 #include <errno.h>
+#include <tcl.h>
 #if HAVE_UNISTD_H
 #  include <unistd.h>
 #endif
@@ -43,6 +44,7 @@
 char	hostname[121] = "";	/* Hostname can be specified in the config
 				   file					    */
 char	myip[121] = "";		/* IP can be specified in the config file   */
+char	encoding[21] = "iso8859-1"; /* Encoding used by default */
 char	firewall[121] = "";	/* Socks server for firewall		    */
 int	firewallport = 1080;	/* Default port of Sock4/5 firewalls	    */
 char	botuser[21] = "eggdrop"; /* Username of the user running the bot    */
@@ -971,18 +973,26 @@
  * 
  * NOTE: Do NOT put Contexts in here if you want DEBUG to be meaningful!!
  */
-void tputs(register int z, char *s, unsigned int len)
+void tputs(register int z, char *string, unsigned int len)
 {
   register int i, x, idx;
   char *p;
   static int inhere = 0;
+  int encode = 0;
+  char nonutf[1024];
+  Tcl_Encoding NonUtfEnc;
+
+  char *s;
+  s = (char *) nmalloc ( len + 1 );
 
   if (z < 0)
     return;			/* um... HELLO?!  sanity check please! */
   if (((z == STDOUT) || (z == STDERR)) && (!backgrd || use_stderr)) {
-    write(z, s, len);
+    write(z, string, len);
+    nfree(s);
     return;
   }
+
   for (i = 0; i < MAXSOCKS; i++) {
     if (!(socklist[i].flags & SOCK_UNUSED) && (socklist[i].sock == z)) {
       for (idx = 0; idx < dcc_total; idx++) {
@@ -990,13 +1000,13 @@
           if (dcc[idx].type) {
             if (dcc[idx].type->name) {
               if (!strncmp(dcc[idx].type->name, "BOT", 3)) {
-                otraffic_bn_today += len;
+                otraffic_bn_today += len; encode = 1;
                 break;
               } else if (!strcmp(dcc[idx].type->name, "SERVER")) {
-                otraffic_irc_today += len;
+                otraffic_irc_today += len; encode = 1;
                 break;
               } else if (!strncmp(dcc[idx].type->name, "CHAT", 4)) {
-                otraffic_dcc_today += len;
+                otraffic_dcc_today += len; encode = 1;
                 break;
               } else if (!strncmp(dcc[idx].type->name, "FILES", 5)) {
                 otraffic_filesys_today += len;
@@ -1016,6 +1026,27 @@
         }
       }
       
+
+#if ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 1)) || (TCL_MAJOR_VERSION > 8)
+
+  /* Encode UTF-8 string to encoding chose by user */
+
+  if(encode == 1 && sizeof(string) < 1024) {
+      NonUtfEnc = Tcl_GetEncoding(NULL, encoding);
+      Tcl_UtfToExternal(NULL, NonUtfEnc, string, -1, 0, NULL, nonutf, 1023, NULL, NULL, NULL);
+      strcpy(s, nonutf);
+  } else {
+      strcpy(s, string);
+  }
+
+#else
+
+  /* No encoding needed because of TCL-version, just pass the string... */
+  strcpy(s, string);
+
+#endif
+
+
       if (socklist[i].outbuf != NULL) {
 	/* Already queueing: just add it */
 	p = (char *) nrealloc(socklist[i].outbuf, socklist[i].outbuflen + len);
@@ -1043,10 +1074,12 @@
 
     putlog(LOG_MISC, "*", "!!! writing to nonexistent socket: %d", z);
     s[strlen(s) - 1] = 0;
+    string[strlen(s) - 1] = 0;
     putlog(LOG_MISC, "*", "!-> '%s'", s);
 
     inhere = 0;
   }
+  nfree(s);
 }
 
 /* tputs might queue data for sockets, let's dump as much of it as
Index: eggdrop1.6/src/tcl.c
diff -u eggdrop1.6/src/tcl.c:1.47 eggdrop1.6/src/tcl.c:1.48
--- eggdrop1.6/src/tcl.c:1.47	Thu Jul 18 14:01:44 2002
+++ eggdrop1.6/src/tcl.c	Tue Oct 22 23:03:04 2002
@@ -4,7 +4,7 @@
  *   Tcl initialization
  *   getting and setting Tcl/eggdrop variables
  *
- * $Id: tcl.c,v 1.47 2002/07/18 19:01:44 guppy Exp $
+ * $Id: tcl.c,v 1.48 2002/10/23 04:03:04 wcc Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -54,7 +54,7 @@
 		firewall[], helpdir[], notify_new[], hostname[], myip[],
 		moddir[], tempdir[], owner[], network[], botnetnick[],
 		bannerfile[], egg_version[], natip[], configfile[],
-		logfile_suffix[], textdir[], pid_file[];
+		logfile_suffix[], textdir[], pid_file[], encoding[];
 extern int	die_on_sighup, die_on_sigterm, max_logs, max_logsize,
 		enable_simul, dcc_total, debug_output, identtimeout,
 		protect_telnet, dupwait_timeout, egg_numver, share_unlinks,
@@ -438,6 +438,7 @@
 #endif
   {"notify-newusers",	notify_new,	120,		0},
   {"owner",		owner,		120,		STR_PROTECT},
+  {"encoding",		encoding,	20,		0},
   {"my-hostname",	hostname,	120,		0},
   {"my-ip",		myip,		120,		0},
   {"network",		network,	40,		0},
----------------------- End of diff -----------------------



More information about the Changes mailing list