Simple roundtrip from ipptool works.

This commit is contained in:
2020-11-01 20:05:53 +01:00
parent 83f35d045c
commit cadcedf43c
16 changed files with 744 additions and 152 deletions

42
packages/ipp/urivalue.go Normal file
View File

@@ -0,0 +1,42 @@
package ipp
import (
"io"
)
type uriValue struct {
name string
value string
}
func newUriValue(name, value string) *uriValue {
u := new(uriValue)
u.name = name
u.value = value
return u
}
func (u uriValue) String() string {
return u.name + ":" + u.value
}
func (u *uriValue) valueTag() tag {
return uriValueTag
}
func (u *uriValue) unmarshal(byteStream io.Reader) {
u.name, u.value = unmarshalSingleValue(byteStream)
}
func (u *uriValue) marshal() []byte {
res := make([]byte, u.size())
res[0] = byte(uriValueTag)
marshalNameValue(u.name, u.value, res[1:])
return res
}
func (u *uriValue) size() int {
l := 1 + 4 // The attribute tag + 2 lengths
l += len(u.name)
l += len(u.value)
return l
}