[cvslog] Module eggdrop1.6: Change committed

cvslog cvs at tsss.org
Sun Sep 23 15:18:00 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2001-09-23 20:17:57 UTC
Commited by: Jeff Fisher <guppy at techmonkeys.org>

Modified files:
     doc/UPDATES1.6 src/botmsg.c src/dccutil.c src/misc.c
     src/modules.c src/patch.h src/proto.h src/tcl.c src/tclegg.h
     src/tclhash.c src/tclmisc.c src/mod/module.h
     src/mod/channels.mod/tclchan.c

Log message:

lets test this patchls

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/UPDATES1.6
diff -u eggdrop1.6/doc/UPDATES1.6:1.180 eggdrop1.6/doc/UPDATES1.6:1.181
--- eggdrop1.6/doc/UPDATES1.6:1.180	Sun Sep 23 14:56:06 2001
+++ eggdrop1.6/doc/UPDATES1.6	Sun Sep 23 15:17:46 2001
@@ -1,10 +1,11 @@
-$Id: UPDATES1.6,v 1.180 2001/09/23 19:56:06 guppy Exp $
+$Id: UPDATES1.6,v 1.181 2001/09/23 20:17:46 guppy Exp $
 
 Changes in eggdrop: (since v1.6.0)
 ----------------------------------
 
 1.6.7
 Found by  Fixed by  What...
+various   stdarg    proper utf8 support
           TaKeDa    small wasop fix
           SuperS    small fix for SunOS
 bleah     PPSlim    Fixed booting with full length handles
Index: eggdrop1.6/src/botmsg.c
diff -u eggdrop1.6/src/botmsg.c:1.23 eggdrop1.6/src/botmsg.c:1.24
--- eggdrop1.6/src/botmsg.c:1.23	Wed Jun 20 09:48:34 2001
+++ eggdrop1.6/src/botmsg.c	Sun Sep 23 15:17:46 2001
@@ -5,7 +5,7 @@
  *
  * by Darrin Smith (beldin at light.iinet.net.au)
  *
- * $Id: botmsg.c,v 1.23 2001/06/20 14:48:34 poptix Exp $
+ * $Id: botmsg.c,v 1.24 2001/09/23 20:17:46 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -55,9 +55,6 @@
   va_end(va);
   s[sizeof(s)-1] = 0;
 
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-  str_nutf8tounicode(s, sizeof s);
-#endif
   len = strlen(s);
 
   for (i = 0; i < dcc_total; i++)
@@ -305,10 +302,6 @@
   egg_vsnprintf(tbuf, 450, format, va);
   va_end(va);
   tbuf[sizeof(tbuf)-1] = 0;
-
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-  str_nutf8tounicode(tbuf, sizeof tbuf);
-#endif
 
   if (tobot) {
 #ifndef NO_OLD_BOTNET
Index: eggdrop1.6/src/dccutil.c
diff -u eggdrop1.6/src/dccutil.c:1.32 eggdrop1.6/src/dccutil.c:1.33
--- eggdrop1.6/src/dccutil.c:1.32	Wed Jun 20 09:48:34 2001
+++ eggdrop1.6/src/dccutil.c	Sun Sep 23 15:17:47 2001
@@ -6,7 +6,7 @@
  *   memory management for dcc structures
  *   timeout checking for dcc connections
  *
- * $Id: dccutil.c,v 1.32 2001/06/20 14:48:34 poptix Exp $
+ * $Id: dccutil.c,v 1.33 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -120,10 +120,6 @@
    * sizeof(buf) bytes. But we're not doing that anyway.
   */
   buf[sizeof(buf)-1] = 0;
-
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-  str_nutf8tounicode(buf, sizeof buf);
-#endif
   len = strlen(buf);
 
   if (idx < 0) {
Index: eggdrop1.6/src/misc.c
diff -u eggdrop1.6/src/misc.c:1.43 eggdrop1.6/src/misc.c:1.44
--- eggdrop1.6/src/misc.c:1.43	Sun Jul 29 01:08:04 2001
+++ eggdrop1.6/src/misc.c	Sun Sep 23 15:17:47 2001
@@ -7,7 +7,7 @@
  *   help system
  *   motd display and %var substitution
  *
- * $Id: misc.c,v 1.43 2001/07/29 06:08:04 guppy Exp $
+ * $Id: misc.c,v 1.44 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -371,38 +371,6 @@
     }
   }
 }
