/****************************************************************************
* [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | \\._.// *
* -----------------------------------------------------------| (0...0) *
* SMAUG 1.4 (C) 1994, 1995, 1996, 1998 by Derek Snider | ).:.( *
* -----------------------------------------------------------| {o o} *
* SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, | / ' ' \ *
* Scryn, Rennard, Swordbearer, Gorog, Grishnakh, Nivek, |~'~.VxvxV.~'~*
* Tricops and Fireblade | *
* ------------------------------------------------------------------------ *
* Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* ------------------------------------------------------------------------ *
* Command interpretation module *
****************************************************************************/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "mud.h"
/*
* Pick off one argument from a string and return the rest.
* Understands quotes. No longer mangles case either. That used to be annoying.
*/
const char *one_argument( const char *argument, char *arg_first )
{
char cEnd;
int count;
count = 0;
while( isspace( *argument ) )
argument++;
cEnd = ' ';
if( *argument == '\'' || *argument == '"' )
cEnd = *argument++;
while( *argument != '\0' || ++count >= 255 )
{
if( *argument == cEnd )
{
argument++;
break;
}
*arg_first = ( *argument );
arg_first++;
argument++;
}
*arg_first = '\0';
while( isspace( *argument ) )
argument++;
return argument;
}
/*
* Pick off one argument from a string and return the rest.
* Understands quotes. Delimiters = { ' ', '-' }
* No longer mangles case either. That used to be annoying.
*/
const char *one_argument2( const char *argument, char *arg_first )
{
char cEnd;
short count;
count = 0;
if( !argument || argument[0] == '\0' )
{
arg_first[0] = '\0';
return argument;
}
while( isspace( *argument ) )
argument++;
cEnd = ' ';
if( *argument == '\'' || *argument == '"' )
cEnd = *argument++;
while( *argument != '\0' || ++count >= 255 )
{
if( *argument == cEnd || *argument == '-' )
{
argument++;
break;
}
*arg_first = ( *argument );
arg_first++;
argument++;
}
*arg_first = '\0';
while( isspace( *argument ) )
argument++;
return argument;
}