cleaned up Channel_IsValidName (now uses strcspn())

This commit is contained in:
Florian Westphal 2006-10-02 21:55:49 +00:00
parent 257312b102
commit d8950c5dd0
2 changed files with 5 additions and 17 deletions

View File

@ -17,7 +17,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: channel.c,v 1.57 2006/08/12 11:58:21 fw Exp $";
static char UNUSED id[] = "$Id: channel.c,v 1.58 2006/10/02 21:55:49 fw Exp $";
#include "imp.h"
#include <assert.h>
@ -462,25 +462,13 @@ Channel_GetChannel( CL2CHAN *Cl2Chan )
GLOBAL bool
Channel_IsValidName( char *Name )
Channel_IsValidName( const char *Name )
{
/* Pruefen, ob Name als Channelname gueltig */
char *ptr, badchars[10];
assert( Name != NULL );
if(( Name[0] != '#' ) || ( strlen( Name ) >= CHANNEL_NAME_LEN )) return false;
ptr = Name;
strcpy( badchars, " ,:\007" );
while( *ptr )
{
if( strchr( badchars, *ptr )) return false;
ptr++;
}
return true;
return Name[strcspn(Name, " ,:\007")] == 0;
} /* Channel_IsValidName */

View File

@ -8,7 +8,7 @@
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: channel.h,v 1.29 2005/09/02 12:50:25 alex Exp $
* $Id: channel.h,v 1.30 2006/10/02 21:55:50 fw Exp $
*
* Channel management (header)
*/
@ -94,7 +94,7 @@ GLOBAL CL2CHAN *Channel_NextChannelOf PARAMS(( CLIENT *Client, CL2CHAN *Cl2Chan
GLOBAL CLIENT *Channel_GetClient PARAMS(( CL2CHAN *Cl2Chan ));
GLOBAL CHANNEL *Channel_GetChannel PARAMS(( CL2CHAN *Cl2Chan ));
GLOBAL bool Channel_IsValidName PARAMS(( char *Name ));
GLOBAL bool Channel_IsValidName PARAMS(( const char *Name ));
GLOBAL bool Channel_ModeAdd PARAMS(( CHANNEL *Chan, char Mode ));
GLOBAL bool Channel_ModeDel PARAMS(( CHANNEL *Chan, char Mode ));