-
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-/* Converts an UTF-8 string to unicode safe string
- */
-void str_nutf8tounicode(char *str, int len)
-{
-  Tcl_DString       ds_conversion;
-  Tcl_SavedResult   sr_oldresult;
-
-  /* Don't call this before calling init_tcl() */
-  if (interp) {
-    Tcl_DStringInit(&ds_conversion);
-
-    /* save our old result */
-    Tcl_SaveResult(interp, &sr_oldresult);
-
-    /* clear any previous interp->result */
-    Tcl_ResetResult(interp);
-
-    /* convert UTF-8 to unicode */
-    Tcl_UtfToExternalDString(NULL, str, -1, &ds_conversion);
-    Tcl_DStringResult(interp, &ds_conversion);
-    strncpyz(str, interp->result, len);
-
-    /* restore our old result */
-    Tcl_RestoreResult(interp, &sr_oldresult);
-
-    /* free our DString buffers */
-    Tcl_DStringFree(&ds_conversion);
-  }
-}
-#endif
 
 /* Dump a potentially super-long string of text.
  */
Index: eggdrop1.6/src/mod/channels.mod/tclchan.c
diff -u eggdrop1.6/src/mod/channels.mod/tclchan.c:1.48 eggdrop1.6/src/mod/channels.mod/tclchan.c:1.49
--- eggdrop1.6/src/mod/channels.mod/tclchan.c:1.48	Sat Jun 30 01:34:44 2001
+++ eggdrop1.6/src/mod/channels.mod/tclchan.c	Sun Sep 23 15:17:47 2001
@@ -1,7 +1,7 @@
 /*
  * tclchan.c -- part of channels.mod
  *
- * $Id: tclchan.c,v 1.48 2001/06/30 06:34:44 guppy Exp $
+ * $Id: tclchan.c,v 1.49 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -1586,11 +1586,6 @@
   strncat(buf, glob_chanset, 2047 - strlen(buf));
   strncat(buf, options, 2047 - strlen(buf));
   buf[2047] = 0;
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-  str_nutf8tounicode(newname, strlen(newname) + 1);
-  str_nutf8tounicode(buf2, sizeof buf2);
-  str_nutf8tounicode(buf, sizeof buf);
-#endif
 
   if (Tcl_SplitList(NULL, buf, &items, &item) != TCL_OK)
     return TCL_ERROR;
Index: eggdrop1.6/src/mod/module.h
diff -u eggdrop1.6/src/mod/module.h:1.51 eggdrop1.6/src/mod/module.h:1.52
--- eggdrop1.6/src/mod/module.h:1.51	Sun Jul 29 01:08:04 2001
+++ eggdrop1.6/src/mod/module.h	Sun Sep 23 15:17:47 2001
@@ -1,7 +1,7 @@
 /*
  * module.h
  *
- * $Id: module.h,v 1.51 2001/07/29 06:08:04 guppy Exp $
+ * $Id: module.h,v 1.52 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -437,9 +437,6 @@
 #define str_unescape ((void (*)(char *, register const char))global[264])
 #define egg_strcatn ((int (*)(char *dst, const char *src, size_t max))global[265])
 #define clear_chanlist_member ((void (*)(const char *nick))global[266])
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-#define str_nutf8tounicode ((int (*)(char *str, int len))global[267])
-#endif
 /* 168 - 271 */
 /* Please don't modify socklist directly, unless there's no other way.
  * Its structure might be changed, or it might be completely removed,
Index: eggdrop1.6/src/modules.c
diff -u eggdrop1.6/src/modules.c:1.54 eggdrop1.6/src/modules.c:1.55
--- eggdrop1.6/src/modules.c:1.54	Sun Jul 29 01:08:04 2001
+++ eggdrop1.6/src/modules.c	Sun Sep 23 15:17:47 2001
@@ -4,7 +4,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: modules.c,v 1.54 2001/07/29 06:08:04 guppy Exp $
+ * $Id: modules.c,v 1.55 2001/09/23 20:17:47 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -529,11 +529,7 @@
   (Function) str_unescape,
   (Function) egg_strcatn,
   (Function) clear_chanlist_member,
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-  (Function) str_nutf8tounicode,
-#else
   (Function) 0,
-#endif
   /* 268 - 271 */
   (Function) & socklist,	/* sock_list *				*/
   (Function) sockoptions,
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.552 eggdrop1.6/src/patch.h:1.553
--- eggdrop1.6/src/patch.h:1.552	Sun Sep 23 14:56:06 2001
+++ eggdrop1.6/src/patch.h	Sun Sep 23 15:17:47 2001
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.552 2001/09/23 19:56:06 guppy Exp $
+ * $Id: patch.h,v 1.553 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1001274891");		/* current unixtime */
+patch("1001276217");		/* current unixtime */
 /*
  *
  *
  */
