Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/libndb/ndbparse.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <bio.h>
4
#include <ctype.h>
5
#include <ndb.h>
6
#include "ndbhf.h"
7
 
8
/*
9
 *  Parse a data base entry.  Entries may span multiple
10
 *  lines.  An entry starts on a left margin.  All subsequent
11
 *  lines must be indented by white space.  An entry consists
12
 *  of tuples of the forms:
13
 *	attribute-name
14
 *	attribute-name=value
15
 *	attribute-name="value with white space"
16
 *
17
 *  The parsing returns a 2-dimensional structure.  The first
18
 *  dimension joins all tuples. All tuples on the same line
19
 *  form a ring along the second dimension.
20
 */
21
 
22
/*
23
 *  parse the next entry in the file
24
 */
25
Ndbtuple*
26
ndbparse(Ndb *db)
27
{
28
	char *line;
29
	Ndbtuple *t;
30
	Ndbtuple *first, *last;
31
	int len;
32
 
33
	first = last = 0;
34
	for(;;){
35
		if((line = Brdline(&db->b, '\n')) == 0)
36
			break;
37
		len = Blinelen(&db->b);
38
		if(line[len-1] != '\n')
39
			break;
40
		if(first && !ISWHITE(*line) && *line != '#'){
41
			Bseek(&db->b, -len, 1);
42
			break;
43
		}
44
		t = _ndbparseline(line);
45
		if(t == 0)
46
			continue;
47
		setmalloctag(t, getcallerpc(&db));
48
		if(first)
49
			last->entry = t;
50
		else
51
			first = t;
52
		last = t;
53
		while(last->entry)
54
			last = last->entry;
55
	}
56
	ndbsetmalloctag(first, getcallerpc(&db));
57
	return first;
58
}