CAPS Universe documentation  1.0.4
All you need to know to be successful
Data Structures | Macros | Functions | Variables
capsprninfo.c File Reference

A command line tool to retrieve some information about his printer device. More...

Data Structures

struct  ieee1284_id
 

Macros

#define IOCTL_IEEE1284_ID_GET(cnt)   _IOC(_IOC_READ, 'P', 1, cnt)
 
#define IOCTL_PRINTER_RESET   _IOC(_IOC_NONE, 'P', 7, 0)
 

Functions

static int _prn_info_ieee_id_print (int fd)
 
static int _prn_info_status_print (int fd)
 
static int _prn_info_printer_reset (int fd)
 
static void handle_nls (void)
 
static void print_help (FILE *out)
 
int main (int argc, char **argv)
 

Variables

static int verbose
 
static const struct option long_options []
 

Detailed Description

Author
Jürgen Borleis
Warning
Use as experimental

Macro Definition Documentation

◆ IOCTL_IEEE1284_ID_GET

#define IOCTL_IEEE1284_ID_GET (   cnt)    _IOC(_IOC_READ, 'P', 1, cnt)

◆ IOCTL_PRINTER_RESET

#define IOCTL_PRINTER_RESET   _IOC(_IOC_NONE, 'P', 7, 0)

Function Documentation

◆ _prn_info_ieee_id_print()

static int _prn_info_ieee_id_print ( int  fd)
static

Retrieve printer's IEEE1284 ID and print it to stdout

Parameters
[in]fdThe printer's corresponding device node
Return values
0Successful
Negativeerrno else

Don't know why the kernel does not export this IOCTL command. We need a '1' command to retrieve the IEEE1284 ID and a so called 'new' style IOCTL.

Note
In the returned IEEE1284 ID data set, a 16 bit count value in big endian notation leads the string and defines the whole size of the data including itself.

◆ _prn_info_status_print()

static int _prn_info_status_print ( int  fd)
static

Retrieve the printer's status and print a decoded list

Parameters
[in]fdThe printer's corresponding device node
Return values
0Successful
Negativeerrno else

The kernel expands a signed char into an signed int. Thus, we recice a 0xffffffb0 if the printer is busy and out of paper.

◆ _prn_info_printer_reset()

static int _prn_info_printer_reset ( int  fd)
static

Reset the printer ('soft' style)

Parameters
[in]fdThe printer's corresponding device node
Return values
0Successful
Negativeerrno else

Don't know why the kernel does not export this IOCTL command. We need a '7' (e.g. IOCNR_SOFT_RESET) command to trigger a soft reset and a so called 'new' style IOCTL.

◆ handle_nls()

static void handle_nls ( void  )
static

◆ print_help()

static void print_help ( FILE *  out)
static

◆ main()

int main ( int  argc,
char **  argv 
)

Variable Documentation

◆ verbose

int verbose
static

◆ long_options

const struct option long_options[]
static
Initial value:
= {
{ .name = "verbose", .has_arg = no_argument, .val = 'v', },
{ .name = "help", .has_arg = no_argument, .val = 'h', },
{ .name = NULL, },
}