Documentation

This commit is contained in:
Miek Gieben 2011-07-23 08:54:44 +02:00
parent b7e23f73ed
commit dca86ec149
1 changed files with 7 additions and 9 deletions

View File

@ -14,14 +14,14 @@ import (
//const _IOBUF = 65365 // See comments in gdnsd //const _IOBUF = 65365 // See comments in gdnsd
const _IOBUF = 3e7 // TODO fix sliding window stuff in Ragel const _IOBUF = 3e7 // TODO fix sliding window stuff in Ragel
// A Parser represents a DNS master zone file parser for a // A Parser represents a DNS parser for a
// particular input stream. // particular input stream.
type Parser struct { type Parser struct {
// nothing here yet // nothing here yet
buf []byte buf []byte
} }
// NewParser create a new DNS master zone file parser from r. // NewParser creates a new DNS file parser from r.
func NewParser(r io.Reader) *Parser { func NewParser(r io.Reader) *Parser {
buf := make([]byte, _IOBUF) buf := make([]byte, _IOBUF)
n, err := r.Read(buf) n, err := r.Read(buf)
@ -70,7 +70,7 @@ func atoi(s string) uint {
write data; write data;
}%% }%%
// Token parses a zone file, but only returns the last RR read. // RR parses a zone file, but only returns the last RR read.
func (zp *Parser) RR() RR { func (zp *Parser) RR() RR {
z, err := zp.Zone() z, err := zp.Zone()
if err != nil { if err != nil {
@ -79,9 +79,7 @@ func (zp *Parser) RR() RR {
return z.Pop().(RR) return z.Pop().(RR)
} }
// All the NewReader stuff is expensive... // Zone parses an DNS master zone file.
// only works for short io.Readers as we put the whole thing
// in a string -- needs to be extended for large files (sliding window).
func (zp *Parser) Zone() (z *Zone, err os.Error) { func (zp *Parser) Zone() (z *Zone, err os.Error) {
z = new(Zone) z = new(Zone)
data := string(zp.buf) data := string(zp.buf)
@ -161,8 +159,8 @@ func (zp *Parser) Zone() (z *Zone, err os.Error) {
if cs < z_first_final { if cs < z_first_final {
// No clue what I'm doing what so ever // No clue what I'm doing what so ever
if p == pe { if p == pe {
println("p", p, "pe", pe) println("p", p, "pe", pe)
println("cs", cs, "z_first_final", z_first_final) println("cs", cs, "z_first_final", z_first_final)
println("unexpected eof at line ", lines) println("unexpected eof at line ", lines)
return z, nil return z, nil
} else { } else {