Revision: 1880
http://undernet-ircu.svn.sourceforge.net/undernet-ircu/?rev=1880&view=rev
Author: klmitch
Date: 2008-09-22 16:46:42 +0000 (Mon, 22 Sep 2008)
Log Message:
-----------
Author: Kev <[EMAIL PROTECTED]>
Description:
Begin sketching out the structures and fields necessary for the new,
unified mode processing system. Each entity (channel, user, or server)
will have a mode_set_t (modes with arguments will set those arguments
in fields directly adjunct to the entity structure, rather than collected
into the mode_set_t). Each mode is described by a mode_desc_t, and the
list of modes for a given entity are described by a mode_list_t.
Processing will consist of parsing the mode string into a mode_delta_t,
then applying it to the entity. (Bouncing will be simple; set the
MDELTA_REVERSE flag on the mode_delta_t before flushing it.)
Modes and mode lists will be linked in to the registration system,
making it easy to dynamically define new entities that can take modes
(e.g., services), as well as to dynamically define new modes for any
entity. Manipulating a mode will require a pointer to the mode_desc_t
for the mode, instead of the integer or flag value of the mode, so that
the mode system can dynamically assign that integer.
Couple of notes on terminology: "switch" specifies the character for
the mode, i.e., the no-topic switch is 't'. The "mode" is the integer
specifying the mode (the mode_t type is used for this). Modes also have
full names, allowing a future extension where you can use long names for
modes instead of just single characters.
Modified Paths:
--------------
ircu2/branches/mode/ChangeLog
Added Paths:
-----------
ircu2/branches/mode/include/mode.h
Modified: ircu2/branches/mode/ChangeLog
===================================================================
--- ircu2/branches/mode/ChangeLog 2008-09-20 02:32:51 UTC (rev 1879)
+++ ircu2/branches/mode/ChangeLog 2008-09-22 16:46:42 UTC (rev 1880)
@@ -1,3 +1,8 @@
+2008-09-22 Kevin L. Mitchell <[EMAIL PROTECTED]>
+
+ * include/mode.h: begin sketching out structures for new, unified
+ mode processing system
+
2008-09-19 Kevin L. Mitchell <[EMAIL PROTECTED]>
* include/flagset.h: we declared flagpage_t, then never used
Added: ircu2/branches/mode/include/mode.h
===================================================================
--- ircu2/branches/mode/include/mode.h (rev 0)
+++ ircu2/branches/mode/include/mode.h 2008-09-22 16:46:42 UTC (rev 1880)
@@ -0,0 +1,186 @@
+/*
+ * IRC - Internet Relay Chat, include/mode.h
+ * 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 Structures and functions for handling generic modes.
+ * @version $Id$
+ */
+#ifndef INCLUDED_mode_h
+#define INCLUDED_mode_h
+#ifndef INCLUDED_register_h
+#include "register.h"
+#endif
+#ifndef INCLUDED_flagset_h
+#include "flagset.h"
+#endif
+
+struct Client;
+struct Channel;
+
+/** Specifies the maximum number of modes permitted on any entity. */
+#define MAX_MODES 64
+/** Specifies the maximum number of mode params permitted in one message. */
+#define MAX_MODEPARAMS 6
+
+/** Specifies the numerical value of a mode switch. */
+typedef unsigned int mode_t;
+
+/** Describes a single mode, including parsing flags and policy flags. */
+typedef struct ModeDesc mode_desc_t;
+/** Describes a list of modes available for a channel, user, etc. */
+typedef struct ModeList mode_list_t;
+/** Describes the set of modes applicable to a specific channel, user, etc. */
+typedef struct ModeSet mode_set_t;
+/** Describes some modes with arguments. */
+typedef struct ModeArgs mode_args_t;
+/** Describes the difference between two sets of modes. */
+typedef struct ModeDelta mode_delta_t;
+
+/** Describes a single mode. */
+struct ModeDesc {
+ regent_t md_regent; /**< Registration entry. */
+ int md_switch; /**< Mode switch (character). */
+ mode_t md_mode; /**< Numerical value of mode. */
+ const char *md_desc; /**< Textual description of mode. */
+ flagpage_t md_flags; /**< Flags affecting mode. */
+};
+
+/** Mode maintains a list. */
+#define MDFLAG_LIST 0x80000000
+/** Mode should not be propagated to other servers. */
+#define MDFLAG_LOCAL 0x40000000
+/** Accept octal or hexadecimal integers, not just decimal. */
+#define MDFLAG_HEXINT 0x20000000
+
+/** Mode is visible to anyone. */
+#define MDFLAG_VIS_OPEN 0x00000000
+/** Mode is visible only to channel operators. */
+#define MDFLAG_VIS_CHOP 0x00001000
+/** Mode is visible only to IRC operators. */
+#define MDFLAG_VIS_OPER 0x00002000
+/** Mode is visible only to global IRC operators. */
+#define MDFLAG_VIS_GOP 0x00003000
+/** Mode is visible only to servers. */
+#define MDFLAG_VIS_SERV 0x00004000
+/** Mode visibility mask. */
+#define MDFLAG_VIS_MASK 0x0000f000
+
+/** Anyone can set or clear mode. */
+#define MDPOL_AUTHZ_OPEN 0x00000000
+/** Only channel operator can set or clear mode. */
+#define MDPOL_AUTHZ_CHOP 0x00000100
+/** Only IRC operators can set or clear mode. */
+#define MDPOL_AUTHZ_OPER 0x00000200
+/** Only global IRC operators can set or clear mode. */
+#define MDPOL_AUTHZ_GOP 0x00000300
+/** Only servers can set or clear mode. */
+#define MDPOL_AUTHZ_SERV 0x00000400
+/** Mode authorization mask. */
+#define MDPOL_AUTHZ_MASK 0x00000f00
+
+/** Mode describes a simple switch, e.g., +t channel mode. */
+#define MDPAR_TYPE_SWITCH 0x00000000
+/** Mode takes an optional argument, e.g., +s user mode. */
+#define MDPAR_TYPE_OPTARG 0x00000010
+/** Mode takes an argument only when added, e.g., +l channel mode. */
+#define MDPAR_TYPE_ADDARG 0x00000020
+/** Mode takes a required argument, e.g., +k channel mode. */
+#define MDPAR_TYPE_REQARG 0x00000030
+/** Mode type mask. */
+#define MDPAR_TYPE_MASK 0x000000f0
+
+/** Mode takes no argument. */
+#define MDPAR_ARG_NONE 0x00000000
+/** Mode takes an integer argument, e.g., +l channel mode. */
+#define MDPAR_ARG_INT 0x00000001
+/** Mode takes a simple string argument, e.g., +k channel mode. */
+#define MDPAR_ARG_STR 0x00000002
+/** Mode takes an argument indicating a client, e.g., +o channel mode. */
+#define MDPAR_ARG_CLI 0x00000003
+/** Mode argument type mask. */
+#define MDPAR_ARG_MASK 0x0000000f
+
+/** Describes the list of modes available for a channel, user, etc. */
+struct ModeList {
+ regtab_t ml_table; /**< Registration table. */
+ size_t ml_offset; /**< Offset of mode structure
+ within entity. */
+ mode_desc_t *ml_smap[256]; /**< Mode switch map. */
+ mode_desc_t *ml_mmap[MAX_MODES];
+ /**< Mode value map. */
+};
+
+/** Describes the set of modes set on a specific channel, user, etc. */
+DECLARE_FLAGSET(ModeSet, MAX_MODES);
+
+/** Direction not yet selected. */
+#define MDIR_NONE 0x00000000
+/** Adding modes. */
+#define MDIR_ADD 0x00000001
+/** Removing modes. */
+#define MDIR_REM 0x00000002
+/** Direction mask. */
+#define MDIR_MASK 0x00000003
+
+/** Contains a set of modes with arguments. */
+struct ModeArgs {
+ mode_args_t *ma_next; /**< Chain to next set of modes with
+ arguments. */
+ mode_args_t *ma_prev; /**< Chain to previous set of modes
+ with arguments. */
+ struct {
+ mode_desc_t *mam_mode; /**< The mode. */
+ mode_dir_t mam_dir; /**< Direction of mode. */
+ union {
+ unsigned int mama_int; /**< Unsigned integer argument. */
+ const char *mama_str; /**< String argument (keys). */
+ struct Client *mama_cli; /**< Client argument (chanops). */
+ } mam_arg; /**< Argument for mode. */
+ unsigned short mam_oplevel; /**< Oplevel for a bounce. */
+ } ma_modeargs[MAX_MODEPARAMS];
+ /**< Modes with arguments. */
+};
+
+/** Describes the difference between two mode_set_t's. */
+struct ModeDelta {
+ struct Client *md_origin; /**< Origin of delta. */
+ int md_etype; /**< Type of entity--1 for channel,
+ 0 for client. */
+ union {
+ struct Client *mde_client; /**< Client mode delta applies to. */
+ struct Channel *mde_chan; /**< Channel mode delta applies to. */
+ } md_entity; /**< Entity mode delta applies to. */
+ mode_list_t *md_modes; /**< Mode list used by this delta. */
+
+ mode_set_t md_add; /**< Simple modes to be added. */
+ mode_set_t md_rem; /**< Simple modes to be removed. */
+
+ flagpage_t md_flags; /**< Flags affecting the delta. */
+ int md_count; /**< Number of modes with args. */
+
+ mode_args_t *md_tail; /**< Tail of modes-with-args list. */
+ mode_args_t md_head; /**< First element of modes-with-args
+ list. */
+};
+
+/** The delta should not be automatically flushed. */
+#define MDELTA_NOAUTOFLUSH 0x80000000
+/** The delta is in reverse-sense mode. */
+#define MDELTA_REVERSE 0x40000000
+
+#endif /* INCLUDED_mode_h */
Property changes on: ircu2/branches/mode/include/mode.h
___________________________________________________________________
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