initial commit

This commit is contained in:
tumillanino
2025-11-12 23:59:00 +11:00
commit 991cca06bf
274 changed files with 70484 additions and 0 deletions

28
pkg/ipp/utils.go Normal file
View File

@@ -0,0 +1,28 @@
package ipp
import (
"fmt"
"os"
"path"
)
// ParseControlFile reads and decodes a cups control file into a response
func ParseControlFile(jobID int, spoolDirectory string) (*Response, error) {
if spoolDirectory == "" {
spoolDirectory = "/var/spool/cups"
}
controlFilePath := path.Join(spoolDirectory, fmt.Sprintf("c%d", jobID))
if _, err := os.Stat(controlFilePath); err != nil {
return nil, err
}
controlFile, err := os.Open(controlFilePath)
if err != nil {
return nil, err
}
defer controlFile.Close()
return NewResponseDecoder(controlFile).Decode(nil)
}