Created
October 11, 2015 00:53
-
-
Save georgeawg/2aacd1618986a890ac20 to your computer and use it in GitHub Desktop.
lpstat implemented in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ipp = require("ipp"); | |
var uri = "http://localhost:631"; | |
var data = ipp.serialize({ | |
"operation": 0x4002, //CUPS-GET-PRINTERS | |
"operation-attributes-tag": { | |
"attributes-charset": "utf-8", | |
"attributes-natural-language": "en", | |
"printer-uri": uri | |
} | |
}); | |
/* Patch in "operation": 0x4002" //CUPS-GET-PRINTERS | |
*/ | |
data[2] = 0x40; | |
data[3] = 0x02; | |
ipp.request(uri, data, function(err, res){ | |
if(err){ | |
return console.log(err); | |
} | |
//console.log(res); | |
var printers = res["printer-attributes-tag"]; | |
if (! Array.isArray(printers)) | |
printers = [printers]; | |
for (i in printers) { | |
printer = printers[i]; | |
console.log("printer %s %s '%s'" | |
, printer["printer-name"] | |
, printer["printer-more-info"] | |
, printer["printer-make-and-model"] | |
); | |
}; | |
}) | |
// | |
//The spec is not clear on how to handle tag 19. Please open a github issue to help find a solution! | |
//The spec is not clear on how to handle tag 19. Please open a github issue to help find a solution! | |
//printer fred http://localhost:631/printers/fred 'Canon PIXMA MX860 - CUPS+Gutenprint v5.2.8-pre1' | |
//printer PDF http://localhost:631/printers/PDF 'Generic CUPS-PDF Printer' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Opened issue williamkapke/ipp#22