On Fri, Sep 19, 1997 at 10:30:06AM -0500, Sammy wrote:
Sammy> With a few more similar argument processing functions, you can
Sammy> eliminate all the argX[MAX_INPUT_LENGTH] variables throughout the ACMD
Sammy> functions.
How about the following??? Little func I use for all argument processing.
It supllies an argc, argv lookalike thing... I prefer it a lot over the
old argument handling funcs.
typedef struct args ARGS;
struct args
{
int argc;
char **argv;
};
/* generate an array with pointers to args in s
* s is destroyed by this (nulls on token separators)
*/
const char str_to_args[] = " \t";
#define MAXTOKEN 32
ARGS *string_to_args( char *s )
{
char *tok;
int ntok = 0;
static char *args[MAXTOKEN+1];
static ARGS arguments;
tok = strtok( s, " \t" );
while( tok != NULL && ntok < MAXTOKEN )
{
if( ntok > 0 )
tok[-1] = '\0';
args[ntok++] = tok;
tok = strtok( NULL, " \t" );
}
args[ntok] = NULL;
arguments.argc = ntok;
arguments.argv = args;
return &arguments;
}
Ric
--
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST