Source File
nss.go
Belonging Package
net
package net
import (
)
return false
}
if && .action == "return" {
return true
}
return .action ==
}
func ( string) *nssConf {
, := os.Open()
if != nil {
return &nssConf{err: }
}
defer .Close()
return parseNSSConf()
}
func ( io.Reader) *nssConf {
, := readFull()
if != nil {
return &nssConf{err: }
}
:= new(nssConf)
.err = foreachLine(, func( []byte) error {
= trimSpace(removeComment())
if len() == 0 {
return nil
}
:= bytealg.IndexByte(, ':')
if == -1 {
return errors.New("no colon on line")
}
:= string(trimSpace([:]))
:= [+1:]
for {
= trimSpace()
if len() == 0 {
break
}
:= bytealg.IndexByte(, ' ')
var string
if == -1 {
= string()
= nil // done
} else {
= string([:])
= trimSpace([+1:])
}
if len() > 0 && [0] == '[' {
:= bytealg.IndexByte(, ']')
if == -1 {
return errors.New("unclosed criterion bracket")
}
var error
, = parseCriteria([1:])
if != nil {
return errors.New("invalid criteria: " + string([1:]))
}
= [+1:]
}
if .sources == nil {
.sources = make(map[string][]nssSource)
}
.sources[] = append(.sources[], nssSource{
source: ,
criteria: ,
})
}
return nil
})
return
}
func ( []byte) ( []nssCriterion, error) {
= foreachField(, func( []byte) error {
:= false
if len() > 0 && [0] == '!' {
= true
= [1:]
}
if len() < 3 {
return errors.New("criterion too short")
}
:= bytealg.IndexByte(, '=')
if == -1 {
return errors.New("criterion lacks equal sign")
}
lowerASCIIBytes()
= append(, nssCriterion{
negate: ,
status: string([:]),
action: string([+1:]),
})
return nil
})
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |