CAPS Universe documentation  1.0.4
All you need to know to be successful
Functions | Variables
capsprinter.c File Reference

A command line tool to retrieve status information about printing devices. More...

Functions

static void output_printers_status (const struct caps_cl_printer_state *pr_state)
 
static int print_printer_provider_info (struct caps_cl_handle *instance, caps_identifier printer_id)
 
static int output_list_of_printers (struct caps_cl_handle *instance)
 
static int get_first_available_printer (struct caps_cl_handle *instance, caps_identifier *id)
 
static int get_and_output_printers_status (struct caps_cl_handle *instance, const char *printer_device)
 
static int output_printers_ppd (struct caps_cl_handle *instance, const char *printer_device, const char *printer_ppd)
 
static void handle_nls (void)
 
static void verbosity_handling (int verbosity)
 
static void print_help (FILE *out)
 
int main (int argc, char *argv[])
 

Variables

static int verbose
 
static const char * printer_state []
 Messages about a state a printer is in.
 
static const char * printer_reason []
 Messages about a reason why a printer is in a specific state.
 
static struct option long_options []
 

Detailed Description

Author
Jürgen Borleis
Warning
Use as experimental

Function Documentation

◆ output_printers_status()

static void output_printers_status ( const struct caps_cl_printer_state pr_state)
static

Print out the status information about one printer to stdout

Parameters
[in]pr_stateThe printer's status info

◆ print_printer_provider_info()

static int print_printer_provider_info ( struct caps_cl_handle instance,
caps_identifier  printer_id 
)
static

Print the name of a printer or all available information about it

Parameters
[in]instanceThe library instance handle
[in]printer_idThe CAPS printer ID to query
Returns
0 on success, negative value else

If verbosity isn't incremented, only the printer's name is printed.

Todo:
Deal with the -ENODEV return value

◆ output_list_of_printers()

static int output_list_of_printers ( struct caps_cl_handle instance)
static

Print the names of available printers and (on demand) all available information about them

Parameters
[in]instanceThe library instance handle
Returns
EXIT_SUCCESS on success, EXIT_FAILURE else

If verbosity isn't incremented, only the printer names are printed.

◆ get_first_available_printer()

static int get_first_available_printer ( struct caps_cl_handle instance,
caps_identifier id 
)
static

Retrieve ID of first available printer

Parameters
[in]instanceThe library instance handle
[in]idPointer where to store the printer's ID
Returns
0 on success (id is valid), negative value else

◆ get_and_output_printers_status()

static int get_and_output_printers_status ( struct caps_cl_handle instance,
const char *  printer_device 
)
static

Print the status of a printer

Parameters
[in]instanceThe library instance handle
[in]printer_deviceName of printer of interest (can be NULL)
Returns
EXIT_SUCCESS on success, EXIT_FAILURE else

If printer_device is NULL, the first available printer will be retrieved

Todo:
Deal with the -ENODEV return value

◆ output_printers_ppd()

static int output_printers_ppd ( struct caps_cl_handle instance,
const char *  printer_device,
const char *  printer_ppd 
)
static

Store or output a printer's PPD

Parameters
[in]instanceThe library instance handle
[in]printer_deviceName of printer of interest (can be NULL)
[in]printer_ppdFilename of the to be created PPD file
Returns
EXIT_SUCCESS on success, EXIT_FAILURE else

If printer_device is NULL, the first available printer's PPD will be retrieved. If printer_ppd is "-", the PPD content will be output to 'stdout' instead.

Todo:
Deal with the -ENODEV return value

◆ handle_nls()

static void handle_nls ( void  )
static

◆ verbosity_handling()

static void verbosity_handling ( int  verbosity)
static

Increase verbosity of the CAPS components if more than '1' is defined

Parameters
[in]verbosityThe uses choice of verbosity

If '1' is given, it increases the verbosity of capsprinter itself. If more than '1' is given, it increases the CAPS verbosity level as well

◆ print_help()

static void print_help ( FILE *  out)
static

◆ main()

int main ( int  argc,
char *  argv[] 
)

Variable Documentation

◆ verbose

int verbose
static

◆ printer_state

const char* printer_state[]
static
Initial value:
= {
[LIBCAPS_PP_STATE_INVISIBLE] = NLS_("Not visible to the public"),
[LIBCAPS_PP_STATE_PREPARING] = NLS_("Preparing for printing"),
[LIBCAPS_PP_STATE_PROCESSING] = NLS_("Processing"),
[LIBCAPS_PP_STATE_SHUTDOWN] = NLS_("Going offline"),
}
@ LIBCAPS_PP_STATE_PRINTING
Definition: libcapsppcommon.h:146
@ LIBCAPS_PP_STATE_PREPARING
Definition: libcapsppcommon.h:144
@ LIBCAPS_PP_STATE_OFFLINE
Definition: libcapsppcommon.h:149
@ LIBCAPS_PP_STATE_PROCESSING
Definition: libcapsppcommon.h:145
@ LIBCAPS_PP_STATE_INVISIBLE
Definition: libcapsppcommon.h:140
@ LIBCAPS_PP_STATE_STOPPED
Definition: libcapsppcommon.h:142
@ LIBCAPS_PP_STATE_SHUTDOWN
Definition: libcapsppcommon.h:148
@ LIBCAPS_PP_STATE_IDLE
Definition: libcapsppcommon.h:143
@ LIBCAPS_PP_STATE_UNKNOWN
Definition: libcapsppcommon.h:139
#define NLS_(string)
National Language Support related.
Definition: libcapsbase-local.h:61

◆ printer_reason

const char* printer_reason[]
static
Initial value:
= {
[LIBCAPS_PP_REASON_MEDIA_NEEDED] = NLS_("Out of paper"),
[LIBCAPS_PP_REASON_SHUTDOWN] = NLS_("Shutting down"),
}
@ LIBCAPS_PP_REASON_SHUTDOWN
Definition: libcapsppcommon.h:161
@ LIBCAPS_PP_REASON_MEDIA_JAM
Definition: libcapsppcommon.h:160
@ LIBCAPS_PP_REASON_MEDIA_NEEDED
Definition: libcapsppcommon.h:159
@ LIBCAPS_PP_REASON_NONE
Definition: libcapsppcommon.h:157
@ LIBCAPS_PP_REASON_ATTENTION
Definition: libcapsppcommon.h:158
Note
Useful only if the corresponding printer state is LIBCAPS_PP_STATE_STOPPED

◆ long_options

struct option long_options[]
static
Initial value:
= {
{ .name = "device", .has_arg = required_argument, .val = 'd', },
{ .name = "ppd", .has_arg = required_argument, .val = 'p', },
{ .name = "verbose", .has_arg = no_argument, .val = 'v', },
{ .name = "help", .has_arg = no_argument, .val = 'h', },
{ .name = "version", .has_arg = no_argument, .val = 19, },
{ .name = NULL, },
}

This parser uses a free argument: the commands. This isn't currently supported by the capscmdparser. Thus, we stay with getopt_long() for now.