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

A simple printing provider demo, emulating some kind of printers. More...

Macros

#define PAGES_TO_PRINT   10
 

Functions

static void simulate_printing (struct caps_pp_handle *instance, struct caps_pp_document_desc *job)
 
static int process_job (struct caps_pp_handle *instance, struct caps_pp_document_desc *job)
 
void sig_handler (int sig)
 
static void shutdown_service (struct caps_pp_handle *instance)
 
static void setup_run_time_info (struct caps_pp_handle *instance)
 
static int base_printer_info_implant (struct caps_pp_handle *instance)
 
static int emul_printer_cb (const struct caps_arg_parser *parser, const char *value)
 
static int emul_crash_cb (const struct caps_arg_parser *parser, const char *value)
 
int main (int argc, char *argv[])
 

Variables

static int emul_crash = 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 const struct caps_ppd_base printers []
 
static volatile sig_atomic_t quit = 0
 
static int warm_up_wait
 
unsigned print_wait
 
static int paper_empty
 
static int paper_jam
 
static size_t emul_printer = 1
 
static const struct caps_arg_parameter test_provider_argument []
 
static struct caps_arg_parser test_provider_parser [2]
 
static char * mime_format [3]
 
static const struct caps_supported_mime_list mime_list
 

Detailed Description

This application is mostly intended for testing purposes. Don't use it as a template for your own driver. Use the example in libcapsraster or - much better - the skeleton from the libcapsdriver instead.

Note
This file isn't part of NLS and thus, all strings are plain English.

Macro Definition Documentation

◆ PAGES_TO_PRINT

#define PAGES_TO_PRINT   10

Function Documentation

◆ simulate_printing()

static void simulate_printing ( struct caps_pp_handle instance,
struct caps_pp_document_desc job 
)
static

Simulate the printing of PAGES_TO_PRINT pages

Parameters
[in]instanceOur insance handle to communicate with the printing provider
[in,out]jobThe job to print

Prints PAGES_TO_PRINT pages (full duplex), with a pause of print_wait ms each

◆ process_job()

static int process_job ( struct caps_pp_handle instance,
struct caps_pp_document_desc job 
)
static

Simulate the printing of a document

Parameters
[in]instanceOur insance handle to communicate with the printing provider
[in,out]jobThe job to print

◆ sig_handler()

void sig_handler ( int  sig)

◆ shutdown_service()

static void shutdown_service ( struct caps_pp_handle instance)
static

◆ setup_run_time_info()

static void setup_run_time_info ( struct caps_pp_handle instance)
static

◆ 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

◆ emul_printer_cb()

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

Command line parser callback for the --printer keyword

Parameters
[in]parserOur own parser
[in]valueThe parameter's value

◆ emul_crash_cb()

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

Command line parser callback for the --crash keyword

Parameters
[in]parserOur own parser
[in]valueThe parameter's value

◆ main()

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

Variable Documentation

◆ emul_crash

int emul_crash = 0
static

The printer should simulate a crash while printing.

This crash should test, if the printing coordinator cleans up the related resources and notifies clients.

◆ 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 = 12.0,
.right = 12.0,
.top = 25.0,
.bottom = 12.0,
}

◆ media_coverage

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

◆ printers

const struct caps_ppd_base printers[]
static

Some emulated printers for testing purposes

◆ quit

volatile sig_atomic_t quit = 0
static

◆ warm_up_wait

int warm_up_wait
static

◆ print_wait

unsigned print_wait

◆ paper_empty

int paper_empty
static

◆ paper_jam

int paper_jam
static

◆ emul_printer

size_t emul_printer = 1
static

The printer to emulate. Refer the printers table for details

◆ test_provider_argument

const struct caps_arg_parameter test_provider_argument[]
static
Initial value:
= {
{
.keyword = "printer", .key = 'p', .cb = emul_printer_cb,
.arg = "NUMBER", .flags = CAPS_PARAM_OPTIONAL,
.doc = "Emulated printer (1…3), default is the first one",
}, {
.keyword = "crash", .key = 'c', .cb = emul_crash_cb,
.doc = "Emulate a crash while emulating printing",
}
}
static int emul_printer_cb(const struct caps_arg_parser *parser, const char *value)
Definition: caps-printing-test-provider.c:343
static int emul_crash_cb(const struct caps_arg_parser *parser, const char *value)
Definition: caps-printing-test-provider.c:354
@ CAPS_PARAM_OPTIONAL
Definition: libcapscmdparser.h:273

This test provider has one additional optional parameter.

◆ test_provider_parser

struct caps_arg_parser test_provider_parser[2]
static
Initial value:
= {
{
.parameter_cnt = (sizeof( test_provider_argument )/sizeof( test_provider_argument [0])),
.parameter_list = test_provider_argument,
.header = "Driver specific options",
},
}
static const struct caps_arg_parameter test_provider_argument[]
Definition: caps-printing-test-provider.c:364

The application's argument parser

Attention
Requires two entries. The first for this application and the second one gets filled by caps_pp_instance_create()

◆ mime_format

char* mime_format[3]
static
Initial value:
= {
"application/pdf",
"application/postscript",
"application/octed-stream",
}

The document formats we 'emulate'

◆ mime_list

const struct caps_supported_mime_list mime_list
static
Initial value:
= {
.format = mime_format,
.cnt = 3,
}
static char * mime_format[3]
Definition: caps-printing-test-provider.c:393

Emulated list of supported MIME formats of this provider