Exemplo n.º 1
0
int
main (int argc, char *argv [])
{
        g_thread_init (NULL);

	free (malloc (8));

	if (!bonobo_init (NULL, NULL))
		g_error ("Can not bonobo_init");

	bonobo_activate ();

	check_string ("a:", "\\\\", "\\");

	check_string ("a:", "\\#", "#");

	check_string ("prefix:", "\\!", "!");

	check_string ("a:",
		      "1\\!\\#\\!\\!\\#\\\\",
		      "1!#!!#\\");

	check_parse_name ("#b:", "b:", 0);

	check_parse_name ("a:#b:", "b:", 2);

	check_parse_name ("a:!b:", "!b:", 2);

	check_parse_name ("a:3456789#b:", "b:", 9);

	check_parse_name ("a:\\##b:", "b:", 4);

	check_parse_name ("a:\\#c:", "a:\\#c:", 0);

	check_parse_name ("a:\\\\##c:", "c:", 5);

	check_parse_name ("a:\\\\#b:#c:", "c:", 7);

	check_parse_name ("a:\\\\#b:\\#c:", "b:\\#c:", 4);

	check_parse_name ("a:\\\\\\#b:\\#c:", "a:\\\\\\#b:\\#c:", 0);

	test_real_monikers ();

	return bonobo_debug_shutdown ();
}
Exemplo n.º 2
0
void do_rename (CHAR_DATA* ch, char* argument)
{
	char old_name[MAX_INPUT_LENGTH], 
	     new_name[MAX_INPUT_LENGTH],
	     strsave [MAX_INPUT_LENGTH];

	CHAR_DATA* victim;
	FILE* file;
	
	argument = one_argument(argument, old_name); /* find new/old name */
	one_argument (argument, new_name);
	
	/* Trivial checks */
	if (!old_name[0])
	{
		send_to_char ("Rename who?\n\r",ch);
		return;
	}
	
	victim = get_char_world (ch, old_name);
	
	if (!victim)
	{
		send_to_char ("There is no such a person online.\n\r",ch);
		return;
	}
	
	if (IS_NPC(victim))
	{   
		send_to_char ("You cannot use Rename on NPCs.\n\r",ch);
		return;
	}

	/* allow rename self new_name,but otherwise only lower level */	
	if ( (victim != ch) && (get_trust (victim) >= get_trust (ch)) )
	{
		send_to_char ("You failed.\n\r",ch);
		return;
	}
	
	if (!victim->desc || (victim->desc->connected != CON_PLAYING) )
	{
		send_to_char ("This player has lost his link or is inside a pager or the like.\n\r",ch);
		return;
	}

	if (!new_name[0])
	{
		send_to_char ("Rename to what new name?\n\r",ch);
		return;
	}
	
	/* Insert check for clan here!! */
	/*

	if (victim->clan)
	{
		send_to_char ("This player is member of a clan, remove him from there first.\n\r",ch);
		return;
	}
	*/
	
	if (!check_parse_name(new_name))
	{
		send_to_char ("The new name is illegal.\n\r",ch);
		return;
	}

	/* First, check if there is a player named that off-line */	
#if !defined(machintosh) && !defined(MSDOS)
    sprintf( strsave, "%s%s%s%s", PLAYER_DIR, initial( new_name ),
	    	 "/", capitalize( new_name ) );
#else
    sprintf( strsave, "%s%s", PLAYER_DIR, capitalize( new_name ) );
#endif

	fclose (fpReserve); /* close the reserve file */
	file = fopen (strsave, "r"); /* attempt to to open pfile */
	if (file)
	{
		send_to_char ("A player with that name already exists!\n\r",ch);
		fclose (file);
    	fpReserve = fopen( NULL_FILE, "r" ); /* is this really necessary these days? */
		return;		
	}
   	fpReserve = fopen( NULL_FILE, "r" );  /* reopen the extra file */

	/* Check .gz file ! */
#if !defined(machintosh) && !defined(MSDOS)
    sprintf( strsave, "%s%s%s%s.gz", PLAYER_DIR, initial( new_name ),
	    	 "/", capitalize( new_name ) );
#else
    sprintf( strsave, "%s%s.gz", PLAYER_DIR, capitalize( new_name ) );
#endif

	fclose (fpReserve); /* close the reserve file */
	file = fopen (strsave, "r"); /* attempt to to open pfile */
	if (file)
	{
		send_to_char ("A player with that name already exists in a compressed file!\n\r",ch);
		fclose (file);
    	fpReserve = fopen( NULL_FILE, "r" ); 
		return;		
	}
   	fpReserve = fopen( NULL_FILE, "r" );  /* reopen the extra file */

	if (get_char_world(ch,new_name)) /* check for playing level-1 non-saved */
	{
		send_to_char ("A player with the name you specified already exists!\n\r",ch);
		return;
	}

	/* Save the filename of the old name */

#if !defined(machintosh) && !defined(MSDOS)
    sprintf( strsave, "%s%s%s%s", PLAYER_DIR, initial( victim->name ),
	    	 "/", capitalize( victim->name ) );
#else
    sprintf( strsave, "%s%s", PLAYER_DIR, capitalize( victim->name ) );
#endif


	/* Rename the character and save him to a new file */
	/* NOTE: Players who are level 1 do NOT get saved under a new name */

	free_string (victim->name);
	victim->name = str_dup (capitalize(new_name));
	
	save_char_obj (victim);
	
	/* unlink the old file */
	unlink (strsave); /* unlink does return a value.. but we do not care */

	/* That's it! */
	
	send_to_char ("Character renamed.\n\r",ch);

	victim->position = POS_STANDING; /* I am laaazy */
	act ("$n has renamed you to $N!",ch,NULL,victim,TO_VICT);
			
} /* do_rename */
Exemplo n.º 3
0
void do_ban( char_data* ch, char* argument )
{
  account_data*   account;
  ban_data*           ban;
  pfile_data*       pfile  = NULL;
  int               flags;
  int                   i;
  bool              first  = TRUE;
  const char*        name;
  player_data*     victim;

  if( !get_flags( ch, argument, &flags, "srn", "Ban" ) )
    return;

  if( is_set( &flags, 2 ) ) {
    if( *argument == '\0' ) {
      if( badname_array == NULL ) {
        send( ch, "The badname array is empty.\n\r" );
        }
      else {
        display_array( ch, "Bad Name Array", &badname_array[0],
          &badname_array[1], max_badname );
        }
      return;
      }
    i = pntr_search( badname_array, max_badname, argument );
    if( is_set( &flags, 1 ) ) {
      if( i < 0 ) {
        send( ch, "The name '%s' wasn't in the badname array.\n\r",
          argument );
        }
      else {
        record_delete( sizeof( char* ), MEM_BADNAME );
        remove( badname_array, max_badname, i );
        send( ch, "Name removed from badname array.\n\r" );
        save_badname( );
        }
      }
    else {
      if( i > 0 ) {
        send( ch, "The name '%s' is already in the badname array.\n\r",
          argument );
        }
      else if( check_parse_name( ch->link, argument ) ) {
        i = -i-1;
        record_new( sizeof( char* ), MEM_BADNAME );
        name = alloc_string( argument, MEM_BADNAME );
        insert( badname_array, max_badname, name, i );
        send( ch, "The name '%s' is added to the badname array.\n\r",
          name );
        save_badname( );
        }
      }
    return;
    }

  if( is_set( &flags, 0 ) ) {
    if( *argument == '\0' ) {
      page_title( ch, "Banned Sites" );
      for( ban = ban_list; ban != NULL; ban = ban->next )
        page( ch, "%s\n\r", ban->name );
      return;
      }
    if( !is_set( &flags, 1 ) ) {
      for( ban = ban_list; ban != NULL; ban = ban->next ) {
        if( !strcasecmp( argument, ban->name ) ) {
          send( "That site is already banned!\n\r", ch );
          return;
          }
        }
      ban        = new ban_data;
      ban->name  = alloc_string( argument, MEM_BAN );
      save_banned( );
      send( ch, "Ok.\n\r" );
      }
    else {
      for( ban = ban_list; ban != NULL; ban = ban->next ) {
        if( !strcasecmp( argument, ban->name ) ) {
          delete ban;
          save_banned();
          send( ch, "Ok.\n\r" );
          return;
          }
        }
      send( ch, "Site is not banned.\n\r" );
      }
    return;
    }

  if( *argument == '\0' ) {
    page_title( ch, "Banned Accounts" );
    for( i = 0; i < max_account; i++ )
      if( account_list[i]->banned != -1 ) 
        display_account( ch, account_list[i], first );
    return;
    }

  if( ( account = account_arg( argument ) ) == NULL ) {
    if( ( pfile = player_arg( argument ) ) == NULL ) {
      send( ch, "No such account or player.\n\r" );
      return;
      }
    if( ( account = pfile->account ) == NULL ) {
      send( ch, "That player doesn't have an account which makes banning\
 it difficult.\n\r" );
      return;
      }
    }