Last change
on this file was
c5c522c,
checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago
|
initial commit, transferred from cleaned syn3 svn tree
|
-
Property mode set to
100644
|
File size:
612 bytes
|
Rev | Line | |
---|
[c5c522c] | 1 | #include <stdlib.h> |
---|
| 2 | #include <stdio.h> |
---|
| 3 | #include <string.h> |
---|
| 4 | |
---|
| 5 | #include "debug.h" |
---|
| 6 | #include "str.h" |
---|
| 7 | |
---|
| 8 | int get_args(char **argv, char *str, int max_args) |
---|
| 9 | { |
---|
| 10 | char *delimiters = " \n\0"; |
---|
| 11 | char *item; |
---|
| 12 | int i=0; |
---|
| 13 | |
---|
| 14 | if(!argv) return -1; |
---|
| 15 | if(!str) return 0; |
---|
| 16 | if(max_args < 1) return 0; |
---|
| 17 | |
---|
| 18 | //debug("get_args(%i): string=%s\n", max_args, str); |
---|
| 19 | |
---|
| 20 | // Parse the command line... |
---|
| 21 | for(item = strtok(str, delimiters); item; item=strtok(NULL, delimiters)) |
---|
| 22 | { |
---|
| 23 | //debug("get_args: item=%s\n", item); |
---|
| 24 | if(i < max_args) |
---|
| 25 | { |
---|
| 26 | argv[i] = item; |
---|
| 27 | i++; |
---|
| 28 | } |
---|
| 29 | else return i; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | return i; |
---|
| 33 | } |
---|
| 34 | |
---|
Note: See
TracBrowser
for help on using the repository browser.