A simple C client that authenticates to a printer server using CUPS. It makes use of the following library: authenticate-printer-library.
- A C compiler
- Make
- CUPS
In some distributions the CUPS header files are in a package ~libcups2-dev
First we clone the git submodule for the authenticate-printer-library from the root of this project:
git submodule init
git submodule update
We then compile the authenticate-printer-library:
cd authenticate-printer-library
make
cd ..
We then compile the client:
make
To run the client, it is necessary to ensure that the system can find
the shared library. For example, add to environment variable
LD_LIBRARY_PATH the path to the shared library and store it in a shell
initialization script, for example .bashrc
:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/authenticate-printer/authenticate-printer-library
We can then run the program with:
./authenticate-printer
Typical usage is the following: First check whether the file is in A4 format:
pdfinfo file.pdf
If it is, we can check whether the printer is available with:
lpq
We then send the file to the printer:
lpr file.pdf
We then check whether the file is done processing. This is the case when the file jumps from rank “active” to rank “1st”:
lpq +5
With output something similar to:
myprinter is ready and printing Rank Owner Job File(s) Total Size active pieter 331 file.pdf 151552 bytes myprinter is ready Rank Owner Job File(s) Total Size 1st pieter 331 file.pdf 151552 bytes
At this point, we can authenticate the printer for multiple jobs with:
./authenticate-printer
We can then verify that the rank changes to “active” again with:
lpq +5
The program will exit when all documents have been processed.