Skip to content

Add CUPS printing system bindings to c.s.j.p.unix#1718

Open
dbwiddis wants to merge 1 commit intojava-native-access:masterfrom
dbwiddis:add-cups-bindings
Open

Add CUPS printing system bindings to c.s.j.p.unix#1718
dbwiddis wants to merge 1 commit intojava-native-access:masterfrom
dbwiddis:add-cups-bindings

Conversation

@dbwiddis
Copy link
Copy Markdown
Contributor

@dbwiddis dbwiddis commented May 9, 2026

Adds Cups interface to c.s.j.p.unix providing JNA bindings for libcups, the Common UNIX Printing System library available on Linux, macOS, and other UNIX platforms.

Structures

Structure C type Description
CupsDest cups_dest_t Printer/class destination with name, instance, and options
CupsOption cups_option_t Name/value option pair
CupsJob cups_job_t Print job with ID, state, title, user, and timestamps

Functions

Function Description
cupsGetDests / cupsGetDests2 Enumerate available printers
cupsFreeDests Free destination list
cupsGetDest Find a printer in a list by name
cupsGetNamedDest Optimized single-printer lookup
cupsGetDefault Get default printer name
cupsGetOption Read an option value
cupsAddOption Add/replace an option
cupsFreeOptions Free options array
cupsGetJobs2 Get print jobs (active/completed/all)
cupsFreeJobs Free job array
cupsCancelJob Cancel a print job
cupsServer / cupsSetServer Get/set CUPS server
cupsUser / cupsSetUser Get/set CUPS user
cupsLastError / cupsLastErrorString Error reporting

Constants

  • Printer state: IPP_PRINTER_IDLE, IPP_PRINTER_PROCESSING, IPP_PRINTER_STOPPED
  • Printer type flags: CUPS_PRINTER_CLASS, CUPS_PRINTER_COLOR, CUPS_PRINTER_DUPLEX, etc.
  • Job state: IPP_JSTATE_PENDING through IPP_JSTATE_COMPLETED
  • Job filters: CUPS_WHICHJOBS_ALL, CUPS_WHICHJOBS_ACTIVE, CUPS_WHICHJOBS_COMPLETED

Closes #1710

Test Output

On my local mac with actual printers:

[junit] Testsuite: com.sun.jna.platform.CupsTest
[junit] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.393 sec
[junit] 
[junit] ------------- Standard Output ---------------
[junit] Default named dest: HP_ENVY_6000_series
[junit] Number of CUPS destinations: 2
[junit] First destination: SecurePrintAMER
[junit]   printer-info: Secure Print AMER
[junit]   printer-state: 3
[junit]   printer-type: 2109692
[junit] CUPS server: /private/var/run/cupsd
[junit] Number of CUPS jobs: 50
[junit] First job: id=4 dest=HP_ENVY_6000_series title=Microsoft Word - Guidelines.docx state=9
[junit] CUPS user: dbwiddis
[junit] Default printer: HP_ENVY_6000_series
[junit] ------------- ---------------- ---------------

@dbwiddis dbwiddis force-pushed the add-cups-bindings branch 3 times, most recently from 798d6b9 to 9730d3f Compare May 9, 2026 21:47
Closes java-native-access#1710

Add Cups interface providing JNA bindings for libcups, the Common UNIX
Printing System library. Includes structures (CupsDest, CupsOption,
CupsJob), printer state/type constants, job state constants, and
functions for destination enumeration, job management, option handling,
and server/user configuration.
@dbwiddis dbwiddis force-pushed the add-cups-bindings branch from 9730d3f to 2e49a2e Compare May 9, 2026 21:47
@dbwiddis dbwiddis requested a review from matthiasblaesing May 9, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New feature suggestions,

1 participant