-patch("wasopfix");
+patch("proper_utf8_support");
 /*
  *
  *
Index: eggdrop1.6/src/proto.h
diff -u eggdrop1.6/src/proto.h:1.45 eggdrop1.6/src/proto.h:1.46
--- eggdrop1.6/src/proto.h:1.45	Sun Jul 29 01:08:04 2001
+++ eggdrop1.6/src/proto.h	Sun Sep 23 15:17:47 2001
@@ -7,7 +7,7 @@
  * because they use structures in those
  * (saves including those .h files EVERY time) - Beldin
  *
- * $Id: proto.h,v 1.45 2001/07/29 06:08:04 guppy Exp $
+ * $Id: proto.h,v 1.46 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -231,9 +231,6 @@
 char *str_escape(const char *str, const char div, const char mask);
 char *strchr_unescape(char *str, const char div, register const char esc_char);
 void str_unescape(char *str, register const char esc_char);
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-void str_nutf8tounicode(char *str, int len);
-#endif
 void kill_bot(char *, char *);
 
 /* net.c */
Index: eggdrop1.6/src/tcl.c
diff -u eggdrop1.6/src/tcl.c:1.36 eggdrop1.6/src/tcl.c:1.37
--- eggdrop1.6/src/tcl.c:1.36	Wed Jul 25 22:59:44 2001
+++ eggdrop1.6/src/tcl.c	Sun Sep 23 15:17:47 2001
@@ -4,7 +4,7 @@
  *   Tcl initialization
  *   getting and setting Tcl/eggdrop variables
  *
- * $Id: tcl.c,v 1.36 2001/07/26 03:59:44 guppy Exp $
+ * $Id: tcl.c,v 1.37 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -62,7 +62,6 @@
 		default_uflags, strict_host, userfile_perm;
 extern struct dcc_t	*dcc;
 extern tcl_timer_t	*timer, *utimer;
-extern log_t		*logs;
 
 int	    protect_readonly = 0;	/* turn on/off readonly protection */
 char	    whois_fields[1025] = "";	/* fields to display in a .whois */
@@ -85,6 +84,8 @@
 					   ppl? - dw			      */
 int	    quiet_save = 0;             /* quiet-save patch by Lucas	      */
 int	    strtot = 0;
+int utftot = 0;
+int clientdata_stuff = 0;
 
 
 /* Prototypes for tcl */
@@ -92,83 +93,7 @@
 
 int expmem_tcl()
 {
-  int i, tot = 0;
-
-  for (i = 0; i < max_logs; i++)
-    if (logs[i].filename != NULL) {
-      tot += strlen(logs[i].filename) + 1;
-      tot += strlen(logs[i].chname) + 1;
-    }
-  return tot + strtot;
-}
-
-
-/*
- *      Logging
- */
-
-/* logfile [<modes> <channel> <filename>] */
-static int tcl_logfile STDVAR
-{
-  int i;
-  char s[151];
-
-  BADARGS(1, 4, " ?logModes channel logFile?");
-  if (argc == 1) {
-    /* They just want a list of the logfiles and modes */
-    for (i = 0; i < max_logs; i++)
-      if (logs[i].filename != NULL) {
-	strcpy(s, masktype(logs[i].mask));
-	strcat(s, " ");
-	strcat(s, logs[i].chname);
-	strcat(s, " ");
-	strcat(s, logs[i].filename);
-	Tcl_AppendElement(interp, s);
-      }
-    return TCL_OK;
-  }
-  BADARGS(4, 4, " ?logModes channel logFile?");
-  for (i = 0; i < max_logs; i++)
-    if ((logs[i].filename != NULL) && (!strcmp(logs[i].filename, argv[3]))) {
-      logs[i].flags &= ~LF_EXPIRING;
-      logs[i].mask = logmodes(argv[1]);
-      nfree(logs[i].chname);
-      logs[i].chname = NULL;
-      if (!logs[i].mask) {
-	/* ending logfile */
-	nfree(logs[i].filename);
-	logs[i].filename = NULL;
-	if (logs[i].f != NULL) {
-	  fclose(logs[i].f);
-	  logs[i].f = NULL;
-	}
-        logs[i].flags = 0;
-      } else {
-	logs[i].chname = (char *) nmalloc(strlen(argv[2]) + 1);
-	strcpy(logs[i].chname, argv[2]);
-      }
-      Tcl_AppendResult(interp, argv[3], NULL);
-      return TCL_OK;
-    }
-  /* Do not add logfiles without any flags to log ++rtc */
-  if (!logmodes (argv [1])) {
-    Tcl_AppendResult (interp, "can't remove \"", argv[3],
-                     "\" from list: no such logfile", NULL);
-    return TCL_ERROR;
-  }
-  for (i = 0; i < max_logs; i++)
-    if (logs[i].filename == NULL) {
-      logs[i].flags = 0;
-      logs[i].mask = logmodes(argv[1]);
-      logs[i].filename = (char *) nmalloc(strlen(argv[3]) + 1);
-      strcpy(logs[i].filename, argv[3]);
-      logs[i].chname = (char *) nmalloc(strlen(argv[2]) + 1);
-      strcpy(logs[i].chname, argv[2]);
-      Tcl_AppendResult(interp, argv[3], NULL);
-      return TCL_OK;
-    }
-  Tcl_AppendResult(interp, "reached max # of logfiles", NULL);
-  return TCL_ERROR;
+  return strtot + utftot + clientdata_stuff;
 }
 
 int findidx(int z)
