/*
 * Define this in merc.h or right above the function.
 * #define ILLEGAL_NAME_FILE	"illegalnames.txt"
 */

void do_illegalname( CHAR_DATA *ch, char *argument)
{
    char strsave[MIL], namelist[MSL], nameread[MSL], name[MSL];
    FILE *fp;
    if ( argument[0] == '\0' )
    {
	send_to_char( "syntax: badname <name>.\n\r", ch );
	return;
    }
    fclose( fpReserve );
    sprintf( strsave, "%s", ILLEGAL_NAME_FILE );
    sprintf(name, "%s\n", argument);
    sprintf(namelist,"%s","");
    if ( (fp = fopen( strsave, "r" ) ) != NULL )
    {
	for ( ; ; )
	{
            fscanf (fp, "%s", nameread);
	    if ( !str_cmp( nameread, "END" ) )
           	break;
	    else
	    {
		strcat(namelist, nameread);
		strcat(namelist,"\n");
	    }
	}
    }
    else
	fp = fopen( NULL_FILE, "r" );
    fclose( fp );
    fp = fopen( strsave, "w" );
    strcat( namelist, name );
    fprintf( fp, "%s", namelist );
    fprintf( fp, "END" );
    fclose( fp );
    fpReserve = fopen( NULL_FILE, "r" );
    send_to_char( "All set, that name is now illegal.\n\r",ch);
}

/*
 * Depending on the users/ownership or a funky FTP program you might
 * need to set the chmod on the txt file. If the MUD crashes due to this
 * command then that is most likely why.
 */

/*
 * Add this function to comm.c or nanny.c
 */

bool check_illegal_name( char *name )
{
    char strsave[MIL], nameread[MSL];
    FILE *fp;
    fclose( fpReserve );
    sprintf( strsave, "%s", ILLEGAL_NAME_FILE );
    if ( (fp = fopen( strsave, "r" ) ) != NULL )
    {
        for ( ; ; )
	{
            fscanf (fp, " %s", nameread);
            if ( !str_cmp( nameread, "END" ) )
                break;  
            else if (is_name(name,nameread))
		return TRUE;
        }
    }
    else
	fp = fopen( NULL_FILE, "r" );
    fclose( fp );
    fpReserve = fopen( NULL_FILE, "r" );  
    return FALSE;  
}

/*
 * Add this check to check_parse_name
 */

    if (check_delete_name( name ))
	return FALSE;

/* 
 * Add the do_illegalname to interp.c/h and define the bool if you didn't
 * insert it above its call. Now create a file called illegalnames.txt in
 * your areas dir and type END and save/exit.
 */