[cvslog] (2003-08-06 18:01:10 UTC) Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Wed Aug 6 12:01:10 CST 2003


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2003-08-06 18:01:10 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     lib/eggdrop/binds.c lib/eggdrop/binds.h
     modules/script/scriptbind.c modules/server/dcc_commands.c
     modules/server/input.c modules/server/scriptcmds.c
     modules/server/server.c modules/server/serverlist.h
     src/Makefile.am

Removed files:
     src/dccutil.c src/dccutil.h

Log message:



---------------------- diff included ----------------------
Index: eggdrop1.7/lib/eggdrop/binds.c
diff -u eggdrop1.7/lib/eggdrop/binds.c:1.8 eggdrop1.7/lib/eggdrop/binds.c:1.9
--- eggdrop1.7/lib/eggdrop/binds.c:1.8	Tue Jun 17 23:10:22 2003
+++ eggdrop1.7/lib/eggdrop/binds.c	Wed Aug  6 13:00:59 2003
@@ -8,8 +8,6 @@
 static bind_table_t *bind_table_list_head = NULL;
 
 /* Garbage collection stuff. */
-static int check_bind_executing = 0;
-static int already_scheduled = 0;
 static void bind_table_really_del(bind_table_t *table);
 static void bind_entry_really_del(bind_table_t *table, bind_entry_t *entry);
 
@@ -29,20 +27,12 @@
 			if (entry->flags & BIND_DELETED) bind_entry_really_del(table, entry);
 		}
 	}
-	already_scheduled = 0;
 	return(0);
 }
 
 static void schedule_bind_cleanup()
 {
-	egg_timeval_t when;
-
-	if (already_scheduled) return;
-	already_scheduled = 1;
-
-	when.sec = 0;
-	when.usec = 0;
-	timer_create(&when, "bind table cleanup", internal_bind_cleanup);
+	garbage_add(internal_bind_cleanup, NULL, GARBAGE_ONCE);
 }
 
 void kill_binds(void)
@@ -89,13 +79,8 @@
 	}
 
 	/* Now delete it. */
-	if (check_bind_executing) {
-		table->flags |= BIND_DELETED;
-		schedule_bind_cleanup();
-	}
-	else {
-		bind_table_really_del(table);
-	}
+	table->flags |= BIND_DELETED;
+	schedule_bind_cleanup();
 }
 
 static void bind_table_really_del(bind_table_t *table)
@@ -132,7 +117,7 @@
 }
 
 /* Look up a bind entry based on either function name or id. */
-bind_entry_t *bind_entry_lookup(bind_table_t *table, int id, const char *mask, const char *function_name)
+bind_entry_t *bind_entry_lookup(bind_table_t *table, int id, const char *mask, const char *function_name, Function callback)
 {
 	bind_entry_t *entry;
 	int hit;
@@ -147,27 +132,25 @@
 			if (entry->mask && !strcmp(entry->mask, mask)) hit++;
 			else if (!entry->mask) hit++;
 			if (entry->function_name && !strcmp(entry->function_name, function_name)) hit++;
-			if (hit == 2) break;
+			if (entry->callback == callback || !callback) hit++;
+			if (hit == 3) break;
 		}
 	}
 	return(entry);
 }
 
-int bind_entry_del(bind_table_t *table, int id, const char *mask, const char *function_name, void *cdataptr)
+int bind_entry_del(bind_table_t *table, int id, const char *mask, const char *function_name, Function callback, void *cdataptr)
 {
 	bind_entry_t *entry;
 
-	entry = bind_entry_lookup(table, id, mask, function_name);
+	entry = bind_entry_lookup(table, id, mask, function_name, callback);
 	if (!entry) return(-1);
 
 	if (cdataptr) *(void **)cdataptr = entry->client_data;
 
 	/* Delete it. */
-	if (check_bind_executing) {
-		entry->flags |= BIND_DELETED;
-		schedule_bind_cleanup();
-	}
-	else bind_entry_really_del(table, entry);
+	entry->flags |= BIND_DELETED;
+	schedule_bind_cleanup();
 	return(0);
 }
 
@@ -187,7 +170,7 @@
 {
 	bind_entry_t *entry;
 
-	entry = bind_entry_lookup(table, id, mask, function_name);
+	entry = bind_entry_lookup(table, id, mask, function_name, NULL);
 	if (!entry) return(-1);
 
 	/* Modify it. */
@@ -202,7 +185,7 @@
 {
 	bind_entry_t *entry;
 
-	entry = bind_entry_lookup(table, id, mask, function_name);
+	entry = bind_entry_lookup(table, id, mask, function_name, NULL);
 	if (!entry) return(-1);
 
 	entry->callback = callback;
@@ -214,7 +197,7 @@
 {
 	bind_entry_t *entry, *old_entry;
 
-	old_entry = bind_entry_lookup(table, -1, mask, function_name);
+	old_entry = bind_entry_lookup(table, -1, mask, function_name, NULL);
 
 	if (old_entry) {
 		if (table->flags & BIND_STACKABLE) {
@@ -305,8 +288,6 @@
 	int tie = 0, matchlen = 0;
 	va_list ap;
 
-	check_bind_executing++;
-
 	va_start(ap, match);
 	for (i = 1; i <= table->nargs; i++) {
 		args[i] = va_arg(ap, void *);
@@ -363,7 +344,6 @@
 	if (winner && tie == 1) {
 		retval = bind_entry_exec(table, winner, args);
 	}
-	check_bind_executing--;
 	return(retval);
 }
 
@@ -376,10 +356,23 @@
 
 	for (; cmds->callback; cmds++) {
 		snprintf(name, 50, "*%s:%s", table->name, cmds->mask ? cmds->mask : "");
+		name[49] = 0;
 		bind_entry_add(table, cmds->user_flags, cmds->mask, name, 0, cmds->callback, NULL);
 	}
 }
 
+void bind_add_simple(const char *table_name, const char *flags, const char *mask, Function callback)
+{
+	char name[50];
+	bind_table_t *table;
+
+	table = bind_table_lookup_or_fake(table_name);
+
+	snprintf(name, 50, "*%s:%s", table->name, mask ? mask : "");
+	name[49] = 0;
+	bind_entry_add(table, flags, mask, name, 0, callback, NULL);
+}
+
 void bind_rem_list(const char *table_name, bind_list_t *cmds)
 {
 	char name[50];
@@ -390,6 +383,20 @@
 
 	for (; cmds->mask; cmds++) {
 		snprintf(name, 50, "*%s:%s", table->name, cmds->mask);
-		bind_entry_del(table, -1, cmds->mask, name, NULL);
+		name[49] = 0;
+		bind_entry_del(table, -1, cmds->mask, name, cmds->callback, NULL);
 	}
+}
+
+void bind_rem_simple(const char *table_name, const char *flags, const char *mask, Function callback)
+{
+	char name[50];
+	bind_table_t *table;
+
+	table = bind_table_lookup(table_name);
+	if (!table) return;
+
+	snprintf(name, 50, "*%s:%s", table->name, mask);
+	name[49] = 0;
+	bind_entry_del(table, -1, mask, name, callback, NULL);
 }
Index: eggdrop1.7/lib/eggdrop/binds.h
diff -u eggdrop1.7/lib/eggdrop/binds.h:1.3 eggdrop1.7/lib/eggdrop/binds.h:1.4
--- eggdrop1.7/lib/eggdrop/binds.h:1.3	Thu Jun 12 22:35:14 2003
+++ eggdrop1.7/lib/eggdrop/binds.h	Wed Aug  6 13:00:59 2003
@@ -73,7 +73,7 @@
 
 int bind_entry_add(bind_table_t *table, const char *user_flags, const char *mask, const char *function_name, int bind_flags, Function callback, void *client_data);
 
-int bind_entry_del(bind_table_t *table, int id, const char *mask, const char *function_name, void *cdataptr);
+int bind_entry_del(bind_table_t *table, int id, const char *mask, const char *function_name, Function callback, void *cdataptr);
 
 int bind_entry_modify(bind_table_t *table, int id, const char *mask, const char *function_name, const char *newflags, const char *newmask);
 
@@ -81,6 +81,10 @@
 
 void bind_add_list(const char *table_name, bind_list_t *cmds);
 
+void bind_add_simple(const char *table_name, const char *flags, const char *mask, Function callback);
+
 void bind_rem_list(const char *table_name, bind_list_t *cmds);
+
+void bind_rem_simple(const char *table_name, const char *flags, const char *mask, Function callback);
 
 #endif
Index: eggdrop1.7/modules/script/scriptbind.c
diff -u eggdrop1.7/modules/script/scriptbind.c:1.2 eggdrop1.7/modules/script/scriptbind.c:1.3
--- eggdrop1.7/modules/script/scriptbind.c:1.2	Thu Jun 12 22:35:14 2003
+++ eggdrop1.7/modules/script/scriptbind.c	Wed Aug  6 13:01:00 2003
@@ -73,7 +73,7 @@
 	table = bind_table_lookup(table_name);
 	if (!table) return(1);
 
-	retval = bind_entry_del(table, -1, mask, name, &callback);
+	retval = bind_entry_del(table, -1, mask, name, NULL, &callback);
 	if (callback) callback->del(callback);
 	return(retval);
 }
Index: eggdrop1.7/modules/server/dcc_commands.c
diff -u eggdrop1.7/modules/server/dcc_commands.c:1.5 eggdrop1.7/modules/server/dcc_commands.c:1.6
--- eggdrop1.7/modules/server/dcc_commands.c:1.5	Thu Jun 12 22:35:15 2003
+++ eggdrop1.7/modules/server/dcc_commands.c	Wed Aug  6 13:01:00 2003
@@ -1,23 +1,40 @@
 #include <eggdrop/eggdrop.h>
+#include <ctype.h>
 
 #include "server.h"
 #include "serverlist.h"
 #include "output.h"
 
+static int party_servers(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
+{
+	server_t *s;
+
+	if (server_list_len <= 0) partymember_printf(p, "The server list is empty.");
+	else partymember_printf(p, "%d server%s:", server_list_len, (server_list_len == 1) ? "s" : "");
+	for (s = server_list; s; s = s->next) {
+		if (s->port) partymember_printf(p, "   %s (port %d)%s", s->host, s->port, s->pass ? " (password set)" : "");
+		else partymember_printf(p, "   %s (default port)%s", s->host, s->pass ? " (password set)" : "");
+	}
+	return(0);
+}
+
 static void parse_server(const char *text, char **host, int *port, char **pass)
 {
 	char *sep, *sport = NULL;
 
 	*pass = NULL;
 	*port = 0;
+	while (isspace(*text)) text++;
 	*host = strdup(text);
 	sep = strchr(*host, ' ');
 	if (sep) {
 		*sep++ = 0;
+		while (isspace(*sep)) sep++;
 		sport = sep;
 		sep = strchr(sep, ' ');
 		if (sep) {
 			*sep++ = 0;
+			while (isspace(*sep)) sep++;
 			*pass = sep;
 		}
 		*port = atoi(sport);
@@ -34,6 +51,10 @@
 		return(0);
 	}
 	parse_server(text, &host, &port, &pass);
+	if (!strlen(host)) {
+		partymember_printf(p, "Please specify a valid host.");
+		return(0);
+	}
 	server_add(host, port, pass);
 	partymember_printf(p, "Added %s:%d\n", host, port ? port : server_config.default_port);
 	free(host);
@@ -52,12 +73,12 @@
 
 	parse_server(text, &host, &port, &pass);
 	i = server_find(host, port, pass);
+	free(host);
 	if (i < 0) partymember_printf(p, "No matching servers.");
 	else {
 		server_del(i);
 		partymember_printf(p, "Deleted server %d", i+1);
 	}
-	free(host);
 	return(0);
 }
 
@@ -72,6 +93,7 @@
 }
 
 bind_list_t server_party_commands[] = {
+	{"", "servers", party_servers},
 	{"m", "+server", party_plus_server},
 	{"m", "-server", party_minus_server},
 	{"m", "dump", party_dump},
Index: eggdrop1.7/modules/server/input.c
diff -u eggdrop1.7/modules/server/input.c:1.22 eggdrop1.7/modules/server/input.c:1.23
--- eggdrop1.7/modules/server/input.c:1.22	Sun Jul  6 02:17:21 2003
+++ eggdrop1.7/modules/server/input.c	Wed Aug  6 13:01:00 2003
@@ -173,6 +173,10 @@
 	if (!current_server.type4modes) current_server.type4modes = strdup("imnprst");
 	if (!current_server.modeprefix) current_server.modeprefix = strdup("ov");
 	if (!current_server.whoprefix) current_server.whoprefix = strdup("@+");
+	if (strlen(current_server.modeprefix) != strlen(current_server.whoprefix)) {
+		str_redup(&current_server.modeprefix, "ov");
+		str_redup(&current_server.whoprefix, "@+");
+	}
 	return(0);
 }
 
@@ -462,12 +466,15 @@
 	if (current_server.registered) {
 		char *uhost, *full;
 
-		uhost = egg_mprintf("%s@%s", current_server.user, current_server.host);
-		full = egg_mprintf("%s!%s", current_server.nick, uhost);
-		u = user_lookup_by_irchost_nocache(full);
+		if (current_server.user && current_server.host) {
+			uhost = egg_mprintf("%s@%s", current_server.user, current_server.host);
+			full = egg_mprintf("%s!%s", current_server.nick, uhost);
+			u = user_lookup_by_irchost_nocache(full);
+			free(full);
+		}
+		else uhost = NULL;
 		channel_on_quit(current_server.nick, uhost, u);
-		free(full);
-		free(uhost);
+		if (uhost) free(uhost);
 	}
 
 	putlog(LOG_MSGS | LOG_SERV, "*", "-ERROR from server- %s", args[0]);
Index: eggdrop1.7/modules/server/scriptcmds.c
diff -u eggdrop1.7/modules/server/scriptcmds.c:1.28 eggdrop1.7/modules/server/scriptcmds.c:1.29
--- eggdrop1.7/modules/server/scriptcmds.c:1.28	Tue Apr 15 03:18:03 2003
+++ eggdrop1.7/modules/server/scriptcmds.c	Wed Aug  6 13:01:00 2003
@@ -22,7 +22,7 @@
 
 /* FIXME: #include mess
 #ifndef lint
-static const char rcsid[] = "$Id: scriptcmds.c,v 1.28 2003/04/15 08:18:03 stdarg Exp $";
+static const char rcsid[] = "$Id: scriptcmds.c,v 1.29 2003/08/06 18:01:00 stdarg Exp $";
 #endif
 */
 
@@ -36,9 +36,6 @@
 #include "servsock.h"
 #include "dcc.h"
 #include "channels.h"
-
-/* From serverlist.c */
-extern int server_list_index;
 
 /* From server.c */
 extern int cycle_delay;
Index: eggdrop1.7/modules/server/server.c
diff -u eggdrop1.7/modules/server/server.c:1.47 eggdrop1.7/modules/server/server.c:1.48
--- eggdrop1.7/modules/server/server.c:1.47	Thu Jun 12 22:35:15 2003
+++ eggdrop1.7/modules/server/server.c	Wed Aug  6 13:01:00 2003
@@ -72,32 +72,31 @@
 	return(0);
 }
 
-/* A report on the module status.  */
-static void server_report(int idx, int details)
+static void server_status(partymember_t *p, int details)
 {
 	if (!current_server.connected) {
 		if (current_server.idx >= 0) {
-			dprintf(idx, "   Connecting to server %s:%d\n", current_server.server_host, current_server.port);
+			partymember_printf(p, "   Connecting to server %s:%d", current_server.server_host, current_server.port);
 		}
 		else {
-			dprintf(idx, "   Connecting to next server in %d seconds\n", cycle_delay);
+			partymember_printf(p, "   Connecting to next server in %d seconds", cycle_delay);
 		}
 	}
 	else {
 		/* First line, who we've connected to. */
-		dprintf(idx, "   Connected to %s:%d\n", current_server.server_self ? current_server.server_self : current_server.server_host, current_server.port);
+		partymember_printf(p, "   Connected to %s:%d", current_server.server_self ? current_server.server_self : current_server.server_host, current_server.port);
 
 		/* Second line, who we're connected as. */
 		if (current_server.registered) {
 			if (current_server.user) {
-				dprintf(idx, "    Online as %s!%s@%s (%s)\n", current_server.nick, current_server.user, current_server.host, current_server.real_name);
+				partymember_printf(p, "    Online as %s!%s@%s (%s)", current_server.nick, current_server.user, current_server.host, current_server.real_name);
 			}
 			else {
-				dprintf(idx, "    Online as %s (still waiting for WHOIS result)\n", current_server.nick);
+				partymember_printf(p, "    Online as %s (still waiting for WHOIS result)", current_server.nick);
 			}
 		}
 		else {
-			dprintf(idx, "   Still logging in\n");
+			partymember_printf(p, "   Still logging in");
 		}
 	}
 }
Index: eggdrop1.7/modules/server/serverlist.h
diff -u eggdrop1.7/modules/server/serverlist.h:1.2 eggdrop1.7/modules/server/serverlist.h:1.3
--- eggdrop1.7/modules/server/serverlist.h:1.2	Sun Feb 16 05:15:06 2003
+++ eggdrop1.7/modules/server/serverlist.h	Wed Aug  6 13:01:00 2003
@@ -8,6 +8,10 @@
 	char *pass;
 } server_t;
 
+extern server_t *server_list;
+extern int server_list_index;
+extern int server_list_len;
+
 server_t *server_get_next();
 void server_set_next(int next);
 int server_add(char *host, int port, char *pass);
Index: eggdrop1.7/src/Makefile.am
diff -u eggdrop1.7/src/Makefile.am:1.44 eggdrop1.7/src/Makefile.am:1.45
--- eggdrop1.7/src/Makefile.am:1.44	Sat Aug  2 00:59:53 2003
+++ eggdrop1.7/src/Makefile.am	Wed Aug  6 13:01:00 2003
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.44 2003/08/02 05:59:53 tothwolf Exp $
+# $Id: Makefile.am,v 1.45 2003/08/06 18:01:00 stdarg Exp $
 
 # FIXME: optionally allow a system wide install by ignoring the line below.
 bindir			= $(exec_prefix)
@@ -19,7 +19,6 @@
 			core_binds.c core_binds.h \
 			core_config.c core_config.h \
 			core_party.c \
-			dccutil.c dccutil.h \
 			debug.h \
 			egg.h \
 			logfile.c logfile.h \
Index: eggdrop1.7/src/dccutil.c
diff -u eggdrop1.7/src/dccutil.c:1.64 eggdrop1.7/src/dccutil.c:removed
--- eggdrop1.7/src/dccutil.c:1.64	Sat Aug  2 00:59:53 2003
+++ eggdrop1.7/src/dccutil.c	Wed Aug  6 13:01:10 2003
@@ -1,607 +0,0 @@
-/*
- * dccutil.c --
- *
- *	lots of little functions to send formatted text to
- *	varying types of connections
- *	'.who', '.whom', and '.dccstat' code
- *	memory management for dcc structures
- *	timeout checking for dcc connections
- */
-/*
- * Copyright (C) 1997 Robey Pointer
- * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
- *
- * 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
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: dccutil.c,v 1.64 2003/08/02 05:59:53 tothwolf Exp $";
-#endif
-
-#include <sys/stat.h>
-#include "main.h"
-#include <errno.h>
-#include "chan.h"
-#include "modules.h"
-#include "logfile.h"
-#include "misc.h"
-#include "cmdt.h"		/* cmd_t				*/
-#include "net.h"		/* tputs, killsock			*/
-#include "dccutil.h"		/* prototypes				*/
-#include "users.h"		/* get_user_by_handle */
-
-extern struct dcc_t   *dcc;
-extern struct userrec *userlist;
-
-extern int  dcc_total, max_dcc, dcc_flood_thr, backgrd, MAXSOCKS;
-extern char spaces[], version[];
-
-extern time_t now;
-
-extern sock_list *socklist;
-
-#ifndef MAKING_MODS
-extern struct dcc_table	DCC_CHAT, DCC_LOST;
-#endif /* MAKING_MODS   */
-
-char myname[HANDLEN + 1] = "";
-char motdfile[121] = "text/motd";	/* File where the motd is stored */
-int connect_timeout = 15;		/* How long to wait before a telnet
-					   connection times out */
-
-int reserved_port_min = 0;
-int reserved_port_max = 0;
-
-void init_dcc_max(int newmax)
-{
-  int osock = MAXSOCKS;
-
-  if (newmax < 1) newmax = 1;
-  dcc = realloc(dcc, sizeof(struct dcc_t) * newmax);
-  if (newmax > max_dcc) memset(dcc+max_dcc, 0, (newmax-max_dcc) * sizeof(*dcc));
-
-  MAXSOCKS = newmax + 10;
-  socklist = (sock_list *)realloc(socklist, sizeof(sock_list) * MAXSOCKS);
-  if (newmax > max_dcc) memset(socklist+max_dcc+10, 0, (newmax-max_dcc) * sizeof(*socklist));
-
-  for (; osock < MAXSOCKS; osock++)
-    socklist[osock].flags = SOCK_UNUSED;
-
-  max_dcc = newmax;
-}
-
-
-/* Replace \n with \r\n */
-char *add_cr(char *buf)
-{
-  static char WBUF[1024];
-  char *p, *q;
-
-  for (p = buf, q = WBUF; *p; p++, q++) {
-    if (*p == '\n')
-      *q++ = '\r';
-    *q = *p;
-  }
-  *q = *p;
-  return WBUF;
-}
-
-extern void (*qserver) (int, char *, int);
-
-void dprintf EGG_VARARGS_DEF(int, arg1)
-{
-  static char buf[1024];
-  char *format;
-  int idx, len;
-  va_list va;
-
-  idx = EGG_VARARGS_START(int, arg1, va);
-  format = va_arg(va, char *);
-  len = vsnprintf(buf, 1023, format, va);
-  va_end(va);
-  if (len < 0 || len >= sizeof(buf)) len = sizeof(buf)-1;
-  buf[len] = 0;
-
-  if (idx < 0) {
-    tputs(-idx, buf, len);
-  } else if (idx > 0x7FF0) {
-    switch (idx) {
-    case DP_LOG:
-      putlog(LOG_MISC, "*", "%s", buf);
-      break;
-    case DP_STDOUT:
-      tputs(STDOUT, buf, len);
-      break;
-    case DP_STDERR:
-      tputs(STDERR, buf, len);
-      break;
-    case DP_SERVER:
-    case DP_HELP:
-    case DP_MODE:
-    case DP_MODE_NEXT:
-    case DP_SERVER_NEXT:
-    case DP_HELP_NEXT:
-      qserver(idx, buf, len);
-      break;
-    }
-    return;
-  } else {
-    if (len > 500) {		/* Truncate to fit */
-      buf[500] = 0;
-      strcat(buf, "\n");
-      len = 501;
-    }
-    if (dcc[idx].type && ((long) (dcc[idx].type->output) == 1)) {
-      char *p = add_cr(buf);
-
-      tputs(dcc[idx].sock, p, strlen(p));
-    } else if (dcc[idx].type && dcc[idx].type->output) {
-      dcc[idx].type->output(idx, buf, dcc[idx].u.other);
-    } else
-      tputs(dcc[idx].sock, buf, len);
-  }
-}
-
-void chatout EGG_VARARGS_DEF(char *, arg1)
-{
-  int i, len;
-  char *format;
-  char s[601];
-  va_list va;
-
-  format = EGG_VARARGS_START(char *, arg1, va);
-  vsnprintf(s, 511, format, va);
-  va_end(va);
-  len = strlen(s);
-  if (len > 511)
-    len = 511;
-  s[len + 1] = 0;
-
-  for (i = 0; i < dcc_total; i++)
-    if (dcc[i].type == &DCC_CHAT)
-      if (dcc[i].u.chat->channel >= 0)
-        dprintf(i, "%s", s);
-
-}
-
-/* Print to all on this channel but one.
- */
-void chanout_but EGG_VARARGS_DEF(int, arg1)
-{
-  int i, x, chan, len;
-  char *format;
-  char s[601];
-  va_list va;
-
-  x = EGG_VARARGS_START(int, arg1, va);
-  chan = va_arg(va, int);
-  format = va_arg(va, char *);
-  vsnprintf(s, 511, format, va);
-  va_end(va);
-  len = strlen(s);
-  if (len > 511)
-    len = 511;
-  s[len + 1] = 0;
-
-  for (i = 0; i < dcc_total; i++)
-    if ((dcc[i].type == &DCC_CHAT) && (i != x))
-      if (dcc[i].u.chat->channel == chan)
-        dprintf(i, "%s", s);
-
-}
-
-void dcc_chatter(int idx)
-{
-  int i, j;
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
-
-  get_user_flagrec(dcc[idx].user, &fr, NULL);
-  show_motd(idx);
-  i = dcc[idx].u.chat->channel;
-  dcc[idx].u.chat->channel = 234567;
-  j = dcc[idx].sock;
-  strcpy(dcc[idx].u.chat->con_chan, "***");
-  /* Still there? */
-  if ((idx >= dcc_total) || (dcc[idx].sock != j))
-    return;			/* Nope */
-  /* Tcl script may have taken control */
-  if (dcc[idx].type == &DCC_CHAT) {
-    if (!strcmp(dcc[idx].u.chat->con_chan, "***"))
-      strcpy(dcc[idx].u.chat->con_chan, "*");
-    if (dcc[idx].u.chat->channel == 234567) {
-      /* If the chat channel has already been altered it's *highly*
-       * probably join/part messages have been broadcast everywhere,
-       * so dont bother sending them
-       */
-      if (i == -2)
-	i = 0;
-      dcc[idx].u.chat->channel = i;
-    }
-    /* But *do* bother with sending it locally */
-    if (!dcc[idx].u.chat->channel) {
-      chanout_but(-1, 0, "*** %s joined the party line.\n", dcc[idx].nick);
-    } else if (dcc[idx].u.chat->channel > 0) {
-      chanout_but(-1, dcc[idx].u.chat->channel,
-		  "*** %s joined the channel.\n", dcc[idx].nick);
-    }
-  }
-}
-
-/* Closes an open FD for transfer sockets. */
-void killtransfer(int n)
-{
-	int i, ok = 1;
-
-	if (dcc[n].type->flags & DCT_FILETRAN) {
-		if (dcc[n].u.xfer->f) {
-			fclose(dcc[n].u.xfer->f);
-			dcc[n].u.xfer->f = NULL;
-		}
-	}
- }
-
-/* Mark an entry as lost and deconstruct it's contents. It will be securely
- * removed from the dcc list in the main loop.
- */
-void lostdcc(int n)
-{
-  /* Make sure it's a valid dcc index. */
-  if (n < 0 || n >= max_dcc) return;
-
-  if (dcc[n].type && dcc[n].type->kill)
-    dcc[n].type->kill(n, dcc[n].u.other);
-  else if (dcc[n].u.other)
-    free(dcc[n].u.other);
-  memset(&dcc[n], 0, sizeof(struct dcc_t));
-
-  dcc[n].sock = (-1);
-  dcc[n].type = &DCC_LOST;
-}
-
-/* Remove entry from dcc list. Think twice before using this function,
- * because it invalidates any variables that point to a specific dcc
- * entry!
- *
- * Note: The entry will be deconstructed if it was not deconstructed
- *       already. This case should normally not occur.
- */
-static void removedcc(int n)
-{
-  if (dcc[n].type && dcc[n].type->kill)
-    dcc[n].type->kill(n, dcc[n].u.other);
-  else if (dcc[n].u.other)
-    free(dcc[n].u.other);
-
-  /* if we are removing the last entry let's decrease dcc_total */
-  if(n + 1 == dcc_total) dcc_total--;
-
-  memset(&dcc[n], 0, sizeof(struct dcc_t)); /* drummer */
-}
-
-/* Clean up sockets that were just left for dead.
- */
-void dcc_remove_lost(void)
-{
-  int i;
-
-  
-  for (i = dcc_total; i > 0; --i) {
-    if (dcc[i].type == &DCC_LOST) {
-      dcc[i].type = NULL;
-      removedcc(i);
-    }
-  }
-}
-
-/* Show list of current dcc's to a dcc-chatter
- * positive value: idx given -- negative value: sock given
- */
-void tell_dcc(int zidx)
-{
-  int i, j, k;
-  char other[160];
-
-  spaces[HANDLEN - 9] = 0;
-  dprintf(zidx, "SOCK PORT  NICK     %s HOST                       TYPE\n"
-	  ,spaces);
-  dprintf(zidx, "---- ----- ---------%s -------------------------- ----\n"
-	  ,spaces);
-  spaces[HANDLEN - 9] = ' ';
-  /* Show server */
-  for (i = 0; i < dcc_total; i++) {
-    if (!dcc[i].type) continue;
-    j = strlen(dcc[i].host);
-    if (j > 26)
-      j -= 26;
-    else
-      j = 0;
-    if (dcc[i].type && dcc[i].type->display)
-      dcc[i].type->display(i, other);
-    else {
-      sprintf(other, "?:%lX  !! ERROR !!", (long) dcc[i].type);
-      break;
-    }
-    k = HANDLEN - strlen(dcc[i].nick);
-    spaces[k] = 0;
-    dprintf(zidx, "%-4d %5d %s%s %-26s %s\n", i,
-	    dcc[i].port, dcc[i].nick, spaces, dcc[i].host + j, other);
-    spaces[k] = ' ';
-  }
-}
-
-/* Mark someone on dcc chat as no longer away
- */
-void not_away(int idx)
-{
-  if (dcc[idx].u.chat->away == NULL) {
-    dprintf(idx, "You weren't away!\n");
-    return;
-  }
-  if (dcc[idx].u.chat->channel >= 0) {
-    chanout_but(-1, dcc[idx].u.chat->channel,
-		"*** %s is no longer away.\n", dcc[idx].nick);
-  }
-  dprintf(idx, "You're not away any more.\n");
-  free_null(dcc[idx].u.chat->away);
-}
-
-void set_away(int idx, char *s)
-{
-  if (s == NULL) {
-    not_away(idx);
-    return;
-  }
-  if (!s[0]) {
-    not_away(idx);
-    return;
-  }
-  if (dcc[idx].u.chat->away != NULL)
-    free(dcc[idx].u.chat->away);
-  dcc[idx].u.chat->away = strdup(s);
-  if (dcc[idx].u.chat->channel >= 0) {
-    chanout_but(-1, dcc[idx].u.chat->channel,
-		"*** %s is now away: %s\n", dcc[idx].nick, s);
-  }
-  dprintf(idx, "You are now away.\n");
-}
-
-/* Make a password, 10-15 random letters and digits
- */
-void makepass(char *s)
-{
-  int i;
-
-  i = 10 + (random() % 6);
-  make_rand_str(s, i);
-}
-
-void flush_lines(int idx, struct chat_info *ci)
-{
-  int c = ci->line_count;
-  struct msgq *p = ci->buffer, *o;
-
-  while (p && c < (ci->max_line)) {
-    ci->current_lines--;
-    tputs(dcc[idx].sock, p->msg, p->len);
-    free(p->msg);
-    o = p->next;
-    free(p);
-    p = o;
-    c++;
-  }
-  if (p != NULL) {
-    if (dcc[idx].status & STAT_TELNET)
-      tputs(dcc[idx].sock, "[More]: ", 8);
-    else
-      tputs(dcc[idx].sock, "[More]\n", 7);
-  }
-  ci->buffer = p;
-  ci->line_count = 0;
-}
-
-int new_dcc(struct dcc_table *type, int xtra_size)
-{
-  int i = dcc_total;
-
-  for (i = 0; i < dcc_total; i++)
-    if (!dcc[i].type) break;
-
-  if (i == max_dcc)
-    return -1;
-
-  if (i == dcc_total)
-    dcc_total++;
-  memset(&dcc[i], 0, sizeof(*dcc));
-
-  dcc[i].type = type;
-  if (xtra_size)
-    dcc[i].u.other = calloc(1, xtra_size);
-  return i;
-}
-
-/* Changes the given dcc entry to another type.
- */
-void changeover_dcc(int i, struct dcc_table *type, int xtra_size)
-{
-  /* Free old structure. */
-  if (dcc[i].type && dcc[i].type->kill)
-    dcc[i].type->kill(i, dcc[i].u.other);
-  else if (dcc[i].u.other)
-    free_null(dcc[i].u.other);
-
-  dcc[i].type = type;
-  if (xtra_size)
-    dcc[i].u.other = calloc(1, xtra_size);
-}
-
-int detect_dcc_flood(time_t * timer, struct chat_info *chat, int idx)
-{
-  time_t t;
-
-  if (!dcc_flood_thr)
-    return 0;
-  t = now;
-  if (*timer != t) {
-    *timer = t;
-    chat->msgs_per_sec = 0;
-  } else {
-    chat->msgs_per_sec++;
-    if (chat->msgs_per_sec > dcc_flood_thr) {
-      /* FLOOD */
-      dprintf(idx, "*** FLOOD: %s.\n", _("Goodbye"));
-      /* Evil assumption here that flags&DCT_CHAT implies chat type */
-      if ((dcc[idx].type->flags & DCT_CHAT) && chat &&
-	  (chat->channel >= 0)) {
-	char x[1024];
-
-	snprintf(x, sizeof x, _("%s has been forcibly removed for flooding.\n"), dcc[idx].nick);
-	chanout_but(idx, chat->channel, "*** %s", x);
-      }
-      if ((dcc[idx].sock != STDOUT) || backgrd) {
-	killsock(dcc[idx].sock);
-	lostdcc(idx);
-      } else {
-	dprintf(DP_STDOUT, "\n### SIMULATION RESET ###\n\n");
-	dcc_chatter(idx);
-      }
-      return 1;			/* <- flood */
-    }
-  }
-  return 0;
-}
-
-/* Handle someone being booted from dcc chat.
- */
-void do_boot(int idx, char *by, char *reason)
-{
-  int files = (dcc[idx].type != &DCC_CHAT);
-
-  dprintf(idx, _("-=- poof -=-\n"));
-  dprintf(idx, _("Youve been booted from the %s by %s%s%s\n"), files ? "file section" : "bot",
-          by, reason[0] ? ": " : ".", reason);
-  /* If it's a partyliner (chatterer :) */
-  /* Horrible assumption that DCT_CHAT using structure uses same format
-   * as DCC_CHAT */
-  if ((dcc[idx].type->flags & DCT_CHAT) &&
-      (dcc[idx].u.chat->channel >= 0)) {
-    char x[1024];
-
-    snprintf(x, sizeof x, _("%s booted %s from the party line%s%s\n"), by, dcc[idx].nick,
-		 reason[0] ? ": " : "", reason);
-    chanout_but(idx, dcc[idx].u.chat->channel, "*** %s.\n", x);
-  }
-  if ((dcc[idx].sock != STDOUT) || backgrd) {
-    killsock(dcc[idx].sock);
-    lostdcc(idx);
-    /* Entry must remain in the table so it can be logged by the caller */
-  } else {
-    dprintf(DP_STDOUT, "\n### SIMULATION RESET\n\n");
-    dcc_chatter(idx);
-  }
-  return;
-}
-
-/* FIXME: botnet dependencies */
-int add_note(char *to, char *from, char *msg, int idx, int echo)
-{
-  int status, i, iaway, sock;
-  char ss[81], ssf[81];
-  struct userrec *u;
-
-  if (strlen(msg) > 450)
-    msg[450] = 0;		/* Notes have a limit */
-  /* note length + PRIVMSG header + nickname + date  must be <512  */
-  /* Might be form "sock:nick" */
-  splitc(ssf, from, ':');
-  rmspace(ssf);
-  splitc(ss, to, ':');
-  rmspace(ss);
-  if (!ss[0])
-    sock = (-1);
-  else
-    sock = atoi(ss);
-  /* Don't process if there's a note binding for it */
-  if (idx != (-2)) {		/* Notes from bots don't trigger it */
-  }
-  if (!(u = get_user_by_handle(userlist, to))) {
-    if (idx >= 0)
-      dprintf(idx, _("I dont know anyone by that name.\n"));
-    return NOTE_ERROR;
-  }
-  if (is_bot(u)) {
-    if (idx >= 0)
-      dprintf(idx, _("Thats a bot.  You cant leave notes for a bot.\n"));
-    return NOTE_ERROR;
-  }
-  if (match_noterej(u, from)) {
-    if (idx >= 0)
-       dprintf(idx, "%s %s\n", u->handle, "rejected your note.");
-    return NOTE_REJECT;
-  }
-  status = NOTE_STORED;
-  iaway = 0;
-  /* Online right now? */
-  for (i = 0; i < dcc_total; i++) {
-    if (dcc[i].type && (dcc[i].type->flags & DCT_GETNOTES) &&
-	((sock == (-1)) || (sock == dcc[i].sock)) &&
-	(!strcasecmp(dcc[i].nick, to))) {
-      int aok = 1;
-
-      if (dcc[i].type == &DCC_CHAT)
-	if ((dcc[i].u.chat->away != NULL) &&
-	    (idx != (-2))) {
-	  /* Only check away if it's not from a bot */
-	  aok = 0;
-	  if (idx >= 0)
-	    dprintf(idx, "%s %s: %s\n", dcc[i].nick, _("is away"),
-		    dcc[i].u.chat->away);
-	  if (!iaway)
-	    iaway = i;
-	  status = NOTE_AWAY;
-	}
-      if (aok) {
-	char *p, *fr = from;
-	int l = 0;
-	char work[1024];
-
-	while ((*msg == '<') || (*msg == '>')) {
-	  p = newsplit(&msg);
-	  if (*p == '<')
-	    l += simple_sprintf(work + l, "via %s, ", p + 1);
-	  else if (*from == '@')
-	    fr = p + 1;
-	}
-	if (idx == -2 || (!strcasecmp(from, myname)))
-	  dprintf(i, "*** [%s] %s%s\n", fr, l ? work : "", msg);
-	else
-	  dprintf(i, "%cNote [%s]: %s%s\n", 7, fr, l ? work : "", msg);
-	if ((idx >= 0) && (echo))
-	  dprintf(idx, "-> %s: %s\n", to, msg);
-	return NOTE_OK;
-      }
-    }
-  }
-  if (idx == (-2))
-    return NOTE_OK;		/* Error msg from a tandembot: don't store */
-  status = storenote(from, to, msg, idx, NULL, 0);
-  if (status < 0) status = NOTE_ERROR;
-  else if (status == NOTE_AWAY) {
-      /* User is away in all sessions -- just notify the user that a
-       * message arrived and was stored. (only oldest session is notified.)
-       */
-      dprintf(iaway, "*** %s.\n", _("Note arrived for you"));
-  }
-  return(status);
-}
Index: eggdrop1.7/src/dccutil.h
diff -u eggdrop1.7/src/dccutil.h:1.8 eggdrop1.7/src/dccutil.h:removed
--- eggdrop1.7/src/dccutil.h:1.8	Sat Aug  2 00:59:53 2003
+++ eggdrop1.7/src/dccutil.h	Wed Aug  6 13:01:10 2003
@@ -1,63 +0,0 @@
-/*
- * dccutil.h --
- */
-/*
- * Copyright (C) 2000, 2001, 2002, 2003 Eggheads Development Team
- *
- * 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
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-/*
- * $Id: dccutil.h,v 1.8 2003/08/02 05:59:53 tothwolf Exp $
- */
-
-#ifndef _EGG_DCCUTIL_H
-#define _EGG_DCCUTIL_H
-
-/* TODO: rename me to dccprintf
- *  (background: dprintf has become a system call,
- *   so all occurences of dprintf in eggdrop has been
- *   redefnied as dprintf_eggdrop)
- */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#ifdef HAVE_DPRINTF
-# define dprintf dprintf_eggdrop
-#endif
-
-void dprintf EGG_VARARGS(int, arg1);
-void chatout EGG_VARARGS(char *, arg1);
-void chanout_but EGG_VARARGS(int, arg1);
-void dcc_chatter(int);
-void killtransfer(int);
-void lostdcc(int);
-void makepass(char *);
-void tell_dcc(int);
-void not_away(int);
-void set_away(int, char *);
-void dcc_remove_lost(void);
-void flush_lines(int, struct chat_info *);
-struct dcc_t *find_idx(int);
-int new_dcc(struct dcc_table *, int);
-void del_dcc(int);
-char *add_cr(char *);
-void changeover_dcc(int, struct dcc_table *, int);
-void do_boot(int, char *, char *);
-int detect_dcc_flood(time_t *, struct chat_info *, int);
-
-/* Moved there since there is no botnet */
-int add_note(char *to, char *from, char *msg, int idx, int echo);
-
-#endif				/* !_EGG_DCCUTIL_H */
----------------------- End of diff -----------------------


More information about the Changes mailing list