@@ -365,6 +290,73 @@
 
 /* Add/remove tcl commands
  */
+
+#if ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 1)) || (TCL_MAJOR_VERSION > 8)
+
+static int utf_converter(ClientData cdata, Tcl_Interp *myinterp, int objc, Tcl_Obj *CONST objv[])
+{
+	char **strings, *byteptr;
+	int i, len, retval, *intarray, diff;
+	Function func;
+	ClientData cd;
+
+	strings = (char **)nmalloc(sizeof(char *) * objc);
+	diff = utftot;
+	utftot += sizeof(char *) * objc;
+	for (i = 0; i < objc; i++) {
+		byteptr = (char *)Tcl_GetByteArrayFromObj(objv[i], &len);
+		strings[i] = (char *)nmalloc(len+1);
+		utftot += len+1;
+		strncpy(strings[i], byteptr, len);
+		strings[i][len] = 0;
+	}
+	intarray = (int *)cdata;
+	func = (Function) intarray[0];
+	cd = (ClientData) intarray[1];
+	diff -= utftot;
+	retval = func(cd, myinterp, objc, strings);
+	for (i = 0; i < objc; i++) nfree(strings[i]);
+	nfree(strings);
+	utftot += diff;
+	return(retval);
+}
+
+void cmd_delete_callback(ClientData cdata)
+{
+	nfree(cdata);
+	clientdata_stuff -= sizeof(int) * 2;
+}
+
+void add_tcl_commands(tcl_cmds *tab)
+{
+	int *cdata;
+
+	while (tab->name) {
+		cdata = (int *)nmalloc(sizeof(int) * 2);
+		clientdata_stuff += sizeof(int) * 2;
+		cdata[0] = (int) tab->func;
+		cdata[1] = (int) NULL;
+		Tcl_CreateObjCommand(interp, tab->name, utf_converter, (ClientData) cdata, cmd_delete_callback);
+		tab++;
+	}
+}
+
+void add_cd_tcl_cmds(cd_tcl_cmd *table)
+{
+	int *cdata;
+
+	while (table->name) {
+		cdata = (int *)nmalloc(sizeof(int) * 2);
+		clientdata_stuff += sizeof(int) * 2;
+		cdata[0] = (int) table->callback;
+		cdata[1] = (int) table->cdata;
+		Tcl_CreateObjCommand(interp, table->name, utf_converter, (ClientData) cdata, cmd_delete_callback);
+		table++;
+	}
+}
+
+#else
+
 void add_tcl_commands(tcl_cmds *tab)
 {
   int i;
@@ -373,6 +365,16 @@
     Tcl_CreateCommand(interp, tab[i].name, tab[i].func, NULL, NULL);
 }
 
+void add_cd_tcl_cmds(cd_tcl_cmd *table)
+{
+	while (table->name) {
+		Tcl_CreateCommand(interp, table->name, table->callback, (ClientData) table->cdata, NULL);
+		table++;
+	}
+}
+
+#endif
+
 void rem_tcl_commands(tcl_cmds *tab)
 {
   int i;
@@ -381,6 +383,14 @@
     Tcl_DeleteCommand(interp, tab[i].name);
 }
 
