Exemplo n.º 1
0
        /*
         * ===============
         * Cmd_Alias_f
         *
         * Creates a new command that executes a command string (possibly ; seperated)
         * ===============
         */

        static void Cmd_Alias_f()
        {
            cmdalias_t a;
            string     cmd;
            int        i, c;
            string     s;

            if (Cmd_Argc() == 1)
            {
                console.Con_Printf("Current alias commands:\n");
                for (a = cmd_alias; a != null; a = a.next)
                {
                    console.Con_Printf(a.name + " : " + a.value + "\n");
                }
                return;
            }

            s = Cmd_Argv(1);
            if (s.Length >= MAX_ALIAS_NAME)
            {
                console.Con_Printf("Alias name is too long\n");
                return;
            }

            // if the alias allready exists, reuse it
            for (a = cmd_alias; a != null; a = a.next)
            {
                if (s.CompareTo(a.name) == 0)
                {
                    a.value = null;
                    break;
                }
            }

            if (a == null)
            {
                a         = new cmdalias_t();
                a.next    = cmd_alias;
                cmd_alias = a;
            }
            a.name = s;

            // copy the rest of the command line
            cmd = "";                   // start out with a null string
            c   = Cmd_Argc();
            for (i = 2; i < c; i++)
            {
                cmd += Cmd_Argv(i);
                if (i != c)
                {
                    cmd += " ";
                }
            }
            cmd += "\n";

            a.value = cmd;
        }
Exemplo n.º 2
0
        /*
        ===============
        Cmd_Alias_f

        Creates a new command that executes a command string (possibly ; seperated)
        ===============
        */
        static void Cmd_Alias_f()
        {
            cmdalias_t	a;
            string		cmd;
            int			i, c;
            string		s;

            if (Cmd_Argc() == 1)
            {
                console.Con_Printf ("Current alias commands:\n");
                for (a = cmd_alias ; a != null ; a=a.next)
                    console.Con_Printf(a.name + " : " + a.value + "\n");
                return;
            }

            s = Cmd_Argv(1);
            if (s.Length >= MAX_ALIAS_NAME)
            {
                console.Con_Printf("Alias name is too long\n");
                return;
            }

            // if the alias allready exists, reuse it
            for (a = cmd_alias ; a != null ; a=a.next)
            {
                if (s.CompareTo(a.name) == 0)
                {
                    a.value = null;
                    break;
                }
            }

            if (a == null)
            {
                a = new cmdalias_t();
                a.next = cmd_alias;
                cmd_alias = a;
            }
            a.name = s;

            // copy the rest of the command line
            cmd = "";		// start out with a null string
            c = Cmd_Argc();
            for (i=2 ; i< c ; i++)
            {
                cmd += Cmd_Argv(i);
                if (i != c)
                    cmd += " ";
            }
            cmd += "\n";

            a.value = cmd;
        }