CLeanups
This commit is contained in:
@@ -38,8 +38,8 @@ func main() {
|
|||||||
rb.UnMarshal(httpResponse.Body)
|
rb.UnMarshal(httpResponse.Body)
|
||||||
fmt.Print(rb)
|
fmt.Print(rb)
|
||||||
|
|
||||||
fmt.Print("\n-------------\n")
|
// fmt.Print("\n-------------\n")
|
||||||
printFile("4-untitled")
|
// printFile("4-untitled")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,6 @@ func Run(ctx context.Context) {
|
|||||||
log.Fatalf("EntryGroupNew() failed: %v", err)
|
log.Fatalf("EntryGroupNew() failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//hostname, err := a.GetHostName()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("GetHostName() failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fqdn, err := a.GetHostNameFqdn()
|
fqdn, err := a.GetHostNameFqdn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("GetHostNameFqdn() failed: %v", err)
|
log.Fatalf("GetHostNameFqdn() failed: %v", err)
|
||||||
@@ -36,11 +31,11 @@ func Run(ctx context.Context) {
|
|||||||
var txt [][]byte
|
var txt [][]byte
|
||||||
|
|
||||||
txt = append(txt, []byte("note=burken"))
|
txt = append(txt, []byte("note=burken"))
|
||||||
txt = append(txt, []byte("product=coola-skrivaren"))
|
txt = append(txt, []byte("product=ChroBroPrint V1"))
|
||||||
txt = append(txt, []byte("Color=T"))
|
txt = append(txt, []byte("Color=T"))
|
||||||
txt = append(txt, []byte("rp=ipp/print"))
|
txt = append(txt, []byte("rp=ipp/print"))
|
||||||
txt = append(txt, []byte("ty=ChroBro 001"))
|
txt = append(txt, []byte("ty=ChroBroPrint"))
|
||||||
err = eg.AddService(avahi.InterfaceUnspec, avahi.ProtoUnspec, 0, "ChroBro 1000", "_ipp._tcp", "local", fqdn, 1234, txt)
|
err = eg.AddService(avahi.InterfaceUnspec, avahi.ProtoUnspec, 0, "ChroBroPrint", "_ipp._tcp", "local", fqdn, 1234, txt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("AddService() failed: %v", err)
|
log.Fatalf("AddService() failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ func handlePrintJob(r *ipp.Request, byteStream io.Reader, requestID uint32) *ipp
|
|||||||
j := l[len(l)-1]
|
j := l[len(l)-1]
|
||||||
|
|
||||||
joburi := r.GetAttribute("printer-uri").(*ipp.URIValue).Value() + "/" + j
|
joburi := r.GetAttribute("printer-uri").(*ipp.URIValue).Value() + "/" + j
|
||||||
log.Infof(">>>>>>>>>>>>>>>>>>>>>>joburi: %v", joburi)
|
|
||||||
response.AddJobAttribute(ipp.NewURIValue("job-uri", joburi))
|
response.AddJobAttribute(ipp.NewURIValue("job-uri", joburi))
|
||||||
}
|
}
|
||||||
response.AddJobAttribute(rb.GetAttribute("job-id"))
|
response.AddJobAttribute(rb.GetAttribute("job-id"))
|
||||||
|
|||||||
@@ -41,17 +41,8 @@ func handle(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Unsupported method", http.StatusMethodNotAllowed)
|
http.Error(w, "Unsupported method", http.StatusMethodNotAllowed)
|
||||||
|
|
||||||
}
|
}
|
||||||
//log.Info(r.Header)
|
|
||||||
//body := make([]byte, r.ContentLength)
|
|
||||||
//io.ReadFull(r.Body, body)
|
|
||||||
//log.Infof("Body %x", body)
|
|
||||||
|
|
||||||
request := ipp.NewRequest(0, 0)
|
request := ipp.NewRequest(0, 0)
|
||||||
//rdata := make([]byte, r.ContentLength)
|
|
||||||
//io.ReadFull(r.Body, rdata)
|
|
||||||
//log.Printf("Data %x", rdata)
|
|
||||||
//fmt.Printf("data % #0x", rdata)
|
|
||||||
//buf := bytes.NewBuffer(rdata)
|
|
||||||
request.UnMarshal(r.Body)
|
request.UnMarshal(r.Body)
|
||||||
log.Infof("Upstream Request: \n%v\n", request)
|
log.Infof("Upstream Request: \n%v\n", request)
|
||||||
var response *ipp.Response
|
var response *ipp.Response
|
||||||
@@ -72,8 +63,5 @@ func handle(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
log.Infof("Upstream Response:\n%v\n", response)
|
log.Infof("Upstream Response:\n%v\n", response)
|
||||||
data := response.Marshal()
|
data := response.Marshal()
|
||||||
|
|
||||||
//log.Debugf("% x", data)
|
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user