51,40 → 51,7 |
#include "errors.h" |
#include "util.h" |
|
/* Functions that just have no other home */ |
|
/* Tests if string is an --option/-option */ |
unsigned int is_option(char *string) |
{ |
size_t i; |
|
/* We have rubbish */ |
if (NULL == string) |
return 0; |
|
/* - or -- means an option (or end of options) */ |
for (i=0; i < strlen(string); i++) { |
if (string[i] == '-' && i <= 1) |
return 1; |
} |
|
return 0; |
} |
|
/* Returns the option count in an array of arguments */ |
unsigned int count_options(char *argv[]) |
{ |
unsigned int i; |
unsigned int n = 0; |
|
for (i=0; argv[i] != NULL; i++) { |
if (is_option((char *)argv[i])) |
n++; |
} |
|
return n; |
} |
|
/* some platforms do not have strdup, implement it here */ |
char * cli_strdup(const char *s1) |
{ |
143,5 → 110,3 |
|
return (cli_strtok_r(s, delim, &last)); |
} |
|
|