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

Some convinience functions dealing with jobs. More...

Data Structures

struct  color_model_string
 

Functions

int job_file_seek (struct document_desc *job, off_t offset)
 
ssize_t job_file_read (struct document_desc *job, void *buf, size_t count)
 
bool job_is_duplex (struct document_desc *job)
 
bool caps_rstr_job_is_duplex (struct caps_rasterizer *rstr)
 
bool job_is_collating (struct document_desc *job)
 
bool caps_rstr_job_is_collating (struct caps_rasterizer *rstr)
 
unsigned job_copies_get (struct document_desc *job)
 
unsigned caps_rstr_job_copies_get (struct caps_rasterizer *rstr)
 
static const char * job_value_get (struct document_desc *job, const char *keyword, const char *name)
 
const char * caps_rstr_job_value_get (struct caps_rasterizer *rstr, const char *keyword, const char *name)
 
static enum caps_ppd_color_formats get_color_model_macro (struct document_desc *job)
 
enum caps_ppd_color_formats caps_rstr_job_color_mode_get (struct caps_rasterizer *rstr)
 
static const char * job_medium_format_name_get (struct document_desc *job)
 
const char * caps_rstr_job_medium_format_name_get (struct caps_rasterizer *rstr)
 
static enum caps_ppd_paper_leading_edges job_medium_leading_edge_get (struct document_desc *job)
 
enum caps_ppd_paper_leading_edges caps_rstr_job_medium_orientation_get (struct caps_rasterizer *rstr)
 
struct caps_rect caps_rstr_job_medium_size_get (struct caps_rasterizer *rstr)
 
struct caps_area caps_rstr_job_medium_imageable_get (struct caps_rasterizer *rstr)
 
struct caps_area caps_rstr_job_medium_margins_get (struct caps_rasterizer *rstr)
 
static void list_ppd_db_entries (const struct caps_ppd_options_table *db)
 
static const char * job_choice_get (struct document_desc *job, const char *keyword)
 
const char * caps_rstr_job_choice_get (struct caps_rasterizer *rstr, const char *keyword)
 
const struct caps_ppd_resolutioncaps_rstr_job_resolution_get (struct caps_rasterizer *rstr)
 
const struct caps_job_progressioncaps_rstr_job_progression_get (struct caps_rasterizer *rstr)
 

Variables

static const struct color_model_string cmodels []
 Name to colour mode mapping.
 

Detailed Description

Author
Jürgen Borleis
Warning
Use as experimental

Function Documentation

◆ job_file_seek()

int job_file_seek ( struct document_desc job,
off_t  offset 
)

Wrapper to read some data from the document

Parameters
[in]jobThe job data collection
[in]offsetThe read offset in the document's file
Return values
0Successful
NegativeAn errno code from the lseek syscall

◆ job_file_read()

ssize_t job_file_read ( struct document_desc job,
void *  buf,
size_t  count 
)

Wrapper to read some data from the document

Parameters
[in]jobThe job data collection
[in,out]bufWhere to store the read data
[in]countSize in bytes of buf
Return values
PositiveThe count of bytes read from the file into buf
NegativeAn errno code from the read syscall

◆ job_is_duplex()

bool job_is_duplex ( struct document_desc job)

Check if this job should be printed in duplex mode

Parameters
[in]jobThe job data collection
Return values
truePrint in duplex mode
falsePrint in simplex mode

◆ job_is_collating()

bool job_is_collating ( struct document_desc job)

Check if this job should be printed in collating mode

Parameters
[in]jobThe job data collection
Return values
truePrint collated
falsePrint non-collated

◆ job_copies_get()

unsigned job_copies_get ( struct document_desc job)

Read the amount of media copies to print

Parameters
[in]jobThe job data collection
Returns
Amount of copies to print (never '0')

TODO can this ever happen?

◆ job_value_get()

static const char * job_value_get ( struct document_desc job,
const char *  keyword,
const char *  name 
)
static

Get the attached job specific PPD value with a special keyword out of the run-time information

Parameters
[in]jobThe description of the currently attached print job
[in]keywordKeyword to query for
[in]nameName of the parameter (can be NULL)
Return values
PointerPointer to the parameter's value
NULLIf the keyword does not exist or has no value
Attention
A keyword/name option without a value cannot be distinguished from a nonexistent keyword/name option.

Refer caps_ppd_option for details about the meaning of keyword and name.

◆ get_color_model_macro()

static enum caps_ppd_color_formats get_color_model_macro ( struct document_desc job)
static

Convert the colour name (PPD related) to the corresponding colour macro

Parameters
[in]jobThe description of the currently attached print job
Returns
The colour macro

Relies on the existence of the DefaultColorModel entry in the PPD option list.

Note
This function does not return in the case the given name is invalid

Valid colour names are listed in cmodels

◆ job_medium_format_name_get()

static const char * job_medium_format_name_get ( struct document_desc job)
static

Get the format name of the user selected print medium (or the default one defined by the printer driver)

Parameters
[in]jobThe description of the currently attached print job
Returns
The format name based on the PPD content (e.g. the corresponding option table)

Relies on the existence of the DefaultPageSize entry in the PPD option list.

Note
Does not return in the case the DefaultPageSize isn't set in the option list and in this case it seems libcapsppd is broken.
The returned string is valid, as long as the document_desc::ppd_options is valid

◆ job_medium_leading_edge_get()

static enum caps_ppd_paper_leading_edges job_medium_leading_edge_get ( struct document_desc job)
static

Get the the user selected leading edge of print medium

Parameters
[in]jobThe description of the currently attached print job
Returns
The leading edge macro

Relies on the existence of the DefaultLeadingEdge entry in the PPD option list.

Note
Does not return in the case the DefaultLeadingEdge isn't set in the option list and in this case it seems libcapsppd is broken.

◆ list_ppd_db_entries()

static void list_ppd_db_entries ( const struct caps_ppd_options_table db)
static

Print the whole list of available job configuration options for debugging purposes

Parameters
[in]dbThe table with job configuration options

The list is only visible in the logs if the library was compiled with DEBUG enabled and the run-time loglevel is at debug as well.

◆ job_choice_get()

static const char * job_choice_get ( struct document_desc job,
const char *  keyword 
)
static

Variable Documentation

◆ cmodels

const struct color_model_string cmodels[]
static
Initial value:
= {
{ .val = 0, },
{ .val = LIBCAPS_CT_MONOCHROME, .name = "Mono", },
{ .val = LIBCAPS_CT_GRAY, .name = "Gray", },
{ .val = LIBCAPS_CT_RGB, .name = "RGB", },
{ .val = LIBCAPS_CT_CMYK, .name = "CMYK", },
}
@ LIBCAPS_CT_RGB
Definition: libcapsppd.h:204
@ LIBCAPS_CT_GRAY
Definition: libcapsppd.h:203
@ LIBCAPS_CT_MONOCHROME
Definition: libcapsppd.h:202
@ LIBCAPS_CT_CMYK
Definition: libcapsppd.h:205

The used names here rely on the used names in libcapsppd!