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

Full functional printing provider reference implementation. More...

Data Structures

struct  reference_driver
 

Macros

#define MM2PTS(mm)   (mm * 72.0 / 25.4)
 
#define MEDIUM_NAME   "LABEL"
 

Functions

static void sig_handler (int sig)
 
static int printer_prepare_page (struct reference_driver *printer, const struct caps_rstr_page_desc *pg_desc, struct caps_rstr_page *pg)
 
int rpp_raster_write (struct caps_rasterizer *rstr, const struct caps_rstr_raster *raster, const struct caps_rstr_page_desc *pg_desc, const struct caps_rstr_page *pg)
 
static int printer_job_process (struct reference_driver *printer, struct caps_pp_document_desc *job)
 
static void printer_shutdown_report (struct reference_driver *printer)
 
static void printer_idle_report (struct reference_driver *printer)
 
static void printer_start_up_state_report (struct reference_driver *printer)
 
static int printer_device_setup (struct reference_driver *printer)
 
static void printer_device_shutdown (struct reference_driver *printer)
 
static int printer_runtime_adaptions (struct reference_driver *printer)
 
static int base_printer_info_implant (struct caps_pp_handle *instance)
 
static int verbose_cb (const struct caps_arg_parser *parser, const char *value)
 
static int emul_colour_cb (const struct caps_arg_parser *parser, const char *value)
 
static int emul_type_cb (const struct caps_arg_parser *parser, const char *value)
 
int main (int argc, char *argv[])
 

Variables

static struct reference_driver printer
 
static volatile sig_atomic_t quit = 0
 
static const struct caps_ppd_resolution supported_resolutions []
 
static const struct caps_ppd_media_margins media_margins
 
static const struct caps_ppd_media_size media_coverage
 
static struct caps_ppd_base printers_capabilities
 
static const struct caps_ppd_custom_medium label_medium
 
static const struct caps_ppd_resolution label_res []
 
static const struct caps_ppd_media_size label_min_max_medium
 
static const struct caps_ppd_media_margins label_margins
 
static struct caps_ppd_base label_printer_capability
 
static const struct caps_arg_parameter ref_prn_arguments []
 
static struct caps_arg_parser ref_prn_parser [2]
 

Detailed Description

Author
Jürgen Borleis
Version
1.0.0
Warning
Use as experimental

There is different printing provider implementation in the caps-printing-provider package, but this one here also uses libcapsraster to really rasterize the image and thus, can be used as a starting point for a real printing driver.

Macro Definition Documentation

◆ MM2PTS

#define MM2PTS (   mm)    (mm * 72.0 / 25.4)

◆ MEDIUM_NAME

#define MEDIUM_NAME   "LABEL"

Function Documentation

◆ sig_handler()

static void sig_handler ( int  sig)
static

◆ printer_prepare_page()

static int printer_prepare_page ( struct reference_driver printer,
const struct caps_rstr_page_desc pg_desc,
struct caps_rstr_page pg 
)
static

◆ rpp_raster_write()

int rpp_raster_write ( struct caps_rasterizer rstr,
const struct caps_rstr_raster raster,
const struct caps_rstr_page_desc pg_desc,
const struct caps_rstr_page pg 
)

◆ printer_job_process()

static int printer_job_process ( struct reference_driver printer,
struct caps_pp_document_desc job 
)
static

◆ printer_shutdown_report()

static void printer_shutdown_report ( struct reference_driver printer)
static

Shutting down the printing service

Parameters
[in,out]printerOur information collection

◆ printer_idle_report()

static void printer_idle_report ( struct reference_driver printer)
static

Report this printer is now idle and waiting for jobs

Parameters
[in,out]printerOur information collection

◆ printer_start_up_state_report()

static void printer_start_up_state_report ( struct reference_driver printer)
static

Report this printer is now starting up

Parameters
[in,out]printerOur information collection

This will make the printer visible at the printing provider, but still signal it does not accept jobs, yet.

◆ printer_device_setup()

static int printer_device_setup ( struct reference_driver printer)
static

◆ printer_device_shutdown()

static void printer_device_shutdown ( struct reference_driver printer)
static

Do last things to clean up

Note
No longer connected to the printing coordinator

◆ printer_runtime_adaptions()

