Ignore:
Timestamp:
05/31/07 15:15:23 (5 years ago)
Author:
wd
Message:

Many more changes:

  • Moved the 'core' addon code into various places in the main ircd module.
  • Split channel/user modes out of channel.c/client.c and into chanmode.c/usermode.c respectively.
  • Added init/teardown routines for channel/usermodes.
  • Changed the INVIS and OPER macros to have longer(:/) and more descriptive names.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ithildin/modules/ircd/client.h

    r801 r803  
    22 * client.h: client structure declarations 
    33 *  
    4  * Copyright 2002 the Ithildin Project. 
     4 * Copyright 2002-2007 the Ithildin Project. 
    55 * See the COPYING file for more information on licensing and use. 
    66 *  
     
    7878char *make_client_mask(char *mask); 
    7979 
    80 /* mode stuff here.  modules/systems should acquire and release modes as they 
    81  * need them.  You may not get the mode you asked for, if something else is 
    82  * already using it, so don't assume that you did.  The function will return 
    83  * the bitmask used to check for the mode on a user's structure, and also place 
    84  * the actual mode letter in a character, passed as a pointer.  If you don't 
    85  * care what mode you get specify '\0' as the suggested field.  Also, if you 
    86  * want all users who set your specific mode to be placed in a 'send flag' 
    87  * group (see send.[ch]) pass the value of the flag to use, if not pass -1. 
    88  * The last argument is the name of the function used to determine whether a 
    89  * user can set/unset the node.  The arguments are the client setting the mode, 
    90  * the client on which the mode is being set, the mode character, an integer 
    91  * specifying whether the mode is being set or unset, a pointer to an argument 
    92  * (may be NULL), and a pointer to allow the function to specify whether the 
    93  * mode used the argument or not. */ 
    94 #define USERMODE_FUNC(x)                                                   \ 
    95 int x(client_t *by __UNUSED, client_t *cli, unsigned char mode __UNUSED,   \ 
    96         int set __UNUSED, char *arg __UNUSED, int *argused __UNUSED) 
    97 typedef int (*usermode_func)(client_t *, client_t *, unsigned char, int, 
    98         char *, int *); 
    99  
    100 uint64_t usermode_request(unsigned char, unsigned char *, int, int, 
    101         usermode_func); 
    102  
    103 /* use this function to release a mode if you no longer care about it being set 
    104  * on users.  You are still responsible for clearing out the group if the mode 
    105  * had one */ 
    106 void usermode_release(unsigned char); 
    107  
    108 /* this function provides a way to update the assigned function for a 
    109  * usermode */ 
    110 void usermode_update_func(unsigned char, usermode_func); 
    111  
    112 /* this function returns a mode string from the passed 64bit integer. the 
    113  * string is statically allocated inside the function, if global is unset, get 
    114  * all usermodes, otherwise, get only global modes */ 
    115 unsigned char *usermode_getstr(uint64_t, char); 
    116  
    117 /* this does the opposite of the above, it returns a mask from a given string 
    118  * of modes, if global is non-false, the mask will only contain 'global' flags, 
    119  * otherwise, all flags are returned.  */ 
    120 uint64_t usermode_getmask(unsigned char *, char); 
    121  
    122 /* this performs a 'diff' on the modes, and returns a string reflecting the 
    123  * change from old modes to new modes, and places the result in 'result' */ 
    124 void usermode_diff(uint64_t, uint64_t, char *, char); 
    125  
    126 /* this does all the work to set a mode on a user.  it checks to see if they 
    127  * can set it, and places them in any appropriate groups.  if the function 
    128  * succeeds it returns 1, if the user cannot set the mode it returns 0 */ 
    129 int usermode_set(unsigned char, client_t *, client_t *, char *, int *); 
    130  
    131 /* this does like above, but unsetting instead of setting. */ 
    132 int usermode_unset(unsigned char, client_t *, client_t *, char *, int *); 
    133  
    134 /* returns positive if a given mode is valid and set on a client */ 
    135 #define usermode_isset(client, themode)                                       \ 
    136     ((ircd.umodes.modes[themode].avail == 0) ?                                \ 
    137      (client->modes & ircd.umodes.modes[themode].mask) :                      \ 
    138      0) 
    139  
    140 /* we know we will create some modes, create special macros to check them */ 
    141 #define INVIS(client) (client->modes & ircd.umodes.modes['i'].mask) 
    142 #define OPER(client) (client->modes & ircd.umodes.modes['o'].mask) 
    143  
    144 struct usermode { 
    145     unsigned char mode;             /* the actual mode */ 
    146     char    avail;                  /* 1 if available, 0 otherwise */ 
    147 #define USERMODE_FL_GLOBAL  0x1     /* the usermode is spread across the 
    148                                        network */ 
    149 #define USERMODE_FL_OPER    0x2     /* the usermode is operator only */ 
    150 #define USERMODE_FL_PRESERVE 0x4    /* preserve the mode once set unless 
    151                                        explicitly unset by the user */ 
    152     int     flags;                  /* flags for the usermode */ 
    153     uint64_t mask;                  /* the bitmask for the mode */ 
    154     usermode_func changefunc;       /* the changer function for the mode */ 
    155     int     sflag;                  /* send flag (if any) for this mode. */ 
    156 }; 
    157  
    15880TAILQ_HEAD(client_history_list, client_history); 
    15981struct client_history { 
Note: See TracChangeset for help on using the changeset viewer.