2-add-keyword-support (#6)
More development. More types. Fixed attribute groups in requests. Started on client. Saving data to file. More types. Printing from chromeos works a little bit. More types. Spelling corrections. WIP: Fix keyword handling Move request to a separate file and add test. Co-authored-by: Henrik Sölver <henrik.solver@gmail.com> Reviewed-on: #6 Co-Authored-By: henrik <henrik.solver@gmail.com> Co-Committed-By: henrik <henrik.solver@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package ipp
|
||||
|
||||
import "encoding/binary"
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ippResponseHeader struct {
|
||||
versionNumber versionNumber
|
||||
@@ -8,6 +11,10 @@ type ippResponseHeader struct {
|
||||
requestId uint32
|
||||
}
|
||||
|
||||
func (h ippResponseHeader) String() string {
|
||||
return fmt.Sprintf("Version number: %v Status code: %v Request Id: %v", h.versionNumber, h.statusCode, h.requestId)
|
||||
}
|
||||
|
||||
func (h *ippResponseHeader) marshal() []byte {
|
||||
a := make([]byte, 8, 8)
|
||||
binary.BigEndian.PutUint16(a[0:2], uint16(h.versionNumber))
|
||||
@@ -18,10 +25,10 @@ func (h *ippResponseHeader) marshal() []byte {
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
header ippResponseHeader
|
||||
operationAttributes []Attribute
|
||||
jobAttributes []Attribute
|
||||
printerAttributes []Attribute
|
||||
header ippResponseHeader
|
||||
}
|
||||
|
||||
func NewResponse(code statusCode, requestId uint32) *Response {
|
||||
@@ -52,6 +59,23 @@ func NewResponse(code statusCode, requestId uint32) *Response {
|
||||
|
||||
// }
|
||||
|
||||
func (r Response) String() string {
|
||||
|
||||
s := r.header.String() + "\n" + " OperationAttributes" + "\n"
|
||||
for _, a := range r.operationAttributes {
|
||||
s = s + fmt.Sprintf(" %v (%v)\n", a, a.valueTag())
|
||||
}
|
||||
s = s + " PrinterAttributes" + "\n"
|
||||
for _, a := range r.printerAttributes {
|
||||
s = s + fmt.Sprintf(" %v (%v)\n", a, a.valueTag())
|
||||
}
|
||||
s = s + " JobAttributes" + "\n"
|
||||
for _, a := range r.jobAttributes {
|
||||
s = s + fmt.Sprintf(" %v (%v)\n", a, a.valueTag())
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func (r *Response) Marshal() []byte {
|
||||
a := make([]byte, 0, 20)
|
||||
a = append(a, r.header.marshal()...)
|
||||
|
||||
Reference in New Issue
Block a user