[IRC-Dev CVS] SF.net SVN: irc-dev:[195] ircd/trunk
Brought to you by:
zolty
From: <zo...@us...> - 2008-08-15 00:11:05
|
Revision: 195 http://irc-dev.svn.sourceforge.net/irc-dev/?rev=195&view=rev Author: zolty Date: 2008-08-15 00:11:13 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Soporte completo Tabla F Modified Paths: -------------- ircd/trunk/TODO.es ircd/trunk/ircd/ddb_events.c ircd/trunk/ircd/ircd_features.c Modified: ircd/trunk/TODO.es =================================================================== --- ircd/trunk/TODO.es 2008-08-14 21:11:51 UTC (rev 194) +++ ircd/trunk/TODO.es 2008-08-15 00:11:13 UTC (rev 195) @@ -10,7 +10,6 @@ -------------------------------------------------------------------------------------- - [D] Implementar tabla o de Operadores - [D] Implementar tabla p de Privilegios - - [D] Implementar tabla f de Features ALTA PRIORIDAD -------------------------------------------------------------------------------------- Modified: ircd/trunk/ircd/ddb_events.c =================================================================== --- ircd/trunk/ircd/ddb_events.c 2008-08-14 21:11:51 UTC (rev 194) +++ ircd/trunk/ircd/ddb_events.c 2008-08-15 00:11:13 UTC (rev 195) @@ -30,6 +30,8 @@ #include "client.h" #include "hash.h" #include "ircd.h" +#include "ircd_alloc.h" +#include "ircd_chattr.h" #include "ircd_snprintf.h" #include "ircd_tea.h" #include "msg.h" @@ -37,6 +39,7 @@ #include "s_user.h" #include "send.h" +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -48,6 +51,7 @@ static void ddb_events_table_c(char *key, char *content, int update); static void ddb_events_table_d(char *key, char *content, int update); +static void ddb_events_table_f(char *key, char *content, int update); static void ddb_events_table_o(char *key, char *content, int update); static void ddb_events_table_n(char *key, char *content, int update); static void ddb_events_table_v(char *key, char *content, int update); @@ -69,6 +73,7 @@ ddb_events_table[DDB_CHANDB] = ddb_events_table_c; ddb_events_table[DDB_CHANDB2] = ddb_events_table_d; + ddb_events_table[DDB_FEATUREDB] = ddb_events_table_f; ddb_events_table[DDB_ILINEDB] = 0; ddb_events_table[DDB_NICKDB] = ddb_events_table_n; ddb_events_table[DDB_OPERDB] = ddb_events_table_o; @@ -231,6 +236,51 @@ #endif } +/** Handle events on Features Table. + * @param[in] key Key of registry. + * @param[in] content Content of registry. + * @param[in] update Update of registry or no. + */ +static void +ddb_events_table_f(char *key, char *content, int update) +{ + static char *keytemp = NULL; + static int key_len = 0; + int i = 0; + + if ((strlen(key) + 1 > key_len) || (!keytemp)) + { + key_len = strlen(key) + 1; + if (keytemp) + MyFree(keytemp); + keytemp = MyMalloc(key_len); + + assert(0 != keytemp); + } + strcpy(keytemp, key); + while (keytemp[i]) + { + keytemp[i] = ToUpper(keytemp[i]); + i++; + } + + if (content) + { + char *tempa[2]; + tempa[0] = keytemp; + tempa[1] = content; + + feature_set(&me, tempa, 2); + } + else + { + char *tempb[1]; + tempb[0] = keytemp; + + feature_set(&me, tempb, 1); + } +} + /** Handle events on Nick Table. * @param[in] key Key of registry. * @param[in] content Content of registry. Modified: ircd/trunk/ircd/ircd_features.c =================================================================== --- ircd/trunk/ircd/ircd_features.c 2008-08-14 21:11:51 UTC (rev 194) +++ ircd/trunk/ircd/ircd_features.c 2008-08-15 00:11:13 UTC (rev 195) @@ -315,6 +315,9 @@ #define FEAT_OPER 0x0100 /**< set to display only to opers */ #define FEAT_MYOPER 0x0200 /**< set to display only to local opers */ #define FEAT_NODISP 0x0400 /**< feature must never be displayed */ +#if defined(DDB) +#define FEAT_DDB 0x0800 /**< feature ajusted via DDB */ +#endif #define FEAT_READ 0x1000 /**< feature is read-only (for now, perhaps?) */ @@ -602,7 +605,16 @@ int i, change = 0, tmp; const char *t_str; struct FeatureDesc *feat; +#if defined(DDB) + int byddb = 0; + if (from == &me) + { + byddb = 1; + from = NULL; + } +#endif + if (from && !HasPriv(from, PRIV_SET)) return send_reply(from, ERR_NOPRIVILEGES); @@ -612,6 +624,22 @@ else log_write(LS_CONFIG, L_ERROR, 0, "Not enough fields in F line"); } else if ((feat = feature_desc(from, fields[0]))) { /* find feature */ +#if defined(DDB) + if (byddb) + { + if (count < 2) + feat->flags &= ~FEAT_DDB; + else + feat->flags |= FEAT_DDB; + + } else if (feat->flags & FEAT_DDB) { + if (from) { + sendcmdto_one(&me, CMD_NOTICE, from, "%C :The feature has been setted by DDB", from); + send_reply(from, ERR_NOFEATURE, fields[0]); + } + return 0; + } +#endif if (from && feat->flags & FEAT_READ) return send_reply(from, ERR_NOFEATURE, fields[0]); @@ -767,6 +795,16 @@ if (count < 1) /* check arguments */ need_more_params(from, "RESET"); else if ((feat = feature_desc(from, fields[0]))) { /* get descriptor */ +#if defined(DDB) + if (feat->flags & FEAT_DDB) { + if (from) { + sendcmdto_one(&me, CMD_NOTICE, from, "%C :The feature has been setted by DDB", from); + send_reply(from, ERR_NOFEATURE, fields[0]); + } + return 0; + } +#endif + if (from && feat->flags & FEAT_READ) return send_reply(from, ERR_NOFEATURE, fields[0]); @@ -878,6 +916,10 @@ int i; for (i = 0; features[i].type; i++) { +#if defined(DDB) + if (features[i].flags & FEAT_DDB) + continue; +#endif features[i].flags &= ~FEAT_MARK; /* clear the marks... */ if (features[i].unmark) /* call the unmark callback if necessary */ (*features[i].unmark)(); @@ -893,6 +935,11 @@ for (i = 0; features[i].type; i++) { change = 0; +#if defined(DDB) + if (features[i].flags & FEAT_DDB) + continue; +#endif + switch (feat_type(&features[i])) { case FEAT_NONE: if (features[i].mark && @@ -984,25 +1031,61 @@ case FEAT_INT: /* Report an F-line with integer values */ +#if defined(DDB) + if (features[i].flags & FEAT_DDB) { + send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %d (setted by DDB)", + features[i].type, features[i].v_int); + break; + } else if (features[i].flags & FEAT_MARK) /* it's been changed */ +#else if (features[i].flags & FEAT_MARK) /* it's been changed */ +#endif send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %d", features[i].type, features[i].v_int); break; case FEAT_UINT: /* Report an F-line with unsigned values */ +#if defined(DDB) + if (features[i].flags & FEAT_DDB) { + send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %u (setted by DDB)", + features[i].type, features[i].v_int); + break; + } else if (features[i].flags & FEAT_MARK) /* it's been changed */ +#else if (features[i].flags & FEAT_MARK) /* it's been changed */ +#endif send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %u", features[i].type, features[i].v_int); break; case FEAT_BOOL: /* Report an F-line with boolean values */ +#if defined(DDB) + if (features[i].flags & FEAT_DDB) { + send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %s (setted by DDB)", + features[i].type, features[i].v_int ? "TRUE" : "FALSE"); + break; + } else if (features[i].flags & FEAT_MARK) /* it's been changed */ +#else if (features[i].flags & FEAT_MARK) /* it's been changed */ +#endif send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %s", features[i].type, features[i].v_int ? "TRUE" : "FALSE"); break; case FEAT_STR: /* Report an F-line with string values */ +#if defined(DDB) + if (features[i].flags & FEAT_DDB) { + if (features[i].v_str) + send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %s (setted by DDB)", + features[i].type, features[i].v_str); + else + send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s (setted by DDB)", + features[i].type); + break; + } else if (features[i].flags & FEAT_MARK) { /* it's been changed */ +#else if (features[i].flags & FEAT_MARK) { /* it's been changed */ +#endif if (features[i].v_str) send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %s", features[i].type, features[i].v_str); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |