/* This command copies the mud commands.dat file from code port to main port and build port
 * It is written for, and meant to be added to, the shell snippet, by samson - Sadiq 7-3-00 */

void do_copycommands( CHAR_DATA *ch, char *argument )
{
   char buf[MAX_STRING_LENGTH];
   int valid = 0;

   if ( IS_NPC(ch) )
   {
      send_to_char( "Mobs cannot use the copycommands command!\n\r", ch );
	return;
   }

   if ( port != CODEPORT )
   {
	send_to_char( "&RThe copycommands command may only be used from the Code Port.\n\r", ch );
	return;
   }

   strcpy( buf, CODESYSTEMDIR );
   strcat( buf, COMMANDFILE );
   valid = copy_file( ch, buf );
   
   if ( valid != 0 )
   {
	bug( "do_copycommands: Error opening file for copy - %s!", buf );
	return;
   }

   set_char_color( AT_GREEN, ch );

   /* Code port to Builders' port */
   send_to_char( "&Gcommands.dat file updated to builder port.\n\r", ch );
   strcpy( buf, "cp -f " );
   strcat( buf, CODESYSTEMDIR );
   strcat( buf, COMMANDFILE );
   strcat( buf, " " );
   strcat( buf, BUILDSYSTEMDIR );
   strcat( buf, COMMANDFILE );
   do_mudexec( ch, buf );
 
   if ( !sysdata.TESTINGMODE )
   {
	send_to_char( "&Rcommands.dat file updated to main port.\n\r", ch );
   	/* Code port to Main port */
   	strcpy( buf, "cp -f " );
   	strcat( buf, CODESYSTEMDIR );
   	strcat( buf, COMMANDFILE );
   	strcat( buf, " " );
   	strcat( buf, MAINSYSTEMDIR );
      strcat( buf, COMMANDFILE );
   	do_mudexec( ch, buf );
   }
   return;
}