+void rem_cd_tcl_cmds(cd_tcl_cmd *table)
+{
+	while (table->name) {
+		Tcl_DeleteCommand(interp, table->name);
+		table++;
+	}
+}
+
 void add_tcl_objcommands(tcl_cmds *tab)
 {
 #if (TCL_MAJOR_VERSION >= 8)
@@ -627,7 +637,6 @@
   init_traces();
 
   /* Add new commands */
-  Tcl_CreateCommand(interp, "logfile", tcl_logfile, NULL, NULL);
   add_tcl_commands(tcluser_cmds);
   add_tcl_commands(tcldcc_cmds);
   add_tcl_commands(tclmisc_cmds);
Index: eggdrop1.6/src/tclegg.h
diff -u eggdrop1.6/src/tclegg.h:1.13 eggdrop1.6/src/tclegg.h:1.14
--- eggdrop1.6/src/tclegg.h:1.13	Wed Jul 25 22:59:45 2001
+++ eggdrop1.6/src/tclegg.h	Sun Sep 23 15:17:47 2001
@@ -2,7 +2,7 @@
  * tclegg.h
  *   stuff used by tcl.c and tclhash.c
  *
- * $Id: tclegg.h,v 1.13 2001/07/26 03:59:45 guppy Exp $
+ * $Id: tclegg.h,v 1.14 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -114,8 +114,16 @@
   Function func;
 } tcl_cmds;
 
+typedef struct _cd_tcl_cmd {
+	char *name;
+	Function callback;
+	void *cdata;
+} cd_tcl_cmd;
+
 void add_tcl_commands(tcl_cmds *);
+void add_cd_tcl_cmds(cd_tcl_cmd *);
 void rem_tcl_commands(tcl_cmds *);
+void rem_cd_tcl_cmds(cd_tcl_cmd *);
 void add_tcl_strings(tcl_strings *);
 void rem_tcl_strings(tcl_strings *);
 void add_tcl_coups(tcl_coups *);
Index: eggdrop1.6/src/tclhash.c
diff -u eggdrop1.6/src/tclhash.c:1.28 eggdrop1.6/src/tclhash.c:1.29
--- eggdrop1.6/src/tclhash.c:1.28	Tue Jul 24 09:09:27 2001
+++ eggdrop1.6/src/tclhash.c	Sun Sep 23 15:17:47 2001
@@ -7,7 +7,7 @@
  *   (non-Tcl) procedure lookups for msg/dcc/file commands
  *   (Tcl) binding internal procedures to msg/dcc/file commands
  *
- * $Id: tclhash.c,v 1.28 2001/07/24 14:09:27 guppy Exp $
+ * $Id: tclhash.c,v 1.29 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -206,12 +206,16 @@
 extern cmd_t C_dcc[];
 static int tcl_bind();
 
