socketmud/
socketmud/doc/
socketmud/help/
socketmud/players/
socketmud/scripts/
socketmud/scripts/brain_data/
socketmud/scripts/brain_data/base_brains/
socketmud/scripts/cmd_data/
socketmud/scripts/cmd_data/commands/
socketmud/scripts/home/
socketmud/scripts/home/LordLua/
/*
 * This file handles command interpreting
 */
#include <sys/types.h>
#include <stdio.h>

/* include main header file */
#include "mud.h"
#include "scripting.h"

void handle_cmd_input(D_SOCKET *dsock, char *arg)
{
  D_MOBILE *dMob;
  char command[MAX_BUFFER];
  bool found_cmd = FALSE;
  int i;

  if ((dMob = dsock->player) == NULL)
    return;

  if (dMob->editing != NULL)
  {
	  handle_file_editing(dMob, arg);
	  return;
  }
  arg = one_arg(arg, command);
  if (dMob->shell == TRUE)
  {
  for (i = 0; tabCmd[i].cmd_name[0] != '\0' && !found_cmd; i++)
  {
    if (tabCmd[i].level > dMob->level) continue;

    if (is_prefix(command, tabCmd[i].cmd_name))
    {
    	found_cmd = TRUE;
      	(*tabCmd[i].cmd_funct)(dMob, arg);
    	}
  	}
  }
  else
  {
	  input_to_lua(dMob, command, arg);
	  return;
  }
  if (!found_cmd)
    text_to_mobile(dMob, "No such command.\n\r");
}

/*
 * The command table, very simple, but easy to extend.
 */
const struct typCmd tabCmd [] =
{

 /* command          function        Req. Level   */
 /* --------------------------------------------- */

  { "commands",      cmd_commands,   LEVEL_GUEST  },
#ifndef NOMCCP
  { "compress",      cmd_compress,   LEVEL_GUEST  },
#endif
  { "copyover",      cmd_copyover,   LEVEL_GOD    },
  { "help",          cmd_help,       LEVEL_GUEST  },
  { "linkdead",      cmd_linkdead,   LEVEL_ADMIN  },
  { "say",           cmd_say,        LEVEL_GUEST  },
  { "save",          cmd_save,       LEVEL_GUEST  },
  { "shutdown",      cmd_shutdown,   LEVEL_GOD    },
  { "quit",          cmd_quit,       LEVEL_GUEST  },
  { "who",           cmd_who,        LEVEL_GUEST  },
  { "ls",			 cmd_ls,		 LEVEL_GOD	  },
  { "touch",		 cmd_touch,		 LEVEL_GOD	  },
  { "cd",			 cmd_cd,		LEVEL_GOD	 },
  { "view",			 cmd_view,		LEVEL_GOD	 },
  { "rm",			cmd_rm,			LEVEL_GOD	 },
  { "edit",			cmd_edit,		LEVEL_GOD	 },
  { "exit",		cmd_return,		LEVEL_GUEST	 },
  { "mkdir",		cmd_mkdir, 		LEVEL_GOD	 },
  { "rmdir",		cmd_rmdir, 		LEVEL_GOD	 },
  { "reload",		cmd_reload,		LEVEL_GOD	 },
  { "promote",		cmd_promote,	LEVEL_ADMIN	 },
  { "demote",		cmd_demote, 	LEVEL_ADMIN	 },
  { "chmod",		cmd_chmod,		LEVEL_GOD	},
  { "chown",		cmd_chown,		LEVEL_ADMIN },
  { "mkcore",		cmd_mkcore,		LEVEL_ADMIN },
    
  /* end of table */
  { "", 0 }
};