Class CupsFunctions
java.lang.Object
oshi.ffm.ForeignFunctions
oshi.ffm.unix.CupsFunctions
FFM bindings for the CUPS (Common Unix Printing System) library.
CUPS is available as libcups on Linux and macOS (via the dyld shared cache as libcups.dylib).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final VarHandleVarHandle for theis_defaultfield ofcups_dest_t.static final VarHandleVarHandle for thenamefield ofcups_dest_t.static final VarHandleVarHandle for thenum_optionsfield ofcups_dest_t.static final VarHandleVarHandle for theoptionsfield ofcups_dest_t.static final StructLayoutLayout ofcups_dest_t:static final intPrinter type bit flag indicating a remote (network) printer.static final intIPP printer state: idle.static final intIPP printer state: processing (printing).static final intIPP printer state: stopped.Fields inherited from class ForeignFunctions
CAPTURE_CALL_STATE, CAPTURED_STATE_LAYOUT, ERRNO_HANDLE, LIBRARY_ARENA, LINKER, SYMBOL_LOOKUP -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcupsFreeDests(int numDests, MemorySegment dests) Frees the memory allocated bycupsGetDests.static MemorySegmentGets the default printer name.static intcupsGetDests(MemorySegment dests) Gets all available CUPS destinations (printers and classes).static MemorySegmentcupsGetOption(MemorySegment name, int numOptions, MemorySegment options) Gets the value of a named option from a destination's options array.static StringgetOption(String optionName, int numOptions, MemorySegment options, Arena arena) Convenience method to read a named option value from a destination's options segment.static booleanReturns whether the CUPS library was successfully loaded and all symbols bound.Methods inherited from class ForeignFunctions
downcall, getByteArrayFromNativePointer, getErrno, getStringFromNativePointer, getStructFromNativePointer, lib, libraryLookup
-
Field Details
-
IPP_PRINTER_IDLE
public static final int IPP_PRINTER_IDLEIPP printer state: idle.- See Also:
-
IPP_PRINTER_PROCESSING
public static final int IPP_PRINTER_PROCESSINGIPP printer state: processing (printing).- See Also:
-
IPP_PRINTER_STOPPED
public static final int IPP_PRINTER_STOPPEDIPP printer state: stopped.- See Also:
-
CUPS_PRINTER_REMOTE
public static final int CUPS_PRINTER_REMOTEPrinter type bit flag indicating a remote (network) printer.- See Also:
-
CUPS_DEST_T
Layout ofcups_dest_t:typedef struct { char *name; // Printer or class name char *instance; // Local instance name or NULL int is_default; // Is this printer the default? int num_options; // Number of options cups_option_t *options; // Options } cups_dest_t; -
CUPS_DEST_NAME
VarHandle for thenamefield ofcups_dest_t. -
CUPS_DEST_IS_DEFAULT
VarHandle for theis_defaultfield ofcups_dest_t. -
CUPS_DEST_NUM_OPTIONS
VarHandle for thenum_optionsfield ofcups_dest_t. -
CUPS_DEST_OPTIONS
VarHandle for theoptionsfield ofcups_dest_t.
-
-
Method Details
-
isAvailable
public static boolean isAvailable()Returns whether the CUPS library was successfully loaded and all symbols bound.- Returns:
trueif libcups is available
-
cupsGetDests
Gets all available CUPS destinations (printers and classes).- Parameters:
dests- a pointer-to-pointer that will be set to the allocated destination array- Returns:
- the number of destinations, or 0 on failure
- Throws:
Throwable- if the native call fails
-
cupsFreeDests
Frees the memory allocated bycupsGetDests.- Parameters:
numDests- the number of destinations returned bycupsGetDestsdests- the destination array pointer- Throws:
Throwable- if the native call fails
-
cupsGetOption
public static MemorySegment cupsGetOption(MemorySegment name, int numOptions, MemorySegment options) throws Throwable Gets the value of a named option from a destination's options array.- Parameters:
name- the option name as a native string segmentnumOptions- the number of optionsoptions- pointer to the options array- Returns:
- a native segment pointing to the option value string, or a NULL segment if not found
- Throws:
Throwable- if the native call fails
-
cupsGetDefault
Gets the default printer name.- Returns:
- a native segment pointing to the default printer name, or a NULL segment if none is set
- Throws:
Throwable- if the native call fails
-
getOption
public static String getOption(String optionName, int numOptions, MemorySegment options, Arena arena) Convenience method to read a named option value from a destination's options segment.- Parameters:
optionName- the option namenumOptions- the number of options in the arrayoptions- the native options pointerarena- the arena to allocate the name string in- Returns:
- the option value, or an empty string if not found
-