+static cd_tcl_cmd cd_cmd_table[] = {
+	{"bind", tcl_bind, (void *)0},
+	{"unbind", tcl_bind, (void *)1}
+};
+
 void init_bind(void)
 {
   bind_table_list = NULL;
   Context;
-  Tcl_CreateCommand(interp, "bind", tcl_bind, (ClientData) 0, NULL);
-  Tcl_CreateCommand(interp, "unbind", tcl_bind, (ClientData) 1, NULL);
+  add_cd_tcl_cmds(cd_cmd_table);
   H_unld = add_bind_table("unld", HT_STACKABLE, builtin_char);
   H_time = add_bind_table("time", HT_STACKABLE, builtin_5int);
   H_note = add_bind_table("note", 0, builtin_3char);
@@ -387,10 +391,6 @@
     tm->mask = nmalloc(strlen(cmd) + 1);
     strcpy(tm->mask, cmd);
 
-#if (TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 1) || (TCL_MAJOR_VERSION >= 9)
-    str_nutf8tounicode(tm->mask, strlen(tm->mask) + 1);
-#endif
-	
     /* Link into linked list of binds. */
     tm->next = tl->first;
     tl->first = tm;
@@ -1126,13 +1126,18 @@
 {
   int	k, i;
   char	p[1024], *l;
+  cd_tcl_cmd table[2];
 
+  table[0].name = p;
+  table[0].callback = tl->func;
+  table[1].name = NULL;
   for (i = 0; cc[i].name; i++) {
     egg_snprintf(p, sizeof p, "*%s:%s", tl->name,
 		   cc[i].funcname ? cc[i].funcname : cc[i].name);
     l = (char *) nmalloc(Tcl_ScanElement(p, &k));
     Tcl_ConvertElement(p, l, k | TCL_DONT_USE_BRACES);
-    Tcl_CreateCommand(interp, p, tl->func, (ClientData) cc[i].func, NULL);
+    table[0].cdata = (void *)cc[i].func;
+    add_cd_tcl_cmds(table);
     bind_bind_entry(tl, cc[i].flags, cc[i].name, l);
     nfree(l);
   }
Index: eggdrop1.6/src/tclmisc.c
diff -u eggdrop1.6/src/tclmisc.c:1.23 eggdrop1.6/src/tclmisc.c:1.24
--- eggdrop1.6/src/tclmisc.c:1.23	Sun Jul 29 01:08:04 2001
+++ eggdrop1.6/src/tclmisc.c	Sun Sep 23 15:17:47 2001
@@ -3,7 +3,7 @@
  *   Tcl stubs for file system commands
  *   Tcl stubs for everything else
  *
- * $Id: tclmisc.c,v 1.23 2001/07/29 06:08:04 guppy Exp $
+ * $Id: tclmisc.c,v 1.24 2001/09/23 20:17:47 guppy Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -40,7 +40,77 @@
 extern struct userrec	*userlist;
 extern time_t		 now;
 extern module_entry	*module_list;
+extern int max_logs;
+extern log_t *logs;
+extern Tcl_Interp *interp;
 
+/*
+ *      Logging
+ */
+
+/* logfile [<modes> <channel> <filename>] */
+static int tcl_logfile STDVAR
+{
+  int i;
+  char s[151];
+
+  BADARGS(1, 4, " ?logModes channel logFile?");
+  if (argc == 1) {
+    /* They just want a list of the logfiles and modes */
+    for (i = 0; i < max_logs; i++)
+      if (logs[i].filename != NULL) {
+	strcpy(s, masktype(logs[i].mask));
+	strcat(s, " ");
+	strcat(s, logs[i].chname);
+	strcat(s, " ");
+	strcat(s, logs[i].filename);
+	Tcl_AppendElement(interp, s);
+      }
+    return TCL_OK;
+  }
+  BADARGS(4, 4, " ?logModes channel logFile?");
+  for (i = 0; i < max_logs; i++)
+    if ((logs[i].filename != NULL) && (!strcmp(logs[i].filename, argv[3]))) {
+      logs[i].flags &= ~LF_EXPIRING;
+      logs[i].mask = logmodes(argv[1]);
+      nfree(logs[i].chname);
+      logs[i].chname = NULL;
+      if (!logs[i].mask) {
+	/* ending logfile */
+	nfree(logs[i].filename);
+	logs[i].filename = NULL;
+	if (logs[i].f != NULL) {
+	  fclose(logs[i].f);
+	  logs[i].f = NULL;
+	}
+        logs[i].flags = 0;
+      } else {
+	logs[i].chname = (char *) nmalloc(strlen(argv[2]) + 1);
+	strcpy(logs[i].chname, argv[2]);
+      }
+      Tcl_AppendResult(interp, argv[3], NULL);
+      return TCL_OK;
+    }
+  /* Do not add logfiles without any flags to log ++rtc */
+  if (!logmodes (argv [1])) {
+    Tcl_AppendResult (interp, "can't remove \"", argv[3],
+                     "\" from list: no such logfile", NULL);
+    return TCL_ERROR;
+  }
+  for (i = 0; i < max_logs; i++)
+    if (logs[i].filename == NULL) {
+      logs[i].flags = 0;
+      logs[i].mask = logmodes(argv[1]);
+      logs[i].filename = (char *) nmalloc(strlen(argv[3]) + 1);
+      strcpy(logs[i].filename, argv[3]);
+      logs[i].chname = (char *) nmalloc(strlen(argv[2]) + 1);
+      strcpy(logs[i].chname, argv[2]);
+      Tcl_AppendResult(interp, argv[3], NULL);
+      return TCL_OK;
+    }
+  Tcl_AppendResult(interp, "reached max # of logfiles", NULL);
+  return TCL_ERROR;
+}
 
 static int tcl_putlog STDVAR
 {
@@ -542,6 +612,7 @@
 
 tcl_cmds tclmisc_cmds[] =
 {
+  {"logfile",           tcl_logfile},
   {"putlog",		tcl_putlog},
   {"putcmdlog",		tcl_putcmdlog},
   {"putxferlog",	tcl_putxferlog},
----------------------- End of diff -----------------------



More information about the Changes mailing list