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

45
packages/ipp/keyword.go Normal file
View File

@@ -0,0 +1,45 @@
package ipp
import "io"
type keyWord struct {
name string
values []string
}
func newKeyWord() *keyWord {
k := new(keyWord)
return k
}
func (k *keyWord) string() string {
return "a uriValue"
}
func (k *keyWord) valueTag() tag {
return keyWordValueTag
}
func (k *keyWord) unmarshal(byteStream io.Reader) {
}
func (k *keyWord) marshal() []byte {
return []byte{}
}
func (k *keyWord) addValue(v string) {
k.values = append(k.values, v)
}
func (k *keyWord) size() int {
l := 1 + 2 // The value tag (0x44) + name-length field (2 bytes)
l += len(k.name)
l += 2 // value-length field (2 bytes)
l += len(k.values[0])
// Add all additional values
for _, v := range k.values[1:] {
l += 1 + 4 // The value tag (0x44) + 2 length fields (2 bytes)
l += len(v)
}
return l
}