static int printer_runtime_adaptions ( struct reference_driver printer)
static

Adapt our settings to configured one

Parameters
[in,out]printerOur information collection
Return values
0On sucess
NegativeErrno else

caps_pp_instance_runtime_prepare() might had read in all kind of INI files and we can now request for these settings.

What can be changed/adapted here? For example:

  • the loaded paper type and format
  • some special printer behaviour (generic printer driver for specific printer device)

The information read from the INI files can be retrieved via a call to caps_pp_instance_runtime_param_get()

◆ base_printer_info_implant()

static int base_printer_info_implant ( struct caps_pp_handle instance)
static

Setup some fake information to make the coordinator happy while testing

This is just a development feature, to avoid a fully setup environment.

◆ verbose_cb()

static int verbose_cb ( const struct caps_arg_parser parser,
const char *  value 
)
static

◆ emul_colour_cb()

static int emul_colour_cb ( const struct caps_arg_parser parser,
const char *  value 
)
static

◆ emul_type_cb()

static int emul_type_cb ( const struct caps_arg_parser parser,
const char *  value 
)
static

◆ main()

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

Variable Documentation

◆ printer

struct reference_driver printer
static

Global instance information

◆ quit

volatile sig_atomic_t quit = 0
static

Global quit information. The driver prepares for termination if quit is non-null

◆ supported_resolutions

const struct caps_ppd_resolution supported_resolutions[]
static
Initial value:
= {
{ .horizontal = 300.0, .vertical = 300.0, },
{ .horizontal = 600.0, .vertical = 600.0, },
{ .horizontal = 1200.0, .vertical = 600.0, },
}

◆ media_margins

const struct caps_ppd_media_margins media_margins
static
Initial value:
= {
.left = ( 4.0 * 72.0 / 25.4), .right = ( 4.0 * 72.0 / 25.4),
.top = ( 15.0 * 72.0 / 25.4), .bottom = ( 20.0 * 72.0 / 25.4),
}

◆ media_coverage

const struct caps_ppd_media_size media_coverage
static
Initial value:
= {
.width_min = 250.0, .width_max = 612.0,
.height_min = 300.0, .height_max = 841.89,
}

◆ printers_capabilities

struct caps_ppd_base printers_capabilities
static
Initial value:
= {
.paper_type = LIBCAPS_PT_SINGLE,
.default_leading_edges = 0,
.supported_color_formats = LIBCAPS_CT_MONOCHROME | LIBCAPS_CT_GRAY | LIBCAPS_CT_RGB,
.default_color_format = LIBCAPS_CT_GRAY,
.resolution_count = ARRAY_SIZE(supported_resolutions),
.default_resolution = 0,
.resolutions = supported_resolutions,
.media_coverage = &media_coverage,
.default_paper_name = "A4",
.media_margins = &media_margins,
}
@ LIBCAPS_CT_RGB
Definition: libcapsppd.h:204
@ LIBCAPS_CT_GRAY
Definition: libcapsppd.h:203
@ LIBCAPS_CT_MONOCHROME
Definition: libcapsppd.h:202
@ LIBCAPS_GA_MANUAL_FEED
Definition: libcapsppd.h:216
@ LIBCAPS_GA_DUPLEX
Definition: libcapsppd.h:214
@ LIBCAPS_GA_SINGLE_TRAY
Definition: libcapsppd.h:215
@ LIBCAPS_PT_SINGLE
Definition: libcapsppd.h:37
#define ARRAY_SIZE(x)
Definition: libcapsbase-local.h:37
static const struct caps_ppd_media_size media_coverage
Definition: reference-printing-provider.c:80
static const struct caps_ppd_resolution supported_resolutions[]
Definition: reference-printing-provider.c:68
static const struct caps_ppd_media_margins media_margins
Definition: reference-printing-provider.c:74

Some emulated printers for testing purposes TODO add docs

◆ label_medium

const struct caps_ppd_custom_medium label_medium
static
Initial value:
= {
.name = "LABEL" ,
.description = "User defined label roll",
.width = ( 62.0 * 72.0 / 25.4), .length = ( 1000.0 * 72.0 / 25.4),
.left = ( 0.2 * 72.0 / 25.4), .right = ( 0.8 * 72.0 / 25.4), .top = ( 3.0 * 72.0 / 25.4), .bottom = ( 3.0 * 72.0 / 25.4),
}

