Revision: 1884
http://undernet-ircu.svn.sourceforge.net/undernet-ircu/?rev=1884&view=rev
Author: klmitch
Date: 2008-10-03 03:49:25 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
Author: Kev <[EMAIL PROTECTED]>
Description:
Rough out mode.c and the basic programming interface, then implement
mode_compat_init().
Modified Paths:
--------------
ircu2/branches/mode/ChangeLog
ircu2/branches/mode/include/mode.h
ircu2/branches/mode/ircd/mode-compat.c
Added Paths:
-----------
ircu2/branches/mode/ircd/mode.c
Modified: ircu2/branches/mode/ChangeLog
===================================================================
--- ircu2/branches/mode/ChangeLog 2008-10-03 01:16:53 UTC (rev 1883)
+++ ircu2/branches/mode/ChangeLog 2008-10-03 03:49:25 UTC (rev 1884)
@@ -1,5 +1,14 @@
2008-10-02 Kevin L. Mitchell <[EMAIL PROTECTED]>
+ * ircd/mode-compat.c: implement mode_compat_init()
+
+ * include/mode.h: define mode table name; adjust MODE_LIST_INIT()
+ to reference reg_t and unreg_t callbacks; declare those callbacks
+ and mode_init() function
+
+ * ircd/mode.c: begin sketching out the actual code of the generic
+ mode system
+
* include/mode.h: mode deltas are not necessarily applied against
a specific client, so pull that code out; remove pre-declaration
of struct Channel that's no longer needed; define magic number and
Modified: ircu2/branches/mode/include/mode.h
===================================================================
--- ircu2/branches/mode/include/mode.h 2008-10-03 01:16:53 UTC (rev 1883)
+++ ircu2/branches/mode/include/mode.h 2008-10-03 03:49:25 UTC (rev 1884)
@@ -39,6 +39,9 @@
/** Specifies the maximum number of mode params permitted in one message. */
#define MAX_MODEPARAMS 6
+/** Registration table for mode lists. */
+#define MODE_TABLE "mode"
+
/** Specifies the numerical value of a mode switch. */
typedef key_t mode_t;
@@ -158,8 +161,9 @@
* @param[in] name Descriptive name for the mode list.
* @param[in] offset Offset of modeset_t entry in entity structure.
*/
-#define MODE_LIST_INIT(name, offset) \
- { REGTAB_INIT((name), MODE_DESC_MAGIC, 0, 0), (offset), \
+#define MODE_LIST_INIT(name, offset) \
+ { REGTAB_INIT((name), MODE_DESC_MAGIC, (reg_t) _mode_desc_reg, \
+ (unreg_t) _mode_desc_unreg), (offset), \
KEYSPACE_INIT(MAX_MODES, 0, 0, 0) }
/** Describes the set of modes set on a specific channel, user, etc. */
@@ -214,4 +218,12 @@
/** The delta is in reverse-sense mode. */
#define MDELTA_REVERSE 0x40000000
+/* Assign mode and add to appropriate tables. */
+extern int _mode_desc_reg(regtab_t* table, modedesc_t* md);
+/* Release mode and remove from tables. */
+extern int _mode_desc_unreg(regtab_t* table, modedesc_t* md);
+
+/* Initialize mode subsystem. */
+extern void mode_init(void);
+
#endif /* INCLUDED_mode_h */
Modified: ircu2/branches/mode/ircd/mode-compat.c
===================================================================
--- ircu2/branches/mode/ircd/mode-compat.c 2008-10-03 01:16:53 UTC (rev
1883)
+++ ircu2/branches/mode/ircd/mode-compat.c 2008-10-03 03:49:25 UTC (rev
1884)
@@ -24,7 +24,11 @@
#include "mode-compat.h"
#include "mode.h"
+#include "register.h"
+/** Compute the number of entries in a modedesc_t array. */
+#define mdcount(arr) (sizeof(arr) / sizeof(modedesc_t))
+
/** Initial list of channel modes. Note that this must be the same
* order as enum ChanModes!
*/
@@ -125,4 +129,13 @@
void
mode_compat_init(void)
{
+ /* Let's first register the mode lists... */
+ reg(MODE_TABLE, &chanmodes);
+ reg(MODE_TABLE, &usermodes);
+ reg(MODE_TABLE, &servmodes);
+
+ /* Now, let's register the mode descriptors. */
+ regtab_n(&chanmodes, _cmodes, mdcount(_cmodes), sizeof(modedesc_t));
+ regtab_n(&usermodes, _umodes, mdcount(_umodes), sizeof(modedesc_t));
+ regtab_n(&servmodes, _smodes, mdcount(_smodes), sizeof(modedesc_t));
}
Added: ircu2/branches/mode/ircd/mode.c
===================================================================
--- ircu2/branches/mode/ircd/mode.c (rev 0)
+++ ircu2/branches/mode/ircd/mode.c 2008-10-03 03:49:25 UTC (rev 1884)
@@ -0,0 +1,78 @@
+/*
+ * IRC - Internet Relay Chat, include/mode.c
+ * Copyright (C) 2008 Kevin L. Mitchell
+ *
+ * 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, 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 Implementation of generic modes.
+ * @version $Id$
+ */
+#include "config.h"
+
+#include "mode.h"
+#include "ircd_log.h"
+#include "register.h"
+
+/** Initialize a mode list.
+ * @param[in] table Pointer to md_table.
+ * @param[in] ml Mode list to verify.
+ * @return 0 for valid mode list, non-zero otherwise.
+ */
+static int
+ml_reg(regtab_t* table, modelist_t* ml)
+{
+}
+
+/** Clean up a mode list.
+ * @param[in] table Pointer to md_table.
+ * @param[in] ml Mode list to flush.
+ * @return 0 to accept unregistration.
+ */
+static int
+ml_unreg(regtab_t* table, modelist_t* ml)
+{
+}
+
+/** Table of mode lists. */
+static regtab_t md_table = REGTAB_INIT(MODE_TABLE, REGTAB_MAGIC,
+ (reg_t) ml_reg, (unreg_t) ml_unreg);
+
+/** Assign mode and add to appropriate tables.
+ * @param[in] table Pointer to mode list.
+ * @param[in] md Mode descriptor to add.
+ * @return 0 for valid mode descriptor, non-zero otherwise.
+ */
+int
+_mode_desc_reg(regtab_t* table, modedesc_t* md)
+{
+}
+
+/** Release mode and remove from tables.
+ * @param[in] table Pointer to mode list.
+ * @param[in] md Mode descriptor to remove.
+ * @return 0 to accept unregistration.
+ */
+int
+_mode_desc_unreg(regtab_t* table, modedesc_t* md)
+{
+}
+
+/** Initialize mode subsystem. */
+void
+mode_init(void)
+{
+ reg(REG_TABLE, &md_table);
+}
Property changes on: ircu2/branches/mode/ircd/mode.c
___________________________________________________________________
Added: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches