[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2005-04-14 10:28:38
|
CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2005-04-14 10:28:17 UTC Modified files: ChangeLog ChangeLog.es include/ddb.h include/patchlevel.h ircd/Makefile.in ircd/ddb.c Added files: ircd/ddb_events.c Log message: Author: zoltan <zo...@ir...> Log message: 2005-04-14 Toni García <zo...@ir...> 1.0.alpha26 * Eventos de DDB ---------------------- diff included ---------------------- Index: ircd-ircdev/ChangeLog diff -u ircd-ircdev/ChangeLog:1.27 ircd-ircdev/ChangeLog:1.28 --- ircd-ircdev/ChangeLog:1.27 Mon Apr 11 01:44:55 2005 +++ ircd-ircdev/ChangeLog Thu Apr 14 03:28:05 2005 @@ -1,10 +1,13 @@ # # ChangeLog for ircd-ircdev # -# $Id: ChangeLog,v 1.27 2005/04/11 08:44:55 zolty Exp $ +# $Id: ChangeLog,v 1.28 2005/04/14 10:28:05 zolty Exp $ # # Insert new changes at beginning of the change list. # +2005-04-14 Toni García <zo...@ir...> 1.0.alpha26 + * DDB Events + 2005-04-11 Toni García <zo...@ir...> 1.0.alpha25 * CAPAB command * Undernet synchronization Index: ircd-ircdev/ChangeLog.es diff -u ircd-ircdev/ChangeLog.es:1.27 ircd-ircdev/ChangeLog.es:1.28 --- ircd-ircdev/ChangeLog.es:1.27 Mon Apr 11 01:44:55 2005 +++ ircd-ircdev/ChangeLog.es Thu Apr 14 03:28:05 2005 @@ -1,10 +1,13 @@ # # Log de Cambios para ircd-ircdev # -# $Id: ChangeLog.es,v 1.27 2005/04/11 08:44:55 zolty Exp $ +# $Id: ChangeLog.es,v 1.28 2005/04/14 10:28:05 zolty Exp $ # # Insertar los nuevos cambios al principio de esta lista de cambios. # +2005-04-14 Toni García <zo...@ir...> 1.0.alpha26 + * Eventos de DDB + 2005-04-11 Toni García <zo...@ir...> 1.0.alpha25 * Comando CAPAB totalmente funcional * Sincronización Undernet Index: ircd-ircdev/include/ddb.h diff -u ircd-ircdev/include/ddb.h:1.4 ircd-ircdev/include/ddb.h:1.5 --- ircd-ircdev/include/ddb.h:1.4 Thu Mar 31 04:58:02 2005 +++ ircd-ircdev/include/ddb.h Thu Apr 14 03:28:06 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: ddb.h,v 1.4 2005/03/31 12:58:02 zolty Exp $ + * $Id: ddb.h,v 1.5 2005/04/14 10:28:06 zolty Exp $ * */ #ifndef INCLUDED_ddb_h @@ -109,6 +109,7 @@ } #endif + #define DdbMalloc(x) MyMalloc(x) #define DdbFree(x) MyFree(x) @@ -119,6 +120,8 @@ extern unsigned int ddb_resident_table[DDB_TABLE_MAX]; extern unsigned int ddb_count_table[DDB_TABLE_MAX]; extern unsigned int ddb_id_table[DDB_TABLE_MAX]; +typedef void (*ddb_events_table_t)(char *, char *, int); +extern ddb_events_table_t ddb_events_table[DDB_TABLE_MAX]; extern unsigned int ddb_hashtable_hi[DDB_TABLE_MAX]; extern unsigned int ddb_hashtable_lo[DDB_TABLE_MAX]; extern int ddb_hash_register(char *key, int hash_size); @@ -128,7 +131,7 @@ extern unsigned int ddb_count_in_table(unsigned char table); extern void ddb_init(void); - +extern void ddb_events_init(void); /* extern int ddb_read(struct ddb_memory_table *dump, char *buf); Index: ircd-ircdev/include/patchlevel.h diff -u ircd-ircdev/include/patchlevel.h:1.26 ircd-ircdev/include/patchlevel.h:1.27 --- ircd-ircdev/include/patchlevel.h:1.26 Sat Apr 2 11:47:34 2005 +++ ircd-ircdev/include/patchlevel.h Thu Apr 14 03:28:06 2005 @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: patchlevel.h,v 1.26 2005/04/02 19:47:34 zolty Exp $ + * $Id: patchlevel.h,v 1.27 2005/04/14 10:28:06 zolty Exp $ * */ -#define PATCHLEVEL ".alpha24" +#define PATCHLEVEL ".alpha26" #define RELEASE "1.0" Index: ircd-ircdev/ircd/Makefile.in diff -u ircd-ircdev/ircd/Makefile.in:1.22 ircd-ircdev/ircd/Makefile.in:1.23 --- ircd-ircdev/ircd/Makefile.in:1.22 Mon Apr 11 01:44:59 2005 +++ ircd-ircdev/ircd/Makefile.in Thu Apr 14 03:28:06 2005 @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA -# $Id: Makefile.in,v 1.22 2005/04/11 08:44:59 zolty Exp $ +# $Id: Makefile.in,v 1.23 2005/04/14 10:28:06 zolty Exp $ #### Start of system configuration section. #### @@ -94,6 +94,7 @@ DDB_SRC = \ ddb.c \ ddb_db_template.c \ + ddb_events.c\ m_db.c \ m_dbq.c \ m_ghost.c \ Index: ircd-ircdev/ircd/ddb.c diff -u ircd-ircdev/ircd/ddb.c:1.4 ircd-ircdev/ircd/ddb.c:1.5 --- ircd-ircdev/ircd/ddb.c:1.4 Wed Mar 23 10:34:46 2005 +++ ircd-ircdev/ircd/ddb.c Thu Apr 14 03:28:06 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Implementation of Distributed DataBase. - * @version $Id: ddb.c,v 1.4 2005/03/23 18:34:46 zolty Exp $ + * @version $Id: ddb.c,v 1.5 2005/04/14 10:28:06 zolty Exp $ */ #include "config.h" @@ -67,8 +67,8 @@ static int ddb_iterator_hash_len = 0; static void ddb_table_init(unsigned char table); -static void ddb_add_key(unsigned char table, char *key, char *content); -static void ddb_del_key(unsigned char table, char *key); +static int ddb_add_key(unsigned char table, char *key, char *content); +static int ddb_del_key(unsigned char table, char *key); int ddb_table_is_resident(unsigned char table) @@ -152,7 +152,7 @@ { unsigned char table; - /* ddb_events_init(); */ + ddb_events_init(); memset(ddb_resident_table, 0, sizeof(ddb_resident_table)); @@ -215,6 +215,7 @@ if (!match(mask, cli_name(&me))) { int i = 0; + int update = 0; /* pasamos el key en minusculas */ if ((strlen(key) + 1 > key_len) || (!keytemp)) @@ -234,29 +235,29 @@ } if (content) - ddb_add_key(table, keytemp, content); + update = ddb_add_key(table, keytemp, content); else ddb_del_key(table, keytemp); -#if 0 /* Ejecutamos los eventos */ - if (!cptr && ddb_event_tables[table]) - ddb_event_parse[table](key, content); -#endif + /* if (!cptr && ddb_events_table[table]) */ + if (ddb_events_table[table]) + ddb_events_table[table](key, content, update); } } -static void +static int ddb_add_key(unsigned char table, char *key, char *content) { struct Ddb *ddb; char *k, *c; int hashi; + int delete = 0; ddb_iterator_key = NULL; - ddb_del_key(table, key); + delete = ddb_del_key(table, key); ddb = DdbMalloc(sizeof(struct Ddb) + strlen(key) + strlen(content) + 2); assert(0 != ddb); @@ -278,8 +279,6 @@ ddb->key = k; ddb->content = c; -// strcpy(ddb->key, key); -// strcpy(ddb->content, content); ddb->next = NULL; hashi = ddb_hash_register(ddb->key, ddb_resident_table[table]); @@ -290,14 +289,15 @@ ddb_data_table[table][hashi] = ddb; ddb_count_table[table]++; - /* EVENTOS DE ALTA */ + return delete; } -static void +static int ddb_del_key(unsigned char table, char *key) { struct Ddb *ddb, *ddb2, **ddb3; int hashi; + int delete = 0; ddb_iterator_key = NULL; @@ -310,13 +310,14 @@ if (!strcmp(ddb->key, key)) { *ddb3 = ddb2; - /* EVENTOS de BAJA */ + delete = 1; DdbFree(ddb); ddb_count_table[table]--; break; } ddb3 = &(ddb->next); } + return delete; } @@ -354,10 +355,10 @@ for (ddb = ddb_data_table[table][i]; ddb; ddb = ddb2) { ddb2 = ddb->next; -#if 0 - if (events && ddb_event_tables[table]) - ddb_event_parse[table](ddb->key, NULL); -#endif + + if (events && ddb_events_table[table]) + ddb_events_table[table](ddb->key, NULL, 0); + DdbFree(ddb); } } Index: ircd-ircdev/ircd/ddb_events.c diff -u /dev/null ircd-ircdev/ircd/ddb_events.c:1.1 --- /dev/null Thu Apr 14 03:28:26 2005 +++ ircd-ircdev/ircd/ddb_events.c Thu Apr 14 03:28:07 2005 @@ -0,0 +1,176 @@ +/* + * IRC-Dev IRCD - An advanced and innovative IRC Daemon, ircd/ddb_events.c + * + * Copyright (C) 2002-2005 IRC-Dev Development Team <de...@ir...> + * Copyright (C) 2004-2005 Toni Garcia (zoltan) <zo...@ir...> + * + * 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 + * + */ +/** @file + * @brief Events of Distributed DataBase. + * @version $Id: ddb_events.c,v 1.1 2005/04/14 10:28:07 zolty Exp $ + */ +#include "config.h" + +#include "ddb.h" +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_tea.h" +#include "msg.h" +#include "numnicks.h" +#include "s_user.h" +#include "send.h" + +#include <stdio.h> +#include <string.h> + + +static int events_init = 0; +static void ddb_events_table_n(char *key, char *content, int update); + +ddb_events_table_t ddb_events_table[DDB_TABLE_MAX]; + + +void +ddb_events_init(void) +{ + if (events_init) + return; + + ddb_events_table[DDB_NICKDB] = ddb_events_table_n; + + events_init = 1; +} + + +static void +ddb_events_table_n(char *key, char *content, int update) +{ + struct Client *cptr; + char *botname; + int nick_renames = 0; + + /* Only my clients */ + if ((cptr = FindUser(key)) && MyConnect(cptr)) + { + botname = ddb_get_botname(DDB_NICKSERV); + /* Droping Key */ + if (!content && (IsNickRegistered(cptr) || IsNickSuspended(cptr))) + { + struct Flags oldflags; + + oldflags = cli_flags(cptr); + ClearNickRegistered(cptr); + ClearNickSuspended(cptr); + + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Your nick %C is droping", cptr, cptr); + + send_umode_out(cptr, cptr, &oldflags, IsRegistered(cptr)); + } + else + { + /* New Key or Update Key */ + char c = content[strlen(content) - 1]; + int nick_suspend = 0; + int nick_forbid = 0; + + if (c == '+') + nick_suspend = 1; + else if (c == '*') + nick_forbid = 1; + + if (nick_forbid) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Your nick %C has been forbided, cannot be used", cptr, cptr); + nick_renames = 1; + } + else if (nick_suspend && update && IsNickRegistered(cptr)) + { + struct Flags oldflags; + + oldflags = cli_flags(cptr); + ClearNickRegistered(cptr); + SetNickSuspended(cptr); + + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Your nick %C has been suspended", cptr, cptr); + + send_umode_out(cptr, cptr, &oldflags, IsRegistered(cptr)); + } + else if (!nick_suspend && update && IsNickSuspended(cptr)) + { + struct Flags oldflags; + + oldflags = cli_flags(cptr); + ClearNickSuspended(cptr); + SetNickRegistered(cptr); + + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Your nick %C has been unsuspended", cptr, cptr); + + send_umode_out(cptr, cptr, &oldflags, IsRegistered(cptr)); + } + else if (!update) + { + sendcmdbotto_one(botname, CMD_NOTICE, cptr, + "%C :*** Your nick %C has been registered", cptr, cptr); + nick_renames = 1; + } + } + + if (nick_renames) + { + struct Client *acptr; + unsigned int v[2], k[2], x[2]; + char newnick[NICKLEN + 2]; + char tmp[100]; + char *parv[3]; + int flags = 0; + + k[0] = k[1] = x[0] = x[1] = 0; + + v[0] = base64toint(cli_yxx(cptr)); + v[1] = base64toint(cli_yxx(&me)); + + acptr = cptr; + + do + { + ircd_tea(v, k, x); + v[1] += 4096; + + if (x[0] >= 4294000000ul) + continue; + + sprintf(newnick, "Guest%.6d", (int)(x[0] % 1000000)); + acptr = FindUser(newnick); + } + while (acptr); + + SetRenamed(flags); + + parv[0] = cli_name(cptr); + parv[1] = newnick; + sprintf(tmp, "%lu", TStime()); + parv[2] = tmp; + + set_nick_name(cptr, cptr, newnick, 3, parv, flags); + } + } +} ----------------------- End of diff ----------------------- |