◆ label_res

const struct caps_ppd_resolution label_res[]
static
Initial value:
= {
{ .horizontal = 300, .vertical = 300, },
{ .horizontal = 300, .vertical = 600, },
}

◆ label_min_max_medium

const struct caps_ppd_media_size label_min_max_medium
static
Initial value:
= {
.width_min = ( 12.0 * 72.0 / 25.4),
.width_max = ( 62.0 * 72.0 / 25.4),
.height_min = ( 13.0 * 72.0 / 25.4),
.height_max = ( 1000.0 * 72.0 / 25.4),
}

◆ label_margins

const struct caps_ppd_media_margins label_margins
static
Initial value:
= {
.left = ( 0.2 * 72.0 / 25.4), .right = ( 0.8 * 72.0 / 25.4),
.top = ( 3.0 * 72.0 / 25.4), .bottom = ( 3.0 * 72.0 / 25.4),
}

◆ label_printer_capability

struct caps_ppd_base label_printer_capability
static
Initial value:
= {
.domain_name = NULL,
.paper_type = LIBCAPS_PT_ENDLESS,
.default_leading_edges = LIBCAPS_PLE_SHORT | LIBCAPS_PLE_MINUS_90_DEGREE,
.supported_color_formats = LIBCAPS_CT_GRAY | LIBCAPS_CT_RGB,
.default_color_format = LIBCAPS_CT_GRAY,
.resolution_count = ARRAY_SIZE(label_res),
.default_resolution = 0,
.resolutions = label_res,
.custom_media_count = 1,
.custom_media = &label_medium,
.default_paper_name = "LABEL" ,
.media_coverage = &label_min_max_medium,
.media_margins = &label_margins,
}
@ LIBCAPS_GA_CUTTER
Definition: libcapsppd.h:218
@ LIBCAPS_GA_CUSTOM_MEDIA
Definition: libcapsppd.h:217
@ LIBCAPS_PT_ENDLESS
Definition: libcapsppd.h:38
@ LIBCAPS_PLE_MINUS_90_DEGREE
Definition: libcapsppd.h:151
@ LIBCAPS_PLE_SHORT
Definition: libcapsppd.h:148
static const struct caps_ppd_custom_medium label_medium
Definition: reference-printing-provider.c:108
static const struct caps_ppd_resolution label_res[]
Definition: reference-printing-provider.c:115
static const struct caps_ppd_media_size label_min_max_medium
Definition: reference-printing-provider.c:121
static const struct caps_ppd_media_margins label_margins
Definition: reference-printing-provider.c:128

A label printer with a continuous roll feature

◆ ref_prn_arguments

const struct caps_arg_parameter ref_prn_arguments[]
static
Initial value:
= {
{
.keyword = "verbose", .key = 'v', .cb = verbose_cb,
.flags = CAPS_PARAM_OPTIONAL, .doc = "Produce verbose output",
}, {
.keyword = "emul-colour", .key = 'e', .arg = "TYPE",
.doc = "Emulated colour support: 'monochrome' (the default), 'grey' or 'colour'",
}, {
.keyword = "emul-type", .key = 't', .arg = "TYPE",
.doc = "Emulated printer type: 'laser' (the default) or 'label'",
}
}
@ CAPS_PARAM_OPTIONAL
Definition: libcapscmdparser.h:273
static int emul_colour_cb(const struct caps_arg_parser *parser, const char *value)
Definition: reference-printing-provider.c:381
static int verbose_cb(const struct caps_arg_parser *parser, const char *value)
Definition: reference-printing-provider.c:373
static int emul_type_cb(const struct caps_arg_parser *parser, const char *value)
Definition: reference-printing-provider.c:395

The parameters we understand here in the main application

◆ ref_prn_parser

struct caps_arg_parser ref_prn_parser[2]
static
Initial value:
= {
[0] = {
.parameter_cnt = ARRAY_SIZE(ref_prn_arguments),
.parameter_list = ref_prn_arguments,
.header = "Printer driver arguments",
.footer = "These arguments are optional",
.domain = PACKAGE,
}
}
static const struct caps_arg_parameter ref_prn_arguments[]
Definition: reference-printing-provider.c:408