Files
lcdproc/shared/str.c
T

36 lines
580 B
C
Raw Normal View History

1999-12-09 23:15:14 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "debug.h"
#include "str.h"
int
get_args (char **argv, char *str, int max_args)
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
char *delimiters = " \n\0";
char *item;
int i = 0;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
if (!argv)
return -1;
if (!str)
return 0;
if (max_args < 1)
return 0;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
//debug("get_args(%i): string=%s\n", max_args, str);
2000-04-03 22:13:57 +00:00
// Parse the command line...
for (item = strtok (str, delimiters); item; item = strtok (NULL, delimiters)) {
//debug("get_args: item=%s\n", item);
if (i < max_args) {
argv[i] = item;
i++;
} else
return i;
}
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
return i;
1999-12-09 23:15:14 +00:00
}