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)