xref: /plan9/sys/src/cmd/9nfs/strparse.c (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1 #include <u.h>
2 #include <libc.h>
3 
4 int	strcomment = '#';
5 
6 int
strparse(char * p,int arsize,char ** arv)7 strparse(char *p, int arsize, char **arv)
8 {
9 	int arc = 0;
10 
11 	/*print("parse: 0x%lux = \"%s\"\n", p, p);/**/
12 	while(p){
13 		while(*p == ' ' || *p == '\t')
14 			p++;
15 		if(*p == 0 || *p == strcomment)
16 			break;
17 		if(arc >= arsize-1)
18 			break;
19 		arv[arc++] = p;
20 		while(*p && *p != ' ' && *p != '\t')
21 			p++;
22 		if(*p == 0)
23 			break;
24 		*p++ = 0;
25 	}
26 	arv[arc] = 0;
27 	/*while(*arv){
28 		print("\t0x%lux = \"%s\"\n", *arv, *arv);
29 		++arv;
30 	}/**/
31 	return arc;
32 }
33