Skip to content

Commit 2312b20

Browse files
committed
it's alive
1 parent 144c2c3 commit 2312b20

16 files changed

+7963
-4
lines changed

README.md

+76-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,77 @@
1-
ipp
2-
===
1+
# Internet Printing Protocol (IPP) for nodejs
2+
---
33

4-
Internet Printing Protocol (IPP) for nodejs
4+
This is a very indepth protocol that spans many RFCs- some of which are dead while others were herded into IPP/v2.x. It
5+
will take a while to build this lib and definately needs community help.
6+
7+
I have a pretty good starting point here. I created reference files
8+
(<del>`attributes`</del>, `enums`, `keywords`, `operations`, `status-codes`, `versions` and `tags`) and tried to include as many
9+
links in the comments to the ref docs as I could.
10+
11+
IPP uses a confusing/complicated/custom binary serialization IMHO that dates back to the lates '90s. After 15 years of
12+
building this protocol- I the technologies available today could simplified things 10X (again IMO). But it is what is
13+
deployed on millions of printers now- so we'll work with it.
14+
15+
### Install
16+
```bash
17+
$ npm install ipp
18+
```
19+
20+
21+
## ipp.parse(buffer)
22+
23+
My first goal was to create a parser...
24+
25+
```javascript
26+
var ipp = require('ipp');
27+
var data = new Buffer(
28+
'0200' + //version 2.0
29+
'000B' + //Get-Printer-Attributes
30+
'00000001'+ //reqid
31+
'01' + //operation-attributes-tag
32+
//blah blah the required bloat of this protocol
33+
'470012617474726962757465732d6368617273657400057574662d3848001b617474726962757465732d6e61747572616c2d6c616e67756167650002656e' +
34+
'03' //end-of-attributes-tag
35+
,'hex');
36+
37+
38+
var result = ipp.parse(data);
39+
console.log(JSON.stringify(result,null,2));
40+
// ta-da!
41+
//{
42+
// "version": "2.0",
43+
// "operation": 11,
44+
// "id": 1,
45+
// "operation-attributes-tag": {
46+
// "attributes-charset": "utf-8",
47+
// "attributes-natural-language": "en"
48+
// }
49+
//}
50+
```
51+
52+
## ipp.request(url, data, callback)
53+
54+
This is a work-in-progress but it is working enough for ya'll to reference.
55+
56+
```javascript
57+
var ipp = require('ipp');
58+
var id = 0x0123;//made up reqid
59+
var op = ipp.operations['Get-Printer-Attributes'];
60+
61+
//This is a experimental module.
62+
//Expect it to be changed.
63+
//Don't expect it to do what you want.
64+
var data = require('./lib/message')("your-printer", op, id);
65+
66+
ipp.request("ipp://your-printer/", data, function(err, res){
67+
if(err){
68+
return console.log(err);
69+
}
70+
console.log(JSON.stringify(res,null,2));
71+
})
72+
// ta-da!.. hopefully you'll see a ton of stuff from your printer
73+
```
74+
75+
## License
76+
77+
MIT

ipp.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
var util = require('./lib/ipputil');
3+
4+
module.exports = {
5+
parse: require('./lib/parser'),
6+
request: require('./lib/request'),
7+
versions: require('./lib/versions'),
8+
//attributes: q(require('./lib/attributes')),
9+
keywords: require('./lib/keywords'),
10+
enums: require('./lib/enums'),
11+
tags: require('./lib/tags'),
12+
operations: require('./lib/operations'),
13+
statusCodes: require('./lib/status-codes')
14+
};
15+
module.exports.attribute = {
16+
//http://www.iana.org/assignments/ipp-registrations/ipp-registrations.xml#ipp-registrations-7
17+
groups: util.xref(module.exports.tags.lookup.slice(0x00, 0x0F)),
18+
//http://www.iana.org/assignments/ipp-registrations/ipp-registrations.xml#ipp-registrations-8
19+
values: util.xref(module.exports.tags.lookup.slice(0x10, 0x1F)),
20+
//http://www.iana.org/assignments/ipp-registrations/ipp-registrations.xml#ipp-registrations-9
21+
syntaxes: util.xref(module.exports.tags.lookup.slice(0x20))
22+
}

0 commit comments

Comments
 (0)