Documentation
This commit is contained in:
parent
b7e23f73ed
commit
dca86ec149
10
zparse.rl
10
zparse.rl
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue