break;
}
- switch( *mode_ptr )
- {
- case '+':
- case '-':
- if((( *mode_ptr == '+' ) && ( ! set )) || (( *mode_ptr == '-' ) && ( set )))
- {
- /* Action modifier ("+"/"-") must be changed ... */
- len = strlen( the_modes ) - 1;
- if(( the_modes[len] == '+' ) || ( the_modes[len] == '-' ))
- {
- /* Adjust last action modifier in result */
- the_modes[len] = *mode_ptr;
- }
- else
- {
- /* Append modifier character to result string */
- x[0] = *mode_ptr;
- strlcat( the_modes, x, sizeof( the_modes ));
- }
- if( *mode_ptr == '+' ) set = true;
- else set = false;
+ switch(*mode_ptr) {
+ case '+':
+ case '-':
+ if ((*mode_ptr == '+' && !set)
+ || (*mode_ptr == '-' && set)) {
+ /* Action modifier ("+"/"-") must be changed */
+ len = strlen(the_modes) - 1;
+ if (the_modes[len] == '+'
+ || the_modes[len] == '-') {
+ /* Last character in the "result
+ * string" was an "action", so just
+ * overwrite it with the new action */
+ the_modes[len] = *mode_ptr;
+ } else {
+ /* Append new modifier character to
+ * the resulting mode string */
+ x[0] = *mode_ptr;
+ strlcat(the_modes, x,
+ sizeof(the_modes));
}
- continue;
+ if (*mode_ptr == '+')
+ set = true;
+ else
+ set = false;
+ }
+ continue;
}
-
+
/* Validate modes */
x[0] = '\0';
- switch( *mode_ptr )
- {
- case 'i': /* Invisible */
- case 's': /* Server messages */
- case 'w': /* Wallops messages */
- x[0] = *mode_ptr;
- break;
-
- case 'a': /* Away */
- if( Client_Type( Client ) == CLIENT_SERVER )
- {
- x[0] = 'a';
- Client_SetAway( Origin, DEFAULT_AWAY_MSG );
- }
- else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
- break;
-
- case 'c': /* Receive connect notices
- * (only settable by IRC operators!) */
- if(!set || Client_OperByMe(Origin)
- || Client_Type(Client) == CLIENT_SERVER)
- x[0] = 'c';
- else
- ok = IRC_WriteStrClient(Origin,
+ switch (*mode_ptr) {
+ case 'i': /* Invisible */
+ case 's': /* Server messages */
+ case 'w': /* Wallops messages */
+ x[0] = *mode_ptr;
+ break;
+ case 'a': /* Away */
+ if (Client_Type(Client) == CLIENT_SERVER) {
+ x[0] = 'a';
+ Client_SetAway(Origin, DEFAULT_AWAY_MSG);
+ } else
+ ok = IRC_WriteStrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
- break;
-
- case 'o': /* IRC operator (only unsettable!) */
- if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER ))
- {
- Client_SetOperByMe( Target, false );
- x[0] = 'o';
- }
- else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
- break;
-
- case 'r': /* Restricted (only settable) */
- if(( set ) || ( Client_Type( Client ) == CLIENT_SERVER )) x[0] = 'r';
- else ok = IRC_WriteStrClient( Origin, ERR_RESTRICTED_MSG, Client_ID( Origin ));
- break;
-
- case 'x': /* Cloak hostname */
- if (Client_HasMode(Client, 'r'))
- ok = IRC_WriteStrClient(Origin,
- ERR_RESTRICTED_MSG,
- Client_ID(Origin));
- else
- x[0] = 'x';
- break;
-
- default:
- Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ));
- if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
+ break;
+ case 'c': /* Receive connect notices
+ * (only settable by IRC operators!) */
+ if (!set || Client_Type(Client) == CLIENT_SERVER
+ || Client_OperByMe(Origin))
+ x[0] = 'c';
+ else
+ ok = IRC_WriteStrClient(Origin,
+ ERR_NOPRIVILEGES_MSG,
+ Client_ID(Origin));
+ break;
+ case 'o': /* IRC operator (only unsettable!) */
+ if (!set || Client_Type(Client) == CLIENT_SERVER) {
+ Client_SetOperByMe(Target, false);
+ x[0] = 'o';
+ } else
+ ok = IRC_WriteStrClient(Origin,
+ ERR_NOPRIVILEGES_MSG,
+ Client_ID(Origin));
+ break;
+ case 'r': /* Restricted (only settable) */
+ if (set || Client_Type(Client) == CLIENT_SERVER)
+ x[0] = 'r';
+ else
+ ok = IRC_WriteStrClient(Origin,
+ ERR_RESTRICTED_MSG,
+ Client_ID(Origin));
+ break;
+ case 'x': /* Cloak hostname */
+ if (Client_HasMode(Client, 'r'))
+ ok = IRC_WriteStrClient(Origin,
+ ERR_RESTRICTED_MSG,
+ Client_ID(Origin));
+ else
+ x[0] = 'x';
+ break;
+ default:
+ if (Client_Type(Client) != CLIENT_SERVER) {
+ Log(LOG_DEBUG,
+ "Unknown mode \"%c%c\" from \"%s\"!?",
+ set ? '+' : '-', *mode_ptr,
+ Client_ID(Origin));
+ ok = IRC_WriteStrClient(Origin,
+ ERR_UMODEUNKNOWNFLAG2_MSG,
+ Client_ID(Origin),
+ set ? '+' : '-',
+ *mode_ptr);
x[0] = '\0';
- goto client_exit;
+ } else {
+ Log(LOG_DEBUG,
+ "Handling unknown mode \"%c%c\" from \"%s\" for \"%s\" ...",
+ set ? '+' : '-', *mode_ptr,
+ Client_ID(Origin), Client_ID(Target));
+ x[0] = *mode_ptr;
+ }
}
+
if (!ok)
break;
strlcat(the_modes, x, sizeof(the_modes));
}
}
-client_exit:
/* Are there changed modes? */
if (the_modes[1]) {
if (Client_Type(Client) == CLIENT_SERVER) {
/* Forward modes to other servers */
+ if (Client_Conn(Target) != NONE) {
+ /* Remote server (service?) changed modes
+ * for one of our clients. Inform it! */
+ IRC_WriteStrClientPrefix(Target, Origin,
+ "MODE %s :%s",
+ Client_ID(Target),
+ the_modes);
+ }
IRC_WriteStrServersPrefix(Client, Origin,
"MODE %s :%s",
Client_ID(Target),
case 'i': /* Invite only */
case 'm': /* Moderated */
case 'n': /* Only members can write */
+ case 'R': /* Registered users only */
case 's': /* Secret channel */
case 't': /* Topic locked */
case 'z': /* Secure connections only */
Channel_Name(Channel));
break;
/* --- Channel user modes --- */
+ case 'a':
+ case 'h':
+ case 'q':
+ if (Client_Type(Client) != CLIENT_SERVER) {
+ connected = IRC_WriteStrClient(Origin,
+ ERR_CHANOPRIVSNEEDED_MSG,
+ Client_ID(Origin),
+ Channel_Name(Channel));
+ goto chan_exit;
+ }
case 'o': /* Channel operator */
case 'v': /* Voice */
if (arg_arg > mode_arg) {
}
break;
default:
- Log(LOG_DEBUG,
- "Unknown mode \"%c%c\" from \"%s\" on %s!?",
- set ? '+' : '-', *mode_ptr, Client_ID(Origin),
- Channel_Name(Channel));
- if (Client_Type(Client) != CLIENT_SERVER)
+ if (Client_Type(Client) != CLIENT_SERVER) {
+ Log(LOG_DEBUG,
+ "Unknown mode \"%c%c\" from \"%s\" on %s!?",
+ set ? '+' : '-', *mode_ptr,
+ Client_ID(Origin), Channel_Name(Channel));
connected = IRC_WriteStrClient(Origin,
ERR_UMODEUNKNOWNFLAG2_MSG,
Client_ID(Origin),
set ? '+' : '-', *mode_ptr);
- x[0] = '\0';
- goto chan_exit;
- } /* switch() */
+ x[0] = '\0';
+ } else {
+ Log(LOG_DEBUG,
+ "Handling unknown mode \"%c%c\" from \"%s\" on %s ...",
+ set ? '+' : '-', *mode_ptr,
+ Client_ID(Origin), Channel_Name(Channel));
+ x[0] = *mode_ptr;
+ }
+ }
if (!connected)
break;