# arch-tag: automatic-ChangeLog--srvx@srvx.net--2005-srvx/srvx--devo--1.3
#
+2005-11-01 00:23:14 GMT Michael Poole <mdpoole@troilus.org> patch-31
+
+ Summary:
+ Handle default oplevels.
+ Revision:
+ srvx--devo--1.3--patch-31
+
+ src/chanserv.c (cmd_mode): Calculate base oplevel as 1 plus one point
+ for each access level below owner.
+ (chan_opt_modes): Add new argument for mod_chanmode_parse().
+ (chanserv_conf_read): Likewise.
+ (chanserv_channel_read): Likewise.
+
+ src/hash.c (AddChannel): Likewise.
+ (AddChannelUser): Set oplevel by default.
+
+ src/hash.h (MAXOPLEVEL): New define value.
+ (modeNode): Shrink modes and oplevel fields.
+
+ src/opserv.c (cmd_chaninfo): Fix indentation; show oplevel after
+ nickname rather than before it.
+
+ src/proto.h (mod_chanmode_parse): Declare new parameter.
+
+ src/proto-bahamut.c (mod_chanmode_parse): Add new parameter (and
+ ignore it).
+
+ src/proto-common.c (mod_chanmode): Find the default oplevels for
+ parsing the mode change.
+
+ src/proto-p10.c (create_desc): Remove oplevel field.
+ (join_helper): Do not try to set oplevel for new modeNode.
+ (parse_foreach): Do not bother parsing oplevels in JOIN, since they
+ are no longer used.
+ (mod_chanmode_parse): Add new parameter and use it to determine the
+ oplevel to set when a valid oplevel one is not specified.
+
+ modified files:
+ ChangeLog src/chanserv.c src/hash.c src/hash.h src/opserv.c
+ src/proto-bahamut.c src/proto-common.c src/proto-p10.c
+ src/proto.h
+
+
2005-10-13 02:20:55 GMT Michael Poole <mdpoole@troilus.org> patch-30
Summary:
static CHANSERV_FUNC(cmd_mode)
{
+ struct userData *uData;
struct mod_chanmode *change;
-
+ short base_oplevel;
+
if(argc < 2)
{
change = &channel->channel_info->modes;
return 1;
}
- change = mod_chanmode_parse(channel, argv+1, argc-1, MCP_KEY_FREE|MCP_REGISTERED);
+ uData = GetChannelUser(channel->channel_info, user->handle_info);
+ if (!uData)
+ base_oplevel = MAXOPLEVEL;
+ else if (uData->access >= UL_OWNER)
+ base_oplevel = 1;
+ else
+ base_oplevel = 1 + UL_OWNER - uData->access;
+ change = mod_chanmode_parse(channel, argv+1, argc-1, MCP_KEY_FREE|MCP_REGISTERED, base_oplevel);
if(!change)
{
reply("MSG_INVALID_MODES", unsplit_string(argv+1, argc-1, NULL));
{
memset(&channel->channel_info->modes, 0, sizeof(channel->channel_info->modes));
}
- else if(!(new_modes = mod_chanmode_parse(channel, argv+1, argc-1, MCP_KEY_FREE|MCP_REGISTERED)))
+ else if(!(new_modes = mod_chanmode_parse(channel, argv+1, argc-1, MCP_KEY_FREE|MCP_REGISTERED, 0)))
{
reply("CSMSG_INVALID_MODE_LOCK", unsplit_string(argv+1, argc-1, NULL));
return 0;
str = "+nt";
safestrncpy(mode_line, str, sizeof(mode_line));
ii = split_line(mode_line, 0, ArrayLength(modes), modes);
- if((change = mod_chanmode_parse(NULL, modes, ii, MCP_KEY_FREE)) && (change->argc < 2))
+ if((change = mod_chanmode_parse(NULL, modes, ii, MCP_KEY_FREE, 0))
+ && (change->argc < 2))
{
chanserv_conf.default_modes = *change;
mod_chanmode_free(change);
if(!IsSuspended(cData)
&& (str = database_get_data(channel, KEY_MODES, RECDB_QSTRING))
&& (argc = split_line(str, 0, ArrayLength(argv), argv))
- && (modes = mod_chanmode_parse(cNode, argv, argc, MCP_KEY_FREE))) {
+ && (modes = mod_chanmode_parse(cNode, argv, argc, MCP_KEY_FREE, 0))) {
cData->modes = *modes;
if(off_channel > 0)
cData->modes.modes_set |= MODE_REGISTERED;
strcpy(cNode->name, name);
banList_init(&cNode->banlist);
modeList_init(&cNode->members);
- mod_chanmode(NULL, cNode, argv, nn, 0);
+ mod_chanmode(NULL, cNode, argv, nn, MCP_FROM_SERVER);
dict_insert(channels, cNode->name, cNode);
cNode->timestamp = time_;
rel_age = 1;
wipeout_channel(cNode, time_, argv, nn);
rel_age = 1;
} else if (cNode->timestamp == time_) {
- mod_chanmode(NULL, cNode, argv, nn, 0);
+ mod_chanmode(NULL, cNode, argv, nn, MCP_FROM_SERVER);
rel_age = 0;
} else {
rel_age = -1;
mNode->channel = channel;
mNode->user = user;
mNode->modes = 0;
+ mNode->oplevel = -1;
mNode->idle_since = now;
/* Add modeNode to channel and to user.
#define REALLEN 50
#define TOPICLEN 250
#define CHANNELLEN 200
+#define MAXOPLEVEL 999
#define MAXMODEPARAMS 6
#define MAXBANS 45
struct modeNode {
struct chanNode *channel;
struct userNode *user;
- long modes;
- int oplevel;
+ unsigned short modes;
+ short oplevel;
time_t idle_since;
};
}
reply("OSMSG_CHANINFO_USER_COUNT", channel->members.used);
for (n=0; n<channel->members.used; n++) {
- moden = channel->members.list[n];
- if (moden->modes & MODE_CHANOP)
- {
- if (moden->oplevel >= 0)
- {
- send_message_type(4, user, cmd->parent->bot, " (%d)@%s (%s@%s)", moden->oplevel, moden->user->nick, moden->user->ident, moden->user->hostname);
- } else {
- send_message_type(4, user, cmd->parent->bot, " @%s (%s@%s)", moden->user->nick, moden->user->ident, moden->user->hostname);
- }
+ moden = channel->members.list[n];
+ if (moden->modes & MODE_CHANOP) {
+ if (moden->oplevel >= 0)
+ send_message_type(4, user, cmd->parent->bot, " @%s:%d (%s@%s)", moden->user->nick, moden->oplevel, moden->user->ident, moden->user->hostname);
+ else
+ send_message_type(4, user, cmd->parent->bot, " @%s (%s@%s)", moden->user->nick, moden->user->ident, moden->user->hostname);
}
}
for (n=0; n<channel->members.used; n++) {
if (!inchan)
DelChannelUser(bot, channel, "My work here is done", 0);
reply("OSMSG_KICKALL_DONE", channel->name);
- return 1;
+ return 1;
}
static MODCMD_FUNC(cmd_part)
}
struct mod_chanmode *
-mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags)
+mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags, short base_oplevel)
{
struct mod_chanmode *change;
unsigned int ii, in_arg, ch_arg, add;
error:
mod_chanmode_free(change);
return NULL;
+ (void)base_oplevel;
}
struct chanmode_buffer {
int
mod_chanmode(struct userNode *who, struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags)
{
+ struct modeNode *member;
struct mod_chanmode *change;
unsigned int ii;
+ short base_oplevel;
if (!modes || !modes[0])
return 0;
- if (!(change = mod_chanmode_parse(channel, modes, argc, flags)))
+ if (who && (member = GetUserMode(channel, who)))
+ base_oplevel = member->oplevel;
+ else
+ base_oplevel = MAXOPLEVEL;
+ if (!(change = mod_chanmode_parse(channel, modes, argc, flags, base_oplevel)))
return 0;
if (flags & MC_ANNOUNCE)
mod_chanmode_announce(who, channel, change);
struct create_desc {
struct userNode *user;
- int oplevel;
time_t when;
};
join_helper(struct chanNode *chan, void *data)
{
struct create_desc *cd = data;
- struct modeNode *mNode;
-
- mNode = AddChannelUser(cd->user, chan);
- mNode->oplevel = cd->oplevel;
- if (mNode->oplevel >= 0)
- mNode->modes |= MODE_CHANOP;
+ AddChannelUser(cd->user, chan);
}
static void
parse_foreach(char *target_list, foreach_chanfunc cf, foreach_nonchan nc, foreach_userfunc uf, foreach_nonuser nu, void *data)
{
char *j, old;
- char *cPos, *hPos;
- int oplevel;
do {
j = target_list;
old = *j;
*j = 0;
- hPos = strchr(target_list,'#');
- cPos = strchr(target_list,':');
-
- /*
- * Check if both a '#' and a ':' is in the target's name
- * and if cPos < hPos.
- * If that's the case, voila, we've found a join with an oplevel
- */
- if (hPos && cPos && (cPos < hPos))
- {
- oplevel = parse_oplevel(target_list);
- target_list = hPos + 1;
- }
- else
- oplevel = -1;
-
if (IsChannelName(target_list)
|| (target_list[0] == '0' && target_list[1] == '\0')) {
struct chanNode *chan = GetChannel(target_list);
- struct create_desc *cd = (struct create_desc*) data;
- cd->oplevel = oplevel;
if (chan) {
if (cf)
cf(chan, data);
}
struct mod_chanmode *
-mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags)
+mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags, short base_oplevel)
{
struct mod_chanmode *change;
unsigned int ii, in_arg, ch_arg, add;
int oplevel;
oplevel_str = strchr(modes[in_arg], ':');
-
- /* XXYYY M #channel +o XXYYY:<oplevel> */
if (oplevel_str)
{
- oplevel = parse_oplevel(oplevel_str+1);
- *oplevel_str = 0;
+ /* XXYYY M #channel +o XXYYY:<oplevel> */
+ *oplevel_str++ = '\0';
+ oplevel = parse_oplevel(oplevel_str);
+ if (oplevel <= base_oplevel && !(flags & MCP_FROM_SERVER))
+ oplevel = base_oplevel + 1;
}
else if (channel->modes & MODE_UPASS)
- {
- /* TODO: need to set oplevel based on issuer's oplevel */
- oplevel = -1;
- }
+ oplevel = base_oplevel + 1;
else
oplevel = -1;
+ /* Check that oplevel is within bounds. */
+ if (oplevel > MAXOPLEVEL)
+ oplevel = MAXOPLEVEL;
+
if (!(flags & MCP_ALLOW_OVB))
goto error;
if (in_arg >= argc)
struct mod_chanmode *mod_chanmode_alloc(unsigned int argc);
struct mod_chanmode *mod_chanmode_dup(struct mod_chanmode *orig, unsigned int extra);
-struct mod_chanmode *mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags);
+struct mod_chanmode *mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags, short base_oplevel);
void mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_chanmode *change);
void mod_chanmode_announce(struct userNode *who, struct chanNode *channel, struct mod_chanmode *change);
char *mod_chanmode_format(struct mod_chanmode *desc, char *buffer);