[cvslog] Module eggdrop1.6: Change committed

cvslog cvs at tsss.iavalley.cc.ia.us
Thu Dec 7 21:08:00 CST 2000


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2000-12-08 03:07:49 UTC

Modified files:
     doc/UPDATES1.6 src/patch.h src/tcldcc.c src/tclmisc.c
     src/tcluser.c

Log message:

guppy: added my tclfiles.diff (left out the shit to remove the check for # in tcl_utimers and tcl_timers)

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/UPDATES1.6
diff -u eggdrop1.6/doc/UPDATES1.6:1.31 eggdrop1.6/doc/UPDATES1.6:1.32
--- eggdrop1.6/doc/UPDATES1.6:1.31	Tue Dec  5 20:45:37 2000
+++ eggdrop1.6/doc/UPDATES1.6	Thu Dec  7 21:07:38 2000
@@ -4,6 +4,7 @@
 
 1.6.2
 Found by  Fixed by  What...
+          guppy     did some cleanup in tcl[user/misc/dcc].c
           Sup       Added a channel option to .[un]stick and slightly
                     cleaned up channels.mod/cmdschan.c.
 fabulous  Fabian    Two calls to fclose() were missing in transfer.mod, causing
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.398 eggdrop1.6/src/patch.h:1.399
--- eggdrop1.6/src/patch.h:1.398	Tue Dec  5 20:45:37 2000
+++ eggdrop1.6/src/patch.h	Thu Dec  7 21:07:38 2000
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  * 
- * $Id: patch.h,v 1.398 2000/12/06 02:45:37 guppy Exp $
+ * $Id: patch.h,v 1.399 2000/12/08 03:07:38 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("976069655");		/* current unixtime */
+patch("976243381");		/* current unixtime */
 /*
  *
  *
  */
-patch("stickfix");
+patch("tclfiles");
 /*
  *
  *
Index: eggdrop1.6/src/tcldcc.c
diff -u eggdrop1.6/src/tcldcc.c:1.22 eggdrop1.6/src/tcldcc.c:1.23
--- eggdrop1.6/src/tcldcc.c:1.22	Fri Oct 27 14:35:52 2000
+++ eggdrop1.6/src/tcldcc.c	Thu Dec  7 21:07:38 2000
@@ -2,7 +2,7 @@
  * tcldcc.c -- handles:
  *   Tcl stubs for the dcc commands
  * 
- * $Id: tcldcc.c,v 1.22 2000/10/27 19:35:52 fabian Exp $
+ * $Id: tcldcc.c,v 1.23 2000/12/08 03:07:38 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -60,7 +60,6 @@
 {
   int i, j;
 
-  Context;
   BADARGS(3, 3, " idx text");
   i = atoi(argv[1]);
   j = findidx(i);
@@ -69,7 +68,6 @@
     return TCL_ERROR;
   }
   dumplots(-i, "", argv[2]);
-
   return TCL_OK;
 }
 
@@ -83,15 +81,15 @@
  *
  * (added by drummer at sophia.jpte.hu)
  */
+
 static int tcl_putdccraw STDVAR
 {
   int i, j = 0, z;
 
-  Context;
   BADARGS(4, 4, " idx size text");
   z = atoi(argv[1]);
   for (i = 0; i < dcc_total; i++) {
-    if (z == 0 && !strcmp(dcc[i].nick, "(server)")) {
+    if (!z && !strcmp(dcc[i].nick, "(server)")) {
       j = dcc[i].sock;
       break;
     } else if (dcc[i].sock == z) {
@@ -109,7 +107,6 @@
 
 static int tcl_dccsimul STDVAR
 {
-  Context;
   BADARGS(3, 3, " idx command");
   if (enable_simul) {
     int idx = findidx(atoi(argv[1]));
@@ -136,10 +133,8 @@
 {
   char msg[401];
 
-  Context;
   BADARGS(2, 2, " message");
-  strncpy(msg, argv[1], 400);
-  msg[400] = 0;
+  strncpyz(msg, argv[1], sizeof msg);
   chatout("*** %s\n", msg);
   botnet_send_chat(-1, botnetnick, msg);
   return TCL_OK;
@@ -150,33 +145,27 @@
   int i;
   char s[10];
 
-  Context;
   BADARGS(2, 2, " nickname");
   for (i = 0; i < dcc_total; i++)
-    if (!egg_strcasecmp(argv[1], dcc[i].nick) &&
-	 (dcc[i].type->flags & DCT_SIMUL)) {
+    if ((dcc[i].type->flags & DCT_SIMUL) &&
+        !egg_strcasecmp(argv[1], dcc[i].nick)) {
       egg_snprintf(s, sizeof s, "%ld", dcc[i].sock);
       Tcl_AppendResult(irp, s, NULL);
       return TCL_OK;
     }
   Tcl_AppendResult(irp, "-1", NULL);
-
   return TCL_OK;
 }
 
 static int tcl_getchan STDVAR
 {
-  char s[10];
+  char s[7];
   int idx;
 
-  Context;
   BADARGS(2, 2, " idx");
   idx = findidx(atoi(argv[1]));
-  if (idx < 0) {
-    Tcl_AppendResult(irp, "invalid idx", NULL);
-    return TCL_ERROR;
-  }
-  if (dcc[idx].type != &DCC_CHAT && dcc[idx].type != &DCC_SCRIPT) {
+  if (idx < 0 ||
+      (dcc[idx].type != &DCC_CHAT && dcc[idx].type != &DCC_SCRIPT)) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
@@ -193,14 +182,10 @@
   int idx, chan;
   module_entry *me;
 
-  Context;
   BADARGS(3, 3, " idx channel");
   idx = findidx(atoi(argv[1]));
-  if (idx < 0) {
-    Tcl_AppendResult(irp, "invalid idx", NULL);
-    return TCL_ERROR;
-  }
-  if (dcc[idx].type != &DCC_CHAT && dcc[idx].type != &DCC_SCRIPT) {
+  if (idx < 0 ||
+      (dcc[idx].type != &DCC_CHAT && dcc[idx].type != &DCC_SCRIPT)) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
@@ -243,7 +228,6 @@
   /* Console autosave. */
   if ((me = module_find("console", 1, 1))) {
     Function *func = me->funcs;
-
     (func[CONSOLE_DOSTORE]) (idx);
   }
   return TCL_OK;
@@ -254,7 +238,6 @@
   int chan;
   char msg[401];
 
-  Context;
   BADARGS(3, 3, " channel message");
   chan = atoi(argv[1]);
   if ((chan < 0) || (chan > 199999)) {
@@ -262,9 +245,7 @@
 		     NULL);
     return TCL_ERROR;
   }
-  strncpy(msg, argv[2], 400);
-  msg[400] = 0;
-
+  strncpyz(msg, argv[2], sizeof msg);
   chanout_but(-1, chan, "*** %s\n", argv[2]);
   botnet_send_chan(-1, botnetnick, NULL, chan, argv[2]);
   check_tcl_bcst(botnetnick, chan, argv[2]);
@@ -276,14 +257,9 @@
   int i, j, pls, arg;
   module_entry *me;
 
-  Context;
   BADARGS(2, 4, " idx ?channel? ?console-modes?");
   i = findidx(atoi(argv[1]));
-  if (i < 0) {
-    Tcl_AppendResult(irp, "invalid idx", NULL);
-    return TCL_ERROR;
-  }
-  if (dcc[i].type != &DCC_CHAT) {
+  if (i < 0 || dcc[i].type != &DCC_CHAT) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
@@ -300,12 +276,11 @@
 	Tcl_AppendResult(irp, "invalid channel", NULL);
 	return TCL_ERROR;
       }
-      strncpy(dcc[i].u.chat->con_chan, argv[arg], 81);
-      dcc[i].u.chat->con_chan[80] = 0;
+      strncpyz(dcc[i].u.chat->con_chan, argv[arg], 81);
     } else {
       if ((argv[arg][0] != '+') && (argv[arg][0] != '-'))
 	dcc[i].u.chat->con_flags = 0;
-do_console_flags:
+      do_console_flags:
       for (j = 0; j < strlen(argv[arg]); j++) {
 	if (argv[arg][j] == '+')
 	  pls = 1;
@@ -329,7 +304,6 @@
   /* Console autosave. */
   if (argc > 2 && (me = module_find("console", 1, 1))) {
     Function *func = me->funcs;
-
     (func[CONSOLE_DOSTORE]) (i);
   }
   return TCL_OK;
@@ -340,17 +314,12 @@
   int i, j, pls, arg;
   module_entry *me;
 
-  Context;
   BADARGS(2, 4, " idx ?strip-flags?");
   i = findidx(atoi(argv[1]));
-  if (i < 0) {
+  if (i < 0 || dcc[i].type != &DCC_CHAT) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
-  if (dcc[i].type != &DCC_CHAT) {
-    Tcl_AppendResult(irp, "invalid idx", NULL);
-    return TCL_ERROR;
-  }
   pls = 1;
   for (arg = 2; arg < argc; arg++) {
     if ((argv[arg][0] != '+') && (argv[arg][0] != '-'))
@@ -376,7 +345,6 @@
   /* Console autosave. */
   if (argc > 2 && (me = module_find("console", 1, 1))) {
     Function *func = me->funcs;
-
     (func[CONSOLE_DOSTORE]) (i);
   }
   return TCL_OK;
@@ -387,17 +355,12 @@
   int i;
   module_entry *me;
 
-  Context;
   BADARGS(2, 3, " idx ?status?");
   i = findidx(atoi(argv[1]));
-  if (i < 0) {
+  if (i < 0 || dcc[i].type != &DCC_CHAT) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
-  if (dcc[i].type != &DCC_CHAT) {
-    Tcl_AppendResult(irp, "invalid idx", NULL);
-    return TCL_ERROR;
-  }
   if (argc == 3) {
     if (atoi(argv[2]))
       dcc[i].status |= STAT_ECHO;
@@ -411,7 +374,6 @@
   /* Console autosave. */
   if (argc > 2 && (me = module_find("console", 1, 1))) {
     Function *func = me->funcs;
-
     (func[CONSOLE_DOSTORE]) (i);
   }
   return TCL_OK;
@@ -423,21 +385,16 @@
   char x[20];
   module_entry *me;
 
-  Context;
   BADARGS(2, 3, " idx ?status?");
   i = findidx(atoi(argv[1]));
-  if (i < 0) {
-    Tcl_AppendResult(irp, "invalid idx", NULL);
-    return TCL_ERROR;
-  }
-  if (dcc[i].type != &DCC_CHAT) {
+  if (i < 0 || dcc[i].type != &DCC_CHAT) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
   if (argc == 3) {
     int l = atoi(argv[2]);
 
-    if (l == 0)
+    if (!l)
       dcc[i].status &= ~STAT_PAGE;
     else {
       dcc[i].status |= STAT_PAGE;
@@ -452,7 +409,6 @@
   /* Console autosave. */
   if ((argc > 2) && (me = module_find("console", 1, 1))) {
     Function *func = me->funcs;
-
     (func[CONSOLE_DOSTORE]) (i);
   }
   return TCL_OK;
@@ -463,7 +419,6 @@
   int idx;
   void *hold;
 
-  Context;
   BADARGS(3, 3, " idx command");
   idx = findidx(atoi(argv[1]));
   if (idx < 0) {
@@ -482,7 +437,6 @@
   }
   hold = dcc[idx].u.other;
   dcc[idx].u.script = get_data_ptr(sizeof(struct script_info));
-
   dcc[idx].u.script->u.other = hold;
   dcc[idx].u.script->type = dcc[idx].type;
   dcc[idx].type = &DCC_SCRIPT;
@@ -498,10 +452,9 @@
 {
   int idx;
 
-  Context;
   BADARGS(2, 2, " idx");
   idx = findidx(atoi(argv[1]));
-  if ((idx < 0) || !(dcc[idx].type->flags & DCT_VALIDIDX))
+  if (idx < 0 || !(dcc[idx].type->flags & DCT_VALIDIDX))
      Tcl_AppendResult(irp, "0", NULL);
   else
      Tcl_AppendResult(irp, "1", NULL);
@@ -512,15 +465,12 @@
 {
   int idx;
 
-  ContextNote(argv[1] ? argv[1] : "argv[1] == NULL!");
   BADARGS(2, 3, " idx ?reason?");
   idx = findidx(atoi(argv[1]));
   if (idx < 0) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
-  Context;
-
   /* Don't kill terminal socket */
   if ((dcc[idx].sock == STDOUT) && !backgrd)
     return TCL_OK;
@@ -547,16 +497,13 @@
   int i;
   char msg[401];
 
-  Context;
   BADARGS(3, 3, " botnick message");
   i = nextbot(argv[1]);
   if (i < 0) {
     Tcl_AppendResult(irp, "bot is not in the botnet", NULL);
     return TCL_ERROR;
   }
-  strncpy(msg, argv[2], 400);
-  msg[400] = 0;
-
+  strncpyz(msg, argv[2], sizeof msg);
   botnet_send_zapf(i, botnetnick, argv[1], msg);
   return TCL_OK;
 }
@@ -565,10 +512,8 @@
 {
   char msg[401];
 
-  Context;
   BADARGS(2, 2, " message");
-  strncpy(msg, argv[1], 400);
-  msg[400] = 0;
+  strncpyz(msg, argv[1], sizeof msg);
   botnet_send_zapf_broad(-1, botnetnick, NULL, msg);
   return TCL_OK;
 }
@@ -577,7 +522,6 @@
 {
   int idx;
 
-  Context;
   BADARGS(2, 2, " idx");
   idx = findidx(atoi(argv[1]));
   if (idx < 0) {
@@ -592,7 +536,6 @@
 {
   int i;
 
-  Context;
   BADARGS(2, 2, " bot");
   i = nextbot(argv[1]);
   if (i < 0)
@@ -606,7 +549,6 @@
 {
   tand_t *bot;
 
-  Context;
   BADARGS(1, 1, "");
   for (bot = tandbot; bot; bot = bot->next)
      Tcl_AppendElement(irp, bot->bot);
@@ -619,7 +561,6 @@
   char *list[4], *p;
   char sh[2], string[20];
 
-  Context;
   BADARGS(1, 1, "");
   sh[1] = 0;
   list[3] = sh;
@@ -627,7 +568,7 @@
   for (bot = tandbot; bot; bot = bot->next) {
     list[0] = bot->bot;
     list[1] = (bot->uplink == (tand_t *) 1) ? botnetnick : bot->uplink->bot;
-    strcpy(string, int_to_base10(bot->ver));
+    strncpyz(string, int_to_base10(bot->ver), sizeof string);
     sh[0] = bot->share;
     p = Tcl_Merge(4, list);
     Tcl_AppendElement(irp, p);
@@ -681,7 +622,6 @@
   char c[2], idle[10], work[20], *list[7], *p;
   int chan, i;
 
-  Context;
   BADARGS(2, 2, " chan");
   if (argv[1][0] == '*')
      chan = -1;
@@ -753,7 +693,6 @@
 {
   char s[20];
 
-  Context;
   BADARGS(1, 1, "");
   egg_snprintf(s, sizeof s, "%d", dcc_total);
   Tcl_AppendResult(irp, s, NULL);
@@ -765,14 +704,13 @@
   int  x, idx;
   char s[21];
 
-  Context;
   BADARGS(2, 2, " idx");
   idx = findidx(atoi(argv[1]));
   if (idx < 0) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
   }
-  x = (now - (dcc[idx].timeval));
+  x = (now - dcc[idx].timeval);
   egg_snprintf(s, sizeof s, "%d", x);
   Tcl_AppendElement(irp, s);
   return TCL_OK;
@@ -782,7 +720,6 @@
 {
   int idx;
 
-  Context;
   BADARGS(2, 2, " idx");
   idx = findidx(atol(argv[1]));
   if (idx < 0 || dcc[idx].type != &DCC_CHAT) {
@@ -799,7 +736,6 @@
 {
   int idx;
 
-  Context;
   BADARGS(3, 3, " idx message");
   idx = findidx(atol(argv[1]));
   if (idx < 0 || dcc[idx].type != &DCC_CHAT) {
@@ -822,16 +758,13 @@
   int x, i;
   char bot[HANDLEN + 1], bot2[HANDLEN + 1];
 
-  Context;
   BADARGS(2, 3, " ?via-bot? bot");
-  strncpy(bot, argv[1], HANDLEN);
-  bot[HANDLEN] = 0;
+  strncpyz(bot, argv[1], sizeof bot);
   if (argc == 2)
      x = botlink("", -2, bot);
   else {
     x = 1;
-    strncpy(bot2, argv[2], HANDLEN);
-    bot2[HANDLEN] = 0;
+    strncpyz(bot2, argv[2], sizeof bot2);
     i = nextbot(bot);
     if (i < 0)
       x = 0;
@@ -848,10 +781,8 @@
   int i, x;
   char bot[HANDLEN + 1];
 
-  Context;
   BADARGS(2, 3, " bot ?comment?");
-  strncpy(bot, argv[1], HANDLEN);
-  bot[HANDLEN] = 0;
+  strncpyz(bot, argv[1], sizeof bot);
   i = nextbot(bot);
   if (i < 0)
      x = 0;
@@ -872,7 +803,6 @@
   int i, z, sock;
   char s[81];
 
-  Context;
   BADARGS(3, 3, " hostname port");
   if (dcc_total == max_dcc) {
     Tcl_AppendResult(irp, "out of dcc table space", NULL);
@@ -887,7 +817,7 @@
   if (z < 0) {
     killsock(sock);
     if (z == (-2))
-      strcpy(s, "DNS lookup failed");
+      strncpyz(s, "DNS lookup failed", sizeof s);
     else
       neterror(s);
     Tcl_AppendResult(irp, s, NULL);
@@ -898,8 +828,7 @@
   dcc[i].sock = sock;
   dcc[i].port = atoi(argv[2]);
   strcpy(dcc[i].nick, "*");
-  strncpy(dcc[i].host, argv[1], UHOSTMAX);
-  dcc[i].host[UHOSTMAX] = 0;
+  strncpyz(dcc[i].host, argv[1], UHOSTMAX);
   egg_snprintf(s, sizeof s, "%d", sock);
   Tcl_AppendResult(irp, s, NULL);
   return TCL_OK;
@@ -917,7 +846,6 @@
   char s[10];
   struct portmap *pmap = NULL, *pold = NULL;
 
-  Context;
   BADARGS(3, 5, " port type ?mask?/?proc ?flag??");
   port = realport = atoi(argv[1]);
   for (pmap = root; pmap; pold = pmap, pmap = pmap->next)
@@ -988,8 +916,7 @@
       }
       dcc[idx].status = LSTN_PUBLIC;
     }
-    strncpy(dcc[idx].host, argv[3], UHOSTMAX);
-    dcc[idx].host[UHOSTMAX] = 0;
+    strncpyz(dcc[idx].host, argv[3], UHOSTMAX);
     egg_snprintf(s, sizeof s, "%d", port);
     Tcl_AppendResult(irp, s, NULL);
     return TCL_OK;
@@ -1009,15 +936,13 @@
     return TCL_ERROR;
   }
   if (argc == 4) {
-    strncpy(dcc[idx].host, argv[3], UHOSTMAX);
-    dcc[idx].host[UHOSTMAX] = 0;
+    strncpyz(dcc[idx].host, argv[3], UHOSTMAX);
   } else
     strcpy(dcc[idx].host, "*");
   egg_snprintf(s, sizeof s, "%d", port);
   Tcl_AppendResult(irp, s, NULL);
   if (!pmap) {
     pmap = nmalloc(sizeof(struct portmap));
-
     pmap->next = root;
     root = pmap;
   }
@@ -1032,17 +957,15 @@
   char who[NOTENAMELEN + 1];
   int i, ok = 0;
 
-  Context;
   BADARGS(2, 3, " user at bot ?reason?");
-  strncpy(who, argv[1], NOTENAMELEN);
-  who[NOTENAMELEN] = 0;
+  strncpyz(who, argv[1], sizeof who);
   if (strchr(who, '@') != NULL) {
     char whonick[HANDLEN + 1];
 
     splitc(whonick, who, '@');
     whonick[HANDLEN] = 0;
     if (!egg_strcasecmp(who, botnetnick))
-       strcpy(who, whonick);
+       strncpyz(who, whonick, sizeof who);
     else if (remote_boots > 1) {
       i = nextbot(who);
       if (i < 0)
@@ -1053,8 +976,8 @@
     }
   }
   for (i = 0; i < dcc_total; i++)
-    if ((!egg_strcasecmp(dcc[i].nick, who)) && !ok &&
-	(dcc[i].type->flags & DCT_CANBOOT)) {
+    if (!ok && (dcc[i].type->flags & DCT_CANBOOT) &&
+        !egg_strcasecmp(dcc[i].nick, who)) {
       do_boot(i, botnetnick, argv[2] ? argv[2] : "");
       ok = 1;
     }
@@ -1063,7 +986,6 @@
 
 static int tcl_rehash STDVAR
 {
-  Context;
   BADARGS(1, 1, " ");
   if (make_userfile) {
     putlog(LOG_MISC, "*", USERF_NONEEDNEW);
@@ -1077,7 +999,6 @@
 
 static int tcl_restart STDVAR
 {
-  Context;
   BADARGS(1, 1, " ");
   if (!backgrd) {
     Tcl_AppendResult(interp, "You can't restart a -n bot", NULL);
Index: eggdrop1.6/src/tclmisc.c
diff -u eggdrop1.6/src/tclmisc.c:1.15 eggdrop1.6/src/tclmisc.c:1.16
--- eggdrop1.6/src/tclmisc.c:1.15	Fri Oct 27 14:32:41 2000
+++ eggdrop1.6/src/tclmisc.c	Thu Dec  7 21:07:38 2000
@@ -3,7 +3,7 @@
  *   Tcl stubs for file system commands
  *   Tcl stubs for everything else
  * 
- * $Id: tclmisc.c,v 1.15 2000/10/27 19:32:41 fabian Exp $
+ * $Id: tclmisc.c,v 1.16 2000/12/08 03:07:38 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -48,10 +48,8 @@
 {
   char logtext[501];
 
-  Context;
   BADARGS(2, 2, " text");
-  strncpy(logtext, argv[1], 500);
-  logtext[500] = 0;
+  strncpyz(logtext, argv[1], sizeof logtext);
   putlog(LOG_MISC, "*", "%s", logtext);
   return TCL_OK;
 }
@@ -60,10 +58,8 @@
 {
   char logtext[501];
 
-  Context;
   BADARGS(2, 2, " text");
-  strncpy(logtext, argv[1], 500);
-  logtext[500] = 0;
+  strncpyz(logtext, argv[1], sizeof logtext);
   putlog(LOG_CMDS, "*", "%s", logtext);
   return TCL_OK;
 }
@@ -72,10 +68,8 @@
 {
   char logtext[501];
 
-  Context;
   BADARGS(2, 2, " text");
-  strncpy(logtext, argv[1], 500);
-  logtext[500] = 0;
+  strncpyz(logtext, argv[1], sizeof logtext);
   putlog(LOG_FILES, "*", "%s", logtext);
   return TCL_OK;
 }
@@ -85,15 +79,13 @@
   int lev = 0;
   char logtext[501];
 
-  Context;
   BADARGS(4, 4, " level channel text");
   lev = logmodes(argv[1]);
-  if (lev == 0) {
+  if (!lev) {
     Tcl_AppendResult(irp, "No valid log-level given", NULL);
     return TCL_ERROR;
   }
-  strncpy(logtext, argv[3], 500);
-  logtext[500] = 0;
+  strncpyz(logtext, argv[3], sizeof logtext);
   putlog(lev, argv[2], "%s", logtext);
   return TCL_OK;
 }
@@ -103,7 +95,6 @@
   unsigned long x;
   char s[41];
 
-  Context;
   BADARGS(3, 3, " minutes command");
   if (atoi(argv[1]) < 0) {
     Tcl_AppendResult(irp, "time value must be positive", NULL);
@@ -126,14 +117,12 @@
   int			 matching = 0;
 
   BADARGS(1, 2, " ?type/mask?");
-
   if (argv[1])
     tl_kind = find_bind_table(argv[1]);
   else
     tl_kind = NULL;
   if (!tl_kind && argv[1])
     matching = 1;
-
   for (tl = tl_kind ? tl_kind : bind_table_list; tl;
        tl = tl_kind ? 0 : tl->next) {
     if (tl->flags & HT_DELETED)
@@ -149,7 +138,6 @@
             !wild_match(argv[1], tm->mask) && 
             !wild_match(argv[1], tc->func_name))
           continue;
-
 	build_flags(flg, &(tc->flags), NULL);
         sprintf(hits, "%i", (int) tc->hits);
         list[0] = tl->name;
@@ -171,7 +159,6 @@
   unsigned long x;
   char s[41];
 
-  Context;
   BADARGS(3, 3, " seconds command");
   if (atoi(argv[1]) < 0) {
     Tcl_AppendResult(irp, "time value must be positive", NULL);
@@ -187,29 +174,26 @@
 
 static int tcl_killtimer STDVAR
 {
-  Context;
   BADARGS(2, 2, " timerID");
   if (strncmp(argv[1], "timer", 5)) {
     Tcl_AppendResult(irp, "argument is not a timerID", NULL);
     return TCL_ERROR;
   }
   if (remove_timer(&timer, atol(&argv[1][5])))
-     return TCL_OK;
+    return TCL_OK;
   Tcl_AppendResult(irp, "invalid timerID", NULL);
   return TCL_ERROR;
 }
 
 static int tcl_killutimer STDVAR
 {
-  Context;
   BADARGS(2, 2, " timerID");
   if (strncmp(argv[1], "timer", 5)) {
     Tcl_AppendResult(irp, "argument is not a timerID", NULL);
     return TCL_ERROR;
   }
   if (remove_timer(&utimer, atol(&argv[1][5])))
-     return TCL_OK;
-
+    return TCL_OK;
   Tcl_AppendResult(irp, "invalid timerID", NULL);
   return TCL_ERROR;
 }
@@ -218,15 +202,14 @@
 {
   char s[256];
   time_t sec;
-  BADARGS(2, 2, " seconds");
 
+  BADARGS(2, 2, " seconds");
   if (atol(argv[1]) <= 0) {
     Tcl_AppendResult(irp, "0 seconds", NULL);
     return TCL_OK;
   }
   sec = atoi(argv[1]);
   s[0] = 0;
-
   if (sec >= 31536000) {
     sprintf(s, "%d year", (int) (sec / 31536000));
     if ((int) (sec / 31536000) > 1)
@@ -273,18 +256,16 @@
 
 static int tcl_unixtime STDVAR
 {
-  char s[20];
+  char s[10];
 
-  Context;
   BADARGS(1, 1, "");
-  sprintf(s, "%lu", (unsigned long) now);
+  egg_snprintf(s, sizeof s, "%lu", (unsigned long) now);
   Tcl_AppendResult(irp, s, NULL);
   return TCL_OK;
 }
 
 static int tcl_timers STDVAR
 {
-  Context;
   BADARGS(1, 1, "");
   list_timers(irp, timer);
   return TCL_OK;
@@ -292,7 +273,6 @@
 
 static int tcl_utimers STDVAR
 {
-  Context;
   BADARGS(1, 1, "");
   list_timers(irp, utimer);
   return TCL_OK;
@@ -301,24 +281,21 @@
 static int tcl_ctime STDVAR
 {
   time_t tt;
-  char s[81];
+  char s[25];
 
-  Context;
   BADARGS(2, 2, " unixtime");
   tt = (time_t) atol(argv[1]);
-  strcpy(s, ctime(&tt));
-  s[strlen(s) - 1] = 0;
+  strncpyz(s, ctime(&tt), sizeof s);
   Tcl_AppendResult(irp, s, NULL);
   return TCL_OK;
 }
 
 static int tcl_myip STDVAR
 {
-  char s[21];
+  char s[16];
 
-  Context;
   BADARGS(1, 1, "");
-  sprintf(s, "%lu", iptolong(getmyip()));
+  egg_snprintf(s, sizeof s, "%lu", iptolong(getmyip()));
   Tcl_AppendResult(irp, s, NULL);
   return TCL_OK;
 }
@@ -326,17 +303,15 @@
 static int tcl_rand STDVAR
 {
   unsigned long x;
-  char s[41];
+  char s[11];
 
-  Context;
   BADARGS(2, 2, " limit");
   if (atol(argv[1]) <= 0) {
     Tcl_AppendResult(irp, "random limit must be greater than zero", NULL);
     return TCL_ERROR;
   }
   x = random() % (atol(argv[1]));
-
-  sprintf(s, "%lu", x);
+  egg_snprintf(s, sizeof s, "%lu", x);
   Tcl_AppendResult(irp, s, NULL);
   return TCL_OK;
 }
@@ -345,14 +320,10 @@
 {
   char s[5], from[NOTENAMELEN + 1], to[NOTENAMELEN + 1], msg[451];
 
-  Context;
   BADARGS(4, 4, " from to message");
-  strncpy(from, argv[1], NOTENAMELEN);
-  from[NOTENAMELEN] = 0;
-  strncpy(to, argv[2], NOTENAMELEN);
-  to[NOTENAMELEN] = 0;
-  strncpy(msg, argv[3], 450);
-  msg[450] = 0;
+  strncpyz(from, argv[1], sizeof from);
+  strncpyz(to, argv[2], sizeof to);
+  strncpyz(msg, argv[3], sizeof msg);
   egg_snprintf(s, sizeof s, "%d", add_note(to, from, msg, -1, 0));
   Tcl_AppendResult(irp, s, NULL);
   return TCL_OK;
@@ -363,10 +334,8 @@
   char nick[NICKLEN];
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
 
-  Context;
   BADARGS(3, 3, " nickname filename");
-  strncpy(nick, argv[1], NICKLEN - 1);
-  nick[NICKLEN - 1] = 0;
+  strncpyz(nick, argv[1], sizeof nick);
   get_user_flagrec(get_user_by_nick(nick), &fr, NULL);
   showhelp(argv[1], argv[2], &fr, HELP_TEXT);
   return TCL_OK;
@@ -377,7 +346,6 @@
   int idx, i;
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
 
-  Context;
   BADARGS(3, 3, " idx filename");
   i = atoi(argv[1]);
   idx = findidx(i);
@@ -392,7 +360,6 @@
 
 static int tcl_backup STDVAR
 {
-  Context;
   BADARGS(1, 1, "");
   backup_userfile();
   return TCL_OK;
@@ -417,7 +384,6 @@
   botnet_send_bye();
   write_userfile(-1);
   fatal(g, 0);
-  /* Should never return, but, to keep gcc happy: */
   return TCL_OK;
 }
 
@@ -427,7 +393,6 @@
   struct tm *tm1;
   time_t t;
 
-  Context;
   BADARGS(2, 3, " format ?time?");
   if (argc == 3)
     t = atol(argv[2]);
@@ -446,7 +411,6 @@
 {
   const char *p;
 
-  Context;
   BADARGS(2, 2, " module-name");
   p = module_load(argv[1]);
   if (p && strcmp(p, MOD_ALREADYLOAD) && !strcmp(argv[0], "loadmodule"))
@@ -457,7 +421,6 @@
 
 static int tcl_unloadmodule STDVAR
 {
-  Context;
   BADARGS(2, 2, " module-name");
   Tcl_AppendResult(irp, module_unload(argv[1], origbotname), NULL);
   return TCL_OK;
@@ -491,7 +454,6 @@
   char s[40], s2[40];
   int i;
 
-  Context;
   BADARGS(1, 1, "");
   for (current = module_list; current; current = current->next) {
     list[0] = current->name;
@@ -520,7 +482,6 @@
 
 static int tcl_loadhelp STDVAR
 {
-  Context;
   BADARGS(2, 2, " helpfile-name");
   add_help_reference(argv[1]);
   return TCL_OK;
@@ -528,7 +489,6 @@
 
 static int tcl_unloadhelp STDVAR
 {
-  Context;
   BADARGS(2, 2, " helpfile-name");
   rem_help_reference(argv[1]);
   return TCL_OK;
@@ -536,7 +496,6 @@
 
 static int tcl_reloadhelp STDVAR
 {
-  Context;
   BADARGS(1, 1, "");
   reload_help_data();
   return TCL_OK;
@@ -549,18 +508,13 @@
   unsigned char digest[16];
   int           i;
 
-  Context;
   BADARGS(2, 2, " string");
-
   MD5Init(&md5context);
   MD5Update(&md5context, (unsigned char *)argv[1], strlen(argv[1]));
   MD5Final(digest, &md5context);
-
   for(i=0; i<16; i++)
     sprintf(digest_string + (i*2), "%.2x", digest[i]);
-
   Tcl_AppendResult(irp, digest_string, NULL);
-
   return TCL_OK;
 }
 
Index: eggdrop1.6/src/tcluser.c
diff -u eggdrop1.6/src/tcluser.c:1.17 eggdrop1.6/src/tcluser.c:1.18
--- eggdrop1.6/src/tcluser.c:1.17	Fri Jun  9 20:03:43 2000
+++ eggdrop1.6/src/tcluser.c	Thu Dec  7 21:07:38 2000
@@ -2,7 +2,7 @@
  * tcluser.c -- handles:
  *   Tcl stubs for the user-record-oriented commands
  * 
- * $Id: tcluser.c,v 1.17 2000/06/10 01:03:43 fabian Exp $
+ * $Id: tcluser.c,v 1.18 2000/12/08 03:07:38 guppy Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -38,7 +38,6 @@
 
 static int tcl_countusers STDVAR
 {
-  Context;
   BADARGS(1, 1, "");
   Tcl_AppendResult(irp, int_to_base10(count_users(userlist)), NULL);
   return TCL_OK;
@@ -46,7 +45,6 @@
 
 static int tcl_validuser STDVAR
 {
-  Context;
   BADARGS(2, 2, " handle");
   Tcl_AppendResult(irp, get_user_by_handle(userlist, argv[1]) ? "1" : "0",
 		   NULL);
@@ -57,7 +55,6 @@
 {
   struct userrec *u;
 
-  Context;
   BADARGS(2, 2, " nick!user at host");
   u = get_user_by_host(argv[1]);
   Tcl_AppendResult(irp, u ? u->handle : "*", NULL);
@@ -68,7 +65,6 @@
 {
   struct userrec *u;
 
-  Context;
   BADARGS(3, 3, " handle passwd");
   Tcl_AppendResult(irp, ((u = get_user_by_handle(userlist, argv[1])) &&
 			 u_pass_match(u, argv[2])) ? "1" : "0", NULL);
@@ -81,7 +77,6 @@
   struct flag_record pls, mns, user;
   struct userrec *u;
 
-  Context;
   BADARGS(2, 4, " handle ?changes? ?channel?");
   if ((argv[1][0] == '*') || !(u = get_user_by_handle(userlist, argv[1]))) {
     Tcl_AppendResult(irp, "*", NULL);
@@ -91,8 +86,8 @@
     user.match = FR_GLOBAL | FR_CHAN;
     chan = argv[3];
     chg = argv[2];
-  } else if ((argc == 3)
-	    && (argv[2][0] && (strchr(CHANMETA, argv[2][0]) != NULL))) {
+  } else if (argc == 3 && argv[2][0] &&
+             strchr(CHANMETA, argv[2][0]) != NULL) {
     /* We need todo extra checking here to stop us mixing up +channel's
      * with flags. <cybah>
      */
@@ -158,7 +153,6 @@
   struct flag_record pls, mns, user;
   struct userrec *u;
 
-  Context;
   BADARGS(2, 4, " bot-handle ?changes? ?channel?");
   u = get_user_by_handle(userlist, argv[1]);
   if ((argv[1][0] == '*') || !u || !(u->flags & USER_BOT)) {
@@ -169,8 +163,8 @@
     user.match = FR_BOT | FR_CHAN;
     chan = argv[3];
     chg = argv[2];
-  } else if ((argc == 3)
-	     && (argv[2][0] && (strchr(CHANMETA, argv[2][0]) != NULL))) {
+  } else if (argc == 3 && argv[2][0] &&
+             strchr(CHANMETA, argv[2][0]) != NULL) {
     /* We need todo extra checking here to stop us mixing up +channel's
      * with flags. <cybah>
      */
@@ -231,12 +225,9 @@
   struct flag_record plus, minus, user;
   int ok = 0, f;
 
-  Context;
   BADARGS(3, 4, " handle flags ?channel?");
-  Context;			/* a2 - Last context: tcluser.c/184 */
   if ((u = get_user_by_handle(userlist, argv[1])) &&
       ((argc == 3) || findchan_by_dname(argv[3]))) {
-    Context;			/* a2 - Last context: tcluser.c/184 */
     user.match = FR_GLOBAL | (argc == 4 ? FR_CHAN : 0) | FR_BOT;
     get_user_flagrec(u, &user, argv[3]);
     plus.match = user.match;
@@ -244,7 +235,6 @@
     f = (minus.global || minus.udef_global || minus.chan ||
 	 minus.udef_chan || minus.bot);
     if (flagrec_eq(&plus, &user)) {
-      Context;			/* a2 - Last context: tcluser.c/184 */
       if (!f)
 	ok = 1;
       else {
@@ -254,14 +244,12 @@
       }
     }
   }
-  Context;			/* a2 - Last context: tcluser.c/184 */
   Tcl_AppendResult(irp, ok ? "1" : "0", NULL);
   return TCL_OK;
 }
 
 static int tcl_adduser STDVAR
 {
-  Context;
   BADARGS(3, 3, " handle ?hostmask?");
   if (strlen(argv[1]) > HANDLEN)
     argv[1][HANDLEN] = 0;
@@ -279,7 +267,6 @@
   struct bot_addr *bi;
   char *p, *q;
 
-  Context;
   BADARGS(3, 3, " handle address");
   if (strlen(argv[1]) > HANDLEN)
      argv[1][HANDLEN] = 0;
@@ -290,7 +277,7 @@
   else {
     userlist = adduser(userlist, argv[1], "none", "-", USER_BOT);
     bi = user_malloc(sizeof(struct bot_addr));
-     q = strchr(argv[2], ':');
+    q = strchr(argv[2], ':');
     if (!q) {
       bi->address = user_malloc(strlen(argv[2]) + 1);
       strcpy(bi->address, argv[2]);
@@ -316,7 +303,6 @@
 
 static int tcl_deluser STDVAR
 {
-  Context;
   BADARGS(2, 2, " handle");
   Tcl_AppendResult(irp, (argv[1][0] == '*') ? "0" :
 		   int_to_base10(deluser(argv[1])), NULL);
@@ -325,7 +311,6 @@
 
 static int tcl_delhost STDVAR
 {
-  Context;
   BADARGS(3, 3, " handle hostmask");
   if ((!get_user_by_handle(userlist, argv[1])) || (argv[1][0] == '*')) {
     Tcl_AppendResult(irp, "non-existent user", NULL);
@@ -342,9 +327,8 @@
   struct flag_record user, plus, minus;
   int ok = 1, f = 0;
 
-  Context;
   BADARGS(1, 3, " ?flags ?channel??");
-  if ((argc == 3) && !findchan_by_dname(argv[2])) {
+  if (argc == 3 && !findchan_by_dname(argv[2])) {
     Tcl_AppendResult(irp, "Invalid channel: ", argv[2], NULL);
     return TCL_ERROR;
   }
@@ -373,14 +357,12 @@
 
 static int tcl_save STDVAR
 {
-  Context;
   write_userfile(-1);
   return TCL_OK;
 }
 
 static int tcl_reload STDVAR
 {
-  Context;
   reload();
   return TCL_OK;
 }
@@ -391,14 +373,12 @@
   char newhand[HANDLEN + 1];
   int x = 1, i;
 
-  Context;
   BADARGS(3, 3, " oldnick newnick");
   u = get_user_by_handle(userlist, argv[1]);
   if (!u)
      x = 0;
   else {
-    strncpy(newhand, argv[2], HANDLEN);
-    newhand[HANDLEN] = 0;
+    strncpyz(newhand, argv[2], sizeof newhand);
     for (i = 0; i < strlen(newhand); i++)
       if ((newhand[i] <= 32) || (newhand[i] >= 127) || (newhand[i] == '@'))
 	newhand[i] = '?';
@@ -416,7 +396,6 @@
   }
   if (x)
      x = change_handle(u, newhand);
-
   Tcl_AppendResult(irp, x ? "1" : "0", NULL);
   return TCL_OK;
 }
@@ -425,11 +404,9 @@
 {
   int i;
 
-  Context;
   BADARGS(1, 1, "");
   for (i = 0; i < dcc_total; i++) {
-    if ((dcc[i].type == &DCC_BOT) &&
-	(dcc[i].status & STAT_GETTING)) {
+    if (dcc[i].type == &DCC_BOT && dcc[i].status & STAT_GETTING) {
       Tcl_AppendResult(irp, "1", NULL);
       return TCL_OK;
     }
@@ -440,7 +417,6 @@
 
 static int tcl_isignore STDVAR
 {
-  Context;
   BADARGS(2, 2, " nick!user at host");
   Tcl_AppendResult(irp, match_ignore(argv[1]) ? "1" : "0", NULL);
   return TCL_OK;
@@ -451,14 +427,10 @@
   time_t expire_time;
   char ign[UHOSTLEN], cmt[66], from[HANDLEN + 1];
 
-  Context;
   BADARGS(4, 5, " hostmask creator comment ?lifetime?");
-  strncpy(ign, argv[1], UHOSTMAX);
-  ign[UHOSTMAX] = 0;
-  strncpy(from, argv[2], HANDLEN);
-  from[HANDLEN] = 0;
-  strncpy(cmt, argv[3], 65);
-  cmt[65] = 0;
+  strncpyz(ign, argv[1], sizeof ign);
+  strncpyz(from, argv[2], sizeof from);
+  strncpyz(cmt, argv[3], sizeof cmt);
   if (argc == 4)
      expire_time = now + (60 * ignore_time);
   else {
@@ -473,7 +445,6 @@
 
 static int tcl_killignore STDVAR
 {
-  Context;
   BADARGS(2, 2, " hostmask");
   Tcl_AppendResult(irp, delignore(argv[1]) ? "1" : "0", NULL);
   return TCL_OK;
@@ -484,17 +455,16 @@
 static int tcl_ignorelist STDVAR
 {
   struct igrec *i;
-  char ts[21], ts1[21], *list[5], *p;
+  char ts[10], *list[5], *p;
 
-  Context;
   BADARGS(1, 1, "");
   for (i = global_ign; i; i = i->next) {
     list[0] = i->igmask;
     list[1] = i->msg;
-    sprintf(ts, "%lu", i->expire);
+    egg_snprintf(ts, sizeof ts, "%lu", i->expire);
     list[2] = ts;
-    sprintf(ts1, "%lu", i->added);
-    list[3] = ts1;
+    egg_snprintf(ts, sizeof ts, "%lu", i->added);
+    list[3] = ts;
     list[4] = i->user;
     p = Tcl_Merge(5, list);
     Tcl_AppendElement(irp, p);
@@ -509,7 +479,6 @@
   struct userrec *u;
   struct user_entry *e;
 
-  Context;
   BADARGS(3, 999, " handle type");
   if (!(et = find_entry_type(argv[2])) && egg_strcasecmp(argv[2], "HANDLE")) {
     Tcl_AppendResult(irp, "No such info type: ", argv[2], NULL);
@@ -526,7 +495,6 @@
     Tcl_AppendResult(irp,u->handle, NULL);
   } else {
   e = find_user_entry(et, u);
-
   if (e)
     return et->tcl_get(irp, u, e, argc, argv);
   }
@@ -540,7 +508,6 @@
   struct user_entry *e;
   int r;
 
-  Context;
   BADARGS(3, 999, " handle type ?setting....?");
   if (!(et = find_entry_type(argv[2]))) {
     Tcl_AppendResult(irp, "No such info type: ", argv[2], NULL);
@@ -555,7 +522,6 @@
   }
   if (!(e = find_user_entry(et, u))) {
     e = user_malloc(sizeof(struct user_entry));
-
     e->type = et;
     e->name = NULL;
     e->u.list = NULL;
----------------------- End of diff -----------------------



More information about the Changes mailing list