Skip to content

Commit ed205f7

Browse files
committed
Job Status added
1 parent 02aebb9 commit ed205f7

File tree

7 files changed

+306
-53
lines changed

7 files changed

+306
-53
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# cupstool
2-
A quick program I threw together as both a proof of concept and a debugging tool. It is not up to snuff as far as coding practices go, so don't use it in a larger program without grooming.
2+
A simple program to demonstrate and test CUPS status integration in Java via JNA. A simple, node based socket listener is included for testing rss status notifications.
33

44
If you are here to test printer statuses just run the included jar with 'java -jar cupstool.jar', press 4 then select the printer to test.

cupstool.jar

-618 Bytes
Binary file not shown.

rss-listener/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# RSS-Listener
2+
A bare-bones RSS listener hardcoded to port 8000. To run, install npm, navigate to ./rss-listener and type `npm install` followed by `node index.js`

rss-listener/index.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const http = require('http');
2+
3+
const server = http.createServer((req, res) => {
4+
5+
let body = '';
6+
req.setEncoding('utf8');
7+
8+
req.on('data', (chunk) => {
9+
body += chunk;
10+
});
11+
12+
req.on('end', () => {
13+
try {
14+
console.log(body);
15+
res.statusCode = 200;
16+
res.write(`ok`);
17+
res.end();
18+
} catch (er) {
19+
console.log("Malformed");
20+
res.statusCode = 400;
21+
return res.end(`error: ${er.message}`);
22+
}
23+
body = "";
24+
});
25+
});
26+
27+
server.listen(8000);
28+
console.log("Server started.");

rss-listener/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "rss-listener",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "Kyle Berezin",
10+
"license": "",
11+
"dependencies": {}
12+
}

src/com/berezin/Cups.java

+5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ public interface Cups extends Library {
1111
Pointer cupsEncryption();
1212
Pointer httpConnectEncrypt(String host, int port, Pointer encryption);
1313
Pointer cupsDoRequest(Pointer http, Pointer request, String resource);
14+
Pointer ippNew();
1415
Pointer ippNewRequest(int op);
1516
Pointer ippGetString(Pointer attr, int element, Pointer dataLen);
17+
Pointer ippSetOperation(Pointer ipp, int op);
18+
Pointer ippSetRequestId(Pointer ipp, int request_id);
1619
Pointer ippFirstAttribute(Pointer ipp);
1720
Pointer ippNextAttribute(Pointer ipp);
1821
Pointer ippFindAttribute(Pointer ipp, String name, int type);
@@ -34,6 +37,8 @@ public interface Cups extends Library {
3437
int ippGetCount(Pointer attr);
3538
int ippGetValueTag(Pointer ipp);
3639
int ippGetInteger(Pointer attr, int element);
40+
int ippAddStrings(Pointer ipp, int group, int value_tag, String name, int num_values, String language, StringArray values);
41+
3742

3843
void ippDelete(Pointer ipp);
3944
void httpClose(Pointer http);

0 commit comments

Comments
 (0)